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() */
13 #include "dissector_eth.h"
18 uint16_t h_vlan_encapsulated_proto
;
19 } __attribute__((packed
));
21 static void vlan(struct pkt_buff
*pkt
)
24 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
29 tci
= ntohs(vlan
->h_vlan_TCI
);
32 tprintf("Prio (%d), ", (tci
& 0xE000) >> 13);
33 tprintf("CFI (%d), ", (tci
& 0x1000) >> 12);
34 tprintf("ID (%d), ", (tci
& 0x0FFF));
35 tprintf("Proto (0x%.4x)", ntohs(vlan
->h_vlan_encapsulated_proto
));
38 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
41 static void vlan_less(struct pkt_buff
*pkt
)
44 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
49 tci
= ntohs(vlan
->h_vlan_TCI
);
51 tprintf(" VLAN%d", (tci
& 0x0FFF));
53 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
56 struct protocol vlan_ops
= {
59 .print_less
= vlan_less
,