-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgnrl_nl_user.h
executable file
·64 lines (51 loc) · 1.67 KB
/
gnrl_nl_user.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _GENLNET_SOCKET_H_
#define _GENLNET_SOCKET_H_
#include <linux/socket.h>
#include <linux/unistd.h>
#include <linux/genetlink.h>
#include <linux/netlink.h>
/* XXX: redefine */
#define GENLNET_NAME "genlnet name"
/* XXX: redefine */
#define GENLNET_VERSION 0x1
#define MAX_STR_LEN 100
enum {
MSG_CMD_ATTR_UNSPEC = 0,
MSG_CMD,
__MSG_CMD_ATTR_MAX,
};
#define MSG_CMD_ATTR_MAX (__MSG_CMD_ATTR_MAX - 1)
/*
* Commands sent from userspace
* Not versioned. New commands should only be inserted at the enum's end
* prior to __EFMP_MSG_CMD_MAX
*/
enum {
MSG_CMD_UNSPEC = 0, /* Reserved */
MSG_CMD_SET, /* user->kernel request/get-response */
MSG_CMD_NOTIFY, /* kernel->user event */
__MSG_CMD_MAX,
};
#define MSG_CMD_MAX (__MSG_CMD_MAX - 1)
/* netlink ÏûÏ¢½á¹¹Ìå */
typedef struct genlnet_msg_s {
struct nlmsghdr n;
struct genlmsghdr g;
char data[100];
} genlnet_msg_t;
/*
* Generic macros for dealing with netlink sockets. Might be duplicated
* elsewhere. It is recommended that commercial grade applications use
* libnl or libnetlink and use the interfaces provided by the library
*
* copy from Documentation/accounting/getdelays.c
*/
#undef GENLMSG_DATA
#define GENLMSG_DATA(glh) ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
#undef GENLMSG_PAYLOAD
#define GENLMSG_PAYLOAD(glh) (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
#undef NLA_DATA
#define NLA_DATA(na) ((void *)((char *)(na) + NLA_HDRLEN))
#undef NLA_PAYLOAD
#define NLA_PAYLOAD(len) (len - NLA_HDRLEN)
#endif /* _GENLNET_SOCKET_H_ */