Add VLAN utils
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "ipv6_utils.h"
|
||||
#include "packet_priv.h"
|
||||
#include "eth_utils.h"
|
||||
#include "vlan_utils.h"
|
||||
#include "ipv4_utils.h"
|
||||
#include "ipv6_utils.h"
|
||||
#include "tcp_utils.h"
|
||||
@@ -48,6 +49,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
-e frame.protocols \
|
||||
-e eth.src \
|
||||
-e eth.dst \
|
||||
-e vlan.id \
|
||||
-e ip.src \
|
||||
-e ip.dst \
|
||||
-e ipv6.src \
|
||||
@@ -62,6 +64,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
struct buffer buff_proto = {.buff = {0}, .used = 0, .elimiter = ':'};
|
||||
struct buffer buff_eth_src = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_eth_dst = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_vlan_id = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_ipv4_src = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_ipv4_dst = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_ipv6_src = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
@@ -71,6 +74,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
struct buffer buff_udp_src = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
struct buffer buff_udp_dst = {.buff = {0}, .used = 0, .elimiter = ','};
|
||||
const struct ethhdr *eth_hdr = NULL;
|
||||
const struct vlan_hdr *vlan_hdr = NULL;
|
||||
const struct ip *ipv4_hdr = NULL;
|
||||
const struct ip6_hdr *ipv6_hdr = NULL;
|
||||
const struct tcphdr *tcp_hdr = NULL;
|
||||
@@ -81,6 +85,7 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
struct in6_addr dst_addr_v6 = {0};
|
||||
uint16_t src_port = 0;
|
||||
uint16_t dst_port = 0;
|
||||
uint16_t vlan_id = 0;
|
||||
char tmp_src_buff[256] = {0};
|
||||
char tmp_dst_buff[256] = {0};
|
||||
|
||||
@@ -114,6 +119,10 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
break;
|
||||
case LAYER_TYPE_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:
|
||||
buffer_push(&buff_proto, "pppoes");
|
||||
@@ -205,11 +214,12 @@ static void packet_to_tshark_format(const struct packet *pkt, uint64_t idx)
|
||||
}
|
||||
}
|
||||
|
||||
printf("%lu\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
|
||||
printf("%lu\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",
|
||||
number,
|
||||
buff_proto.buff,
|
||||
buff_eth_src.buff,
|
||||
buff_eth_dst.buff,
|
||||
buff_vlan_id.buff,
|
||||
buff_ipv4_src.buff,
|
||||
buff_ipv4_dst.buff,
|
||||
buff_ipv6_src.buff,
|
||||
|
||||
Reference in New Issue
Block a user