Changeset View
Changeset View
Standalone View
Standalone View
sys/netgraph/ng_socket.c
Show First 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | struct ngsock { | ||||
u_long hmask; /* hash mask */ | u_long hmask; /* hash mask */ | ||||
int flags; | int flags; | ||||
int refs; | int refs; | ||||
struct mtx mtx; /* mtx to wait on */ | struct mtx mtx; /* mtx to wait on */ | ||||
int error; /* place to store error */ | int error; /* place to store error */ | ||||
}; | }; | ||||
#define NGS_FLAG_NOLINGER 1 /* close with last hook */ | #define NGS_FLAG_NOLINGER 1 /* close with last hook */ | ||||
#define NGS_FLAG_FRAGMENT 2 /* allow fragmented packets */ | |||||
/*************************************************************** | /*************************************************************** | ||||
Control sockets | Control sockets | ||||
***************************************************************/ | ***************************************************************/ | ||||
static int | static int | ||||
ngc_attach(struct socket *so, int proto, struct thread *td) | ngc_attach(struct socket *so, int proto, struct thread *td) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, | ||||
/* | /* | ||||
* Move the data into a linear buffer as well. | * Move the data into a linear buffer as well. | ||||
* Messages are not delivered in mbufs. | * Messages are not delivered in mbufs. | ||||
*/ | */ | ||||
msg = malloc(len + 1, M_NETGRAPH_MSG, M_WAITOK); | msg = malloc(len + 1, M_NETGRAPH_MSG, M_WAITOK); | ||||
m_copydata(m, 0, len, (char *)msg); | m_copydata(m, 0, len, (char *)msg); | ||||
if (msg->header.version != NG_VERSION) { | if (msg->header.version != NGM_VERSION) { | ||||
free(msg, M_NETGRAPH_MSG); | free(msg, M_NETGRAPH_MSG); | ||||
error = EINVAL; | error = EINVAL; | ||||
goto release; | goto release; | ||||
} | } | ||||
/* | /* | ||||
* Hack alert! | * Hack alert! | ||||
* We look into the message and if it mkpeers a node of unknown type, we | * We look into the message and if it mkpeers a node of unknown type, we | ||||
▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | ng_attach_common(struct socket *so, int type) | ||||
/* Standard socket setup stuff. */ | /* Standard socket setup stuff. */ | ||||
error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace); | error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
/* Allocate the pcb. */ | /* Allocate the pcb. */ | ||||
pcbp = malloc(sizeof(struct ngpcb), M_PCB, M_WAITOK | M_ZERO); | pcbp = malloc(sizeof(struct ngpcb), M_PCB, M_WAITOK | M_ZERO); | ||||
pcbp->type = type; | pcbp->type = type; | ||||
/* Store the current parameters of socket initialization */ | |||||
pcbp->recvspace = ngpdg_recvspace; | |||||
pcbp->sendspace = ngpdg_sendspace; | |||||
/* Link the pcb and the socket. */ | /* Link the pcb and the socket. */ | ||||
so->so_pcb = (caddr_t)pcbp; | so->so_pcb = (caddr_t)pcbp; | ||||
pcbp->ng_socket = so; | pcbp->ng_socket = so; | ||||
/* Add the socket to linked list */ | /* Add the socket to linked list */ | ||||
mtx_lock(&ngsocketlist_mtx); | mtx_lock(&ngsocketlist_mtx); | ||||
LIST_INSERT_HEAD(&ngsocklist, pcbp, socks); | LIST_INSERT_HEAD(&ngsocklist, pcbp, socks); | ||||
▲ Show 20 Lines • Show All 603 Lines • Show Last 20 Lines |