]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-arp.c
Regenerate.
[tcpdump] / print-arp.c
index cbeb47af32386ef0018eb1dff474c14e4be5e5c3..240ca22aaf36135d0982c9652afef92a21578e61 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.50 2001-06-18 09:12:28 itojun Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-arp.c,v 1.52 2002-02-25 09:40:32 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -52,7 +52,7 @@ static const char rcsid[] =
  * arp_tha and arp_tpa in that order, according to the lengths
  * specified.  Field names used correspond to RFC 826.
  */
-struct arphdr {
+struct arp_pkthdr {
        u_short ar_hrd;         /* format of hardware address */
 #define ARPHRD_ETHER   1       /* ethernet hardware format */
 #define ARPHRD_IEEE802 6       /* token-ring hardware format */
@@ -80,10 +80,10 @@ struct      arphdr {
        u_char  ar_tha[];       /* target hardware address */
        u_char  ar_tpa[];       /* target protocol address */
 #endif
-#define ar_sha(ap)     (((caddr_t)((ap)+1))+0)
-#define ar_spa(ap)     (((caddr_t)((ap)+1))+  (ap)->ar_hln)
-#define ar_tha(ap)     (((caddr_t)((ap)+1))+  (ap)->ar_hln+(ap)->ar_pln)
-#define ar_tpa(ap)     (((caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
+#define ar_sha(ap)     (((const caddr_t)((ap)+1))+0)
+#define ar_spa(ap)     (((const caddr_t)((ap)+1))+  (ap)->ar_hln)
+#define ar_tha(ap)     (((const caddr_t)((ap)+1))+  (ap)->ar_hln+(ap)->ar_pln)
+#define ar_tpa(ap)     (((const caddr_t)((ap)+1))+2*(ap)->ar_hln+(ap)->ar_pln)
 };
 
 #define ARP_HDRLEN     8
@@ -103,17 +103,14 @@ static u_char ezero[6];
 void
 arp_print(const u_char *bp, u_int length, u_int caplen)
 {
-       const struct arphdr *ap;
+       const struct arp_pkthdr *ap;
        u_short pro, hrd, op;
 
-       ap = (struct arphdr *)bp;
-       if ((u_char *)(ap + 1) > snapend)  {
-               printf("[|arp]");
-               return;
-       }
-       if ((u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
+       ap = (const struct arp_pkthdr *)bp;
+       TCHECK(*ap);
+       if ((const u_char *)(ar_tpa(ap) + PLN(ap)) > snapend) {
                (void)printf("truncated-arp");
-               default_print((u_char *)ap, length);
+               default_print((const u_char *)ap, length);
                return;
        }
 
@@ -132,7 +129,7 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
 
        case ARPOP_REQUEST:
                (void)printf("arp who-has %s", ipaddr_string(TPA(ap)));
-               if (memcmp((char *)ezero, (char *)THA(ap), HLN(ap)) != 0)
+               if (memcmp((const char *)ezero, (const char *)THA(ap), HLN(ap)) != 0)
                        (void)printf(" (%s)",
                            linkaddr_string(THA(ap), HLN(ap)));
                (void)printf(" tell %s", ipaddr_string(SPA(ap)));
@@ -157,9 +154,12 @@ arp_print(const u_char *bp, u_int length, u_int caplen)
 
        default:
                (void)printf("arp-#%d", op);
-               default_print((u_char *)ap, caplen);
+               default_print((const u_char *)ap, caplen);
                return;
        }
        if (hrd != ARPHRD_ETHER)
                printf(" hardware #%d", hrd);
+       return;
+trunc:
+       (void)printf("[|arp]");
 }