eth.h

来自「ARP协议,含ARP」· C头文件 代码 · 共 56 行

H
56
字号
#ifndef _ETH_H_
#define _ETH_H_
#include "typedef.h"

#define MAC_ADDR_LEN 6
#define IP_ADDR_LEN 4

#define ETH_FRAME_ARP 0x0608
#define ETH_FRAME_IP   0x0008

#define MIN_ETH_PACK_LEN    60 // expect 4 bytes checksum
#define MAX_ETH_PACK_LEN    1500

#define ETH_UDP_HEAD_SIZE   (sizeof (struct _eth_udp))
#define ETH_HEAD_SIZE       (sizeof (struct _eth_head))


#define ETH_OPEN                    0
#define ETH_10M                     1
#define ETH_100M                    2

#define ETH_FULL_DUPLEX             0
#define ETH_HALF_DUPLEX             1


struct _eth_head {
    uc dst_mac[6];
    uc src_mac[6];
    us frame_type;
};

struct _eth_arp
{
    //以太网头部
    uc dst_mac[6];
    uc src_mac[6];
    us frame_type;
    
    //ARP头部
    us hard_type;
    us prot_type;
    uc hard_addr_len;
    uc prot_addr_len;
    us op;
    uc src_mac_addr[6];
    uc src_ip_addr[4];
    uc dst_mac_addr[6];
    uc dst_ip_addr[4];

};


void eth_recv_msg(uc *msg,us len);
void eth_send_msg(struct _mem_block *p);

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?