2016-05-23 22:36:55 +08:00
|
|
|
/** @file
|
|
|
|
@brief ARP handler
|
|
|
|
|
|
|
|
This is not to be included by the application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-05-23 22:36:55 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ARP_H
|
|
|
|
#define __ARP_H
|
|
|
|
|
2017-07-24 21:23:14 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-06-07 16:52:23 +08:00
|
|
|
#if defined(CONFIG_NET_ARP)
|
|
|
|
|
2016-05-30 18:54:04 +08:00
|
|
|
#include <net/ethernet.h>
|
2016-05-23 22:36:55 +08:00
|
|
|
|
2017-07-20 21:29:45 +08:00
|
|
|
/**
|
|
|
|
* @brief Address resolution (ARP) library
|
|
|
|
* @defgroup arp ARP Library
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2017-04-10 19:03:41 +08:00
|
|
|
#define NET_ARP_HDR(pkt) ((struct net_arp_hdr *)net_pkt_ip_data(pkt))
|
2016-06-01 15:19:36 +08:00
|
|
|
|
2016-05-23 22:36:55 +08:00
|
|
|
struct net_arp_hdr {
|
2017-04-21 22:27:50 +08:00
|
|
|
u16_t hwtype; /* HTYPE */
|
|
|
|
u16_t protocol; /* PTYPE */
|
|
|
|
u8_t hwlen; /* HLEN */
|
|
|
|
u8_t protolen; /* PLEN */
|
|
|
|
u16_t opcode;
|
2016-05-23 22:36:55 +08:00
|
|
|
struct net_eth_addr src_hwaddr; /* SHA */
|
|
|
|
struct in_addr src_ipaddr; /* SPA */
|
|
|
|
struct net_eth_addr dst_hwaddr; /* THA */
|
|
|
|
struct in_addr dst_ipaddr; /* TPA */
|
|
|
|
} __packed;
|
|
|
|
|
|
|
|
#define NET_ARP_HTYPE_ETH 1
|
|
|
|
|
|
|
|
#define NET_ARP_REQUEST 1
|
|
|
|
#define NET_ARP_REPLY 2
|
|
|
|
|
2017-04-05 14:37:44 +08:00
|
|
|
struct net_pkt *net_arp_prepare(struct net_pkt *pkt);
|
|
|
|
enum net_verdict net_arp_input(struct net_pkt *pkt);
|
2016-06-03 18:01:42 +08:00
|
|
|
|
2017-04-22 14:13:23 +08:00
|
|
|
void net_arp_clear_cache(void);
|
2016-05-23 22:36:55 +08:00
|
|
|
void net_arp_init(void);
|
2016-06-07 16:52:23 +08:00
|
|
|
|
2017-07-20 21:29:45 +08:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2016-06-07 16:52:23 +08:00
|
|
|
#else /* CONFIG_NET_ARP */
|
|
|
|
|
2017-04-22 14:13:23 +08:00
|
|
|
#define net_arp_clear_cache(...)
|
2016-06-03 18:01:42 +08:00
|
|
|
#define net_arp_init(...)
|
2016-05-23 22:36:55 +08:00
|
|
|
|
2016-06-07 16:52:23 +08:00
|
|
|
#endif /* CONFIG_NET_ARP */
|
2016-05-23 22:36:55 +08:00
|
|
|
|
2017-07-24 21:23:14 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-07 16:52:23 +08:00
|
|
|
#endif /* __ARP_H */
|