net/mld: Add basic build structure for Multicast Listener Discovery (MLD). No real MLD logic yet. Only a few hooks to capture and dispatch MLD ICMPv6 packets.
This commit is contained in:
parent
a3c67df91d
commit
dde1e89b8c
@ -71,9 +71,9 @@
|
|||||||
#define ICMPv6_RESERVED_ERROR_MSG 127
|
#define ICMPv6_RESERVED_ERROR_MSG 127
|
||||||
#define ICMPv6_ECHO_REQUEST 128
|
#define ICMPv6_ECHO_REQUEST 128
|
||||||
#define ICMPv6_ECHO_REPLY 129
|
#define ICMPv6_ECHO_REPLY 129
|
||||||
#define ICMPV6_MCAST_LISTEN_QUERY 130 /* RFC 2710 */
|
#define ICMPV6_MCAST_LISTEN_QUERY 130 /* RFC 2710 and 3810 */
|
||||||
#define ICMPV6_MCAST_LISTEN_REPORT 131
|
#define ICMPV6_MCAST_LISTEN_REPORT_V1 131 /* RFC 2710 */
|
||||||
#define ICMPV6_MCAST_LISTEN_DONE 132
|
#define ICMPV6_MCAST_LISTEN_DONE_V1 132 /* RFC 2710 */
|
||||||
#define ICMPV6_ROUTER_SOLICIT 133 /* RFC 4861 */
|
#define ICMPV6_ROUTER_SOLICIT 133 /* RFC 4861 */
|
||||||
#define ICMPV6_ROUTER_ADVERTISE 134
|
#define ICMPV6_ROUTER_ADVERTISE 134
|
||||||
#define ICMPv6_NEIGHBOR_SOLICIT 135
|
#define ICMPv6_NEIGHBOR_SOLICIT 135
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/net/mld.h
|
* include/nuttx/net/mld.h
|
||||||
|
* Multicast Listener Discovery (MLD) Definitions
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
@ -306,6 +306,7 @@ source "net/bluetooth/Kconfig"
|
|||||||
source "net/ieee802154/Kconfig"
|
source "net/ieee802154/Kconfig"
|
||||||
source "net/icmp/Kconfig"
|
source "net/icmp/Kconfig"
|
||||||
source "net/icmpv6/Kconfig"
|
source "net/icmpv6/Kconfig"
|
||||||
|
source "net/mld/Kconfig"
|
||||||
source "net/igmp/Kconfig"
|
source "net/igmp/Kconfig"
|
||||||
source "net/arp/Kconfig"
|
source "net/arp/Kconfig"
|
||||||
source "net/loopback/Kconfig"
|
source "net/loopback/Kconfig"
|
||||||
|
@ -65,6 +65,7 @@ include neighbor/Make.defs
|
|||||||
include igmp/Make.defs
|
include igmp/Make.defs
|
||||||
include pkt/Make.defs
|
include pkt/Make.defs
|
||||||
include local/Make.defs
|
include local/Make.defs
|
||||||
|
include mld/Make.defs
|
||||||
include netlink/Make.defs
|
include netlink/Make.defs
|
||||||
include tcp/Make.defs
|
include tcp/Make.defs
|
||||||
include udp/Make.defs
|
include udp/Make.defs
|
||||||
|
@ -18,6 +18,7 @@ Directory Structure
|
|||||||
+- ipforward - IP forwarding logic
|
+- ipforward - IP forwarding logic
|
||||||
+- local - Unix domain (local) sockets
|
+- local - Unix domain (local) sockets
|
||||||
+- loopback - Local loopback
|
+- loopback - Local loopback
|
||||||
|
+- mld - Multicast Listener Discovery (MLD)
|
||||||
+- neighbor - Neighbor Discovery Protocol (IPv6)
|
+- neighbor - Neighbor Discovery Protocol (IPv6)
|
||||||
+- netdev - Socket network device interface
|
+- netdev - Socket network device interface
|
||||||
+- netlink - Netlink IPC socket interface
|
+- netlink - Netlink IPC socket interface
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include "neighbor/neighbor.h"
|
#include "neighbor/neighbor.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "icmpv6/icmpv6.h"
|
#include "icmpv6/icmpv6.h"
|
||||||
|
#include "mld/mld.h"
|
||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#ifdef CONFIG_NET_ICMPv6
|
||||||
|
|
||||||
@ -82,6 +83,15 @@
|
|||||||
#define ICMPv6RADVERTISE \
|
#define ICMPv6RADVERTISE \
|
||||||
((struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
((struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||||
|
|
||||||
|
#define MLDQUEURY \
|
||||||
|
((FAR struct mld_mcast_listen_query_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||||
|
#define MLDREPORT_V1 \
|
||||||
|
((FAR struct mld_mcast_listen_report_v1_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||||
|
#define MLDREPORT_V2 \
|
||||||
|
((FAR struct mld_mcast_listen_report_v2_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||||
|
#define MLDDONE_V1 \
|
||||||
|
((FAR struct mld_mcast_listen_done_v1_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -475,6 +485,71 @@ void icmpv6_input(FAR struct net_driver_s *dev)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MLD
|
||||||
|
/* Dispatch received Multicast Listener Discovery (MLD) packets. */
|
||||||
|
|
||||||
|
case ICMPV6_MCAST_LISTEN_QUERY: /* Multicast Listener Query, RFC 2710 and RFC 3810 */
|
||||||
|
{
|
||||||
|
FAR struct mld_mcast_listen_query_s *query = MLDQUEURY;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = mld_query_input(dev, query);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
goto icmpv6_drop_packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto icmpv6_send_nothing; /* REVISIT */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ICMPV6_MCAST_LISTEN_REPORT_V1: /* Version 1 Multicast Listener Report, RFC 2710 */
|
||||||
|
{
|
||||||
|
FAR struct mld_mcast_listen_report_v1_s *report = MLDREPORT_V1;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = mld_report_v1(dev, report);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
goto icmpv6_drop_packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto icmpv6_send_nothing; /* REVISIT */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case ICMPV6_MCAST_LISTEN_REPORT_V2: /* Version 2 Multicast Listener Report, RFC 3810 */
|
||||||
|
{
|
||||||
|
FAR struct mld_mcast_listen_report_v2_s *report = MLDREPORT_V2;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = mld_report_v2(dev, report);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
goto icmpv6_drop_packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto icmpv6_send_nothing; /* REVISIT */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ICMPV6_MCAST_LISTEN_DONE_V1: /* Version 1 Multicast Listener Done, RFC 2710 */
|
||||||
|
{
|
||||||
|
FAR struct mld_mcast_listen_done_v1_s *done = MLDDONE_V1;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = mld_done_v1(dev, done);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
goto icmpv6_drop_packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
goto icmpv6_send_nothing; /* REVISIT */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
nwarn("WARNING: Unknown ICMPv6 type: %d\n", ipicmp->type);
|
nwarn("WARNING: Unknown ICMPv6 type: %d\n", ipicmp->type);
|
||||||
|
18
net/mld/Kconfig
Normal file
18
net/mld/Kconfig
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
if NET_ICMPv6
|
||||||
|
|
||||||
|
menuconfig NET_MLD
|
||||||
|
bool "Multicast Listener Discovery (MLD)"
|
||||||
|
default n
|
||||||
|
depends on EXPERIMENTAL
|
||||||
|
---help---
|
||||||
|
Enable Multicast Listener Discovery (MLD) support.
|
||||||
|
|
||||||
|
if NET_MLD
|
||||||
|
|
||||||
|
endif # NET_MLD
|
||||||
|
endif # NET_ICMPv6
|
47
net/mld/Make.defs
Normal file
47
net/mld/Make.defs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
############################################################################
|
||||||
|
# net/mld/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Logic specific to Multicast Listener Discovery (MLD)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_NET_MLD),y)
|
||||||
|
|
||||||
|
SOCK_CSRCS +=
|
||||||
|
NET_CSRCS +=
|
||||||
|
|
||||||
|
# Include MLD build support
|
||||||
|
|
||||||
|
DEPPATH += --dep-path mld
|
||||||
|
VPATH += :mld
|
||||||
|
endif
|
149
net/mld/mld.h
Normal file
149
net/mld/mld.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* net/mld/mld.h
|
||||||
|
* Multicast Listener Discovery (MLD) Definitions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __NET_NETLINK_MLD_H
|
||||||
|
#define __NET_NETLINK_MLD_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <queue.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
|
#include "devif/devif.h"
|
||||||
|
#include "socket/socket.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MLD
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Type Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
# define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct net_driver_s; /* Forward reference */
|
||||||
|
struct mld_mcast_listen_query_s; /* Forward reference */
|
||||||
|
struct mld_mcast_listen_report_v1_s; /* Forward reference */
|
||||||
|
struct mld_mcast_listen_report_v2_s; /* Forward reference */
|
||||||
|
struct mld_mcast_listen_done_v1_s; /* Forward reference */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mld_initialize()
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the MLD structures. Called once and only from the
|
||||||
|
* networking layer.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void mld_initialize(void);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mld_query
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called from icmpv6_input() when a Multicast Listener Query is received.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int mld_query_input(FAR struct net_driver_s *dev,
|
||||||
|
FAR const struct mld_mcast_listen_query_s *query);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mld_report_v1
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called from icmpv6_input() when a Version 1 Multicast Listener Report is
|
||||||
|
* received.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int mld_report_v1(FAR struct net_driver_s *dev,
|
||||||
|
FAR const struct mld_mcast_listen_report_v1_s *report);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mld_report_v2
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called from icmpv6_input() when a Version 2 Multicast Listener Report is
|
||||||
|
* received.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int mld_report_v2(FAR struct net_driver_s *dev,
|
||||||
|
FAR const struct mld_mcast_listen_report_v2_s *report);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mld_done_v1
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Called from icmpv6_input() when a Version 1 Multicast Listener Done is
|
||||||
|
* received.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int mld_done_v1(FAR struct net_driver_s *dev,
|
||||||
|
FAR const struct mld_mcast_listen_done_v1_s *done);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_NET_MLD */
|
||||||
|
#endif /* __NET_NETLINK_MLD_H */
|
@ -54,6 +54,7 @@
|
|||||||
#include "neighbor/neighbor.h"
|
#include "neighbor/neighbor.h"
|
||||||
#include "icmp/icmp.h"
|
#include "icmp/icmp.h"
|
||||||
#include "icmpv6/icmpv6.h"
|
#include "icmpv6/icmpv6.h"
|
||||||
|
#include "mld/mld.h"
|
||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
#include "udp/udp.h"
|
#include "udp/udp.h"
|
||||||
#include "pkt/pkt.h"
|
#include "pkt/pkt.h"
|
||||||
@ -108,6 +109,12 @@ void net_setup(void)
|
|||||||
|
|
||||||
neighbor_initialize();
|
neighbor_initialize();
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MLD
|
||||||
|
/* Initialize ICMPv6 Multicast Listener Discovery (MLD) logic */
|
||||||
|
|
||||||
|
mld_initialize();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
/* Initialize 6LoWPAN data structures */
|
/* Initialize 6LoWPAN data structures */
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ EXTERN const struct sock_intf_s g_netlink_sockif;
|
|||||||
* Name: netlink_initialize()
|
* Name: netlink_initialize()
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the User Socket connection structures. Called once and only
|
* Initialize the NetLink connection structures. Called once and only
|
||||||
* from the networking layer.
|
* from the networking layer.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user