📄 print-isoclns.c
字号:
clnp_header->lifetime/2, (clnp_header->lifetime%2)*5, EXTRACT_16BITS(clnp_header->segment_length), EXTRACT_16BITS(clnp_header->cksum)); osi_print_cksum(optr, EXTRACT_16BITS(clnp_header->cksum), 7, clnp_header->length_indicator); printf("\n\tFlags [%s]", bittok2str(clnp_flag_values,"none",clnp_flags)); printf("\n\tsource address (length %u): %s\n\tdest address (length %u): %s", source_address_length, isonsap_string(source_address, source_address_length), dest_address_length, isonsap_string(dest_address,dest_address_length)); if (clnp_flags & CLNP_SEGMENT_PART) { clnp_segment_header = (const struct clnp_segment_header_t *) pptr; TCHECK(*clnp_segment_header); printf("\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u", EXTRACT_16BITS(clnp_segment_header->data_unit_id), EXTRACT_16BITS(clnp_segment_header->segment_offset), EXTRACT_16BITS(clnp_segment_header->total_length)); pptr+=sizeof(const struct clnp_segment_header_t); li-=sizeof(const struct clnp_segment_header_t); } /* now walk the options */ while (li >= 2) { u_int op, opli; const u_int8_t *tptr; TCHECK2(*pptr, 2); if (li < 2) { printf(", bad opts/li"); return (0); } op = *pptr++; opli = *pptr++; li -= 2; TCHECK2(*pptr, opli); if (opli > li) { printf(", opt (%d) too long", op); return (0); } li -= opli; tptr = pptr; tlen = opli; printf("\n\t %s Option #%u, length %u, value: ", tok2str(clnp_option_values,"Unknown",op), op, opli); switch (op) { case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */ case CLNP_OPTION_SOURCE_ROUTING: printf("%s %s", tok2str(clnp_option_sr_rr_values,"Unknown",*tptr), tok2str(clnp_option_sr_rr_string_values,"Unknown Option %u",op)); nsap_offset=*(tptr+1); if (nsap_offset == 0) { printf(" Bad NSAP offset (0)"); break; } nsap_offset-=1; /* offset to nsap list */ if (nsap_offset > tlen) { printf(" Bad NSAP offset (past end of option)"); break; } tptr+=nsap_offset; tlen-=nsap_offset; while (tlen > 0) { source_address_length=*tptr; if (tlen < source_address_length+1) { printf("\n\t NSAP address goes past end of option"); break; } if (source_address_length > 0) { source_address=(tptr+1); TCHECK2(*source_address, source_address_length); printf("\n\t NSAP address (length %u): %s", source_address_length, isonsap_string(source_address, source_address_length)); } tlen-=source_address_length+1; } break; case CLNP_OPTION_PRIORITY: printf("0x%1x", *tptr&0x0f); break; case CLNP_OPTION_QOS_MAINTENANCE: printf("\n\t Format Code: %s", tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK)); if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL) printf("\n\t QoS Flags [%s]", bittok2str(clnp_option_qos_global_values, "none", *tptr&CLNP_OPTION_OPTION_QOS_MASK)); break; case CLNP_OPTION_SECURITY: printf("\n\t Format Code: %s, Security-Level %u", tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK), *(tptr+1)); break; case CLNP_OPTION_DISCARD_REASON: rfd_error_major = (*tptr&0xf0) >> 4; rfd_error_minor = *tptr&0x0f; printf("\n\t Class: %s Error (0x%01x), %s (0x%01x)", tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major), rfd_error_major, tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor), rfd_error_minor); break; case CLNP_OPTION_PADDING: printf("padding data"); break; /* * FIXME those are the defined Options that lack a decoder * you are welcome to contribute code ;-) */ default: print_unknown_data(tptr,"\n\t ",opli); break; } if (vflag > 1) print_unknown_data(pptr,"\n\t ",opli); pptr += opli; } switch (clnp_pdu_type) { case CLNP_PDU_ER: /* fall through */ case CLNP_PDU_ERP: TCHECK(*pptr); if (*(pptr) == NLPID_CLNP) { printf("\n\t-----original packet-----\n\t"); /* FIXME recursion protection */ clnp_print(pptr, length-clnp_header->length_indicator); break; } case CLNP_PDU_DT: case CLNP_PDU_MD: case CLNP_PDU_ERQ: default: /* dump the PDU specific data */ if (length-(pptr-optr) > 0) { printf("\n\t undecoded non-header data, length %u",length-clnp_header->length_indicator); print_unknown_data(pptr,"\n\t ",length-(pptr-optr)); } } return (1); trunc: fputs("[|clnp]", stdout); return (1);}#define ESIS_PDU_REDIRECT 6#define ESIS_PDU_ESH 2#define ESIS_PDU_ISH 4static struct tok esis_pdu_values[] = { { ESIS_PDU_REDIRECT, "redirect"}, { ESIS_PDU_ESH, "ESH"}, { ESIS_PDU_ISH, "ISH"}, { 0, NULL }};struct esis_header_t { u_int8_t nlpid; u_int8_t length_indicator; u_int8_t version; u_int8_t reserved; u_int8_t type; u_int8_t holdtime[2]; u_int8_t cksum[2];};static voidesis_print(const u_int8_t *pptr, u_int length){ const u_int8_t *optr; u_int li,esis_pdu_type,source_address_length, source_address_number; const struct esis_header_t *esis_header; if (!eflag) printf("ES-IS"); if (length <= 2) { if (qflag) printf("bad pkt!"); else printf("no header at all!"); return; } esis_header = (const struct esis_header_t *) pptr; TCHECK(*esis_header); li = esis_header->length_indicator; optr = pptr; /* * Sanity checking of the header. */ if (esis_header->nlpid != NLPID_ESIS) { printf(" nlpid 0x%02x packet not supported", esis_header->nlpid); return; } if (esis_header->version != ESIS_VERSION) { printf(" version %d packet not supported", esis_header->version); return; } if (li > length) { printf(" length indicator(%d) > PDU size (%d)!", li, length); return; } if (li < sizeof(struct esis_header_t) + 2) { printf(" length indicator < min PDU size %d:", li); while (--length != 0) printf("%02X", *pptr++); return; } esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK; if (vflag < 1) { printf("%s%s, length %u", eflag ? "" : ", ", tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type), length); return; } else printf("%slength %u\n\t%s (%u)", eflag ? "" : ", ", length, tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type), esis_pdu_type); printf(", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ); printf(", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)); osi_print_cksum(pptr, EXTRACT_16BITS(esis_header->cksum), 7, li); printf(", holding time: %us, length indicator: %u",EXTRACT_16BITS(esis_header->holdtime),li); if (vflag > 1) print_unknown_data(optr,"\n\t",sizeof(struct esis_header_t)); pptr += sizeof(struct esis_header_t); li -= sizeof(struct esis_header_t); switch (esis_pdu_type) { case ESIS_PDU_REDIRECT: { const u_int8_t *dst, *snpa, *neta; u_int dstl, snpal, netal; TCHECK(*pptr); if (li < 1) { printf(", bad redirect/li"); return; } dstl = *pptr; pptr++; li--; TCHECK2(*pptr, dstl); if (li < dstl) { printf(", bad redirect/li"); return; } dst = pptr; pptr += dstl; li -= dstl; printf("\n\t %s", isonsap_string(dst,dstl)); TCHECK(*pptr); if (li < 1) { printf(", bad redirect/li"); return; } snpal = *pptr; pptr++; li--; TCHECK2(*pptr, snpal); if (li < snpal) { printf(", bad redirect/li"); return; } snpa = pptr; pptr += snpal; li -= snpal; TCHECK(*pptr); if (li < 1) { printf(", bad redirect/li"); return; } netal = *pptr; pptr++; TCHECK2(*pptr, netal); if (li < netal) { printf(", bad redirect/li"); return; } neta = pptr; pptr += netal; li -= netal; if (netal == 0) printf("\n\t %s", etheraddr_string(snpa)); else printf("\n\t %s", isonsap_string(neta,netal)); break; } case ESIS_PDU_ESH: TCHECK(*pptr); if (li < 1) { printf(", bad esh/li"); return; } source_address_number = *pptr; pptr++; li--; printf("\n\t Number of Source Addresses: %u", source_address_number); while (source_address_number > 0) { TCHECK(*pptr); if (li < 1) { printf(", bad esh/li"); return; } source_address_length = *pptr; pptr++; li--; TCHECK2(*pptr, source_address_length); if (li < source_address_length) { printf(", bad esh/li"); return; } printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr,source_address_length)); pptr += source_address_length; li -= source_address_length; source_address_number--; } break; case ESIS_PDU_ISH: { TCHECK(*pptr); if (li < 1) { printf(", bad ish/li"); return; } source_address_length = *pptr; pptr++; li--; TCHECK2(*pptr, source_address_length); if (li < source_address_length) { printf(", bad ish/li"); return; } printf("\n\t NET (length: %u): %s", source_address_length, isonsap_string(pptr, source_address_length)); pptr += source_address_length; li -= source_address_length; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -