From df8743f48efa538bb588d7f4572a24f93cff2625 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 2 Oct 2013 06:58:37 -0600 Subject: Add candidate net/route.h. Not yet integrated --- nuttx/ChangeLog | 2 + nuttx/include/net/route.h | 104 ++++++++++++++++++++++++++++++ nuttx/include/nuttx/net/ioctl.h | 139 +++++++++++++++++++++------------------- 3 files changed, 180 insertions(+), 65 deletions(-) create mode 100644 nuttx/include/net/route.h diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index d130c9cf0..ff96f518f 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5691,4 +5691,6 @@ * include/nuttx/net/route.h and net/net_*route.c: Partial implementation of a routing table. Not yet hooked into the build system (2013-10-1) + * include/net/route.h: Defines the application interface to + the routing table (2013-10-2). diff --git a/nuttx/include/net/route.h b/nuttx/include/net/route.h new file mode 100644 index 000000000..72a4e64f9 --- /dev/null +++ b/nuttx/include/net/route.h @@ -0,0 +1,104 @@ +/**************************************************************************** + * include/net/route.h + * + * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 __INCLUDE_NET_ROUTE_H +#define __INCLUDE_NET_ROUTE_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#ifdef CONFIG_NET_ROUTE + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct ifnet +{ + uint16_t if_index; /* Interface number */ + uint16_t if_mtu; /* MTU of interface */ + struct sockaddr_in if_addr; /* Address of interface */ + struct sockaddr_in if_netmask; /* Netmask of if_addr */ +}; + +/* This structure describes the route information passed with the SIOCADDRT + * and SIOCDELRT ioctl commands (see include/nuttx/net/ioctl.h). + */ + +struct ortentry +{ + uint32_t rt_hash; /* To speed lookups */ + struct sockaddr rt_dst; /* Key */ + struct sockaddr rt_gateway; /* Value */ + uint16_t rt_flags; /* Up/down?, host/net */ + uint16_t rt_refcnt; /* Number of held references */ + uint32_t rt_use; /* Raw number of packets forwarded */ + struct ifnet *rt_ifp; /* The answer: interface to use */ +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_NET_ROUTE */ +#endif /* __INCLUDE_NET_ROUTE_H */ diff --git a/nuttx/include/nuttx/net/ioctl.h b/nuttx/include/nuttx/net/ioctl.h index d5d1a001c..00ea2e7f3 100644 --- a/nuttx/include/nuttx/net/ioctl.h +++ b/nuttx/include/nuttx/net/ioctl.h @@ -54,6 +54,8 @@ #define _SIOCVALID(c) (_IOC_TYPE(c)==_SIOCBASE) #define _SIOC(nr) _IOC(_SIOCBASE,nr) +/* Interface control operations */ + #define SIOCGIFADDR _SIOC(0x0001) /* Get IP address */ #define SIOCSIFADDR _SIOC(0x0002) /* Set IP address */ #define SIOCGIFDSTADDR _SIOC(0x0003) /* Get P-to-P address */ @@ -68,9 +70,6 @@ #define SIOCDIFADDR _SIOC(0x000c) /* Delete IP address */ #define SIOCGIFCOUNT _SIOC(0x000d) /* Get number of devices */ -#define SIOCGIPMSFILTER _SIOC(0x000e) /* Retrieve source filter addresses */ -#define SIOCSIPMSFILTER _SIOC(0x000f) /* Set source filter content */ - /* Newer interface ioctls that use the struct lifreq. Can be used for * both IPv4 and IPv6. */ @@ -85,71 +84,81 @@ #define SIOCSLIFNETMASK SIOCSIFNETMASK /* Set network mask */ #define SIOCGLIFMTU SIOCGIFMTU /* Get MTU size */ -/* Wireless ioctl commands **************************************************/ +/* Interface flags */ -#define SIOCSIWCOMMIT _SIOC(0x0010) /* Commit pending changes to driver */ -#define SIOCGIWNAME _SIOC(0x0011) /* Get name of wireless protocol */ - -#define SIOCSIWNWID _SIOC(0x0012) /* Set network ID (pre-802.11) */ -#define SIOCGIWNWID _SIOC(0x0013) /* Get network ID (the cell) */ -#define SIOCSIWFREQ _SIOC(0x0014) /* Set channel/frequency (Hz) */ -#define SIOCGIWFREQ _SIOC(0x0015) /* Get channel/frequency (Hz) */ -#define SIOCSIWMODE _SIOC(0x0016) /* Set operation mode */ -#define SIOCGIWMODE _SIOC(0x0017) /* Get operation mode */ -#define SIOCSIWSENS _SIOC(0x0018) /* Set sensitivity (dBm) */ -#define SIOCGIWSENS _SIOC(0x0019) /* Get sensitivity (dBm) */ - -#define SIOCGIWRANGE _SIOC(0x001a) /* Get range of parameters */ -#define SIOCGIWPRIV _SIOC(0x001b) /* Get private ioctl interface info */ -#define SIOCGIWSTATS _SIOC(0x001c) /* Get wireless stats */ - -#define SIOCSIWSPY _SIOC(0x001d) /* Set spy addresses */ -#define SIOCGIWSPY _SIOC(0x001e) /* Get spy info (quality of link) */ -#define SIOCSIWTHRSPY _SIOC(0x001f) /* Set spy threshold (spy event) */ -#define SIOCGIWTHRSPY _SIOC(0x0020) /* Get spy threshold */ - -#define SIOCSIWAP _SIOC(0x0021) /* Set access point MAC addresses */ -#define SIOCGIWAP _SIOC(0x0022) /* Get access point MAC addresses */ -#define SIOCGIWAPLIST _SIOC(0x0023) /* Deprecated in favor of scanning */ -#define SIOCSIWSCAN _SIOC(0x0024) /* Trigger scanning (list cells) */ -#define SIOCGIWSCAN _SIOC(0x0025) /* Get scanning results */ - -#define SIOCSIWESSID _SIOC(0x0026) /* Set ESSID (network name) */ -#define SIOCGIWESSID _SIOC(0x0027) /* Get ESSID */ -#define SIOCSIWNICKN _SIOC(0x0028) /* Set node name/nickname */ -#define SIOCGIWNICKN _SIOC(0x0029) /* Get node name/nickname */ - -#define SIOCSIWRATE _SIOC(0x002a) /* Set default bit rate (bps) */ -#define SIOCGIWRATE _SIOC(0x002b) /* Get default bit rate (bps) */ -#define SIOCSIWRTS _SIOC(0x002c) /* Set RTS/CTS threshold (bytes) */ -#define SIOCGIWRTS _SIOC(0x002d) /* Get RTS/CTS threshold (bytes) */ -#define SIOCSIWFRAG _SIOC(0x002e) /* Set fragmentation thr (bytes) */ -#define SIOCGIWFRAG _SIOC(0x002f) /* Get fragmentation thr (bytes) */ -#define SIOCSIWTXPOW _SIOC(0x0030) /* Set transmit power (dBm) */ -#define SIOCGIWTXPOW _SIOC(0x0031) /* Get transmit power (dBm) */ -#define SIOCSIWRETRY _SIOC(0x0032) /* Set retry limits and lifetime */ -#define SIOCGIWRETRY _SIOC(0x0033) /* Get retry limits and lifetime */ - -#define SIOCSIWPOWER _SIOC(0x0034) /* Set Power Management settings */ -#define SIOCGIWPOWER _SIOC(0x0035) /* Get Power Management settings */ - -#define SIOCSIWGENIE _SIOC(0x0030) /* Set generic IE */ -#define SIOCGIWGENIE _SIOC(0x0031) /* Get generic IE */ - -#define SIOCSIWMLME _SIOC(0x0016) /* Request MLME operation */ - -#define SIOCSIWAUTH _SIOC(0x0032) /* Set authentication mode params */ -#define SIOCGIWAUTH _SIOC(0x0033) /* Get authentication mode params */ - -#define SIOCSIWENCODEEXT _SIOC(0x0034) /* Set encoding token & mode */ -#define SIOCGIWENCODEEXT _SIOC(0x0035) /* Get encoding token & mode */ - -#define SIOCSIWPMKSA _SIOC(0x0036) /* PMKSA cache operation */ +#define SIOCSIFFLAGS _SIOC(0x000e) /* Sets the interface flags */ +#define SIOCGIFFLAGS _SIOC(0x000f) /* Gets the interface flags */ -/* Interface flags */ +#define SIOCGIPMSFILTER _SIOC(0x0010) /* Retrieve source filter addresses */ +#define SIOCSIPMSFILTER _SIOC(0x0011) /* Set source filter content */ + +/* Routing table. Argument is a reference to struct ortentry in + * include/net/route.h + */ + +#define SIOCADDRT _SIOC(0x0012) /* Add an entry to the routing table */ +#define SIOCDELRT _SIOC(0x0013) /* Delete an entry from the routing table */ + +/* Wireless ioctl commands **************************************************/ -#define SIOCSIFFLAGS _SIOC(0x0037) /* Sets the interface flags */ -#define SIOCGIFFLAGS _SIOC(0x0038) /* Gets the interface flags */ +#define SIOCSIWCOMMIT _SIOC(0x0014) /* Commit pending changes to driver */ +#define SIOCGIWNAME _SIOC(0x0015) /* Get name of wireless protocol */ + +#define SIOCSIWNWID _SIOC(0x0016) /* Set network ID (pre-802.11) */ +#define SIOCGIWNWID _SIOC(0x0017) /* Get network ID (the cell) */ +#define SIOCSIWFREQ _SIOC(0x0018) /* Set channel/frequency (Hz) */ +#define SIOCGIWFREQ _SIOC(0x0019) /* Get channel/frequency (Hz) */ +#define SIOCSIWMODE _SIOC(0x001a) /* Set operation mode */ +#define SIOCGIWMODE _SIOC(0x001b) /* Get operation mode */ +#define SIOCSIWSENS _SIOC(0x001c) /* Set sensitivity (dBm) */ +#define SIOCGIWSENS _SIOC(0x001d) /* Get sensitivity (dBm) */ + +#define SIOCGIWRANGE _SIOC(0x001e) /* Get range of parameters */ +#define SIOCGIWPRIV _SIOC(0x001f) /* Get private ioctl interface info */ +#define SIOCGIWSTATS _SIOC(0x0020) /* Get wireless stats */ + +#define SIOCSIWSPY _SIOC(0x0021) /* Set spy addresses */ +#define SIOCGIWSPY _SIOC(0x0022) /* Get spy info (quality of link) */ +#define SIOCSIWTHRSPY _SIOC(0x0023) /* Set spy threshold (spy event) */ +#define SIOCGIWTHRSPY _SIOC(0x0024) /* Get spy threshold */ + +#define SIOCSIWAP _SIOC(0x0025) /* Set access point MAC addresses */ +#define SIOCGIWAP _SIOC(0x0026) /* Get access point MAC addresses */ +#define SIOCGIWAPLIST _SIOC(0x0027) /* Deprecated in favor of scanning */ +#define SIOCSIWSCAN _SIOC(0x0028) /* Trigger scanning (list cells) */ +#define SIOCGIWSCAN _SIOC(0x0029) /* Get scanning results */ + +#define SIOCSIWESSID _SIOC(0x002a) /* Set ESSID (network name) */ +#define SIOCGIWESSID _SIOC(0x002b) /* Get ESSID */ +#define SIOCSIWNICKN _SIOC(0x002c) /* Set node name/nickname */ +#define SIOCGIWNICKN _SIOC(0x002d) /* Get node name/nickname */ + +#define SIOCSIWRATE _SIOC(0x002e) /* Set default bit rate (bps) */ +#define SIOCGIWRATE _SIOC(0x002f) /* Get default bit rate (bps) */ +#define SIOCSIWRTS _SIOC(0x0030) /* Set RTS/CTS threshold (bytes) */ +#define SIOCGIWRTS _SIOC(0x0031) /* Get RTS/CTS threshold (bytes) */ +#define SIOCSIWFRAG _SIOC(0x0032) /* Set fragmentation thr (bytes) */ +#define SIOCGIWFRAG _SIOC(0x0033) /* Get fragmentation thr (bytes) */ +#define SIOCSIWTXPOW _SIOC(0x0034) /* Set transmit power (dBm) */ +#define SIOCGIWTXPOW _SIOC(0x0035) /* Get transmit power (dBm) */ +#define SIOCSIWRETRY _SIOC(0x0036) /* Set retry limits and lifetime */ +#define SIOCGIWRETRY _SIOC(0x0037) /* Get retry limits and lifetime */ + +#define SIOCSIWPOWER _SIOC(0x0038) /* Set Power Management settings */ +#define SIOCGIWPOWER _SIOC(0x0039) /* Get Power Management settings */ + +#define SIOCSIWGENIE _SIOC(0x003a) /* Set generic IE */ +#define SIOCGIWGENIE _SIOC(0x003b) /* Get generic IE */ + +#define SIOCSIWMLME _SIOC(0x003c) /* Request MLME operation */ + +#define SIOCSIWAUTH _SIOC(0x003d) /* Set authentication mode params */ +#define SIOCGIWAUTH _SIOC(0x003e) /* Get authentication mode params */ + +#define SIOCSIWENCODEEXT _SIOC(0x003f) /* Set encoding token & mode */ +#define SIOCGIWENCODEEXT _SIOC(0x0040) /* Get encoding token & mode */ + +#define SIOCSIWPMKSA _SIOC(0x0041) /* PMKSA cache operation */ /**************************************************************************** * Type Definitions -- cgit v1.2.3