net/arp: Move arp_ipin and arp_out to private header file
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
c6e9edcbb6
commit
43bda3282f
5 changed files with 57 additions and 57 deletions
|
@ -108,28 +108,6 @@ extern "C"
|
|||
|
||||
struct net_driver_s; /* Forward reference */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_ipin
|
||||
*
|
||||
* Description:
|
||||
* The arp_ipin() function should be called by Ethernet device drivers
|
||||
* whenever an IP packet arrives from the network. The function will
|
||||
* check if the address is in the ARP cache, and if so the ARP cache entry
|
||||
* will be refreshed.
|
||||
* If no ARP cache entry was found, a new one is created.
|
||||
*
|
||||
* This function expects that an IP packet with an Ethernet header is
|
||||
* present in the d_buf buffer and that the length of the packet is in the
|
||||
* d_len field.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_ARP_IPIN
|
||||
void arp_ipin(FAR struct net_driver_s *dev);
|
||||
#else
|
||||
# define arp_ipin(dev)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_input
|
||||
*
|
||||
|
@ -156,42 +134,11 @@ void arp_ipin(FAR struct net_driver_s *dev);
|
|||
|
||||
void arp_input(FAR struct net_driver_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_out
|
||||
*
|
||||
* Description:
|
||||
* This function should be called before sending out an IPv4 packet. The
|
||||
* function checks the destination IPv4 address of the IPv4 packet to see
|
||||
* what Ethernet MAC address that should be used as a destination MAC
|
||||
* address on the Ethernet.
|
||||
*
|
||||
* If the destination IPv4 address is in the local network (determined
|
||||
* by logical ANDing of netmask and our IPv4 address), the function
|
||||
* checks the ARP cache to see if an entry for the destination IPv4
|
||||
* address is found. If so, an Ethernet header is pre-pended at the
|
||||
* beginning of the packet and the function returns.
|
||||
*
|
||||
* If no ARP cache entry is found for the destination IIPv4P address, the
|
||||
* packet in the d_buf is replaced by an ARP request packet for the
|
||||
* IPv4 address. The IPv4 packet is dropped and it is assumed that the
|
||||
* higher level protocols (e.g., TCP) eventually will retransmit the
|
||||
* dropped packet.
|
||||
*
|
||||
* Upon return in either the case, a packet to be sent is present in the
|
||||
* d_buf buffer and the d_len field holds the length of the Ethernet
|
||||
* frame that should be transmitted.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void arp_out(FAR struct net_driver_s *dev);
|
||||
|
||||
#else /* CONFIG_NET_ARP */
|
||||
|
||||
/* If ARP is disabled, stub out all ARP interfaces */
|
||||
|
||||
# define arp_ipin(dev)
|
||||
# define arp_input(dev)
|
||||
# define arp_out(dev)
|
||||
# define arp_input(dev)
|
||||
|
||||
#endif /* CONFIG_NET_ARP */
|
||||
|
||||
|
|
|
@ -180,6 +180,57 @@ struct arp_notify_s
|
|||
struct net_driver_s; /* Forward reference */
|
||||
void arp_format(FAR struct net_driver_s *dev, in_addr_t ipaddr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_ipin
|
||||
*
|
||||
* Description:
|
||||
* The arp_ipin() function should be called by Ethernet device drivers
|
||||
* whenever an IP packet arrives from the network. The function will
|
||||
* check if the address is in the ARP cache, and if so the ARP cache entry
|
||||
* will be refreshed.
|
||||
* If no ARP cache entry was found, a new one is created.
|
||||
*
|
||||
* This function expects that an IP packet with an Ethernet header is
|
||||
* present in the d_buf buffer and that the length of the packet is in the
|
||||
* d_len field.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_ARP_IPIN
|
||||
void arp_ipin(FAR struct net_driver_s *dev);
|
||||
#else
|
||||
# define arp_ipin(dev)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_out
|
||||
*
|
||||
* Description:
|
||||
* This function should be called before sending out an IPv4 packet. The
|
||||
* function checks the destination IPv4 address of the IPv4 packet to see
|
||||
* what Ethernet MAC address that should be used as a destination MAC
|
||||
* address on the Ethernet.
|
||||
*
|
||||
* If the destination IPv4 address is in the local network (determined
|
||||
* by logical ANDing of netmask and our IPv4 address), the function
|
||||
* checks the ARP cache to see if an entry for the destination IPv4
|
||||
* address is found. If so, an Ethernet header is pre-pended at the
|
||||
* beginning of the packet and the function returns.
|
||||
*
|
||||
* If no ARP cache entry is found for the destination IIPv4P address, the
|
||||
* packet in the d_buf is replaced by an ARP request packet for the
|
||||
* IPv4 address. The IPv4 packet is dropped and it is assumed that the
|
||||
* higher level protocols (e.g., TCP) eventually will retransmit the
|
||||
* dropped packet.
|
||||
*
|
||||
* Upon return in either the case, a packet to be sent is present in the
|
||||
* d_buf buffer and the d_len field holds the length of the Ethernet
|
||||
* frame that should be transmitted.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void arp_out(FAR struct net_driver_s *dev);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arp_send
|
||||
*
|
||||
|
@ -482,6 +533,8 @@ void arp_dump(FAR struct arp_hdr_s *arp);
|
|||
/* If ARP is disabled, stub out all ARP interfaces */
|
||||
|
||||
# define arp_format(d,i);
|
||||
# define arp_ipin(dev)
|
||||
# define arp_out(dev)
|
||||
# define arp_send(i) (0)
|
||||
# define arp_poll(d,c) (0)
|
||||
# define arp_wait_setup(i,n)
|
||||
|
|
|
@ -92,9 +92,9 @@
|
|||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/netstats.h>
|
||||
#include <nuttx/net/arp.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "arp/arp.h"
|
||||
#include "inet/inet.h"
|
||||
#include "tcp/tcp.h"
|
||||
#include "udp/udp.h"
|
||||
|
|
|
@ -171,7 +171,7 @@ void neighbor_ethernet_out(FAR struct net_driver_s *dev);
|
|||
* Input Parameters:
|
||||
* snapshot - Location to return the Neighbor table copy
|
||||
* nentries - The size of the user provided 'dest' in entries, each of
|
||||
* size sizeof(struct arp_entry_s)
|
||||
* size sizeof(struct neighbor_entry_s)
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the number of entries actually copied is returned. Unused
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
* Input Parameters:
|
||||
* snapshot - Location to return the Neighbor table copy
|
||||
* nentries - The size of the user provided 'dest' in entries, each of
|
||||
* size sizeof(struct arp_entry_s)
|
||||
* size sizeof(struct neighbor_entry_s)
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the number of entries actually copied is returned. Unused
|
||||
|
|
Loading…
Reference in a new issue