print-bootp.c revision 1.1 1 1.1 gwr /*
2 1.1 gwr * Copyright (c) 1988-1990 The Regents of the University of California.
3 1.1 gwr * All rights reserved.
4 1.1 gwr *
5 1.1 gwr * Redistribution and use in source and binary forms, with or without
6 1.1 gwr * modification, are permitted provided that: (1) source code distributions
7 1.1 gwr * retain the above copyright notice and this paragraph in its entirety, (2)
8 1.1 gwr * distributions including binary code include the above copyright notice and
9 1.1 gwr * this paragraph in its entirety in the documentation or other materials
10 1.1 gwr * provided with the distribution, and (3) all advertising materials mentioning
11 1.1 gwr * features or use of this software display the following acknowledgement:
12 1.1 gwr * ``This product includes software developed by the University of California,
13 1.1 gwr * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 1.1 gwr * the University nor the names of its contributors may be used to endorse
15 1.1 gwr * or promote products derived from this software without specific prior
16 1.1 gwr * written permission.
17 1.1 gwr * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 1.1 gwr * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 1.1 gwr * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 1.1 gwr *
21 1.1 gwr * Format and print bootp packets.
22 1.1 gwr *
23 1.1 gwr * This file was copied from tcpdump-2.1.1 and modified.
24 1.1 gwr * There is an e-mail list for tcpdump: <tcpdump (at) ee.lbl.gov>
25 1.1 gwr */
26 1.1 gwr #ifndef lint
27 1.1 gwr /* from: print-bootp.c,v 1.17 91/11/14 22:21:34 leres Exp */
28 1.1 gwr static char rcsid[] = "$Id: print-bootp.c,v 1.1 1994/06/27 21:25:49 gwr Exp $";
29 1.1 gwr #endif
30 1.1 gwr
31 1.1 gwr #include <stdio.h>
32 1.1 gwr
33 1.1 gwr #include <sys/param.h>
34 1.1 gwr #include <sys/types.h>
35 1.1 gwr #include <sys/socket.h>
36 1.1 gwr #include <net/if.h>
37 1.1 gwr #include <netinet/in.h>
38 1.1 gwr #include <string.h>
39 1.1 gwr #include <ctype.h>
40 1.1 gwr
41 1.1 gwr #include "bootp.h"
42 1.1 gwr
43 1.1 gwr #ifdef BOOTPTEST
44 1.1 gwr #include "bootptest.h"
45 1.1 gwr #else /* BOOTPTEST */
46 1.1 gwr #include "interface.h"
47 1.1 gwr #include "addrtoname.h"
48 1.1 gwr #endif /* BOOTPTEST */
49 1.1 gwr
50 1.1 gwr /* These decode the vendor data. */
51 1.1 gwr static void rfc1048_print();
52 1.1 gwr static void cmu_print();
53 1.1 gwr static void other_print();
54 1.1 gwr static void dump_hex();
55 1.1 gwr
56 1.1 gwr /*
57 1.1 gwr * Print bootp requests
58 1.1 gwr */
59 1.1 gwr void
60 1.1 gwr bootp_print(bp, length, sport, dport)
61 1.1 gwr struct bootp *bp;
62 1.1 gwr int length;
63 1.1 gwr u_short sport, dport;
64 1.1 gwr {
65 1.1 gwr static char tstr[] = " [|bootp]";
66 1.1 gwr static unsigned char vm_cmu[4] = VM_CMU;
67 1.1 gwr static unsigned char vm_rfc1048[4] = VM_RFC1048;
68 1.1 gwr u_char *ep;
69 1.1 gwr int vdlen;
70 1.1 gwr
71 1.1 gwr #define TCHECK(var, l) if ((u_char *)&(var) > ep - l) goto trunc
72 1.1 gwr
73 1.1 gwr /* Note funny sized packets */
74 1.1 gwr if (length != sizeof(struct bootp))
75 1.1 gwr (void) printf(" [len=%d]", length);
76 1.1 gwr
77 1.1 gwr /* 'ep' points to the end of avaible data. */
78 1.1 gwr ep = (u_char *) snapend;
79 1.1 gwr
80 1.1 gwr switch (bp->bp_op) {
81 1.1 gwr
82 1.1 gwr case BOOTREQUEST:
83 1.1 gwr /* Usually, a request goes from a client to a server */
84 1.1 gwr if (sport != IPPORT_BOOTPC || dport != IPPORT_BOOTPS)
85 1.1 gwr printf(" (request)");
86 1.1 gwr break;
87 1.1 gwr
88 1.1 gwr case BOOTREPLY:
89 1.1 gwr /* Usually, a reply goes from a server to a client */
90 1.1 gwr if (sport != IPPORT_BOOTPS || dport != IPPORT_BOOTPC)
91 1.1 gwr printf(" (reply)");
92 1.1 gwr break;
93 1.1 gwr
94 1.1 gwr default:
95 1.1 gwr printf(" bootp-#%d", bp->bp_op);
96 1.1 gwr }
97 1.1 gwr
98 1.1 gwr /* The usual hardware address type is 1 (10Mb Ethernet) */
99 1.1 gwr if (bp->bp_htype != 1)
100 1.1 gwr printf(" htype:%d", bp->bp_htype);
101 1.1 gwr
102 1.1 gwr /* The usual length for 10Mb Ethernet address is 6 bytes */
103 1.1 gwr if (bp->bp_hlen != 6)
104 1.1 gwr printf(" hlen:%d", bp->bp_hlen);
105 1.1 gwr
106 1.1 gwr /* Client's Hardware address */
107 1.1 gwr if (bp->bp_hlen) {
108 1.1 gwr register struct ether_header *eh;
109 1.1 gwr register char *e;
110 1.1 gwr
111 1.1 gwr TCHECK(bp->bp_chaddr[0], 6);
112 1.1 gwr eh = (struct ether_header *) packetp;
113 1.1 gwr if (bp->bp_op == BOOTREQUEST)
114 1.1 gwr e = (char *) ESRC(eh);
115 1.1 gwr else if (bp->bp_op == BOOTREPLY)
116 1.1 gwr e = (char *) EDST(eh);
117 1.1 gwr else
118 1.1 gwr e = 0;
119 1.1 gwr if (e == 0 || bcmp((char *) bp->bp_chaddr, e, 6))
120 1.1 gwr dump_hex(bp->bp_chaddr, bp->bp_hlen);
121 1.1 gwr }
122 1.1 gwr /* Only print interesting fields */
123 1.1 gwr if (bp->bp_hops)
124 1.1 gwr printf(" hops:%d", bp->bp_hops);
125 1.1 gwr
126 1.1 gwr if (bp->bp_xid)
127 1.1 gwr printf(" xid:%d", ntohl(bp->bp_xid));
128 1.1 gwr
129 1.1 gwr if (bp->bp_secs)
130 1.1 gwr printf(" secs:%d", ntohs(bp->bp_secs));
131 1.1 gwr
132 1.1 gwr /* Client's ip address */
133 1.1 gwr TCHECK(bp->bp_ciaddr, sizeof(bp->bp_ciaddr));
134 1.1 gwr if (bp->bp_ciaddr.s_addr)
135 1.1 gwr printf(" C:%s", ipaddr_string(&bp->bp_ciaddr));
136 1.1 gwr
137 1.1 gwr /* 'your' ip address (bootp client) */
138 1.1 gwr TCHECK(bp->bp_yiaddr, sizeof(bp->bp_yiaddr));
139 1.1 gwr if (bp->bp_yiaddr.s_addr)
140 1.1 gwr printf(" Y:%s", ipaddr_string(&bp->bp_yiaddr));
141 1.1 gwr
142 1.1 gwr /* Server's ip address */
143 1.1 gwr TCHECK(bp->bp_siaddr, sizeof(bp->bp_siaddr));
144 1.1 gwr if (bp->bp_siaddr.s_addr)
145 1.1 gwr printf(" S:%s", ipaddr_string(&bp->bp_siaddr));
146 1.1 gwr
147 1.1 gwr /* Gateway's ip address */
148 1.1 gwr TCHECK(bp->bp_giaddr, sizeof(bp->bp_giaddr));
149 1.1 gwr if (bp->bp_giaddr.s_addr)
150 1.1 gwr printf(" G:%s", ipaddr_string(&bp->bp_giaddr));
151 1.1 gwr
152 1.1 gwr TCHECK(bp->bp_sname[0], sizeof(bp->bp_sname));
153 1.1 gwr if (*bp->bp_sname) {
154 1.1 gwr printf(" sname:");
155 1.1 gwr if (printfn(bp->bp_sname, ep)) {
156 1.1 gwr fputs(tstr + 1, stdout);
157 1.1 gwr return;
158 1.1 gwr }
159 1.1 gwr }
160 1.1 gwr TCHECK(bp->bp_file[0], sizeof(bp->bp_file));
161 1.1 gwr if (*bp->bp_file) {
162 1.1 gwr printf(" file:");
163 1.1 gwr if (printfn(bp->bp_file, ep)) {
164 1.1 gwr fputs(tstr + 1, stdout);
165 1.1 gwr return;
166 1.1 gwr }
167 1.1 gwr }
168 1.1 gwr /* Don't try to decode the vendor buffer unless we're verbose */
169 1.1 gwr if (vflag <= 0)
170 1.1 gwr return;
171 1.1 gwr
172 1.1 gwr vdlen = sizeof(bp->bp_vend);
173 1.1 gwr /* Vendor data can extend to the end of the packet. */
174 1.1 gwr if (vdlen < (ep - bp->bp_vend))
175 1.1 gwr vdlen = (ep - bp->bp_vend);
176 1.1 gwr
177 1.1 gwr TCHECK(bp->bp_vend[0], vdlen);
178 1.1 gwr printf(" vend");
179 1.1 gwr if (!bcmp(bp->bp_vend, vm_rfc1048, sizeof(u_int32)))
180 1.1 gwr rfc1048_print(bp->bp_vend, vdlen);
181 1.1 gwr else if (!bcmp(bp->bp_vend, vm_cmu, sizeof(u_int32)))
182 1.1 gwr cmu_print(bp->bp_vend, vdlen);
183 1.1 gwr else
184 1.1 gwr other_print(bp->bp_vend, vdlen);
185 1.1 gwr
186 1.1 gwr return;
187 1.1 gwr trunc:
188 1.1 gwr fputs(tstr, stdout);
189 1.1 gwr #undef TCHECK
190 1.1 gwr }
191 1.1 gwr
192 1.1 gwr /*
194 1.1 gwr * Option description data follows.
195 1.1 gwr * These are decribed in: RFC-1048, RFC-1395, RFC-1497, RFC-1533
196 1.1 gwr *
197 1.1 gwr * The first char of each option string encodes the data format:
198 1.1 gwr * ?: unknown
199 1.1 gwr * a: ASCII
200 1.1 gwr * b: byte (8-bit)
201 1.1 gwr * i: inet address
202 1.1 gwr * l: int32
203 1.1 gwr * s: short (16-bit)
204 1.1 gwr */
205 1.1 gwr char *
206 1.1 gwr rfc1048_opts[] = {
207 1.1 gwr /* Originally from RFC-1048: */
208 1.1 gwr "?PAD", /* 0: Padding - special, no data. */
209 1.1 gwr "iSM", /* 1: subnet mask (RFC950)*/
210 1.1 gwr "lTZ", /* 2: time offset, seconds from UTC */
211 1.1 gwr "iGW", /* 3: gateways (or routers) */
212 1.1 gwr "iTS", /* 4: time servers (RFC868) */
213 1.1 gwr "iINS", /* 5: IEN name servers (IEN116) */
214 1.1 gwr "iDNS", /* 6: domain name servers (RFC1035)(1034?) */
215 1.1 gwr "iLOG", /* 7: MIT log servers */
216 1.1 gwr "iCS", /* 8: cookie servers (RFC865) */
217 1.1 gwr "iLPR", /* 9: lpr server (RFC1179) */
218 1.1 gwr "iIPS", /* 10: impress servers (Imagen) */
219 1.1 gwr "iRLP", /* 11: resource location servers (RFC887) */
220 1.1 gwr "aHN", /* 12: host name (ASCII) */
221 1.1 gwr "sBFS", /* 13: boot file size (in 512 byte blocks) */
222 1.1 gwr
223 1.1 gwr /* Added by RFC-1395: */
224 1.1 gwr "aDUMP", /* 14: Merit Dump File */
225 1.1 gwr "aDNAM", /* 15: Domain Name (for DNS) */
226 1.1 gwr "iSWAP", /* 16: Swap Server */
227 1.1 gwr "aROOT", /* 17: Root Path */
228 1.1 gwr
229 1.1 gwr /* Added by RFC-1497: */
230 1.1 gwr "aEXTF", /* 18: Extensions Path (more options) */
231 1.1 gwr
232 1.1 gwr /* Added by RFC-1533: (many, many options...) */
233 1.1 gwr #if 1 /* These might not be worth recognizing by name. */
234 1.1 gwr
235 1.1 gwr /* IP Layer Parameters, per-host (RFC-1533, sect. 4) */
236 1.1 gwr "bIP-forward", /* 19: IP Forwarding flag */
237 1.1 gwr "bIP-srcroute", /* 20: IP Source Routing Enable flag */
238 1.1 gwr "iIP-filters", /* 21: IP Policy Filter (addr pairs) */
239 1.1 gwr "sIP-maxudp", /* 22: IP Max-UDP reassembly size */
240 1.1 gwr "bIP-ttlive", /* 23: IP Time to Live */
241 1.1 gwr "lIP-pmtuage", /* 24: IP Path MTU aging timeout */
242 1.1 gwr "sIP-pmtutab", /* 25: IP Path MTU plateau table */
243 1.1 gwr
244 1.1 gwr /* IP parameters, per-interface (RFC-1533, sect. 5) */
245 1.1 gwr "sIP-mtu-sz", /* 26: IP MTU size */
246 1.1 gwr "bIP-mtu-sl", /* 27: IP MTU all subnets local */
247 1.1 gwr "bIP-bcast1", /* 28: IP Broadcast Addr ones flag */
248 1.1 gwr "bIP-mask-d", /* 29: IP do mask discovery */
249 1.1 gwr "bIP-mask-s", /* 30: IP do mask supplier */
250 1.1 gwr "bIP-rt-dsc", /* 31: IP do router discovery */
251 1.1 gwr "iIP-rt-sa", /* 32: IP router solicitation addr */
252 1.1 gwr "iIP-routes", /* 33: IP static routes (dst,router) */
253 1.1 gwr
254 1.1 gwr /* Link Layer parameters, per-interface (RFC-1533, sect. 6) */
255 1.1 gwr "bLL-trailer", /* 34: do tralier encapsulation */
256 1.1 gwr "lLL-arp-tmo", /* 35: ARP cache timeout */
257 1.1 gwr "bLL-ether2", /* 36: Ethernet version 2 (IEEE 802.3) */
258 1.1 gwr
259 1.1 gwr /* TCP parameters (RFC-1533, sect. 7) */
260 1.1 gwr "bTCP-def-ttl", /* 37: default time to live */
261 1.1 gwr "lTCP-KA-tmo", /* 38: keepalive time interval */
262 1.1 gwr "bTCP-KA-junk", /* 39: keepalive sends extra junk */
263 1.1 gwr
264 1.1 gwr /* Application and Service Parameters (RFC-1533, sect. 8) */
265 1.1 gwr "aNISDOM", /* 40: NIS Domain (Sun YP) */
266 1.1 gwr "iNISSRV", /* 41: NIS Servers */
267 1.1 gwr "iNTPSRV", /* 42: NTP (time) Servers (RFC 1129) */
268 1.1 gwr "?VSINFO", /* 43: Vendor Specific Info (encapsulated) */
269 1.1 gwr "iNBiosNS", /* 44: NetBIOS Name Server (RFC-1001,1..2) */
270 1.1 gwr "iNBiosDD", /* 45: NetBIOS Datagram Dist. Server. */
271 1.1 gwr "bNBiosNT", /* 46: NetBIOS Note Type */
272 1.1 gwr "?NBiosS", /* 47: NetBIOS Scope */
273 1.1 gwr "iXW-FS", /* 48: X Window System Font Servers */
274 1.1 gwr "iXW-DM", /* 49: X Window System Display Managers */
275 1.1 gwr
276 1.1 gwr /* DHCP extensions (RFC-1533, sect. 9) */
277 1.1 gwr #endif
278 1.1 gwr };
279 1.1 gwr #define KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
280 1.1 gwr
281 1.1 gwr static void print_string();
282 1.1 gwr
283 1.1 gwr static void
284 1.1 gwr rfc1048_print(bp, length)
285 1.1 gwr register u_char *bp;
286 1.1 gwr int length;
287 1.1 gwr {
288 1.1 gwr u_char tag;
289 1.1 gwr u_char *ep;
290 1.1 gwr register int len, j;
291 1.1 gwr u_int32 ul;
292 1.1 gwr u_short us;
293 1.1 gwr struct in_addr ia;
294 1.1 gwr char *optstr;
295 1.1 gwr
296 1.1 gwr printf("-rfc1395");
297 1.1 gwr
298 1.1 gwr /* Step over magic cookie */
299 1.1 gwr bp += sizeof(int32);
300 1.1 gwr /* Setup end pointer */
301 1.1 gwr ep = bp + length;
302 1.1 gwr while (bp < ep) {
303 1.1 gwr tag = *bp++;
304 1.1 gwr /* Check for tags with no data first. */
305 1.1 gwr if (tag == TAG_PAD)
306 1.1 gwr continue;
307 1.1 gwr if (tag == TAG_END)
308 1.1 gwr return;
309 1.1 gwr if (tag < KNOWN_OPTIONS) {
310 1.1 gwr optstr = rfc1048_opts[tag];
311 1.1 gwr printf(" %s:", optstr + 1);
312 1.1 gwr } else {
313 1.1 gwr printf(" T%d:", tag);
314 1.1 gwr optstr = "?";
315 1.1 gwr }
316 1.1 gwr /* Now scan the length byte. */
317 1.1 gwr len = *bp++;
318 1.1 gwr if (bp + len > ep) {
319 1.1 gwr /* truncated option */
320 1.1 gwr printf(" |(%d>%d)", len, ep - bp);
321 1.1 gwr return;
322 1.1 gwr }
323 1.1 gwr /* Print the option value(s). */
324 1.1 gwr switch (optstr[0]) {
325 1.1 gwr
326 1.1 gwr case 'a': /* ASCII string */
327 1.1 gwr printfn(bp, bp + len);
328 1.1 gwr bp += len;
329 1.1 gwr len = 0;
330 1.1 gwr break;
331 1.1 gwr
332 1.1 gwr case 's': /* Word formats */
333 1.1 gwr while (len >= 2) {
334 1.1 gwr bcopy((char *) bp, (char *) &us, 2);
335 1.1 gwr printf("%d", ntohs(us));
336 1.1 gwr bp += 2;
337 1.1 gwr len -= 2;
338 1.1 gwr if (len) printf(",");
339 1.1 gwr }
340 1.1 gwr if (len) printf("(junk=%d)", len);
341 1.1 gwr break;
342 1.1 gwr
343 1.1 gwr case 'l': /* Long words */
344 1.1 gwr while (len >= 4) {
345 1.1 gwr bcopy((char *) bp, (char *) &ul, 4);
346 1.1 gwr printf("%d", ntohl(ul));
347 1.1 gwr bp += 4;
348 1.1 gwr len -= 4;
349 1.1 gwr if (len) printf(",");
350 1.1 gwr }
351 1.1 gwr if (len) printf("(junk=%d)", len);
352 1.1 gwr break;
353 1.1 gwr
354 1.1 gwr case 'i': /* INET addresses */
355 1.1 gwr while (len >= 4) {
356 1.1 gwr bcopy((char *) bp, (char *) &ia, 4);
357 1.1 gwr printf("%s", ipaddr_string(&ia));
358 1.1 gwr bp += 4;
359 1.1 gwr len -= 4;
360 1.1 gwr if (len) printf(",");
361 1.1 gwr }
362 1.1 gwr if (len) printf("(junk=%d)", len);
363 1.1 gwr break;
364 1.1 gwr
365 1.1 gwr case 'b':
366 1.1 gwr default:
367 1.1 gwr break;
368 1.1 gwr
369 1.1 gwr } /* switch */
370 1.1 gwr
371 1.1 gwr /* Print as characters, if appropriate. */
372 1.1 gwr if (len) {
373 1.1 gwr dump_hex(bp, len);
374 1.1 gwr if (isascii(*bp) && isprint(*bp)) {
375 1.1 gwr printf("(");
376 1.1 gwr printfn(bp, bp + len);
377 1.1 gwr printf(")");
378 1.1 gwr }
379 1.1 gwr bp += len;
380 1.1 gwr len = 0;
381 1.1 gwr }
382 1.1 gwr } /* while bp < ep */
383 1.1 gwr }
384 1.1 gwr
385 1.1 gwr static void
386 1.1 gwr cmu_print(bp, length)
387 1.1 gwr register u_char *bp;
388 1.1 gwr int length;
389 1.1 gwr {
390 1.1 gwr struct cmu_vend *v;
391 1.1 gwr u_char *ep;
392 1.1 gwr
393 1.1 gwr printf("-cmu");
394 1.1 gwr
395 1.1 gwr v = (struct cmu_vend *) bp;
396 1.1 gwr if (length < sizeof(*v)) {
397 1.1 gwr printf(" |L=%d", length);
398 1.1 gwr return;
399 1.1 gwr }
400 1.1 gwr /* Setup end pointer */
401 1.1 gwr ep = bp + length;
402 1.1 gwr
403 1.1 gwr /* Subnet mask */
404 1.1 gwr if (v->v_flags & VF_SMASK) {
405 1.1 gwr printf(" SM:%s", ipaddr_string(&v->v_smask));
406 1.1 gwr }
407 1.1 gwr /* Default gateway */
408 1.1 gwr if (v->v_dgate.s_addr)
409 1.1 gwr printf(" GW:%s", ipaddr_string(&v->v_dgate));
410 1.1 gwr
411 1.1 gwr /* Domain name servers */
412 1.1 gwr if (v->v_dns1.s_addr)
413 1.1 gwr printf(" DNS1:%s", ipaddr_string(&v->v_dns1));
414 1.1 gwr if (v->v_dns2.s_addr)
415 1.1 gwr printf(" DNS2:%s", ipaddr_string(&v->v_dns2));
416 1.1 gwr
417 1.1 gwr /* IEN-116 name servers */
418 1.1 gwr if (v->v_ins1.s_addr)
419 1.1 gwr printf(" INS1:%s", ipaddr_string(&v->v_ins1));
420 1.1 gwr if (v->v_ins2.s_addr)
421 1.1 gwr printf(" INS2:%s", ipaddr_string(&v->v_ins2));
422 1.1 gwr
423 1.1 gwr /* Time servers */
424 1.1 gwr if (v->v_ts1.s_addr)
425 1.1 gwr printf(" TS1:%s", ipaddr_string(&v->v_ts1));
426 1.1 gwr if (v->v_ts2.s_addr)
427 1.1 gwr printf(" TS2:%s", ipaddr_string(&v->v_ts2));
428 1.1 gwr
429 1.1 gwr }
430 1.1 gwr
431 1.1 gwr
432 1.1 gwr /*
433 1.1 gwr * Print out arbitrary, unknown vendor data.
434 1.1 gwr */
435 1.1 gwr
436 1.1 gwr static void
437 1.1 gwr other_print(bp, length)
438 1.1 gwr register u_char *bp;
439 1.1 gwr int length;
440 1.1 gwr {
441 1.1 gwr u_char *ep; /* end pointer */
442 1.1 gwr u_char *zp; /* points one past last non-zero byte */
443 1.1 gwr register int i, j;
444 1.1 gwr
445 1.1 gwr /* Setup end pointer */
446 1.1 gwr ep = bp + length;
447 1.1 gwr
448 1.1 gwr /* Find the last non-zero byte. */
449 1.1 gwr for (zp = ep; zp > bp; zp--) {
450 1.1 gwr if (zp[-1] != 0)
451 1.1 gwr break;
452 1.1 gwr }
453 1.1 gwr
454 1.1 gwr /* Print the all-zero case in a compact representation. */
455 1.1 gwr if (zp == bp) {
456 1.1 gwr printf("-all-zero");
457 1.1 gwr return;
458 1.1 gwr }
459 1.1 gwr printf("-unknown");
460 1.1 gwr
461 1.1 gwr /* Are there enough trailing zeros to make "00..." worthwhile? */
462 1.1 gwr if (zp + 2 > ep)
463 1.1 gwr zp = ep; /* print them all normally */
464 1.1 gwr
465 1.1 gwr /* Now just print all the non-zero data. */
466 1.1 gwr while (bp < zp) {
467 1.1 gwr printf(".%02X", *bp);
468 1.1 gwr bp++;
469 1.1 gwr }
470 1.1 gwr
471 1.1 gwr if (zp < ep)
472 1.1 gwr printf(".00...");
473 1.1 gwr
474 1.1 gwr return;
475 1.1 gwr }
476 1.1 gwr
477 1.1 gwr static void
478 1.1 gwr dump_hex(bp, len)
479 1.1 gwr u_char *bp;
480 1.1 gwr int len;
481 1.1 gwr {
482 1.1 gwr while (len > 0) {
483 1.1 gwr printf("%02X", *bp);
484 1.1 gwr bp++;
485 1.1 gwr len--;
486 1.1 gwr if (len) printf(".");
487 1.1 gwr }
488 1.1 gwr }
489 1.1 gwr
490 1.1 gwr /*
491 1.1 gwr * Local Variables:
492 1.1 gwr * tab-width: 4
493 1.1 gwr * c-indent-level: 4
494 1.1 gwr * c-argdecl-indent: 4
495 1.1 gwr * c-continued-statement-offset: 4
496 1.1 gwr * c-continued-brace-offset: -4
497 1.1 gwr * c-label-offset: -4
498 1.1 gwr * c-brace-offset: 0
499 1.1 gwr * End:
500 */
501