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://tools.ietf.org/html/rfc3032
11 #include <netinet/in.h> /* for ntohs() */
15 #include "dissector_eth.h"
23 static int mpls_uc_next_proto(struct pkt_buff
*pkt
)
33 /* FIXME: Right now only test for IP Version field */
36 key
= 0x0800; /* IPv4*/
39 key
= 0x86DD; /* IPv6*/
42 /* Nothing detected ... */
49 static void mpls_uc_full(struct pkt_buff
*pkt
)
52 uint32_t mpls_uc_data
;
53 struct mpls_uchdr
*mpls_uc
;
57 mpls_uc
= (struct mpls_uchdr
*) pkt_pull(pkt
, sizeof(*mpls_uc
));
61 mpls_uc_data
= ntohl(mpls_uc
->mpls_uc_hdr
);
62 s
= (mpls_uc_data
>> 8) & 0x1;
65 tprintf("Label (%u), ", mpls_uc_data
>> 12);
66 tprintf("Exp (%u), ", (mpls_uc_data
>> 9) & 0x7);
67 tprintf("S (%u), ", s
);
68 tprintf("TTL (%u)", (mpls_uc_data
& 0xFF));
72 next
= mpls_uc_next_proto(pkt
);
76 pkt_set_proto(pkt
, ð_lay2
, (uint16_t) next
);
79 static void mpls_uc_less(struct pkt_buff
*pkt
)
82 uint32_t mpls_uc_data
;
83 struct mpls_uchdr
*mpls_uc
;
87 mpls_uc
= (struct mpls_uchdr
*) pkt_pull(pkt
, sizeof(*mpls_uc
));
91 mpls_uc_data
= ntohl(mpls_uc
->mpls_uc_hdr
);
92 s
= (mpls_uc_data
>> 8) & 0x1;
94 tprintf(" MPLS/%u", mpls_uc_data
>> 12);
97 next
= mpls_uc_next_proto(pkt
);
101 pkt_set_proto(pkt
, ð_lay2
, (uint16_t) next
);
104 struct protocol mpls_uc_ops
= {
106 .print_full
= mpls_uc_full
,
107 .print_less
= mpls_uc_less
,