| 558 | } |
| 559 | |
| 560 | static int |
| 561 | div_attach(struct socket *so, int proto, struct thread *td) |
| 562 | { |
| 563 | struct inpcb *inp; |
| 564 | int error; |
| 565 | |
| 566 | inp = sotoinpcb(so); |
| 567 | KASSERT(inp == NULL, ("div_attach: inp != NULL")); |
| 568 | if (td != NULL) { |
| 569 | error = priv_check(td, PRIV_NETINET_DIVERT); |
| 570 | if (error) |
| 571 | return (error); |
| 572 | } |
| 573 | error = soreserve(so, div_sendspace, div_recvspace); |
| 574 | if (error) |
| 575 | return error; |
| 576 | INP_INFO_WLOCK(&V_divcbinfo); |
| 577 | error = in_pcballoc(so, &V_divcbinfo); |
| 578 | if (error) { |
| 579 | INP_INFO_WUNLOCK(&V_divcbinfo); |
| 580 | return error; |
| 581 | } |
| 582 | inp = (struct inpcb *)so->so_pcb; |
| 583 | INP_INFO_WUNLOCK(&V_divcbinfo); |
| 584 | inp->inp_ip_p = proto; |
| 585 | inp->inp_vflag |= INP_IPV4; |
| 586 | inp->inp_flags |= INP_HDRINCL; |
| 587 | INP_WUNLOCK(inp); |
| 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | static void |
| 592 | div_detach(struct socket *so) |
nothing calls this directly
no test coverage detected