print-isoclns.c (26183) | print-isoclns.c (32149) |
---|---|
1/* 2 * Copyright (c) 1992, 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 --- 37 unchanged lines hidden (view full) --- 46#include "ethertype.h" 47#include "extract.h" 48 49#define NLPID_CLNS 129 /* 0x81 */ 50#define NLPID_ESIS 130 /* 0x82 */ 51#define NLPID_ISIS 131 /* 0x83 */ 52#define NLPID_NULLNS 0 53 | 1/* 2 * Copyright (c) 1992, 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 --- 37 unchanged lines hidden (view full) --- 46#include "ethertype.h" 47#include "extract.h" 48 49#define NLPID_CLNS 129 /* 0x81 */ 50#define NLPID_ESIS 130 /* 0x82 */ 51#define NLPID_ISIS 131 /* 0x83 */ 52#define NLPID_NULLNS 0 53 |
54 55/* 56 * IS-IS is defined in ISO 10589. Look there for protocol definitions. 57 */ 58 59#define SYSTEM_ID_LEN sizeof(struct ether_addr) 60#define ISIS_VERSION 1 61#define PDU_TYPE_MASK 0x1F 62#define PRIORITY_MASK 0x7F 63 64#define L1_LAN_IIH 15 65#define L2_LAN_IIH 16 66#define PTP_IIH 17 67#define L1_LS_PDU 18 68#define L2_LS_PDU 19 69#define L1_COMPLETE_SEQ_PDU 24 70#define L2_COMPLETE_SEQ_PDU 25 71 72/* 73 * A TLV is a tuple of a type, length and a value and is normally used for 74 * encoding information in all sorts of places. This is an enumeration of 75 * the well known types. 76 */ 77 78#define TLV_AREA_ADDR 1 79#define TLV_IS_REACH 2 80#define TLV_ES_REACH 3 81#define TLV_SUMMARY 5 82#define TLV_ISNEIGH 6 83#define TLV_PADDING 8 84#define TLV_LSP 9 85#define TLV_AUTHENT 10 86#define TLV_IP_REACH 128 87#define TLV_PROTOCOLS 129 88#define TLV_IP_EXTERN 130 89#define TLV_IDRP_INFO 131 90#define TLV_IPADDR 132 91#define TLV_IPAUTH 133 92#define TLV_PTP_ADJ 240 93 94/* 95 * Katz's point to point adjacency TLV uses codes to tell us the state of 96 * the remote adjacency. Enumerate them. 97 */ 98 99#define ISIS_PTP_ADJ_UP 0 100#define ISIS_PTP_ADJ_INIT 1 101#define ISIS_PTP_ADJ_DOWN 2 102 |
|
54static int osi_cksum(const u_char *, int, u_char *); 55static void esis_print(const u_char *, u_int); 56static int isis_print(const u_char *, u_int); 57 | 103static int osi_cksum(const u_char *, int, u_char *); 104static void esis_print(const u_char *, u_int); 105static int isis_print(const u_char *, u_int); 106 |
107 108struct isis_ptp_adjancey_values { 109 u_char id; 110 char *name; 111}; 112 113static struct isis_ptp_adjancey_values isis_ptp_adjancey_values[] = { 114 ISIS_PTP_ADJ_UP, "UP", 115 ISIS_PTP_ADJ_INIT, "INIT", 116 ISIS_PTP_ADJ_DOWN, "DOWN" 117}; 118 119struct isis_common_header { 120 u_char nlpid; 121 u_char fixed_len; 122 u_char version; /* Protocol version? */ 123 u_char id_length; 124 u_char enc_pdu_type; /* 3 MSbs are reserved */ 125 u_char pkt_version; /* Packet format version? */ 126 u_char reserved; 127 u_char enc_max_area; 128}; 129 130struct isis_header { 131 u_char nlpid; 132 u_char fixed_len; 133 u_char version; /* Protocol version? */ 134 u_char id_length; 135 u_char enc_pdu_type; /* 3 MSbs are reserved */ 136 u_char pkt_version; /* Packet format version? */ 137 u_char reserved; 138 u_char enc_max_area; 139 u_char circuit; 140 u_char enc_source_id[SYSTEM_ID_LEN]; 141 u_char enc_holding_time[2]; 142 u_char enc_packet_len[2]; 143 u_char enc_priority; 144 u_char enc_lan_id[SYSTEM_ID_LEN+1]; 145}; 146struct isis_lan_header { 147 u_char circuit; 148 u_char enc_source_id[SYSTEM_ID_LEN]; 149 u_char enc_holding_time[2]; 150 u_char enc_packet_len[2]; 151 u_char enc_priority; 152 u_char enc_lan_id[SYSTEM_ID_LEN+1]; 153}; 154 155struct isis_ptp_header { 156 u_char circuit; 157 u_char enc_source_id[SYSTEM_ID_LEN]; 158 u_char enc_holding_time[2]; 159 u_char enc_packet_len[2]; 160 u_char loc_circuit_id; 161}; 162 163#define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header)) 164#define ISIS_HEADER_SIZE (15+(SYSTEM_ID_LEN<<1)) 165#define ISIS_PTP_HEADER_SIZE (14+SYSTEM_ID_LEN) 166#define L1_LS_PDU_HEADER_SIZE (21+SYSTEM_ID_LEN) 167#define L2_LS_PDU_HEADER_SIZE L1_LS_PDU_HEADER_SIZE 168#define L1_COMPLETE_SEQ_PDU_HEADER_SIZE 33 169#define L2_COMPLETE_SEQ_PDU_HEADER_SIZE L1_COMPLETE_SEQ_PDU_HEADER_SIZE 170 171 172 |
|
58void 59isoclns_print(const u_char *p, u_int length, u_int caplen, 60 const u_char *esrc, const u_char *edst) 61{ | 173void 174isoclns_print(const u_char *p, u_int length, u_int caplen, 175 const u_char *esrc, const u_char *edst) 176{ |
177 u_char pdu_type; 178 struct isis_header *header; 179 180 header = (struct isis_header *)p; 181 pdu_type = header->enc_pdu_type & PDU_TYPE_MASK; 182 |
|
62 if (caplen < 1) { 63 printf("[|iso-clns] "); 64 if (!eflag) 65 printf("%s > %s", 66 etheraddr_string(esrc), 67 etheraddr_string(edst)); 68 return; 69 } --- 14 unchanged lines hidden (view full) --- 84 (void)printf(" %s > %s", 85 etheraddr_string(esrc), 86 etheraddr_string(edst)); 87 esis_print(p, length); 88 return; 89 90 case NLPID_ISIS: 91 printf("iso isis"); | 183 if (caplen < 1) { 184 printf("[|iso-clns] "); 185 if (!eflag) 186 printf("%s > %s", 187 etheraddr_string(esrc), 188 etheraddr_string(edst)); 189 return; 190 } --- 14 unchanged lines hidden (view full) --- 205 (void)printf(" %s > %s", 206 etheraddr_string(esrc), 207 etheraddr_string(edst)); 208 esis_print(p, length); 209 return; 210 211 case NLPID_ISIS: 212 printf("iso isis"); |
92 if (!eflag) 93 (void)printf(" %s > %s", | 213 if (!eflag) { 214 if(pdu_type != PTP_IIH) 215 (void)printf(" %s > %s", |
94 etheraddr_string(esrc), 95 etheraddr_string(edst)); | 216 etheraddr_string(esrc), 217 etheraddr_string(edst)); |
218 } |
|
96 (void)printf(" len=%d ", length); 97 if (!isis_print(p, length)) 98 default_print_unaligned(p, caplen); 99 break; 100 101 case NLPID_NULLNS: 102 printf("iso nullns"); 103 if (!eflag) --- 195 unchanged lines hidden (view full) --- 299 if (((i & 1) == 0) && (i + 1 < length)) { 300 printf("."); 301 } 302 303 } 304} 305 306/* | 219 (void)printf(" len=%d ", length); 220 if (!isis_print(p, length)) 221 default_print_unaligned(p, caplen); 222 break; 223 224 case NLPID_NULLNS: 225 printf("iso nullns"); 226 if (!eflag) --- 195 unchanged lines hidden (view full) --- 422 if (((i & 1) == 0) && (i + 1 < length)) { 423 printf("."); 424 } 425 426 } 427} 428 429/* |
307 * IS-IS is defined in ISO 10589. Look there for protocol definitions. 308 */ 309 310#define SYSTEM_ID_LEN sizeof(struct ether_addr) 311#define ISIS_VERSION 1 312#define PDU_TYPE_MASK 0x1F 313#define PRIORITY_MASK 0x7F 314 315#define L1_LAN_IIH 15 316#define L2_LAN_IIH 16 317#define PTP_IIH 17 318 319#define TLV_AREA_ADDR 1 320#define TLV_ISNEIGH 6 321#define TLV_PADDING 8 322#define TLV_AUTHENT 10 323 324struct isis_header { 325 u_char nlpid; 326 u_char fixed_len; 327 u_char version; /* Protocol version? */ 328 u_char id_length; 329 u_char enc_pdu_type; /* 3 MSbs are reserved */ 330 u_char pkt_version; /* Packet format version? */ 331 u_char reserved; 332 u_char enc_max_area; 333 u_char circuit; 334 u_char enc_source_id[SYSTEM_ID_LEN]; 335 u_char enc_holding_time[2]; 336 u_char enc_packet_len[2]; 337 u_char enc_priority; 338 u_char enc_lan_id[SYSTEM_ID_LEN+1]; 339}; 340 341#define ISIS_HEADER_SIZE (15+(SYSTEM_ID_LEN<<1)) 342 343/* | |
344 * isis_print 345 * Decode IS-IS packets. Return 0 on error. 346 * 347 * So far, this is only smart enough to print IIH's. Someday... 348 */ 349 350static int 351isis_print (const u_char *p, u_int length) 352{ 353 struct isis_header *header; | 430 * isis_print 431 * Decode IS-IS packets. Return 0 on error. 432 * 433 * So far, this is only smart enough to print IIH's. Someday... 434 */ 435 436static int 437isis_print (const u_char *p, u_int length) 438{ 439 struct isis_header *header; |
440 struct isis_ptp_header *header_ptp; |
|
354 u_char pdu_type, max_area, priority, *pptr, type, len, *tptr, tmp, alen; 355 u_short packet_len, holding_time; | 441 u_char pdu_type, max_area, priority, *pptr, type, len, *tptr, tmp, alen; 442 u_short packet_len, holding_time; |
443 int i; |
|
356 | 444 |
357 header = (struct isis_header *)p; | 445 header_ptp = (struct isis_ptp_header *)header = (struct isis_header *)p; |
358 printf("\n\t\t\t"); 359 360 /* 361 * Sanity checking of the header. 362 */ 363 if (header->nlpid != NLPID_ISIS) { 364 printf(" coding error!"); 365 return(0); --- 5 unchanged lines hidden (view full) --- 371 } 372 373 if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) { 374 printf(" system ID length of %d is not supported", 375 header->id_length); 376 return(0); 377 } 378 | 446 printf("\n\t\t\t"); 447 448 /* 449 * Sanity checking of the header. 450 */ 451 if (header->nlpid != NLPID_ISIS) { 452 printf(" coding error!"); 453 return(0); --- 5 unchanged lines hidden (view full) --- 459 } 460 461 if ((header->id_length != SYSTEM_ID_LEN) && (header->id_length != 0)) { 462 printf(" system ID length of %d is not supported", 463 header->id_length); 464 return(0); 465 } 466 |
379 if ((header->fixed_len != ISIS_HEADER_SIZE)) { 380 printf(" bogus fixed header length %d should be %d", 381 header->fixed_len, ISIS_HEADER_SIZE); 382 return(0); | 467 if ((header->fixed_len != ISIS_HEADER_SIZE) && 468 (header->fixed_len != ISIS_PTP_HEADER_SIZE) && 469 (header->fixed_len != L1_LS_PDU_HEADER_SIZE) && 470 (header-> fixed_len != L1_COMPLETE_SEQ_PDU_HEADER_SIZE) ) { 471 printf(" bogus fixed header length", 472 header->fixed_len); 473 return(0); |
383 } 384 385 pdu_type = header->enc_pdu_type & PDU_TYPE_MASK; | 474 } 475 476 pdu_type = header->enc_pdu_type & PDU_TYPE_MASK; |
386 if ((pdu_type != L1_LAN_IIH) && (pdu_type != L2_LAN_IIH)) { | 477 if ((pdu_type != L1_LAN_IIH) && (pdu_type != L2_LAN_IIH) && 478 (pdu_type != PTP_IIH) && 479 (pdu_type != L1_COMPLETE_SEQ_PDU) && 480 (pdu_type != L2_COMPLETE_SEQ_PDU) ) { |
387 printf(" PDU type (%d) not supported", pdu_type); 388 return; 389 } 390 391 if (header->pkt_version != ISIS_VERSION) { 392 printf(" version %d packet not supported", header->pkt_version); 393 return; 394 } --- 38 unchanged lines hidden (view full) --- 433 packet_len = EXTRACT_16BITS(header->enc_packet_len); 434 if ((packet_len < ISIS_HEADER_SIZE) || 435 (packet_len > length)) { 436 printf(" bogus packet length %d, real length %d", packet_len, 437 length); 438 return(0); 439 } 440 | 481 printf(" PDU type (%d) not supported", pdu_type); 482 return; 483 } 484 485 if (header->pkt_version != ISIS_VERSION) { 486 printf(" version %d packet not supported", header->pkt_version); 487 return; 488 } --- 38 unchanged lines hidden (view full) --- 527 packet_len = EXTRACT_16BITS(header->enc_packet_len); 528 if ((packet_len < ISIS_HEADER_SIZE) || 529 (packet_len > length)) { 530 printf(" bogus packet length %d, real length %d", packet_len, 531 length); 532 return(0); 533 } 534 |
441 priority = header->enc_priority & PRIORITY_MASK; | 535 if(pdu_type != PTP_IIH) 536 priority = header->enc_priority & PRIORITY_MASK; |
442 443 /* 444 * Now print the fixed header. 445 */ 446 switch (pdu_type) { 447 case L1_LAN_IIH: 448 printf(" L1 lan iih, "); 449 break; 450 case L2_LAN_IIH: 451 printf(" L2 lan iih, "); 452 break; | 537 538 /* 539 * Now print the fixed header. 540 */ 541 switch (pdu_type) { 542 case L1_LAN_IIH: 543 printf(" L1 lan iih, "); 544 break; 545 case L2_LAN_IIH: 546 printf(" L2 lan iih, "); 547 break; |
548 case PTP_IIH: 549 printf(" PTP iih, "); 550 break; |
|
453 } 454 455 printf("circuit "); 456 switch (header->circuit) { 457 case 1: 458 printf("l1 only, "); 459 break; 460 case 2: 461 printf("l2 only, "); 462 break; 463 case 3: 464 printf("l1-l2, "); 465 break; 466 } 467 468 printf ("holding time %d ", holding_time); 469 printf ("\n\t\t\t source %s, length %d", 470 etheraddr_string(header->enc_source_id), packet_len); | 551 } 552 553 printf("circuit "); 554 switch (header->circuit) { 555 case 1: 556 printf("l1 only, "); 557 break; 558 case 2: 559 printf("l2 only, "); 560 break; 561 case 3: 562 printf("l1-l2, "); 563 break; 564 } 565 566 printf ("holding time %d ", holding_time); 567 printf ("\n\t\t\t source %s, length %d", 568 etheraddr_string(header->enc_source_id), packet_len); |
471 printf ("\n\t\t\t lan id %s(%d)", etheraddr_string(header->enc_lan_id), 472 header->enc_lan_id[SYSTEM_ID_LEN]); | 569 if((pdu_type==L1_LAN_IIH)||(pdu_type==L2_LAN_IIH)) 570 printf ("\n\t\t\t lan id %s(%d)", etheraddr_string(header->enc_lan_id), 571 header->enc_lan_id[SYSTEM_ID_LEN]); |
473 474 /* 475 * Now print the TLV's. 476 */ | 572 573 /* 574 * Now print the TLV's. 575 */ |
477 packet_len -= ISIS_HEADER_SIZE; 478 pptr = (char *)p + ISIS_HEADER_SIZE; | 576 if(pdu_type==PTP_IIH) { 577 packet_len -= ISIS_PTP_HEADER_SIZE; 578 pptr = (char *)p + ISIS_PTP_HEADER_SIZE; 579 } else { 580 packet_len -= ISIS_HEADER_SIZE; 581 pptr = (char *)p + ISIS_HEADER_SIZE; 582 } |
479 while (packet_len >= 2) { 480 if (pptr >= snapend) { 481 printf("\n\t\t\t packet exceeded snapshot"); 482 return(1); 483 } 484 type = *pptr++; 485 len = *pptr++; 486 packet_len -= 2; --- 28 unchanged lines hidden (view full) --- 515 break; 516 case TLV_PADDING: 517 printf("\n\t\t\t padding for %d bytes", len); 518 break; 519 case TLV_AUTHENT: 520 printf("\n\t\t\t authentication data"); 521 default_print(pptr, len); 522 break; | 583 while (packet_len >= 2) { 584 if (pptr >= snapend) { 585 printf("\n\t\t\t packet exceeded snapshot"); 586 return(1); 587 } 588 type = *pptr++; 589 len = *pptr++; 590 packet_len -= 2; --- 28 unchanged lines hidden (view full) --- 619 break; 620 case TLV_PADDING: 621 printf("\n\t\t\t padding for %d bytes", len); 622 break; 623 case TLV_AUTHENT: 624 printf("\n\t\t\t authentication data"); 625 default_print(pptr, len); 626 break; |
627 case TLV_PTP_ADJ: 628 printf("\n\t\t\t PTP adjacency status %s", 629 isis_ptp_adjancey_values[*pptr].name); 630 break; 631 case TLV_PROTOCOLS: 632 printf("\n\t\t\t Supports protocols %s", (len>1)? "are":"is"); 633 for(i=0;i<len;i++) 634 printf(" %02X", (u_char)*(pptr+i)); 635 break; 636 case TLV_IPADDR: 637 printf("\n\t\t\t IP address: %s", ipaddr_string(pptr)); 638 break; |
|
523 default: 524 printf("\n\t\t\t unknown TLV, type %d, length %d", type, len); 525 break; 526 } 527 528 pptr += len; 529 packet_len -= len; 530 } --- 27 unchanged lines hidden --- | 639 default: 640 printf("\n\t\t\t unknown TLV, type %d, length %d", type, len); 641 break; 642 } 643 644 pptr += len; 645 packet_len -= len; 646 } --- 27 unchanged lines hidden --- |