rename layer_type to layer_proto

This commit is contained in:
luwenpeng
2024-06-12 18:21:45 +08:00
parent 10528bcfd3
commit 01958b56c5
20 changed files with 437 additions and 1049 deletions

View File

@@ -97,7 +97,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
const struct packet_layer *layer = packet_get_layer(pkt, i);
switch (layer->type)
{
case LAYER_TYPE_ETHER:
case LAYER_PROTO_ETHER:
buffer_push(&buff_proto, "eth:ethertype");
eth_hdr = (const struct ethhdr *)layer->hdr_ptr;
eth_hdr_get_source(eth_hdr, tmp_src_buff, sizeof(tmp_src_buff));
@@ -105,32 +105,29 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
buffer_push(&buff_eth_src, tmp_src_buff);
buffer_push(&buff_eth_dst, tmp_dst_buff);
break;
case LAYER_TYPE_PWETH:
case LAYER_PROTO_PWETH:
buffer_push(&buff_proto, "pwethheuristic:pwethcw");
break;
case LAYER_TYPE_PPP:
case LAYER_PROTO_PPP:
buffer_push(&buff_proto, "ppp");
break;
case LAYER_TYPE_HDLC:
buffer_push(&buff_proto, "hdlc");
break;
case LAYER_TYPE_L2TP:
case LAYER_PROTO_L2TP:
buffer_push(&buff_proto, "l2tp");
break;
case LAYER_TYPE_VLAN:
case LAYER_PROTO_VLAN:
buffer_push(&buff_proto, "vlan:ethertype");
vlan_hdr = (const struct vlan_hdr *)layer->hdr_ptr;
vlan_id = vlan_hdr_get_vid(vlan_hdr);
snprintf(tmp_src_buff, sizeof(tmp_src_buff), "%u", vlan_id);
buffer_push(&buff_vlan_id, tmp_src_buff);
break;
case LAYER_TYPE_PPPOE:
case LAYER_PROTO_PPPOE:
buffer_push(&buff_proto, "pppoes");
break;
case LAYER_TYPE_MPLS:
case LAYER_PROTO_MPLS:
buffer_push(&buff_proto, "mpls");
break;
case LAYER_TYPE_IPV4:
case LAYER_PROTO_IPV4:
buffer_push(&buff_proto, "ip");
ipv4_hdr = (const struct ip *)layer->hdr_ptr;
src_addr_v4 = ipv4_hdr_get_src_in_addr(ipv4_hdr);
@@ -140,7 +137,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
buffer_push(&buff_ipv4_src, tmp_src_buff);
buffer_push(&buff_ipv4_dst, tmp_dst_buff);
break;
case LAYER_TYPE_IPV6:
case LAYER_PROTO_IPV6:
buffer_push(&buff_proto, "ipv6");
ipv6_hdr = (const struct ip6_hdr *)layer->hdr_ptr;
switch (ipv6_hdr_get_next_header(ipv6_hdr))
@@ -170,13 +167,13 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
buffer_push(&buff_ipv6_src, tmp_src_buff);
buffer_push(&buff_ipv6_dst, tmp_dst_buff);
break;
case LAYER_TYPE_IPAH:
case LAYER_PROTO_IPAH:
buffer_push(&buff_proto, "ah");
break;
case LAYER_TYPE_GRE:
case LAYER_PROTO_GRE:
buffer_push(&buff_proto, "gre");
break;
case LAYER_TYPE_UDP:
case LAYER_PROTO_UDP:
buffer_push(&buff_proto, "udp");
udp_hdr = (const struct udphdr *)layer->hdr_ptr;
src_port = udp_hdr_get_src_port(udp_hdr);
@@ -186,7 +183,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
buffer_push(&buff_udp_src, tmp_src_buff);
buffer_push(&buff_udp_dst, tmp_dst_buff);
break;
case LAYER_TYPE_TCP:
case LAYER_PROTO_TCP:
buffer_push(&buff_proto, "tcp");
tcp_hdr = (const struct tcphdr *)layer->hdr_ptr;
src_port = tcp_hdr_get_src_port(tcp_hdr);
@@ -196,16 +193,16 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
buffer_push(&buff_tcp_src, tmp_src_buff);
buffer_push(&buff_tcp_dst, tmp_dst_buff);
break;
case LAYER_TYPE_ICMP:
case LAYER_PROTO_ICMP:
buffer_push(&buff_proto, "icmp");
break;
case LAYER_TYPE_ICMP6:
case LAYER_PROTO_ICMP6:
buffer_push(&buff_proto, "icmpv6");
break;
case LAYER_TYPE_VXLAN:
case LAYER_PROTO_VXLAN:
buffer_push(&buff_proto, "vxlan");
break;
case LAYER_TYPE_GTPV1_U:
case LAYER_PROTO_GTPV1_U:
buffer_push(&buff_proto, "gtp");
break;
default: