• Home
  • Raw
  • Download

Lines Matching refs:addr

40 static inline uint16_t dn_ntohs(uint16_t addr)  in dn_ntohs()  argument
46 .word = addr, in dn_ntohs()
52 static inline int do_digit(char *str, uint16_t *addr, uint16_t scale, in do_digit() argument
55 uint16_t tmp = *addr / scale; in do_digit()
64 *addr -= (tmp * scale); in do_digit()
73 uint16_t addr = dn_ntohs(*(uint16_t *)addrbuf); in dnet_ntop() local
74 uint16_t area = addr >> 10; in dnet_ntop()
81 addr &= 0x03ff; in dnet_ntop()
99 if (do_digit(str + pos, &addr, 1000, &pos, len, &started)) in dnet_ntop()
102 if (do_digit(str + pos, &addr, 100, &pos, len, &started)) in dnet_ntop()
105 if (do_digit(str + pos, &addr, 10, &pos, len, &started)) in dnet_ntop()
108 if (do_digit(str + pos, &addr, 1, &pos, len, &started)) in dnet_ntop()
158 static void addr_destroy(struct nl_addr *addr) in addr_destroy() argument
160 if (!addr) in addr_destroy()
163 if (addr->a_refcnt != 1) in addr_destroy()
166 free(addr); in addr_destroy()
189 struct nl_addr *addr; in nl_addr_alloc() local
191 addr = calloc(1, sizeof(*addr) + maxsize); in nl_addr_alloc()
192 if (!addr) in nl_addr_alloc()
195 addr->a_refcnt = 1; in nl_addr_alloc()
196 addr->a_maxsize = maxsize; in nl_addr_alloc()
198 return addr; in nl_addr_alloc()
220 struct nl_addr *addr; in nl_addr_build() local
222 addr = nl_addr_alloc(size); in nl_addr_build()
223 if (!addr) in nl_addr_build()
226 addr->a_family = family; in nl_addr_build()
227 addr->a_len = size; in nl_addr_build()
230 addr->a_prefixlen = 20; /* MPLS address is a 20-bit label */ in nl_addr_build()
233 addr->a_prefixlen = size*8; in nl_addr_build()
237 memcpy(addr->a_addr, buf, size); in nl_addr_build()
239 return addr; in nl_addr_build()
303 struct nl_addr *addr = NULL; /* gcc ain't that smart */ in nl_addr_parse() local
449 addr = nl_addr_alloc(len); in nl_addr_parse()
450 if (!addr) { in nl_addr_parse()
455 nl_addr_set_family(addr, family); in nl_addr_parse()
458 nl_addr_set_binary_addr(addr, buf, len); in nl_addr_parse()
464 addr_destroy(addr); in nl_addr_parse()
468 nl_addr_set_prefixlen(addr, pl); in nl_addr_parse()
472 nl_addr_set_prefixlen(addr, plen); in nl_addr_parse()
474 *result = addr; in nl_addr_parse()
494 struct nl_addr *nl_addr_clone(const struct nl_addr *addr) in nl_addr_clone() argument
498 new = nl_addr_build(addr->a_family, addr->a_addr, addr->a_len); in nl_addr_clone()
500 new->a_prefixlen = addr->a_prefixlen; in nl_addr_clone()
524 struct nl_addr *nl_addr_get(struct nl_addr *addr) in nl_addr_get() argument
526 addr->a_refcnt++; in nl_addr_get()
528 return addr; in nl_addr_get()
540 void nl_addr_put(struct nl_addr *addr) in nl_addr_put() argument
542 if (!addr) in nl_addr_put()
545 if (addr->a_refcnt == 1) in nl_addr_put()
546 addr_destroy(addr); in nl_addr_put()
548 addr->a_refcnt--; in nl_addr_put()
557 int nl_addr_shared(const struct nl_addr *addr) in nl_addr_shared() argument
559 return addr->a_refcnt > 1; in nl_addr_shared()
651 int nl_addr_iszero(const struct nl_addr *addr) in nl_addr_iszero() argument
655 for (i = 0; i < addr->a_len; i++) in nl_addr_iszero()
656 if (addr->a_addr[i]) in nl_addr_iszero()
670 int nl_addr_valid(const char *addr, int family) in nl_addr_valid() argument
678 ret = inet_pton(family, addr, buf); in nl_addr_valid()
684 ret = mpls_pton(family, addr, buf, sizeof(buf)); in nl_addr_valid()
690 ret = dnet_pton(addr, buf); in nl_addr_valid()
696 if (sscanf(addr, "%*02x:%*02x:%*02x:%*02x:%*02x:%*02x") != 6) in nl_addr_valid()
710 int nl_addr_guess_family(const struct nl_addr *addr) in nl_addr_guess_family() argument
712 switch (addr->a_len) { in nl_addr_guess_family()
737 int nl_addr_fill_sockaddr(const struct nl_addr *addr, struct sockaddr *sa, in nl_addr_fill_sockaddr() argument
740 switch (addr->a_family) { in nl_addr_fill_sockaddr()
747 if (addr->a_len == 4) in nl_addr_fill_sockaddr()
748 memcpy(&sai->sin_addr, addr->a_addr, 4); in nl_addr_fill_sockaddr()
749 else if (addr->a_len != 0) in nl_addr_fill_sockaddr()
754 sai->sin_family = addr->a_family; in nl_addr_fill_sockaddr()
765 if (addr->a_len == 16) in nl_addr_fill_sockaddr()
766 memcpy(&sa6->sin6_addr, addr->a_addr, 16); in nl_addr_fill_sockaddr()
767 else if (addr->a_len != 0) in nl_addr_fill_sockaddr()
772 sa6->sin6_family = addr->a_family; in nl_addr_fill_sockaddr()
805 int nl_addr_info(const struct nl_addr *addr, struct addrinfo **result) in nl_addr_info() argument
811 .ai_family = addr->a_family, in nl_addr_info()
814 nl_addr2str(addr, buf, sizeof(buf)); in nl_addr_info()
849 int nl_addr_resolve(const struct nl_addr *addr, char *host, size_t hostlen) in nl_addr_resolve() argument
855 err = nl_addr_fill_sockaddr(addr, (struct sockaddr *) &buf, &salen); in nl_addr_resolve()
881 void nl_addr_set_family(struct nl_addr *addr, int family) in nl_addr_set_family() argument
883 addr->a_family = family; in nl_addr_set_family()
894 int nl_addr_get_family(const struct nl_addr *addr) in nl_addr_get_family() argument
896 return addr->a_family; in nl_addr_get_family()
919 int nl_addr_set_binary_addr(struct nl_addr *addr, const void *buf, size_t len) in nl_addr_set_binary_addr() argument
921 if (len > addr->a_maxsize) in nl_addr_set_binary_addr()
924 addr->a_len = len; in nl_addr_set_binary_addr()
925 memset(addr->a_addr, 0, addr->a_maxsize); in nl_addr_set_binary_addr()
928 memcpy(addr->a_addr, buf, len); in nl_addr_set_binary_addr()
942 void *nl_addr_get_binary_addr(const struct nl_addr *addr) in nl_addr_get_binary_addr() argument
944 return (void*)addr->a_addr; in nl_addr_get_binary_addr()
954 unsigned int nl_addr_get_len(const struct nl_addr *addr) in nl_addr_get_len() argument
956 return addr->a_len; in nl_addr_get_len()
966 void nl_addr_set_prefixlen(struct nl_addr *addr, int prefixlen) in nl_addr_set_prefixlen() argument
968 addr->a_prefixlen = prefixlen; in nl_addr_set_prefixlen()
977 unsigned int nl_addr_get_prefixlen(const struct nl_addr *addr) in nl_addr_get_prefixlen() argument
979 return addr->a_prefixlen; in nl_addr_get_prefixlen()
1000 char *nl_addr2str(const struct nl_addr *addr, char *buf, size_t size) in nl_addr2str() argument
1005 if (!addr || !addr->a_len) { in nl_addr2str()
1007 if (addr) in nl_addr2str()
1013 switch (addr->a_family) { in nl_addr2str()
1015 inet_ntop(AF_INET, addr->a_addr, buf, size); in nl_addr2str()
1019 inet_ntop(AF_INET6, addr->a_addr, buf, size); in nl_addr2str()
1023 mpls_ntop(AF_MPLS, addr->a_addr, buf, size); in nl_addr2str()
1027 dnet_ntop(addr->a_addr, addr->a_len, buf, size); in nl_addr2str()
1033 (unsigned char) addr->a_addr[0]); in nl_addr2str()
1034 for (i = 1; i < addr->a_len; i++) { in nl_addr2str()
1036 (unsigned char) addr->a_addr[i]); in nl_addr2str()
1043 if (addr->a_family != AF_MPLS && in nl_addr2str()
1044 addr->a_prefixlen != (8 * addr->a_len)) { in nl_addr2str()
1045 snprintf(tmp, sizeof(tmp), "/%u", addr->a_prefixlen); in nl_addr2str()