print-chdlc.c (146773) | print-chdlc.c (147899) |
---|---|
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 2005/04/06 21:32:38 mcr Exp $ (LBL)"; | 24 "@(#) $Header: /tcpdump/master/tcpdump/print-chdlc.c,v 1.32.2.7 2005/04/27 14:35:56 hannes Exp $ (LBL)"; |
25#endif 26 27#ifdef HAVE_CONFIG_H 28#include "config.h" 29#endif 30 31#include <tcpdump-stdinc.h> 32 --- 74 unchanged lines hidden (view full) --- 107 default: 108 printf("unknown CHDLC protocol (0x%04x)", proto); 109 break; 110 } 111 112 return (CHDLC_HDRLEN); 113} 114 | 25#endif 26 27#ifdef HAVE_CONFIG_H 28#include "config.h" 29#endif 30 31#include <tcpdump-stdinc.h> 32 --- 74 unchanged lines hidden (view full) --- 107 default: 108 printf("unknown CHDLC protocol (0x%04x)", proto); 109 break; 110 } 111 112 return (CHDLC_HDRLEN); 113} 114 |
115/* 116 * The fixed-length portion of a SLARP packet. 117 */ |
|
115struct cisco_slarp { | 118struct cisco_slarp { |
116 u_int32_t code; | 119 u_int8_t code[4]; |
117#define SLARP_REQUEST 0 118#define SLARP_REPLY 1 119#define SLARP_KEEPALIVE 2 120 union { 121 struct { | 120#define SLARP_REQUEST 0 121#define SLARP_REPLY 1 122#define SLARP_KEEPALIVE 2 123 union { 124 struct { |
122 struct in_addr addr; 123 struct in_addr mask; 124 u_int16_t unused[3]; | 125 u_int8_t addr[4]; 126 u_int8_t mask[4]; |
125 } addr; 126 struct { | 127 } addr; 128 struct { |
127 u_int32_t myseq; 128 u_int32_t yourseq; 129 u_int16_t rel; 130 u_int16_t t1; 131 u_int16_t t2; | 129 u_int8_t myseq[4]; 130 u_int8_t yourseq[4]; 131 u_int8_t rel[2]; |
132 } keep; 133 } un; 134}; 135 | 132 } keep; 133 } un; 134}; 135 |
136#define SLARP_LEN 18 | 136#define SLARP_MIN_LEN 14 137#define SLARP_MAX_LEN 18 |
137 138static void 139chdlc_slarp_print(const u_char *cp, u_int length) 140{ 141 const struct cisco_slarp *slarp; | 138 139static void 140chdlc_slarp_print(const u_char *cp, u_int length) 141{ 142 const struct cisco_slarp *slarp; |
143 u_int sec,min,hrs,days; |
|
142 | 144 |
143 if (length < SLARP_LEN) | 145 printf("SLARP (length: %u), ",length); 146 if (length < SLARP_MIN_LEN) |
144 goto trunc; 145 146 slarp = (const struct cisco_slarp *)cp; | 147 goto trunc; 148 149 slarp = (const struct cisco_slarp *)cp; |
147 TCHECK(*slarp); 148 printf("SLARP (length: %u), ",length); | 150 TCHECK2(*slarp, SLARP_MIN_LEN); |
149 switch (EXTRACT_32BITS(&slarp->code)) { 150 case SLARP_REQUEST: 151 printf("request"); | 151 switch (EXTRACT_32BITS(&slarp->code)) { 152 case SLARP_REQUEST: 153 printf("request"); |
152 /* ok we do not know it - but lets at least dump it */ 153 print_unknown_data(cp+4,"\n\t",length-4); | 154 /* 155 * At least according to William "Chops" Westfield's 156 * message in 157 * 158 * http://www.nethelp.no/net/cisco-hdlc.txt 159 * 160 * the address and mask aren't used in requests - 161 * they're just zero. 162 */ |
154 break; 155 case SLARP_REPLY: 156 printf("reply %s/%s", 157 ipaddr_string(&slarp->un.addr.addr), 158 ipaddr_string(&slarp->un.addr.mask)); 159 break; 160 case SLARP_KEEPALIVE: | 163 break; 164 case SLARP_REPLY: 165 printf("reply %s/%s", 166 ipaddr_string(&slarp->un.addr.addr), 167 ipaddr_string(&slarp->un.addr.mask)); 168 break; 169 case SLARP_KEEPALIVE: |
161 printf("keepalive: mineseen=0x%08x, yourseen=0x%08x", 162 EXTRACT_32BITS(&slarp->un.keep.myseq), 163 EXTRACT_32BITS(&slarp->un.keep.yourseq)); 164 printf(", reliability=0x%04x, t1=%d.%d", 165 EXTRACT_16BITS(&slarp->un.keep.rel), 166 EXTRACT_16BITS(&slarp->un.keep.t1), 167 EXTRACT_16BITS(&slarp->un.keep.t2)); | 170 printf("keepalive: mineseen=0x%08x, yourseen=0x%08x, reliability=0x%04x", 171 EXTRACT_32BITS(&slarp->un.keep.myseq), 172 EXTRACT_32BITS(&slarp->un.keep.yourseq), 173 EXTRACT_16BITS(&slarp->un.keep.rel)); 174 175 if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */ 176 cp += SLARP_MIN_LEN; 177 if (!TTEST2(*cp, 4)) 178 goto trunc; 179 sec = EXTRACT_32BITS(cp) / 1000; 180 min = sec / 60; sec -= min * 60; 181 hrs = min / 60; min -= hrs * 60; 182 days = hrs / 24; hrs -= days * 24; 183 printf(", link uptime=%ud%uh%um%us",days,hrs,min,sec); 184 } |
168 break; 169 default: 170 printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code)); 171 if (vflag <= 1) 172 print_unknown_data(cp+4,"\n\t",length-4); 173 break; 174 } 175 | 185 break; 186 default: 187 printf("0x%02x unknown", EXTRACT_32BITS(&slarp->code)); 188 if (vflag <= 1) 189 print_unknown_data(cp+4,"\n\t",length-4); 190 break; 191 } 192 |
176 if (SLARP_LEN < length && vflag) 177 printf(", (trailing junk: %d bytes)", length - SLARP_LEN); | 193 if (SLARP_MAX_LEN < length && vflag) 194 printf(", (trailing junk: %d bytes)", length - SLARP_MAX_LEN); |
178 if (vflag > 1) 179 print_unknown_data(cp+4,"\n\t",length-4); 180 return; 181 182trunc: 183 printf("[|slarp]"); 184} 185 186 187/* 188 * Local Variables: 189 * c-style: whitesmith 190 * c-basic-offset: 8 191 * End: 192 */ | 195 if (vflag > 1) 196 print_unknown_data(cp+4,"\n\t",length-4); 197 return; 198 199trunc: 200 printf("[|slarp]"); 201} 202 203 204/* 205 * Local Variables: 206 * c-style: whitesmith 207 * c-basic-offset: 8 208 * End: 209 */ |