print-chdlc.c (162017) | print-chdlc.c (172683) |
---|---|
1/* 2 * Copyright (c) 1990, 1991, 1993, 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 --- 7 unchanged lines hidden (view full) --- 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 22#ifndef lint 23static const char rcsid[] _U_ = | 1/* 2 * Copyright (c) 1990, 1991, 1993, 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 --- 7 unchanged lines hidden (view full) --- 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 22#ifndef lint 23static const char rcsid[] _U_ = |
24 "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.8 2005/08/23 10:29:42 hannes Exp $ (LBL)"; | 24 "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.11 2005/11/29 08:57:10 hannes Exp $ (LBL)"; |
25#endif 26 27#ifdef HAVE_CONFIG_H 28#include "config.h" 29#endif 30 31#include <tcpdump-stdinc.h> 32 --- 4 unchanged lines hidden (view full) --- 37#include "addrtoname.h" 38#include "ethertype.h" 39#include "extract.h" 40#include "ppp.h" 41#include "chdlc.h" 42 43static void chdlc_slarp_print(const u_char *, u_int); 44 | 25#endif 26 27#ifdef HAVE_CONFIG_H 28#include "config.h" 29#endif 30 31#include <tcpdump-stdinc.h> 32 --- 4 unchanged lines hidden (view full) --- 37#include "addrtoname.h" 38#include "ethertype.h" 39#include "extract.h" 40#include "ppp.h" 41#include "chdlc.h" 42 43static void chdlc_slarp_print(const u_char *, u_int); 44 |
45const struct tok chdlc_cast_values[] = { 46 { CHDLC_UNICAST, "unicast" }, 47 { CHDLC_BCAST, "bcast" }, 48 { 0, NULL} 49}; 50 51 |
|
45/* Standard CHDLC printer */ 46u_int 47chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p) 48{ 49 register u_int length = h->len; 50 register u_int caplen = h->caplen; 51 52 if (caplen < CHDLC_HDRLEN) { 53 printf("[|chdlc]"); 54 return (caplen); 55 } 56 return (chdlc_print(p,length)); 57} 58 59u_int 60chdlc_print(register const u_char *p, u_int length) { 61 u_int proto; | 52/* Standard CHDLC printer */ 53u_int 54chdlc_if_print(const struct pcap_pkthdr *h, register const u_char *p) 55{ 56 register u_int length = h->len; 57 register u_int caplen = h->caplen; 58 59 if (caplen < CHDLC_HDRLEN) { 60 printf("[|chdlc]"); 61 return (caplen); 62 } 63 return (chdlc_print(p,length)); 64} 65 66u_int 67chdlc_print(register const u_char *p, u_int length) { 68 u_int proto; |
62 const struct ip *ip; | |
63 64 proto = EXTRACT_16BITS(&p[2]); 65 if (eflag) { | 69 70 proto = EXTRACT_16BITS(&p[2]); 71 if (eflag) { |
66 switch (p[0]) { 67 case CHDLC_UNICAST: 68 printf("unicast "); 69 break; 70 case CHDLC_BCAST: 71 printf("bcast "); 72 break; 73 default: 74 printf("0x%02x ", p[0]); 75 break; 76 } 77 printf("%d %04x: ", length, proto); | 72 printf("%s, ethertype %s (0x%04x), length %u: ", 73 tok2str(chdlc_cast_values, "0x%02x", p[0]), 74 tok2str(ethertype_values, "Unknown", proto), 75 proto, 76 length); |
78 } 79 80 length -= CHDLC_HDRLEN; | 77 } 78 79 length -= CHDLC_HDRLEN; |
81 ip = (const struct ip *)(p + CHDLC_HDRLEN); | 80 p += CHDLC_HDRLEN; 81 |
82 switch (proto) { 83 case ETHERTYPE_IP: | 82 switch (proto) { 83 case ETHERTYPE_IP: |
84 ip_print(gndo, (const u_char *)ip, length); | 84 ip_print(gndo, p, length); |
85 break; 86#ifdef INET6 87 case ETHERTYPE_IPV6: | 85 break; 86#ifdef INET6 87 case ETHERTYPE_IPV6: |
88 ip6_print((const u_char *)ip, length); | 88 ip6_print(p, length); |
89 break; 90#endif 91 case CHDLC_TYPE_SLARP: | 89 break; 90#endif 91 case CHDLC_TYPE_SLARP: |
92 chdlc_slarp_print((const u_char *)ip, length); | 92 chdlc_slarp_print(p, length); |
93 break; 94#if 0 95 case CHDLC_TYPE_CDP: | 93 break; 94#if 0 95 case CHDLC_TYPE_CDP: |
96 chdlc_cdp_print((const u_char *)ip, length); | 96 chdlc_cdp_print(p, length); |
97 break; 98#endif 99 case ETHERTYPE_MPLS: 100 case ETHERTYPE_MPLS_MULTI: | 97 break; 98#endif 99 case ETHERTYPE_MPLS: 100 case ETHERTYPE_MPLS_MULTI: |
101 mpls_print((const u_char *)(ip), length); | 101 mpls_print(p, length); |
102 break; 103 case ETHERTYPE_ISO: 104 /* is the fudge byte set ? lets verify by spotting ISO headers */ | 102 break; 103 case ETHERTYPE_ISO: 104 /* is the fudge byte set ? lets verify by spotting ISO headers */ |
105 if (*(p+CHDLC_HDRLEN+1) == 0x81 || 106 *(p+CHDLC_HDRLEN+1) == 0x82 || 107 *(p+CHDLC_HDRLEN+1) == 0x83) 108 isoclns_print(p+CHDLC_HDRLEN+1, length-1, length-1); | 105 if (*(p+1) == 0x81 || 106 *(p+1) == 0x82 || 107 *(p+1) == 0x83) 108 isoclns_print(p+1, length-1, length-1); |
109 else | 109 else |
110 isoclns_print(p+CHDLC_HDRLEN, length, length); | 110 isoclns_print(p, length, length); |
111 break; 112 default: | 111 break; 112 default: |
113 printf("unknown CHDLC protocol (0x%04x)", proto); | 113 if (!eflag) 114 printf("unknown CHDLC protocol (0x%04x)", proto); |
114 break; 115 } 116 117 return (CHDLC_HDRLEN); 118} 119 120/* 121 * The fixed-length portion of a SLARP packet. --- 93 unchanged lines hidden --- | 115 break; 116 } 117 118 return (CHDLC_HDRLEN); 119} 120 121/* 122 * The fixed-length portion of a SLARP packet. --- 93 unchanged lines hidden --- |