arp和rarp

/* ARP protocol opcodes. */
#define    ARPOP_REQUEST    1        /* ARP request.  */
#define    ARPOP_REPLY    2        /* ARP reply.  */
#define    ARPOP_RREQUEST    3        /* RARP request.  */
#define    ARPOP_RREPLY    4        /* RARP reply.  */
#define    ARPOP_InREQUEST    8        /* InARP request.  */
#define    ARPOP_InREPLY    9        /* InARP reply.  */
#define    ARPOP_NAK    10        /* (ATM)ARP NAK.  */

struct arphdr         //arp分组格式参考TCP/IP详解,rarp分组格式和rap基本一致,差别在帧类型上和操作代码
  {
    unsigned short int ar_hrd;        /* Format of hardware address.  */硬件类型:1表示以太网
    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.  */发送端IP地址
    unsigned char __ar_tha[ETH_ALEN];    /* Target hardware address.  */目的以太网地址
    unsigned char __ar_tip[4];        /* Target IP address.  */目的IP地址
#endif
  };//net/if_arp.h中

struct    ether_arp {
    struct    arphdr 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 */
};//在netinet/if_ether.h
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值