2017-03-28 19:35:46 +02:00
|
|
|
/****************************************************************************
|
2017-03-28 20:23:19 +02:00
|
|
|
* net/sixlowpan/sixlowpan_input.c
|
2017-03-28 19:35:46 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2017 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "nuttx/net/netdev.h"
|
2017-03-30 02:07:52 +02:00
|
|
|
#include "sixlowpan/sixlowpan_internal.h"
|
2017-03-28 19:35:46 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_NET_6LOWPAN
|
|
|
|
|
2017-03-31 00:30:04 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Function: sixlowpan_isbroadcast
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Return the address length associated with a 2-bit address mode
|
|
|
|
*
|
|
|
|
* Input parameters:
|
|
|
|
* addrmode - The address mode
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* The address length associated with the address mode.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static bool sixlowpan_isbroadcast(uint8_t mode, FAR uint8_t *addr)
|
|
|
|
{
|
|
|
|
int i = ((mode == FRAME802154_SHORTADDRMODE) ? 2 : 8);
|
|
|
|
|
|
|
|
while (i-- > 0)
|
|
|
|
{
|
|
|
|
if (addr[i] != 0xff)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-03-28 19:35:46 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: sixlowpan_input
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Process an incoming IP packet.
|
|
|
|
*
|
|
|
|
* This function is called when the device driver has received a 6loWPAN
|
|
|
|
* packet from the network. The packet from the device driver must be
|
|
|
|
* present in the d_buf buffer, and the length of the packet should be
|
|
|
|
* placed in the d_len field.
|
|
|
|
*
|
|
|
|
* When the function returns, there may be an outbound packet placed
|
|
|
|
* in the d_buf packet buffer. If so, the d_len field is set to
|
|
|
|
* the length of the packet. If no packet is to be sent out, the
|
|
|
|
* d_len field is set to 0.
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* dev - The IEEE802.15.4 MAC network driver interface.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Ok is returned on success; Othewise a negated errno value is returned.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int sixlowpan_input(FAR struct net_driver_s *dev)
|
|
|
|
{
|
|
|
|
/* REVISIT: To be provided */
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_NET_6LOWPAN */
|