#pragma once #ifdef __cplusplus extern "C" { #endif #include "layer.h" enum tunnel_type { TUNNEL_IPV4 = 1, // contain layers: IPv4, (next inner layer must be IPv4 / IPv6) TUNNEL_IPV6 = 2, // contain layers: IPv6, (next inner layer must be IPv4 / IPv6) TUNNEL_GRE = 3, // contain layers: IPv4 + GRE // contain layers: IPv6 + GRE TUNNEL_GTP = 4, // contain layers: IPv4 + UDP + GTP // contain layers: IPv6 + UDP + GTP TUNNEL_VXLAN = 5, // contain layers: IPv4 + UDP + VXLAN // contain layers: IPv6 + UDP + VXLAN TUNNEL_L2TP = 6, // contain layers: IPv4 + UDP + L2TP // contain layers: IPv6 + UDP + L2TP TUNNEL_TEREDO = 7, // contain layers: IPv4 + UDP, (next inner layer must be IPv6) }; #define MAX_LAYERS_PER_TUNNEL 3 struct tunnel { enum tunnel_type type; int layer_count; const struct layer *layers[MAX_LAYERS_PER_TUNNEL]; }; int packet_get_tunnel_count(const struct packet *pkt); // return 0: success  // return -1: failed int packet_get_tunnel_by_idx(const struct packet *pkt, int idx, struct tunnel *out); #ifdef __cplusplus } #endif