This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhaoyijun-nat-format/src/nat_format.h

54 lines
1.3 KiB
C
Raw Normal View History

2024-08-23 17:53:01 +08:00
#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;
2024-08-26 18:19:47 +08:00
char log_path[256];
2024-08-23 17:53:01 +08:00
u_int32_t log_level;
void *log;
};
// 格式化NAT报文载荷
struct nat_payload {
unsigned int magic_num = FORMAT_LOG_MAGIC_NUMBER;
2024-08-26 18:19:47 +08:00
unsigned short version = FORMAT_LOG_VERSION;
2024-08-23 17:53:01 +08:00
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_