2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2009, 2010 Daniel Borkmann.
4 * Copyright 2010 Emmanuel Roullit.
5 * Subject to the GPL, version 2.
10 #include <netinet/in.h> /* for ntohs() */
14 #include "dissector_eth.h"
19 uint16_t h_vlan_encapsulated_proto
;
20 } __attribute__((packed
));
22 static void vlan(struct pkt_buff
*pkt
)
25 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
30 tci
= ntohs(vlan
->h_vlan_TCI
);
33 tprintf("Prio (%d), ", (tci
& 0xE000) >> 13);
34 tprintf("CFI (%d), ", (tci
& 0x1000) >> 12);
35 tprintf("ID (%d), ", (tci
& 0x0FFF));
36 tprintf("Proto (0x%.4x)", ntohs(vlan
->h_vlan_encapsulated_proto
));
39 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
42 static void vlan_less(struct pkt_buff
*pkt
)
45 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
50 tci
= ntohs(vlan
->h_vlan_TCI
);
52 tprintf(" VLAN%d", (tci
& 0x0FFF));
54 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
57 struct protocol vlan_ops
= {
60 .print_less
= vlan_less
,