X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/dff10c7f70d539c431a1eba9ab5e076d8b0f5c8e..cff875676ce4da91a345ca476e3da65819c58d46:/print-icmp.c diff --git a/print-icmp.c b/print-icmp.c index 38c1fa8f..f7b1b2b9 100644 --- a/print-icmp.c +++ b/print-icmp.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.44 2000-01-17 06:24:25 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-icmp.c,v 1.48 2000-07-01 03:39:03 assar Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -32,10 +32,8 @@ static const char rcsid[] = #include #include -#if __STDC__ struct mbuf; struct rtentry; -#endif #include #include @@ -234,20 +232,20 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) break; case ICMP_UNREACH_NEEDFRAG: - { + { register const struct mtu_discovery *mp; - mp = (struct mtu_discovery *)&dp->icmp_void; mtu = EXTRACT_16BITS(&mp->nexthopmtu); - if (mtu) - (void)snprintf(buf, sizeof(buf), - "%s unreachable - need to frag (mtu %d)", - ipaddr_string(&dp->icmp_ip.ip_dst), mtu); - else - (void)snprintf(buf, sizeof(buf), - "%s unreachable - need to frag", - ipaddr_string(&dp->icmp_ip.ip_dst)); + if (mtu) { + (void)snprintf(buf, sizeof(buf), + "%s unreachable - need to frag (mtu %d)", + ipaddr_string(&dp->icmp_ip.ip_dst), mtu); + } else { + (void)snprintf(buf, sizeof(buf), + "%s unreachable - need to frag", + ipaddr_string(&dp->icmp_ip.ip_dst)); } + } break; default: @@ -269,12 +267,12 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) break; case ICMP_ROUTERADVERT: - { + { register const struct ih_rdiscovery *ihp; register const struct id_rdiscovery *idp; u_int lifetime, num, size; - (void)strcpy(buf, "router advertisement"); + (void)snprintf(buf, sizeof(buf), "router advertisement"); cp = buf + strlen(buf); ihp = (struct ih_rdiscovery *)&dp->icmp_void; @@ -282,18 +280,19 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) (void)strncpy(cp, " lifetime ", sizeof(buf) - (cp - buf)); cp = buf + strlen(buf); lifetime = EXTRACT_16BITS(&ihp->ird_lifetime); - if (lifetime < 60) + if (lifetime < 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u", lifetime); - else if (lifetime < 60 * 60) + } else if (lifetime < 60 * 60) { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u", lifetime / 60, lifetime % 60); - else + } else { (void)snprintf(cp, sizeof(buf) - (cp - buf), "%u:%02u:%02u", lifetime / 3600, (lifetime % 3600) / 60, lifetime % 60); + } cp = buf + strlen(buf); num = ihp->ird_addrnum; @@ -313,8 +312,9 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) ipaddr_string(&idp->ird_addr), EXTRACT_32BITS(&idp->ird_pref)); cp = buf + strlen(buf); + ++idp; } - } + } break; case ICMP_TIMXCEED: @@ -350,7 +350,24 @@ icmp_print(register const u_char *bp, u_int plen, register const u_char *bp2) case ICMP_MASKREPLY: TCHECK(dp->icmp_mask); (void)snprintf(buf, sizeof(buf), "address mask is 0x%08x", - (u_int32_t)ntohl(dp->icmp_mask)); + (unsigned)ntohl(dp->icmp_mask)); + break; + + case ICMP_TSTAMP: + TCHECK(dp->icmp_seq); + (void)sprintf(buf, "time stamp query id %u seq %u", + (unsigned)ntohs(dp->icmp_id), + (unsigned)ntohs(dp->icmp_seq)); + break; + + case ICMP_TSTAMPREPLY: + TCHECK(dp->icmp_ttime); + (void)sprintf(buf, "time stamp reply id %u seq %u : org 0x%lx recv 0x%lx xmit 0x%lx", + (unsigned)ntohs(dp->icmp_id), + (unsigned)ntohs(dp->icmp_seq), + (unsigned long)ntohl(dp->icmp_otime), + (unsigned long)ntohl(dp->icmp_rtime), + (unsigned long)ntohl(dp->icmp_ttime)); break; default: