net/loopback: Move g_lo_* global variable to libc/net/
so netdb could reuse these global variable directly Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: Iaa26ddbdaf416f64d43c6e8888a14bbe0c3405eb
This commit is contained in:
parent
eaab17b66a
commit
c85fe67ebc
|
@ -43,6 +43,10 @@ ifeq ($(CONFIG_NET),y)
|
|||
CSRCS += lib_recvmsg.c lib_sendmsg.c lib_shutdown.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NET_LOOPBACK),y)
|
||||
CSRCS += lib_loopback.c
|
||||
endif
|
||||
|
||||
# Routing table support
|
||||
|
||||
ifeq ($(CONFIG_NET_ROUTE),y)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* net/loopback/lo_globals.c
|
||||
* libs/libc/net/lib_loopback.c
|
||||
*
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
@ -41,8 +41,6 @@
|
|||
|
||||
#include <nuttx/net/loopback.h>
|
||||
|
||||
#include "loopback/loopback.h"
|
||||
|
||||
#ifdef CONFIG_NET_LOOPBACK
|
||||
|
||||
/****************************************************************************
|
|
@ -70,34 +70,6 @@ struct hostent_info_s
|
|||
char hi_data[1];
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* In the FLAT build, there is a single copy of this global variable that
|
||||
* can be accessed from application or OS code. In the protected and
|
||||
* kernel build modes, however, there must be separate copies of OS and
|
||||
* users spaces.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__)
|
||||
/* Local loopback addresses for user mode */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
|
||||
const in_addr_t g_lo_ipv4addr = HTONL(0x7f000001);
|
||||
|
||||
#else /* CONFIG_NET_IPv6 */
|
||||
|
||||
const net_ipv6addr_t g_lo_ipv6addr =
|
||||
{
|
||||
HTONS(0), HTONS(0), HTONS(0), HTONS(0),
|
||||
HTONS(0), HTONS(0), HTONS(0), HTONS(1)
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* !CONFIG_BUILD_FLAT && !__KERNEL__ */
|
||||
|
||||
/****************************************************************************
|
||||
* Private functions
|
||||
****************************************************************************/
|
||||
|
@ -269,7 +241,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||
FAR char *dest;
|
||||
int namelen;
|
||||
|
||||
if (strcmp(name, "localhost") == 0)
|
||||
if (strcmp(name, g_lo_hostname) == 0)
|
||||
{
|
||||
/* Yes.. it is the localhost */
|
||||
|
||||
|
|
|
@ -354,7 +354,6 @@ source "net/icmpv6/Kconfig"
|
|||
source "net/mld/Kconfig"
|
||||
source "net/igmp/Kconfig"
|
||||
source "net/arp/Kconfig"
|
||||
source "net/loopback/Kconfig"
|
||||
source "net/procfs/Kconfig"
|
||||
source "net/usrsock/Kconfig"
|
||||
source "net/utils/Kconfig"
|
||||
|
|
|
@ -74,7 +74,6 @@ include bluetooth/Make.defs
|
|||
include ieee802154/Make.defs
|
||||
include devif/Make.defs
|
||||
include ipforward/Make.defs
|
||||
include loopback/Make.defs
|
||||
include route/Make.defs
|
||||
include procfs/Make.defs
|
||||
include usrsock/Make.defs
|
||||
|
|
|
@ -17,7 +17,6 @@ Directory Structure
|
|||
+- inet - PF_INET/PF_INET6 socket interface
|
||||
+- ipforward - IP forwarding logic
|
||||
+- local - Unix domain (local) sockets
|
||||
+- loopback - Local loopback
|
||||
+- mld - Multicast Listener Discovery (MLD)
|
||||
+- neighbor - Neighbor Discovery Protocol (IPv6)
|
||||
+- netdev - Socket network device interface
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
|
@ -1,47 +0,0 @@
|
|||
############################################################################
|
||||
# net/loopback/Make.defs
|
||||
#
|
||||
# Copyright (C) 2015 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
ifeq ($(CONFIG_NET_LOOPBACK),y)
|
||||
|
||||
# Local loopback support
|
||||
|
||||
NETDEV_CSRCS += lo_globals.c
|
||||
|
||||
# Include routing table build support
|
||||
|
||||
DEPPATH += --dep-path loopback
|
||||
VPATH += :loopback
|
||||
|
||||
endif
|
|
@ -1,77 +0,0 @@
|
|||
/****************************************************************************
|
||||
* net/route/route.h
|
||||
*
|
||||
* Copyright (C) 2013-2014 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __NET_LOOPBACK_LOOBACK_H
|
||||
#define __NET_LOOPBACK_LOOBACK_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_NET_LOOPBACK
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* 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_LOOPBACK */
|
||||
#endif /* __NET_LOOPBACK_LOOBACK_H */
|
Loading…
Reference in New Issue