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

Function sctp_inpcb_bind

freebsd/netinet/sctp_pcb.c:2805–3222  ·  view source on GitHub ↗

sctp_ifap is used to bypass normal local address validation checks */

Source from the content-addressed store, hash-verified

2803
2804/* sctp_ifap is used to bypass normal local address validation checks */
2805int
2806sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
2807 struct sctp_ifa *sctp_ifap, struct thread *p)
2808{
2809 /* bind a ep to a socket address */
2810 struct sctppcbhead *head;
2811 struct sctp_inpcb *inp, *inp_tmp;
2812 struct inpcb *ip_inp;
2813 int port_reuse_active = 0;
2814 int bindall;
2815 uint16_t lport;
2816 int error;
2817 uint32_t vrf_id;
2818
2819 lport = 0;
2820 bindall = 1;
2821 inp = (struct sctp_inpcb *)so->so_pcb;
2822 ip_inp = (struct inpcb *)so->so_pcb;
2823#ifdef SCTP_DEBUG
2824 if (addr) {
2825 SCTPDBG(SCTP_DEBUG_PCB1, "Bind called port: %d\n",
2826 ntohs(((struct sockaddr_in *)addr)->sin_port));
2827 SCTPDBG(SCTP_DEBUG_PCB1, "Addr: ");
2828 SCTPDBG_ADDR(SCTP_DEBUG_PCB1, addr);
2829 }
2830#endif
2831 if ((inp->sctp_flags & SCTP_PCB_FLAGS_UNBOUND) == 0) {
2832 /* already did a bind, subsequent binds NOT allowed ! */
2833 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2834 return (EINVAL);
2835 }
2836#ifdef INVARIANTS
2837 if (p == NULL)
2838 panic("null proc/thread");
2839#endif
2840 if (addr != NULL) {
2841 switch (addr->sa_family) {
2842#ifdef INET
2843 case AF_INET:
2844 {
2845 struct sockaddr_in *sin;
2846
2847 /* IPV6_V6ONLY socket? */
2848 if (SCTP_IPV6_V6ONLY(inp)) {
2849 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2850 return (EINVAL);
2851 }
2852 if (addr->sa_len != sizeof(*sin)) {
2853 SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PCB, EINVAL);
2854 return (EINVAL);
2855 }
2856
2857 sin = (struct sockaddr_in *)addr;
2858 lport = sin->sin_port;
2859 /*
2860 * For LOOPBACK the prison_local_ip4() call
2861 * will transmute the ip address to the
2862 * proper value.

Callers 7

sctp_bindx_add_addressFunction · 0.85
sctp_bindFunction · 0.85
sctp_do_connect_xFunction · 0.85
sctp_connectFunction · 0.85
sctp_listenFunction · 0.85
sctp_aloc_assocFunction · 0.85
sctp6_bindFunction · 0.85

Calls 12

sa6_embedscopeFunction · 0.85
sctp_pcb_findepFunction · 0.85
sctp_isport_inuseFunction · 0.85
sctp_select_initial_TSNFunction · 0.85
memsetFunction · 0.85
sctp_find_ifa_by_addrFunction · 0.85
sctp_insert_laddrFunction · 0.85
prison_local_ip4Function · 0.70
panicFunction · 0.50
prison_local_ip6Function · 0.50
priv_checkFunction · 0.50
memcpyFunction · 0.50

Tested by

no test coverage detected