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.
14 #include <netinet/in.h> /* for ntohs() */
16 #include "proto_struct.h"
17 #include "dissector_eth.h"
22 uint16_t h_vlan_encapsulated_proto
;
23 } __attribute__((packed
));
25 static inline void vlan(struct pkt_buff
*pkt
)
28 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
33 tci
= ntohs(vlan
->h_vlan_TCI
);
36 tprintf("Prio (%d), ", (tci
& 0xE000) >> 13);
37 tprintf("CFI (%d), ", (tci
& 0x1000) >> 12);
38 tprintf("ID (%d), ", (tci
& 0x0FFF));
39 tprintf("Proto (0x%.4x)", ntohs(vlan
->h_vlan_encapsulated_proto
));
42 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
45 static inline void vlan_less(struct pkt_buff
*pkt
)
48 struct vlanhdr
*vlan
= (struct vlanhdr
*) pkt_pull(pkt
, sizeof(*vlan
));
53 tci
= ntohs(vlan
->h_vlan_TCI
);
55 tprintf(" VLAN%d", (tci
& 0x0FFF));
57 pkt_set_proto(pkt
, ð_lay2
, ntohs(vlan
->h_vlan_encapsulated_proto
));
60 struct protocol vlan_ops
= {
63 .print_less
= vlan_less
,