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 <assert.h>
|
2023-04-23 05:25:28 +02:00
|
|
|
#include <netinet/icmp6.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>
|
2022-02-07 04:37:39 +01:00
|
|
|
#include <nuttx/net/net.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) \
|
2022-02-07 04:37:39 +01:00
|
|
|
devif_callback_alloc((dev), &(conn)->sconn.list, &(conn)->sconn.list_tail)
|
2019-03-19 16:43:32 +01:00
|
|
|
#define icmpv6_callback_free(dev, conn, cb) \
|
2022-02-07 04:37:39 +01:00
|
|
|
devif_conn_callback_free((dev), (cb), &(conn)->sconn.list, &(conn)->sconn.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. */
|
|
|
|
|
2022-02-07 04:37:39 +01:00
|
|
|
struct socket_conn_s sconn;
|
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 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 */
|
2023-04-23 05:25:28 +02:00
|
|
|
struct icmp6_filter filter; /* ICMP6 type filter */
|
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
|
|
|
};
|
2023-04-23 05:25:28 +02:00
|
|
|
|
|
|
|
/* Callback from icmpv6_foreach() */
|
|
|
|
|
|
|
|
typedef int (*icmpv6_callback_t)(FAR struct icmpv6_conn_s *conn,
|
|
|
|
FAR void *arg);
|
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
|
|
|
|
|
2022-07-29 13:22:27 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_setaddresses
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* We successfully obtained the Router Advertisement. Set the new IPv6
|
|
|
|
* addresses in the driver structure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
|
|
void icmpv6_setaddresses(FAR struct net_driver_s *dev,
|
|
|
|
const net_ipv6addr_t draddr,
|
|
|
|
const net_ipv6addr_t prefix,
|
|
|
|
unsigned int preflen);
|
|
|
|
#else
|
2022-08-26 08:11:48 +02:00
|
|
|
# define icmpv6_setaddresses(dev,draddr,prefix,preflen) (0)
|
2022-07-29 13:22:27 +02: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
|
2022-07-29 13:22:27 +02:00
|
|
|
void icmpv6_rnotify(FAR struct net_driver_s *dev);
|
2015-02-03 20:25:28 +01:00
|
|
|
#else
|
2022-07-29 13:22:27 +02:00
|
|
|
# define icmpv6_rnotify(d) (0)
|
2015-02-03 20:25:28 +01:00
|
|
|
#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
|
|
|
|
|
|
|
|
/****************************************************************************
|
2023-04-23 05:25:28 +02:00
|
|
|
* Name: icmpv6_foreach
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
|
|
|
* Description:
|
2023-04-23 05:25:28 +02:00
|
|
|
* Enumerate each ICMPv6 connection structure. This function will terminate
|
|
|
|
* when either (1) all connection have been enumerated or (2) when a
|
|
|
|
* callback returns any non-zero value.
|
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
|
2023-04-23 05:25:28 +02:00
|
|
|
int icmpv6_foreach(icmpv6_callback_t callback, FAR void *arg);
|
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()
|
2023-04-14 12:11:12 +02:00
|
|
|
* receives ICMPv6 message for the a socket.
|
2017-10-24 19:23:08 +02:00
|
|
|
*
|
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);
|
|
|
|
|
2022-03-31 05:40:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: icmpv6_ioctl
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function performs icmp specific ioctl() operations.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* conn The ICMP connection of interest
|
|
|
|
* cmd The ioctl command
|
|
|
|
* arg The argument of the ioctl cmd
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
2022-08-30 20:18:33 +02:00
|
|
|
int icmpv6_ioctl(FAR struct socket *psock, int cmd, unsigned long arg);
|
2022-03-31 05:40:08 +02:00
|
|
|
#endif
|
|
|
|
|
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 */
|