Deleted Added
full compact
print-atm.c (172686) print-atm.c (190207)
1/*
2 * Copyright (c) 1994, 1995, 1996, 1997
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

--- 4 unchanged lines hidden (view full) ---

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 *
1/*
2 * Copyright (c) 1994, 1995, 1996, 1997
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

--- 4 unchanged lines hidden (view full) ---

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 * $FreeBSD: head/contrib/tcpdump/print-atm.c 172686 2007-10-16 02:31:48Z mlaier $
21 * $FreeBSD: head/contrib/tcpdump/print-atm.c 190207 2009-03-21 18:30:25Z rpaulo $
22 */
23#ifndef lint
24static const char rcsid[] _U_ =
22 */
23#ifndef lint
24static const char rcsid[] _U_ =
25 "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.38.2.6 2006/01/25 13:27:24 hannes Exp $ (LBL)";
25 "@(#) $Header: /tcpdump/master/tcpdump/print-atm.c,v 1.48.2.1 2007-10-22 19:39:12 guy Exp $ (LBL)";
26#endif
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <tcpdump-stdinc.h>
33

--- 6 unchanged lines hidden (view full) ---

40#include "addrtoname.h"
41#include "ethertype.h"
42#include "atm.h"
43#include "atmuni31.h"
44#include "llc.h"
45
46#include "ether.h"
47
26#endif
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include <tcpdump-stdinc.h>
33

--- 6 unchanged lines hidden (view full) ---

