5aeb15469a
The `xxx_ipv6multicast` function in each driver is not adapted to multiple IPv6 addresses yet, and they're redundant, so try to take them into common code. Change: 1. Add MAC `g_ipv6_ethallnodes` and `g_ipv6_ethallrouters` in `icmpv6_devinit` and call them in `netdev_register` 2. Add multicast MAC for Neighbor Solicitation when adding any IPv6 address, and remove them when IPv6 address is removed 3. Select `NET_MCASTGROUP` when `NET_ICMPv6` because now we need `d_addmac` when we have ICMPv6 Note: We want modules outside net stack to call functions like `netdev_ipv6_add` and never touch the related MAC address, so these MAC functions are added as internal functions to `net/netdev/netdev.h` Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
87 lines
2.8 KiB
C
87 lines
2.8 KiB
C
/****************************************************************************
|
|
* net/icmpv6/icmpv6_initialize.c
|
|
* ICMPv6 initialization logic
|
|
*
|
|
* 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
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* 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.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <debug.h>
|
|
|
|
#include <nuttx/net/ethernet.h>
|
|
#include <nuttx/net/netdev.h>
|
|
|
|
#include "icmpv6/icmpv6.h"
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: icmpv6_devinit
|
|
*
|
|
* Description:
|
|
* Called when a new network device is registered to configure that device
|
|
* for ICMPv6 support.
|
|
*
|
|
* Input Parameters:
|
|
* dev - The device driver structure to configure.
|
|
*
|
|
* Returned Value:
|
|
* None
|
|
*
|
|
* Assumptions:
|
|
* The network is locked.
|
|
*
|
|
****************************************************************************/
|
|
|
|
void icmpv6_devinit(FAR struct net_driver_s *dev)
|
|
{
|
|
ninfo("ICMPv6 initializing dev %p\n", dev);
|
|
|
|
#ifdef CONFIG_NET_ETHERNET
|
|
# ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
|
/* Add the IPv6 all link-local nodes Ethernet address. This is the
|
|
* address that we expect to receive ICMPv6 Router Advertisement
|
|
* packets.
|
|
*/
|
|
|
|
if (dev->d_addmac != NULL)
|
|
{
|
|
dev->d_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet);
|
|
}
|
|
# endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
|
|
|
# ifdef CONFIG_NET_ICMPv6_ROUTER
|
|
/* Add the IPv6 all link-local routers Ethernet address. This is the
|
|
* address that we expect to receive ICMPv6 Router Solicitation
|
|
* packets.
|
|
*/
|
|
|
|
if (dev->d_addmac != NULL)
|
|
{
|
|
dev->d_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet);
|
|
}
|
|
# endif /* CONFIG_NET_ICMPv6_ROUTER */
|
|
#endif /* CONFIG_NET_ETHERNET */
|
|
}
|