• Home
  • Raw
  • Download

Lines Matching refs:range

413   struct ncprange range;  in ncpaddr_aton()  local
415 if (!ncprange_aton(&range, ncp, data)) in ncpaddr_aton()
418 if (range.ncprange_family == AF_INET && range.ncprange_ip4width != 32 && in ncpaddr_aton()
419 range.ncprange_ip4addr.s_addr != INADDR_ANY) { in ncpaddr_aton()
425 if (range.ncprange_family == AF_INET6 && range.ncprange_ip6width != 128 && in ncpaddr_aton()
426 !IN6_IS_ADDR_UNSPECIFIED(&range.ncprange_ip6addr)) { in ncpaddr_aton()
432 switch (range.ncprange_family) { in ncpaddr_aton()
434 addr->ncpaddr_family = range.ncprange_family; in ncpaddr_aton()
435 addr->ncpaddr_ip4addr = range.ncprange_ip4addr; in ncpaddr_aton()
440 addr->ncpaddr_family = range.ncprange_family; in ncpaddr_aton()
441 addr->ncpaddr_ip6addr = range.ncprange_ip6addr; in ncpaddr_aton()
450 ncprange_init(struct ncprange *range) in ncprange_init() argument
452 range->ncprange_family = AF_UNSPEC; in ncprange_init()
456 ncprange_isset(const struct ncprange *range) in ncprange_isset() argument
458 return range->ncprange_family != AF_UNSPEC; in ncprange_isset()
462 ncprange_equal(const struct ncprange *range, const struct ncprange *cmp) in ncprange_equal() argument
464 if (range->ncprange_family != cmp->ncprange_family) in ncprange_equal()
467 switch (range->ncprange_family) { in ncprange_equal()
469 if (range->ncprange_ip4addr.s_addr != cmp->ncprange_ip4addr.s_addr) in ncprange_equal()
471 return range->ncprange_ip4mask.s_addr == cmp->ncprange_ip4mask.s_addr; in ncprange_equal()
475 if (range->ncprange_ip6width != cmp->ncprange_ip6width) in ncprange_equal()
477 return !memcmp(&range->ncprange_ip6addr, &cmp->ncprange_ip6addr, in ncprange_equal()
478 sizeof range->ncprange_ip6addr); in ncprange_equal()
489 ncprange_isdefault(const struct ncprange *range) in ncprange_isdefault() argument
491 switch (range->ncprange_family) { in ncprange_isdefault()
493 if (range->ncprange_ip4addr.s_addr == INADDR_ANY) in ncprange_isdefault()
499 if (range->ncprange_ip6width == 0 && in ncprange_isdefault()
500 IN6_IS_ADDR_UNSPECIFIED(&range->ncprange_ip6addr)) in ncprange_isdefault()
510 ncprange_setdefault(struct ncprange *range, int af) in ncprange_setdefault() argument
512 memset(range, '\0', sizeof *range); in ncprange_setdefault()
513 range->ncprange_family = af; in ncprange_setdefault()
517 ncprange_contains(const struct ncprange *range, const struct ncpaddr *addr) in ncprange_contains() argument
525 if (range->ncprange_family != addr->ncpaddr_family) in ncprange_contains()
528 switch (range->ncprange_family) { in ncprange_contains()
530 return !((addr->ncpaddr_ip4addr.s_addr ^ range->ncprange_ip4addr.s_addr) & in ncprange_contains()
531 range->ncprange_ip4mask.s_addr); in ncprange_contains()
535 rangep = (const u_char *)range->ncprange_ip6addr.s6_addr; in ncprange_contains()
538 for (bits = range->ncprange_ip6width; bits > 0; bits -= 8) in ncprange_contains()
550 ncprange_containsip4(const struct ncprange *range, struct in_addr addr) in ncprange_containsip4() argument
552 switch (range->ncprange_family) { in ncprange_containsip4()
554 return !((addr.s_addr ^ range->ncprange_ip4addr.s_addr) & in ncprange_containsip4()
555 range->ncprange_ip4mask.s_addr); in ncprange_containsip4()
562 ncprange_copy(struct ncprange *range, const struct ncprange *from) in ncprange_copy() argument
566 range->ncprange_family = AF_INET; in ncprange_copy()
567 range->ncprange_ip4addr = from->ncprange_ip4addr; in ncprange_copy()
568 range->ncprange_ip4mask = from->ncprange_ip4mask; in ncprange_copy()
569 range->ncprange_ip4width = from->ncprange_ip4width; in ncprange_copy()
574 range->ncprange_family = AF_INET6; in ncprange_copy()
575 range->ncprange_ip6addr = from->ncprange_ip6addr; in ncprange_copy()
576 range->ncprange_ip6width = from->ncprange_ip6width; in ncprange_copy()
581 range->ncprange_family = AF_UNSPEC; in ncprange_copy()
586 ncprange_set(struct ncprange *range, const struct ncpaddr *addr, int width) in ncprange_set() argument
588 ncprange_sethost(range, addr); in ncprange_set()
589 ncprange_setwidth(range, width); in ncprange_set()
593 ncprange_sethost(struct ncprange *range, const struct ncpaddr *from) in ncprange_sethost() argument
597 range->ncprange_family = AF_INET; in ncprange_sethost()
598 range->ncprange_ip4addr = from->ncpaddr_ip4addr; in ncprange_sethost()
600 range->ncprange_ip4mask.s_addr = INADDR_ANY; in ncprange_sethost()
601 range->ncprange_ip4width = 0; in ncprange_sethost()
603 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_sethost()
604 range->ncprange_ip4width = 32; in ncprange_sethost()
610 range->ncprange_family = AF_INET6; in ncprange_sethost()
611 range->ncprange_ip6addr = from->ncpaddr_ip6addr; in ncprange_sethost()
612 range->ncprange_ip6width = 128; in ncprange_sethost()
617 range->ncprange_family = AF_UNSPEC; in ncprange_sethost()
622 ncprange_ishost(const struct ncprange *range) in ncprange_ishost() argument
624 switch (range->ncprange_family) { in ncprange_ishost()
626 return range->ncprange_ip4width == 32; in ncprange_ishost()
629 return range->ncprange_ip6width == 128; in ncprange_ishost()
637 ncprange_setwidth(struct ncprange *range, int width) in ncprange_setwidth() argument
639 switch (range->ncprange_family) { in ncprange_setwidth()
643 range->ncprange_ip4width = width; in ncprange_setwidth()
644 range->ncprange_ip4mask = bits2mask4(width); in ncprange_setwidth()
651 range->ncprange_ip6width = width; in ncprange_setwidth()
663 ncprange_setip4host(struct ncprange *range, struct in_addr from) in ncprange_setip4host() argument
665 range->ncprange_family = AF_INET; in ncprange_setip4host()
666 range->ncprange_ip4addr = from; in ncprange_setip4host()
668 range->ncprange_ip4mask.s_addr = INADDR_ANY; in ncprange_setip4host()
669 range->ncprange_ip4width = 0; in ncprange_setip4host()
671 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_setip4host()
672 range->ncprange_ip4width = 32; in ncprange_setip4host()
677 ncprange_setip4(struct ncprange *range, struct in_addr from, struct in_addr msk) in ncprange_setip4() argument
679 range->ncprange_family = AF_INET; in ncprange_setip4()
680 range->ncprange_ip4addr = from; in ncprange_setip4()
681 range->ncprange_ip4mask = msk; in ncprange_setip4()
682 range->ncprange_ip4width = mask42bits(msk); in ncprange_setip4()
687 ncprange_setip4mask(struct ncprange *range, struct in_addr mask) in ncprange_setip4mask() argument
689 if (range->ncprange_family != AF_INET) in ncprange_setip4mask()
691 range->ncprange_ip4mask = mask; in ncprange_setip4mask()
692 range->ncprange_ip4width = mask42bits(mask); in ncprange_setip4mask()
697 ncprange_setsa(struct ncprange *range, const struct sockaddr *host, in ncprange_setsa() argument
709 range->ncprange_family = AF_INET; in ncprange_setsa()
710 range->ncprange_ip4addr = host4->sin_addr; in ncprange_setsa()
712 range->ncprange_ip4mask.s_addr = INADDR_ANY; in ncprange_setsa()
713 range->ncprange_ip4width = 0; in ncprange_setsa()
715 range->ncprange_ip4mask.s_addr = mask4->sin_addr.s_addr; in ncprange_setsa()
716 range->ncprange_ip4width = mask42bits(mask4->sin_addr); in ncprange_setsa()
718 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_setsa()
719 range->ncprange_ip4width = 32; in ncprange_setsa()
725 range->ncprange_family = AF_INET6; in ncprange_setsa()
726 range->ncprange_ip6addr = host6->sin6_addr; in ncprange_setsa()
728 range->ncprange_ip6width = 0; in ncprange_setsa()
730 range->ncprange_ip6width = mask6 ? mask62bits(&mask6->sin6_addr) : 128; in ncprange_setsa()
735 range->ncprange_family = AF_UNSPEC; in ncprange_setsa()
740 ncprange_getsa(const struct ncprange *range, struct sockaddr_storage *host, in ncprange_getsa() argument
754 switch (range->ncprange_family) { in ncprange_getsa()
758 host4->sin_addr = range->ncprange_ip4addr; in ncprange_getsa()
762 mask4->sin_addr = range->ncprange_ip4mask; in ncprange_getsa()
770 host6->sin6_addr = range->ncprange_ip6addr; in ncprange_getsa()
774 mask6->sin6_addr = bits2mask6(range->ncprange_ip6width); in ncprange_getsa()
788 ncprange_getaddr(const struct ncprange *range, struct ncpaddr *addr) in ncprange_getaddr() argument
790 switch (range->ncprange_family) { in ncprange_getaddr()
793 addr->ncpaddr_ip4addr = range->ncprange_ip4addr; in ncprange_getaddr()
798 addr->ncpaddr_ip6addr = range->ncprange_ip6addr; in ncprange_getaddr()
807 ncprange_getip4addr(const struct ncprange *range, struct in_addr *addr) in ncprange_getip4addr() argument
809 if (range->ncprange_family != AF_INET) in ncprange_getip4addr()
812 *addr = range->ncprange_ip4addr; in ncprange_getip4addr()
817 ncprange_getip4mask(const struct ncprange *range, struct in_addr *mask) in ncprange_getip4mask() argument
819 switch (range->ncprange_family) { in ncprange_getip4mask()
821 *mask = range->ncprange_ip4mask; in ncprange_getip4mask()
829 ncprange_getwidth(const struct ncprange *range, int *width) in ncprange_getwidth() argument
831 switch (range->ncprange_family) { in ncprange_getwidth()
833 *width = range->ncprange_ip4width; in ncprange_getwidth()
837 *width = range->ncprange_ip6width; in ncprange_getwidth()
846 ncprange_ntoa(const struct ncprange *range) in ncprange_ntoa() argument
852 if (!ncprange_getaddr(range, &addr)) in ncprange_ntoa()
860 switch (range->ncprange_family) { in ncprange_ntoa()
862 if (range->ncprange_ip4width == -1) { in ncprange_ntoa()
868 (unsigned long)ntohl(range->ncprange_ip4mask.s_addr)); in ncprange_ntoa()
869 } else if (range->ncprange_ip4width < 32) in ncprange_ntoa()
870 snprintf(res + len, sizeof res - len, "/%d", range->ncprange_ip4width); in ncprange_ntoa()
876 if (range->ncprange_ip6width != 128) in ncprange_ntoa()
877 snprintf(res + len, sizeof res - len, "/%d", range->ncprange_ip6width); in ncprange_ntoa()
888 ncprange_scopeid(const struct ncprange *range) in ncprange_scopeid() argument
893 if (range->ncprange_family == AF_INET6) { in ncprange_scopeid()
894 sin6 = &range->ncprange_ip6addr; in ncprange_scopeid()
905 ncprange_aton(struct ncprange *range, struct ncp *ncp, const char *data) in ncprange_aton() argument
915 range->ncprange_family = AF_INET; in ncprange_aton()
916 range->ncprange_ip4addr = ncp->ipcp.peer_ip; in ncprange_aton()
917 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_aton()
918 range->ncprange_ip4width = 32; in ncprange_aton()
922 range->ncprange_family = AF_INET6; in ncprange_aton()
923 range->ncprange_ip6addr = ncp->ipv6cp.hisaddr.ncpaddr_ip6addr; in ncprange_aton()
924 range->ncprange_ip6width = 128; in ncprange_aton()
928 range->ncprange_family = AF_INET; in ncprange_aton()
929 range->ncprange_ip4addr = ncp->ipcp.my_ip; in ncprange_aton()
930 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_aton()
931 range->ncprange_ip4width = 32; in ncprange_aton()
935 range->ncprange_family = AF_INET6; in ncprange_aton()
936 range->ncprange_ip6addr = ncp->ipv6cp.myaddr.ncpaddr_ip6addr; in ncprange_aton()
937 range->ncprange_ip6width = 128; in ncprange_aton()
941 range->ncprange_family = AF_INET; in ncprange_aton()
942 range->ncprange_ip4addr = ncp->ipcp.ns.dns[0]; in ncprange_aton()
943 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_aton()
944 range->ncprange_ip4width = 32; in ncprange_aton()
947 range->ncprange_family = AF_INET; in ncprange_aton()
948 range->ncprange_ip4addr = ncp->ipcp.ns.dns[1]; in ncprange_aton()
949 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_aton()
950 range->ncprange_ip4width = 32; in ncprange_aton()
968 range->ncprange_family = AF_INET; in ncprange_aton()
970 range->ncprange_ip4addr = GetIpAddr(s); in ncprange_aton()
972 if (range->ncprange_ip4addr.s_addr == INADDR_NONE) { in ncprange_aton()
977 if (range->ncprange_ip4addr.s_addr == INADDR_ANY) { in ncprange_aton()
978 range->ncprange_ip4mask.s_addr = INADDR_ANY; in ncprange_aton()
979 range->ncprange_ip4width = 0; in ncprange_aton()
981 range->ncprange_ip4mask.s_addr = INADDR_BROADCAST; in ncprange_aton()
982 range->ncprange_ip4width = 32; in ncprange_aton()
987 range->ncprange_ip4mask = bits2mask4(bits); in ncprange_aton()
988 range->ncprange_ip4width = bits; in ncprange_aton()
994 range->ncprange_family = AF_INET6; in ncprange_aton()
996 if (inet_pton(AF_INET6, s, &range->ncprange_ip6addr) != 1) { in ncprange_aton()
1001 if (IN6_IS_ADDR_UNSPECIFIED(&range->ncprange_ip6addr)) in ncprange_aton()
1002 range->ncprange_ip6width = 0; in ncprange_aton()
1004 range->ncprange_ip6width = (bits == -1) ? 128 : bits; in ncprange_aton()