* Set up a socket protocol control block. * This code is shared between control and data sockets. */
| 596 | * This code is shared between control and data sockets. |
| 597 | */ |
| 598 | static int |
| 599 | ng_attach_common(struct socket *so, int type) |
| 600 | { |
| 601 | struct ngpcb *pcbp; |
| 602 | int error; |
| 603 | |
| 604 | /* Standard socket setup stuff. */ |
| 605 | error = soreserve(so, ngpdg_sendspace, ngpdg_recvspace); |
| 606 | if (error) |
| 607 | return (error); |
| 608 | |
| 609 | /* Allocate the pcb. */ |
| 610 | pcbp = malloc(sizeof(struct ngpcb), M_PCB, M_WAITOK | M_ZERO); |
| 611 | pcbp->type = type; |
| 612 | |
| 613 | /* Link the pcb and the socket. */ |
| 614 | so->so_pcb = (caddr_t)pcbp; |
| 615 | pcbp->ng_socket = so; |
| 616 | |
| 617 | /* Add the socket to linked list */ |
| 618 | mtx_lock(&ngsocketlist_mtx); |
| 619 | LIST_INSERT_HEAD(&ngsocklist, pcbp, socks); |
| 620 | mtx_unlock(&ngsocketlist_mtx); |
| 621 | return (0); |
| 622 | } |
| 623 | |
| 624 | /* |
| 625 | * Disassociate the socket from it's protocol specific |
no test coverage detected