netutils: nxstyle fixes

fixes for errors reported by nxstyle tool

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2021-06-11 12:06:42 +02:00 committed by Xiang Xiao
parent adc3c9fae9
commit 5572819bb1
52 changed files with 228 additions and 173 deletions

View File

@ -30,6 +30,7 @@
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* This is a mindless little wrapper around include/nuttx/config.h. Every /* This is a mindless little wrapper around include/nuttx/config.h. Every
* file in the ftpc directory includes this file at the very beginning of * file in the ftpc directory includes this file at the very beginning of
* of the file (instead of include/nuttx/config.h). The only purpose of * of the file (instead of include/nuttx/config.h). The only purpose of
@ -58,7 +59,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions Prototypes
****************************************************************************/ ****************************************************************************/
#endif /* __APPS_NETUTILS_FTPC_FTPC_CONFIG_H */ #endif /* __APPS_NETUTILS_FTPC_FTPC_CONFIG_H */

View File

@ -77,8 +77,8 @@ int ftpc_help(SESSION handle, FAR const char *arg)
ret = ftpc_cmd(session, "HELP"); ret = ftpc_cmd(session, "HELP");
} }
/* Logic is missing here to return the help string to the caller. The caller /* Logic is missing here to return the help string to the caller.
* needs to call ftpc_getreply. * The caller needs to call ftpc_getreply.
*/ */
return ret; return ret;

View File

@ -65,8 +65,8 @@ int ftpc_unlink(SESSION handle, FAR const char *path)
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle; FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
int ret; int ret;
/* A DELE request asks the server to remove a regular file. A typical server /* A DELE request asks the server to remove a regular file.
* accepts DELE with: * A typical server accepts DELE with:
* *
* - "250 Requested file action okay, completed" if the file was * - "250 Requested file action okay, completed" if the file was
* successfully removed * successfully removed

View File

@ -298,7 +298,9 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle)
rxoff++; rxoff++;
} }
/* Check for overflow, version code should not fill the tmpbuf */ /* Check for overflow,
* version code should not fill the tmpbuf
*/
if (tmplen == sizeof(tmpbuf)) if (tmplen == sizeof(tmpbuf))
{ {
@ -350,7 +352,9 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle)
rxoff++; rxoff++;
} }
/* Check for overflow, version code should not fill the tmpbuf */ /* Check for overflow,
* version code should not fill the tmpbuf
*/
if (tmplen == sizeof(tmpbuf)) if (tmplen == sizeof(tmpbuf))
{ {
@ -501,12 +505,14 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle)
{ {
curl4nx_info( curl4nx_info(
"Too many redirections\n"); "Too many redirections\n");
cret = CURL4NXE_TOO_MANY_REDIRECTS; cret =
CURL4NXE_TOO_MANY_REDIRECTS;
goto close; goto close;
} }
cret = cret =
curl4nx_easy_setopt(handle, curl4nx_easy_setopt(
handle,
CURL4NXOPT_URL, CURL4NXOPT_URL,
headerbuf + off); headerbuf + off);
if (cret != CURL4NXE_OK) if (cret != CURL4NXE_OK)
@ -516,7 +522,8 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle)
redirected = true; redirected = true;
redircount += 1; redircount += 1;
curl4nx_info("REDIRECTION (%d) -> %s\n", curl4nx_info("
REDIRECTION (%d) -> %s\n",
redircount, redircount,
headerbuf + off); headerbuf + off);
} }

View File

