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.17 2008/11/01 04:22:15 sephe 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>
56 #include <sys/domain.h>
57 #include <sys/errno.h>
58 #include <sys/kernel.h>
59 #include <sys/filedesc.h>
60 #include <sys/malloc.h>
61 #include <sys/queue.h>
63 #include <sys/protosw.h>
64 #include <sys/socket.h>
65 #include <sys/socketvar.h>
66 #include <sys/sysctl.h>
67 #include <sys/thread2.h>
69 #include <sys/vnode.h>
71 #include <netgraph/ng_message.h>
72 #include <netgraph/netgraph.h>
73 #include "ng_socketvar.h"
74 #include "ng_socket.h"
77 * It's Ascii-art time!
78 * +-------------+ +-------------+
79 * |socket (ctl)| |socket (data)|
80 * +-------------+ +-------------+
84 * +-----------+ +-----------+
85 * |pcb (ctl)| |pcb (data)|
86 * +-----------+ +-----------+
90 * +--------------------------+
91 * | Socket type private |
93 * +--------------------------+
102 /* Netgraph node methods */
103 static ng_constructor_t ngs_constructor;
104 static ng_rcvmsg_t ngs_rcvmsg;
105 static ng_shutdown_t ngs_rmnode;
106 static ng_newhook_t ngs_newhook;
107 static ng_rcvdata_t ngs_rcvdata;
108 static ng_disconnect_t ngs_disconnect;
110 /* Internal methods */
111 static int ng_attach_data(struct socket *so);
112 static int ng_attach_cntl(struct socket *so);
113 static int ng_attach_common(struct socket *so, int type);
114 static void ng_detach_common(struct ngpcb *pcbp, int type);
115 /*static int ng_internalize(struct mbuf *m, struct thread *td); */
117 static int ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp);
118 static int ng_connect_cntl(struct sockaddr *nam, struct ngpcb *pcbp);
119 static int ng_bind(struct sockaddr *nam, struct ngpcb *pcbp);
121 static int ngs_mod_event(module_t mod, int event, void *data);
122 static int ship_msg(struct ngpcb *pcbp, struct ng_mesg *msg,
123 struct sockaddr_ng *addr);
125 /* Netgraph type descriptor */
126 static struct ng_type typestruct = {
141 NETGRAPH_INIT(socket, &typestruct);
144 static u_long ngpdg_sendspace = 20 * 1024; /* really max datagram size */
145 static u_long ngpdg_recvspace = 20 * 1024;
147 /* List of all sockets */
148 LIST_HEAD(, ngpcb) ngsocklist;
150 #define sotongpcb(so) ((struct ngpcb *)(so)->so_pcb)
152 /* If getting unexplained errors returned, set this to "Debugger("X"); */
157 /***************************************************************
159 ***************************************************************/
162 ngc_attach(struct socket *so, int proto, struct pru_attach_info *ai)
164 struct ngpcb *const pcbp = sotongpcb(so);
166 if (priv_check_cred(ai->p_ucred, PRIV_ROOT, NULL_CRED_OKAY) != 0)
170 return (ng_attach_cntl(so));
174 ngc_detach(struct socket *so)
176 struct ngpcb *const pcbp = sotongpcb(so);
180 ng_detach_common(pcbp, NG_CONTROL);
185 ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
186 struct mbuf *control, struct thread *td)
188 struct ngpcb *const pcbp = sotongpcb(so);
189 struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
190 struct ng_mesg *resp;
192 char *msg, *path = NULL;
200 if (control && (error = ng_internalize(control, p))) {
201 if (pcbp->sockdata == NULL) {
213 /* Require destination as there may be >= 1 hooks on this node */
215 error = EDESTADDRREQ;
219 /* Allocate an expendable buffer for the path, chop off
220 * the sockaddr header, and make sure it's NUL terminated */
221 len = sap->sg_len - 2;
222 MALLOC(path, char *, len + 1, M_NETGRAPH, M_WAITOK);
223 bcopy(sap->sg_data, path, len);
226 /* Move the actual message out of mbufs into a linear buffer.
227 * Start by adding up the size of the data. (could use mh_len?) */
228 for (len = 0, m0 = m; m0 != NULL; m0 = m0->m_next)
231 /* Move the data into a linear buffer as well. Messages are not
232 * delivered in mbufs. */
233 MALLOC(msg, char *, len + 1, M_NETGRAPH, M_WAITOK);
234 m_copydata(m, 0, len, msg);
236 /* The callee will free the msg when done. The addr is our business. */
237 error = ng_send_msg(pcbp->sockdata->node,
238 (struct ng_mesg *) msg, path, &resp);
240 /* If the callee responded with a synchronous response, then put it
241 * back on the receive side of the socket; sap is source address. */
242 if (error == 0 && resp != NULL)
243 error = ship_msg(pcbp, resp, sap);
247 FREE(path, M_NETGRAPH);
256 ngc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
258 struct ngpcb *const pcbp = sotongpcb(so);
262 return (ng_bind(nam, pcbp));
266 ngc_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
268 struct ngpcb *const pcbp = sotongpcb(so);
272 return (ng_connect_cntl(nam, pcbp));
275 /***************************************************************
277 ***************************************************************/
280 ngd_attach(struct socket *so, int proto, struct pru_attach_info *ai)
282 struct ngpcb *const pcbp = sotongpcb(so);
286 return (ng_attach_data(so));
290 ngd_detach(struct socket *so)
292 struct ngpcb *const pcbp = sotongpcb(so);
296 ng_detach_common(pcbp, NG_DATA);
301 ngd_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
302 struct mbuf *control, struct thread *td)
304 struct ngpcb *const pcbp = sotongpcb(so);
305 struct sockaddr_ng *const sap = (struct sockaddr_ng *) addr;
309 char hookname[NG_HOOKSIZ];
311 if ((pcbp == NULL) || (control != NULL)) {
315 if (pcbp->sockdata == NULL) {
320 * If the user used any of these ways to not specify an address
321 * then handle specially.
324 || ((len = sap->sg_len - 2) <= 0)
325 || (*sap->sg_data == '\0')) {
326 if (pcbp->sockdata->node->numhooks != 1) {
327 error = EDESTADDRREQ;
331 * if exactly one hook exists, just use it.
332 * Special case to allow write(2) to work on an ng_socket.
334 hook = LIST_FIRST(&pcbp->sockdata->node->hooks);
336 if (len >= NG_HOOKSIZ) {
342 * chop off the sockaddr header, and make sure it's NUL
345 bcopy(sap->sg_data, hookname, len);
346 hookname[len] = '\0';
348 /* Find the correct hook from 'hookname' */
349 LIST_FOREACH(hook, &pcbp->sockdata->node->hooks, hooks) {
350 if (strcmp(hookname, hook->name) == 0)
354 error = EHOSTUNREACH;
357 /* Send data (OK if hook is NULL) */
358 NG_SEND_DATA(error, hook, m, mp); /* makes m NULL */
369 ngd_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
371 struct ngpcb *const pcbp = sotongpcb(so);
375 return (ng_connect_data(nam, pcbp));
379 * Used for both data and control sockets
382 ng_setsockaddr(struct socket *so, struct sockaddr **addr)
385 struct sockaddr_ng *sg;
388 /* Why isn't sg_data a `char[1]' ? :-( */
389 sg_len = sizeof(struct sockaddr_ng) - sizeof(sg->sg_data) + 1;
392 pcbp = sotongpcb(so);
393 if ((pcbp == 0) || (pcbp->sockdata == NULL)) {
398 namelen = 0; /* silence compiler ! */
400 if (pcbp->sockdata->node->name != NULL)
401 sg_len += namelen = strlen(pcbp->sockdata->node->name);
403 MALLOC(sg, struct sockaddr_ng *, sg_len, M_SONAME, M_WAITOK | M_ZERO);
405 if (pcbp->sockdata->node->name != NULL)
406 bcopy(pcbp->sockdata->node->name, sg->sg_data, namelen);
410 sg->sg_family = AF_NETGRAPH;
411 *addr = (struct sockaddr *)sg;
417 * Attach a socket to it's protocol specific partner.
418 * For a control socket, actually create a netgraph node and attach
423 ng_attach_cntl(struct socket *so)
425 struct ngsock *privdata;
429 /* Setup protocol control block */
430 if ((error = ng_attach_common(so, NG_CONTROL)) != 0)
432 pcbp = sotongpcb(so);
434 /* Allocate node private info */
435 MALLOC(privdata, struct ngsock *,
436 sizeof(*privdata), M_NETGRAPH, M_WAITOK | M_ZERO);
438 /* Make the generic node components */
439 if ((error = ng_make_node_common(&typestruct, &privdata->node)) != 0) {
440 FREE(privdata, M_NETGRAPH);
441 ng_detach_common(pcbp, NG_CONTROL);
444 privdata->node->private = privdata;
446 /* Link the pcb and the node private data */
447 privdata->ctlsock = pcbp;
448 pcbp->sockdata = privdata;
454 ng_attach_data(struct socket *so)
456 return(ng_attach_common(so, NG_DATA));
460 * Set up a socket protocol control block.
461 * This code is shared between control and data sockets.
464 ng_attach_common(struct socket *so, int type)
469 /* Standard socket setup stuff */
470 error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace, NULL);
474 /* Allocate the pcb */
475 MALLOC(pcbp, struct ngpcb *, sizeof(*pcbp), M_PCB, M_WAITOK | M_ZERO);
478 /* Link the pcb and the socket */
480 so->so_pcb = (caddr_t) pcbp;
481 pcbp->ng_socket = so;
483 /* Add the socket to linked list */
484 LIST_INSERT_HEAD(&ngsocklist, pcbp, socks);
489 * Disassociate the socket from it's protocol specific
490 * partner. If it's attached to a node's private data structure,
491 * then unlink from that too. If we were the last socket attached to it,
492 * then shut down the entire node. Shared code for control and data sockets.
495 ng_detach_common(struct ngpcb *pcbp, int which)
497 struct ngsock *sockdata;
500 if (pcbp->sockdata) {
501 sockdata = pcbp->sockdata;
502 pcbp->sockdata = NULL;
505 sockdata->ctlsock = NULL;
508 sockdata->datasock = NULL;
513 if ((--sockdata->refs == 0) && (sockdata->node != NULL))
514 ng_rmnode(sockdata->node);
516 so = pcbp->ng_socket;
518 pcbp->ng_socket = NULL;
519 sofree(so); /* remove pcb ref */
521 LIST_REMOVE(pcbp, socks);
527 * File descriptors can be passed into a AF_NETGRAPH socket.
528 * Note, that file descriptors cannot be passed OUT.
529 * Only character device descriptors are accepted.
530 * Character devices are useful to connect a graph to a device,
531 * which after all is the purpose of this whole system.
534 ng_internalize(struct mbuf *control, struct thread *td)
536 struct filedesc *fdp = p->p_fd;
537 const struct cmsghdr *cm = mtod(control, const struct cmsghdr *);
543 if (cm->cmsg_type != SCM_RIGHTS || cm->cmsg_level != SOL_SOCKET ||
544 cm->cmsg_len != control->m_len) {
549 /* Check there is only one FD. XXX what would more than one signify? */
550 oldfds = (cm->cmsg_len - sizeof(*cm)) / sizeof(int);
556 /* Check that the FD given is legit. and change it to a pointer to a
558 fd = *(int *) (cm + 1);
559 if ((unsigned) fd >= fdp->fd_nfiles
560 || (fp = fdp->fd_files[fd].fp) == NULL) {
564 /* Depending on what kind of resource it is, act differently. For
565 * devices, we treat it as a file. For a AF_NETGRAPH socket,
566 * shortcut straight to the node. */
567 switch (fp->f_type) {
569 vn = (struct vnode *) fp->f_data;
570 if (vn && (vn->v_type == VCHR)) {
571 /* for a VCHR, actually reference the FILE */
573 /* XXX then what :) */
574 /* how to pass on to other modules? */
589 * Connect the data socket to a named control socket node.
592 ng_connect_data(struct sockaddr *nam, struct ngpcb *pcbp)
594 struct sockaddr_ng *sap;
596 struct ngsock *sockdata;
599 /* If we are already connected, don't do it again */
600 if (pcbp->sockdata != NULL)
603 /* Find the target (victim) and check it doesn't already have a data
604 * socket. Also check it is a 'socket' type node. */
605 sap = (struct sockaddr_ng *) nam;
606 if ((error = ng_path2node(NULL, sap->sg_data, &farnode, NULL)))
609 if (strcmp(farnode->type->name, NG_SOCKET_NODE_TYPE) != 0)
611 sockdata = farnode->private;
612 if (sockdata->datasock != NULL)
615 /* Link the PCB and the private data struct. and note the extra
617 sockdata->datasock = pcbp;
618 pcbp->sockdata = sockdata;
624 * Connect the existing control socket node to a named node:hook.
625 * The hook we use on this end is the same name as the remote node name.
628 ng_connect_cntl(struct sockaddr *nam, struct ngpcb *pcbp)
630 struct ngsock *const sockdata = pcbp->sockdata;
631 struct sockaddr_ng *sap;
636 sap = (struct sockaddr_ng *) nam;
637 rtn = ng_path_parse(sap->sg_data, &node, NULL, &hook);
638 if (rtn < 0 || node == NULL || hook == NULL) {
642 farnode = ng_findname(sockdata->node, node);
643 if (farnode == NULL) {
645 return (EADDRNOTAVAIL);
648 /* Connect, using a hook name the same as the far node name. */
649 error = ng_con_nodes(sockdata->node, node, farnode, hook);
654 * Binding a socket means giving the corresponding node a name
657 ng_bind(struct sockaddr *nam, struct ngpcb *pcbp)
659 struct ngsock *const sockdata = pcbp->sockdata;
660 struct sockaddr_ng *const sap = (struct sockaddr_ng *) nam;
662 if (sockdata == NULL) {
666 if (sap->sg_len < 3 || sap->sg_data[sap->sg_len - 3] != '\0') {
670 return (ng_name_node(sockdata->node, sap->sg_data));
674 * Take a message and pass it up to the control socket associated
678 ship_msg(struct ngpcb *pcbp, struct ng_mesg *msg, struct sockaddr_ng *addr)
680 struct socket *const so = pcbp->ng_socket;
684 /* Copy the message itself into an mbuf chain */
685 msglen = sizeof(struct ng_mesg) + msg->header.arglen;
686 mdata = m_devget((caddr_t) msg, msglen, 0, NULL, NULL);
688 /* Here we free the message, as we are the end of the line.
689 * We need to do that regardless of whether we got mbufs. */
690 FREE(msg, M_NETGRAPH);
697 /* Send it up to the socket */
698 if (ssb_appendaddr(&so->so_rcv,
699 (struct sockaddr *) addr, mdata, NULL) == 0) {
709 * You can only create new nodes from the socket end of things.
712 ngs_constructor(node_p *nodep)
718 * We allow any hook to be connected to the node.
719 * There is no per-hook private information though.
722 ngs_newhook(node_p node, hook_p hook, const char *name)
724 hook->private = node->private;
729 * Incoming messages get passed up to the control socket.
730 * Unless they are for us specifically (socket_type)
733 ngs_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr,
734 struct ng_mesg **resp)
736 struct ngsock *const sockdata = node->private;
737 struct ngpcb *const pcbp = sockdata->ctlsock;
738 struct sockaddr_ng *addr;
742 /* Only allow mesgs to be passed if we have the control socket.
743 * Data sockets can only support the generic messages. */
749 if (msg->header.typecookie == NGM_SOCKET_COOKIE) {
750 switch (msg->header.cmd) {
751 case NGM_SOCK_CMD_NOLINGER:
752 sockdata->flags |= NGS_FLAG_NOLINGER;
754 case NGM_SOCK_CMD_LINGER:
755 sockdata->flags &= ~NGS_FLAG_NOLINGER;
758 error = EINVAL; /* unknown command */
760 /* Free the message and return */
761 FREE(msg, M_NETGRAPH);
765 /* Get the return address into a sockaddr */
766 if ((retaddr == NULL) || (*retaddr == '\0'))
768 addrlen = strlen(retaddr);
769 MALLOC(addr, struct sockaddr_ng *, addrlen + 4, M_NETGRAPH, M_NOWAIT);
774 addr->sg_len = addrlen + 3;
775 addr->sg_family = AF_NETGRAPH;
776 bcopy(retaddr, addr->sg_data, addrlen);
777 addr->sg_data[addrlen] = '\0';
780 error = ship_msg(pcbp, msg, addr);
781 FREE(addr, M_NETGRAPH);
786 * Receive data on a hook
789 ngs_rcvdata(hook_p hook, struct mbuf *m, meta_p meta)
791 struct ngsock *const sockdata = hook->node->private;
792 struct ngpcb *const pcbp = sockdata->datasock;
794 struct sockaddr_ng *addr;
795 char *addrbuf[NG_HOOKSIZ + 4];
798 /* If there is no data socket, black-hole it */
800 NG_FREE_DATA(m, meta);
803 so = pcbp->ng_socket;
805 /* Get the return address into a sockaddr. */
806 addrlen = strlen(hook->name); /* <= NG_HOOKSIZ - 1 */
807 addr = (struct sockaddr_ng *) addrbuf;
808 addr->sg_len = addrlen + 3;
809 addr->sg_family = AF_NETGRAPH;
810 bcopy(hook->name, addr->sg_data, addrlen);
811 addr->sg_data[addrlen] = '\0';
813 /* We have no use for the meta data, free/clear it now. */
816 /* Try to tell the socket which hook it came in on */
817 if (ssb_appendaddr(&so->so_rcv, (struct sockaddr *) addr, m, NULL) == 0) {
829 * For this type, removal of the last link destroys the node
830 * if the NOLINGER flag is set.
833 ngs_disconnect(hook_p hook)
835 struct ngsock *const sockdata = hook->node->private;
837 if ((sockdata->flags & NGS_FLAG_NOLINGER )
838 && (hook->node->numhooks == 0)) {
839 ng_rmnode(hook->node);
845 * Do local shutdown processing.
846 * In this case, that involves making sure the socket
847 * knows we should be shutting down.
850 ngs_rmnode(node_p node)
852 struct ngsock *const sockdata = node->private;
853 struct ngpcb *const dpcbp = sockdata->datasock;
854 struct ngpcb *const pcbp = sockdata->ctlsock;
860 soisdisconnected(dpcbp->ng_socket);
861 dpcbp->sockdata = NULL;
862 sockdata->datasock = NULL;
866 soisdisconnected(pcbp->ng_socket);
867 pcbp->sockdata = NULL;
868 sockdata->ctlsock = NULL;
871 node->private = NULL;
873 FREE(sockdata, M_NETGRAPH);
878 * Control and data socket type descriptors
881 static struct pr_usrreqs ngc_usrreqs = {
883 .pru_accept = pru_accept_notsupp,
884 .pru_attach = ngc_attach,
885 .pru_bind = ngc_bind,
886 .pru_connect = ngc_connect,
887 .pru_connect2 = pru_connect2_notsupp,
888 .pru_control = pru_control_notsupp,
889 .pru_detach = ngc_detach,
890 .pru_disconnect = NULL,
891 .pru_listen = pru_listen_notsupp,
892 .pru_peeraddr = NULL,
893 .pru_rcvd = pru_rcvd_notsupp,
894 .pru_rcvoob = pru_rcvoob_notsupp,
895 .pru_send = ngc_send,
896 .pru_sense = pru_sense_null,
897 .pru_shutdown = NULL,
898 .pru_sockaddr = ng_setsockaddr,
899 .pru_sosend = sosend,
900 .pru_soreceive = soreceive
903 static struct pr_usrreqs ngd_usrreqs = {
905 .pru_accept = pru_accept_notsupp,
906 .pru_attach = ngd_attach,
908 .pru_connect = ngd_connect,
909 .pru_connect2 = pru_connect2_notsupp,
910 .pru_control = pru_control_notsupp,
911 .pru_detach = ngd_detach,
912 .pru_disconnect = NULL,
913 .pru_listen = pru_listen_notsupp,
914 .pru_peeraddr = NULL,
915 .pru_rcvd = pru_rcvd_notsupp,
916 .pru_rcvoob = pru_rcvoob_notsupp,
917 .pru_send = ngd_send,
918 .pru_sense = pru_sense_null,
919 .pru_shutdown = NULL,
920 .pru_sockaddr = ng_setsockaddr,
921 .pru_sosend = sosend,
922 .pru_soreceive = soreceive
926 * Definitions of protocols supported in the NETGRAPH domain.
929 extern struct domain ngdomain; /* stop compiler warnings */
931 static struct protosw ngsw[] = {
936 PR_ATOMIC | PR_ADDR /* | PR_RIGHTS */,
954 struct domain ngdomain = {
955 AF_NETGRAPH, "netgraph", NULL, NULL, NULL,
956 ngsw, &ngsw[sizeof(ngsw) / sizeof(ngsw[0])],
960 * Handle loading and unloading for this node type
961 * This is to handle auxiliary linkages (e.g protocol domain addition).
964 ngs_mod_event(module_t mod, int event, void *data)
970 /* Register protocol domain */
971 net_add_domain(&ngdomain);
974 /* Insure there are no open netgraph sockets */
975 if (!LIST_EMPTY(&ngsocklist)) {
981 /* Unregister protocol domain XXX can't do this yet.. */
982 if ((error = net_rm_domain(&ngdomain)) != 0)
995 SYSCTL_INT(_net_graph, OID_AUTO, family, CTLFLAG_RD, 0, AF_NETGRAPH, "");
996 SYSCTL_NODE(_net_graph, OID_AUTO, data, CTLFLAG_RW, 0, "DATA");
997 SYSCTL_INT(_net_graph_data, OID_AUTO, proto, CTLFLAG_RD, 0, NG_DATA, "");
998 SYSCTL_NODE(_net_graph, OID_AUTO, control, CTLFLAG_RW, 0, "CONTROL");
999 SYSCTL_INT(_net_graph_control, OID_AUTO, proto, CTLFLAG_RD, 0, NG_CONTROL, "");