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()
154 rtnl_link_put(addr->a_link); in addr_free_data()
199 struct rtnl_addr *addr; in addr_msg_parser() local
206 addr = rtnl_addr_alloc(); in addr_msg_parser()
207 if (!addr) in addr_msg_parser()
210 addr->ce_msgtype = nlh->nlmsg_type; in addr_msg_parser()
217 addr->a_family = family = ifa->ifa_family; in addr_msg_parser()
218 addr->a_prefixlen = ifa->ifa_prefixlen; in addr_msg_parser()
219 addr->a_scope = ifa->ifa_scope; in addr_msg_parser()
220 addr->a_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) : in addr_msg_parser()
222 addr->a_ifindex = ifa->ifa_index; in addr_msg_parser()
224 addr->ce_mask = (ADDR_ATTR_FAMILY | ADDR_ATTR_PREFIXLEN | in addr_msg_parser()
228 nla_strlcpy(addr->a_label, tb[IFA_LABEL], IFNAMSIZ); in addr_msg_parser()
229 addr->ce_mask |= ADDR_ATTR_LABEL; in addr_msg_parser()
237 addr->a_cacheinfo.aci_prefered = ca->ifa_prefered; in addr_msg_parser()
238 addr->a_cacheinfo.aci_valid = ca->ifa_valid; in addr_msg_parser()
239 addr->a_cacheinfo.aci_cstamp = ca->cstamp; in addr_msg_parser()
240 addr->a_cacheinfo.aci_tstamp = ca->tstamp; in addr_msg_parser()
241 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in addr_msg_parser()
245 addr->a_local = nl_addr_alloc_attr(tb[IFA_LOCAL], family); in addr_msg_parser()
246 if (!addr->a_local) in addr_msg_parser()
248 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
249 plen_addr = addr->a_local; in addr_msg_parser()
262 if (!tb[IFA_LOCAL] || !nl_addr_cmp(a, addr->a_local)) { in addr_msg_parser()
263 nl_addr_put(addr->a_local); in addr_msg_parser()
264 addr->a_local = a; in addr_msg_parser()
265 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
267 addr->a_peer = a; in addr_msg_parser()
268 addr->ce_mask |= ADDR_ATTR_PEER; in addr_msg_parser()
275 nl_addr_set_prefixlen(plen_addr, addr->a_prefixlen); in addr_msg_parser()
279 addr->a_bcast = nl_addr_alloc_attr(tb[IFA_BROADCAST], family); in addr_msg_parser()
280 if (!addr->a_bcast) in addr_msg_parser()
283 addr->ce_mask |= ADDR_ATTR_BROADCAST; in addr_msg_parser()
288 addr->a_multicast = nl_addr_alloc_attr(tb[IFA_MULTICAST], in addr_msg_parser()
290 if (!addr->a_multicast) in addr_msg_parser()
293 addr->ce_mask |= ADDR_ATTR_MULTICAST; in addr_msg_parser()
298 addr->a_anycast = nl_addr_alloc_attr(tb[IFA_ANYCAST], in addr_msg_parser()
300 if (!addr->a_anycast) in addr_msg_parser()
303 addr->ce_mask |= ADDR_ATTR_ANYCAST; in addr_msg_parser()
309 if ((link = rtnl_link_get(link_cache, addr->a_ifindex))) { in addr_msg_parser()
310 rtnl_addr_set_link(addr, link); in addr_msg_parser()
317 err = pp->pp_cb((struct nl_object *) addr, pp); in addr_msg_parser()
319 rtnl_addr_put(addr); in addr_msg_parser()
335 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_line() local
341 if (addr->ce_mask & ADDR_ATTR_LOCAL) in addr_dump_line()
343 nl_addr2str(addr->a_local, buf, sizeof(buf))); in addr_dump_line()
347 if (addr->ce_mask & ADDR_ATTR_PEER) in addr_dump_line()
349 nl_addr2str(addr->a_peer, buf, sizeof(buf))); in addr_dump_line()
351 nl_dump(p, " %s ", nl_af2str(addr->a_family, buf, sizeof(buf))); in addr_dump_line()
355 rtnl_link_i2name(link_cache, addr->a_ifindex, in addr_dump_line()
358 nl_dump(p, "dev %d ", addr->a_ifindex); in addr_dump_line()
361 rtnl_scope2str(addr->a_scope, buf, sizeof(buf))); in addr_dump_line()
363 rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf)); in addr_dump_line()
375 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_details() local
380 if (addr->ce_mask & (ADDR_ATTR_LABEL | ADDR_ATTR_BROADCAST | in addr_dump_details()
384 if (addr->ce_mask & ADDR_ATTR_LABEL) in addr_dump_details()
385 nl_dump(p, " label %s", addr->a_label); in addr_dump_details()
387 if (addr->ce_mask & ADDR_ATTR_BROADCAST) in addr_dump_details()
389 nl_addr2str(addr->a_bcast, buf, sizeof(buf))); in addr_dump_details()
391 if (addr->ce_mask & ADDR_ATTR_MULTICAST) in addr_dump_details()
393 nl_addr2str(addr->a_multicast, buf, in addr_dump_details()
396 if (addr->ce_mask & ADDR_ATTR_ANYCAST) in addr_dump_details()
398 nl_addr2str(addr->a_anycast, buf, in addr_dump_details()
404 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) { in addr_dump_details()
405 struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo; in addr_dump_details()
418 nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10, in addr_dump_details()
422 nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10, in addr_dump_details()
493 void rtnl_addr_put(struct rtnl_addr *addr) in rtnl_addr_put() argument
495 nl_object_put((struct nl_object *) addr); in rtnl_addr_put()
525 struct nl_addr *addr) in rtnl_addr_get() argument
537 !nl_addr_cmp(a->a_local, addr)) { in rtnl_addr_get()
650 int rtnl_addr_build_add_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_add_request() argument
656 if ((addr->ce_mask & required) != required) in rtnl_addr_build_add_request()
659 return build_addr_msg(addr, RTM_NEWADDR, NLM_F_CREATE | flags, result); in rtnl_addr_build_add_request()
676 int rtnl_addr_add(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_add() argument
681 if ((err = rtnl_addr_build_add_request(addr, flags, &msg)) < 0) in rtnl_addr_add()
723 int rtnl_addr_build_delete_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_delete_request() argument
728 if ((addr->ce_mask & required) != required) in rtnl_addr_build_delete_request()
731 return build_addr_msg(addr, RTM_DELADDR, flags, result); in rtnl_addr_build_delete_request()
748 int rtnl_addr_delete(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_delete() argument
753 if ((err = rtnl_addr_build_delete_request(addr, flags, &msg)) < 0) in rtnl_addr_delete()
771 int rtnl_addr_set_label(struct rtnl_addr *addr, const char *label) in rtnl_addr_set_label() argument
773 if (strlen(label) > sizeof(addr->a_label) - 1) in rtnl_addr_set_label()
776 strcpy(addr->a_label, label); in rtnl_addr_set_label()
777 addr->ce_mask |= ADDR_ATTR_LABEL; in rtnl_addr_set_label()
782 char *rtnl_addr_get_label(struct rtnl_addr *addr) in rtnl_addr_get_label() argument
784 if (addr->ce_mask & ADDR_ATTR_LABEL) in rtnl_addr_get_label()
785 return addr->a_label; in rtnl_addr_get_label()
790 void rtnl_addr_set_ifindex(struct rtnl_addr *addr, int ifindex) in rtnl_addr_set_ifindex() argument
792 addr->a_ifindex = ifindex; in rtnl_addr_set_ifindex()
793 addr->ce_mask |= ADDR_ATTR_IFINDEX; in rtnl_addr_set_ifindex()
796 int rtnl_addr_get_ifindex(struct rtnl_addr *addr) in rtnl_addr_get_ifindex() argument
798 return addr->a_ifindex; in rtnl_addr_get_ifindex()
801 void rtnl_addr_set_link(struct rtnl_addr *addr, struct rtnl_link *link) in rtnl_addr_set_link() argument
803 rtnl_link_put(addr->a_link); in rtnl_addr_set_link()
809 addr->a_link = link; in rtnl_addr_set_link()
810 addr->a_ifindex = link->l_index; in rtnl_addr_set_link()
811 addr->ce_mask |= ADDR_ATTR_IFINDEX; in rtnl_addr_set_link()
814 struct rtnl_link *rtnl_addr_get_link(struct rtnl_addr *addr) in rtnl_addr_get_link() argument
816 if (addr->a_link) { in rtnl_addr_get_link()
817 nl_object_get(OBJ_CAST(addr->a_link)); in rtnl_addr_get_link()
818 return addr->a_link; in rtnl_addr_get_link()
824 void rtnl_addr_set_family(struct rtnl_addr *addr, int family) in rtnl_addr_set_family() argument
826 addr->a_family = family; in rtnl_addr_set_family()
827 addr->ce_mask |= ADDR_ATTR_FAMILY; in rtnl_addr_set_family()
830 int rtnl_addr_get_family(struct rtnl_addr *addr) in rtnl_addr_get_family() argument
832 return addr->a_family; in rtnl_addr_get_family()
851 void rtnl_addr_set_prefixlen(struct rtnl_addr *addr, int prefixlen) in rtnl_addr_set_prefixlen() argument
853 addr->a_prefixlen = prefixlen; in rtnl_addr_set_prefixlen()
856 addr->ce_mask |= ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_prefixlen()
858 addr->ce_mask &= ~ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_prefixlen()
864 if (addr->a_peer) in rtnl_addr_set_prefixlen()
865 nl_addr_set_prefixlen(addr->a_peer, prefixlen); in rtnl_addr_set_prefixlen()
866 else if (addr->a_local) in rtnl_addr_set_prefixlen()
867 nl_addr_set_prefixlen(addr->a_local, prefixlen); in rtnl_addr_set_prefixlen()
870 int rtnl_addr_get_prefixlen(struct rtnl_addr *addr) in rtnl_addr_get_prefixlen() argument
872 return addr->a_prefixlen; in rtnl_addr_get_prefixlen()
875 void rtnl_addr_set_scope(struct rtnl_addr *addr, int scope) in rtnl_addr_set_scope() argument
877 addr->a_scope = scope; in rtnl_addr_set_scope()
878 addr->ce_mask |= ADDR_ATTR_SCOPE; in rtnl_addr_set_scope()
881 int rtnl_addr_get_scope(struct rtnl_addr *addr) in rtnl_addr_get_scope() argument
883 return addr->a_scope; in rtnl_addr_get_scope()
886 void rtnl_addr_set_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_set_flags() argument
888 addr->a_flag_mask |= flags; in rtnl_addr_set_flags()
889 addr->a_flags |= flags; in rtnl_addr_set_flags()
890 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_set_flags()
893 void rtnl_addr_unset_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_unset_flags() argument
895 addr->a_flag_mask |= flags; in rtnl_addr_unset_flags()
896 addr->a_flags &= ~flags; in rtnl_addr_unset_flags()
897 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_unset_flags()
900 unsigned int rtnl_addr_get_flags(struct rtnl_addr *addr) in rtnl_addr_get_flags() argument
902 return addr->a_flags; in rtnl_addr_get_flags()
905 static inline int __assign_addr(struct rtnl_addr *addr, struct nl_addr **pos, in __assign_addr() argument
909 if (addr->ce_mask & ADDR_ATTR_FAMILY) { in __assign_addr()
910 if (new->a_family != addr->a_family) in __assign_addr()
913 addr->a_family = new->a_family; in __assign_addr()
919 addr->ce_mask |= (flag | ADDR_ATTR_FAMILY); in __assign_addr()
925 addr->ce_mask &= ~flag; in __assign_addr()
931 int rtnl_addr_set_local(struct rtnl_addr *addr, struct nl_addr *local) in rtnl_addr_set_local() argument
936 if ((addr->ce_mask & ADDR_ATTR_PEER) && local && in rtnl_addr_set_local()
940 err = __assign_addr(addr, &addr->a_local, local, ADDR_ATTR_LOCAL); in rtnl_addr_set_local()
945 if (!(addr->ce_mask & ADDR_ATTR_PEER)) in rtnl_addr_set_local()
946 rtnl_addr_set_prefixlen(addr, local ? nl_addr_get_prefixlen(local) : 0); in rtnl_addr_set_local()
951 struct nl_addr *rtnl_addr_get_local(struct rtnl_addr *addr) in rtnl_addr_get_local() argument
953 return addr->a_local; in rtnl_addr_get_local()
956 int rtnl_addr_set_peer(struct rtnl_addr *addr, struct nl_addr *peer) in rtnl_addr_set_peer() argument
963 err = __assign_addr(addr, &addr->a_peer, peer, ADDR_ATTR_PEER); in rtnl_addr_set_peer()
967 rtnl_addr_set_prefixlen(addr, peer ? nl_addr_get_prefixlen(peer) : 0); in rtnl_addr_set_peer()
972 struct nl_addr *rtnl_addr_get_peer(struct rtnl_addr *addr) in rtnl_addr_get_peer() argument
974 return addr->a_peer; in rtnl_addr_get_peer()
977 int rtnl_addr_set_broadcast(struct rtnl_addr *addr, struct nl_addr *bcast) in rtnl_addr_set_broadcast() argument
982 return __assign_addr(addr, &addr->a_bcast, bcast, ADDR_ATTR_BROADCAST); in rtnl_addr_set_broadcast()
985 struct nl_addr *rtnl_addr_get_broadcast(struct rtnl_addr *addr) in rtnl_addr_get_broadcast() argument
987 return addr->a_bcast; in rtnl_addr_get_broadcast()
990 int rtnl_addr_set_multicast(struct rtnl_addr *addr, struct nl_addr *multicast) in rtnl_addr_set_multicast() argument
995 return __assign_addr(addr, &addr->a_multicast, multicast, in rtnl_addr_set_multicast()
999 struct nl_addr *rtnl_addr_get_multicast(struct rtnl_addr *addr) in rtnl_addr_get_multicast() argument
1001 return addr->a_multicast; in rtnl_addr_get_multicast()
1004 int rtnl_addr_set_anycast(struct rtnl_addr *addr, struct nl_addr *anycast) in rtnl_addr_set_anycast() argument
1009 return __assign_addr(addr, &addr->a_anycast, anycast, in rtnl_addr_set_anycast()
1013 struct nl_addr *rtnl_addr_get_anycast(struct rtnl_addr *addr) in rtnl_addr_get_anycast() argument
1015 return addr->a_anycast; in rtnl_addr_get_anycast()
1018 uint32_t rtnl_addr_get_valid_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_valid_lifetime() argument
1020 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_valid_lifetime()
1021 return addr->a_cacheinfo.aci_valid; in rtnl_addr_get_valid_lifetime()
1026 void rtnl_addr_set_valid_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_valid_lifetime() argument
1028 addr->a_cacheinfo.aci_valid = lifetime; in rtnl_addr_set_valid_lifetime()
1029 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_valid_lifetime()
1032 uint32_t rtnl_addr_get_preferred_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_preferred_lifetime() argument
1034 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_preferred_lifetime()
1035 return addr->a_cacheinfo.aci_prefered; in rtnl_addr_get_preferred_lifetime()
1040 void rtnl_addr_set_preferred_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_preferred_lifetime() argument
1042 addr->a_cacheinfo.aci_prefered = lifetime; in rtnl_addr_set_preferred_lifetime()
1043 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_preferred_lifetime()
1046 uint32_t rtnl_addr_get_create_time(struct rtnl_addr *addr) in rtnl_addr_get_create_time() argument
1048 return addr->a_cacheinfo.aci_cstamp; in rtnl_addr_get_create_time()
1051 uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *addr) in rtnl_addr_get_last_update_time() argument
1053 return addr->a_cacheinfo.aci_tstamp; in rtnl_addr_get_last_update_time()