* Append a netlink attribute to a message. * * @param[in, out] nh * The netlink message to parse, received from the kernel. * @param[in] type * The type of attribute to append. * @param[in] data_len * The length of the data to append. * @param[in] data * The data to append. */
| 292 | * The data to append. |
| 293 | */ |
| 294 | void |
| 295 | tap_nlattr_add(struct nlmsghdr *nh, unsigned short type, |
| 296 | unsigned int data_len, const void *data) |
| 297 | { |
| 298 | /* see man 3 rtnetlink */ |
| 299 | struct rtattr *rta; |
| 300 | |
| 301 | rta = (struct rtattr *)NLMSG_TAIL(nh); |
| 302 | rta->rta_len = RTA_LENGTH(data_len); |
| 303 | rta->rta_type = type; |
| 304 | if (data_len > 0) |
| 305 | memcpy(RTA_DATA(rta), data, data_len); |
| 306 | nh->nlmsg_len = NLMSG_ALIGN(nh->nlmsg_len) + RTA_ALIGN(rta->rta_len); |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Append a uint8_t netlink attribute to a message. |
no test coverage detected