2014-07-06 19:05:28 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* net/arp/arp.h
|
|
|
|
*
|
2024-09-11 14:39:39 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-07-06 19:05:28 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-07-06 19:05:28 +02:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-07-06 19:05:28 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __NET_ARP_ARP_H
|
|
|
|
#define __NET_ARP_ARP_H
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/* The Address Resolution Protocol ARP is used for mapping between IP
|
|
|
|
* addresses and link level addresses such as the Ethernet MAC
|
|
|
|
* addresses. ARP uses broadcast queries to ask for the link level
|
|
|
|
* address of a known IP address and the host which is configured with
|
|
|
|
* the IP address for which the query was meant, will respond with its
|
|
|
|
* link level address.
|
|
|
|
*
|
|
|
|
* Note: This ARP implementation only supports Ethernet.
|
|
|
|
*/
|
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2014-08-18 19:21:53 +02:00
|
|
|
#include <stdint.h>
|
2018-08-25 01:36:08 +02:00
|
|
|
#include <errno.h>
|
2014-08-18 23:24:51 +02:00
|
|
|
|
2022-11-28 08:55:18 +01:00
|
|
|
#include <netinet/arp.h>
|
2014-08-18 20:37:40 +02:00
|
|
|
#include <netinet/in.h>
|
2014-08-18 19:21:53 +02:00
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
#include <nuttx/net/netdev.h>
|
2020-02-01 08:17:32 +01:00
|
|
|
#include <nuttx/semaphore.h>
|
2014-08-18 23:24:51 +02:00
|
|
|
|
2022-12-03 16:03:29 +01:00
|
|
|
#include "devif/devif.h"
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2019-03-11 19:48:17 +01:00
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/* Configuration ************************************************************/
|
|
|
|
|
2016-06-11 22:14:08 +02:00
|
|
|
#ifndef CONFIG_DEBUG_FEATURES
|
2014-08-18 19:08:15 +02:00
|
|
|
# undef CONFIG_NET_ARP_DUMP
|
|
|
|
#endif
|
|
|
|
|
2014-08-18 22:29:02 +02:00
|
|
|
#ifndef CONFIG_ARP_SEND_MAXTRIES
|
|
|
|
# define CONFIG_ARP_SEND_MAXTRIES 5
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_ARP_SEND_DELAYMSEC
|
|
|
|
# define CONFIG_ARP_SEND_DELAYMSEC 20
|
|
|
|
#endif
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/* ARP Definitions **********************************************************/
|
|
|
|
|
|
|
|
#define ARP_REQUEST 1
|
|
|
|
#define ARP_REPLY 2
|
|
|
|
|
|
|
|
#define ARP_HWTYPE_ETH 1
|
|
|
|
|
|
|
|
#define RASIZE 4 /* Size of ROUTER ALERT */
|
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
/* Allocate a new ARP data callback */
|
|
|
|
|
net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.
Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-08-29 22:57:26 +02:00
|
|
|
#define arp_callback_alloc(dev) devif_callback_alloc(dev, \
|
|
|
|
&(dev)->d_conncb, \
|
|
|
|
&(dev)->d_conncb_tail)
|
2015-06-03 16:11:57 +02:00
|
|
|
#define arp_callback_free(dev,cb) devif_dev_callback_free(dev, cb)
|
2014-08-18 23:24:51 +02:00
|
|
|
|
2022-10-26 06:35:08 +02:00
|
|
|
/* This is a helper pointer for accessing the contents of the IP header */
|
|
|
|
|
2023-01-06 04:46:36 +01:00
|
|
|
#define ARPBUF ((FAR struct arp_hdr_s *)IPBUF(0))
|
|
|
|
#define ARPIPBUF ((FAR struct arp_iphdr_s *)IPBUF(0))
|
2022-10-26 06:35:08 +02:00
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/* ARP header -- Size 28 bytes */
|
|
|
|
|
|
|
|
struct arp_hdr_s
|
|
|
|
{
|
|
|
|
uint16_t ah_hwtype; /* 16-bit Hardware type (Ethernet=0x001) */
|
|
|
|
uint16_t ah_protocol; /* 16-bit Protocol type (IP=0x0800) */
|
|
|
|
uint8_t ah_hwlen; /* 8-bit Hardware address size (6) */
|
2023-02-17 12:26:18 +01:00
|
|
|
uint8_t ah_protolen; /* 8-bit Protocol address size (4) */
|
2014-08-18 19:08:15 +02:00
|
|
|
uint16_t ah_opcode; /* 16-bit Operation */
|
|
|
|
uint8_t ah_shwaddr[6]; /* 48-bit Sender hardware address */
|
2020-02-22 19:31:14 +01:00
|
|
|
uint16_t ah_sipaddr[2]; /* 32-bit Sender IP address */
|
2014-08-18 19:08:15 +02:00
|
|
|
uint8_t ah_dhwaddr[6]; /* 48-bit Target hardware address */
|
|
|
|
uint16_t ah_dipaddr[2]; /* 32-bit Target IP address */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IP header -- Size 20 or 24 bytes */
|
|
|
|
|
|
|
|
struct arp_iphdr_s
|
|
|
|
{
|
|
|
|
uint8_t eh_vhl; /* 8-bit Version (4) and header length (5 or 6) */
|
|
|
|
uint8_t eh_tos; /* 8-bit Type of service (e.g., 6=TCP) */
|
|
|
|
uint8_t eh_len[2]; /* 16-bit Total length */
|
|
|
|
uint8_t eh_ipid[2]; /* 16-bit Identification */
|
|
|
|
uint8_t eh_ipoffset[2]; /* 16-bit IP flags + fragment offset */
|
|
|
|
uint8_t eh_ttl; /* 8-bit Time to Live */
|
|
|
|
uint8_t eh_proto; /* 8-bit Protocol */
|
|
|
|
uint16_t eh_ipchksum; /* 16-bit Header checksum */
|
|
|
|
uint16_t eh_srcipaddr[2]; /* 32-bit Source IP address */
|
|
|
|
uint16_t eh_destipaddr[2]; /* 32-bit Destination IP address */
|
|
|
|
uint16_t eh_ipoption[2]; /* (optional) */
|
|
|
|
};
|
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
/* This structure holds the state of the send operation until it can be
|
2017-08-29 22:08:04 +02:00
|
|
|
* operated upon from the network driver poll.
|
2014-08-18 23:24:51 +02:00
|
|
|
*/
|
|
|
|
|
2024-01-22 03:20:46 +01:00
|
|
|
typedef CODE void (*arp_send_finish_cb_t)(FAR struct net_driver_s *dev,
|
|
|
|
int result);
|
2014-08-18 23:24:51 +02:00
|
|
|
struct arp_send_s
|
|
|
|
{
|
|
|
|
FAR struct devif_callback_s *snd_cb; /* Reference to callback instance */
|
2024-01-22 03:20:46 +01:00
|
|
|
FAR arp_send_finish_cb_t finish_cb; /* Reference to send finish callback */
|
2014-08-18 23:24:51 +02:00
|
|
|
sem_t snd_sem; /* Used to wake up the waiting thread */
|
|
|
|
uint8_t snd_retries; /* Retry count */
|
|
|
|
volatile bool snd_sent; /* True: if request sent */
|
|
|
|
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
2015-05-27 19:39:44 +02:00
|
|
|
int16_t snd_result; /* The result of the send operation */
|
2014-08-18 23:24:51 +02:00
|
|
|
in_addr_t snd_ipaddr; /* The IP address to be queried */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-08-19 15:47:32 +02:00
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
/* Used to notify a thread waiting for a particular ARP response */
|
|
|
|
|
|
|
|
struct arp_notify_s
|
|
|
|
{
|
|
|
|
FAR struct arp_notify_s *nt_flink; /* Supports singly linked list */
|
|
|
|
in_addr_t nt_ipaddr; /* Waited for IP address in the mapping */
|
|
|
|
sem_t nt_sem; /* Will wake up the waiter */
|
|
|
|
int nt_result; /* The result of the wait */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2022-11-28 08:55:18 +01:00
|
|
|
/* One entry in the ARP table (volatile!) */
|
|
|
|
|
|
|
|
struct arp_entry_s
|
|
|
|
{
|
|
|
|
in_addr_t at_ipaddr; /* IP address */
|
|
|
|
struct ether_addr at_ethaddr; /* Hardware address */
|
|
|
|
clock_t at_time; /* Time of last usage */
|
|
|
|
FAR struct net_driver_s *at_dev; /* The device driver structure */
|
|
|
|
};
|
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-09-05 17:10:48 +02:00
|
|
|
#ifdef CONFIG_NET_ARP
|
2014-08-18 20:37:40 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_format
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Format an ARP packet.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - Device structure
|
|
|
|
* ipaddr - Target IP address (32-bit)
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct net_driver_s; /* Forward reference */
|
|
|
|
void arp_format(FAR struct net_driver_s *dev, in_addr_t ipaddr);
|
|
|
|
|
2022-12-04 08:26:59 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* 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
|
2023-05-20 00:32:34 +02:00
|
|
|
# define arp_ipin(dev)
|
2022-12-04 08:26:59 +01:00
|
|
|
#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);
|
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_send
|
2014-08-18 23:24:51 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2015-02-02 17:49:50 +01:00
|
|
|
* The arp_send() call may be to send an ARP request to resolve an IPv4
|
|
|
|
* address. This function first checks if the IPv4 address is already in
|
|
|
|
* the ARP table. If so, then it returns success immediately.
|
2014-08-18 23:24:51 +02:00
|
|
|
*
|
2021-02-19 15:01:46 +01:00
|
|
|
* If the requested IPv4 address in not in the ARP table, then this
|
|
|
|
* function will send an ARP request, delay, then check if the IP address
|
|
|
|
* is now in the ARP table. It will repeat this sequence until either (1)
|
|
|
|
* the IP address mapping is now in the ARP table, or (2) a configurable
|
|
|
|
* number of timeouts occur without receiving the ARP replay.
|
2014-08-18 23:24:51 +02:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2014-08-18 23:24:51 +02:00
|
|
|
* ipaddr The IP address to be queried.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success and the IP address mapping can now be
|
|
|
|
* found in the ARP table. On error a negated errno value is returned:
|
|
|
|
*
|
|
|
|
* -ETIMEDOUT: The number or retry counts has been exceed.
|
|
|
|
* -EHOSTUNREACH: Could not find a route to the host
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the normal tasking context.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
int arp_send(in_addr_t ipaddr);
|
2014-08-19 15:47:32 +02:00
|
|
|
#else
|
|
|
|
# define arp_send(i) (0)
|
2014-08-18 23:24:51 +02:00
|
|
|
#endif
|
|
|
|
|
2024-01-22 03:20:46 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_send_async
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The arp_send_async() call may be to send an ARP request asyncly to
|
|
|
|
* resolve an IPv4 address.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* ipaddr The IP address to be queried.
|
|
|
|
* cb The callback when ARP send is finished, should not be NULL.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success the arp been sent to the driver.
|
|
|
|
* On error a negated errno value is returned:
|
|
|
|
*
|
|
|
|
* -ETIMEDOUT: The number or retry counts has been exceed.
|
|
|
|
* -EHOSTUNREACH: Could not find a route to the host
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the normal tasking context.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
int arp_send_async(in_addr_t ipaddr, arp_send_finish_cb_t cb);
|
|
|
|
#endif
|
|
|
|
|
2014-08-18 23:24:51 +02:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_poll
|
2014-08-18 23:24:51 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Poll all pending transfer for ARP requests to send.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the MAC device driver indirectly through
|
2022-06-05 17:34:03 +02:00
|
|
|
* devif_poll(). The network must be locked.
|
2014-08-18 23:24:51 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
int arp_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
|
2014-08-19 15:47:32 +02:00
|
|
|
#else
|
|
|
|
# define arp_poll(d,c) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_wait_setup
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called BEFORE an ARP request is sent. This function sets up the ARP
|
2017-05-11 21:35:56 +02:00
|
|
|
* response timeout before the ARP request is sent so that there is
|
2014-08-19 15:47:32 +02:00
|
|
|
* no race condition when arp_wait() is called.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from ARP send and executes in the normal
|
|
|
|
* tasking environment.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
void arp_wait_setup(in_addr_t ipaddr, FAR struct arp_notify_s *notify);
|
|
|
|
#else
|
|
|
|
# define arp_wait_setup(i,n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_wait_cancel
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Cancel any wait set after arp_wait_setup is called but before arm_wait()
|
|
|
|
* is called (arp_wait() will automatically cancel the wait).
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function may execute in the interrupt context when called from
|
|
|
|
* arp_wait().
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
int arp_wait_cancel(FAR struct arp_notify_s *notify);
|
|
|
|
#else
|
|
|
|
# define arp_wait_cancel(n) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_wait
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a ARP request is sent. This function will sleep
|
|
|
|
* until either: (1) the matching ARP response is received, or (2) a
|
|
|
|
* timeout occurs.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2020-02-23 09:50:23 +01:00
|
|
|
* This function is called from ARP send and must execute with the network
|
2015-02-02 21:48:11 +01:00
|
|
|
* un-locked.
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
2020-01-04 11:37:46 +01:00
|
|
|
int arp_wait(FAR struct arp_notify_s *notify, unsigned int timeout);
|
2014-08-19 15:47:32 +02:00
|
|
|
#else
|
|
|
|
# define arp_wait(n,t) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: arp_notify
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a ARP response is received in order to wake-up
|
|
|
|
* any threads that may be waiting for this particular ARP response.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the MAC device driver indirectly through
|
2022-12-04 08:01:53 +01:00
|
|
|
* arp_input() and will execute with the network locked.
|
2014-08-19 15:47:32 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_SEND
|
|
|
|
void arp_notify(in_addr_t ipaddr);
|
|
|
|
#else
|
|
|
|
# define arp_notify(i)
|
2014-08-18 23:24:51 +02:00
|
|
|
#endif
|
|
|
|
|
2014-08-19 00:35:20 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_find
|
|
|
|
*
|
|
|
|
* Description:
|
2018-08-25 01:36:08 +02:00
|
|
|
* Find the ARP entry corresponding to this IP address which may or may
|
|
|
|
* not be in the ARP table (it may, instead, be a local network device).
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2022-12-06 03:40:18 +01:00
|
|
|
* ipaddr - Refers to an IP address in network order
|
2018-08-25 14:47:10 +02:00
|
|
|
* ethaddr - Location to return the corresponding Ethernet MAN address.
|
|
|
|
* This address may be NULL. In that case, this function may be
|
|
|
|
* used simply to determine if the Ethernet MAC address is
|
|
|
|
* available.
|
2022-12-06 03:40:18 +01:00
|
|
|
* dev - Device structure
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
|
|
|
* Assumptions
|
2018-08-25 01:57:15 +02:00
|
|
|
* The network is locked to assure exclusive access to the ARP table.
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2018-08-25 14:47:10 +02:00
|
|
|
struct ether_addr; /* Forward reference */
|
2022-12-06 03:40:18 +01:00
|
|
|
int arp_find(in_addr_t ipaddr, FAR uint8_t *ethaddr,
|
|
|
|
FAR struct net_driver_s *dev);
|
2014-08-19 00:35:20 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_delete
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Remove an IP association from the ARP table
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2014-08-19 00:35:20 +02:00
|
|
|
* ipaddr - Refers to an IP address in network order
|
2022-12-06 03:40:18 +01:00
|
|
|
* dev - Device structure
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
|
|
|
* Assumptions
|
2018-08-25 01:57:15 +02:00
|
|
|
* The network is locked to assure exclusive access to the ARP table.
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2022-12-06 03:40:18 +01:00
|
|
|
int arp_delete(in_addr_t ipaddr, FAR struct net_driver_s *dev);
|
2014-08-19 00:35:20 +02:00
|
|
|
|
2021-11-18 06:29:25 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_cleanup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Clear the ARP table on the network device
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure
|
|
|
|
*
|
|
|
|
* Assumptions
|
|
|
|
* The network is locked to assure exclusive access to the ARP table.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void arp_cleanup(FAR struct net_driver_s *dev);
|
|
|
|
|
2014-08-19 00:35:20 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_update
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add the IP/HW address mapping to the ARP table -OR- change the IP
|
|
|
|
* address of an existing association.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2021-11-18 06:29:25 +01:00
|
|
|
* dev - The device driver structure
|
2016-02-08 18:17:22 +01:00
|
|
|
* ipaddr - The IP address as an inaddr_t
|
|
|
|
* ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN]
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) if the ARP table entry was successfully modified. A negated
|
|
|
|
* errno value is returned on any error.
|
|
|
|
*
|
|
|
|
* Assumptions
|
|
|
|
* The network is locked to assure exclusive access to the ARP table
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-11-18 06:29:25 +01:00
|
|
|
int arp_update(FAR struct net_driver_s *dev, in_addr_t ipaddr,
|
2022-12-06 03:40:18 +01:00
|
|
|
FAR const uint8_t *ethaddr);
|
2016-02-08 18:17:22 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_hdr_update
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Add the IP/HW address mapping to the ARP table -OR- change the IP
|
|
|
|
* address of an existing association.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2021-11-18 06:29:25 +01:00
|
|
|
* dev - The device driver structure
|
2014-08-19 00:35:20 +02:00
|
|
|
* pipaddr - Refers to an IP address uint16_t[2] in network order
|
|
|
|
* ethaddr - Refers to a HW address uint8_t[IFHWADDRLEN]
|
|
|
|
*
|
2016-02-08 18:17:22 +01:00
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) if the ARP table entry was successfully modified. A negated
|
|
|
|
* errno value is returned on any error.
|
|
|
|
*
|
2014-08-19 00:35:20 +02:00
|
|
|
* Assumptions
|
2016-02-08 18:17:22 +01:00
|
|
|
* The network is locked to assure exclusive access to the ARP table
|
2014-08-19 00:35:20 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2021-11-18 06:29:25 +01:00
|
|
|
void arp_hdr_update(FAR struct net_driver_s *dev, FAR uint16_t *pipaddr,
|
2022-12-06 03:40:18 +01:00
|
|
|
FAR const uint8_t *ethaddr);
|
2014-08-19 00:35:20 +02:00
|
|
|
|
2019-11-03 20:59:42 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_snapshot
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Take a snapshot of the current state of the ARP table.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* snapshot - Location to return the ARP table copy
|
|
|
|
* nentries - The size of the user provided 'dest' in entries, each of
|
|
|
|
* size sizeof(struct arp_entry_s)
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* On success, the number of entries actually copied is returned. Unused
|
|
|
|
* entries are not returned.
|
|
|
|
*
|
|
|
|
* Assumptions
|
|
|
|
* The network is locked to assure exclusive access to the ARP table
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETLINK_ROUTE
|
2022-12-11 15:06:50 +01:00
|
|
|
unsigned int arp_snapshot(FAR struct arpreq *snapshot,
|
2019-11-03 20:59:42 +01:00
|
|
|
unsigned int nentries);
|
2019-11-04 02:27:58 +01:00
|
|
|
#else
|
|
|
|
# define arp_snapshot(s,n) (0)
|
2019-11-03 20:59:42 +01:00
|
|
|
#endif
|
|
|
|
|
2014-08-18 19:08:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_dump
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump the contents of an ARP packet to the SYSLOG device
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* arp - A reference to the ARP header to be dumped.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ARP_DUMP
|
|
|
|
void arp_dump(FAR struct arp_hdr_s *arp);
|
|
|
|
#else
|
2014-08-19 15:47:32 +02:00
|
|
|
# define arp_dump(arp)
|
2014-08-18 19:08:15 +02:00
|
|
|
#endif
|
|
|
|
|
2024-01-22 03:20:46 +01:00
|
|
|
#ifdef CONFIG_NET_ARP_ACD
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_acd_update
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* interface of ARP Address Conflict Detection monitor
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void arp_acd_update(FAR struct net_driver_s *dev);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_acd_set_addr
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* setting address interface of ARP Address Conflict Detection
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void arp_acd_set_addr(FAR struct net_driver_s *dev);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: arp_acd_setup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* set up interface of ARP Address Conflict Detection
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void arp_acd_setup(FAR struct net_driver_s *dev);
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_ARP_ACD */
|
|
|
|
|
2014-07-06 19:05:28 +02:00
|
|
|
#else /* CONFIG_NET_ARP */
|
|
|
|
|
|
|
|
/* If ARP is disabled, stub out all ARP interfaces */
|
|
|
|
|
2014-08-19 15:47:32 +02:00
|
|
|
# define arp_format(d,i);
|
2022-12-04 08:26:59 +01:00
|
|
|
# define arp_ipin(dev)
|
|
|
|
# define arp_out(dev)
|
2014-08-19 15:47:32 +02:00
|
|
|
# define arp_send(i) (0)
|
|
|
|
# define arp_poll(d,c) (0)
|
|
|
|
# define arp_wait_setup(i,n)
|
|
|
|
# define arp_wait_cancel(n) (0)
|
|
|
|
# define arp_wait(n,t) (0)
|
|
|
|
# define arp_notify(i)
|
2022-12-06 03:40:18 +01:00
|
|
|
# define arp_find(i,e,d) (-ENOSYS)
|
|
|
|
# define arp_delete(i,d) (-ENOSYS)
|
2021-11-18 06:29:25 +01:00
|
|
|
# define arp_cleanup(d)
|
|
|
|
# define arp_update(d,i,m);
|
|
|
|
# define arp_hdr_update(d,i,m);
|
2019-11-04 02:27:58 +01:00
|
|
|
# define arp_snapshot(s,n) (0)
|
2014-08-19 15:47:32 +02:00
|
|
|
# define arp_dump(arp)
|
2014-07-06 19:05:28 +02:00
|
|
|
|
|
|
|
#endif /* CONFIG_NET_ARP */
|
2014-08-18 19:08:15 +02:00
|
|
|
#endif /* __NET_ARP_ARP_H */
|