Deleted Added
full compact
print-icmp.c (66644) print-icmp.c (75118)
1/*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
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

--- 4 unchanged lines hidden (view full) ---

13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
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 *
1/*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1993, 1994, 1995, 1996
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

--- 4 unchanged lines hidden (view full) ---

13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
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 * $FreeBSD: head/contrib/tcpdump/print-icmp.c 66644 2000-10-05 02:49:49Z kris $
21 * $FreeBSD: head/contrib/tcpdump/print-icmp.c 75118 2001-04-03 07:50:46Z fenner $
22 */
23
24#ifndef lint
25static const char rcsid[] =
22 */
23
24#ifndef lint
25static const char rcsid[] =
26 "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.43 1999/11/22 04:28:21 fenner Exp $ (LBL)";
26 "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.57 2000/10/10 05:03:32 guy Exp $ (LBL)";
27#endif
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <sys/param.h>
34#include <sys/time.h>
35#include <sys/socket.h>
36
27#endif
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <sys/param.h>
34#include <sys/time.h>
35#include <sys/socket.h>
36
37#if __STDC__
38struct mbuf;
39struct rtentry;
37struct mbuf;
38struct rtentry;
40#endif
41#include <net/if.h>
42
43#include <netinet/in.h>
39
40#include <netinet/in.h>
44#include <net/ethernet.h>
45#include <netinet/in_systm.h>
46#include <netinet/ip.h>
47#include <netinet/ip_icmp.h>
48#include <netinet/ip_var.h>
49#include <netinet/udp.h>
50#include <netinet/udp_var.h>
51#include <netinet/tcp.h>
52
53#include <stdio.h>
54#include <string.h>
41
42#include <stdio.h>
43#include <string.h>
44#include <netdb.h> /* for MAXHOSTNAMELEN on some platforms */
55
56#include "interface.h"
57#include "addrtoname.h"
58#include "extract.h" /* must come after interface.h */
59
45
46#include "interface.h"
47#include "addrtoname.h"
48#include "extract.h" /* must come after interface.h */
49
50#include "ip.h"
51#include "udp.h"
52
53/*
54 * Interface Control Message Protocol Definitions.
55 * Per RFC 792, September 1981.
56 */
57
58/*
59 * Structure of an icmp header.
60 */
61struct icmp {
62 u_int8_t icmp_type; /* type of message, see below */
63 u_int8_t icmp_code; /* type sub code */
64 u_int16_t icmp_cksum; /* ones complement cksum of struct */
65 union {
66 u_int8_t ih_pptr; /* ICMP_PARAMPROB */
67 struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
68 struct ih_idseq {
69 u_int16_t icd_id;
70 u_int16_t icd_seq;
71 } ih_idseq;
72 u_int32_t ih_void;
73
74 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
75 struct ih_pmtu {
76 u_int16_t ipm_void;
77 u_int16_t ipm_nextmtu;
78 } ih_pmtu;
79 } icmp_hun;
80#define icmp_pptr icmp_hun.ih_pptr
81#define icmp_gwaddr icmp_hun.ih_gwaddr
82#define icmp_id icmp_hun.ih_idseq.icd_id
83#define icmp_seq icmp_hun.ih_idseq.icd_seq
84#define icmp_void icmp_hun.ih_void
85#define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void
86#define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu
87 union {
88 struct id_ts {
89 u_int32_t its_otime;
90 u_int32_t its_rtime;
91 u_int32_t its_ttime;
92 } id_ts;
93 struct id_ip {
94 struct ip idi_ip;
95 /* options and then 64 bits of data */
96 } id_ip;
97 u_int32_t id_mask;
98 u_int8_t id_data[1];
99 } icmp_dun;
100#define icmp_otime icmp_dun.id_ts.its_otime
101#define icmp_rtime icmp_dun.id_ts.its_rtime
102#define icmp_ttime icmp_dun.id_ts.its_ttime
103#define icmp_ip icmp_dun.id_ip.idi_ip
104#define icmp_mask icmp_dun.id_mask
105#define icmp_data icmp_dun.id_data
106};
107
108/*
109 * Lower bounds on packet lengths for various types.
110 * For the error advice packets must first insure that the
111 * packet is large enought to contain the returned ip header.
112 * Only then can we do the check to see if 64 bits of packet
113 * data have been returned, since we need to check the returned
114 * ip header length.
115 */
116#define ICMP_MINLEN 8 /* abs minimum */
117#define ICMP_TSLEN (8 + 3 * sizeof (u_int32_t)) /* timestamp */
118#define ICMP_MASKLEN 12 /* address mask */
119#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
120#define ICMP_ADVLEN(p) (8 + (IP_HL(&(p)->icmp_ip) << 2) + 8)
121 /* N.B.: must separately check that ip_hl >= 5 */
122
123/*
124 * Definition of type and code field values.
125 */
126#define ICMP_ECHOREPLY 0 /* echo reply */
127#define ICMP_UNREACH 3 /* dest unreachable, codes: */
128#define ICMP_UNREACH_NET 0 /* bad net */
129#define ICMP_UNREACH_HOST 1 /* bad host */
130#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
131#define ICMP_UNREACH_PORT 3 /* bad port */
132#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
133#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
134#define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */
135#define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */
136#define ICMP_UNREACH_ISOLATED 8 /* src host isolated */
137#define ICMP_UNREACH_NET_PROHIB 9 /* prohibited access */
138#define ICMP_UNREACH_HOST_PROHIB 10 /* ditto */
139#define ICMP_UNREACH_TOSNET 11 /* bad tos for net */
140#define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */
141#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
142#define ICMP_REDIRECT 5 /* shorter route, codes: */
143#define ICMP_REDIRECT_NET 0 /* for network */
144#define ICMP_REDIRECT_HOST 1 /* for host */
145#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
146#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
147#define ICMP_ECHO 8 /* echo service */
148#define ICMP_ROUTERADVERT 9 /* router advertisement */
149#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
150#define ICMP_TIMXCEED 11 /* time exceeded, code: */
151#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
152#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
153#define ICMP_PARAMPROB 12 /* ip header bad */
154#define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */
155#define ICMP_TSTAMP 13 /* timestamp request */
156#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
157#define ICMP_IREQ 15 /* information request */
158#define ICMP_IREQREPLY 16 /* information reply */
159#define ICMP_MASKREQ 17 /* address mask request */
160#define ICMP_MASKREPLY 18 /* address mask reply */
161
162#define ICMP_MAXTYPE 18
163
164#define ICMP_INFOTYPE(type) \
165 ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
166 (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
167 (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
168 (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
169 (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
60/* rfc1700 */
61#ifndef ICMP_UNREACH_NET_UNKNOWN
62#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
63#endif
64#ifndef ICMP_UNREACH_HOST_UNKNOWN
65#define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */
66#endif
67#ifndef ICMP_UNREACH_ISOLATED

--- 18 unchanged lines hidden (view full) ---

86#endif
87#ifndef ICMP_UNREACH_HOST_PRECEDENCE
88#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */
89#endif
90#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
91#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
92#endif
93
170/* rfc1700 */
171#ifndef ICMP_UNREACH_NET_UNKNOWN
172#define ICMP_UNREACH_NET_UNKNOWN 6 /* destination net unknown */
173#endif
174#ifndef ICMP_UNREACH_HOST_UNKNOWN
175#define ICMP_UNREACH_HOST_UNKNOWN 7 /* destination host unknown */
176#endif
177#ifndef ICMP_UNREACH_ISOLATED

--- 18 unchanged lines hidden (view full) ---

196#endif
197#ifndef ICMP_UNREACH_HOST_PRECEDENCE
198#define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host precedence violation */
199#endif
200#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
201#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* precedence cutoff */
202#endif
203
94/* rfc1256 */
95#ifndef ICMP_ROUTERADVERT
96#define ICMP_ROUTERADVERT 9 /* router advertisement */
97#endif
98#ifndef ICMP_ROUTERSOLICIT
99#define ICMP_ROUTERSOLICIT 10 /* router solicitation */
100#endif
101
102/* Most of the icmp types */
103static struct tok icmp2str[] = {
104 { ICMP_ECHOREPLY, "echo reply" },
105 { ICMP_SOURCEQUENCH, "source quench" },
106 { ICMP_ECHO, "echo request" },
107 { ICMP_ROUTERSOLICIT, "router solicitation" },
108 { ICMP_TSTAMP, "time stamp request" },
109 { ICMP_TSTAMPREPLY, "time stamp reply" },

--- 36 unchanged lines hidden (view full) ---

146 { ICMP_REDIRECT_HOST, "redirect %s to host %s" },
147 { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
148 { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to net %s" },
149 { 0, NULL }
150};
151
152/* rfc1191 */
153struct mtu_discovery {
204/* Most of the icmp types */
205static struct tok icmp2str[] = {
206 { ICMP_ECHOREPLY, "echo reply" },
207 { ICMP_SOURCEQUENCH, "source quench" },
208 { ICMP_ECHO, "echo request" },
209 { ICMP_ROUTERSOLICIT, "router solicitation" },
210 { ICMP_TSTAMP, "time stamp request" },
211 { ICMP_TSTAMPREPLY, "time stamp reply" },

--- 36 unchanged lines hidden (view full) ---

248 { ICMP_REDIRECT_HOST, "redirect %s to host %s" },
249 { ICMP_REDIRECT_TOSNET, "redirect-tos %s to net %s" },
250 { ICMP_REDIRECT_TOSHOST, "redirect-tos %s to net %s" },
251 { 0, NULL }
252};
253
254/* rfc1191 */
255struct mtu_discovery {
154 short unused;
155 short nexthopmtu;
256 u_int16_t unused;
257 u_int16_t nexthopmtu;
156};
157
158/* rfc1256 */
159struct ih_rdiscovery {
258};
259
260/* rfc1256 */
261struct ih_rdiscovery {
160 u_char ird_addrnum;
161 u_char ird_addrsiz;
162 u_short ird_lifetime;
262 u_int8_t ird_addrnum;
263 u_int8_t ird_addrsiz;
264 u_int16_t ird_lifetime;
163};
164
165struct id_rdiscovery {
166 u_int32_t ird_addr;
167 u_int32_t ird_pref;
168};
169
170void

--- 22 unchanged lines hidden (view full) ---

193 switch (dp->icmp_type) {
194
195 case ICMP_UNREACH:
196 TCHECK(dp->icmp_ip.ip_dst);
197 switch (dp->icmp_code) {
198
199 case ICMP_UNREACH_PROTOCOL:
200 TCHECK(dp->icmp_ip.ip_p);
265};
266
267struct id_rdiscovery {
268 u_int32_t ird_addr;
269 u_int32_t ird_pref;
270};
271
272void

--- 22 unchanged lines hidden (view full) ---

295 switch (dp->icmp_type) {
296
297 case ICMP_UNREACH:
298 TCHECK(dp->icmp_ip.ip_dst);
299 switch (dp->icmp_code) {
300
301 case ICMP_UNREACH_PROTOCOL:
302 TCHECK(dp->icmp_ip.ip_p);
201 (void)snprintf(buf, sizeof(buf), "%s protocol %d unreachable",
202 ipaddr_string(&dp->icmp_ip.ip_dst),
203 dp->icmp_ip.ip_p);
303 (void)snprintf(buf, sizeof(buf),
304 "%s protocol %d unreachable",
305 ipaddr_string(&dp->icmp_ip.ip_dst),
306 dp->icmp_ip.ip_p);
204 break;
205
206 case ICMP_UNREACH_PORT:
207 TCHECK(dp->icmp_ip.ip_p);
208 oip = &dp->icmp_ip;
307 break;
308
309 case ICMP_UNREACH_PORT:
310 TCHECK(dp->icmp_ip.ip_p);
311 oip = &dp->icmp_ip;
209 hlen = oip->ip_hl * 4;
312 hlen = IP_HL(oip) * 4;
210 ouh = (struct udphdr *)(((u_char *)oip) + hlen);
211 dport = ntohs(ouh->uh_dport);
212 switch (oip->ip_p) {
213
214 case IPPROTO_TCP:
215 (void)snprintf(buf, sizeof(buf),
216 "%s tcp port %s unreachable",
217 ipaddr_string(&oip->ip_dst),

--- 12 unchanged lines hidden (view full) ---

230 "%s protocol %d port %d unreachable",
231 ipaddr_string(&oip->ip_dst),
232 oip->ip_p, dport);
233 break;
234 }
235 break;
236
237 case ICMP_UNREACH_NEEDFRAG:
313 ouh = (struct udphdr *)(((u_char *)oip) + hlen);
314 dport = ntohs(ouh->uh_dport);
315 switch (oip->ip_p) {
316
317 case IPPROTO_TCP:
318 (void)snprintf(buf, sizeof(buf),
319 "%s tcp port %s unreachable",
320 ipaddr_string(&oip->ip_dst),

--- 12 unchanged lines hidden (view full) ---

333 "%s protocol %d port %d unreachable",
334 ipaddr_string(&oip->ip_dst),
335 oip->ip_p, dport);
336 break;
337 }
338 break;
339
340 case ICMP_UNREACH_NEEDFRAG:
238 {
341 {
239 register const struct mtu_discovery *mp;
342 register const struct mtu_discovery *mp;
240
241 mp = (struct mtu_discovery *)&dp->icmp_void;
242 mtu = EXTRACT_16BITS(&mp->nexthopmtu);
343 mp = (struct mtu_discovery *)&dp->icmp_void;
344 mtu = EXTRACT_16BITS(&mp->nexthopmtu);
243 if (mtu)
244 (void)snprintf(buf, sizeof(buf),
245 "%s unreachable - need to frag (mtu %d)",
246 ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
247 else
248 (void)snprintf(buf, sizeof(buf),
249 "%s unreachable - need to frag",
250 ipaddr_string(&dp->icmp_ip.ip_dst));
345 if (mtu) {
346 (void)snprintf(buf, sizeof(buf),
347 "%s unreachable - need to frag (mtu %d)",
348 ipaddr_string(&dp->icmp_ip.ip_dst), mtu);
349 } else {
350 (void)snprintf(buf, sizeof(buf),
351 "%s unreachable - need to frag",
352 ipaddr_string(&dp->icmp_ip.ip_dst));
251 }
353 }
354 }
252 break;
253
254 default:
255 fmt = tok2str(unreach2str, "#%d %%s unreachable",
256 dp->icmp_code);
257 (void)snprintf(buf, sizeof(buf), fmt,
258 ipaddr_string(&dp->icmp_ip.ip_dst));
259 break;

--- 5 unchanged lines hidden (view full) ---

265 fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
266 dp->icmp_code);
267 (void)snprintf(buf, sizeof(buf), fmt,
268 ipaddr_string(&dp->icmp_ip.ip_dst),
269 ipaddr_string(&dp->icmp_gwaddr));
270 break;
271
272 case ICMP_ROUTERADVERT:
355 break;
356
357 default:
358 fmt = tok2str(unreach2str, "#%d %%s unreachable",
359 dp->icmp_code);
360 (void)snprintf(buf, sizeof(buf), fmt,
361 ipaddr_string(&dp->icmp_ip.ip_dst));
362 break;

--- 5 unchanged lines hidden (view full) ---

368 fmt = tok2str(type2str, "redirect-#%d %%s to net %%s",
369 dp->icmp_code);
370 (void)snprintf(buf, sizeof(buf), fmt,
371 ipaddr_string(&dp->icmp_ip.ip_dst),
372 ipaddr_string(&dp->icmp_gwaddr));
373 break;
374
375 case ICMP_ROUTERADVERT:
273 {
376 {
274 register const struct ih_rdiscovery *ihp;
275 register const struct id_rdiscovery *idp;
276 u_int lifetime, num, size;
277
377 register const struct ih_rdiscovery *ihp;
378 register const struct id_rdiscovery *idp;
379 u_int lifetime, num, size;
380
278 (void)strcpy(buf, "router advertisement");
381 (void)snprintf(buf, sizeof(buf), "router advertisement");
279 cp = buf + strlen(buf);
280
281 ihp = (struct ih_rdiscovery *)&dp->icmp_void;
282 TCHECK(*ihp);
382 cp = buf + strlen(buf);
383
384 ihp = (struct ih_rdiscovery *)&dp->icmp_void;
385 TCHECK(*ihp);
283 (void)strcpy(cp, " lifetime ");
386 (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf));
284 cp = buf + strlen(buf);
285 lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
387 cp = buf + strlen(buf);
388 lifetime = EXTRACT_16BITS(&ihp->ird_lifetime);
286 if (lifetime < 60)
287 (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u", lifetime);
288 else if (lifetime < 60 * 60)
289 (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u:%02u",
389 if (lifetime < 60) {
390 (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u",
391 lifetime);
392 } else if (lifetime < 60 * 60) {
393 (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u",
290 lifetime / 60, lifetime % 60);
394 lifetime / 60, lifetime % 60);
291 else
292 (void)snprintf(cp, sizeof(buf) - strlen(buf), "%u:%02u:%02u",
395 } else {
396 (void)snprintf(cp, sizeof(buf) - (cp - buf),
397 "%u:%02u:%02u",
293 lifetime / 3600,
294 (lifetime % 3600) / 60,
295 lifetime % 60);
398 lifetime / 3600,
399 (lifetime % 3600) / 60,
400 lifetime % 60);
401 }
296 cp = buf + strlen(buf);
297
298 num = ihp->ird_addrnum;
402 cp = buf + strlen(buf);
403
404 num = ihp->ird_addrnum;
299 (void)snprintf(cp, sizeof(buf) - strlen(buf), " %d:", num);
405 (void)snprintf(cp, sizeof(buf) - (cp - buf), " %d:", num);
300 cp = buf + strlen(buf);
301
302 size = ihp->ird_addrsiz;
303 if (size != 2) {
406 cp = buf + strlen(buf);
407
408 size = ihp->ird_addrsiz;
409 if (size != 2) {
304 (void)snprintf(cp, sizeof(buf) - strlen(buf), " [size %d]", size);
410 (void)snprintf(cp, sizeof(buf) - (cp - buf),
411 " [size %d]", size);
305 break;
306 }
307 idp = (struct id_rdiscovery *)&dp->icmp_data;
308 while (num-- > 0) {
309 TCHECK(*idp);
412 break;
413 }
414 idp = (struct id_rdiscovery *)&dp->icmp_data;
415 while (num-- > 0) {
416 TCHECK(*idp);
310 (void)snprintf(cp, sizeof(buf) - strlen(buf), " {%s %u}",
417 (void)snprintf(cp, sizeof(buf) - (cp - buf), " {%s %u}",
311 ipaddr_string(&idp->ird_addr),
312 EXTRACT_32BITS(&idp->ird_pref));
313 cp = buf + strlen(buf);
418 ipaddr_string(&idp->ird_addr),
419 EXTRACT_32BITS(&idp->ird_pref));
420 cp = buf + strlen(buf);
421 ++idp;
314 }
422 }
315 }
423 }
316 break;
317
318 case ICMP_TIMXCEED:
319 TCHECK(dp->icmp_ip.ip_dst);
320 switch (dp->icmp_code) {
321
322 case ICMP_TIMXCEED_INTRANS:
323 str = "time exceeded in-transit";
324 break;
325
326 case ICMP_TIMXCEED_REASS:
327 str = "ip reassembly time exceeded";
328 break;
329
330 default:
424 break;
425
426 case ICMP_TIMXCEED:
427 TCHECK(dp->icmp_ip.ip_dst);
428 switch (dp->icmp_code) {
429
430 case ICMP_TIMXCEED_INTRANS:
431 str = "time exceeded in-transit";
432 break;
433
434 case ICMP_TIMXCEED_REASS:
435 str = "ip reassembly time exceeded";
436 break;
437
438 default:
331 (void)snprintf(buf, sizeof(buf), "time exceeded-#%d", dp->icmp_code);
439 (void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
440 dp->icmp_code);
332 break;
333 }
334 break;
335
336 case ICMP_PARAMPROB:
337 if (dp->icmp_code)
441 break;
442 }
443 break;
444
445 case ICMP_PARAMPROB:
446 if (dp->icmp_code)
338 (void)snprintf(buf, sizeof(buf), "parameter problem - code %d",
339 dp->icmp_code);
447 (void)snprintf(buf, sizeof(buf),
448 "parameter problem - code %d", dp->icmp_code);
340 else {
341 TCHECK(dp->icmp_pptr);
449 else {
450 TCHECK(dp->icmp_pptr);
342 (void)snprintf(buf, sizeof(buf), "parameter problem - octet %d",
343 dp->icmp_pptr);
451 (void)snprintf(buf, sizeof(buf),
452 "parameter problem - octet %d", dp->icmp_pptr);
344 }
345 break;
346
347 case ICMP_MASKREPLY:
348 TCHECK(dp->icmp_mask);
349 (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
453 }
454 break;
455
456 case ICMP_MASKREPLY:
457 TCHECK(dp->icmp_mask);
458 (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x",
350 (u_int32_t)ntohl(dp->icmp_mask));
459 (unsigned)ntohl(dp->icmp_mask));
351 break;
352
460 break;
461
462 case ICMP_TSTAMP:
463 TCHECK(dp->icmp_seq);
464 (void)snprintf(buf, sizeof(buf),
465 "time stamp query id %u seq %u",
466 (unsigned)ntohs(dp->icmp_id),
467 (unsigned)ntohs(dp->icmp_seq));
468 break;
469
470 case ICMP_TSTAMPREPLY:
471 TCHECK(dp->icmp_ttime);
472 (void)snprintf(buf, sizeof(buf),
473 "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx",
474 (unsigned)ntohs(dp->icmp_id),
475 (unsigned)ntohs(dp->icmp_seq),
476 (unsigned long)ntohl(dp->icmp_otime),
477 (unsigned long)ntohl(dp->icmp_rtime),
478 (unsigned long)ntohl(dp->icmp_ttime));
479 break;
480
353 default:
354 str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
355 break;
356 }
357 (void)printf("icmp: %s", str);
358 if (vflag) {
359 if (TTEST2(*bp, plen)) {
360 if (in_cksum((u_short*)dp, plen, 0))

--- 14 unchanged lines hidden ---
481 default:
482 str = tok2str(icmp2str, "type-#%d", dp->icmp_type);
483 break;
484 }
485 (void)printf("icmp: %s", str);
486 if (vflag) {
487 if (TTEST2(*bp, plen)) {
488 if (in_cksum((u_short*)dp, plen, 0))

--- 14 unchanged lines hidden ---