Lines Matching full:nh
33 static struct rtattr *rtattr_add(struct nlmsghdr *nh, unsigned short type, in rtattr_add() argument
37 (struct rtattr *)((uint8_t *)nh + RTA_ALIGN(nh->nlmsg_len)); in rtattr_add()
40 nh->nlmsg_len = RTA_ALIGN(nh->nlmsg_len) + RTA_ALIGN(rta->rta_len); in rtattr_add()
44 static struct rtattr *rtattr_begin(struct nlmsghdr *nh, unsigned short type) in rtattr_begin() argument
46 return rtattr_add(nh, type, 0); in rtattr_begin()
49 static void rtattr_end(struct nlmsghdr *nh, struct rtattr *attr) in rtattr_end() argument
51 uint8_t *end = (uint8_t *)nh + nh->nlmsg_len; in rtattr_end()
56 static struct rtattr *rtattr_add_str(struct nlmsghdr *nh, unsigned short type, in rtattr_add_str() argument
59 struct rtattr *rta = rtattr_add(nh, type, strlen(s)); in rtattr_add_str()
65 static struct rtattr *rtattr_add_strsz(struct nlmsghdr *nh, unsigned short type, in rtattr_add_strsz() argument
68 struct rtattr *rta = rtattr_add(nh, type, strlen(s) + 1); in rtattr_add_strsz()
74 static struct rtattr *rtattr_add_any(struct nlmsghdr *nh, unsigned short type, in rtattr_add_any() argument
77 struct rtattr *rta = rtattr_add(nh, type, len); in rtattr_add_any()
84 int (*fill_rtattr)(struct nlmsghdr *nh), in dev_create() argument
85 int (*fill_info_data)(struct nlmsghdr *nh)) in dev_create() argument
88 struct nlmsghdr nh; in dev_create() member
102 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in dev_create()
103 req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE; in dev_create()
104 req.nh.nlmsg_type = RTM_NEWLINK; in dev_create()
112 rtattr_add_str(&req.nh, IFLA_IFNAME, dev); in dev_create()
115 ret = fill_rtattr(&req.nh); in dev_create()
120 link_info = rtattr_begin(&req.nh, IFLA_LINKINFO); in dev_create()
122 rtattr_add_strsz(&req.nh, IFLA_INFO_KIND, link_type); in dev_create()
125 info_data = rtattr_begin(&req.nh, IFLA_INFO_DATA); in dev_create()
126 ret = fill_info_data(&req.nh); in dev_create()
129 rtattr_end(&req.nh, info_data); in dev_create()
132 rtattr_end(&req.nh, link_info); in dev_create()
134 ret = send(rtnl, &req, req.nh.nlmsg_len, 0); in dev_create()
137 ret = (unsigned int)ret != req.nh.nlmsg_len; in dev_create()
146 struct nlmsghdr nh; in dev_delete() member
159 req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(req.info)); in dev_delete()
160 req.nh.nlmsg_flags = NLM_F_REQUEST; in dev_delete()
161 req.nh.nlmsg_type = RTM_DELLINK; in dev_delete()
165 rtattr_add_str(&req.nh, IFLA_IFNAME, dev); in dev_delete()
167 ret = send(rtnl, &req, req.nh.nlmsg_len, 0); in dev_delete()
171 ret = (unsigned int)ret != req.nh.nlmsg_len; in dev_delete()
177 static int macvtap_fill_rtattr(struct nlmsghdr *nh) in macvtap_fill_rtattr() argument
187 rtattr_add_any(nh, IFLA_LINK, &ifindex, sizeof(ifindex)); in macvtap_fill_rtattr()
188 rtattr_add_any(nh, IFLA_ADDRESS, param_hwaddr_src, ETH_ALEN); in macvtap_fill_rtattr()