2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Copyright 2010 Emmanuel Roullit.
6 * Subject to the GPL, version 2.
11 #include <netinet/in.h> /* for ntohs() */
15 #include "dissector_eth.h"
20 uint16_t h_vlan_encapsulated_proto
;
21 } __attribute__((packed
));
23 static void vlan(struct pkt_buff
*pkt
)
26 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
31 tci
= ntohs(vlan
->h_vlan_TCI
);
34 tprintf("Prio (%d), ", (tci
& 0xE000) >> 13);
35 tprintf("CFI (%d), ", (tci
& 0x1000) >> 12);
36 tprintf("ID (%d), ", (tci
& 0x0FFF));
37 tprintf("Proto (0x%.4x)", ntohs(vlan
->h_vlan_encapsulated_proto
));
40 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
43 static void vlan_less(struct pkt_buff
*pkt
)
46 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
51 tci
= ntohs(vlan
->h_vlan_TCI
);
53 tprintf(" VLAN%d", (tci
& 0x0FFF));
55 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
58 struct protocol vlan_ops
= {
61 .print_less
= vlan_less
,