Fix some initial loop back device compilation errors; mark configuration as EXPERIMENTAL

This commit is contained in:
Gregory Nutt 2015-08-24 11:29:54 -06:00
parent ccb24e1766
commit 0b012c7978
7 changed files with 38 additions and 34 deletions

View File

@ -9,6 +9,7 @@ config NETDEV_LOOPBACK
bool "Local loopback support"
default n
select NET_NOINTS
depends on EXPERIMENTAL
---help---
Add support for the local network loopback device, lo. Any additional
networking devices that are enabled must be compatible with

View File

@ -213,7 +213,6 @@ static void lo_loopback(FAR struct lo_driver_s *priv)
{
ndbg("WARNING: Unrecognized packet type dropped: %04x\n", BUF->type);
}
#endif
}
/****************************************************************************

View File

@ -113,9 +113,9 @@ struct skel_driver_s
struct work_s sk_work; /* For deferring work to the work queue */
#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) */
(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;
}
@ -223,8 +224,9 @@ static int skel_transmit(FAR struct skel_driver_s *priv)
* Function: skel_txpoll
*
* Description:
* The transmitter is available, check if uIP has any outgoing packets ready
* to send. This is a callback from devif_poll(). devif_poll() may be called:
* The transmitter is available, check if the network has any outgoing
* 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,
* 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 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
* 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);
/* Then poll uIP for new XMIT data */
/* Then poll the network for new XMIT data */
(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 poll uIP for new XMIT data */
/* Then poll the network for new XMIT data */
(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.
*/
/* If so, update TCP timing states and poll uIP for new XMIT data. Hmmm..
* might be bug here. Does this mean if there is a transmit in progress,
* we will missing TCP time state updates?
/* If so, update TCP timing states and poll the network for new XMIT data.
* Hmmm.. might be bug here. Does this mean if there is a transmit in
* progress, we will missing TCP time state updates?
*/
(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. */
/* 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);
}

View File

@ -47,6 +47,7 @@
#include <nuttx/config.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/ip.h>
#ifdef CONFIG_NETDEV_LOOPBACK

View File

@ -46,6 +46,7 @@
#include <errno.h>
#include <arpa/inet.h>
#include <nuttx/net/loopback.h>
#include "lib_internal.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;
socklen_t addrlen;
FAR const uint8_t *src;
FAR uint8_t *dest;
FAR char *dest;
bool match;
int herrnocode;
int namelen;
int ret;
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;
dest = (FAR uint8_t *)info->hi_data;
dest = info->hi_data;
buflen -= (sizeof(struct hostent_info_s) - 1);
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_length = addrlen;
ptr += addrlen;
dest += addrlen;
buflen -= addrlen;
/* 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;
}
strncpy(ptr, g_lo_hostname, buflen);
strncpy(dest, g_lo_hostname, buflen);
return 0;
}

View File

@ -51,6 +51,7 @@
#include <arpa/inet.h>
#include <nuttx/net/dns.h>
#include <nuttx/net/loopback.h>
#include "lib_internal.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;
socklen_t addrlen;
FAR const uint8_t *src;
FAR uint8_t *dest;
FAR const char *src;
FAR char *dest;
int namelen;
int ret;
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 */
addrlen = sizeof(struct in_addr);
src = (FAR uint8_t *)&g_lo_ipv4addr;
src = (FAR const char *)&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;
src = (FAR const char *)&g_lo_ipv6addr;
host->h_addrtype = AF_INET6;
#endif
@ -270,7 +270,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
}
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);
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_length = addrlen;
ptr += addrlen;
dest += addrlen;
buflen -= addrlen;
/* And copy name */
@ -292,7 +292,7 @@ static int lib_localhost(FAR const char *name, FAR struct hostent *host,
return -ERANGE;
}
strncpy(ptr, name, buflen);
strncpy(dest, name, buflen);
return 0;
}

View File

@ -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>
#
# 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
SOCK_CSRCS += net_foreachroute.c net_router.c netdev_router.c
NETDEV_CSRCS += lo_globals.c
# Include routing table build support
DEPPATH += --dep-path route
VPATH += :route
DEPPATH += --dep-path loopback
VPATH += :loopback
endif