blob: c08e8871f28c392a6381223b8711b32773223081 (
plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
#ifndef __MRL_UTILS_H_
#define __MRL_UTILS_H_
#include "maxminddb.h"
#define MRL_STR_MAC_LEN 18
#define MRL_STR_PORT_LEN 6
#define MRL_STR_IP_LEN 16
#define MRL_STR_ENCAP_TYPE_LEN 5
#define MRL_STR_LINK_ID_LEN 5
#define MRL_STR_LINK_DIR_LEN 2
#define MRL_STR_VPN_ID_LEN 5
#define MRL_STR_PROT_LEN 4
#define MRL_STR_USER_TYPE_LEN 6
#define MRL_STR_USER_ID_LEN 1024
#define MRL_STR_EFFEC_RANGE_LEN 20
#define MRL_STR_NETCARD_LEN 20
#define MRL_STR_DETECT_RESPONSE_LEN 50
#define MRL_DETECT_TYPE_LEN 10
#define MRL_MAX_PAYLOAD_LEN 50
#define MRL_DETECT_SERVER_NUM 2
#define MRL_DATE_LEN 50
#define MRL_LOCATION_LEN 20
#define MRL_MAX_PATH 50
#define MRL_IPV4_TYPE 4
#define MRL_UDP_HDR_LEN 8
#define MRL_IP_HDR_LEN 20
#define MRL_MAC_LEN 6
#define MRL_BUFF_LEN 3000
#define MRL_IP_PKT_LEN 1500
#define MRL_MAX_STRING 50
#define MRL_TCP_TYPE 6
#define MRL_UDP_TYPE 17
#define MRL_SNAT_BACK_TYPE 0
#define MRL_DNAT_BACK_TYPE 1
#define DEFAULT_EFFECTIVE_RANGE "{}"
#define MRL_CFG_ID_MOD 500000000
#define MRL_DEL_AFTER 1800
#define MRL_DEL_NOW 0
#define MRL_INVALID 0
#define MRL_VALID 1
#define MRL_ADD_DNAT_NOMINEE 0
#define MRL_DEL_DNAT_NOMINEE 1
#define RLOG_LV_DEBUG 10
#define RLOG_LV_INFO 20
#define RLOG_LV_FATAL 30
#define MRL_HTABLE_DEL_NULL 0
#define MRL_HTABLE_DEL_SUCCESS 1
#define MRL_HTABLE_ADD_DUPLICATE 0
#define MRL_HTABLE_ADD_SUCCESS 1
#define MRL_SNAT_NOMINEE_TYPE 0
#define MRL_DNAT_NOMINEE_TYPE 1
#define IR_NOMINEE_IP_TABLE_NAME "IR_NOMINEE_IP"
#define IR_CANDIDATE_IP_TABLE_NAME "IR_CANDIDATE_IP"
#define IR_DNAT_POLICY_TABLE_NAME "IR_DNAT_POLICY"
#define IR_DNAT_CANDIDATE_IP_TABLE_NAME "IR_DNAT_CANDIDATE_IP"
#define IR_VXLAN_INFO_TABLE_NAME "IR_VXLAN_INFO"
#define IR_MRL_IP_INFO_TABLE_NAME "IR_MRL_IP_INFO"
struct mrl_tuple{
char sip[MRL_STR_IP_LEN];
char dip[MRL_STR_IP_LEN];
uint16_t sport;//host order
uint16_t dport;//host order
uint8_t protocol;//udp or tcp
};
unsigned int mrl_split_str(char *str, const char *delim, char **dest);
int mrl_mac_pton(const char *str, int delim, uint8_t *mac);
void mrl_get_cur_time(char *time);
unsigned short mrl_get_checksum(unsigned short * buffer, size_t len);
unsigned int mrl_get_ip_by_eth_name(const char *ifname);
int mrl_inet_ntoa(uint32_t ip, char *dest);
int mrl_get_pkt_tuple(const char *raw_packet, struct mrl_tuple *five_tuple);
void mrl_mmdb_init(const char *path);
int mrl_is_inside_ip(const char *ip_addr);
#endif
|