diff --git a/ChangeLog b/ChangeLog index d6a532f42c..32a4086f3b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10873,4 +10873,7 @@ Pavel Pisa (2015-08-23). * net/ ande include/nuttx/net: Remove references to PPP as a link layer protocol (2015-08-24). - + * net/, drivers/net, and include/net: Add definitions to support + a local loopback device and link layer (2015-08-24). + * libc/netdb, net/loopback, include/nuttx/net: Add NetDB support + for the local loopback device (2015-08-24). diff --git a/include/nuttx/net/loopback.h b/include/nuttx/net/loopback.h new file mode 100644 index 0000000000..084a8d61be --- /dev/null +++ b/include/nuttx/net/loopback.h @@ -0,0 +1,98 @@ +/**************************************************************************** + * include/nuttx/net/loopback.h + * Definitions for use with local loopback device + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory nutt + * + * Includes some definitions that a compatible with the LGPL GNU C Library + * header file of the same name. + * + * 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_NUTTX_NET_LOOPBACK_H +#define __INCLUDE_NUTTX_NET_LOOPBACK_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#ifdef CONFIG_NETDEV_LOOPBACK + +/**************************************************************************** + * Public Type Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +#ifdef CONFIG_LIBC_NETDB +/* Local loopback hostname */ + +EXTERN const char g_lo_hostname[]; +#endif + +/* Local loopback addresses */ + +EXTERN const in_addr_t g_lo_ipv4addr; +EXTERN const in_addr_t g_lo_ipv4mask; +EXTERN const net_ipv6addr_t g_lo_ipv6addr; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* CONFIG_NETDEV_LOOPBACK */ +#endif /* __INCLUDE_NUTTX_NET_LOOPBACK_H */ diff --git a/libc/netdb/lib_gethostbyaddrr.c b/libc/netdb/lib_gethostbyaddrr.c index d88527570c..153e749602 100644 --- a/libc/netdb/lib_gethostbyaddrr.c +++ b/libc/netdb/lib_gethostbyaddrr.c @@ -53,21 +53,81 @@ #ifdef CONFIG_NETDB_HOSTFILE /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: gethostbyaddr_r + * Name: lib_lo_ipv4match * * Description: - * The gethostbyaddr_r() function returns a structure of type hostent for - * the given host address addr of length len and address type type. Valid - * address types are AF_INET and AF_INET6. The host address argument is a - * pointer to a struct of a type depending on the address type, for example - * a struct in_addr * for address type AF_INET. - * - * gethostbyaddr_r() is *not* POSIX but is similar to a Glibc extension and is - * used internally by NuttX to implement the POSIX gethostbyaddr(). + * Check if the address is the reserved IPv4 address for the local + * loopback device. + * + * Input Parameters: + * addr - The address of the host to find. + * len - The length of the address + * type - The type of the address + * + * Returned Value: + * True if the address is the IPv4 local loopback address. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_LOOPBACK +static bool lib_lo_ipv4match(FAR const void *addr, socklen_t len, int type) +{ + FAR struct in_addr *ipv4addr; + + if (type == AF_INET && len >= sizeof(struct in_addr)) + { + ipv4addr = (FAR struct in_addr *)addr; + return net_ipv4addr_maskcmp(ipv4addr->sin_addr.s_addr, + g_lo_ipv4addr->s_addr, + g_lo_ipv4addr->s_addr); + } + + return false; +} +#endif + +/**************************************************************************** + * Name: lib_lo_ipv6match + * + * Description: + * Check if the address is the reserved IPv6 address for the local + * loopback device. + * + * Input Parameters: + * addr - The address of the host to find. + * len - The length of the address + * type - The type of the address + * + * Returned Value: + * True if the address is the IPv4 local loopback address. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_LOOPBACK +static bool lib_lo_ipv6match(FAR const void *addr, socklen_t len, int type) +{ + FAR struct in_addr6 *ipv6addr; + + if (type == AF_INE6T && len >= sizeof(struct in_addr6)) + { + ipv6addr = (FAR struct in_addr6 *)addr; + return net_ipv6addr_cmp(ipv6addr->sin6_addr.s6_addr16, g_lo_ipv6addr); + } + + return false; +} +#endif + +/**************************************************************************** + * Name: lib_localhost + * + * Description: + * Check if the address is the reserved address for the local loopback + * device. * * Input Parameters: * addr - The address of the host to find. @@ -85,24 +145,123 @@ * ****************************************************************************/ -int gethostbyaddr_r(FAR const void *addr, socklen_t len, int type, - FAR struct hostent *host, FAR char *buf, - size_t buflen, int *h_errnop) +#ifdef CONFIG_NETDEV_LOOPBACK +static int lib_localhost(FAR const void *addr, socklen_t len, int type, + FAR struct hostent *host, FAR char *buf, + size_t buflen, int *h_errnop) +{ + FAR struct hostent_info_s *info; + socklen_t addrlen; + FAR const uint8_t *src; + FAR uint8_t *dest; + bool match; + int herrnocode; + int namelen; + int ret; + + if (lib_lo_ipv4match(addr, len, type)) + { + /* Setup to transfer the IPv4 address */ + + addrlen = sizeof(struct in_addr); + src = (FAR uint8_t *)&g_lo_ipv4addr; + host->h_addrtype = AF_INET; + } + else if (lib_lo_ipv4match(addr, len, type)) + { + /* Setup to transfer the IPv6 address */ + + addrlen = sizeof(struct in6_addr); + src = (FAR uint8_t *)&g_lo_ipv6addr; + host->h_addrtype = AF_INET6; + } + else + { + /* Return 1 meaning that we have no errors but no match either */ + + return 1; + } + + /* Make sure that space remains to hold the hostent structure and + * the IP address. + */ + + if (buflen <= (sizeof(struct hostent_info_s) + addrlen)) + { + return -ERANGE; + } + + + info = (FAR struct hostent_info_s *)buf; + dest = (FAR uint8_t *)info->hi_data; + buflen -= (sizeof(struct hostent_info_s) - 1); + + memset(host, 0, sizeof(struct hostent)); + memset(info, 0, sizeof(struct hostent_info_s)); + memcpy(dest, src, addrlen); + + info->hi_addrlist[0] = dest; + host->h_addr_list = info->hi_addrlist; + host->h_length = addrlen; + + ptr += addrlen; + buflen -= addrlen; + + /* And copy localhost host name */ + + namelen = strlen(g_lo_hostname); + if (addrlen + namelen + 1 > buflen) + { + herrnocode = ERANGE; + goto errorout_with_herrnocode; + } + + strncpy(ptr, g_lo_hostname, buflen); + return 0; + } + + return 1; + +errorout_with_herrnocode: + if (h_errnop) + { + *h_errnop = herrnocode; + } + + return ERROR; +} +#endif + +/**************************************************************************** + * Name: lib_hostfile_lookup + * + * Description: + * Try to look-up the host name from the network host file + * + * Input Parameters: + * addr - The address of the host to find. + * len - The length of the address + * type - The type of the address + * host - Caller provided location to return the host data. + * buf - Caller provided buffer to hold string data associated with the + * host data. + * buflen - The size of the caller-provided buffer + * h_errnop - There h_errno value returned in the event of a failure. + * + * Returned Value: + * Zero (OK) is returned on success, -1 (ERROR) is returned on a failure + * with the returned h_errno value provided the reason for the failure. + * + ****************************************************************************/ + +int lib_hostfile_lookup(FAR const void *addr, socklen_t len, int type, + FAR struct hostent *host, FAR char *buf, + size_t buflen, int *h_errnop) { FAR FILE *stream; int herrnocode; int nread; - DEBUGASSERT(addr != NULL && host != NULL && buf != NULL); - DEBUGASSERT(type == AF_INET || type == AF_INET6); - - /* Make sure that the h_errno has a non-error code */ - - if (h_errnop) - { - *h_errnop = 0; - } - /* Search the hosts file for a match */ stream = fopen(CONFIG_NETDB_HOSTCONF_PATH, "r"); @@ -185,4 +344,71 @@ errorout_with_herrnocode: return ERROR; } +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: gethostbyaddr_r + * + * Description: + * The gethostbyaddr_r() function returns a structure of type hostent for + * the given host address addr of length len and address type type. Valid + * address types are AF_INET and AF_INET6. The host address argument is a + * pointer to a struct of a type depending on the address type, for example + * a struct in_addr * for address type AF_INET. + * + * gethostbyaddr_r() is *not* POSIX but is similar to a Glibc extension and is + * used internally by NuttX to implement the POSIX gethostbyaddr(). + * + * Input Parameters: + * addr - The address of the host to find. + * len - The length of the address + * type - The type of the address + * host - Caller provided location to return the host data. + * buf - Caller provided buffer to hold string data associated with the + * host data. + * buflen - The size of the caller-provided buffer + * h_errnop - There h_errno value returned in the event of a failure. + * + * Returned Value: + * Zero (OK) is returned on success, -1 (ERROR) is returned on a failure + * with the returned h_errno value provided the reason for the failure. + * + ****************************************************************************/ + +int gethostbyaddr_r(FAR const void *addr, socklen_t len, int type, + FAR struct hostent *host, FAR char *buf, + size_t buflen, int *h_errnop) +{ + FAR FILE *stream; + int herrnocode; + int nread; + + DEBUGASSERT(addr != NULL && host != NULL && buf != NULL); + DEBUGASSERT(type == AF_INET || type == AF_INET6); + + /* Make sure that the h_errno has a non-error code */ + + if (h_errnop) + { + *h_errnop = 0; + } + +#ifdef CONFIG_NETDEV_LOOPBACK + /* Check for the local loopback address */ + + if (lib_localhost(addr, len, type, host, but, buflen, h_errnop) == 0) + { + /* Yes.. we are done */ + + return OK; + } +#endif + + /* Search the hosts file for a match */ + + return lib_hostfile_lookup(addr, len, type, host, but, buflen, h_errnop); +} + #endif /* CONFIG_NETDB_HOSTFILE */ diff --git a/libc/netdb/lib_gethostbynamer.c b/libc/netdb/lib_gethostbynamer.c index ff90bcbf76..aa18807783 100644 --- a/libc/netdb/lib_gethostbynamer.c +++ b/libc/netdb/lib_gethostbynamer.c @@ -85,7 +85,7 @@ struct hostent_info_s * name into the h_name field and its struct in_addr equivalent into the * h_addr_list[0] field of the returned hostent structure. * - * Input paramters: + * Input Parameters: * stream - File stream of the opened hosts file with the file pointer * positioned at the beginning of the next host entry. * host - Caller provided location to return the host data. @@ -211,6 +211,95 @@ static int lib_numeric_address(FAR const char *name, FAR struct hostent *host, return 0; } +/**************************************************************************** + * Name: lib_localhost + * + * Description: + * Check if the name is the reserved name for the local loopback device. + * + * Input Parameters: + * stream - File stream of the opened hosts file with the file pointer + * positioned at the beginning of the next host entry. + * host - Caller provided location to return the host data. + * buf - Caller provided buffer to hold string data associated with the + * host data. + * buflen - The size of the caller-provided buffer + * + * Returned Value: + * Zero (0) is returned if the name is an numeric IP address. + * + ****************************************************************************/ + +#ifdef CONFIG_NETDEV_LOOPBACK +static int lib_localhost(FAR const char *name, FAR struct hostent *host, + FAR char *buf, size_t buflen) +{ + FAR struct hostent_info_s *info; + socklen_t addrlen; + FAR const uint8_t *src; + FAR uint8_t *dest; + int namelen; + int ret; + + if (strcmp(name, "localhost") == 0) + { + /* Yes.. it is the localhost */ + +#ifdef CONFIG_NET_IPv4 + /* Setup to transfer the IPv4 address */ + + addrlen = sizeof(struct in_addr); + src = (FAR uint8_t *)&g_lo_ipv4addr; + host->h_addrtype = AF_INET; + +#else /* CONFIG_NET_IPv6 */ + /* Setup to transfer the IPv6 address */ + + addrlen = sizeof(struct in6_addr); + src = (FAR uint8_t *)&g_lo_ipv6addr; + host->h_addrtype = AF_INET6; +#endif + + /* Make sure that space remains to hold the hostent structure and + * the IP address. + */ + + if (buflen <= (sizeof(struct hostent_info_s) + addrlen)) + { + return -ERANGE; + } + + info = (FAR struct hostent_info_s *)buf; + dest = (FAR uint8_t *)info->hi_data; + buflen -= (sizeof(struct hostent_info_s) - 1); + + memset(host, 0, sizeof(struct hostent)); + memset(info, 0, sizeof(struct hostent_info_s)); + memcpy(dest, src, addrlen); + + info->hi_addrlist[0] = dest; + host->h_addr_list = info->hi_addrlist; + host->h_length = addrlen; + + ptr += addrlen; + buflen -= addrlen; + + /* And copy name */ + + namelen = strlen(name); + if (addrlen + namelen + 1 > buflen) + { + return -ERANGE; + } + + strncpy(ptr, name, buflen); + return 0; + } + + return 1; +} +#endif + /**************************************************************************** * Name: lib_find_answer * @@ -471,7 +560,7 @@ static int lib_dns_lookup(FAR const char *name, FAR struct hostent *host, * Description: * Try to look-up the host name from the network host file * - * Input paramters: + * Input Parameters: * name - The name of the host to find. * host - Caller provided location to return the host data. * buf - Caller provided buffer to hold string data associated with the @@ -651,6 +740,17 @@ int gethostbyname_r(FAR const char *name, FAR struct hostent *host, return OK; } +#ifdef CONFIG_NETDEV_LOOPBACK + /* Check for the local loopback host name */ + + if (lib_localhost(name, host, buf, buflen) == 0) + { + /* Yes.. we are done */ + + return OK; + } +#endif + /* Try to find the name in the HOSTALIASES environment variable */ /* REVISIT: Not implemented */ diff --git a/net/Kconfig b/net/Kconfig index 3c91e020d0..a6597e064d 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -245,6 +245,7 @@ source "net/icmp/Kconfig" source "net/icmpv6/Kconfig" source "net/igmp/Kconfig" source "net/arp/Kconfig" +source "net/loopback/Kconfig" source "net/iob/Kconfig" source "net/utils/Kconfig" diff --git a/net/Makefile b/net/Makefile index ce3faf0f3a..0b3aea0a29 100644 --- a/net/Makefile +++ b/net/Makefile @@ -68,6 +68,7 @@ include local/Make.defs include tcp/Make.defs include udp/Make.defs include devif/Make.defs +include loopback/Make.defs include route/Make.defs include utils/Make.defs endif diff --git a/net/README.txt b/net/README.txt index db0a59452a..0f93c07581 100644 --- a/net/README.txt +++ b/net/README.txt @@ -14,6 +14,7 @@ Directory Structure +- icmpv6 - Internet Control Message Protocol (IPv6) +- iob - I/O buffering logic +- local - Unix domain (local) sockets + +- loopback - Local loopback +- neighbor - Neighbor Discovery Protocol (IPv6) +- netdev - Socket network device interface +- pkt - "Raw" packet socket support diff --git a/net/loopback/Kconfig b/net/loopback/Kconfig new file mode 100644 index 0000000000..f72f3c094c --- /dev/null +++ b/net/loopback/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# diff --git a/net/loopback/Make.defs b/net/loopback/Make.defs new file mode 100644 index 0000000000..5cbdc8bf75 --- /dev/null +++ b/net/loopback/Make.defs @@ -0,0 +1,48 @@ +############################################################################ +# net/route/Make.defs +# +# Copyright (C) 2014 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. +# +############################################################################ + +ifeq ($(CONFIG_NET_ROUTE),y) + +# Routing table support + +SOCK_CSRCS += net_addroute.c net_allocroute.c net_delroute.c +SOCK_CSRCS += net_foreachroute.c net_router.c netdev_router.c + +# Include routing table build support + +DEPPATH += --dep-path route +VPATH += :route + +endif diff --git a/net/loopback/lo_globals.c b/net/loopback/lo_globals.c new file mode 100644 index 0000000000..55d273c566 --- /dev/null +++ b/net/loopback/lo_globals.c @@ -0,0 +1,70 @@ +/**************************************************************************** + * net/loopback/lo_globals.c + * + * Copyright (C) 2015 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include "loopback/loopback.h" + +#ifdef CONFIG_NETDEV_LOOPBACK + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* Local loopback hostname */ + +const char g_lo_hostname[] = "localhost"; + +/* Local loopback addresses */ + +const in_addr_t g_lo_ipv4addr = HTONL(0x7f000001); +const in_addr_t g_lo_ipv4mask = HTONL(0xff000000); +const net_ipv6addr_t g_lo_ipv6addr = +{ + HTONS(0), HTONS(0), HTONS(0), HTONS(0), + HTONS(0), HTONS(0), HTONS(0), HTONS(1) +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#endif /* CONFIG_NETDEV_LOOPBACK */ diff --git a/net/loopback/loopback.h b/net/loopback/loopback.h new file mode 100644 index 0000000000..082e6ccb68 --- /dev/null +++ b/net/loopback/loopback.h @@ -0,0 +1,72 @@ +/**************************************************************************** + * net/route/route.h + * + * Copyright (C) 2013-2014 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 __NET_LOOPBACK_LOOBACK_H +#define __NET_LOOPBACK_LOOBACK_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#ifdef CONFIG_NETDEV_LOOPBACK + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + + /**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#endif /* CONFIG_NETDEV_LOOPBACK */ +#endif /* __NET_LOOPBACK_LOOBACK_H */