3 * Siemens AG, All rights reserved.
4 * Dmitry Eremin-Solenikov (dbaryshkov@gmail.com)
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that: (1) source code distributions
8 * retain the above copyright notice and this paragraph in its entirety, (2)
9 * distributions including binary code include the above copyright notice and
10 * this paragraph in its entirety in the documentation or other materials
11 * provided with the distribution, and (3) all advertising materials mentioning
12 * features or use of this software display the following acknowledgement:
13 * ``This product includes software developed by the University of California,
14 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
15 * the University nor the names of its contributors may be used to endorse
16 * or promote products derived from this software without specific prior
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 /* \summary: IEEE 802.15.4 printer */
29 #include <netdissect-stdinc.h>
31 #include "netdissect.h"
32 #include "addrtoname.h"
36 static const char *ftypes
[] = {
48 extract_header_length(uint16_t fc
)
52 switch ((fc
>> 10) & 0x3) {
54 if (fc
& (1 << 6)) /* intra-PAN with none dest addr */
67 switch ((fc
>> 14) & 0x3) {
91 ieee802_15_4_if_print(netdissect_options
*ndo
,
92 const struct pcap_pkthdr
*h
, const u_char
*p
)
94 u_int caplen
= h
->caplen
;
100 ND_PRINT((ndo
, "[|802.15.4] %x", caplen
));
104 fc
= EXTRACT_LE_16BITS(p
);
105 hdrlen
= extract_header_length(fc
);
107 seq
= EXTRACT_LE_8BITS(p
+ 2);
112 ND_PRINT((ndo
,"IEEE 802.15.4 %s packet ", ftypes
[fc
& 0x7]));
114 ND_PRINT((ndo
,"seq %02x ", seq
));
116 ND_PRINT((ndo
,"invalid! "));
121 if (!ndo
->ndo_vflag
) {
127 switch ((fc
>> 10) & 0x3) {
129 ND_PRINT((ndo
,"none "));
132 ND_PRINT((ndo
,"reserved destination addressing mode"));
135 panid
= EXTRACT_LE_16BITS(p
);
137 ND_PRINT((ndo
,"%04x:%04x ", panid
, EXTRACT_LE_16BITS(p
)));
141 panid
= EXTRACT_LE_16BITS(p
);
143 ND_PRINT((ndo
,"%04x:%s ", panid
, le64addr_string(ndo
, p
)));
147 ND_PRINT((ndo
,"< "));
149 switch ((fc
>> 14) & 0x3) {
151 ND_PRINT((ndo
,"none "));
154 ND_PRINT((ndo
,"reserved source addressing mode"));
157 if (!(fc
& (1 << 6))) {
158 panid
= EXTRACT_LE_16BITS(p
);
161 ND_PRINT((ndo
,"%04x:%04x ", panid
, EXTRACT_LE_16BITS(p
)));
165 if (!(fc
& (1 << 6))) {
166 panid
= EXTRACT_LE_16BITS(p
);
169 ND_PRINT((ndo
,"%04x:%s ", panid
, le64addr_string(ndo
, p
)));
177 if (!ndo
->ndo_suppress_default_print
)
178 ND_DEFAULTPRINT(p
, caplen
);