Lines Matching refs:addr
131 struct rtnl_addr *addr = nl_object_priv(obj); in addr_constructor() local
133 addr->a_scope = RT_SCOPE_NOWHERE; in addr_constructor()
138 struct rtnl_addr *addr = nl_object_priv(obj); in addr_free_data() local
140 if (!addr) in addr_free_data()
143 nl_addr_put(addr->a_peer); in addr_free_data()
144 nl_addr_put(addr->a_local); in addr_free_data()
145 nl_addr_put(addr->a_bcast); in addr_free_data()
146 nl_addr_put(addr->a_multicast); in addr_free_data()
147 nl_addr_put(addr->a_anycast); in addr_free_data()
148 rtnl_link_put(addr->a_link); in addr_free_data()
200 struct rtnl_addr *addr; in addr_msg_parser() local
207 addr = rtnl_addr_alloc(); in addr_msg_parser()
208 if (!addr) in addr_msg_parser()
211 addr->ce_msgtype = nlh->nlmsg_type; in addr_msg_parser()
218 addr->a_family = family = ifa->ifa_family; in addr_msg_parser()
219 addr->a_prefixlen = ifa->ifa_prefixlen; in addr_msg_parser()
220 addr->a_scope = ifa->ifa_scope; in addr_msg_parser()
221 addr->a_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) : in addr_msg_parser()
223 addr->a_ifindex = ifa->ifa_index; in addr_msg_parser()
225 addr->ce_mask = (ADDR_ATTR_FAMILY | ADDR_ATTR_PREFIXLEN | in addr_msg_parser()
229 nla_strlcpy(addr->a_label, tb[IFA_LABEL], IFNAMSIZ); in addr_msg_parser()
230 addr->ce_mask |= ADDR_ATTR_LABEL; in addr_msg_parser()
238 addr->a_cacheinfo.aci_prefered = ca->ifa_prefered; in addr_msg_parser()
239 addr->a_cacheinfo.aci_valid = ca->ifa_valid; in addr_msg_parser()
240 addr->a_cacheinfo.aci_cstamp = ca->cstamp; in addr_msg_parser()
241 addr->a_cacheinfo.aci_tstamp = ca->tstamp; in addr_msg_parser()
242 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in addr_msg_parser()
251 addr->a_local = nl_addr_alloc_attr(tb[IFA_LOCAL], family); in addr_msg_parser()
253 addr->a_local = nl_addr_build(family, &null, sizeof (null)); in addr_msg_parser()
254 if (!addr->a_local) in addr_msg_parser()
256 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
259 addr->a_peer = nl_addr_alloc_attr(tb[IFA_ADDRESS], family); in addr_msg_parser()
261 addr->a_peer = nl_addr_build(family, &null, sizeof (null)); in addr_msg_parser()
262 if (!addr->a_peer) in addr_msg_parser()
265 if (!nl_addr_cmp (addr->a_local, addr->a_peer)) { in addr_msg_parser()
272 nl_addr_put(addr->a_peer); in addr_msg_parser()
273 addr->a_peer = NULL; in addr_msg_parser()
275 addr->ce_mask |= ADDR_ATTR_PEER; in addr_msg_parser()
277 plen_addr = addr->a_local; in addr_msg_parser()
280 addr->a_local = nl_addr_alloc_attr(tb[IFA_LOCAL], family); in addr_msg_parser()
281 if (!addr->a_local) in addr_msg_parser()
283 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
284 plen_addr = addr->a_local; in addr_msg_parser()
297 if (!tb[IFA_LOCAL] || !nl_addr_cmp(a, addr->a_local)) { in addr_msg_parser()
298 nl_addr_put(addr->a_local); in addr_msg_parser()
299 addr->a_local = a; in addr_msg_parser()
300 addr->ce_mask |= ADDR_ATTR_LOCAL; in addr_msg_parser()
302 addr->a_peer = a; in addr_msg_parser()
303 addr->ce_mask |= ADDR_ATTR_PEER; in addr_msg_parser()
311 nl_addr_set_prefixlen(plen_addr, addr->a_prefixlen); in addr_msg_parser()
315 addr->a_bcast = nl_addr_alloc_attr(tb[IFA_BROADCAST], family); in addr_msg_parser()
316 if (!addr->a_bcast) in addr_msg_parser()
319 addr->ce_mask |= ADDR_ATTR_BROADCAST; in addr_msg_parser()
324 addr->a_multicast = nl_addr_alloc_attr(tb[IFA_MULTICAST], in addr_msg_parser()
326 if (!addr->a_multicast) in addr_msg_parser()
329 addr->ce_mask |= ADDR_ATTR_MULTICAST; in addr_msg_parser()
334 addr->a_anycast = nl_addr_alloc_attr(tb[IFA_ANYCAST], in addr_msg_parser()
336 if (!addr->a_anycast) in addr_msg_parser()
339 addr->ce_mask |= ADDR_ATTR_ANYCAST; in addr_msg_parser()
345 if ((link = rtnl_link_get(link_cache, addr->a_ifindex))) { in addr_msg_parser()
346 rtnl_addr_set_link(addr, link); in addr_msg_parser()
353 err = pp->pp_cb((struct nl_object *) addr, pp); in addr_msg_parser()
355 rtnl_addr_put(addr); in addr_msg_parser()
371 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_line() local
377 if (addr->ce_mask & ADDR_ATTR_LOCAL) in addr_dump_line()
379 nl_addr2str(addr->a_local, buf, sizeof(buf))); in addr_dump_line()
383 if (addr->ce_mask & ADDR_ATTR_PEER) in addr_dump_line()
385 nl_addr2str(addr->a_peer, buf, sizeof(buf))); in addr_dump_line()
387 nl_dump(p, " %s ", nl_af2str(addr->a_family, buf, sizeof(buf))); in addr_dump_line()
391 rtnl_link_i2name(link_cache, addr->a_ifindex, in addr_dump_line()
394 nl_dump(p, "dev %d ", addr->a_ifindex); in addr_dump_line()
397 rtnl_scope2str(addr->a_scope, buf, sizeof(buf))); in addr_dump_line()
399 rtnl_addr_flags2str(addr->a_flags, buf, sizeof(buf)); in addr_dump_line()
411 struct rtnl_addr *addr = (struct rtnl_addr *) obj; in addr_dump_details() local
416 if (addr->ce_mask & (ADDR_ATTR_LABEL | ADDR_ATTR_BROADCAST | in addr_dump_details()
420 if (addr->ce_mask & ADDR_ATTR_LABEL) in addr_dump_details()
421 nl_dump(p, " label %s", addr->a_label); in addr_dump_details()
423 if (addr->ce_mask & ADDR_ATTR_BROADCAST) in addr_dump_details()
425 nl_addr2str(addr->a_bcast, buf, sizeof(buf))); in addr_dump_details()
427 if (addr->ce_mask & ADDR_ATTR_MULTICAST) in addr_dump_details()
429 nl_addr2str(addr->a_multicast, buf, in addr_dump_details()
432 if (addr->ce_mask & ADDR_ATTR_ANYCAST) in addr_dump_details()
434 nl_addr2str(addr->a_anycast, buf, in addr_dump_details()
440 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) { in addr_dump_details()
441 struct rtnl_addr_cacheinfo *ci = &addr->a_cacheinfo; in addr_dump_details()
454 nl_msec2str(addr->a_cacheinfo.aci_cstamp * 10, in addr_dump_details()
458 nl_msec2str(addr->a_cacheinfo.aci_tstamp * 10, in addr_dump_details()
470 struct rtnl_addr *addr = (struct rtnl_addr *)obj; in addr_id_attrs_get() local
473 switch (addr->a_family) { in addr_id_attrs_get()
477 if (addr->a_peer) in addr_id_attrs_get()
565 void rtnl_addr_put(struct rtnl_addr *addr) in rtnl_addr_put() argument
567 nl_object_put((struct nl_object *) addr); in rtnl_addr_put()
597 struct nl_addr *addr) in rtnl_addr_get() argument
609 !nl_addr_cmp(a->a_local, addr)) { in rtnl_addr_get()
722 int rtnl_addr_build_add_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_add_request() argument
728 if ((addr->ce_mask & required) != required) in rtnl_addr_build_add_request()
731 return build_addr_msg(addr, RTM_NEWADDR, NLM_F_CREATE | flags, result); in rtnl_addr_build_add_request()
748 int rtnl_addr_add(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_add() argument
753 if ((err = rtnl_addr_build_add_request(addr, flags, &msg)) < 0) in rtnl_addr_add()
795 int rtnl_addr_build_delete_request(struct rtnl_addr *addr, int flags, in rtnl_addr_build_delete_request() argument
800 if ((addr->ce_mask & required) != required) in rtnl_addr_build_delete_request()
803 return build_addr_msg(addr, RTM_DELADDR, flags, result); in rtnl_addr_build_delete_request()
820 int rtnl_addr_delete(struct nl_sock *sk, struct rtnl_addr *addr, int flags) in rtnl_addr_delete() argument
825 if ((err = rtnl_addr_build_delete_request(addr, flags, &msg)) < 0) in rtnl_addr_delete()
843 int rtnl_addr_set_label(struct rtnl_addr *addr, const char *label) in rtnl_addr_set_label() argument
845 if (strlen(label) > sizeof(addr->a_label) - 1) in rtnl_addr_set_label()
848 strcpy(addr->a_label, label); in rtnl_addr_set_label()
849 addr->ce_mask |= ADDR_ATTR_LABEL; in rtnl_addr_set_label()
854 char *rtnl_addr_get_label(struct rtnl_addr *addr) in rtnl_addr_get_label() argument
856 if (addr->ce_mask & ADDR_ATTR_LABEL) in rtnl_addr_get_label()
857 return addr->a_label; in rtnl_addr_get_label()
862 void rtnl_addr_set_ifindex(struct rtnl_addr *addr, int ifindex) in rtnl_addr_set_ifindex() argument
864 addr->a_ifindex = ifindex; in rtnl_addr_set_ifindex()
865 addr->ce_mask |= ADDR_ATTR_IFINDEX; in rtnl_addr_set_ifindex()
868 int rtnl_addr_get_ifindex(struct rtnl_addr *addr) in rtnl_addr_get_ifindex() argument
870 return addr->a_ifindex; in rtnl_addr_get_ifindex()
873 void rtnl_addr_set_link(struct rtnl_addr *addr, struct rtnl_link *link) in rtnl_addr_set_link() argument
875 rtnl_link_put(addr->a_link); in rtnl_addr_set_link()
881 addr->a_link = link; in rtnl_addr_set_link()
882 addr->a_ifindex = link->l_index; in rtnl_addr_set_link()
883 addr->ce_mask |= ADDR_ATTR_IFINDEX; in rtnl_addr_set_link()
886 struct rtnl_link *rtnl_addr_get_link(struct rtnl_addr *addr) in rtnl_addr_get_link() argument
888 if (addr->a_link) { in rtnl_addr_get_link()
889 nl_object_get(OBJ_CAST(addr->a_link)); in rtnl_addr_get_link()
890 return addr->a_link; in rtnl_addr_get_link()
896 void rtnl_addr_set_family(struct rtnl_addr *addr, int family) in rtnl_addr_set_family() argument
898 addr->a_family = family; in rtnl_addr_set_family()
899 addr->ce_mask |= ADDR_ATTR_FAMILY; in rtnl_addr_set_family()
902 int rtnl_addr_get_family(struct rtnl_addr *addr) in rtnl_addr_get_family() argument
904 return addr->a_family; in rtnl_addr_get_family()
923 void rtnl_addr_set_prefixlen(struct rtnl_addr *addr, int prefixlen) in rtnl_addr_set_prefixlen() argument
925 addr->a_prefixlen = prefixlen; in rtnl_addr_set_prefixlen()
928 addr->ce_mask |= ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_prefixlen()
930 addr->ce_mask &= ~ADDR_ATTR_PREFIXLEN; in rtnl_addr_set_prefixlen()
936 if (addr->a_peer) in rtnl_addr_set_prefixlen()
937 nl_addr_set_prefixlen(addr->a_peer, prefixlen); in rtnl_addr_set_prefixlen()
938 else if (addr->a_local) in rtnl_addr_set_prefixlen()
939 nl_addr_set_prefixlen(addr->a_local, prefixlen); in rtnl_addr_set_prefixlen()
942 int rtnl_addr_get_prefixlen(struct rtnl_addr *addr) in rtnl_addr_get_prefixlen() argument
944 return addr->a_prefixlen; in rtnl_addr_get_prefixlen()
947 void rtnl_addr_set_scope(struct rtnl_addr *addr, int scope) in rtnl_addr_set_scope() argument
949 addr->a_scope = scope; in rtnl_addr_set_scope()
950 addr->ce_mask |= ADDR_ATTR_SCOPE; in rtnl_addr_set_scope()
953 int rtnl_addr_get_scope(struct rtnl_addr *addr) in rtnl_addr_get_scope() argument
955 return addr->a_scope; in rtnl_addr_get_scope()
958 void rtnl_addr_set_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_set_flags() argument
960 addr->a_flag_mask |= flags; in rtnl_addr_set_flags()
961 addr->a_flags |= flags; in rtnl_addr_set_flags()
962 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_set_flags()
965 void rtnl_addr_unset_flags(struct rtnl_addr *addr, unsigned int flags) in rtnl_addr_unset_flags() argument
967 addr->a_flag_mask |= flags; in rtnl_addr_unset_flags()
968 addr->a_flags &= ~flags; in rtnl_addr_unset_flags()
969 addr->ce_mask |= ADDR_ATTR_FLAGS; in rtnl_addr_unset_flags()
972 unsigned int rtnl_addr_get_flags(struct rtnl_addr *addr) in rtnl_addr_get_flags() argument
974 return addr->a_flags; in rtnl_addr_get_flags()
977 static inline int __assign_addr(struct rtnl_addr *addr, struct nl_addr **pos, in __assign_addr() argument
981 if (addr->ce_mask & ADDR_ATTR_FAMILY) { in __assign_addr()
982 if (new->a_family != addr->a_family) in __assign_addr()
985 addr->a_family = new->a_family; in __assign_addr()
991 addr->ce_mask |= (flag | ADDR_ATTR_FAMILY); in __assign_addr()
997 addr->ce_mask &= ~flag; in __assign_addr()
1003 int rtnl_addr_set_local(struct rtnl_addr *addr, struct nl_addr *local) in rtnl_addr_set_local() argument
1008 if ((addr->ce_mask & ADDR_ATTR_PEER) && local && in rtnl_addr_set_local()
1012 err = __assign_addr(addr, &addr->a_local, local, ADDR_ATTR_LOCAL); in rtnl_addr_set_local()
1017 if (!(addr->ce_mask & ADDR_ATTR_PEER)) in rtnl_addr_set_local()
1018 rtnl_addr_set_prefixlen(addr, local ? nl_addr_get_prefixlen(local) : 0); in rtnl_addr_set_local()
1023 struct nl_addr *rtnl_addr_get_local(struct rtnl_addr *addr) in rtnl_addr_get_local() argument
1025 return addr->a_local; in rtnl_addr_get_local()
1028 int rtnl_addr_set_peer(struct rtnl_addr *addr, struct nl_addr *peer) in rtnl_addr_set_peer() argument
1035 err = __assign_addr(addr, &addr->a_peer, peer, ADDR_ATTR_PEER); in rtnl_addr_set_peer()
1039 rtnl_addr_set_prefixlen(addr, peer ? nl_addr_get_prefixlen(peer) : 0); in rtnl_addr_set_peer()
1044 struct nl_addr *rtnl_addr_get_peer(struct rtnl_addr *addr) in rtnl_addr_get_peer() argument
1046 return addr->a_peer; in rtnl_addr_get_peer()
1049 int rtnl_addr_set_broadcast(struct rtnl_addr *addr, struct nl_addr *bcast) in rtnl_addr_set_broadcast() argument
1054 return __assign_addr(addr, &addr->a_bcast, bcast, ADDR_ATTR_BROADCAST); in rtnl_addr_set_broadcast()
1057 struct nl_addr *rtnl_addr_get_broadcast(struct rtnl_addr *addr) in rtnl_addr_get_broadcast() argument
1059 return addr->a_bcast; in rtnl_addr_get_broadcast()
1062 int rtnl_addr_set_multicast(struct rtnl_addr *addr, struct nl_addr *multicast) in rtnl_addr_set_multicast() argument
1067 return __assign_addr(addr, &addr->a_multicast, multicast, in rtnl_addr_set_multicast()
1071 struct nl_addr *rtnl_addr_get_multicast(struct rtnl_addr *addr) in rtnl_addr_get_multicast() argument
1073 return addr->a_multicast; in rtnl_addr_get_multicast()
1076 int rtnl_addr_set_anycast(struct rtnl_addr *addr, struct nl_addr *anycast) in rtnl_addr_set_anycast() argument
1081 return __assign_addr(addr, &addr->a_anycast, anycast, in rtnl_addr_set_anycast()
1085 struct nl_addr *rtnl_addr_get_anycast(struct rtnl_addr *addr) in rtnl_addr_get_anycast() argument
1087 return addr->a_anycast; in rtnl_addr_get_anycast()
1090 uint32_t rtnl_addr_get_valid_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_valid_lifetime() argument
1092 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_valid_lifetime()
1093 return addr->a_cacheinfo.aci_valid; in rtnl_addr_get_valid_lifetime()
1098 void rtnl_addr_set_valid_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_valid_lifetime() argument
1100 addr->a_cacheinfo.aci_valid = lifetime; in rtnl_addr_set_valid_lifetime()
1101 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_valid_lifetime()
1104 uint32_t rtnl_addr_get_preferred_lifetime(struct rtnl_addr *addr) in rtnl_addr_get_preferred_lifetime() argument
1106 if (addr->ce_mask & ADDR_ATTR_CACHEINFO) in rtnl_addr_get_preferred_lifetime()
1107 return addr->a_cacheinfo.aci_prefered; in rtnl_addr_get_preferred_lifetime()
1112 void rtnl_addr_set_preferred_lifetime(struct rtnl_addr *addr, uint32_t lifetime) in rtnl_addr_set_preferred_lifetime() argument
1114 addr->a_cacheinfo.aci_prefered = lifetime; in rtnl_addr_set_preferred_lifetime()
1115 addr->ce_mask |= ADDR_ATTR_CACHEINFO; in rtnl_addr_set_preferred_lifetime()
1118 uint32_t rtnl_addr_get_create_time(struct rtnl_addr *addr) in rtnl_addr_get_create_time() argument
1120 return addr->a_cacheinfo.aci_cstamp; in rtnl_addr_get_create_time()
1123 uint32_t rtnl_addr_get_last_update_time(struct rtnl_addr *addr) in rtnl_addr_get_last_update_time() argument
1125 return addr->a_cacheinfo.aci_tstamp; in rtnl_addr_get_last_update_time()