在我的系统中
/usr/include/net/if_arp.h中arphdr的结构体定义如下
struct arphdr
{
unsigned short int ar_hrd;/* Format of hardware address. */
unsigned short int ar_pro;/* Format of protocol address. */
unsigned char ar_hln;/* Length of hardware address. */
unsigned char ar_pln;/* Length of protocol address. */
unsigned short int ar_op;/* ARP opcode (command). */
#if 0
/* Ethernet looks like this : This bit is variable sized
however... */
unsigned char __ar_sha[ETH_ALEN];/* Sender hardware address. */
unsigned char __ar_sip[4];/* Sender IP address. */
unsigned char __ar_tha[ETH_ALEN];/* Target hardware address. */
unsigned char __ar_tip[4];/* Target IP address. */
#endif
};
十分不解为什么要注释掉后面的部分
后来在/usr/include/netinet/if_ether.h找到
#include
__BEGIN_DECLS
/*
* Ethernet Address Resolution Protocol.
*
* See RFC 826 for protocol description. Structure below is adapted
* to resolving internet addresses. Field names used correspond to
* RFC 826.
*/
structether_arp {
structarphdr ea_hdr;/* fixed-size header */
u_int8_t arp_sha[ETH_ALEN];/* sender hardware address */
u_int8_t arp_spa[4];/* sender protocol address */
u_int8_t arp_tha[ETH_ALEN];/* target hardware address */
u_int8_t arp_tpa[4];/* target protocol address */
};
#definearp_hrdea_hdr.ar_hrd
#definearp_proea_hdr.ar_pro
#definearp_hlnea_hdr.ar_hln
#definearp_plnea_hdr.ar_pln
#definearp_opea_hdr.ar_op