-
Notifications
You must be signed in to change notification settings - Fork 0
/
commom.h
68 lines (58 loc) · 1.23 KB
/
commom.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
65
66
67
68
#ifndef __COMMON_H__
#define __COMMON_H__
#ifndef __KERNEL__
#include <stdint.h>
#endif
#ifndef __KERNEL__
#define UINT8 uint8_t
#define UINT16 uint16_t
#define UINT32 uint32_t
#else
#define UINT8 u8
#define UINT16 u16
#define UINT32 u32
#endif
//=============netlink config==============
#define NLNUM 24
#ifndef __KERNEL__
#define NL_MAXPAYLOAD 4096
#else
#define NL_MAXPAYLOAD (NLMSG_DEFAULT_SIZE>>1)
#endif
//type lower than 0x10 is reserved for control messages, which is defined in uapi/linux/netlink.h
//control managenent messages
#define NLMSG_SUCCESS 0xf0
#define NLMSG_FAIL 0xff
#define NLMSG_SETECHO 0x11
#define NLMSG_GETECHO 0x12
#define NLMSG_DAEMON_REG 0x13
#define NLMSG_DAEMON_UNREG 0x14
//setup message
#define NLMSG_SETUP_MIRROR 0x20
#define NLMSG_SETUP_SERVER 0x21
//data transfer message
#define NLMSG_DATA_SEND 0x30
#define NLMSG_DATA_ACK 0x31
#define NLMSG_DATA_INFO 0x32
//=============netlink config end==============
#define HOST_TYPE_TARGET 1
#define HOST_TYPE_MIRROR 2
union my_ip_type
{
unsigned char c[4];
UINT32 i;
};
struct host_info
{
union my_ip_type ip;
unsigned char mac[6];
UINT16 port_no;
};
struct connection_info
{
union my_ip_type ip;
UINT16 port;
UINT8 proto;
UINT8 host_type;
};
#endif