TSG-13383 解析RAW_PACKET

* 增加 ETH_VLAN_VLAN_IP4_IP4_UDP 的测试用例
    * 增加 ETH_IP6_IP4_TCP_SSH 的测试用例
    * 增加 ETH_IP4_IP6_TCP 的测试用例
    * 增加 ETH_IP6_IP6_UDP 的测试用例
    * 增加 ETH_MPLS_IP4_TCP 的测试用例
    * 增加 ETH_MPLS_MPLS_IP4_TCP 的测试用例
    * 增加 ETH_VLAN_PPPOE_IP4_TCP 的测试用例
    * 增加 ETH_IP6_UDP_GTP_IP6_TCP_TLS 的测试用例
    * 增加 ETH_IP6_UDP_GTP_IP4_TCP_TLS 的测试用例
    * 增加 ETH_IP4_UDP_VXLAN_ETH_IP4_UDP_DNS 的测试用例
    * 增加 ETH_MPLS_MPLS_PWETHCW_ETH_ARP 的测试用例
    * 增加 ETH_MPLS_MPLS_PWETHCW_ETH_ARP 的测试用例
This commit is contained in:
luwenpeng
2023-01-15 18:07:18 +08:00
committed by luwenpeng
parent 2a971cd9f4
commit 8a3b3eb049
20 changed files with 2471 additions and 47 deletions

View File

@@ -8,44 +8,42 @@ extern "C"
#include <netinet/in.h>
enum addr_tuple4_type
{
ADDR_TUPLE4_TYPE_V4,
ADDR_TUPLE4_TYPE_V6,
};
struct addr_tuple4_v4
{
struct in_addr src_addr; /* network order */
struct in_addr dst_addr; /* network order */
in_port_t src_port; /* network order */
in_port_t dst_port; /* network order */
};
struct addr_tuple4_v6
{
struct in6_addr src_addr; /* network order */
struct in6_addr dst_addr; /* network order */
in_port_t src_port; /* network order */
in_port_t dst_port; /* network order */
};
struct addr_tuple4
{
enum addr_tuple4_type addr_type;
union
enum addr_tuple4_type
{
struct addr_tuple4_v4 addr_v4;
struct addr_tuple4_v6 addr_v6;
ADDR_TUPLE4_TYPE_V4,
ADDR_TUPLE4_TYPE_V6,
};
struct addr_v4
{
struct in_addr src_addr; /* network order */
struct in_addr dst_addr; /* network order */
};
struct addr_v6
{
struct in6_addr src_addr; /* network order */
struct in6_addr dst_addr; /* network order */
};
struct addr_tuple4
{
enum addr_tuple4_type addr_type;
in_port_t src_port; /* network order */
in_port_t dst_port; /* network order */
union
{
struct addr_v4 addr_v4;
struct addr_v6 addr_v6;
};
};
};
#define INIT_ADDR_V4(name, src_addr_str, src_port_num, dst_addr_str, dst_port_num) \
struct addr_tuple4 name; \
memset(&name, 0, sizeof(name)); \
(name).addr_type = ADDR_TUPLE4_TYPE_V4; \
(name).addr_v4.src_port = htons((src_port_num)); \
(name).addr_v4.dst_port = htons((dst_port_num)); \
(name).src_port = htons((src_port_num)); \
(name).dst_port = htons((dst_port_num)); \
inet_pton(AF_INET, (src_addr_str), &(name).addr_v4.src_addr); \
inet_pton(AF_INET, (dst_addr_str), &(name).addr_v4.dst_addr);
@@ -53,13 +51,13 @@ struct addr_tuple4
struct addr_tuple4 name; \
memset(&name, 0, sizeof(name)); \
(name).addr_type = ADDR_TUPLE4_TYPE_V6; \
(name).addr_v6.src_port = htons((src_port_num)); \
(name).addr_v6.dst_port = htons((dst_port_num)); \
(name).src_port = htons((src_port_num)); \
(name).dst_port = htons((dst_port_num)); \
inet_pton(AF_INET6, (src_addr_str), &(name).addr_v6.src_addr); \
inet_pton(AF_INET6, (dst_addr_str), &(name).addr_v6.dst_addr);
char *addr_tuple4_to_str(const struct addr_tuple4 *addr);
void addr_tuple4_reverse(const struct addr_tuple4 *orin, struct addr_tuple4 *out);
char *addr_tuple4_to_str(const struct addr_tuple4 *addr);
void addr_tuple4_reverse(const struct addr_tuple4 *orin, struct addr_tuple4 *out);
#ifdef __cpluscplus
}