📄 etharp.h
字号:
#ifndef __NETIF_ETHARP_H__#define __NETIF_ETHARP_H__#ifndef ETH_PAD_SIZE#define ETH_PAD_SIZE 0#endif#include "lwip/pbuf.h"#include "lwip/ip_addr.h"#include "lwip/netif.h"#include "lwip/ip.h"/** 5 seconds period */#define ARP_TMR_INTERVAL 5000#define ETHTYPE_ARP 0x0806#define ETHTYPE_IP 0x0800#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/bpstruct.h"#endifPACK_STRUCT_BEGINstruct eth_addr { PACK_STRUCT_FIELD(u8_t addr[6]);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/epstruct.h"#endif#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/bpstruct.h"#endifPACK_STRUCT_BEGINstruct eth_hdr {#if ETH_PAD_SIZE PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);#endif PACK_STRUCT_FIELD(struct eth_addr dest); PACK_STRUCT_FIELD(struct eth_addr src); PACK_STRUCT_FIELD(u16_t type);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/epstruct.h"#endif#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/bpstruct.h"#endifPACK_STRUCT_BEGINstruct etharp_hdr { PACK_STRUCT_FIELD(struct eth_hdr ethhdr); PACK_STRUCT_FIELD(u16_t hwtype); PACK_STRUCT_FIELD(u16_t proto); PACK_STRUCT_FIELD(u16_t _hwlen_protolen); /*硬件地址长度:6AND协议地址长度:4*/ PACK_STRUCT_FIELD(u16_t opcode); PACK_STRUCT_FIELD(struct eth_addr shwaddr); PACK_STRUCT_FIELD(struct ip_addr2 sipaddr); PACK_STRUCT_FIELD(struct eth_addr dhwaddr); PACK_STRUCT_FIELD(struct ip_addr2 dipaddr);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/epstruct.h"#endif#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/bpstruct.h"#endifPACK_STRUCT_BEGINstruct ethip_hdr { PACK_STRUCT_FIELD(struct eth_hdr eth); PACK_STRUCT_FIELD(struct ip_hdr ip);} PACK_STRUCT_STRUCT;PACK_STRUCT_END#ifdef PACK_STRUCT_USE_INCLUDES# include "arch/epstruct.h"#endifvoid etharp_init(void);void etharp_tmr(void);void etharp_ip_input(struct netif *netif, struct pbuf *p);void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p);err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);err_t etharp_request(struct netif *netif, struct ip_addr *ipaddr);//from 0.5.3version added by dy/* arp_loopup() is called to do an IP address -> Ethernet address translation. If the function returns NULL, there is no mapping and the arp_query() function should be called. */struct eth_addr *arp_lookup(struct ip_addr *ipaddr);/* Constructs an ARP query packet for the given IP address. The function returns a pbuf that contains the reply and that should be sent out on the Ethernet. */struct pbuf *arp_query(struct netif *netif, struct eth_addr *ethaddr, struct ip_addr *ipaddr);#endif /* __NETIF_ARP_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -