net/tap: use SPDX tags in 6WIND copyrighted files
[dpdk.git] / drivers / net / tap / tap_netlink.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 6WIND S.A.
3  * Copyright 2017 Mellanox.
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
19 struct 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
28 int tap_nl_init(uint32_t nl_groups);
29 int tap_nl_final(int nlsk_fd);
30 int tap_nl_send(int nlsk_fd, struct nlmsghdr *nh);
31 int tap_nl_recv(int nlsk_fd, int (*callback)(struct nlmsghdr *, void *),
32                 void *arg);
33 int tap_nl_recv_ack(int nlsk_fd);
34 void tap_nlattr_add(struct nlmsghdr *nh, unsigned short type,
35                     unsigned int data_len, const void *data);
36 void tap_nlattr_add8(struct nlmsghdr *nh, unsigned short type, uint8_t data);
37 void tap_nlattr_add16(struct nlmsghdr *nh, unsigned short type, uint16_t data);
38 void tap_nlattr_add32(struct nlmsghdr *nh, unsigned short type, uint32_t data);
39 int tap_nlattr_nested_start(struct nlmsg *msg, uint16_t type);
40 void tap_nlattr_nested_finish(struct nlmsg *msg);
41
42 #endif /* _TAP_NETLINK_H_ */