1
2
3
4
5
6#ifndef _TAP_NETLINK_H_
7#define _TAP_NETLINK_H_
8
9#include <ctype.h>
10#include <inttypes.h>
11#include <linux/rtnetlink.h>
12#include <linux/netlink.h>
13#include <stdio.h>
14
15#include <rte_log.h>
16
17#define NLMSG_BUF 512
18
19struct nlmsg {
20 struct nlmsghdr nh;
21 struct tcmsg t;
22 char buf[NLMSG_BUF];
23 struct nested_tail *nested_tails;
24};
25
26#define NLMSG_TAIL(nlh) (void *)((char *)(nlh) + NLMSG_ALIGN((nlh)->nlmsg_len))
27
28int tap_nl_init(uint32_t nl_groups);
29int tap_nl_final(int nlsk_fd);
30int tap_nl_send(int nlsk_fd, struct nlmsghdr *nh);
31int tap_nl_recv(int nlsk_fd, int (*callback)(struct nlmsghdr *, void *),
32 void *arg);
33int tap_nl_recv_ack(int nlsk_fd);
34void tap_nlattr_add(struct nlmsghdr *nh, unsigned short type,
35 unsigned int data_len, const void *data);
36void tap_nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data);
37void tap_nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data);
38void tap_nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data);
39int tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type);
40void tap_nlattr_nested_finish(struct nlmsg *msg);
41
42#endif
43