Check for Link Local. @return @true if @a ip is link local.
| 764 | /// Check for Link Local. |
| 765 | /// @return @true if @a ip is link local. |
| 766 | inline bool |
| 767 | ats_is_ip_linklocal(sockaddr const *ip) |
| 768 | { |
| 769 | bool zret = false; |
| 770 | if (ats_is_ip4(ip)) { |
| 771 | in_addr_t a = ats_ip4_addr_cast(ip); |
| 772 | zret = ((a & htonl(0xFFFF0000)) == htonl(0xA9FE0000)) // 169.254.0.0/16 |
| 773 | ; |
| 774 | } else if (ats_is_ip6(ip)) { |
| 775 | in6_addr a = ats_ip6_addr_cast(ip); |
| 776 | zret = ((a.s6_addr[0] == 0xFE) && ((a.s6_addr[1] & 0xC0) == 0x80)) // fe80::/10 |
| 777 | ; |
| 778 | } |
| 779 | return zret; |
| 780 | } |
| 781 | |
| 782 | /// Check for Link Local. |
| 783 | /// @return @true if @a ip is link local. |
no test coverage detected