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() */
16 #include "dissector_eth.h"
24 static int mpls_uc_next_proto(struct pkt_buff
*pkt
)
34 /* FIXME: Right now only test for IP Version field */
37 key
= 0x0800; /* IPv4*/
40 key
= 0x86DD; /* IPv6*/
43 /* Nothing detected ... */
50 static void mpls_uc_full(struct pkt_buff
*pkt
)
53 uint32_t mpls_uc_data
;
54 struct mpls_uchdr
*mpls_uc
;
58 mpls_uc
= (struct mpls_uchdr
*) pkt_pull(pkt
, sizeof(*mpls_uc
));
62 mpls_uc_data
= ntohl(mpls_uc
->mpls_uc_hdr
);
63 s
= (mpls_uc_data
>> 8) & 0x1;
66 tprintf("Label (%u), ", mpls_uc_data
>> 12);
67 tprintf("Exp (%u), ", (mpls_uc_data
>> 9) & 0x7);
68 tprintf("S (%u), ", s
);
69 tprintf("TTL (%u)", (mpls_uc_data
& 0xFF));
73 next
= mpls_uc_next_proto(pkt
);
77 pkt_set_proto(pkt
, ð_lay2
, (uint16_t) next
);
80 static void mpls_uc_less(struct pkt_buff
*pkt
)
83 uint32_t mpls_uc_data
;
84 struct mpls_uchdr
*mpls_uc
;
88 mpls_uc
= (struct mpls_uchdr
*) pkt_pull(pkt
, sizeof(*mpls_uc
));
92 mpls_uc_data
= ntohl(mpls_uc
->mpls_uc_hdr
);
93 s
= (mpls_uc_data
>> 8) & 0x1;
95 tprintf(" MPLS/%u", mpls_uc_data
>> 12);
98 next
= mpls_uc_next_proto(pkt
);
102 pkt_set_proto(pkt
, ð_lay2
, (uint16_t) next
);
105 struct protocol mpls_uc_ops
= {
107 .print_full
= mpls_uc_full
,
108 .print_less
= mpls_uc_less
,
111 EXPORT_SYMBOL(mpls_uc_ops
);