MCPcopy Create free account
hub / github.com/F-Stack/f-stack / raw_attach

Function raw_attach

freebsd/net/raw_cb.c:79–103  ·  view source on GitHub ↗

* Allocate a control block and a nominal amount of buffer space for the * socket. */

Source from the content-addressed store, hash-verified

77 * socket.
78 */
79int
80raw_attach(struct socket *so, int proto)
81{
82 struct rawcb *rp = sotorawcb(so);
83 int error;
84
85 /*
86 * It is assumed that raw_attach is called after space has been
87 * allocated for the rawcb; consumer protocols may simply allocate
88 * type struct rawcb, or a wrapper data structure that begins with a
89 * struct rawcb.
90 */
91 KASSERT(rp != NULL, ("raw_attach: rp == NULL"));
92
93 error = soreserve(so, raw_sendspace, raw_recvspace);
94 if (error)
95 return (error);
96 rp->rcb_socket = so;
97 rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family;
98 rp->rcb_proto.sp_protocol = proto;
99 mtx_lock(&rawcb_mtx);
100 LIST_INSERT_HEAD(&V_rawcb_list, rp, list);
101 mtx_unlock(&rawcb_mtx);
102 return (0);
103}
104
105/*
106 * Detach the raw connection block and discard socket resources.

Callers 3

rts_attachFunction · 0.85
raw_uattachFunction · 0.85
key_attachFunction · 0.85

Calls 3

soreserveFunction · 0.85
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected