X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/88a7ba9550dcbc8470cb20a9bd31beaa70bd6d11..refs/heads/tcpdump-3.9:/print-juniper.c diff --git a/print-juniper.c b/print-juniper.c index 80136693..fde0b935 100644 --- a/print-juniper.c +++ b/print-juniper.c @@ -15,7 +15,7 @@ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.18 2005-08-10 14:23:07 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-juniper.c,v 1.8.2.22 2006-05-10 22:42:46 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -358,6 +358,74 @@ juniper_pppoe_print(const struct pcap_pkthdr *h, register const u_char *p) } #endif +#ifdef DLT_JUNIPER_ETHER +u_int +juniper_ether_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_ETHER; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw Ethernet frames */ + ether_print(p, l2info.length, l2info.caplen); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_PPP +u_int +juniper_ppp_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_PPP; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw ppp frames */ + ppp_print(p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_FRELAY +u_int +juniper_frelay_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_FRELAY; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw frame-relay frames */ + fr_print(p, l2info.length); + return l2info.header_len; +} +#endif + +#ifdef DLT_JUNIPER_CHDLC +u_int +juniper_chdlc_print(const struct pcap_pkthdr *h, register const u_char *p) +{ + struct juniper_l2info_t l2info; + + l2info.pictype = DLT_JUNIPER_CHDLC; + if(juniper_parse_header(p, h, &l2info) == 0) + return l2info.header_len; + + p+=l2info.header_len; + /* this DLT contains nothing but raw c-hdlc frames */ + chdlc_print(p, l2info.length); + return l2info.header_len; +} +#endif + #ifdef DLT_JUNIPER_PPPOE_ATM u_int juniper_pppoe_atm_print(const struct pcap_pkthdr *h, register const u_char *p) @@ -602,7 +670,6 @@ u_int juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p) { u_int16_t extracted_ethertype; - u_int32_t control_word; struct juniper_l2info_t l2info; @@ -613,12 +680,6 @@ juniper_atm2_print(const struct pcap_pkthdr *h, register const u_char *p) p+=l2info.header_len; if (l2info.cookie[7] & ATM2_PKT_TYPE_MASK) { /* OAM cell ? */ - control_word = EXTRACT_32BITS(p); - if(control_word == 0 || control_word == 0x08000000) { - l2info.header_len += 4; - l2info.length -= 4; - p += 4; - } oam_print(p,l2info.length,ATM_OAM_NOHEC); return l2info.header_len; } @@ -734,6 +795,9 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip struct juniper_cookie_table_t *lp = juniper_cookie_table; u_int idx, offset; +#ifdef DLT_JUNIPER_ATM2 + u_int32_t control_word; +#endif l2info->header_len = 0; l2info->cookie_len = 0; @@ -906,10 +970,21 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip case DLT_JUNIPER_ATM2: TCHECK2(p[0],4); /* ATM cell relay control word present ? */ - if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK && *p & 0x08) { - l2info->header_len += 4; + if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) { + control_word = EXTRACT_32BITS(p); + /* some control word heuristics */ + switch(control_word) { + case 0: /* zero control word */ + case 0x08000000: /* < JUNOS 7.4 control-word */ + case 0x08380000: /* cntl word plus cell length (56) >= JUNOS 7.4*/ + l2info->header_len += 4; + break; + default: + break; + } + if (eflag) - printf("control-word 0x%08x ",EXTRACT_32BITS(p)); + printf("control-word 0x%08x ", control_word); } break; #endif @@ -917,6 +992,23 @@ juniper_parse_header (const u_char *p, const struct pcap_pkthdr *h, struct junip case DLT_JUNIPER_ATM1: break; #endif +#ifdef DLT_JUNIPER_PPP + case DLT_JUNIPER_PPP: + break; +#endif +#ifdef DLT_JUNIPER_CHDLC + case DLT_JUNIPER_CHDLC: + break; +#endif +#ifdef DLT_JUNIPER_ETHER + case DLT_JUNIPER_ETHER: + break; +#endif +#ifdef DLT_JUNIPER_FRELAY + case DLT_JUNIPER_FRELAY: + break; +#endif + default: printf("Unknown Juniper DLT_ type %u: ", l2info->pictype); break;