@ -120,6 +120,7 @@ int curl4nx_easy_setopt(FAR struct curl4nx_s *handle, int option,
cret = CURL4NXE_BAD_FUNCTION_ARGUMENT; cret = CURL4NXE_BAD_FUNCTION_ARGUMENT;
break; break;
} }
handle->port = (uint16_t)(port & 0xffff); handle->port = (uint16_t)(port & 0xffff);
break; break;
} }
@ -196,6 +197,7 @@ int curl4nx_easy_setopt(FAR struct curl4nx_s *handle, int option,
cret = CURL4NXE_BAD_FUNCTION_ARGUMENT; cret = CURL4NXE_BAD_FUNCTION_ARGUMENT;
break; break;
} }
handle->max_redirs = redirs; handle->max_redirs = redirs;
break; break;
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* apps/netutils/curl4nx/curl4nx_private.h * apps/netutils/libcurl4nx/curl4nx_private.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -96,7 +96,7 @@
while(0) while(0)
/**************************************************************************** /****************************************************************************
* Private Types * Public Types
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_delarp.c * apps/netutils/netlib/netlib_delarp.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_eaddrconv.c * apps/netutils/netlib/netlib_eaddrconv.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getarp.c * apps/netutils/netlib/netlib_getarp.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getarptab.c * apps/netutils/netlib/netlib_getarptab.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getdevs.c * apps/netutils/netlib/netlib_getdevs.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getdripv4addr.c * apps/netutils/netlib/netlib_getdripv4addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getessid.c * apps/netutils/netlib/netlib_getessid.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getifstatus.c * apps/netutils/netlib/netlib_getifstatus.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getipv4addr.c * apps/netutils/netlib/netlib_getipv4addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getipv4netmask.c * apps/netutils/netlib/netlib_getipv4netmask.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getipv6addr.c * apps/netutils/netlib/netlib_getipv6addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getmacaddr.c * apps/netutils/netlib/netlib_getmacaddr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getntab.c * apps/netutils/netlib/netlib_getnbtab.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getnodnodeaddr.c * apps/netutils/netlib/netlib_getnodeaddr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getpanid.c * apps/netutils/netlib/netlib_getpanid.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_getproperties.c * apps/netutils/netlib/netlib_getproperties.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipmsfilter.c * apps/netutils/netlib/netlib_ipmsfilter.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_ipv4route.c * apps/netutils/netlib/netlib_ipv4route.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -71,7 +71,9 @@
static void set_nul_terminator(FAR char *str) static void set_nul_terminator(FAR char *str)
{ {
/* The first non-decimal character that is not '.' terminates the address */ /* The first non-decimal character that is not '.' terminates the
* address
*/
while ((*str >= '0' && *str <= '9') || *str == '.') while ((*str >= '0' && *str <= '9') || *str == '.')
{ {

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_ipv4router.c * apps/netutils/netlib/netlib_ipv4router.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -81,7 +81,9 @@ int netlib_ipv4router(FAR const struct in_addr *destipaddr,
hdest = ntohl(destipaddr->s_addr); hdest = ntohl(destipaddr->s_addr);
/* Find the routing table entry that provides the router for this sub-net. */ /* Find the routing table entry that provides the router for this
* sub-net.
*/
for (; ; ) for (; ; )
{ {

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_ipv6netmask2prefix.c * apps/netutils/netlib/netlib_ipv6netmask2prefix.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_ipv6route.c * apps/netutils/netlib/netlib_ipv6route.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_ipv6router.c * apps/netutils/netlib/netlib_ipv6router.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -88,7 +88,9 @@ int netlib_ipv6router(FAR const struct in6_addr *destipaddr,
hdest[6] = ntohs(destipaddr->s6_addr16[6]); hdest[6] = ntohs(destipaddr->s6_addr16[6]);
hdest[7] = ntohs(destipaddr->s6_addr16[7]); hdest[7] = ntohs(destipaddr->s6_addr16[7]);
/* Find the routing table entry that provides the router for this sub-net. */ /* Find the routing table entry that provides the router for this
* sub-net.
*/
for (; ; ) for (; ; )
{ {

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_listenon.c * apps/netutils/netlib/netlib_listenon.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -77,7 +77,8 @@ int netlib_listenon(uint16_t portno)
/* Set socket to reuse address */ /* Set socket to reuse address */
optval = 1; optval = 1;
if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0) if (setsockopt(listensd, SOL_SOCKET,
SO_REUSEADDR, (void *)&optval, sizeof(int)) < 0)
{ {
nwarn("WARNING: setsockopt SO_REUSEADDR failure: %d\n", errno); nwarn("WARNING: setsockopt SO_REUSEADDR failure: %d\n", errno);
} }
@ -88,7 +89,8 @@ int netlib_listenon(uint16_t portno)
myaddr.sin_port = portno; myaddr.sin_port = portno;
myaddr.sin_addr.s_addr = INADDR_ANY; myaddr.sin_addr.s_addr = INADDR_ANY;
if (bind(listensd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0) if (bind(listensd, (struct sockaddr *)&myaddr,
sizeof(struct sockaddr_in)) < 0)
{ {
nerr("ERROR: bind failure: %d\n", errno); nerr("ERROR: bind failure: %d\n", errno);
goto errout_with_socket; goto errout_with_socket;

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_nodeaddrconv.c * apps/netutils/netlib/netlib_nodeaddrconv.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_parsehttpurl.c * apps/netutils/netlib/netlib_parsehttpurl.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_saddrconv.c * apps/netutils/netlib/netlib_saddrconv.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -63,7 +63,8 @@
* *
****************************************************************************/ ****************************************************************************/
void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksize) void netlib_server(uint16_t portno,
pthread_startroutine_t handler, int stacksize)
{ {
struct sockaddr_in myaddr; struct sockaddr_in myaddr;
#ifdef CONFIG_NET_SOLINGER #ifdef CONFIG_NET_SOLINGER
@ -108,7 +109,8 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz
ling.l_onoff = 1; ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */ ling.l_linger = 30; /* timeout is seconds */
ret = setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)); ret = setsockopt(acceptsd, SOL_SOCKET,
SO_LINGER, &ling, sizeof(struct linger));
if (ret < 0) if (ret < 0)
{ {
close(acceptsd); close(acceptsd);
@ -124,7 +126,8 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, stacksize); pthread_attr_setstacksize(&attr, stacksize);
ret = pthread_create(&child, &attr, handler, (pthread_addr_t)((uintptr_t)acceptsd)); ret = pthread_create(&child, &attr,
handler, (pthread_addr_t)((uintptr_t)acceptsd));
if (ret != 0) if (ret != 0)
{ {
/* Close the connection */ /* Close the connection */

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setarp.c * apps/netutils/netlib/netlib_setarp.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setdripv4addr.c * apps/netutils/netlib/netlib_setdripv4addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -105,6 +105,7 @@ int netlib_set_dripv4addr(FAR const char *ifname,
if (OK == ret) if (OK == ret)
{ {
/* Delete the default route first */ /* Delete the default route first */
/* This call fails if no default route exists, but it's OK */ /* This call fails if no default route exists, but it's OK */
delroute(sockfd, delroute(sockfd,

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_seteaddr.c * apps/netutils/netlib/netlib_seteaddr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setessid.c * apps/netutils/netlib/netlib_setessid.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setifstatus.c * apps/netutils/netlib/netlib_setifstatus.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipv4addr.c * apps/netutils/netlib/netlib_setipv4addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -56,7 +56,8 @@
* *
****************************************************************************/ ****************************************************************************/
int netlib_set_ipv4addr(FAR const char *ifname, FAR const struct in_addr *addr) int netlib_set_ipv4addr(FAR const char *ifname,
FAR const struct in_addr *addr)
{ {
int ret = ERROR; int ret = ERROR;

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipv4dnsaddr.c * apps/netutils/netlib/netlib_setipv4dnsaddr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipv4netmask.c * apps/netutils/netlib/netlib_setipv4netmask.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipv6addr.c * apps/netutils/netlib/netlib_setipv6addr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -80,7 +80,8 @@ int netlib_set_ipv6addr(FAR const char *ifname,
inaddr->sin6_port = 0; inaddr->sin6_port = 0;
memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr)); memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr));
ret = ioctl(sockfd, SIOCSLIFADDR, ((unsigned long)(uintptr_t)&req)); ret = ioctl(sockfd, SIOCSLIFADDR,
((unsigned long)(uintptr_t)&req));
close(sockfd); close(sockfd);
} }
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setipv6netmask.c * apps/netutils/netlib/netlib_setipv6netmask.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -79,7 +79,8 @@ int netlib_set_ipv6netmask(FAR const char *ifname,
inaddr->sin6_port = 0; inaddr->sin6_port = 0;
memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr)); memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr));
ret = ioctl(sockfd, SIOCSLIFNETMASK, (unsigned long)((uintptr_t)&req)); ret = ioctl(sockfd, SIOCSLIFNETMASK,
(unsigned long)((uintptr_t)&req));
close(sockfd); close(sockfd);
} }
} }

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/netlib/netlib_setmacaddr.c * apps/netutils/netlib/netlib_setmacaddr.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/tftp/tftpc_get.c * apps/netutils/tftpc/tftpc_get.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/tftoc/tftpc_internal.h * apps/netutils/tftpc/tftpc_internal.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -42,6 +42,7 @@
****************************************************************************/ ****************************************************************************/
/* Verify TFTP configuration settings ***************************************/ /* Verify TFTP configuration settings ***************************************/
/* The settings beginning with CONFIG_NETUTILS_TFTP_* can all be set in the /* The settings beginning with CONFIG_NETUTILS_TFTP_* can all be set in the
* NuttX configuration file. If they are are defined in the configuration * NuttX configuration file. If they are are defined in the configuration
* then default values are assigned here. * then default values are assigned here.
@ -157,15 +158,19 @@
/* Defined in tftp_packet.c *************************************************/ /* Defined in tftp_packet.c *************************************************/
extern int tftp_sockinit(struct sockaddr_in *server, in_addr_t addr); extern int tftp_sockinit(struct sockaddr_in *server, in_addr_t addr);
extern int tftp_mkreqpacket(uint8_t *buffer, int opcode, const char *path, bool binary); extern int tftp_mkreqpacket(uint8_t *buffer, int opcode,
const char *path, bool binary);
extern int tftp_mkackpacket(uint8_t *buffer, uint16_t blockno); extern int tftp_mkackpacket(uint8_t *buffer, uint16_t blockno);
extern int tftp_mkerrpacket(uint8_t *buffer, uint16_t errorcode, const char *errormsg); extern int tftp_mkerrpacket(uint8_t *buffer, uint16_t errorcode,
const char *errormsg);
#ifdef CONFIG_DEBUG_NET_WARN #ifdef CONFIG_DEBUG_NET_WARN
extern int tftp_parseerrpacket(const uint8_t *packet); extern int tftp_parseerrpacket(const uint8_t *packet);
#endif #endif
extern ssize_t tftp_recvfrom(int sd, void *buf, size_t len, struct sockaddr_in *from); extern ssize_t tftp_recvfrom(int sd, void *buf,
extern ssize_t tftp_sendto(int sd, const void *buf, size_t len, struct sockaddr_in *to); size_t len, struct sockaddr_in *from);
extern ssize_t tftp_sendto(int sd, const void *buf,
size_t len, struct sockaddr_in *to);
#ifdef CONFIG_NETUTILS_TFTP_DUMPBUFFERS #ifdef CONFIG_NETUTILS_TFTP_DUMPBUFFERS
# define tftp_dumpbuffer(msg, buffer, nbytes) ninfodumpbuffer(msg, buffer, nbytes) # define tftp_dumpbuffer(msg, buffer, nbytes) ninfodumpbuffer(msg, buffer, nbytes)

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/tftp/tftpc_packets.c * apps/netutils/tftpc/tftpc_packets.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/tftp/tftpc_put.c * apps/netutils/tftpc/tftpc_put.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/thttpd/config.h * apps/netutils/thttpd/config.h
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -22,7 +22,7 @@
#define __NETUTILS_THTTPD_CONFIG_H #define __NETUTILS_THTTPD_CONFIG_H
/**************************************************************************** /****************************************************************************
* Included files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@ -88,15 +88,17 @@
# define CONFIG_THTTPD_CGI_PATH "/mnt/www/cgi-bin" # define CONFIG_THTTPD_CGI_PATH "/mnt/www/cgi-bin"
# endif # endif
/* Only CGI programs whose fully expanded paths match this pattern will be executed. In fact, /* Only CGI programs whose fully expanded paths match this pattern will be
* if this value is not defined then no CGI logic will be built. * executed. In fact, if this value is not defined then no CGI logic will
* be built.
*/ */
# ifndef CONFIG_THTTPD_CGI_PATTERN # ifndef CONFIG_THTTPD_CGI_PATTERN
# define CONFIG_THTTPD_CGI_PATTERN "/mnt/www/cgi-bin/*" # define CONFIG_THTTPD_CGI_PATTERN "/mnt/www/cgi-bin/*"
# endif # endif
/* These provide the priority and stack size of the CGI child tasks */ /* These provide the priority and stack size of the CGI child tasks
*/
# ifndef CONFIG_THTTPD_CGI_PRIORITY # ifndef CONFIG_THTTPD_CGI_PRIORITY
# define CONFIG_THTTPD_CGI_PRIORITY 50 # define CONFIG_THTTPD_CGI_PRIORITY 50
@ -106,25 +108,29 @@
# define CONFIG_THTTPD_CGI_STACKSIZE 2048 # define CONFIG_THTTPD_CGI_STACKSIZE 2048
# endif # endif
/* Byte output limit for CGI tasks */ /* Byte output limit for CGI tasks
*/
# ifndef CONFIG_THTTPD_CGI_BYTECOUNT # ifndef CONFIG_THTTPD_CGI_BYTECOUNT
# define CONFIG_THTTPD_CGI_BYTECOUNT 200000 # define CONFIG_THTTPD_CGI_BYTECOUNT 200000
# endif # endif
/* How many seconds to allow CGI programs to run before killing them. */ /* How many seconds to allow CGI programs to run before killing them.
*/
# ifndef CONFIG_THTTPD_CGI_TIMELIMIT # ifndef CONFIG_THTTPD_CGI_TIMELIMIT
# define CONFIG_THTTPD_CGI_TIMELIMIT 0 /* No time limit */ # define CONFIG_THTTPD_CGI_TIMELIMIT 0 /* No time limit */
# endif # endif
/* The default character set name to use with text MIME types. */ /* The default character set name to use with text MIME types.
*/
# ifndef CONFIG_THTTPD_CHARSET # ifndef CONFIG_THTTPD_CHARSET
# define CONFIG_THTTPD_CHARSET "iso-8859-1" # define CONFIG_THTTPD_CHARSET "iso-8859-1"
# endif # endif
/* Initial buffer size, buffer reallocation increment, maximum buffer size */ /* Initial buffer size, buffer reallocation increment, maximum buffer size
*/
# ifndef CONFIG_THTTPD_IOBUFFERSIZE # ifndef CONFIG_THTTPD_IOBUFFERSIZE
# define CONFIG_THTTPD_IOBUFFERSIZE 256 # define CONFIG_THTTPD_IOBUFFERSIZE 256
@ -154,78 +160,93 @@
# error "Can't use uint16_t for buffer size" # error "Can't use uint16_t for buffer size"
# endif # endif
/* A list of index filenames to check. The files are searched for in this order. */ /* A list of index filenames to check.
* The files are searched for in this order.
*/
# ifndef CONFIG_THTTPD_INDEX_NAMES # ifndef CONFIG_THTTPD_INDEX_NAMES
# define CONFIG_THTTPD_INDEX_NAMES "index.html", "index.htm", "index.cgi" # define CONFIG_THTTPD_INDEX_NAMES "index.html", "index.htm", "index.cgi"
# endif # endif
/* CONFIG_AUTH_FILE - The file to use for authentication. If this is defined then /* CONFIG_AUTH_FILE - The file to use for authentication. If this is defined
* thttpd checks for this file in the local directory before every fetch. If the * then thttpd checks for this file in the local directory before every
* file exists then authentication is done, otherwise the fetch proceeds as usual. * fetch. If the file exists then authentication is done, otherwise the
* If you leave this undefined then thttpd will not implement authentication at * fetch proceeds as usual.
* all and will not check for auth files, which saves a bit of CPU time. * If you leave this undefined then thttpd will not implement
* A typical value is ".htpasswd" * authentication at all and will not check for auth files, which saves a
* bit of CPU time. A typical value is ".htpasswd"
*/ */
/* The listen() backlog queue length. */ /* The listen() backlog queue length.
*/
# ifndef CONFIG_THTTPD_LISTEN_BACKLOG # ifndef CONFIG_THTTPD_LISTEN_BACKLOG
# define CONFIG_THTTPD_LISTEN_BACKLOG 8 # define CONFIG_THTTPD_LISTEN_BACKLOG 8
# endif # endif
/* How many milliseconds to leave a connection open while doing a lingering close */ /* How many milliseconds to leave a connection open while doing a lingering
* close
*/
# ifndef CONFIG_THTTPD_LINGER_MSEC # ifndef CONFIG_THTTPD_LINGER_MSEC
# define CONFIG_THTTPD_LINGER_MSEC 500 # define CONFIG_THTTPD_LINGER_MSEC 500
# endif # endif
/* How often to run the occasional cleanup job.*/ /* How often to run the occasional cleanup job.
*/
# ifndef CONFIG_THTTPD_OCCASIONAL_MSEC # ifndef CONFIG_THTTPD_OCCASIONAL_MSEC
# define CONFIG_THTTPD_OCCASIONAL_MSEC 120 /* Two minutes */ # define CONFIG_THTTPD_OCCASIONAL_MSEC 120 /* Two minutes */
# endif # endif
/* How many seconds to allow for reading the initial request on a new connection. */ /* How many seconds to allow for reading the initial request on a new
* connection.
*/
# ifndef CONFIG_THTTPD_IDLE_READ_LIMIT_SEC # ifndef CONFIG_THTTPD_IDLE_READ_LIMIT_SEC
# define CONFIG_THTTPD_IDLE_READ_LIMIT_SEC 300 # define CONFIG_THTTPD_IDLE_READ_LIMIT_SEC 300
# endif # endif
/* How many seconds before an idle connection gets closed. */ /* How many seconds before an idle connection gets closed.
*/
# ifndef CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC # ifndef CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC
# define CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC 300 # define CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC 300
# endif # endif
/* Memory debug instrumentation depends on other debug options */ /* Memory debug instrumentation depends on other debug options
*/
# if (!defined(CONFIG_DEBUG_FEATURES) || !defined(CONFIG_DEBUG_NET)) && defined(CONFIG_THTTPD_MEMDEBUG) # if (!defined(CONFIG_DEBUG_FEATURES) || !defined(CONFIG_DEBUG_NET)) && defined(CONFIG_THTTPD_MEMDEBUG)
# undef CONFIG_THTTPD_MEMDEBUG # undef CONFIG_THTTPD_MEMDEBUG
# endif # endif
/* Tilde mapping. Many URLs use ~username to indicate a user's home directory. thttpd /* Tilde mapping.
* provides two options for mapping this construct to an actual filename. * Many URLs use ~username to indicate a user's home directory.
* thttpd provides two options for mapping this construct to an actual
* filename.
* *
* 1) Map ~username to <prefix>/username. This is the recommended choice. Each user * 1) Map ~username to <prefix>/username. This is the recommended choice.
* gets a subdirectory in the main web tree, and the tilde construct points there. * Each user gets a subdirectory in the main web tree, and the tilde
* construct points there.
* The prefix could be something like "users", or it could be empty. * The prefix could be something like "users", or it could be empty.
* 2) Map ~username to <user's homedir>/<postfix>. The postfix would be the name of * 2) Map ~username to <user's homedir>/<postfix>. The postfix would be
* a subdirectory off of the user's actual home dir, something like "public_html". * the name of a subdirectory off of the user's actual home dir, something
* like "public_html".
* *
* You can also leave both options undefined, and thttpd will not do anything special * You can also leave both options undefined, and thttpd will not do anything
* about tildes. Enabling both options is an error. * special about tildes. Enabling both options is an error.
* *
* Typical values, if they're defined, are "users" for CONFIG_THTTPD_TILDE_MAP1 and "public_html" * Typical values, if they're defined, are "users" for
* for CONFIG_THTTPD_TILDE_MAP2. * CONFIG_THTTPD_TILDE_MAP1 and "public_html" for CONFIG_THTTPD_TILDE_MAP2.
*/ */
# if defined(CONFIG_THTTPD_TILDE_MAP1) && defined(CONFIG_THTTPD_TILDE_MAP2) # if defined(CONFIG_THTTPD_TILDE_MAP1) && defined(CONFIG_THTTPD_TILDE_MAP2)
# error "Both CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 are defined" # error "Both CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 are defined"
# endif # endif
/* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and verify /* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and
* referrers. * verify referrers.
*/ */
#else /* Dependencies not provided */ #else /* Dependencies not provided */

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/webserver/httpd_mmap.c * apps/netutils/webserver/httpd_mmap.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -19,7 +19,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Header Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@ -94,7 +94,9 @@ int httpd_mmap_open(const char *name, struct httpd_fs_file *file)
file->len = (int) st.st_size; file->len = (int) st.st_size;
/* SUS3: "If len is zero, mmap() shall fail and no mapping shall be established." */ /* SUS3: "If len is zero, mmap() shall fail and no mapping shall
* be established."
*/
if (st.st_size == 0) if (st.st_size == 0)
{ {
@ -107,7 +109,8 @@ int httpd_mmap_open(const char *name, struct httpd_fs_file *file)
return ERROR; return ERROR;
} }
file->data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED | MAP_FILE, file->fd, 0); file->data = mmap(NULL, st.st_size, PROT_READ,
MAP_SHARED | MAP_FILE, file->fd, 0);
if (file->data == MAP_FAILED) if (file->data == MAP_FAILED)
{ {
close(file->fd); close(file->fd);

View File

@ -1,5 +1,5 @@
/**************************************************************************** /****************************************************************************
* netutils/webserver/httpd_mmap.c * apps/netutils/webserver/httpd_sendfile.c
* *
* Licensed to the Apache Software Foundation (ASF) under one or more * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with * contributor license agreements. See the NOTICE file distributed with
@ -19,7 +19,7 @@
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Included Header Files * Included Files
****************************************************************************/ ****************************************************************************/
#include <nuttx/config.h> #include <nuttx/config.h>
@ -105,6 +105,7 @@ int httpd_sendfile_close(struct httpd_fs_file *file)
return OK; return OK;
} }
#endif #endif
if (-1 == close(file->fd)) if (-1 == close(file->fd))
{ {
return ERROR; return ERROR;