2015-01-14 23:10:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* net/icmpv6/icmpv6.h
|
|
|
|
*
|
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
|
2015-01-14 23:10:38 +01:00
|
|
|
*
|
2021-02-19 12:45:37 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-01-14 23:10:38 +01: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.
|
2015-01-14 23:10:38 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __NET_ICMPv6_ICMPv6_H
|
|
|
|
#define __NET_ICMPv6_ICMPv6_H
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2017-10-24 19:23:08 +02:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <queue.h>
|
|
|
|
#include <assert.h>
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
#include <nuttx/mm/iob.h>
|
2015-01-14 23:10:38 +01:00
|
|
|
#include <nuttx/net/ip.h>
|
2017-10-24 19:23:08 +02:00
|
|
|
#include <nuttx/net/netdev.h>
|
2020-02-01 08:17:32 +01:00
|
|
|
#include <nuttx/semaphore.h>
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2018-11-09 18:25:57 +01:00
|
|
|
#if defined(CONFIG_NET_ICMPv6) && !defined(CONFIG_NET_ICMPv6_NO_STACK)
|
2015-01-14 23:10:38 +01:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2018-11-09 18:25:57 +01:00
|
|
|
#define NET_ICMPv6_HAVE_STACK 1
|
|
|
|
|
2015-02-02 20:44:31 +01:00
|
|
|
/* Allocate a new ICMPv6 data callback */
|
|
|
|
|
2019-03-19 16:43:32 +01:00
|
|
|
#define icmpv6_callback_alloc(dev, conn) \
|
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
|
|
|
devif_callback_alloc((dev), &(conn)->list, &(conn)->list_tail)
|
2019-03-19 16:43:32 +01:00
|
|
|
#define icmpv6_callback_free(dev, conn, cb) \
|
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
|
|
|
devif_conn_callback_free((dev), (cb), &(conn)->list, &(conn)->list_tail)
|
2015-02-02 20:44:31 +01:00
|
|
|
|
2015-01-14 23:10:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
struct net_driver_s; /* Forward reference */
|
|
|
|
struct socket; /* Forward reference */
|
|
|
|
struct sockaddr; /* Forward reference */
|
|
|
|
struct pollfd; /* Forward reference */
|
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
/* Representation of a IPPROTO_ICMP socket connection */
|
|
|
|
|
|
|
|
struct devif_callback_s; /* Forward reference */
|
2015-02-02 18:34:51 +01:00
|
|
|
|
2019-12-31 16:26:14 +01:00
|
|
|
/* This is a container that holds the poll-related information */
|
|
|
|
|
|
|
|
struct icmpv6_poll_s
|
|
|
|
{
|
|
|
|
FAR struct socket *psock; /* IPPROTO_ICMP6 socket structure */
|
|
|
|
FAR struct pollfd *fds; /* Needed to handle poll events */
|
|
|
|
FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
|
|
|
|
};
|
|
|
|
|
2015-02-02 18:34:51 +01:00
|
|
|
struct icmpv6_conn_s
|
|
|
|
{
|
2019-09-01 16:47:01 +02:00
|
|
|
/* Common prologue of all connection structures. */
|
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
dq_entry_t node; /* Supports a double linked list */
|
2019-09-01 16:47:01 +02:00
|
|
|
|
|
|
|
/* This is a list of ICMPV6 callbacks. Each callback represents a thread
|
|
|
|
* that is stalled, waiting for a device-specific event.
|
|
|
|
*/
|
|
|
|
|
|
|
|
FAR struct devif_callback_s *list;
|
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
|
|
|
FAR struct devif_callback_s *list_tail;
|
2019-09-01 16:47:01 +02:00
|
|
|
|
|
|
|
/* ICMPv6-specific content follows */
|
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
uint16_t id; /* ICMPv6 ECHO request ID */
|
|
|
|
uint8_t nreqs; /* Number of requests with no response received */
|
|
|
|
uint8_t crefs; /* Reference counts on this instance */
|
|
|
|
|
|
|
|
/* The device that the ICMPv6 request was sent on */
|
|
|
|
|
|
|
|
FAR struct net_driver_s *dev; /* Needed to free the callback structure */
|
|
|
|
|
|
|
|
/* ICMPv6 response read-ahead list. A singly linked list of type struct
|
|
|
|
* iob_qentry_s where the ICMPv6 read-ahead data for the current ID is
|
|
|
|
* retained.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct iob_queue_s readahead; /* Read-ahead buffering */
|
2019-12-31 16:26:14 +01:00
|
|
|
|
|
|
|
/* The following is a list of poll structures of threads waiting for
|
|
|
|
* socket events.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct icmpv6_poll_s pollinfo[CONFIG_NET_ICMPv6_NPOLLWAITERS];
|
2015-02-02 18:34:51 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-02-02 20:44:31 +01:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
2015-02-03 20:25:28 +01:00
|
|
|
/* Used to notify a thread waiting for a particular Neighbor Advertisement */
|
2015-02-02 18:34:51 +01:00
|
|
|
|
|
|
|
struct icmpv6_notify_s
|
|
|
|
{
|
2018-02-23 14:54:06 +01:00
|
|
|
FAR struct icmpv6_notify_s *nt_flink; /* Supports singly linked list */
|
|
|
|
net_ipv6addr_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 */
|
2015-02-02 18:34:51 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-02-03 20:25:28 +01:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
|
|
/* Used to notify a thread waiting for a particular Router Advertisement */
|
|
|
|
|
|
|
|
struct icmpv6_rnotify_s
|
|
|
|
{
|
2018-02-23 14:54:06 +01:00
|
|
|
FAR struct icmpv6_rnotify_s *rn_flink; /* Supports singly linked list */
|
|
|
|
char rn_ifname[IFNAMSIZ]; /* Device name */
|
|
|
|
sem_t rn_sem; /* Will wake up the waiter */
|
|
|
|
int rn_result; /* The result of the wait */
|
2015-02-03 20:25:28 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2015-01-14 23:10:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
# define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
# define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
/* PF_INET6 socket address family, IPPROTO_ICMP6 protocol interface */
|
|
|
|
|
|
|
|
EXTERN const struct sock_intf_s g_icmpv6_sockif;
|
|
|
|
#endif
|
|
|
|
|
2015-01-14 23:10:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-01-20 21:37:02 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_input
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle incoming ICMPv6 input
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2018-11-05 15:56:07 +01:00
|
|
|
* dev - The device driver structure containing the received ICMPv6
|
|
|
|
* packet
|
|
|
|
* iplen - The size of the IPv6 header. This may be larger than
|
|
|
|
* IPv6_HDRLEN the IPv6 header if IPv6 extension headers are
|
|
|
|
* present.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-01-20 21:37:02 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 23:08:38 +02:00
|
|
|
* The network is locked.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2018-11-05 15:56:07 +01:00
|
|
|
void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen);
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2015-01-20 21:37:02 +01:00
|
|
|
/****************************************************************************
|
2015-02-02 17:49:50 +01:00
|
|
|
* Name: icmpv6_neighbor
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2015-02-02 17:49:50 +01:00
|
|
|
* The icmpv6_solicit() call may be to send an ICMPv6 Neighbor
|
|
|
|
* Solicitation to resolve an IPv6 address. This function first checks if
|
|
|
|
* the IPv6 address is already in the Neighbor Table. If so, then it
|
|
|
|
* returns success immediately.
|
|
|
|
*
|
|
|
|
* If the requested IPv6 address in not in the Neighbor Table, then this
|
|
|
|
* function will send the Neighbor Solicitation, delay, then check if the
|
|
|
|
* IP address is now in the Neighbor able. It will repeat this sequence
|
2015-02-02 18:34:51 +01:00
|
|
|
* until either (1) the IPv6 address mapping is now in the Neighbor table,
|
2015-02-02 17:49:50 +01:00
|
|
|
* or (2) a configurable number of timeouts occur without receiving the
|
|
|
|
* ICMPv6 Neighbor Advertisement.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2015-02-02 17:49:50 +01:00
|
|
|
* ipaddr The IPv6 address to be queried.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
2015-02-02 17:49:50 +01:00
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success and the IP address mapping can now be
|
2021-02-19 15:01:46 +01:00
|
|
|
* found in the Neighbor Table.
|
|
|
|
* On error a negated errno value is returned:
|
2015-02-02 17:49:50 +01:00
|
|
|
*
|
|
|
|
* -ETIMEDOUT: The number or retry counts has been exceed.
|
|
|
|
* -EHOSTUNREACH: Could not find a route to the host
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-02-02 17:49:50 +01:00
|
|
|
* This function is called from the normal tasking context.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2015-02-02 20:44:31 +01:00
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
|
|
|
int icmpv6_neighbor(const net_ipv6addr_t ipaddr);
|
2015-02-02 17:49:50 +01:00
|
|
|
#else
|
|
|
|
# define icmpv6_neighbor(i) (0)
|
|
|
|
#endif
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2015-01-20 21:37:02 +01:00
|
|
|
/****************************************************************************
|
2015-02-02 17:49:50 +01:00
|
|
|
* Name: icmpv6_poll
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
* Description:
|
2017-10-24 19:23:08 +02:00
|
|
|
* Poll a UDP "connection" structure for availability of ICMPv6 TX data
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2015-01-20 21:37:02 +01:00
|
|
|
* dev - The device driver structure to use in the send operation
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-01-20 21:37:02 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2017-08-29 23:08:38 +02:00
|
|
|
* The network is locked.
|
2015-01-20 21:37:02 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
#if defined(CONFIG_NET_ICMPv6_SOCKET) || defined(CONFIG_NET_ICMPv6_NEIGHBOR)
|
2019-03-19 16:43:32 +01:00
|
|
|
void icmpv6_poll(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct icmpv6_conn_s *conn);
|
2015-02-02 17:49:50 +01:00
|
|
|
#endif
|
2015-01-14 23:10:38 +01:00
|
|
|
|
2015-01-20 21:37:02 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_solicit
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to send an ICMPv6 Neighbor Solicitation message
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2019-03-19 16:43:32 +01:00
|
|
|
* dev - Reference to a device driver structure
|
2015-01-20 21:37:02 +01:00
|
|
|
* ipaddr - IP address of Neighbor to be solicited
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-01-20 21:37:02 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void icmpv6_solicit(FAR struct net_driver_s *dev,
|
|
|
|
FAR const net_ipv6addr_t ipaddr);
|
|
|
|
|
2015-02-03 20:25:28 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_rsolicit
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Set up to send an ICMPv6 Router Solicitation message. This version
|
|
|
|
* is for a standalone solicitation. If formats:
|
|
|
|
*
|
|
|
|
* - The IPv6 header
|
|
|
|
* - The ICMPv6 Neighbor Router Message
|
|
|
|
*
|
|
|
|
* The device IP address should have been set to the link local address
|
|
|
|
* prior to calling this function.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2018-11-09 22:41:23 +01:00
|
|
|
* dev - Reference to a device driver structure
|
2015-02-03 20:25:28 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-02-03 20:25:28 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
|
|
void icmpv6_rsolicit(FAR struct net_driver_s *dev);
|
|
|
|
#endif
|
|
|
|
|
2015-02-04 22:43:54 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_advertise
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send an ICMPv6 Neighbor Advertisement
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2015-02-04 22:43:54 +01:00
|
|
|
* dev - The device driver structure containing the outgoing ICMPv6 packet
|
|
|
|
* buffer
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-02-04 23:13:27 +01:00
|
|
|
* None.
|
2015-02-04 22:43:54 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-02-04 23:13:27 +01:00
|
|
|
void icmpv6_advertise(FAR struct net_driver_s *dev,
|
|
|
|
const net_ipv6addr_t destipaddr);
|
2015-02-04 22:43:54 +01:00
|
|
|
|
2015-02-05 16:43:29 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_radvertise
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send an ICMPv6 Router Advertisement
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2015-02-05 16:43:29 +01:00
|
|
|
* dev - The device driver structure containing the outgoing ICMPv6 packet
|
|
|
|
* buffer
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-02-05 16:43:29 +01:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* The network is locked
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_ROUTER
|
|
|
|
void icmpv6_radvertise(FAR struct net_driver_s *dev);
|
|
|
|
#endif
|
|
|
|
|
2015-02-02 20:44:31 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_wait_setup
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called BEFORE an Neighbor Solicitation is sent. This function sets up
|
2015-02-03 20:25:28 +01:00
|
|
|
* the Neighbor Advertisement timeout before the Neighbor Solicitation
|
2015-02-02 20:44:31 +01:00
|
|
|
* is sent so that there is no race condition when icmpv6_wait() is called.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2021-02-19 15:01:46 +01:00
|
|
|
* This function is called from icmpv6_neighbor() and executes in the
|
|
|
|
* normal tasking environment.
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
|
|
|
void icmpv6_wait_setup(const net_ipv6addr_t ipaddr,
|
|
|
|
FAR struct icmpv6_notify_s *notify);
|
|
|
|
#else
|
|
|
|
# define icmpv6_wait_setup(i,n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_wait_cancel
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Cancel any wait set after icmpv6_wait_setup is called but before
|
|
|
|
* icmpv6_wait()is called (icmpv6_wait() will automatically cancel the
|
|
|
|
* wait).
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function may execute in the interrupt context when called from
|
|
|
|
* icmpv6_wait().
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
|
|
|
int icmpv6_wait_cancel(FAR struct icmpv6_notify_s *notify);
|
|
|
|
#else
|
|
|
|
# define icmpv6_wait_cancel(n) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_wait
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a Neighbor Solicitation is sent. This function
|
|
|
|
* will sleep until either: (1) the matching Neighbor Advertisement is
|
|
|
|
* received, or (2) a timeout occurs.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
2015-02-02 21:50:16 +01:00
|
|
|
* This function is called from icmpv6_neighbor() and must execute with
|
|
|
|
* the network un-locked (interrupts may be disabled to keep the things
|
|
|
|
* stable).
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
2020-01-04 11:37:46 +01:00
|
|
|
int icmpv6_wait(FAR struct icmpv6_notify_s *notify, unsigned int timeout);
|
2015-02-02 20:44:31 +01:00
|
|
|
#else
|
|
|
|
# define icmpv6_wait(n,t) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_notify
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a Neighbor Advertisement is received in order to
|
|
|
|
* wake-up any threads that may be waiting for this particular Neighbor
|
|
|
|
* Advertisement.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the MAC device driver indirectly through
|
2015-02-02 21:50:16 +01:00
|
|
|
* icmpv6_icmpv6in() will execute with the network locked.
|
2015-02-02 20:44:31 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
|
|
|
void icmpv6_notify(net_ipv6addr_t ipaddr);
|
|
|
|
#else
|
|
|
|
# define icmpv6_notify(i)
|
|
|
|
#endif
|
|
|
|
|
2015-02-03 00:54:48 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_autoconfig
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Perform IPv6 auto-configuration to assign an IPv6 address to this
|
|
|
|
* device.
|
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2019-03-19 16:43:32 +01:00
|
|
|
* dev - The device driver structure to assign the address to
|
2015-02-03 00:54:48 +01:00
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Returned Value:
|
2015-02-03 00:54:48 +01:00
|
|
|
* Zero (OK) is returned on success; A negated errno value is returned on
|
|
|
|
* any failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
2019-09-20 20:45:05 +02:00
|
|
|
int icmpv6_autoconfig(FAR struct net_driver_s *dev);
|
2015-02-03 00:54:48 +01:00
|
|
|
#endif
|
|
|
|
|
2015-02-03 20:25:28 +01:00
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_rwait_setup
|
2015-02-03 20:25:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called BEFORE an Router Solicitation is sent. This function sets up
|
|
|
|
* the Router Advertisement timeout before the Router Solicitation
|
|
|
|
* is sent so that there is no race condition when icmpv6_rwait() is
|
|
|
|
* called.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from icmpv6_autoconfig() and executes in the
|
|
|
|
* normal tasking environment.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
|
|
void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
|
|
|
|
FAR struct icmpv6_rnotify_s *notify);
|
|
|
|
#else
|
|
|
|
# define icmpv6_rwait_setup(d,n)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_rwait_cancel
|
2015-02-03 20:25:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Cancel any wait set after icmpv6_rwait_setup() is called but before
|
|
|
|
* icmpv6_rwait()is called (icmpv6_rwait() will automatically cancel the
|
|
|
|
* wait).
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function may execute in the interrupt context when called from
|
|
|
|
* icmpv6_rwait().
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
|
|
int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify);
|
|
|
|
#else
|
|
|
|
# define icmpv6_rwait_cancel(n) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_rwait
|
2015-02-03 20:25:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a Router Solicitation is sent. This function
|
|
|
|
* will sleep until either: (1) the matching Router Advertisement is
|
|
|
|
* received, or (2) a timeout occurs.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from icmpv6_autoconfig() and must execute with
|
|
|
|
* the network un-locked (interrupts may be disabled to keep the things
|
|
|
|
* stable).
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
2020-01-04 11:37:46 +01:00
|
|
|
int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, unsigned int timeout);
|
2015-02-03 20:25:28 +01:00
|
|
|
#else
|
|
|
|
# define icmpv6_rwait(n,t) (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: icmpv6_rnotify
|
2015-02-03 20:25:28 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Called each time that a Router Advertisement is received in order to
|
|
|
|
* wake-up any threads that may be waiting for this particular Router
|
|
|
|
* Advertisement.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from the MAC device driver indirectly through
|
|
|
|
* icmpv6_icmpv6in() will execute with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
2021-02-19 15:01:46 +01:00
|
|
|
void icmpv6_rnotify(FAR struct net_driver_s *dev,
|
|
|
|
const net_ipv6addr_t draddr,
|
|
|
|
const net_ipv6addr_t prefix,
|
|
|
|
unsigned int preflen);
|
2015-02-03 20:25:28 +01:00
|
|
|
#else
|
|
|
|
# define icmpv6_rnotify(d,p,l)
|
|
|
|
#endif
|
|
|
|
|
2017-10-24 19:23:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_sock_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize the IPPROTO_ICMP socket connection structures. Called once
|
|
|
|
* and only from the network initialization layer.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
void icmpv6_sock_initialize(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_alloc
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Allocate a new, uninitialized IPPROTO_ICMP socket connection structure.
|
|
|
|
* This is normally something done by the implementation of the socket()
|
|
|
|
* interface.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
FAR struct icmpv6_conn_s *icmpv6_alloc(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_free
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Free a IPPROTO_ICMP socket connection structure that is no longer in
|
|
|
|
* use. This should be done by the implementation of close().
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
void icmpv6_free(FAR struct icmpv6_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_active()
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Find a connection structure that is the appropriate connection to be
|
|
|
|
* used with the provided ECHO request ID.
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from network logic at with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
FAR struct icmpv6_conn_s *icmpv6_active(uint16_t id);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_nextconn
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Traverse the list of allocated packet connections
|
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from network logic at with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
FAR struct icmpv6_conn_s *icmpv6_nextconn(FAR struct icmpv6_conn_s *conn);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_findconn
|
|
|
|
*
|
|
|
|
* Description:
|
2021-02-19 15:01:46 +01:00
|
|
|
* Find an ICMPv6 connection structure that is expecting a ICMPv6 ECHO
|
|
|
|
* response with this ID from this device
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
* This function is called from network logic at with the network locked.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
FAR struct icmpv6_conn_s *icmpv6_findconn(FAR struct net_driver_s *dev,
|
2018-08-26 23:28:02 +02:00
|
|
|
uint16_t id);
|
2017-10-24 19:23:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2020-12-01 07:55:16 +01:00
|
|
|
* Name: icmpv6_sendmsg
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2020-12-01 07:55:16 +01:00
|
|
|
* Implements the sendmsg() operation for the case of the IPPROTO_ICMP6
|
2017-10-24 19:23:08 +02:00
|
|
|
* socket. The 'buf' parameter points to a block of memory that includes
|
|
|
|
* an ICMPv6 request header, followed by any payload that accompanies the
|
|
|
|
* request. The 'len' parameter includes both the size of the ICMPv6
|
|
|
|
* header and the following payload.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock A pointer to a NuttX-specific, internal socket structure
|
2020-12-01 07:55:16 +01:00
|
|
|
* msg Message to send
|
2017-10-24 19:23:08 +02:00
|
|
|
* flags Send flags
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2020-12-01 07:55:16 +01:00
|
|
|
* On success, returns the number of characters sent. On error, a negated
|
|
|
|
* errno value is returned (see sendmsg() for the list of appropriate error
|
2017-10-24 19:23:08 +02:00
|
|
|
* values.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
2020-12-01 07:55:16 +01:00
|
|
|
ssize_t icmpv6_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|
|
|
int flags);
|
2017-10-24 19:23:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
2020-12-01 07:55:16 +01:00
|
|
|
* Name: icmpv6_recvmsg
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2020-12-01 07:55:16 +01:00
|
|
|
* Implements the socket recvfrom interface for the case of the AF_INET
|
|
|
|
* data gram socket with the IPPROTO_ICMP6 protocol. icmpv6_recvmsg()
|
2017-10-24 19:23:08 +02:00
|
|
|
* receives ICMPv6 ECHO replies for the a socket.
|
|
|
|
*
|
2020-12-01 07:55:16 +01:00
|
|
|
* If msg_name is not NULL, and the underlying protocol provides the source
|
|
|
|
* address, this source address is filled in. The argument 'msg_namelen' is
|
|
|
|
* initialized to the size of the buffer associated with msg_name, and
|
2017-10-24 19:23:08 +02:00
|
|
|
* modified on return to indicate the actual size of the address stored
|
|
|
|
* there.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock A pointer to a NuttX-specific, internal socket structure
|
2020-12-01 07:55:16 +01:00
|
|
|
* msg Buffer to receive the message
|
2017-10-24 19:23:08 +02:00
|
|
|
* flags Receive flags
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2020-12-01 07:55:16 +01:00
|
|
|
* On success, returns the number of characters received. If no data is
|
2017-10-24 19:23:08 +02:00
|
|
|
* available to be received and the peer has performed an orderly shutdown,
|
2020-12-01 07:55:16 +01:00
|
|
|
* recvmsg() will return 0. Otherwise, on errors, a negated errno value is
|
|
|
|
* returned (see recvmsg() for the list of appropriate error values).
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
2020-12-01 07:55:16 +01:00
|
|
|
ssize_t icmpv6_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
|
|
|
|
int flags);
|
2017-10-24 19:23:08 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_pollsetup
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Setup to monitor events on one ICMPv6 socket
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - The IPPROTO_ICMP6 socket of interest
|
|
|
|
* fds - The structure describing the events to be monitored, OR NULL if
|
|
|
|
* this is a request to stop monitoring events.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0: Success; Negated errno on failure
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_pollteardown
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Teardown monitoring of events on an ICMPv6 socket
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* psock - The IPPROTO_ICMP6 socket of interest
|
|
|
|
* fds - The structure describing the events to be monitored, OR NULL if
|
|
|
|
* this is a request to stop monitoring events.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0: Success; Negated errno on failure
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
|
|
|
int icmpv6_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
|
|
|
|
#endif
|
|
|
|
|
2018-11-09 22:28:58 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_linkipaddr
|
|
|
|
*
|
|
|
|
* Description:
|
2021-02-19 15:01:46 +01:00
|
|
|
* Generate the device link scope ipv6 address as below:
|
|
|
|
* 128 112 96 80 64 48 32 16
|
|
|
|
* ---- ---- ---- ---- ---- ---- ---- ----
|
|
|
|
* fe80 0000 0000 0000 0000 00ff fe00 xx00 1-byte short addr IEEE 48-bit MAC
|
|
|
|
* fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte short addr IEEE 48-bit MAC
|
|
|
|
* fe80 0000 0000 0000 xxxx xxff fexx xxxx 6-byte normal addr IEEE 48-bit MAC
|
|
|
|
* fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte extended addr IEEE EUI-64
|
2018-11-09 22:28:58 +01:00
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure containing the link layer address
|
|
|
|
* ipaddr - Receive the device link scope ipv6 address
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr);
|
|
|
|
|
2021-11-25 15:03:33 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_reply
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Send an ICMPv6 message in response to a situation
|
|
|
|
* RFC 1122: 3.2.2 MUST send at least the IP header and 8 bytes of header.
|
|
|
|
* MAY send more (we do).
|
|
|
|
* MUST NOT change this header information.
|
|
|
|
* MUST NOT reply to a multicast/broadcast IP address.
|
|
|
|
* MUST NOT reply to a multicast/broadcast MAC address.
|
|
|
|
* MUST reply to only the first fragment.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The device driver structure containing the received packet
|
|
|
|
* type - ICMPv6 Message Type, eg. ICMPv6_DEST_UNREACHABLE
|
|
|
|
* code - ICMPv6 Message Code, eg. ICMPv6_PORT_UNREACH
|
|
|
|
* data - Additional 32-bit parameter in the ICMPv6 header
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void icmpv6_reply(FAR struct net_driver_s *dev,
|
|
|
|
int type, int code, int data);
|
|
|
|
|
2017-05-25 16:02:08 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-11-09 18:25:57 +01:00
|
|
|
#endif /* CONFIG_NET_ICMPv6 && !CONFIG_NET_ICMPv6_NO_STACK */
|
2015-01-14 23:10:38 +01:00
|
|
|
#endif /* __NET_ICMPv6_ICMPv6_H */
|