MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_ksocket_rcvmsg

Function ng_ksocket_rcvmsg

freebsd/netgraph/ng_ksocket.c:659–876  ·  view source on GitHub ↗

* Receive a control message */

Source from the content-addressed store, hash-verified

657 * Receive a control message
658 */
659static int
660ng_ksocket_rcvmsg(node_p node, item_p item, hook_p lasthook)
661{
662 struct thread *td = curthread; /* XXX broken */
663 const priv_p priv = NG_NODE_PRIVATE(node);
664 struct socket *const so = priv->so;
665 struct ng_mesg *resp = NULL;
666 int error = 0;
667 struct ng_mesg *msg;
668 ng_ID_t raddr;
669
670 NGI_GET_MSG(item, msg);
671 switch (msg->header.typecookie) {
672 case NGM_KSOCKET_COOKIE:
673 switch (msg->header.cmd) {
674 case NGM_KSOCKET_BIND:
675 {
676 struct sockaddr *const sa
677 = (struct sockaddr *)msg->data;
678
679 /* Sanity check */
680 if (msg->header.arglen < SADATA_OFFSET
681 || msg->header.arglen < sa->sa_len)
682 ERROUT(EINVAL);
683 if (so == NULL)
684 ERROUT(ENXIO);
685
686 /* Bind */
687 error = sobind(so, sa, td);
688 break;
689 }
690 case NGM_KSOCKET_LISTEN:
691 {
692 /* Sanity check */
693 if (msg->header.arglen != sizeof(int32_t))
694 ERROUT(EINVAL);
695 if (so == NULL)
696 ERROUT(ENXIO);
697
698 /* Listen */
699 so->so_state |= SS_NBIO;
700 error = solisten(so, *((int32_t *)msg->data), td);
701 break;
702 }
703
704 case NGM_KSOCKET_ACCEPT:
705 {
706 /* Sanity check */
707 if (msg->header.arglen != 0)
708 ERROUT(EINVAL);
709 if (so == NULL)
710 ERROUT(ENXIO);
711
712 /* Make sure the socket is capable of accepting */
713 if (!(so->so_options & SO_ACCEPTCONN))
714 ERROUT(EINVAL);
715 if (priv->flags & KSF_ACCEPTING)
716 ERROUT(EALREADY);

Callers

nothing calls this directly

Calls 7

sobindFunction · 0.85
solistenFunction · 0.85
soconnectFunction · 0.85
sogetoptFunction · 0.85
sosetoptFunction · 0.85
ng_ksocket_acceptFunction · 0.70
freeFunction · 0.50

Tested by

no test coverage detected