mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Fix some initial loop back device compilation errors; mark configuration as EXPERIMENTAL
This commit is contained in:
@@ -9,6 +9,7 @@ config NETDEV_LOOPBACK
|
|||||||
bool "Local loopback support"
|
bool "Local loopback support"
|
||||||
default n
|
default n
|
||||||
select NET_NOINTS
|
select NET_NOINTS
|
||||||
|
depends on EXPERIMENTAL
|
||||||
---help---
|
---help---
|
||||||
Add support for the local network loopback device, lo. Any additional
|
Add support for the local network loopback device, lo. Any additional
|
||||||
networking devices that are enabled must be compatible with
|
networking devices that are enabled must be compatible with
|
||||||
|
|||||||
@@ -213,7 +213,6 @@ static void lo_loopback(FAR struct lo_driver_s *priv)
|
|||||||
{
|
{
|
||||||
ndbg("WARNING: Unrecognized packet type dropped: %04x\n", BUF->type);
|
ndbg("WARNING: Unrecognized packet type dropped: %04x\n", BUF->type);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+16
-12
@@ -113,9 +113,9 @@ struct skel_driver_s
|
|||||||
struct work_s sk_work; /* For deferring work to the work queue */
|
struct work_s sk_work; /* For deferring work to the work queue */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This holds the information visible to uIP/NuttX */
|
/* This holds the information visible to the NuttX network */
|
||||||
|
|
||||||
struct net_driver_s sk_dev; /* Interface understood by uIP */
|
struct net_driver_s sk_dev; /* Interface understood by the network */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -215,7 +215,8 @@ static int skel_transmit(FAR struct skel_driver_s *priv)
|
|||||||
|
|
||||||
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
|
/* Setup the TX timeout watchdog (perhaps restarting the timer) */
|
||||||
|
|
||||||
(void)wd_start(priv->sk_txtimeout, skeleton_TXTIMEOUT, skel_txtimeout_expiry, 1, (uint32_t)priv);
|
(void)wd_start(priv->sk_txtimeout, skeleton_TXTIMEOUT,
|
||||||
|
skel_txtimeout_expiry, 1, (uint32_t)priv);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,8 +224,9 @@ static int skel_transmit(FAR struct skel_driver_s *priv)
|
|||||||
* Function: skel_txpoll
|
* Function: skel_txpoll
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The transmitter is available, check if uIP has any outgoing packets ready
|
* The transmitter is available, check if the network has any outgoing
|
||||||
* to send. This is a callback from devif_poll(). devif_poll() may be called:
|
* packets ready to send. This is a callback from devif_poll().
|
||||||
|
* devif_poll() may be called:
|
||||||
*
|
*
|
||||||
* 1. When the preceding TX packet send is complete,
|
* 1. When the preceding TX packet send is complete,
|
||||||
* 2. When the preceding TX packet send timesout and the interface is reset
|
* 2. When the preceding TX packet send timesout and the interface is reset
|
||||||
@@ -314,7 +316,9 @@ static void skel_receive(FAR struct skel_driver_s *priv)
|
|||||||
{
|
{
|
||||||
/* Check for errors and update statistics */
|
/* Check for errors and update statistics */
|
||||||
|
|
||||||
/* Check if the packet is a valid size for the uIP buffer configuration */
|
/* Check if the packet is a valid size for the network buffer
|
||||||
|
* configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Copy the data data from the hardware to priv->sk_dev.d_buf. Set
|
/* Copy the data data from the hardware to priv->sk_dev.d_buf. Set
|
||||||
* amount of data in priv->sk_dev.d_len
|
* amount of data in priv->sk_dev.d_len
|
||||||
@@ -451,7 +455,7 @@ static void skel_txdone(FAR struct skel_driver_s *priv)
|
|||||||
|
|
||||||
wd_cancel(priv->sk_txtimeout);
|
wd_cancel(priv->sk_txtimeout);
|
||||||
|
|
||||||
/* Then poll uIP for new XMIT data */
|
/* Then poll the network for new XMIT data */
|
||||||
|
|
||||||
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
||||||
}
|
}
|
||||||
@@ -607,7 +611,7 @@ static inline void skel_txtimeout_process(FAR struct skel_driver_s *priv)
|
|||||||
|
|
||||||
/* Then reset the hardware */
|
/* Then reset the hardware */
|
||||||
|
|
||||||
/* Then poll uIP for new XMIT data */
|
/* Then poll the network for new XMIT data */
|
||||||
|
|
||||||
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
||||||
}
|
}
|
||||||
@@ -713,9 +717,9 @@ static inline void skel_poll_process(FAR struct skel_driver_s *priv)
|
|||||||
* the TX poll if he are unable to accept another packet for transmission.
|
* the TX poll if he are unable to accept another packet for transmission.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
|
/* If so, update TCP timing states and poll the network for new XMIT data.
|
||||||
* might be bug here. Does this mean if there is a transmit in progress,
|
* Hmmm.. might be bug here. Does this mean if there is a transmit in
|
||||||
* we will missing TCP time state updates?
|
* progress, we will missing TCP time state updates?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(void)devif_timer(&priv->sk_dev, skel_txpoll, skeleton_POLLHSEC);
|
(void)devif_timer(&priv->sk_dev, skel_txpoll, skeleton_POLLHSEC);
|
||||||
@@ -927,7 +931,7 @@ static inline void skel_txavail_process(FAR struct skel_driver_s *priv)
|
|||||||
{
|
{
|
||||||
/* Check if there is room in the hardware to hold another outgoing packet. */
|
/* Check if there is room in the hardware to hold another outgoing packet. */
|
||||||
|
|
||||||
/* If so, then poll uIP for new XMIT data */
|
/* If so, then poll the network for new XMIT data */
|
||||||
|
|
||||||
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
(void)devif_poll(&priv->sk_dev, skel_txpoll);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <nuttx/net/netconfig.h>
|
#include <nuttx/net/netconfig.h>
|
||||||
|
#include <nuttx/net/ip.h>
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_LOOPBACK
|
#ifdef CONFIG_NETDEV_LOOPBACK
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <nuttx/net/loopback.h>
|
||||||
|
|
||||||
#include "lib_internal.h"
|
#include "lib_internal.h"
|
||||||
#include "netdb/lib_netdb.h"
|
#include "netdb/lib_netdb.h"
|
||||||
@@ -153,11 +154,10 @@ static int lib_localhost(FAR const void *addr, socklen_t len, int type,
|
|||||||
FAR struct hostent_info_s *info;
|
FAR struct hostent_info_s *info;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
FAR const uint8_t *src;
|
FAR const uint8_t *src;
|
||||||
FAR uint8_t *dest;
|
FAR char *dest;
|
||||||
bool match;
|
bool match;
|
||||||
int herrnocode;
|
int herrnocode;
|
||||||
int namelen;
|
int namelen;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (lib_lo_ipv4match(addr, len, type))
|
if (lib_lo_ipv4match(addr, len, type))
|
||||||
{
|
{
|
||||||
@@ -193,7 +193,7 @@ static int lib_localhost(FAR const void *addr, socklen_t len, int type,
|
|||||||
|
|
||||||
|
|
||||||
info = (FAR struct hostent_info_s *)buf;
|
info = (FAR struct hostent_info_s *)buf;
|
||||||
dest = (FAR uint8_t *)info->hi_data;
|
dest = info->hi_data;
|
||||||
buflen -= (sizeof(struct hostent_info_s) - 1);
|
buflen -= (sizeof(struct hostent_info_s) - 1);
|
||||||
|
|
||||||
memset(host, 0, sizeof(struct hostent));
|
memset(host, 0, sizeof(struct hostent));
|
||||||
@@ -204,7 +204,7 @@ static int lib_localhost(FAR const void *addr, socklen_t len, int type,
|
|||||||
host->h_addr_list = info->hi_addrlist;
|
host->h_addr_list = info->hi_addrlist;
|
||||||
host->h_length = addrlen;
|
host->h_length = addrlen;
|
||||||
|
|
||||||
ptr += addrlen;
|
dest += addrlen;
|
||||||
buflen -= addrlen;
|
buflen -= addrlen;
|
||||||
|
|
||||||
/* And copy localhost host name */
|
/* And copy localhost host name */
|
||||||
@@ -216,7 +216,7 @@ static int lib_localhost(FAR const void *addr, socklen_t len, int type,
|
|||||||
goto errorout_with_herrnocode;
|
goto errorout_with_herrnocode;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ptr, g_lo_hostname, buflen);
|
strncpy(dest, g_lo_hostname, buflen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <nuttx/net/dns.h>
|
#include <nuttx/net/dns.h>
|
||||||
|
#include <nuttx/net/loopback.h>
|
||||||
|
|
||||||
#include "lib_internal.h"
|
#include "lib_internal.h"
|
||||||
#include "netdb/lib_dns.h"
|
#include "netdb/lib_dns.h"
|
||||||
@@ -236,10 +237,9 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||||||
{
|
{
|
||||||
FAR struct hostent_info_s *info;
|
FAR struct hostent_info_s *info;
|
||||||
socklen_t addrlen;
|
socklen_t addrlen;
|
||||||
FAR const uint8_t *src;
|
FAR const char *src;
|
||||||
FAR uint8_t *dest;
|
FAR char *dest;
|
||||||
int namelen;
|
int namelen;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (strcmp(name, "localhost") == 0)
|
if (strcmp(name, "localhost") == 0)
|
||||||
{
|
{
|
||||||
@@ -249,14 +249,14 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||||||
/* Setup to transfer the IPv4 address */
|
/* Setup to transfer the IPv4 address */
|
||||||
|
|
||||||
addrlen = sizeof(struct in_addr);
|
addrlen = sizeof(struct in_addr);
|
||||||
src = (FAR uint8_t *)&g_lo_ipv4addr;
|
src = (FAR const char *)&g_lo_ipv4addr;
|
||||||
host->h_addrtype = AF_INET;
|
host->h_addrtype = AF_INET;
|
||||||
|
|
||||||
#else /* CONFIG_NET_IPv6 */
|
#else /* CONFIG_NET_IPv6 */
|
||||||
/* Setup to transfer the IPv6 address */
|
/* Setup to transfer the IPv6 address */
|
||||||
|
|
||||||
addrlen = sizeof(struct in6_addr);
|
addrlen = sizeof(struct in6_addr);
|
||||||
src = (FAR uint8_t *)&g_lo_ipv6addr;
|
src = (FAR const char *)&g_lo_ipv6addr;
|
||||||
host->h_addrtype = AF_INET6;
|
host->h_addrtype = AF_INET6;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||||||
}
|
}
|
||||||
|
|
||||||
info = (FAR struct hostent_info_s *)buf;
|
info = (FAR struct hostent_info_s *)buf;
|
||||||
dest = (FAR uint8_t *)info->hi_data;
|
dest = info->hi_data;
|
||||||
buflen -= (sizeof(struct hostent_info_s) - 1);
|
buflen -= (sizeof(struct hostent_info_s) - 1);
|
||||||
|
|
||||||
memset(host, 0, sizeof(struct hostent));
|
memset(host, 0, sizeof(struct hostent));
|
||||||
@@ -281,7 +281,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||||||
host->h_addr_list = info->hi_addrlist;
|
host->h_addr_list = info->hi_addrlist;
|
||||||
host->h_length = addrlen;
|
host->h_length = addrlen;
|
||||||
|
|
||||||
ptr += addrlen;
|
dest += addrlen;
|
||||||
buflen -= addrlen;
|
buflen -= addrlen;
|
||||||
|
|
||||||
/* And copy name */
|
/* And copy name */
|
||||||
@@ -292,7 +292,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
|
|||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(ptr, name, buflen);
|
strncpy(dest, name, buflen);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# net/route/Make.defs
|
# net/loopback/Make.defs
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -33,16 +33,15 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_ROUTE),y)
|
ifeq ($(CONFIG_NETDEV_LOOPBACK),y)
|
||||||
|
|
||||||
# Routing table support
|
# Local loopback support
|
||||||
|
|
||||||
SOCK_CSRCS += net_addroute.c net_allocroute.c net_delroute.c
|
NETDEV_CSRCS += lo_globals.c
|
||||||
SOCK_CSRCS += net_foreachroute.c net_router.c netdev_router.c
|
|
||||||
|
|
||||||
# Include routing table build support
|
# Include routing table build support
|
||||||
|
|
||||||
DEPPATH += --dep-path route
|
DEPPATH += --dep-path loopback
|
||||||
VPATH += :route
|
VPATH += :loopback
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user