* Allocate a control block and a nominal amount of buffer space for the * socket. */
| 77 | * socket. |
| 78 | */ |
| 79 | int |
| 80 | raw_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. |
no test coverage detected