summaryrefslogtreecommitdiff
path: root/src/nat_format.h
blob: a7dd59288a51988e21e652dcd66da07b9b643f5d (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
#ifndef NAT_FORMAT_H_
#define NAT_FORMAT_H_

#include <MESA/stream.h>
#include <MESA/MESA_handle_logger.h>
#include <MESA/MESA_prof_load.h>

#define FORMAT_LOG_MAGIC_NUMBER 0x004e4154
#define FORMAT_LOG_VERSION 0x0200

#define FORMAT_LOG_PROTOCOL_ICMP 0x01
#define FORMAT_LOG_PROTOCOL_TCP 0x06
#define FORMAT_LOG_PROTOCOL_UDP 0x17    // 目前均采用UDP传输

// 全局配置信息
struct nat_format_global_info {
    int32_t batch_size;
    char host_ip[64];
    u_int32_t host_port;
    char multicast_ip[64];
    u_int32_t multicast_port;

    int32_t hw_syslog_port;
    int32_t hw_binary_port;
    int32_t h3_syslog_port;
    int32_t h3_binary_port;
    int32_t dp_syslog_port;
    int32_t dp_binary_port;

    char log_path[256];
    u_int32_t log_level;
    void *log;
};

// 格式化NAT报文载荷
struct nat_payload {
    unsigned int magic_num = FORMAT_LOG_MAGIC_NUMBER;
    unsigned short version = FORMAT_LOG_VERSION;
    unsigned int fw_log_timestamp;
    unsigned int fw_ip;
    char action;
    unsigned int stream_start_timestamp;
    unsigned int stream_end_timestamp;
    unsigned int src_intra_ip;
    unsigned short src_intra_port;
    unsigned int src_extra_ip;
    unsigned short src_extra_port;
    unsigned int dst_ip;
    unsigned short dst_port;
    char protocol = FORMAT_LOG_PROTOCOL_UDP;
};

#endif  // NAT_FORMAT_H_