Skip to content
Newer
Older
100644 884 lines (748 sloc) 26 KB
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
1 /*
2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
bbc1cfa @yuguy Have the configure script arrange that the Makefile define _U_
yuguy authored
22 #ifndef lint
23 static const char rcsid[] _U_ =
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
24 "@(#)$Header: /tcpdump/master/tcpdump/print-fr.c,v 1.51 2006-06-23 22:20:32 hannes Exp $ (LBL)";
bbc1cfa @yuguy Have the configure script arrange that the Makefile define _U_
yuguy authored
25 #endif
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
26
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
3d93249 Added support for Win32, based on WinPcap.
risso authored
31 #include <tcpdump-stdinc.h>
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
32
33 #include <stdio.h>
34 #include <string.h>
35 #include <pcap.h>
36
37 #include "addrtoname.h"
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
38 #include "interface.h"
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
39 #include "ethertype.h"
4d399db -move the nlpid definitions and tokens to a dedicated file(s)
hannes authored
40 #include "nlpid.h"
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
41 #include "extract.h"
9c2d2a4 move the SNAP OUI values out of the llc printer into
hannes authored
42 #include "oui.h"
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
43
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
44 static void frf15_print(const u_char *, u_int);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
45
b17c37f -add frame-relay header documentation
hannes authored
46 /*
47 * the frame relay header has a variable length
48 *
49 * the EA bit determines if there is another byte
50 * in the header
51 *
52 * minimum header length is 2 bytes
53 * maximum header length is 4 bytes
54 *
55 * 7 6 5 4 3 2 1 0
56 * +----+----+----+----+----+----+----+----+
57 * | DLCI (6 bits) | CR | EA |
58 * +----+----+----+----+----+----+----+----+
59 * | DLCI (4 bits) |FECN|BECN| DE | EA |
60 * +----+----+----+----+----+----+----+----+
61 * | DLCI (7 bits) | EA |
62 * +----+----+----+----+----+----+----+----+
63 * | DLCI (6 bits) |SDLC| EA |
64 * +----+----+----+----+----+----+----+----+
65 */
66
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
67 #define FR_EA_BIT 0x01
68
b17c37f -add frame-relay header documentation
hannes authored
69 #define FR_CR_BIT 0x02000000
70 #define FR_DE_BIT 0x00020000
71 #define FR_BECN_BIT 0x00040000
72 #define FR_FECN_BIT 0x00080000
73 #define FR_SDLC_BIT 0x00000002
74
75
76 struct tok fr_header_flag_values[] = {
77 { FR_CR_BIT, "C!" },
78 { FR_DE_BIT, "DE" },
79 { FR_BECN_BIT, "BECN" },
80 { FR_FECN_BIT, "FECN" },
81 { FR_SDLC_BIT, "sdlcore" },
82 { 0, NULL }
83 };
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
84
84fcf28 -share some code between the FRF.15 and FRF.16 printer
hannes authored
85 /* FRF.15 / FRF.16 */
86 #define MFR_B_BIT 0x80
87 #define MFR_E_BIT 0x40
88 #define MFR_C_BIT 0x20
89 #define MFR_BEC_MASK (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
90 #define MFR_CTRL_FRAME (MFR_B_BIT | MFR_E_BIT | MFR_C_BIT)
91 #define MFR_FRAG_FRAME (MFR_B_BIT | MFR_E_BIT )
92
93 struct tok frf_flag_values[] = {
94 { MFR_B_BIT, "Begin" },
95 { MFR_E_BIT, "End" },
96 { MFR_C_BIT, "Control" },
97 { 0, NULL }
98 };
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
99
b17c37f -add frame-relay header documentation
hannes authored
100 /* Finds out Q.922 address length, DLCI and flags. Returns 0 on success
101 * save the flags dep. on address length
102 */
aebfcfe rework the ARP printer & add support for Frame-Relay ARP
hannes authored
103 static int parse_q922_addr(const u_char *p, u_int *dlci,
b17c37f -add frame-relay header documentation
hannes authored
104 u_int *addr_len, u_int8_t *flags)
105 {
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
106 if ((p[0] & FR_EA_BIT))
107 return -1;
108
109 *addr_len = 2;
110 *dlci = ((p[0] & 0xFC) << 2) | ((p[1] & 0xF0) >> 4);
111
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
112 flags[0] = p[0] & 0x02; /* populate the first flag fields */
b17c37f -add frame-relay header documentation
hannes authored
113 flags[1] = p[1] & 0x0c;
e06503a @yuguy Clear out the flags field when parsing the Frame Relay header, rather
yuguy authored
114 flags[2] = 0; /* clear the rest of the flags */
115 flags[3] = 0;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
116
117 if (p[1] & FR_EA_BIT)
118 return 0; /* 2-byte Q.922 address */
119
120 p += 2;
121 (*addr_len)++; /* 3- or 4-byte Q.922 address */
122 if ((p[0] & FR_EA_BIT) == 0) {
123 *dlci = (*dlci << 7) | (p[0] >> 1);
124 (*addr_len)++; /* 4-byte Q.922 address */
125 p++;
126 }
127
128 if ((p[0] & FR_EA_BIT) == 0)
129 return -1; /* more than 4 bytes of Q.922 address? */
130
b17c37f -add frame-relay header documentation
hannes authored
131 flags[3] = p[0] & 0x02;
132
aebfcfe rework the ARP printer & add support for Frame-Relay ARP
hannes authored
133 *dlci = (*dlci << 6) | (p[0] >> 2);
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
134
135 return 0;
136 }
137
aebfcfe rework the ARP printer & add support for Frame-Relay ARP
hannes authored
138 char *q922_string(const u_char *p) {
139
140 static u_int dlci, addr_len;
141 static u_int8_t flags[4];
142 static char buffer[sizeof("DLCI xxxxxxxxxx")];
143 memset(buffer, 0, sizeof(buffer));
144
145 if (parse_q922_addr(p, &dlci, &addr_len, flags) == 0){
146 snprintf(buffer, sizeof(buffer), "DLCI %u", dlci);
147 }
148
149 return buffer;
150 }
151
152
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
153 /* Frame Relay packet structure, with flags and CRC removed
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
154
155 +---------------------------+
156 | Q.922 Address* |
157 +-- --+
158 | |
159 +---------------------------+
160 | Control (UI = 0x03) |
161 +---------------------------+
162 | Optional Pad (0x00) |
163 +---------------------------+
164 | NLPID |
165 +---------------------------+
166 | . |
167 | . |
168 | . |
169 | Data |
170 | . |
171 | . |
172 +---------------------------+
173
174 * Q.922 addresses, as presently defined, are two octets and
175 contain a 10-bit DLCI. In some networks Q.922 addresses
176 may optionally be increased to three or four octets.
177 */
178
edb0e92 @yuguy Add a few more GCC warnings on GCC >= 2 for ".devel" builds.
yuguy authored
179 static u_int
af9f8b6 split up the frame-relay printer into
hannes authored
180 fr_hdrlen(const u_char *p, u_int addr_len)
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
181 {
af9f8b6 split up the frame-relay printer into
hannes authored
182 if (!p[addr_len + 1] /* pad exist */)
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
183 return addr_len + 1 /* UI */ + 1 /* pad */ + 1 /* NLPID */;
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
184 else
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
185 return addr_len + 1 /* UI */ + 1 /* NLPID */;
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
186 }
187
188 static void
b17c37f -add frame-relay header documentation
hannes authored
189 fr_hdr_print(int length, u_int addr_len, u_int dlci, u_int8_t *flags, u_int16_t nlpid)
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
190 {
b17c37f -add frame-relay header documentation
hannes authored
191 if (qflag) {
192 (void)printf("Q.922, DLCI %u, length %u: ",
193 dlci,
194 length);
195 } else {
196 if (nlpid <= 0xff) /* if its smaller than 256 then its a NLPID */
197 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], NLPID %s (0x%02x), length %u: ",
198 addr_len,
199 dlci,
200 bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
201 tok2str(nlpid_values,"unknown", nlpid),
202 nlpid,
203 length);
204 else /* must be an ethertype */
205 (void)printf("Q.922, hdr-len %u, DLCI %u, Flags [%s], cisco-ethertype %s (0x%04x), length %u: ",
206 addr_len,
207 dlci,
208 bittok2str(fr_header_flag_values, "none", EXTRACT_32BITS(flags)),
209 tok2str(ethertype_values, "unknown", nlpid),
210 nlpid,
211 length);
212 }
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
213 }
214
4bec97f @yuguy Hoist a bunch of stuff that should be done by all if_print routines into
yuguy authored
215 u_int
216 fr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
217 {
218 register u_int length = h->len;
219 register u_int caplen = h->caplen;
af9f8b6 split up the frame-relay printer into
hannes authored
220
221 TCHECK2(*p, 4); /* minimum frame header length */
222
223 if ((length = fr_print(p, length)) == 0)
224 return (0);
225 else
226 return length;
227 trunc:
228 printf("[|fr]");
229 return caplen;
230 }
231
232 u_int
233 fr_print(register const u_char *p, u_int length)
234 {
b17c37f -add frame-relay header documentation
hannes authored
235 u_int16_t extracted_ethertype;
e693f83 @yuguy Make the "dlci" variable a u_int, as all the code that refers to it
yuguy authored
236 u_int dlci;
9bfb523 @yuguy Make the "addr_len" variable a "u_int", as we pass a pointer to it to a
yuguy authored
237 u_int addr_len;
b17c37f -add frame-relay header documentation
hannes authored
238 u_int16_t nlpid;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
239 u_int hdr_len;
b17c37f -add frame-relay header documentation
hannes authored
240 u_int8_t flags[4];
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
241
aebfcfe rework the ARP printer & add support for Frame-Relay ARP
hannes authored
242 if (parse_q922_addr(p, &dlci, &addr_len, flags)) {
b17c37f -add frame-relay header documentation
hannes authored
243 printf("Q.922, invalid address");
af9f8b6 split up the frame-relay printer into
hannes authored
244 return 0;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
245 }
246
af9f8b6 split up the frame-relay printer into
hannes authored
247 TCHECK2(*p,addr_len+1+1);
248 hdr_len = fr_hdrlen(p, addr_len);
249 TCHECK2(*p,hdr_len);
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
250
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
251 if (p[addr_len] != 0x03 && dlci != 0) {
de7827f add support for cisco-style ethertype encaps within frame-relay
hannes authored
252
253 /* lets figure out if we have cisco style encapsulation: */
254 extracted_ethertype = EXTRACT_16BITS(p+addr_len);
255
256 if (eflag)
b17c37f -add frame-relay header documentation
hannes authored
257 fr_hdr_print(length, addr_len, dlci, flags, extracted_ethertype);
de7827f add support for cisco-style ethertype encaps within frame-relay
hannes authored
258
1cead82 @mcr reworked print-ether to use netdissect
authored
259 if (ethertype_print(gndo, extracted_ethertype,
de7827f add support for cisco-style ethertype encaps within frame-relay
hannes authored
260 p+addr_len+ETHERTYPE_LEN,
b17c37f -add frame-relay header documentation
hannes authored
261 length-addr_len-ETHERTYPE_LEN,
ea5736c @guyharris Process VLAN frames and Alteon jumbo frames in the Ethernet printer.
guyharris authored
262 length-addr_len-ETHERTYPE_LEN) == 0)
de7827f add support for cisco-style ethertype encaps within frame-relay
hannes authored
263 /* ether_type not known, probably it wasn't one */
264 printf("UI %02x! ", p[addr_len]);
265 else
b17c37f -add frame-relay header documentation
hannes authored
266 return hdr_len;
de7827f add support for cisco-style ethertype encaps within frame-relay
hannes authored
267 }
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
268
269 if (!p[addr_len + 1]) { /* pad byte should be used with 3-byte Q.922 */
270 if (addr_len != 3)
271 printf("Pad! ");
272 } else if (addr_len == 3)
273 printf("No pad! ");
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
274
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
275 nlpid = p[hdr_len - 1];
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
276
b17c37f -add frame-relay header documentation
hannes authored
277 if (eflag)
278 fr_hdr_print(length, addr_len, dlci, flags, nlpid);
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
279 p += hdr_len;
280 length -= hdr_len;
281
282 switch (nlpid) {
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
283 case NLPID_IP:
4189fb7 refactored ip_print() so that chained header parser (ESP/AH) can
mcr authored
284 ip_print(gndo, p, length);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
285 break;
286
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
287 #ifdef INET6
4d399db -move the nlpid definitions and tokens to a dedicated file(s)
hannes authored
288 case NLPID_IP6:
a91d20c @guyharris Convert the IPv6 printer to use netdissect.
guyharris authored
289 ip6_print(gndo, p, length);
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
290 break;
291 #endif
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
292 case NLPID_CLNP:
293 case NLPID_ESIS:
294 case NLPID_ISIS:
af9f8b6 split up the frame-relay printer into
hannes authored
295 isoclns_print(p-1, length+1, length+1); /* OSI printers need the NLPID field */
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
296 break;
297
298 case NLPID_SNAP:
ea5736c @guyharris Process VLAN frames and Alteon jumbo frames in the Ethernet printer.
guyharris authored
299 if (snap_print(p, length, length, 0) == 0) {
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
300 /* ether_type not known, print raw packet */
9c2d2a4 move the SNAP OUI values out of the llc printer into
hannes authored
301 if (!eflag)
b17c37f -add frame-relay header documentation
hannes authored
302 fr_hdr_print(length + hdr_len, hdr_len,
9c2d2a4 move the SNAP OUI values out of the llc printer into
hannes authored
303 dlci, flags, nlpid);
d953299 @yuguy Add a flag to suppress the "default_print()" call made in various
yuguy authored
304 if (!suppress_default_print)
af9f8b6 split up the frame-relay printer into
hannes authored
305 default_print(p - hdr_len, length + hdr_len);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
306 }
307 break;
308
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
309 case NLPID_Q933:
310 q933_print(p, length);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
311 break;
312
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
313 case NLPID_MFR:
314 frf15_print(p, length);
315 break;
316
5aa9c17 add support for PPP over Frame-Relay
hannes authored
317 case NLPID_PPP:
318 ppp_print(p, length);
319 break;
320
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
321 default:
322 if (!eflag)
b17c37f -add frame-relay header documentation
hannes authored
323 fr_hdr_print(length + hdr_len, addr_len,
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
324 dlci, flags, nlpid);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
325 if (!xflag)
af9f8b6 split up the frame-relay printer into
hannes authored
326 default_print(p, length);
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
327 }
328
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
329 return hdr_len;
af9f8b6 split up the frame-relay printer into
hannes authored
330
331 trunc:
332 printf("[|fr]");
333 return 0;
334
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
335 }
336
997e4c6 add support for FRF.16 Multilink Frame-Relay (DLT_MFR)
hannes authored
337 u_int
338 mfr_if_print(const struct pcap_pkthdr *h, register const u_char *p)
339 {
340 register u_int length = h->len;
341 register u_int caplen = h->caplen;
342
343 TCHECK2(*p, 2); /* minimum frame header length */
344
345 if ((length = mfr_print(p, length)) == 0)
346 return (0);
347 else
348 return length;
349 trunc:
350 printf("[|mfr]");
351 return caplen;
352 }
353
354
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
355 #define MFR_CTRL_MSG_ADD_LINK 1
356 #define MFR_CTRL_MSG_ADD_LINK_ACK 2
357 #define MFR_CTRL_MSG_ADD_LINK_REJ 3
358 #define MFR_CTRL_MSG_HELLO 4
359 #define MFR_CTRL_MSG_HELLO_ACK 5
360 #define MFR_CTRL_MSG_REMOVE_LINK 6
361 #define MFR_CTRL_MSG_REMOVE_LINK_ACK 7
362
363 struct tok mfr_ctrl_msg_values[] = {
364 { MFR_CTRL_MSG_ADD_LINK, "Add Link" },
365 { MFR_CTRL_MSG_ADD_LINK_ACK, "Add Link ACK" },
366 { MFR_CTRL_MSG_ADD_LINK_REJ, "Add Link Reject" },
367 { MFR_CTRL_MSG_HELLO, "Hello" },
368 { MFR_CTRL_MSG_HELLO_ACK, "Hello ACK" },
369 { MFR_CTRL_MSG_REMOVE_LINK, "Remove Link" },
370 { MFR_CTRL_MSG_REMOVE_LINK_ACK, "Remove Link ACK" },
371 { 0, NULL }
372 };
373
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
374 #define MFR_CTRL_IE_BUNDLE_ID 1
375 #define MFR_CTRL_IE_LINK_ID 2
376 #define MFR_CTRL_IE_MAGIC_NUM 3
377 #define MFR_CTRL_IE_TIMESTAMP 5
378 #define MFR_CTRL_IE_VENDOR_EXT 6
379 #define MFR_CTRL_IE_CAUSE 7
380
381 struct tok mfr_ctrl_ie_values[] = {
b4eb98e fix 'Bundle ID' typo
hannes authored
382 { MFR_CTRL_IE_BUNDLE_ID, "Bundle ID"},
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
383 { MFR_CTRL_IE_LINK_ID, "Link ID"},
384 { MFR_CTRL_IE_MAGIC_NUM, "Magic Number"},
385 { MFR_CTRL_IE_TIMESTAMP, "Timestamp"},
386 { MFR_CTRL_IE_VENDOR_EXT, "Vendor Extension"},
387 { MFR_CTRL_IE_CAUSE, "Cause"},
388 { 0, NULL }
389 };
390
391 #define MFR_ID_STRING_MAXLEN 50
392
393 struct ie_tlv_header_t {
394 u_int8_t ie_type;
395 u_int8_t ie_len;
396 };
397
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
398 u_int
399 mfr_print(register const u_char *p, u_int length)
400 {
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
401 u_int tlen,idx,hdr_len = 0;
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
402 u_int16_t sequence_num;
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
403 u_int8_t ie_type,ie_len;
4fe64c9 @yuguy Pointers into packet data should usually be pointers to unsigned 1-byte
yuguy authored
404 const u_int8_t *tptr;
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
405
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
406
407 /*
408 * FRF.16 Link Integrity Control Frame
409 *
410 * 7 6 5 4 3 2 1 0
411 * +----+----+----+----+----+----+----+----+
412 * | B | E | C=1| 0 0 0 0 | EA |
413 * +----+----+----+----+----+----+----+----+
414 * | 0 0 0 0 0 0 0 0 |
415 * +----+----+----+----+----+----+----+----+
416 * | message type |
417 * +----+----+----+----+----+----+----+----+
418 */
419
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
420 TCHECK2(*p, 4); /* minimum frame header length */
421
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
422 if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
84fcf28 -share some code between the FRF.15 and FRF.16 printer
hannes authored
423 printf("FRF.16 Control, Flags [%s], %s, length %u",
424 bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)),
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
425 tok2str(mfr_ctrl_msg_values,"Unknown Message (0x%02x)",p[2]),
426 length);
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
427 tptr = p + 3;
428 tlen = length -3;
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
429 hdr_len = 3;
430
431 if (!vflag)
432 return hdr_len;
433
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
434 while (tlen>sizeof(struct ie_tlv_header_t)) {
435 TCHECK2(*tptr, sizeof(struct ie_tlv_header_t));
436 ie_type=tptr[0];
437 ie_len=tptr[1];
438
439 printf("\n\tIE %s (%u), length %u: ",
440 tok2str(mfr_ctrl_ie_values,"Unknown",ie_type),
441 ie_type,
442 ie_len);
443
444 /* infinite loop check */
445 if (ie_type == 0 || ie_len <= sizeof(struct ie_tlv_header_t))
446 return hdr_len;
447
448 TCHECK2(*tptr,ie_len);
449 tptr+=sizeof(struct ie_tlv_header_t);
450 /* tlv len includes header */
451 ie_len-=sizeof(struct ie_tlv_header_t);
452 tlen-=sizeof(struct ie_tlv_header_t);
453
454 switch (ie_type) {
455
456 case MFR_CTRL_IE_MAGIC_NUM:
457 printf("0x%08x",EXTRACT_32BITS(tptr));
458 break;
459
460 case MFR_CTRL_IE_BUNDLE_ID: /* same message format */
461 case MFR_CTRL_IE_LINK_ID:
224bdf9 don't print the null-termination byte in FRF.16 link/bundle msgs
hannes authored
462 for (idx = 0; idx < ie_len && idx < MFR_ID_STRING_MAXLEN; idx++) {
463 if (*(tptr+idx) != 0) /* don't print null termination */
464 safeputchar(*(tptr+idx));
465 else
466 break;
467 }
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
468 break;
469
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
470 case MFR_CTRL_IE_TIMESTAMP:
471 if (ie_len == sizeof(struct timeval)) {
472 ts_print((const struct timeval *)tptr);
473 break;
474 }
475 /* fall through and hexdump if no unix timestamp */
476
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
477 /*
478 * FIXME those are the defined IEs that lack a decoder
479 * you are welcome to contribute code ;-)
480 */
481
482 case MFR_CTRL_IE_VENDOR_EXT:
483 case MFR_CTRL_IE_CAUSE:
484
485 default:
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
486 if (vflag <= 1)
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
487 print_unknown_data(tptr,"\n\t ",ie_len);
488 break;
489 }
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
490
491 /* do we want to see a hexdump of the IE ? */
492 if (vflag > 1 )
493 print_unknown_data(tptr,"\n\t ",ie_len);
494
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
495 tlen-=ie_len;
496 tptr+=ie_len;
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
497 }
498 return hdr_len;
499 }
500 /*
501 * FRF.16 Fragmentation Frame
502 *
503 * 7 6 5 4 3 2 1 0
504 * +----+----+----+----+----+----+----+----+
505 * | B | E | C=0|seq. (high 4 bits) | EA |
506 * +----+----+----+----+----+----+----+----+
507 * | sequence (low 8 bits) |
508 * +----+----+----+----+----+----+----+----+
509 * | DLCI (6 bits) | CR | EA |
510 * +----+----+----+----+----+----+----+----+
511 * | DLCI (4 bits) |FECN|BECN| DE | EA |
512 * +----+----+----+----+----+----+----+----+
513 */
514
646a88f hexdump MFR middle or last fragments
hannes authored
515 sequence_num = (p[0]&0x1e)<<7 | p[1];
516 /* whole packet or first fragment ? */
517 if ((p[0] & MFR_BEC_MASK) == MFR_FRAG_FRAME ||
e2d1667 @yuguy Fix a test (as per a compiler warning).
yuguy authored
518 (p[0] & MFR_BEC_MASK) == MFR_B_BIT) {
646a88f hexdump MFR middle or last fragments
hannes authored
519 printf("FRF.16 Frag, seq %u, Flags [%s], ",
520 sequence_num,
521 bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
522 hdr_len = 2;
523 fr_print(p+hdr_len,length-hdr_len);
646a88f hexdump MFR middle or last fragments
hannes authored
524 return hdr_len;
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
525 }
526
646a88f hexdump MFR middle or last fragments
hannes authored
527 /* must be a middle or the last fragment */
528 printf("FRF.16 Frag, seq %u, Flags [%s]",
529 sequence_num,
530 bittok2str(frf_flag_values,"none",(p[0] & MFR_BEC_MASK)));
531 print_unknown_data(p,"\n\t",length);
532
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
533 return hdr_len;
751cd0a add support for MFR FRF.16 IE Message printing, add boundary checks
hannes authored
534
535 trunc:
536 printf("[|mfr]");
537 return length;
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
538 }
539
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
540 /* an NLPID of 0xb1 indicates a 2-byte
541 * FRF.15 header
542 *
543 * 7 6 5 4 3 2 1 0
544 * +----+----+----+----+----+----+----+----+
545 * ~ Q.922 header ~
546 * +----+----+----+----+----+----+----+----+
547 * | NLPID (8 bits) | NLPID=0xb1
548 * +----+----+----+----+----+----+----+----+
549 * | B | E | C |seq. (high 4 bits) | R |
550 * +----+----+----+----+----+----+----+----+
551 * | sequence (low 8 bits) |
552 * +----+----+----+----+----+----+----+----+
553 */
554
555 #define FR_FRF15_FRAGTYPE 0x01
556
557 static void
558 frf15_print (const u_char *p, u_int length) {
559
560 u_int16_t sequence_num, flags;
561
84fcf28 -share some code between the FRF.15 and FRF.16 printer
hannes authored
562 flags = p[0]&MFR_BEC_MASK;
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
563 sequence_num = (p[0]&0x1e)<<7 | p[1];
564
565 printf("FRF.15, seq 0x%03x, Flags [%s],%s Fragmentation, length %u",
566 sequence_num,
84fcf28 -share some code between the FRF.15 and FRF.16 printer
hannes authored
567 bittok2str(frf_flag_values,"none",flags),
568 p[0]&FR_FRF15_FRAGTYPE ? "Interface" : "End-to-End",
ecdfb8a add baseline FRF.15 (=fragmentation) support for frame-relay
hannes authored
569 length);
570
571 /* TODO:
572 * depending on all permutations of the B, E and C bit
573 * dig as deep as we can - e.g. on the first (B) fragment
574 * there is enough payload to print the IP header
575 * on non (B) fragments it depends if the fragmentation
576 * model is end-to-end or interface based wether we want to print
577 * another Q.922 header
578 */
579
580 }
581
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
582 /*
583 * Q.933 decoding portion for framerelay specific.
584 */
585
586 /* Q.933 packet format
587 Format of Other Protocols
588 using Q.933 NLPID
589 +-------------------------------+
590 | Q.922 Address |
591 +---------------+---------------+
592 |Control 0x03 | NLPID 0x08 |
593 +---------------+---------------+
594 | L2 Protocol ID |
595 | octet 1 | octet 2 |
596 +-------------------------------+
597 | L3 Protocol ID |
598 | octet 2 | octet 2 |
599 +-------------------------------+
600 | Protocol Data |
601 +-------------------------------+
602 | FCS |
603 +-------------------------------+
604 */
605
606 /* L2 (Octet 1)- Call Reference Usually is 0x0 */
607
608 /*
609 * L2 (Octet 2)- Message Types definition 1 byte long.
610 */
611 /* Call Establish */
612 #define MSG_TYPE_ESC_TO_NATIONAL 0x00
613 #define MSG_TYPE_ALERT 0x01
614 #define MSG_TYPE_CALL_PROCEEDING 0x02
615 #define MSG_TYPE_CONNECT 0x07
616 #define MSG_TYPE_CONNECT_ACK 0x0F
617 #define MSG_TYPE_PROGRESS 0x03
618 #define MSG_TYPE_SETUP 0x05
619 /* Call Clear */
620 #define MSG_TYPE_DISCONNECT 0x45
621 #define MSG_TYPE_RELEASE 0x4D
622 #define MSG_TYPE_RELEASE_COMPLETE 0x5A
623 #define MSG_TYPE_RESTART 0x46
624 #define MSG_TYPE_RESTART_ACK 0x4E
625 /* Status */
626 #define MSG_TYPE_STATUS 0x7D
627 #define MSG_TYPE_STATUS_ENQ 0x75
628
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
629 struct tok fr_q933_msg_values[] = {
b17c37f -add frame-relay header documentation
hannes authored
630 { MSG_TYPE_ESC_TO_NATIONAL, "ESC to National" },
631 { MSG_TYPE_ALERT, "Alert" },
632 { MSG_TYPE_CALL_PROCEEDING, "Call proceeding" },
633 { MSG_TYPE_CONNECT, "Connect" },
634 { MSG_TYPE_CONNECT_ACK, "Connect ACK" },
635 { MSG_TYPE_PROGRESS, "Progress" },
636 { MSG_TYPE_SETUP, "Setup" },
637 { MSG_TYPE_DISCONNECT, "Disconnect" },
638 { MSG_TYPE_RELEASE, "Release" },
639 { MSG_TYPE_RELEASE_COMPLETE, "Release Complete" },
640 { MSG_TYPE_RESTART, "Restart" },
641 { MSG_TYPE_RESTART_ACK, "Restart ACK" },
642 { MSG_TYPE_STATUS, "Status Reply" },
643 { MSG_TYPE_STATUS_ENQ, "Status Enquiry" },
644 { 0, NULL }
645 };
646
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
647 #define MSG_ANSI_LOCKING_SHIFT 0x95
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
648
b17c37f -add frame-relay header documentation
hannes authored
649 #define FR_LMI_ANSI_REPORT_TYPE_IE 0x01
650 #define FR_LMI_ANSI_LINK_VERIFY_IE_91 0x19 /* details? */
651 #define FR_LMI_ANSI_LINK_VERIFY_IE 0x03
652 #define FR_LMI_ANSI_PVC_STATUS_IE 0x07
653
654 #define FR_LMI_CCITT_REPORT_TYPE_IE 0x51
655 #define FR_LMI_CCITT_LINK_VERIFY_IE 0x53
656 #define FR_LMI_CCITT_PVC_STATUS_IE 0x57
657
b9bc936 -add basic support for codeset shifting for IE printing in the frame-…
hannes authored
658 struct tok fr_q933_ie_values_codeset5[] = {
b17c37f -add frame-relay header documentation
hannes authored
659 { FR_LMI_ANSI_REPORT_TYPE_IE, "ANSI Report Type" },
660 { FR_LMI_ANSI_LINK_VERIFY_IE_91, "ANSI Link Verify" },
661 { FR_LMI_ANSI_LINK_VERIFY_IE, "ANSI Link Verify" },
662 { FR_LMI_ANSI_PVC_STATUS_IE, "ANSI PVC Status" },
663 { FR_LMI_CCITT_REPORT_TYPE_IE, "CCITT Report Type" },
664 { FR_LMI_CCITT_LINK_VERIFY_IE, "CCITT Link Verify" },
665 { FR_LMI_CCITT_PVC_STATUS_IE, "CCITT PVC Status" },
666 { 0, NULL }
667 };
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
668
b17c37f -add frame-relay header documentation
hannes authored
669 #define FR_LMI_REPORT_TYPE_IE_FULL_STATUS 0
670 #define FR_LMI_REPORT_TYPE_IE_LINK_VERIFY 1
671 #define FR_LMI_REPORT_TYPE_IE_ASYNC_PVC 2
672
673 struct tok fr_lmi_report_type_ie_values[] = {
674 { FR_LMI_REPORT_TYPE_IE_FULL_STATUS, "Full Status" },
675 { FR_LMI_REPORT_TYPE_IE_LINK_VERIFY, "Link verify" },
676 { FR_LMI_REPORT_TYPE_IE_ASYNC_PVC, "Async PVC Status" },
677 { 0, NULL }
678 };
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
679
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
680 /* array of 16 codepages - currently we only support codepage 1,5 */
b9bc936 -add basic support for codeset shifting for IE printing in the frame-…
hannes authored
681 static struct tok *fr_q933_ie_codesets[] = {
682 NULL,
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
683 fr_q933_ie_values_codeset5,
b9bc936 -add basic support for codeset shifting for IE printing in the frame-…
hannes authored
684 NULL,
685 NULL,
686 NULL,
687 fr_q933_ie_values_codeset5,
688 NULL,
689 NULL,
690 NULL,
691 NULL,
692 NULL,
693 NULL,
694 NULL,
695 NULL,
696 NULL,
697 NULL
698 };
699
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
700 static int fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p,
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
701 const u_char *p);
702
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
703 typedef int (*codeset_pr_func_t)(const struct ie_tlv_header_t *ie_p,
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
704 const u_char *p);
705
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
706 /* array of 16 codepages - currently we only support codepage 1,5 */
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
707 static codeset_pr_func_t fr_q933_print_ie_codeset[] = {
708 NULL,
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
709 fr_q933_print_ie_codeset5,
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
710 NULL,
711 NULL,
712 NULL,
713 fr_q933_print_ie_codeset5,
714 NULL,
715 NULL,
716 NULL,
717 NULL,
718 NULL,
719 NULL,
720 NULL,
721 NULL,
722 NULL,
723 NULL
724 };
725
efd5520 -export the q933 printer and call it from the OSI printer
hannes authored
726 void
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
727 q933_print(const u_char *p, u_int length)
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
728 {
729 const u_char *ptemp = p;
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
730 struct ie_tlv_header_t *ie_p;
b17c37f -add frame-relay header documentation
hannes authored
731 int olen;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
732 int is_ansi = 0;
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
733 u_int codeset;
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
734 u_int ie_is_known = 0;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
735
736 if (length < 9) { /* shortest: Q.933a LINK VERIFY */
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
737 printf("[|q.933]");
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
738 return;
739 }
740
b9bc936 -add basic support for codeset shifting for IE printing in the frame-…
hannes authored
741 codeset = p[2]&0x0f; /* extract the codeset */
742
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
743 if (p[2] == MSG_ANSI_LOCKING_SHIFT) {
744 is_ansi = 1;
745 }
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
746
efd5520 -export the q933 printer and call it from the OSI printer
hannes authored
747 printf("%s", eflag ? "" : "Q.933, ");
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
748
b17c37f -add frame-relay header documentation
hannes authored
749 /* printing out header part */
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
750 printf("%s, codeset %u", is_ansi ? "ANSI" : "CCITT", codeset);
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
751
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
752 if (p[0]) {
753 printf(", Call Ref: 0x%02x", p[0]);
754 }
755 if (vflag) {
756 printf(", %s (0x%02x), length %u",
757 tok2str(fr_q933_msg_values,
758 "unknown message", p[1]),
759 p[1],
760 length);
761 } else {
762 printf(", %s",
763 tok2str(fr_q933_msg_values,
764 "unknown message 0x%02x", p[1]));
765 }
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
766
b17c37f -add frame-relay header documentation
hannes authored
767 olen = length; /* preserve the original length for non verbose mode */
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
768
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
769 if (length < (u_int)(2 - is_ansi)) {
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
770 printf("[|q.933]");
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
771 return;
772 }
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
773 length -= 2 + is_ansi;
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
774 ptemp += 2 + is_ansi;
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
775
776 /* Loop through the rest of IE */
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
777 while (length > sizeof(struct ie_tlv_header_t)) {
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
778 ie_p = (struct ie_tlv_header_t *)ptemp;
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
779 if (length < sizeof(struct ie_tlv_header_t) ||
780 length < sizeof(struct ie_tlv_header_t) + ie_p->ie_len) {
781 if (vflag) { /* not bark if there is just a trailer */
cf96293 clean up some confusion between Q.933 and LMI:
hannes authored
782 printf("\n[|q.933]");
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
783 } else {
b17c37f -add frame-relay header documentation
hannes authored
784 printf(", length %u",olen);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
785 }
b17c37f -add frame-relay header documentation
hannes authored
786 return;
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
787 }
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
788
b17c37f -add frame-relay header documentation
hannes authored
789 /* lets do the full IE parsing only in verbose mode
790 * however some IEs (DLCI Status, Link Verify)
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
791 * are also interestting in non-verbose mode */
792 if (vflag) {
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
793 printf("\n\t%s IE (0x%02x), length %u: ",
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
794 tok2str(fr_q933_ie_codesets[codeset],
795 "unknown", ie_p->ie_type),
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
796 ie_p->ie_type,
b17c37f -add frame-relay header documentation
hannes authored
797 ie_p->ie_len);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
798 }
799
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
800 /* sanity check */
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
801 if (ie_p->ie_type == 0 || ie_p->ie_len == 0) {
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
802 return;
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
803 }
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
804
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
805 if (fr_q933_print_ie_codeset[codeset] != NULL) {
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
806 ie_is_known = fr_q933_print_ie_codeset[codeset](ie_p, ptemp);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
807 }
808
809 if (vflag >= 1 && !ie_is_known) {
bf8dae1 add basic support for FRF.16 Frame-Relay dissector, fix garbled outpu…
hannes authored
810 print_unknown_data(ptemp+2,"\n\t",ie_p->ie_len);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
811 }
b17c37f -add frame-relay header documentation
hannes authored
812
813 /* do we want to see a hexdump of the IE ? */
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
814 if (vflag> 1 && ie_is_known) {
b17c37f -add frame-relay header documentation
hannes authored
815 print_unknown_data(ptemp+2,"\n\t ",ie_p->ie_len);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
816 }
dc3034d @yuguy From Krzysztof Halasa <khc@pm.waw.pl>:
yuguy authored
817
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
818 length = length - ie_p->ie_len - 2;
819 ptemp = ptemp + ie_p->ie_len + 2;
820 }
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
821 if (!vflag) {
b17c37f -add frame-relay header documentation
hannes authored
822 printf(", length %u",olen);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
823 }
6d6270c @yuguy From Paul S. Traina: FreeBSD's Frame Relay printer.
yuguy authored
824 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
825
826 static int
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
827 fr_q933_print_ie_codeset5(const struct ie_tlv_header_t *ie_p, const u_char *p)
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
828 {
829 u_int dlci;
830
831c9aa link codeset 1 (lmi messages) to codeset 5, add IE = 0 sanity check, …
hannes authored
831 switch (ie_p->ie_type) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
832
833 case FR_LMI_ANSI_REPORT_TYPE_IE: /* fall through */
834 case FR_LMI_CCITT_REPORT_TYPE_IE:
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
835 if (vflag) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
836 printf("%s (%u)",
837 tok2str(fr_lmi_report_type_ie_values,"unknown",p[2]),
838 p[2]);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
839 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
840 return 1;
841
842 case FR_LMI_ANSI_LINK_VERIFY_IE: /* fall through */
843 case FR_LMI_CCITT_LINK_VERIFY_IE:
844 case FR_LMI_ANSI_LINK_VERIFY_IE_91:
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
845 if (!vflag) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
846 printf(", ");
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
847 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
848 printf("TX Seq: %3d, RX Seq: %3d", p[2], p[3]);
849 return 1;
850
851 case FR_LMI_ANSI_PVC_STATUS_IE: /* fall through */
852 case FR_LMI_CCITT_PVC_STATUS_IE:
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
853 if (!vflag) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
854 printf(", ");
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
855 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
856 /* now parse the DLCI information element. */
857 if ((ie_p->ie_len < 3) ||
858 (p[2] & 0x80) ||
859 ((ie_p->ie_len == 3) && !(p[3] & 0x80)) ||
860 ((ie_p->ie_len == 4) && ((p[3] & 0x80) || !(p[4] & 0x80))) ||
861 ((ie_p->ie_len == 5) && ((p[3] & 0x80) || (p[4] & 0x80) ||
862 !(p[5] & 0x80))) ||
863 (ie_p->ie_len > 5) ||
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
864 !(p[ie_p->ie_len + 1] & 0x80)) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
865 printf("Invalid DLCI IE");
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
866 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
867
868 dlci = ((p[2] & 0x3F) << 4) | ((p[3] & 0x78) >> 3);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
869 if (ie_p->ie_len == 4) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
870 dlci = (dlci << 6) | ((p[4] & 0x7E) >> 1);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
871 }
872 else if (ie_p->ie_len == 5) {
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
873 dlci = (dlci << 13) | (p[4] & 0x7F) | ((p[5] & 0x7E) >> 1);
072e016 code cosmetics: bracketize the on-liners after if statements, proper …
hannes authored
874 }
4ff4565 @yuguy Base all interpretion of IE contents on the code set.
yuguy authored
875
876 printf("DLCI %u: status %s%s", dlci,
877 p[ie_p->ie_len + 1] & 0x8 ? "New, " : "",
878 p[ie_p->ie_len + 1] & 0x2 ? "Active" : "Inactive");
879 return 1;
880 }
881
882 return 0;
883 }
Something went wrong with that request. Please try again.