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

Function rip6_attach

freebsd/netinet6/raw_ip6.c:654–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

652}
653
654static int
655rip6_attach(struct socket *so, int proto, struct thread *td)
656{
657 struct inpcb *inp;
658 struct icmp6_filter *filter;
659 int error;
660
661 inp = sotoinpcb(so);
662 KASSERT(inp == NULL, ("rip6_attach: inp != NULL"));
663
664 error = priv_check(td, PRIV_NETINET_RAW);
665 if (error)
666 return (error);
667 error = soreserve(so, rip_sendspace, rip_recvspace);
668 if (error)
669 return (error);
670 filter = malloc(sizeof(struct icmp6_filter), M_PCB, M_NOWAIT);
671 if (filter == NULL)
672 return (ENOMEM);
673 INP_INFO_WLOCK(&V_ripcbinfo);
674 error = in_pcballoc(so, &V_ripcbinfo);
675 if (error) {
676 INP_INFO_WUNLOCK(&V_ripcbinfo);
677 free(filter, M_PCB);
678 return (error);
679 }
680 inp = (struct inpcb *)so->so_pcb;
681 INP_INFO_WUNLOCK(&V_ripcbinfo);
682 inp->inp_vflag |= INP_IPV6;
683 inp->inp_ip_p = (long)proto;
684 inp->in6p_hops = -1; /* use kernel default */
685 inp->in6p_cksum = -1;
686 inp->in6p_icmp6filt = filter;
687 ICMP6_FILTER_SETPASSALL(inp->in6p_icmp6filt);
688 INP_WUNLOCK(inp);
689 return (0);
690}
691
692static void
693rip6_detach(struct socket *so)

Callers

nothing calls this directly

Calls 5

soreserveFunction · 0.85
mallocFunction · 0.85
in_pcballocFunction · 0.85
priv_checkFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected