5 * Copyright (c) 1996-1999 Whistle Communications, Inc.
8 * Subject to the following obligations and disclaimer of warranty, use and
9 * redistribution of this software, in source or object code forms, with or
10 * without modifications are expressly permitted by Whistle Communications;
11 * provided, however, that:
12 * 1. Any and all reproductions of the source or object code must include the
13 * copyright notice above and the following disclaimer of warranties; and
14 * 2. No rights are granted, in any manner or form, to use Whistle
15 * Communications, Inc. trademarks, including the mark "WHISTLE
16 * COMMUNICATIONS" on advertising, endorsements, or otherwise except as
17 * such appears in the above copyright notice or in the software.
19 * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
20 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
21 * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
22 * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
25 * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
26 * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
27 * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
28 * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
29 * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
30 * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
37 * Author: Julian Elischer <julian@freebsd.org>
39 * $FreeBSD: src/sys/netgraph/ng_socket.c,v 1.11.2.6 2002/07/02 22:17:18 archie Exp $
40 * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.14 2007/06/03 20:51:13 dillon Exp $
41 * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $
45 * Netgraph socket nodes
47 * There are two types of netgraph sockets, control and data.
48 * Control sockets have a netgraph node, but data sockets are
49 * parasitic on control sockets, and have no node of their own.
52 #include <sys/param.h>
53 #include <sys/systm.h>
55 #include <sys/domain.h>
56 #include <sys/errno.h>
57 #include <sys/kernel.h>
58 #include <sys/filedesc.h>
59 #include <sys/malloc.h>
60 #include <sys/queue.h>
62 #include <sys/protosw.h>
63 #include <sys/socket.h>
64 #include <sys/socketvar.h>
65 #include <sys/sysctl.h>
66 #include <sys/thread2.h>
68 #include <sys/vnode.h>
70 #include <netgraph/ng_message.h>
71 #include <netgraph/netgraph.h>
72 #include "ng_socketvar.h"
73 #include "ng_socket.h"
76 * It's Ascii-art time!
77 * +-------------+ +-------------+
78 * |socket (ctl)| |socket (data)|
79 * +-------------+ +-------------+
83 * +-----------+ +-----------+
84 * |pcb (ctl)| |pcb (data)|
85 * +-----------+ +-----------+
89 * +--------------------------+
90 * | Socket type private |
92 * +--------------------------+
101 /* Netgraph node methods */
102 static ng_constructor_t ngs_constructor;
103 static ng_rcvmsg_t ngs_rcvmsg;
104 static ng_shutdown_t ngs_rmnode;
105 static ng_newhook_t ngs_newhook;
106 static ng_rcvdata_t ngs_rcvdata;
107 static ng_disconnect_t ngs_disconnect;
109 /* Internal methods */
110 static int ng_attach_data(struct socket *so);
111 static int ng_attach_cntl(struct socket *so);
112 static int ng_attach_common(struct socket *so, int type);
113 static void ng_detach_common(struct ngpcb *pcbp, int type);
114 /*static int ng_internalize(struct mbuf *m, struct thread *td); */
116 static int ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp);
117 static int ng_connect_cntl(struct sockaddr *nam, struct ngpcb *pcbp);
118 static int ng_bind(struct sockaddr *nam, struct ngpcb *pcbp);
120 static int ngs_mod_event(module_t mod, int event, void *data);
121 static int ship_msg(struct ngpcb *pcbp, struct ng_mesg *msg,
122 struct sockaddr_ng *addr);
124 /* Netgraph type descriptor */
125 static struct ng_type typestruct = {
140 NETGRAPH_INIT(socket, &typestruct);
143 static u_long ngpdg_sendspace = 20 * 1024; /* really max datagram size */
144 static u_long ngpdg_recvspace = 20 * 1024;
146 /* List of all sockets */
147 LIST_HEAD(, ngpcb) ngsocklist;
149 #define sotongpcb(so) ((struct ngpcb *)(so)->so_pcb)
151 /* If getting unexplained errors returned, set this to "Debugger("X"); */
156 /***************************************************************
158 ***************************************************************/
161 ngc_attach(struct socket *so, int proto, struct pru_attach_info *ai)
163 struct ngpcb *const pcbp = sotongpcb(so);
165 if (suser_cred(ai->p_ucred, NULL_CRED_OKAY) != 0)
169 return (ng_attach_cntl(so));
173 ngc_detach(struct socket *so)
175 struct ngpcb *const pcbp = sotongpcb(so);
179 ng_detach_common(pcbp, NG_CONTROL);
184 ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
185 struct mbuf *control, struct thread *td)
187 struct ngpcb *const pcbp = sotongpcb(so);
188 struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
189 struct ng_mesg *resp;
191 char *msg, *path = NULL;
199 if (control && (error = ng_internalize(control, p))) {
200 if (pcbp->sockdata == NULL) {
212 /* Require destination as there may be >= 1 hooks on this node */
214 error = EDESTADDRREQ;
218 /* Allocate an expendable buffer for the path, chop off
219 * the sockaddr header, and make sure it's NUL terminated */
220 len = sap->sg_len - 2;
221 MALLOC(path, char *, len + 1, M_NETGRAPH, M_WAITOK);
226 bcopy(sap->sg_data, path, len);
229 /* Move the actual message out of mbufs into a linear buffer.
230 * Start by adding up the size of the data. (could use mh_len?) */
231 for (len = 0, m0 = m; m0 != NULL; m0 = m0->m_next)
234 /* Move the data into a linear buffer as well. Messages are not
235 * delivered in mbufs. */
236 MALLOC(msg, char *, len + 1, M_NETGRAPH, M_WAITOK);
241 m_copydata(m, 0, len, msg);
243 /* The callee will free the msg when done. The addr is our business. */
244 error = ng_send_msg(pcbp->sockdata->node,
245 (struct ng_mesg *) msg, path, &resp);
247 /* If the callee responded with a synchronous response, then put it
248 * back on the receive side of the socket; sap is source address. */
249 if (error == 0 && resp != NULL)
250 error = ship_msg(pcbp, resp, sap);
254 FREE(path, M_NETGRAPH);
263 ngc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
265 struct ngpcb *const pcbp = sotongpcb(so);
269 return (ng_bind(nam, pcbp));
273 ngc_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
275 struct ngpcb *const pcbp = sotongpcb(so);
279 return (ng_connect_cntl(nam, pcbp));
282 /***************************************************************
284 ***************************************************************/
287 ngd_attach(struct socket *so, int proto, struct pru_attach_info *ai)
289 struct ngpcb *const pcbp = sotongpcb(so);
293 return (ng_attach_data(so));
297 ngd_detach(struct socket *so)
299 struct ngpcb *const pcbp = sotongpcb(so);
303 ng_detach_common(pcbp, NG_DATA);
308 ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
309 struct mbuf *control, struct thread *td)
311 struct ngpcb *const pcbp = sotongpcb(so);
312 struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
316 char hookname[NG_HOOKSIZ];
318 if ((pcbp == NULL) || (control != NULL)) {
322 if (pcbp->sockdata == NULL) {
327 * If the user used any of these ways to not specify an address
328 * then handle specially.
331 || ((len = sap->sg_len - 2) <= 0)
332 || (*sap->sg_data == '\0')) {
333 if (pcbp->sockdata->node->numhooks != 1) {
334 error = EDESTADDRREQ;
338 * if exactly one hook exists, just use it.
339 * Special case to allow write(2) to work on an ng_socket.
341 hook = LIST_FIRST(&pcbp->sockdata->node->hooks);
343 if (len >= NG_HOOKSIZ) {
349 * chop off the sockaddr header, and make sure it's NUL
352 bcopy(sap->sg_data, hookname, len);
353 hookname[len] = '\0';
355 /* Find the correct hook from 'hookname' */
356 LIST_FOREACH(hook, &pcbp->sockdata->node->hooks, hooks) {
357 if (strcmp(hookname, hook->name) == 0)
361 error = EHOSTUNREACH;
364 /* Send data (OK if hook is NULL) */
365 NG_SEND_DATA(error, hook, m, mp); /* makes m NULL */
376 ngd_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
378 struct ngpcb *const pcbp = sotongpcb(so);
382 return (ng_connect_data(nam, pcbp));
386 * Used for both data and control sockets
389 ng_setsockaddr(struct socket *so, struct sockaddr **addr)
392 struct sockaddr_ng *sg;
395 /* Why isn't sg_data a `char[1]' ? :-( */
396 sg_len = sizeof(struct sockaddr_ng) - sizeof(sg->sg_data) + 1;
399 pcbp = sotongpcb(so);
400 if ((pcbp == 0) || (pcbp->sockdata == NULL)) {
405 namelen = 0; /* silence compiler ! */
407 if (pcbp->sockdata->node->name != NULL)
408 sg_len += namelen = strlen(pcbp->sockdata->node->name);
410 MALLOC(sg, struct sockaddr_ng *, sg_len, M_SONAME, M_WAITOK);
413 if (pcbp->sockdata->node->name != NULL)
414 bcopy(pcbp->sockdata->node->name, sg->sg_data, namelen);
418 sg->sg_family = AF_NETGRAPH;
419 *addr = (struct sockaddr *)sg;
425 * Attach a socket to it's protocol specific partner.
426 * For a control socket, actually create a netgraph node and attach
431 ng_attach_cntl(struct socket *so)
433 struct ngsock *privdata;
437 /* Setup protocol control block */
438 if ((error = ng_attach_common(so, NG_CONTROL)) != 0)
440 pcbp = sotongpcb(so);
442 /* Allocate node private info */
443 MALLOC(privdata, struct ngsock *,
444 sizeof(*privdata), M_NETGRAPH, M_WAITOK);
445 if (privdata == NULL) {
446 ng_detach_common(pcbp, NG_CONTROL);
449 bzero(privdata, sizeof(*privdata));
451 /* Make the generic node components */
452 if ((error = ng_make_node_common(&typestruct, &privdata->node)) != 0) {
453 FREE(privdata, M_NETGRAPH);
454 ng_detach_common(pcbp, NG_CONTROL);
457 privdata->node->private = privdata;
459 /* Link the pcb and the node private data */
460 privdata->ctlsock = pcbp;
461 pcbp->sockdata = privdata;
467 ng_attach_data(struct socket *so)
469 return(ng_attach_common(so, NG_DATA));
473 * Set up a socket protocol control block.
474 * This code is shared between control and data sockets.
477 ng_attach_common(struct socket *so, int type)
482 /* Standard socket setup stuff */
483 error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace, NULL);
487 /* Allocate the pcb */
488 MALLOC(pcbp, struct ngpcb *, sizeof(*pcbp), M_PCB, M_WAITOK);
491 bzero(pcbp, sizeof(*pcbp));
494 /* Link the pcb and the socket */
495 so->so_pcb = (caddr_t) pcbp;
496 pcbp->ng_socket = so;
498 /* Add the socket to linked list */
499 LIST_INSERT_HEAD(&ngsocklist, pcbp, socks);
504 * Disassociate the socket from it's protocol specific
505 * partner. If it's attached to a node's private data structure,
506 * then unlink from that too. If we were the last socket attached to it,
507 * then shut down the entire node. Shared code for control and data sockets.
510 ng_detach_common(struct ngpcb *pcbp, int which)
512 struct ngsock *sockdata;
514 if (pcbp->sockdata) {
515 sockdata = pcbp->sockdata;
516 pcbp->sockdata = NULL;
519 sockdata->ctlsock = NULL;
522 sockdata->datasock = NULL;
527 if ((--sockdata->refs == 0) && (sockdata->node != NULL))
528 ng_rmnode(sockdata->node);
530 pcbp->ng_socket->so_pcb = NULL;
531 pcbp->ng_socket = NULL;
532 LIST_REMOVE(pcbp, socks);
538 * File descriptors can be passed into a AF_NETGRAPH socket.
539 * Note, that file descriptors cannot be passed OUT.
540 * Only character device descriptors are accepted.
541 * Character devices are useful to connect a graph to a device,
542 * which after all is the purpose of this whole system.
545 ng_internalize(struct mbuf *control, struct thread *td)
547 struct filedesc *fdp = p->p_fd;
548 const struct cmsghdr *cm = mtod(control, const struct cmsghdr *);
554 if (cm->cmsg_type != SCM_RIGHTS || cm->cmsg_level != SOL_SOCKET ||
555 cm->cmsg_len != control->m_len) {
560 /* Check there is only one FD. XXX what would more than one signify? */
561 oldfds = (cm->cmsg_len - sizeof(*cm)) / sizeof(int);
567 /* Check that the FD given is legit. and change it to a pointer to a
569 fd = *(int *) (cm + 1);
570 if ((unsigned) fd >= fdp->fd_nfiles
571 || (fp = fdp->fd_files[fd].fp) == NULL) {
575 /* Depending on what kind of resource it is, act differently. For
576 * devices, we treat it as a file. For a AF_NETGRAPH socket,
577 * shortcut straight to the node. */
578 switch (fp->f_type) {
580 vn = (struct vnode *) fp->f_data;
581 if (vn && (vn->v_type == VCHR)) {
582 /* for a VCHR, actually reference the FILE */
584 /* XXX then what :) */
585 /* how to pass on to other modules? */
600 * Connect the data socket to a named control socket node.
603 ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp)
605 struct sockaddr_ng *sap;
607 struct ngsock *sockdata;
610 /* If we are already connected, don't do it again */
611 if (pcbp->sockdata != NULL)
614 /* Find the target (victim) and check it doesn't already have a data
615 * socket. Also check it is a 'socket' type node. */
616 sap = (struct sockaddr_ng *) nam;
617 if ((error = ng_path2node(NULL, sap->sg_data, &farnode, NULL)))
620 if (strcmp(farnode->type->name, NG_SOCKET_NODE_TYPE) != 0)
622 sockdata = farnode->private;
623 if (sockdata->datasock != NULL)
626 /* Link the PCB and the private data struct. and note the extra
628 sockdata->datasock = pcbp;
629 pcbp->sockdata = sockdata;
635 * Connect the existing control socket node to a named node:hook.
636 * The hook we use on this end is the same name as the remote node name.
639 ng_connect_cntl(struct sockaddr *nam, struct ngpcb *pcbp)
641 struct ngsock *const sockdata = pcbp->sockdata;
642 struct sockaddr_ng *sap;
647 sap = (struct sockaddr_ng *) nam;
648 rtn = ng_path_parse(sap->sg_data, &node, NULL, &hook);
649 if (rtn < 0 || node == NULL || hook == NULL) {
653 farnode = ng_findname(sockdata->node, node);
654 if (farnode == NULL) {
656 return (EADDRNOTAVAIL);
659 /* Connect, using a hook name the same as the far node name. */
660 error = ng_con_nodes(sockdata->node, node, farnode, hook);
665 * Binding a socket means giving the corresponding node a name
668 ng_bind(struct sockaddr *nam, struct ngpcb *pcbp)
670 struct ngsock *const sockdata = pcbp->sockdata;
671 struct sockaddr_ng *const sap = (struct sockaddr_ng *) nam;
673 if (sockdata == NULL) {
677 if (sap->sg_len < 3 || sap->sg_data[sap->sg_len - 3] != '\0') {
681 return (ng_name_node(sockdata->node, sap->sg_data));
685 * Take a message and pass it up to the control socket associated
689 ship_msg(struct ngpcb *pcbp, struct ng_mesg *msg, struct sockaddr_ng *addr)
691 struct socket *const so = pcbp->ng_socket;
695 /* Copy the message itself into an mbuf chain */
696 msglen = sizeof(struct ng_mesg) + msg->header.arglen;
697 mdata = m_devget((caddr_t) msg, msglen, 0, NULL, NULL);
699 /* Here we free the message, as we are the end of the line.
700 * We need to do that regardless of whether we got mbufs. */
701 FREE(msg, M_NETGRAPH);
708 /* Send it up to the socket */
709 if (ssb_appendaddr(&so->so_rcv,
710 (struct sockaddr *) addr, mdata, NULL) == 0) {
720 * You can only create new nodes from the socket end of things.
723 ngs_constructor(node_p *nodep)
729 * We allow any hook to be connected to the node.
730 * There is no per-hook private information though.
733 ngs_newhook(node_p node, hook_p hook, const char *name)
735 hook->private = node->private;
740 * Incoming messages get passed up to the control socket.
741 * Unless they are for us specifically (socket_type)
744 ngs_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
745 struct ng_mesg **resp)
747 struct ngsock *const sockdata = node->private;
748 struct ngpcb *const pcbp = sockdata->ctlsock;
749 struct sockaddr_ng *addr;
753 /* Only allow mesgs to be passed if we have the control socket.
754 * Data sockets can only support the generic messages. */
760 if (msg->header.typecookie == NGM_SOCKET_COOKIE) {
761 switch (msg->header.cmd) {
762 case NGM_SOCK_CMD_NOLINGER:
763 sockdata->flags |= NGS_FLAG_NOLINGER;
765 case NGM_SOCK_CMD_LINGER:
766 sockdata->flags &= ~NGS_FLAG_NOLINGER;
769 error = EINVAL; /* unknown command */
771 /* Free the message and return */
772 FREE(msg, M_NETGRAPH);
776 /* Get the return address into a sockaddr */
777 if ((retaddr == NULL) || (*retaddr == '\0'))
779 addrlen = strlen(retaddr);
780 MALLOC(addr, struct sockaddr_ng *, addrlen + 4, M_NETGRAPH, M_NOWAIT);
785 addr->sg_len = addrlen + 3;
786 addr->sg_family = AF_NETGRAPH;
787 bcopy(retaddr, addr->sg_data, addrlen);
788 addr->sg_data[addrlen] = '\0';
791 error = ship_msg(pcbp, msg, addr);
792 FREE(addr, M_NETGRAPH);
797 * Receive data on a hook
800 ngs_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
802 struct ngsock *const sockdata = hook->node->private;
803 struct ngpcb *const pcbp = sockdata->datasock;
805 struct sockaddr_ng *addr;
806 char *addrbuf[NG_HOOKSIZ + 4];
809 /* If there is no data socket, black-hole it */
811 NG_FREE_DATA(m, meta);
814 so = pcbp->ng_socket;
816 /* Get the return address into a sockaddr. */
817 addrlen = strlen(hook->name); /* <= NG_HOOKSIZ - 1 */
818 addr = (struct sockaddr_ng *) addrbuf;
819 addr->sg_len = addrlen + 3;
820 addr->sg_family = AF_NETGRAPH;
821 bcopy(hook->name, addr->sg_data, addrlen);
822 addr->sg_data[addrlen] = '\0';
824 /* We have no use for the meta data, free/clear it now. */
827 /* Try to tell the socket which hook it came in on */
828 if (ssb_appendaddr(&so->so_rcv, (struct sockaddr *) addr, m, NULL) == 0) {
840 * For this type, removal of the last link destroys the node
841 * if the NOLINGER flag is set.
844 ngs_disconnect(hook_p hook)
846 struct ngsock *const sockdata = hook->node->private;
848 if ((sockdata->flags & NGS_FLAG_NOLINGER )
849 && (hook->node->numhooks == 0)) {
850 ng_rmnode(hook->node);
856 * Do local shutdown processing.
857 * In this case, that involves making sure the socket
858 * knows we should be shutting down.
861 ngs_rmnode(node_p node)
863 struct ngsock *const sockdata = node->private;
864 struct ngpcb *const dpcbp = sockdata->datasock;
865 struct ngpcb *const pcbp = sockdata->ctlsock;
871 soisdisconnected(dpcbp->ng_socket);
872 dpcbp->sockdata = NULL;
873 sockdata->datasock = NULL;
877 soisdisconnected(pcbp->ng_socket);
878 pcbp->sockdata = NULL;
879 sockdata->ctlsock = NULL;
882 node->private = NULL;
884 FREE(sockdata, M_NETGRAPH);
889 * Control and data socket type descriptors
892 static struct pr_usrreqs ngc_usrreqs = {
894 .pru_accept = pru_accept_notsupp,
895 .pru_attach = ngc_attach,
896 .pru_bind = ngc_bind,
897 .pru_connect = ngc_connect,
898 .pru_connect2 = pru_connect2_notsupp,
899 .pru_control = pru_control_notsupp,
900 .pru_detach = ngc_detach,
901 .pru_disconnect = NULL,
902 .pru_listen = pru_listen_notsupp,
903 .pru_peeraddr = NULL,
904 .pru_rcvd = pru_rcvd_notsupp,
905 .pru_rcvoob = pru_rcvoob_notsupp,
906 .pru_send = ngc_send,
907 .pru_sense = pru_sense_null,
908 .pru_shutdown = NULL,
909 .pru_sockaddr = ng_setsockaddr,
910 .pru_sosend = sosend,
911 .pru_soreceive = soreceive,
915 static struct pr_usrreqs ngd_usrreqs = {
917 .pru_accept = pru_accept_notsupp,
918 .pru_attach = ngd_attach,
920 .pru_connect = ngd_connect,
921 .pru_connect2 = pru_connect2_notsupp,
922 .pru_control = pru_control_notsupp,
923 .pru_detach = ngd_detach,
924 .pru_disconnect = NULL,
925 .pru_listen = pru_listen_notsupp,
926 .pru_peeraddr = NULL,
927 .pru_rcvd = pru_rcvd_notsupp,
928 .pru_rcvoob = pru_rcvoob_notsupp,
929 .pru_send = ngd_send,
930 .pru_sense = pru_sense_null,
931 .pru_shutdown = NULL,
932 .pru_sockaddr = ng_setsockaddr,
933 .pru_sosend = sosend,
934 .pru_soreceive = soreceive,
939 * Definitions of protocols supported in the NETGRAPH domain.
942 extern struct domain ngdomain; /* stop compiler warnings */
944 static struct protosw ngsw[] = {
949 PR_ATOMIC | PR_ADDR /* | PR_RIGHTS */,
967 struct domain ngdomain = {
968 AF_NETGRAPH, "netgraph", NULL, NULL, NULL,
969 ngsw, &ngsw[sizeof(ngsw) / sizeof(ngsw[0])],
973 * Handle loading and unloading for this node type
974 * This is to handle auxiliary linkages (e.g protocol domain addition).
977 ngs_mod_event(module_t mod, int event, void *data)
983 /* Register protocol domain */
984 net_add_domain(&ngdomain);
987 /* Insure there are no open netgraph sockets */
988 if (!LIST_EMPTY(&ngsocklist)) {
994 /* Unregister protocol domain XXX can't do this yet.. */
995 if ((error = net_rm_domain(&ngdomain)) != 0)
1008 SYSCTL_INT(_net_graph, OID_AUTO, family, CTLFLAG_RD, 0, AF_NETGRAPH, "");
1009 SYSCTL_NODE(_net_graph, OID_AUTO, data, CTLFLAG_RW, 0, "DATA");
1010 SYSCTL_INT(_net_graph_data, OID_AUTO, proto, CTLFLAG_RD, 0, NG_DATA, "");
1011 SYSCTL_NODE(_net_graph, OID_AUTO, control, CTLFLAG_RW, 0, "CONTROL");
1012 SYSCTL_INT(_net_graph_control, OID_AUTO, proto, CTLFLAG_RD, 0, NG_CONTROL, "");