ifpps: fix typo in help
[netsniff.git] / src / proto_vlan_q_in_q.c
blob17e09b85c599201b3c7918db5f706868078d38d2
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * Copyright 2012 Markus Amend <markus@netsniff-ng.org>, Deutsche Flugsicherung GmbH
4 * Subject to the GPL, version 2.
6 * http://www.ieee802.org/1/pages/802.1ad.html
7 */
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <netinet/in.h> /* for ntohs() */
13 #include "proto.h"
14 #include "protos.h"
15 #include "dissector_eth.h"
16 #include "built_in.h"
17 #include "pkt_buff.h"
19 struct QinQhdr {
20 uint16_t TCI;
21 uint16_t TPID;
22 } __packed;
24 static void QinQ_full(struct pkt_buff *pkt)
26 uint16_t tci;
27 struct QinQhdr *QinQ = (struct QinQhdr *) pkt_pull(pkt, sizeof(*QinQ));
29 if (QinQ == NULL)
30 return;
32 tci = ntohs(QinQ->TCI);
34 tprintf(" [ VLAN QinQ ");
35 tprintf("Prio (%d), ", (tci & 0xE000) >> 13);
36 tprintf("DEI (%d), ", (tci & 0x1000) >> 12);
37 tprintf("ID (%d), ", (tci & 0x0FFF));
38 tprintf("Proto (0x%.4x)", ntohs(QinQ->TPID));
39 tprintf(" ]\n");
41 pkt_set_proto(pkt, &eth_lay2, ntohs(QinQ->TPID));
44 static void QinQ_less(struct pkt_buff *pkt)
46 uint16_t tci;
47 struct QinQhdr *QinQ = (struct QinQhdr *) pkt_pull(pkt, sizeof(*QinQ));
49 if (QinQ == NULL)
50 return;
52 tci = ntohs(QinQ->TCI);
54 tprintf(" VLAN%d", (tci & 0x0FFF));
56 pkt_set_proto(pkt, &eth_lay2, ntohs(QinQ->TPID));
59 struct protocol QinQ_ops = {
60 .key = 0x88a8,
61 .print_full = QinQ_full,
62 .print_less = QinQ_less,
65 EXPORT_SYMBOL(QinQ_ops);