Lines Matching refs:addr
137 struct rtnl_addr *addr = nl_object_priv(obj); in addr_constructor() local
139 addr->a_scope = RT_SCOPE_NOWHERE; in addr_constructor()
144 struct rtnl_addr *addr = nl_object_priv(obj); in addr_free_data() local
146 if (!addr) in addr_free_data()
149 nl_addr_put(addr->a_peer); in addr_free_data()
150 nl_addr_put(addr->a_local); in addr_free_data()
151 nl_addr_put(addr->a_bcast); in addr_free_data()
152 nl_addr_put(addr->a_multicast); in addr_free_data()
153 nl_addr_put(addr->a_anycast); in addr_free_data()
193 struct rtnl_addr *addr; in addr_msg_parser() local
198 addr = rtnl_addr_alloc(); in addr_msg_parser()
199 if (!addr) in addr_msg_parser()
202 addr->ce_msgtype = nlh->nlmsg_type; in addr_msg_parser()
209 addr->a_family = family = ifa->ifa_family; in addr_msg_parser()
210 addr->a_prefixlen = ifa->ifa_prefixlen; in addr_msg_parser()
211 addr->a_flags = ifa->ifa_flags; in addr_msg_parser()
212 addr->a_scope = ifa->ifa_scope; in addr_msg_parser()
213 addr->a_ifindex = ifa->ifa_index; in addr_msg_parser()
215 addr->ce_mask = (ADDR_ATTR_FAMILY | ADDR_ATTR_PREFIXLEN | in addr_msg_parser()
219 nla_strlcpy(addr->a_label, tb[IFA_LABEL], IFNAMSIZ); in addr_msg_parser()
220 addr->ce_mask |= ADDR_ATTR_LABEL; in addr_msg_parser()
227 addr->a_cacheinfo.aci_prefered = ca->ifa_prefered; in addr_msg_parser()
228 addr->a_cacheinfo.aci_valid = ca->ifa_valid; in addr_msg_parser()
229 addr->a_cacheinfo.aci_cstamp = ca->cstamp; in addr_msg_parser()
230 addr->a_cacheinfo.aci_tstamp = ca->tstamp; in addr_msg_parser()
231 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in addr_msg_parser()
235 addr->a_local = nl_addr_alloc_attr(tb[IFA_LOCAL], family); in addr_msg_parser()
236 if (!addr->a_local) in addr_msg_parser()
238 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
251 if (!tb[IFA_LOCAL] || !nl_addr_cmp(a, addr->a_local)) { in addr_msg_parser()
252 nl_addr_put(addr->a_local); in addr_msg_parser()
253 addr->a_local = a; in addr_msg_parser()
254 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
256 addr->a_peer = a; in addr_msg_parser()
257 addr->ce_mask |= ADDR_ATTR_PEER; in addr_msg_parser()
262 nl_addr_set_prefixlen(peer_prefix ? addr->a_peer : addr->a_local, in addr_msg_parser()
263 addr->a_prefixlen); in addr_msg_parser()
266 addr->a_bcast = nl_addr_alloc_attr(tb[IFA_BROADCAST], family); in addr_msg_parser()
267 if (!addr->a_bcast) in addr_msg_parser()
270 addr->ce_mask |= ADDR_ATTR_BROADCAST; in addr_msg_parser()
274 addr->a_multicast = nl_addr_alloc_attr(tb[IFA_MULTICAST], in addr_msg_parser()
276 if (!addr->a_multicast) in addr_msg_parser()
279 addr->ce_mask |= ADDR_ATTR_MULTICAST; in addr_msg_parser()
283 addr->a_anycast = nl_addr_alloc_attr(tb[IFA_ANYCAST], in addr_msg_parser()
285 if (!addr->a_anycast) in addr_msg_parser()
288 addr->ce_mask |= ADDR_ATTR_ANYCAST; in addr_msg_parser()
291 err = pp->pp_cb((struct nl_object *) addr, pp); in addr_msg_parser()
293 rtnl_addr_put(addr); in addr_msg_parser()
309 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_line() local
315 if (addr->ce_mask & ADDR_ATTR_LOCAL) in addr_dump_line()
317 nl_addr2str(addr->a_local, buf, sizeof(buf))); in addr_dump_line()
321 if (addr->ce_mask & ADDR_ATTR_PEER) in addr_dump_line()
323 nl_addr2str(addr->a_peer, buf, sizeof(buf))); in addr_dump_line()
325 nl_dump(p, " %s ", nl_af2str(addr->a_family, buf, sizeof(buf))); in addr_dump_line()
329 rtnl_link_i2name(link_cache, addr->a_ifindex, in addr_dump_line()
332 nl_dump(p, "dev %d ", addr->a_ifindex); in addr_dump_line()
335 rtnl_scope2str(addr->a_scope, buf, sizeof(buf))); in addr_dump_line()
337 rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf)); in addr_dump_line()
346 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_details() local
351 if (addr->ce_mask & (ADDR_ATTR_LABEL | ADDR_ATTR_BROADCAST | in addr_dump_details()
355 if (addr->ce_mask & ADDR_ATTR_LABEL) in addr_dump_details()
356 nl_dump(p, " label %s", addr->a_label); in addr_dump_details()
358 if (addr->ce_mask & ADDR_ATTR_BROADCAST) in addr_dump_details()
360 nl_addr2str(addr->a_bcast, buf, sizeof(buf))); in addr_dump_details()
362 if (addr->ce_mask & ADDR_ATTR_MULTICAST) in addr_dump_details()
364 nl_addr2str(addr->a_multicast, buf, in addr_dump_details()
367 if (addr->ce_mask & ADDR_ATTR_ANYCAST) in addr_dump_details()
369 nl_addr2str(addr->a_anycast, buf, in addr_dump_details()
375 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) { in addr_dump_details()
376 struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo; in addr_dump_details()
389 nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10, in addr_dump_details()
393 nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10, in addr_dump_details()
405 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_env() local
410 nl_af2str(addr->a_family, buf, sizeof(buf))); in addr_dump_env()
412 if (addr->ce_mask & ADDR_ATTR_LOCAL) in addr_dump_env()
414 nl_addr2str(addr->a_local, buf, sizeof(buf))); in addr_dump_env()
416 if (addr->ce_mask & ADDR_ATTR_PEER) in addr_dump_env()
418 nl_addr2str(addr->a_peer, buf, sizeof(buf))); in addr_dump_env()
420 if (addr->ce_mask & ADDR_ATTR_BROADCAST) in addr_dump_env()
422 nl_addr2str(addr->a_bcast, buf, sizeof(buf))); in addr_dump_env()
424 if (addr->ce_mask & ADDR_ATTR_ANYCAST) in addr_dump_env()
426 nl_addr2str(addr->a_anycast, buf, sizeof(buf))); in addr_dump_env()
428 if (addr->ce_mask & ADDR_ATTR_MULTICAST) in addr_dump_env()
430 nl_addr2str(addr->a_multicast, buf, in addr_dump_env()
433 if (addr->ce_mask & ADDR_ATTR_PREFIXLEN) in addr_dump_env()
435 addr->a_prefixlen); in addr_dump_env()
438 nl_dump_line(p, "ADDR_IFINDEX=%u\n", addr->a_ifindex); in addr_dump_env()
441 rtnl_link_i2name(link_cache, addr->a_ifindex, in addr_dump_env()
444 if (addr->ce_mask & ADDR_ATTR_SCOPE) in addr_dump_env()
446 rtnl_scope2str(addr->a_scope, buf, sizeof(buf))); in addr_dump_env()
448 if (addr->ce_mask & ADDR_ATTR_LABEL) in addr_dump_env()
449 nl_dump_line(p, "ADDR_LABEL=%s\n", addr->a_label); in addr_dump_env()
451 rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf)); in addr_dump_env()
455 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) { in addr_dump_env()
456 struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo; in addr_dump_env()
469 nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10, in addr_dump_env()
473 nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10, in addr_dump_env()
539 void rtnl_addr_put(struct rtnl_addr *addr) in rtnl_addr_put() argument
541 nl_object_put((struct nl_object *) addr); in rtnl_addr_put()
646 int rtnl_addr_build_add_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_add_request() argument
652 if ((addr->ce_mask & required) != required) in rtnl_addr_build_add_request()
655 return build_addr_msg(addr, RTM_NEWADDR, NLM_F_CREATE | flags, result); in rtnl_addr_build_add_request()
672 int rtnl_addr_add(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_add() argument
677 if ((err = rtnl_addr_build_add_request(addr, flags, &msg)) < 0) in rtnl_addr_add()
719 int rtnl_addr_build_delete_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_delete_request() argument
724 if ((addr->ce_mask & required) != required) in rtnl_addr_build_delete_request()
727 return build_addr_msg(addr, RTM_DELADDR, flags, result); in rtnl_addr_build_delete_request()
744 int rtnl_addr_delete(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_delete() argument
749 if ((err = rtnl_addr_build_delete_request(addr, flags, &msg)) < 0) in rtnl_addr_delete()
767 int rtnl_addr_set_label(struct rtnl_addr *addr, const char *label) in rtnl_addr_set_label() argument
769 if (strlen(label) > sizeof(addr->a_label) - 1) in rtnl_addr_set_label()
772 strcpy(addr->a_label, label); in rtnl_addr_set_label()
773 addr->ce_mask |= ADDR_ATTR_LABEL; in rtnl_addr_set_label()
778 char *rtnl_addr_get_label(struct rtnl_addr *addr) in rtnl_addr_get_label() argument
780 if (addr->ce_mask & ADDR_ATTR_LABEL) in rtnl_addr_get_label()
781 return addr->a_label; in rtnl_addr_get_label()
786 void rtnl_addr_set_ifindex(struct rtnl_addr *addr, int ifindex) in rtnl_addr_set_ifindex() argument
788 addr->a_ifindex = ifindex; in rtnl_addr_set_ifindex()
789 addr->ce_mask |= ADDR_ATTR_IFINDEX; in rtnl_addr_set_ifindex()
792 int rtnl_addr_get_ifindex(struct rtnl_addr *addr) in rtnl_addr_get_ifindex() argument
794 return addr->a_ifindex; in rtnl_addr_get_ifindex()
797 void rtnl_addr_set_family(struct rtnl_addr *addr, int family) in rtnl_addr_set_family() argument
799 addr->a_family = family; in rtnl_addr_set_family()
800 addr->ce_mask |= ADDR_ATTR_FAMILY; in rtnl_addr_set_family()
803 int rtnl_addr_get_family(struct rtnl_addr *addr) in rtnl_addr_get_family() argument
805 return addr->a_family; in rtnl_addr_get_family()
808 void rtnl_addr_set_prefixlen(struct rtnl_addr *addr, int prefix) in rtnl_addr_set_prefixlen() argument
810 addr->a_prefixlen = prefix; in rtnl_addr_set_prefixlen()
811 addr->ce_mask |= ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_prefixlen()
814 int rtnl_addr_get_prefixlen(struct rtnl_addr *addr) in rtnl_addr_get_prefixlen() argument
816 return addr->a_prefixlen; in rtnl_addr_get_prefixlen()
819 void rtnl_addr_set_scope(struct rtnl_addr *addr, int scope) in rtnl_addr_set_scope() argument
821 addr->a_scope = scope; in rtnl_addr_set_scope()
822 addr->ce_mask |= ADDR_ATTR_SCOPE; in rtnl_addr_set_scope()
825 int rtnl_addr_get_scope(struct rtnl_addr *addr) in rtnl_addr_get_scope() argument
827 return addr->a_scope; in rtnl_addr_get_scope()
830 void rtnl_addr_set_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_set_flags() argument
832 addr->a_flag_mask |= flags; in rtnl_addr_set_flags()
833 addr->a_flags |= flags; in rtnl_addr_set_flags()
834 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_set_flags()
837 void rtnl_addr_unset_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_unset_flags() argument
839 addr->a_flag_mask |= flags; in rtnl_addr_unset_flags()
840 addr->a_flags &= ~flags; in rtnl_addr_unset_flags()
841 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_unset_flags()
844 unsigned int rtnl_addr_get_flags(struct rtnl_addr *addr) in rtnl_addr_get_flags() argument
846 return addr->a_flags; in rtnl_addr_get_flags()
849 static inline int __assign_addr(struct rtnl_addr *addr, struct nl_addr **pos, in __assign_addr() argument
852 if (addr->ce_mask & ADDR_ATTR_FAMILY) { in __assign_addr()
853 if (new->a_family != addr->a_family) in __assign_addr()
856 addr->a_family = new->a_family; in __assign_addr()
862 addr->ce_mask |= (flag | ADDR_ATTR_FAMILY); in __assign_addr()
867 int rtnl_addr_set_local(struct rtnl_addr *addr, struct nl_addr *local) in rtnl_addr_set_local() argument
871 err = __assign_addr(addr, &addr->a_local, local, ADDR_ATTR_LOCAL); in rtnl_addr_set_local()
875 if (!(addr->ce_mask & ADDR_ATTR_PEER)) { in rtnl_addr_set_local()
876 addr->a_prefixlen = nl_addr_get_prefixlen(addr->a_local); in rtnl_addr_set_local()
877 addr->ce_mask |= ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_local()
883 struct nl_addr *rtnl_addr_get_local(struct rtnl_addr *addr) in rtnl_addr_get_local() argument
885 return addr->a_local; in rtnl_addr_get_local()
888 int rtnl_addr_set_peer(struct rtnl_addr *addr, struct nl_addr *peer) in rtnl_addr_set_peer() argument
890 return __assign_addr(addr, &addr->a_peer, peer, ADDR_ATTR_PEER); in rtnl_addr_set_peer()
892 addr->a_prefixlen = nl_addr_get_prefixlen(addr->a_peer); in rtnl_addr_set_peer()
893 addr->ce_mask |= ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_peer()
898 struct nl_addr *rtnl_addr_get_peer(struct rtnl_addr *addr) in rtnl_addr_get_peer() argument
900 return addr->a_peer; in rtnl_addr_get_peer()
903 int rtnl_addr_set_broadcast(struct rtnl_addr *addr, struct nl_addr *bcast) in rtnl_addr_set_broadcast() argument
905 return __assign_addr(addr, &addr->a_bcast, bcast, ADDR_ATTR_BROADCAST); in rtnl_addr_set_broadcast()
908 struct nl_addr *rtnl_addr_get_broadcast(struct rtnl_addr *addr) in rtnl_addr_get_broadcast() argument
910 return addr->a_bcast; in rtnl_addr_get_broadcast()
913 int rtnl_addr_set_multicast(struct rtnl_addr *addr, struct nl_addr *multicast) in rtnl_addr_set_multicast() argument
915 return __assign_addr(addr, &addr->a_multicast, multicast, in rtnl_addr_set_multicast()
919 struct nl_addr *rtnl_addr_get_multicast(struct rtnl_addr *addr) in rtnl_addr_get_multicast() argument
921 return addr->a_multicast; in rtnl_addr_get_multicast()
924 int rtnl_addr_set_anycast(struct rtnl_addr *addr, struct nl_addr *anycast) in rtnl_addr_set_anycast() argument
926 return __assign_addr(addr, &addr->a_anycast, anycast, in rtnl_addr_set_anycast()
930 struct nl_addr *rtnl_addr_get_anycast(struct rtnl_addr *addr) in rtnl_addr_get_anycast() argument
932 return addr->a_anycast; in rtnl_addr_get_anycast()
935 uint32_t rtnl_addr_get_valid_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_valid_lifetime() argument
937 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_valid_lifetime()
938 return addr->a_cacheinfo.aci_valid; in rtnl_addr_get_valid_lifetime()
943 void rtnl_addr_set_valid_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_valid_lifetime() argument
945 addr->a_cacheinfo.aci_valid = lifetime; in rtnl_addr_set_valid_lifetime()
946 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_valid_lifetime()
949 uint32_t rtnl_addr_get_preferred_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_preferred_lifetime() argument
951 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_preferred_lifetime()
952 return addr->a_cacheinfo.aci_prefered; in rtnl_addr_get_preferred_lifetime()
957 void rtnl_addr_set_preferred_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_preferred_lifetime() argument
959 addr->a_cacheinfo.aci_prefered = lifetime; in rtnl_addr_set_preferred_lifetime()
960 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_preferred_lifetime()
963 uint32_t rtnl_addr_get_create_time(struct rtnl_addr *addr) in rtnl_addr_get_create_time() argument
965 return addr->a_cacheinfo.aci_cstamp; in rtnl_addr_get_create_time()
968 uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *addr) in rtnl_addr_get_last_update_time() argument
970 return addr->a_cacheinfo.aci_tstamp; in rtnl_addr_get_last_update_time()