2018-11-10 04:21:49 +08:00
|
|
|
/****************************************************************************
|
|
|
|
* net/neighbor/neighbor_out.c
|
|
|
|
*
|
2024-09-11 20:39:39 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2020-08-23 00:36:57 +08: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
|
2018-11-10 04:21:49 +08:00
|
|
|
*
|
2020-08-23 00:36:57 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-11-10 04:21:49 +08:00
|
|
|
*
|
2020-08-23 00:36:57 +08: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.
|
2018-11-10 04:21:49 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <nuttx/net/net.h>
|
|
|
|
#include <nuttx/net/netdev.h>
|
|
|
|
|
|
|
|
#include "neighbor/neighbor.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: neighbor_out
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function should be called before sending out an IPv6 packet. The
|
|
|
|
* function checks the destination IPv6 address of the IPv6 packet to see
|
|
|
|
* what L2 address that should be used as a destination L2 address.
|
|
|
|
*
|
|
|
|
* If the destination IPv6 address is in the local network (determined
|
|
|
|
* by logical ANDing of netmask and our IPv6 address), the function
|
|
|
|
* checks the Neighbor Table to see if an entry for the destination IPv6
|
|
|
|
* address is found. If so, an L2 header is pre-pended at the beginning
|
|
|
|
* of the packet and the function returns.
|
|
|
|
*
|
|
|
|
* If no Neighbor Table entry is found for the destination IPv6 address,
|
|
|
|
* the packet in the d_buf is replaced by an ICMPv6 Neighbor Solicit
|
|
|
|
* request packet for the IPv6 address. The IPv6 packet is dropped and
|
|
|
|
* it is assumed that the higher level protocols (e.g., TCP) eventually
|
|
|
|
* will retransmit the dropped packet.
|
|
|
|
*
|
|
|
|
* Upon return in either the case, a packet to be sent is present in the
|
|
|
|
* d_buf buffer and the d_len field holds the length of the L2 frame that
|
|
|
|
* should be transmitted.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void neighbor_out(FAR struct net_driver_s *dev)
|
|
|
|
{
|
|
|
|
switch (dev->d_lltype)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_NET_ETHERNET
|
|
|
|
case NET_LL_ETHERNET:
|
2020-01-06 19:35:50 +08:00
|
|
|
case NET_LL_IEEE80211:
|
2018-11-10 04:21:49 +08:00
|
|
|
neighbor_ethernet_out(dev);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|