Add test case for tunnel

This commit is contained in:
luwenpeng
2024-06-19 14:43:32 +08:00
parent 327d6e7b14
commit c3fd452793
17 changed files with 933 additions and 138 deletions

View File

@@ -46,29 +46,29 @@ static void on_sess_msg(struct session *sess, int topic_id, const void *msg, voi
switch (layer.proto)
{
case LAYER_PROTO_IPV4:
if (memcmp(&layer.header.ip4->ip_src, &rule.addr4, sizeof(struct in_addr)) == 0 ||
memcmp(&layer.header.ip4->ip_dst, &rule.addr4, sizeof(struct in_addr)) == 0)
if (memcmp(&layer.hdr.ip4->ip_src, &rule.addr4, sizeof(struct in_addr)) == 0 ||
memcmp(&layer.hdr.ip4->ip_dst, &rule.addr4, sizeof(struct in_addr)) == 0)
{
is_ip_hit = 1;
}
break;
case LAYER_PROTO_IPV6:
if (memcmp(&layer.header.ip6->ip6_src, &rule.addr6, sizeof(struct in6_addr)) == 0 ||
memcmp(&layer.header.ip6->ip6_dst, &rule.addr6, sizeof(struct in6_addr)) == 0)
if (memcmp(&layer.hdr.ip6->ip6_src, &rule.addr6, sizeof(struct in6_addr)) == 0 ||
memcmp(&layer.hdr.ip6->ip6_dst, &rule.addr6, sizeof(struct in6_addr)) == 0)
{
is_ip_hit = 1;
}
break;
case LAYER_PROTO_TCP:
if (layer.header.tcp->th_sport == rule.port ||
layer.header.tcp->th_dport == rule.port)
if (layer.hdr.tcp->th_sport == rule.port ||
layer.hdr.tcp->th_dport == rule.port)
{
is_port_hit = 1;
}
break;
case LAYER_PROTO_UDP:
if (layer.header.udp->uh_sport == rule.port ||
layer.header.udp->uh_dport == rule.port)
if (layer.hdr.udp->uh_sport == rule.port ||
layer.hdr.udp->uh_dport == rule.port)
{
is_port_hit = 1;
}

View File

@@ -202,7 +202,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
case LAYER_PROTO_VXLAN:
buffer_push(&buff_proto, "vxlan");
break;
case LAYER_PROTO_GTPV1_U:
case LAYER_PROTO_GTP:
buffer_push(&buff_proto, "gtp");
break;
default:
@@ -239,7 +239,7 @@ static void packet_handler(u_char *user, const struct pcap_pkthdr *h, const u_ch
if (opts->print_readable_format)
{
printf("\033[0;32m frame=%lu len=%u \033[0m", number, h->caplen);
packet_print_str(&pkt);
packet_print(&pkt);
}
if (opts->print_tshark_format)