53 lines
1.2 KiB
C
53 lines
1.2 KiB
C
#ifndef _G_VXLAN_H
|
|
#define _G_VXLAN_H
|
|
|
|
#ifdef __cpluscplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
struct g_vxlan
|
|
{
|
|
unsigned char flags;
|
|
unsigned char reserved[3];
|
|
|
|
// VNI 3 Bytes
|
|
unsigned char vlan_id_half_high;
|
|
|
|
unsigned char link_layer_type : 4; // 二层报文封装格式
|
|
unsigned char vlan_id_half_low : 4;
|
|
|
|
unsigned int dir_is_e2i : 1;
|
|
unsigned int traffic_is_decrypted : 1;
|
|
unsigned int next_sf_index : 5; // max value 32
|
|
unsigned int online_test : 1;
|
|
|
|
// Reserved 1 Bytes
|
|
unsigned int r7 : 1;
|
|
unsigned int r6 : 1;
|
|
unsigned int r5 : 1;
|
|
unsigned int r4 : 1;
|
|
unsigned int vni_flag : 1;
|
|
unsigned int r2 : 1;
|
|
unsigned int r1 : 1;
|
|
unsigned int r0 : 1;
|
|
} __attribute__((__packed__));
|
|
|
|
void g_vxlan_set_packet_dir(struct g_vxlan *hdr, int dir_is_e2i);
|
|
void g_vxlan_set_next_sf_index(struct g_vxlan *hdr, int next_sf_index);
|
|
void g_vxlan_set_traffic_type(struct g_vxlan *hdr, int traffic_is_decrypted);
|
|
|
|
int g_vxlan_get_packet_dir(struct g_vxlan *hdr);
|
|
int g_vxlan_get_next_sf_index(struct g_vxlan *hdr);
|
|
int g_vxlan_get_traffic_type(struct g_vxlan *hdr);
|
|
|
|
// return 0 : success
|
|
// return -1 : error
|
|
int g_vxlan_decode(struct g_vxlan **g_vxlan_hd, const char *raw_data, int raw_len);
|
|
|
|
#ifdef __cpluscplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|