#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
* 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 */
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
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;
}
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)));
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]");
}