40#include "addrtoname.h"
41#include "ethertype.h"
42#include "atm.h"
43#include "atmuni31.h"
44#include "llc.h"
45
46#include "ether.h"
47
48#define OAM_CRC10_MASK 0x3ff
49#define OAM_PAYLOAD_LEN 48
50#define OAM_FUNCTION_SPECIFIC_LEN 45 /* this excludes crc10 and cell-type/function-type */
51#define OAM_CELLTYPE_FUNCTYPE_LEN 1
52
48struct tok oam_f_values[] = {
53struct tok oam_f_values[] = {
49 { OAMF4SC, "OAM F4 (segment)" },
50 { OAMF4EC, "OAM F4 (end)" },
54 { VCI_OAMF4SC, "OAM F4 (segment)" },
55 { VCI_OAMF4EC, "OAM F4 (end)" },
51 { 0, NULL }
52};
53
56 { 0, NULL }
57};
58
59struct tok atm_pty_values[] = {
60 { 0x0, "user data, uncongested, SDU 0" },
61 { 0x1, "user data, uncongested, SDU 1" },
62 { 0x2, "user data, congested, SDU 0" },
63 { 0x3, "user data, congested, SDU 1" },
64 { 0x4, "VCC OAM F5 flow segment" },
65 { 0x5, "VCC OAM F5 flow end-to-end" },
66 { 0x6, "Traffic Control and resource Mgmt" },
67 { 0, NULL }
68};
69
70#define OAM_CELLTYPE_FM 0x1
71#define OAM_CELLTYPE_PM 0x2
72#define OAM_CELLTYPE_AD 0x8
73#define OAM_CELLTYPE_SM 0xf
74
54struct tok oam_celltype_values[] = {
75struct tok oam_celltype_values[] = {
55 { 0x1, "Fault Management" },
56 { 0x2, "Performance Management" },
57 { 0x8, "activate/deactivate" },
58 { 0xf, "System Management" },
76 { OAM_CELLTYPE_FM, "Fault Management" },
77 { OAM_CELLTYPE_PM, "Performance Management" },
78 { OAM_CELLTYPE_AD, "activate/deactivate" },
79 { OAM_CELLTYPE_SM, "System Management" },
59 { 0, NULL }
60};
61
80 { 0, NULL }
81};
82
83#define OAM_FM_FUNCTYPE_AIS 0x0
84#define OAM_FM_FUNCTYPE_RDI 0x1
85#define OAM_FM_FUNCTYPE_CONTCHECK 0x4
86#define OAM_FM_FUNCTYPE_LOOPBACK 0x8
87
62struct tok oam_fm_functype_values[] = {
88struct tok oam_fm_functype_values[] = {
63 { 0x0, "AIS" },
64 { 0x1, "RDI" },
65 { 0x4, "Continuity Check" },
66 { 0x8, "Loopback" },
89 { OAM_FM_FUNCTYPE_AIS, "AIS" },
90 { OAM_FM_FUNCTYPE_RDI, "RDI" },
91 { OAM_FM_FUNCTYPE_CONTCHECK, "Continuity Check" },
92 { OAM_FM_FUNCTYPE_LOOPBACK, "Loopback" },
67 { 0, NULL }
68};
69
70struct tok oam_pm_functype_values[] = {
71 { 0x0, "Forward Monitoring" },
72 { 0x1, "Backward Reporting" },
73 { 0x2, "Monitoring and Reporting" },
74 { 0, NULL }
75};
76
77struct tok oam_ad_functype_values[] = {
78 { 0x0, "Performance Monitoring" },
79 { 0x1, "Continuity Check" },
80 { 0, NULL }
81};
82
93 { 0, NULL }
94};
95
96struct tok oam_pm_functype_values[] = {
97 { 0x0, "Forward Monitoring" },
98 { 0x1, "Backward Reporting" },
99 { 0x2, "Monitoring and Reporting" },
100 { 0, NULL }
101};
102
103struct tok oam_ad_functype_values[] = {
104 { 0x0, "Performance Monitoring" },
105 { 0x1, "Continuity Check" },
106 { 0, NULL }
107};
108
109#define OAM_FM_LOOPBACK_INDICATOR_MASK 0x1
110
111struct tok oam_fm_loopback_indicator_values[] = {
112 { 0x0, "Reply" },
113 { 0x1, "Request" },
114 { 0, NULL }
115};
116
83static const struct tok *oam_functype_values[16] = {
84 NULL,
85 oam_fm_functype_values, /* 1 */
86 oam_pm_functype_values, /* 2 */
87 NULL,
88 NULL,
89 NULL,
90 NULL,

--- 167 unchanged lines hidden (view full) ---

258 u_int caplen)
259{
260 if (eflag)
261 printf("VPI:%u VCI:%u ", vpi, vci);
262
263 if (vpi == 0) {
264 switch (vci) {
265
117static const struct tok *oam_functype_values[16] = {
118 NULL,
119 oam_fm_functype_values, /* 1 */
120 oam_pm_functype_values, /* 2 */
121 NULL,
122 NULL,
123 NULL,
124 NULL,

--- 167 unchanged lines hidden (view full) ---

292 u_int caplen)
293{
294 if (eflag)
295 printf("VPI:%u VCI:%u ", vpi, vci);
296
297 if (vpi == 0) {
298 switch (vci) {
299
266 case PPC:
300 case VCI_PPC:
267 sig_print(p, caplen);
268 return;
269
301 sig_print(p, caplen);
302 return;
303
270 case BCC:
304 case VCI_BCC:
271 printf("broadcast sig: ");
272 return;
273
305 printf("broadcast sig: ");
306 return;
307
274 case OAMF4SC: /* fall through */
275 case OAMF4EC:
308 case VCI_OAMF4SC: /* fall through */
309 case VCI_OAMF4EC:
276 oam_print(p, length, ATM_OAM_HEC);
277 return;
278
310 oam_print(p, length, ATM_OAM_HEC);
311 return;
312
279 case METAC:
313 case VCI_METAC:
280 printf("meta: ");
281 return;
282
314 printf("meta: ");
315 return;
316
283 case ILMIC:
317 case VCI_ILMIC:
284 printf("ilmi: ");
285 snmp_print(p, length);
286 return;
287 }
288 }
289
290 switch (traftype) {
291

--- 6 unchanged lines hidden (view full) ---

298 break;
299
300 case ATM_LANE:
301 lane_print(p, length, caplen);
302 break;
303 }
304}
305
318 printf("ilmi: ");
319 snmp_print(p, length);
320 return;
321 }
322 }
323
324 switch (traftype) {
325

--- 6 unchanged lines hidden (view full) ---

332 break;
333
334 case ATM_LANE:
335 lane_print(p, length, caplen);
336 break;
337 }
338}
339
340struct oam_fm_loopback_t {
341 u_int8_t loopback_indicator;
342 u_int8_t correlation_tag[4];
343 u_int8_t loopback_id[12];
344 u_int8_t source_id[12];
345 u_int8_t unused[16];
346};
347
348struct oam_fm_ais_rdi_t {
349 u_int8_t failure_type;
350 u_int8_t failure_location[16];
351 u_int8_t unused[28];
352};
353
306int
307oam_print (const u_char *p, u_int length, u_int hec) {
308
309 u_int32_t cell_header;
354int
355oam_print (const u_char *p, u_int length, u_int hec) {
356
357 u_int32_t cell_header;
310 u_int16_t cell_type, func_type,vpi,vci,payload,clp;
358 u_int16_t vpi, vci, cksum, cksum_shouldbe, idx;
359 u_int8_t cell_type, func_type, payload, clp;
311
360
361 union {
362 const struct oam_fm_loopback_t *oam_fm_loopback;
363 const struct oam_fm_ais_rdi_t *oam_fm_ais_rdi;
364 } oam_ptr;
365
366
312 cell_header = EXTRACT_32BITS(p+hec);
367 cell_header = EXTRACT_32BITS(p+hec);
313 cell_type = ((*(p+4+hec))>>4) & 0x0f;
314 func_type = *(p+4+hec) & 0x0f;
368 cell_type = ((*(p+ATM_HDR_LEN_NOHEC+hec))>>4) & 0x0f;
369 func_type = (*(p+ATM_HDR_LEN_NOHEC+hec)) & 0x0f;
315
316 vpi = (cell_header>>20)&0xff;
317 vci = (cell_header>>4)&0xffff;
318 payload = (cell_header>>1)&0x7;
319 clp = cell_header&0x1;
320
370
371 vpi = (cell_header>>20)&0xff;
372 vci = (cell_header>>4)&0xffff;
373 payload = (cell_header>>1)&0x7;
374 clp = cell_header&0x1;
375
321 printf("%s, vpi %u, vci %u, payload %u, clp %u, ",
376 printf("%s, vpi %u, vci %u, payload [ %s ], clp %u, length %u",
322 tok2str(oam_f_values, "OAM F5", vci),
377 tok2str(oam_f_values, "OAM F5", vci),
323 vpi, vci, payload, clp);
378 vpi, vci,
379 tok2str(atm_pty_values, "Unknown", payload),
380 clp, length);
324
381
325 printf("cell-type %s (%u)",
382 if (!vflag) {
383 return 1;
384 }
385
386 printf("\n\tcell-type %s (%u)",
326 tok2str(oam_celltype_values, "unknown", cell_type),
327 cell_type);
328
329 if (oam_functype_values[cell_type] == NULL)
330 printf(", func-type unknown (%u)", func_type);
331 else
332 printf(", func-type %s (%u)",
387 tok2str(oam_celltype_values, "unknown", cell_type),
388 cell_type);
389
390 if (oam_functype_values[cell_type] == NULL)
391 printf(", func-type unknown (%u)", func_type);
392 else
393 printf(", func-type %s (%u)",
333 bittok2str(oam_functype_values[cell_type],"none",func_type),
394 tok2str(oam_functype_values[cell_type],"none",func_type),
334 func_type);
335
395 func_type);
396
336 printf(", length %u",length);
397 p += ATM_HDR_LEN_NOHEC + hec;
398
399 switch (cell_type << 4 | func_type) {
400 case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_LOOPBACK):
401 oam_ptr.oam_fm_loopback = (const struct oam_fm_loopback_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
402 printf("\n\tLoopback-Indicator %s, Correlation-Tag 0x%08x",
403 tok2str(oam_fm_loopback_indicator_values,
404 "Unknown",
405 oam_ptr.oam_fm_loopback->loopback_indicator & OAM_FM_LOOPBACK_INDICATOR_MASK),
406 EXTRACT_32BITS(&oam_ptr.oam_fm_loopback->correlation_tag));
407 printf("\n\tLocation-ID ");
408 for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->loopback_id); idx++) {
409 if (idx % 2) {
410 printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->loopback_id[idx]));
411 }
412 }
413 printf("\n\tSource-ID ");
414 for (idx = 0; idx < sizeof(oam_ptr.oam_fm_loopback->source_id); idx++) {
415 if (idx % 2) {
416 printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_loopback->source_id[idx]));
417 }
418 }
419 break;
420
421 case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_AIS):
422 case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_RDI):
423 oam_ptr.oam_fm_ais_rdi = (const struct oam_fm_ais_rdi_t *)(p + OAM_CELLTYPE_FUNCTYPE_LEN);
424 printf("\n\tFailure-type 0x%02x", oam_ptr.oam_fm_ais_rdi->failure_type);
425 printf("\n\tLocation-ID ");
426 for (idx = 0; idx < sizeof(oam_ptr.oam_fm_ais_rdi->failure_location); idx++) {
427 if (idx % 2) {
428 printf("%04x ", EXTRACT_16BITS(&oam_ptr.oam_fm_ais_rdi->failure_location[idx]));
429 }
430 }
431 break;
432
433 case (OAM_CELLTYPE_FM << 4 | OAM_FM_FUNCTYPE_CONTCHECK):
434 /* FIXME */
435 break;
436
437 default:
438 break;
439 }
440
441 /* crc10 checksum verification */
442 cksum = EXTRACT_16BITS(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
443 & OAM_CRC10_MASK;
444 cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);
445
446 printf("\n\tcksum 0x%03x (%scorrect)",
447 cksum,
448 cksum_shouldbe == 0 ? "" : "in");
449
337 return 1;
338}
450 return 1;
451}