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"
21 uint16_t h_vlan_encapsulated_proto
;
22 } __attribute__((packed
));
24 static inline void vlan(uint8_t *packet
, size_t len
)
27 struct vlanhdr
*vlan
= (struct vlanhdr
*) packet
;
29 if (len
< sizeof(struct vlanhdr
))
32 tci
= ntohs(vlan
->h_vlan_TCI
);
35 tprintf("Prio (%d), ", (tci
& 0xE000) >> 13);
36 tprintf("CFI (%d), ", (tci
& 0x1000) >> 12);
37 tprintf("ID (%d), ", (tci
& 0x0FFF));
38 tprintf("Proto (0x%.4x)", ntohs(vlan
->h_vlan_encapsulated_proto
));
42 static inline void vlan_less(uint8_t *packet
, size_t len
)
45 struct vlanhdr
*vlan
= (struct vlanhdr
*) packet
;
47 if (len
< sizeof(struct vlanhdr
))
50 tci
= ntohs(vlan
->h_vlan_TCI
);
52 tprintf(" VLAN%d", (tci
& 0x0FFF));
55 static inline void vlan_next(uint8_t *packet
, size_t len
,
56 struct hash_table
**table
,
57 unsigned int *key
, size_t *off
)
59 struct vlanhdr
*vlan
= (struct vlanhdr
*) packet
;
61 if (len
< sizeof(struct vlanhdr
))
64 (*off
) = sizeof(struct vlanhdr
);
65 (*key
) = ntohs(vlan
->h_vlan_encapsulated_proto
);
75 struct protocol vlan_ops
= {
77 .offset
= sizeof(struct vlanhdr
),
79 .print_less
= vlan_less
,
80 .print_pay_ascii
= empty
,
81 .print_pay_hex
= empty
,
82 .print_pay_none
= vlan
,
83 .print_all_cstyle
= __hex2
,
84 .print_all_hex
= __hex
,
85 .proto_next
= vlan_next
,