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

Function rip_bind

freebsd/netinet/raw_ip.c:992–1024  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

990}
991
992static int
993rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
994{
995 struct sockaddr_in *addr = (struct sockaddr_in *)nam;
996 struct inpcb *inp;
997 int error;
998
999 if (nam->sa_len != sizeof(*addr))
1000 return (EINVAL);
1001
1002 error = prison_check_ip4(td->td_ucred, &addr->sin_addr);
1003 if (error != 0)
1004 return (error);
1005
1006 inp = sotoinpcb(so);
1007 KASSERT(inp != NULL, ("rip_bind: inp == NULL"));
1008
1009 if (CK_STAILQ_EMPTY(&V_ifnet) ||
1010 (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) ||
1011 (addr->sin_addr.s_addr &&
1012 (inp->inp_flags & INP_BINDANY) == 0 &&
1013 ifa_ifwithaddr_check((struct sockaddr *)addr) == 0))
1014 return (EADDRNOTAVAIL);
1015
1016 INP_INFO_WLOCK(&V_ripcbinfo);
1017 INP_WLOCK(inp);
1018 rip_delhash(inp);
1019 inp->inp_laddr = addr->sin_addr;
1020 rip_inshash(inp);
1021 INP_WUNLOCK(inp);
1022 INP_INFO_WUNLOCK(&V_ripcbinfo);
1023 return (0);
1024}
1025
1026static int
1027rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)

Callers

nothing calls this directly

Calls 4

ifa_ifwithaddr_checkFunction · 0.85
rip_delhashFunction · 0.85
rip_inshashFunction · 0.85
prison_check_ip4Function · 0.70

Tested by

no test coverage detected