nuttx/net/neighbor/neighbor_out.c

79 lines
3.0 KiB
C
Raw Normal View History

/****************************************************************************
* net/neighbor/neighbor_out.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <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:
case NET_LL_IEEE80211:
neighbor_ethernet_out(dev);
break;
#endif
default:
break;
}
}