1、ARP报文格式
1.1、ARP报文格式
ARP报文的格式如下:
(具体各字段的含义参考《TCP/IP详解卷 1:协议》第4章 ARP:地址解析协议)
1.2、内核定义
op定义如下:
#define ARPOP_REQUEST 1 /* ARP request */
#define ARPOP_REPLY 2 /* ARP reply */
协议类型定义如下:
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#define ETH_P_ARP 0x0806 /* Address Resolution packet */
2、ARP报文的创建(arp_create)
2.1、ARP首部结构体
struct arphdr {
__be16 ar_hrd; /* format of hardware address */
__be16 ar_pro; /* format of protocol address */
unsigned char ar_hln; /* length of hardware address */
unsigned char ar_pln; /* length of protocol address */
__be16 ar_op; /* ARP opcode (command) */
};