FreeBSD kernel netgraph code
|
#include <sys/param.h>
#include <sys/domain.h>
#include <sys/hash.h>
#include <sys/kernel.h>
#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/epoch.h>
#include <sys/priv.h>
#include <sys/protosw.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <net/vnet.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/ng_socketvar.h>
#include <netgraph/ng_socket.h>
Go to the source code of this file.
Data Structures | |
struct | ngsock |
Macros | |
#define | M_NETGRAPH_PATH M_NETGRAPH |
#define | M_NETGRAPH_SOCK M_NETGRAPH |
#define | sotongpcb(so) ((struct ngpcb *)(so)->so_pcb) |
#define | TRAP_ERROR |
#define | NGS_FLAG_NOLINGER 1 /* close with last hook */ |
Functions | |
static int | ng_attach_data (struct socket *so) |
static int | ng_attach_cntl (struct socket *so) |
static int | ng_attach_common (struct socket *so, int type) |
static void | ng_detach_common (struct ngpcb *pcbp, int type) |
static void | ng_socket_free_priv (struct ngsock *priv) |
static int | ng_connect_data (struct sockaddr *nam, struct ngpcb *pcbp) |
static int | ng_bind (struct sockaddr *nam, struct ngpcb *pcbp) |
static int | ngs_mod_event (module_t mod, int event, void *data) |
static void | ng_socket_item_applied (void *context, int error) |
NETGRAPH_INIT_ORDERED (socket, &typestruct, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY) | |
SYSCTL_ULONG (_net_graph, OID_AUTO, maxdgram, CTLFLAG_RW, &ngpdg_sendspace, 0, "Maximum outgoing Netgraph datagram size") | |
SYSCTL_ULONG (_net_graph, OID_AUTO, recvspace, CTLFLAG_RW, &ngpdg_recvspace, 0, "Maximum space for incoming Netgraph datagrams") | |
static | LIST_HEAD (ngpcb) |
LIST_HEAD (ngshash, hookpriv) | |
static int | ngc_attach (struct socket *so, int proto, struct thread *td) |
static void | ngc_detach (struct socket *so) |
static int | ngc_send (struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) |
static int | ngc_bind (struct socket *so, struct sockaddr *nam, struct thread *td) |
static int | ngc_connect (struct socket *so, struct sockaddr *nam, struct thread *td) |
static int | ngd_attach (struct socket *so, int proto, struct thread *td) |
static void | ngd_detach (struct socket *so) |
static int | ngd_send (struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) |
static int | ngd_connect (struct socket *so, struct sockaddr *nam, struct thread *td) |
static int | ng_getsockaddr (struct socket *so, struct sockaddr **addr) |
static int | ngs_constructor (node_p nodep) |
static void | ngs_rehash (node_p node) |
static int | ngs_newhook (node_p node, hook_p hook, const char *name) |
static int | ngs_connect (hook_p hook) |
static hook_p | ngs_findhook (node_p node, const char *name) |
static int | ngs_rcvmsg (node_p node, item_p item, hook_p lasthook) |
static int | ngs_rcvdata (hook_p hook, item_p item) |
static int | ngs_disconnect (hook_p hook) |
static int | ngs_shutdown (node_p node) |
static int | dummy_disconnect (struct socket *so) |
DOMAIN_SET (ng) | |
SYSCTL_INT (_net_graph, OID_AUTO, family, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, AF_NETGRAPH, "") | |
static | SYSCTL_NODE (_net_graph, OID_AUTO, data, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "DATA") |
SYSCTL_INT (_net_graph_data, OID_AUTO, proto, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, NG_DATA, "") | |
static | SYSCTL_NODE (_net_graph, OID_AUTO, control, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "CONTROL") |
SYSCTL_INT (_net_graph_control, OID_AUTO, proto, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, NG_CONTROL, "") | |
Variables | |
static ng_constructor_t | ngs_constructor |
static ng_rcvmsg_t | ngs_rcvmsg |
static ng_shutdown_t | ngs_shutdown |
static ng_newhook_t | ngs_newhook |
static ng_connect_t | ngs_connect |
static ng_findhook_t | ngs_findhook |
static ng_rcvdata_t | ngs_rcvdata |
static ng_disconnect_t | ngs_disconnect |
static struct ng_type | typestruct |
static u_long | ngpdg_sendspace = 20 * 1024 |
static u_long | ngpdg_recvspace = 20 * 1024 |
static struct pr_usrreqs | ngc_usrreqs |
static struct pr_usrreqs | ngd_usrreqs |
struct domain | ngdomain |
static struct protosw | ngsw [] |
#define M_NETGRAPH_PATH M_NETGRAPH |
Definition at line 82 of file ng_socket.c.
#define M_NETGRAPH_SOCK M_NETGRAPH |
Definition at line 83 of file ng_socket.c.
#define NGS_FLAG_NOLINGER 1 /* close with last hook */ |
Definition at line 189 of file ng_socket.c.
#define sotongpcb | ( | so | ) | ((struct ngpcb *)(so)->so_pcb) |
#define TRAP_ERROR |
DOMAIN_SET | ( | ng | ) |
|
static |
Definition at line 1127 of file ng_socket.c.
|
static |
Definition at line 159 of file ng_socket.c.
LIST_HEAD | ( | ngshash | , |
hookpriv | |||
) |
NETGRAPH_INIT_ORDERED | ( | socket | , |
& | typestruct, | ||
SI_SUB_PROTO_DOMAIN | , | ||
SI_ORDER_ANY | |||
) |
|
static |
Definition at line 549 of file ng_socket.c.
References M_NETGRAPH_SOCK, ng_node::nd_ID, ng_attach_common(), NG_CONTROL, ng_detach_common(), ng_make_node_common(), NG_NODE_REF, NG_NODE_SET_PRIVATE, ngpcb::node_id, ngpcb::sockdata, sotongpcb, and typestruct.
Referenced by ngc_attach().
|
static |
Definition at line 605 of file ng_socket.c.
References ngpcb::ng_socket, ngpdg_recvspace, ngpdg_sendspace, type, and ngpcb::type.
Referenced by ng_attach_cntl(), and ng_attach_data().
|
static |
Definition at line 595 of file ng_socket.c.
References ng_attach_common(), and NG_DATA.
Referenced by ngd_attach().
|
static |
Definition at line 758 of file ng_socket.c.
References ng_name_node(), NG_NODESIZ, sockaddr_ng::sg_data, sockaddr_ng::sg_len, ngpcb::sockdata, and TRAP_ERROR.
Referenced by ngc_bind().
|
static |
Definition at line 699 of file ng_socket.c.
References ng_item::el_dest, ngsock::error, ng_type::name, ng_node::nd_type, ng_address_path(), NG_FREE_ITEM, NG_NODE_PRIVATE, ng_package_data(), NG_SOCKET_NODE_TYPE, NG_WAITOK, ngpcb::node_id, sockaddr_ng::sg_data, and ngpcb::sockdata.
Referenced by ngd_connect().
|
static |
Definition at line 637 of file ng_socket.c.
References NG_CONTROL, NG_DATA, ngpcb::ng_socket, ng_socket_free_priv(), ngpcb::node_id, and ngpcb::sockdata.
Referenced by ng_attach_cntl(), ngc_detach(), and ngd_detach().
|
static |
Definition at line 505 of file ng_socket.c.
References ngsock::mtx, NG_NODE_HAS_NAME, NG_NODE_NAME, NG_NODESIZ, ngsock::node, sockaddr_ng::sg_data, sockaddr_ng::sg_family, sockaddr_ng::sg_len, ngpcb::sockdata, and sotongpcb.
|
static |
Definition at line 671 of file ng_socket.c.
References M_NETGRAPH_SOCK, NG_NODE_UNREF, ng_rmnode_self(), and ngsock::node.
Referenced by ng_detach_common(), and ngs_shutdown().
|
static |
Definition at line 1115 of file ng_socket.c.
References ngsock::error.
Referenced by ngc_send().
|
static |
Definition at line 196 of file ng_socket.c.
References ng_attach_cntl(), and sotongpcb.
|
static |
Definition at line 366 of file ng_socket.c.
References ng_bind(), and sotongpcb.
|
static |
Definition at line 376 of file ng_socket.c.
|
static |
Definition at line 210 of file ng_socket.c.
References NG_CONTROL, ng_detach_common(), and sotongpcb.
|
static |
Definition at line 219 of file ng_socket.c.
References ng_apply_info::apply, ng_item::apply, ng_mesg::ng_msghdr::cmd, ng_mesg::ng_msghdr::cmdstr, ng_apply_info::context, control, ng_mesg::data, ng_item::el_dest, ng_apply_info::error, ng_mesg::ng_msghdr::flags, ng_mesg::header, M_NETGRAPH_PATH, ng_type::name, ng_node::nd_ID, ng_node::nd_type, ng_address_path(), ng_findtype(), NG_NODE_PRIVATE, NG_NODESIZ, ng_package_msg(), ng_snd_item(), ng_socket_item_applied(), NG_TYPESIZ, NG_VERSION, NG_WAITOK, NGM_GENERIC_COOKIE, NGM_MKPEER, ngsock::node, SAVE_LINE, sockaddr_ng::sg_data, sockaddr_ng::sg_len, ngpcb::sockdata, sotongpcb, ng_mesg::ng_msghdr::token, ngm_mkpeer::type, ng_mesg::ng_msghdr::typecookie, and ng_mesg::ng_msghdr::version.
|
static |
Definition at line 391 of file ng_socket.c.
References ng_attach_data(), and sotongpcb.
|
static |
Definition at line 492 of file ng_socket.c.
References ng_connect_data(), and sotongpcb.
|
static |
Definition at line 401 of file ng_socket.c.
References NG_DATA, ng_detach_common(), and sotongpcb.
|
static |
Definition at line 410 of file ng_socket.c.
References control, ng_findhook(), NG_FWD_ITEM_HOOK, NG_HOOKSIZ, NG_NODE_NUMHOOKS, NG_NODESIZ, ng_package_data(), NG_WAITOK, ngsock::node, sockaddr_ng::sg_data, sockaddr_ng::sg_len, ngpcb::sockdata, and sotongpcb.
|
static |
Definition at line 846 of file ng_socket.c.
References NG_HOOK_NODE, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, and ngsock::node.
|
static |
Definition at line 784 of file ng_socket.c.
|
static |
Definition at line 1062 of file ng_socket.c.
References M_NETGRAPH_SOCK, NG_HOOK_NODE, NG_HOOK_PRIVATE, NG_NODE_IS_VALID, NG_NODE_NUMHOOKS, NG_NODE_PRIVATE, ng_rmnode_self(), NGS_FLAG_NOLINGER, and ngsock::node.
Definition at line 862 of file ng_socket.c.
References name, ng_node::nd_numhooks, NG_HOOK_NAME, NG_NODE_PRIVATE, and ngsock::node.
|
static |
Definition at line 1200 of file ng_socket.c.
References event.
Definition at line 823 of file ng_socket.c.
References M_NETGRAPH_SOCK, name, ng_node::nd_numhooks, NG_HOOK_SET_PRIVATE, NG_NODE_PRIVATE, ngs_rehash(), and ngsock::node.
Definition at line 1012 of file ng_socket.c.
References NG_FREE_ITEM, NG_FREE_M, NG_HOOK_NAME, NG_HOOK_NODE, NG_HOOKSIZ, NG_NODE_PRIVATE, ngpcb::ng_socket, NGI_GET_M, sockaddr_ng::sg_data, sockaddr_ng::sg_family, sockaddr_ng::sg_len, and TRAP_ERROR.
Definition at line 897 of file ng_socket.c.
References ng_mesg::ng_msghdr::arglen, ng_mesg::ng_msghdr::cmd, ng_mesg::ng_msghdr::cmdstr, ng_mesg::ng_msghdr::flags, ng_mesg::header, NG_FREE_ITEM, NG_FREE_MSG, ng_ID_t, NG_NODE_PRIVATE, ngpcb::ng_socket, NGI_GET_MSG, NGI_RETADDR, NGM_SOCK_CMD_LINGER, NGM_SOCK_CMD_NOLINGER, NGM_SOCKET_COOKIE, NGS_FLAG_NOLINGER, ngsock::node, sockaddr_ng::sg_data, sockaddr_ng::sg_family, sockaddr_ng::sg_len, ng_mesg::ng_msghdr::token, TRAP_ERROR, and ng_mesg::ng_msghdr::typecookie.
|
static |
Definition at line 790 of file ng_socket.c.
References M_NETGRAPH_SOCK, NG_HOOK_NAME, NG_HOOK_PRIVATE, NG_NODE_PRIVATE, and ngsock::node.
Referenced by ngs_newhook().
|
static |
Definition at line 1091 of file ng_socket.c.
References NG_NODE_PRIVATE, NG_NODE_SET_PRIVATE, NG_NODE_UNREF, ngpcb::ng_socket, ng_socket_free_priv(), and ngsock::node.
SYSCTL_INT | ( | _net_graph | , |
OID_AUTO | , | ||
family | , | ||
CTLFLAG_RD | , | ||
SYSCTL_NULL_INT_PTR | , | ||
AF_NETGRAPH | , | ||
"" | |||
) |
SYSCTL_INT | ( | _net_graph_control | , |
OID_AUTO | , | ||
proto | , | ||
CTLFLAG_RD | , | ||
SYSCTL_NULL_INT_PTR | , | ||
NG_CONTROL | , | ||
"" | |||
) |
SYSCTL_INT | ( | _net_graph_data | , |
OID_AUTO | , | ||
proto | , | ||
CTLFLAG_RD | , | ||
SYSCTL_NULL_INT_PTR | , | ||
NG_DATA | , | ||
"" | |||
) |
|
static |
|
static |
SYSCTL_ULONG | ( | _net_graph | , |
OID_AUTO | , | ||
maxdgram | , | ||
CTLFLAG_RW | , | ||
& | ngpdg_sendspace, | ||
0 | , | ||
"Maximum outgoing Netgraph datagram size" | |||
) |
SYSCTL_ULONG | ( | _net_graph | , |
OID_AUTO | , | ||
recvspace | , | ||
CTLFLAG_RW | , | ||
& | ngpdg_recvspace, | ||
0 | , | ||
"Maximum space for incoming Netgraph datagrams" | |||
) |
|
static |
Definition at line 1137 of file ng_socket.c.
|
static |
Definition at line 1151 of file ng_socket.c.
struct domain ngdomain |
Definition at line 1188 of file ng_socket.c.
|
static |
Definition at line 154 of file ng_socket.c.
Referenced by ng_attach_common().
|
static |
Definition at line 151 of file ng_socket.c.
Referenced by ng_attach_common().
|
static |
Definition at line 117 of file ng_socket.c.
|
static |
Definition at line 113 of file ng_socket.c.
|
static |
Definition at line 120 of file ng_socket.c.
|
static |
Definition at line 118 of file ng_socket.c.
|
static |
Definition at line 116 of file ng_socket.c.
|
static |
Definition at line 119 of file ng_socket.c.
|
static |
Definition at line 114 of file ng_socket.c.
|
static |
Definition at line 115 of file ng_socket.c.
|
static |
Definition at line 1171 of file ng_socket.c.
|
static |
Definition at line 135 of file ng_socket.c.
Referenced by ng_attach_cntl().