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

Function sctp_is_address_in_scope

freebsd/netinet/sctp_output.c:1866–1937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1864};
1865
1866int
1867sctp_is_address_in_scope(struct sctp_ifa *ifa,
1868 struct sctp_scoping *scope,
1869 int do_update)
1870{
1871 if ((scope->loopback_scope == 0) &&
1872 (ifa->ifn_p) && SCTP_IFN_IS_IFT_LOOP(ifa->ifn_p)) {
1873 /*
1874 * skip loopback if not in scope *
1875 */
1876 return (0);
1877 }
1878 switch (ifa->address.sa.sa_family) {
1879#ifdef INET
1880 case AF_INET:
1881 if (scope->ipv4_addr_legal) {
1882 struct sockaddr_in *sin;
1883
1884 sin = &ifa->address.sin;
1885 if (sin->sin_addr.s_addr == 0) {
1886 /* not in scope , unspecified */
1887 return (0);
1888 }
1889 if ((scope->ipv4_local_scope == 0) &&
1890 (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr))) {
1891 /* private address not in scope */
1892 return (0);
1893 }
1894 } else {
1895 return (0);
1896 }
1897 break;
1898#endif
1899#ifdef INET6
1900 case AF_INET6:
1901 if (scope->ipv6_addr_legal) {
1902 struct sockaddr_in6 *sin6;
1903
1904 /*
1905 * Must update the flags, bummer, which means any
1906 * IFA locks must now be applied HERE <->
1907 */
1908 if (do_update) {
1909 sctp_gather_internal_ifa_flags(ifa);
1910 }
1911 if (ifa->localifa_flags & SCTP_ADDR_IFA_UNUSEABLE) {
1912 return (0);
1913 }
1914 /* ok to use deprecated addresses? */
1915 sin6 = &ifa->address.sin6;
1916 if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
1917 /* skip unspecifed addresses */
1918 return (0);
1919 }
1920 if ( /* (local_scope == 0) && */
1921 (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))) {
1922 return (0);
1923 }

Calls 1

Tested by

no test coverage detected