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

Function sctp_pcb_findep

freebsd/netinet/sctp_pcb.c:1892–1966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1890}
1891
1892struct sctp_inpcb *
1893sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock,
1894 uint32_t vrf_id)
1895{
1896 /*
1897 * First we check the hash table to see if someone has this port
1898 * bound with just the port.
1899 */
1900 struct sctp_inpcb *inp;
1901 struct sctppcbhead *head;
1902 int lport;
1903 unsigned int i;
1904#ifdef INET
1905 struct sockaddr_in *sin;
1906#endif
1907#ifdef INET6
1908 struct sockaddr_in6 *sin6;
1909#endif
1910
1911 switch (nam->sa_family) {
1912#ifdef INET
1913 case AF_INET:
1914 sin = (struct sockaddr_in *)nam;
1915 lport = sin->sin_port;
1916 break;
1917#endif
1918#ifdef INET6
1919 case AF_INET6:
1920 sin6 = (struct sockaddr_in6 *)nam;
1921 lport = sin6->sin6_port;
1922 break;
1923#endif
1924 default:
1925 return (NULL);
1926 }
1927 /*
1928 * I could cheat here and just cast to one of the types but we will
1929 * do it right. It also provides the check against an Unsupported
1930 * type too.
1931 */
1932 /* Find the head of the ALLADDR chain */
1933 if (have_lock == 0) {
1934 SCTP_INP_INFO_RLOCK();
1935 }
1936 head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(lport,
1937 SCTP_BASE_INFO(hashmark))];
1938 inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
1939
1940 /*
1941 * If the TCP model exists it could be that the main listening
1942 * endpoint is gone but there still exists a connected socket for
1943 * this guy. If so we can return the first one that we find. This
1944 * may NOT be the correct one so the caller should be wary on the
1945 * returned INP. Currently the only caller that sets find_tcp_pool
1946 * is in bindx where we are verifying that a user CAN bind the
1947 * address. He either has bound it already, or someone else has, or
1948 * its open to bind, so this is good enough.
1949 */

Callers 4

sctp_bindx_add_addressFunction · 0.85
sctp_listenFunction · 0.85
sctp_inpcb_bindFunction · 0.85

Calls 1

sctp_endpoint_probeFunction · 0.85

Tested by

no test coverage detected