Refactored packet API to support struct layer (using union to contain different types of encapsulation headers)

This commit is contained in:
luwenpeng
2024-06-14 19:24:27 +08:00
parent 1f78881cbb
commit de4c15f43c
47 changed files with 834 additions and 701 deletions

View File

@@ -95,7 +95,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
memset(tmp_src_buff, 0, sizeof(tmp_src_buff));
memset(tmp_dst_buff, 0, sizeof(tmp_dst_buff));
const struct raw_layer *layer = packet_get_raw_layer(pkt, i);
switch (layer->type)
switch (layer->proto)
{
case LAYER_PROTO_ETHER:
buffer_push(&buff_proto, "eth:ethertype");
@@ -232,6 +232,7 @@ static void packet_handler(u_char *user, const struct pcap_pkthdr *h, const u_ch
struct options *opts = (struct options *)user;
struct packet pkt;
memset(&pkt, 0, sizeof(pkt));
packet_parse(&pkt, (const char *)bytes, h->caplen);
number++;