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 |
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 |
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 |
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"); |
213 if (!eflag) { 214 if(pdu_type != PTP_IIH) 215 (void)printf(" %s > %s", |
216 etheraddr_string(esrc), 217 etheraddr_string(edst)); |
218 } |
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/* |
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; |
441 u_char pdu_type, max_area, priority, *pptr, type, len, *tptr, tmp, alen; 442 u_short packet_len, holding_time; |
443 int i; |
444 |
445 header_ptp = (struct isis_ptp_header *)header = (struct isis_header *)p; |
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 |
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); |
474 } 475 476 pdu_type = header->enc_pdu_type & PDU_TYPE_MASK; |
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) ) { |
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 |
535 if(pdu_type != PTP_IIH) 536 priority = header->enc_priority & PRIORITY_MASK; |
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; |
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); |
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]); |
572 573 /* 574 * Now print the TLV's. 575 */ |
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 } |
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; |
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 --- |