Resync new repository with old repo r5166

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5153 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2012-09-17 18:18:44 +00:00
commit 57623d42eb
5691 changed files with 1361853 additions and 0 deletions
+85
View File
@@ -0,0 +1,85 @@
/****************************************************************************
* apps/include/netutils/dhcpc.h
*
* Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This logic was leveraged from uIP which also has a BSD-style license:
*
* Copyright (c) 2005, Swedish Institute of Computer Science
* All rights reserved.
*
* 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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 __APPS_INCLUDE_NETUTILS_DHCPC_H
#define __APPS_INCLUDE_NETUTILS_DHCPC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
struct dhcpc_state
{
struct in_addr serverid;
struct in_addr ipaddr;
struct in_addr netmask;
struct in_addr dnsaddr;
struct in_addr default_router;
uint32_t lease_time; /* Lease expires in this number of seconds */
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN void *dhcpc_open(const void *mac_addr, int mac_len);
EXTERN int dhcpc_request(void *handle, struct dhcpc_state *presult);
EXTERN void dhcpc_close(void *handle);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_DHCPC_H */
+71
View File
@@ -0,0 +1,71 @@
/****************************************************************************
* apps/include/netutils/dhcpd.h
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This logic was leveraged from uIP which also has a BSD-style license:
*
* Copyright (c) 2005, Swedish Institute of Computer Science
* All rights reserved.
*
* 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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 __APPS_INCLUDE_NETUTILS_DHCPD_H
#define __APPS_INCLUDE_NETUTILS_DHCPD_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN int dhcpd_run(void);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_DHCPD_H */
+58
View File
@@ -0,0 +1,58 @@
/****************************************************************************
* apps/include/netutils/discover.h
*
* Copyright (C) 2012 Max Holtzberg. All rights reserved.
* Author: Max Holtzberg <mh@uvc.de>
*
* 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 __APPS_INCLUDE_NETUTILS_DISCOVER_H
#define __APPS_INCLUDE_NETUTILS_DISCOVER_H
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: discover_start
*
* Description:
* Start the discover daemon.
*
* Return:
* The process ID (pid) of the new discover daemon is returned on
* success; A negated errno is returned if the daemon was not successfully
* started.
*
****************************************************************************/
int discover_start(void);
#endif /* __APPS_INCLUDE_NETUTILS_DISCOVER_H */
+217
View File
@@ -0,0 +1,217 @@
/****************************************************************************
* apps/include/netutils/ftpd.h
*
* Copyright (C) 2012 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 __APPS_INCLUDE_NETUTILS_FTPD_H
#define __APPS_INCLUDE_NETUTILS_FTPD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Required configuration settings: Of course TCP networking support is
* required. But here are a couple that are less obvious:
*
* CONFIG_DISABLE_PTHREAD - pthread support is required
* CONFIG_DISABLE_POLL - poll() support is required
*
* Other FTPD configuration options thay may be of interest:
*
* CONFIG_FTPD_VENDORID - The vendor name to use in FTP communications.
* Default: "NuttX"
* CONFIG_FTPD_SERVERID - The server name to use in FTP communications.
* Default: "NuttX FTP Server"
* CONFIG_FTPD_CMDBUFFERSIZE - The maximum size of one command. Default:
* 128 bytes.
* CONFIG_FTPD_DATABUFFERSIZE - The size of the I/O buffer for data
* transfers. Default: 512 bytes.
* CONFIG_FTPD_WORKERSTACKSIZE - The stacksize to allocate for each
* FTP daemon worker thread. Default: 2048 bytes.
*/
#ifdef CONFIG_DISABLE_PTHREAD
# error "pthread support is required (CONFIG_DISABLE_PTHREAD=n)"
#endif
#ifdef CONFIG_DISABLE_POLL
# error "poll() support is required (CONFIG_DISABLE_POLL=n)"
#endif
#ifndef CONFIG_FTPD_VENDORID
# define CONFIG_FTPD_VENDORID "NuttX"
#endif
#ifndef CONFIG_FTPD_SERVERID
# define CONFIG_FTPD_SERVERID "NuttX FTP Server"
#endif
#ifndef CONFIG_FTPD_CMDBUFFERSIZE
# define CONFIG_FTPD_CMDBUFFERSIZE 128
#endif
#ifndef CONFIG_FTPD_DATABUFFERSIZE
# define CONFIG_FTPD_DATABUFFERSIZE 512
#endif
#ifndef CONFIG_FTPD_WORKERSTACKSIZE
# define CONFIG_FTPD_WORKERSTACKSIZE 2048
#endif
/* Interface definitions ****************************************************/
#define FTPD_ACCOUNTFLAG_NONE (0)
#define FTPD_ACCOUNTFLAG_ADMIN (1 << 0)
#define FTPD_ACCOUNTFLAG_SYSTEM (1 << 1)
#define FTPD_ACCOUNTFLAG_GUEST (1 << 2)
/****************************************************************************
* Public Types
****************************************************************************/
/* This "handle" describes the FTP session */
typedef FAR void *FTPD_SESSION;
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: ftpd_open
*
* Description:
* Create an instance of the FTPD server and return a handle that can be
* used to run the server.
*
* Input Parameters:
* None
*
* Returned Value:
* On success, a non-NULL handle is returned that can be used to reference
* the server instance.
*
****************************************************************************/
EXTERN FTPD_SESSION ftpd_open(void);
/****************************************************************************
* Name: ftpd_adduser
*
* Description:
* Add one FTP user.
*
* Input Parameters:
* handle - A handle previously returned by ftpd_open
* accountflags - The characteristics of this user (see FTPD_ACCOUNTFLAGS_*
* definitions above).
* user - The user login name. May be NULL indicating that no login is
* required.
* passwd - The user password. May be NULL indicating that no password
* is required.
* home - The user home directory. May be NULL.
*
* Returned Value:
* Zero is returned on success. A negated errno value is return on
* failure.
*
****************************************************************************/
EXTERN int ftpd_adduser(FTPD_SESSION handle, uint8_t accountflags,
FAR const char *user, FAR const char *passwd,
FAR const char *home);
/****************************************************************************
* Name: ftpd_session
*
* Description:
* Execute the FTPD server. This thread does not return until either (1)
* the timeout expires with no connection, (2) some other error occurs, or
* (2) a connection was accepted and an FTP worker thread was started to
* service the session. Each call to ftpd_session creates on session.
*
* Input Parameters:
* handle - A handle previously returned by ftpd_open
* timeout - A time in milliseconds to wait for a connection. If this
* time elapses with no connected, the -ETIMEDOUT error will be returned.
*
* Returned Value:
* Zero is returned if the FTP worker was started. On failure, a negated
* errno value is returned to indicate why the servier terminated.
* -ETIMEDOUT indicates that the user-provided timeout elapsed with no
* connection.
*
****************************************************************************/
EXTERN int ftpd_session(FTPD_SESSION handle, int timeout);
/****************************************************************************
* Name: ftpd_close
*
* Description:
* Close and destroy the handle created by ftpd_open.
*
* Input Parameters:
* handle - A handle previously returned by ftpd_open
*
* Returned Value:
* None
*
****************************************************************************/
EXTERN void ftpd_close(FTPD_SESSION handle);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_FTPD_H */
+185
View File
@@ -0,0 +1,185 @@
/****************************************************************************
* apps/include/netutils/httpd.h
*
* Copyright (C) 2007, 2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2001-2005, Adam Dunkels.
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 __APPS_INCLUDE_NETUTILS_HTTPD_H
#define __APPS_INCLUDE_NETUTILS_HTTPD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/net/uip/uip.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef __cplusplus
# define EXTERN extern "C"
extern "C" {
#else
# define EXTERN extern
#endif
/* As threads are created to handle each request, a stack must be allocated
* for the thread. Use a default if the user provided no stacksize.
*/
#ifndef CONFIG_NETUTILS_HTTPDSTACKSIZE
# define CONFIG_NETUTILS_HTTPDSTACKSIZE 4096
#endif
#ifndef CONFIG_NETUTILS_HTTPDFSSTATS
# define CONFIG_NETUTILS_HTTPDFSSTATS
#endif
#ifndef CONFIG_NETUTILS_HTTPDFILESTATS
# define CONFIG_NETUTILS_HTTPDFILESTATS
#endif
#ifndef CONFIG_NET_STATISTICS
# undef CONFIG_NETUTILS_HTTPDNETSTATS
#endif
/* For efficiency reasons, the size of the IO buffer should be a multiple
* of the TCP MSS value. Also, the current design requires that the IO
* buffer be sufficiently large to contain the entire GET request.
*/
#define HTTPD_IOBUFFER_SIZE (3*UIP_TCP_MSS)
/* This is the maximum size of a file path */
#if defined(CONFIG_NETUTILS_HTTPD_MMAP) || defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
#define HTTPD_MAX_FILENAME PATH_MAX
#else
#define HTTPD_MAX_FILENAME 20
#endif
/****************************************************************************
* Public types
****************************************************************************/
struct httpd_fs_file
{
char *data;
int len;
#if defined(CONFIG_NETUTILS_HTTPD_MMAP) || defined(CONFIG_NETUTILS_HTTPD_SENDFILE)
int fd;
#endif
};
struct httpd_state
{
char ht_buffer[HTTPD_IOBUFFER_SIZE]; /* recv()/send() buffer */
char ht_filename[HTTPD_MAX_FILENAME]; /* filename from GET command */
struct httpd_fs_file ht_file; /* Fake file data to send */
int ht_sockfd; /* The socket descriptor from accept() */
char *ht_scriptptr;
uint16_t ht_scriptlen;
uint16_t ht_sndlen;
};
struct httpd_fsdata_file
{
const struct httpd_fsdata_file *next;
FAR const uint8_t *name;
FAR const uint8_t *data;
int len;
#ifdef CONFIG_NETUTILS_HTTPDFSSTATS
uint16_t count;
#endif
};
struct httpd_fsdata_file_noconst
{
FAR struct httpd_fsdata_file *next;
FAR char *name;
FAR char *data;
int len;
#ifdef CONFIG_NETUTILS_HTTPDFSSTATS
uint16_t count;
#endif
};
typedef void (*httpd_cgifunction)(struct httpd_state *, char *);
struct httpd_cgi_call
{
struct httpd_cgi_call *next;
const char *name;
httpd_cgifunction function;
};
/* HTTPD CGI function declaration
*
* Description:
* This macro is used for declaring a HTTPD CGI function. This function is
* then added to the list of HTTPD CGI functions with the httpd_cgi_register()
* function.
* Input Paramters:
*
* name The C variable name of the function
* str The string name of the function, used in the script file
* function A pointer to the function that implements it
*/
#define HTTPD_CGI_CALL(name, str, function) \
static void function(struct httpd_state *, char *); \
static struct httpd_cgi_call name = {NULL, str, function}
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
EXTERN void httpd_init(void);
EXTERN int httpd_listen(void);
EXTERN void httpd_cgi_register(struct httpd_cgi_call *cgi_call);
EXTERN uint16_t httpd_fs_count(char *name);
EXTERN const struct httpd_fsdata_file g_httpdfs_root[];
EXTERN const int g_httpd_numfiles;
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_HTTPD_H */
+101
View File
@@ -0,0 +1,101 @@
/****************************************************************************
* apps/include/netutils/ipmsfilter.h
* User interface to add/remove IP multicast address
*
* Copyright (C) 2009, 2011 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 __APPS_INCLUDE_NETUTILS_IPMSFILTER_H
#define __APPS_INCLUDE_NETUTILS_IPMSFILTER_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <netinet/in.h>
#ifdef CONFIG_NET_IGMP
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NET_IPv6
# error "IGMP for IPv6 not supported"
#endif
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: ipmsfilter
*
* Description:
* Add or remove an IP address from a multicast filter set.
* (See netutils/uiplib/uip_ipmsfilter.c)
*
* Parameters:
* ifname The name of the interface to use, size must less than IMSFNAMSIZ
* multiaddr Multicast group address to add/remove
* fmode MCAST_INCLUDE: Add multicast address
* MCAST_EXCLUDE: Remove multicast address
*
* Return:
* 0 on sucess; Negated errno on failure
*
****************************************************************************/
EXTERN int ipmsfilter(FAR const char *ifname,
FAR const struct in_addr *multiaddr,
uint32_t fmode);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_NET_IGMP */
#endif /* __APPS_INCLUDE_NETUTILS_IPMSFILTER_H */
+82
View File
@@ -0,0 +1,82 @@
/****************************************************************************
* apps/include/netutils/resolv.h
* DNS resolver code header file.
* Author Adam Dunkels <adam@dunkels.com>
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Inspired by/based on uIP logic by Adam Dunkels:
*
* Copyright (c) 2002-2003, Adam Dunkels.
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 __APPS_INCLUDE_NETUTILS_RESOLVE_H
#define __APPS_INCLUDE_NETUTILS_RESOLVE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/net/uip/uipopt.h>
#include <netinet/in.h>
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/* Functions. */
EXTERN int resolv_init(void);
#ifdef CONFIG_NET_IPv6
EXTERN void resolv_conf(FAR const struct in6_addr *dnsserver);
EXTERN void resolv_getserver(FAR const struct in_addr *dnsserver);
EXTERN int resolv_query(FAR const char *name, FAR struct sockaddr_in6 *addr);
#else
EXTERN void resolv_conf(FAR const struct in_addr *dnsserver);
EXTERN void resolv_getserver(FAR struct in_addr *dnsserver);
EXTERN int resolv_query(FAR const char *name, FAR struct sockaddr_in *addr);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_RESOLVE_H */
+78
View File
@@ -0,0 +1,78 @@
/****************************************************************************
* apps/include/netutils/smtp.h
* SMTP header file
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Heavily leveraged from uIP 1.0 which also has a BSD-like license:
*
* Author: Adam Dunkels <adam@dunkels.com>
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 __APPS_INCLUDE_NETUTILS_SMTP_H
#define __APPS_INCLUDE_NETUTILS_SMTP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/net/uip/uipopt.h>
#include <nuttx/net/uip/uip.h>
/****************************************************************************
* Type Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN void *smtp_open(void);
EXTERN void smtp_configure(void *handle, const char *localhostname,
const uip_ipaddr_t *paddr);
EXTERN int smtp_send(void *handle, const char *to, const char *cc,
const char *from, const char *subject,
const char *msg, int msglen);
EXTERN void smtp_close(void *handle);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_SMTP_H */
+127
View File
@@ -0,0 +1,127 @@
/****************************************************************************
* apps/include/netutils/telnetd.h
*
* Copyright (C) 2007, 2011-2012 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 Gregory Nutt 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 __APPS_INCLUDE_NETUTILS_TELNETD_H
#define __APPS_INCLUDE_NETUTILS_TELNETD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* CONFIG_TELNETD_CONSOLE - Use the first telnet session as the default
* console.
* CONFIG_TELNETD_RXBUFFER_SIZE - The size of the telnet receive buffer.
* Default: 256 bytes.
* CONFIG_TELNETD_TXBUFFER_SIZE - The size of the telnet transmit buffer.
* Default: 256 bytes.
* CONFIG_TELNETD_DUMPBUFFER - dumping of all input/output buffers.
*/
#ifndef CONFIG_TELNETD_RXBUFFER_SIZE
# define CONFIG_TELNETD_RXBUFFER_SIZE 256
#endif
#ifndef CONFIG_TELNETD_TXBUFFER_SIZE
# define CONFIG_TELNETD_TXBUFFER_SIZE 256
#endif
/****************************************************************************
* Public Types
****************************************************************************/
/* An instance of the struct telnetd_config_s structure must be passed to
* telnetd_start in order to configure the new telnet daemon.
*/
struct telnetd_config_s
{
/* These fields describe the telnet daemon */
int d_port; /* The port to listen on (in network byte order) */
int d_priority; /* The execution priority of the telnet daemon task */
int d_stacksize; /* The stack size needed by the telnet daemon task */
/* These fields describe the priority of each thread created by the telnet
* daemon.
*/
int t_priority; /* The execution priority of the spawned task, */
int t_stacksize; /* The stack size needed by the spawned task */
main_t t_entry; /* The entrypoint of the task to spawn when a new
* connection is accepted. */
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: telnetd_start
*
* Description:
* Start the telnet daemon.
*
* Parameters:
* config A pointer to a configuration structure that characterizes the
* telnet daemon. This configuration structure may be defined
* on the caller's stack because it is not retained by the
* daemon.
*
* Return:
* The process ID (pid) of the new telnet daemon is returned on
* success; A negated errno is returned if the daemon was not successfully
* started.
*
****************************************************************************/
EXTERN int telnetd_start(FAR struct telnetd_config_s *config);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_TELNETD_H */
+73
View File
@@ -0,0 +1,73 @@
/****************************************************************************
* apps/include/netutils/tftp.h
*
* Copyright (C) 2008-2009, 2011 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 __APPS_INCLUDE_NETUTILS_TFTP_H
#define __APPS_INCLUDE_NETUTILS_TFTP_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdbool.h>
#include <arpa/inet.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
EXTERN int tftpget(const char *remote, const char *local, in_addr_t addr, bool binary);
EXTERN int tftpput(const char *local, const char *remote, in_addr_t addr, bool binary);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_TFTP_H */
+101
View File
@@ -0,0 +1,101 @@
/****************************************************************************
* apps/include/netutils/thttpd.h
*
* Copyright (C) 2009, 2011 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 __APPS_INCLUDE_NETUTILS_THTTPD_H
#define __APPS_INCLUDE_NETUTILS_THTTPD_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/symtab.h>
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/* These values must be provided by the user before the THTTPD task daemon
* is started:
*
* g_thttpdsymtab: A symbol table describing all of the symbols exported
* from the base system. These symbols are used to bind address references
* in CGI programs to NuttX.
* g_nsymbols: The number of symbols in g_thttpdsymtab[].
*
* (See examples/nxflat and examples/thttpd for examples of how such a symbol
* table may be created.)
*/
EXTERN FAR const struct symtab_s *g_thttpdsymtab;
EXTERN int g_thttpdnsymbols;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Function: thttpd_main
*
* Description:
* This function is the entrypoint into the THTTPD server. It does not
* return. It may be called, the normal mechanism for starting the server
* is:
*
* 1) Set is g_thttpdsymtab and g_thttpdnsymbols. The user is required
* to provide a symbol table to use for binding CGI programs (if CGI
* is enabled. See examples/nxflat and examples/thttpd for examples of
* how such a symbol table may be created.)
* 2) Call task_create() to start thttpd_main()
*
****************************************************************************/
EXTERN int thttpd_main(int argc, char **argv);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_THTTPD_H */
+143
View File
@@ -0,0 +1,143 @@
/****************************************************************************
* apps/include/netutils/uiplib.h
* Various non-standard APIs to support netutils. All non-standard and
* intended only for internal use.
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Some of these APIs derive from uIP but all of them use the uip_ prefix
* to identify them as members of this library. uIP also has a BSD style
* license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 __APPS_INCLUDE_NETUTILS_UIPLIB_H
#define __APPS_INCLUDE_NETUTILS_UIPLIB_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <pthread.h>
#include <netinet/in.h>
#include <nuttx/net/uip/uipopt.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* SOCK_DGRAM is the preferred socket type to use when we just want a
* socket for performing drive ioctls. However, we can't use SOCK_DRAM
* if UDP is disabled.
*/
#ifdef CONFIG_NET_UDP
# define UIPLIB_SOCK_IOCTL SOCK_DGRAM
#else
# define UIPLIB_SOCK_IOCTL SOCK_STREAM
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/* Convert a textual representation of an IP address to a numerical representation.
*
* This function takes a textual representation of an IP address in
* the form a.b.c.d and converts it into a 4-byte array that can be
* used by other uIP functions.
*
* addrstr A pointer to a string containing the IP address in
* textual form.
*
* addr A pointer to a 4-byte array that will be filled in with
* the numerical representation of the address.
*
* Return: 0 If the IP address could not be parsed.
* Return: Non-zero If the IP address was parsed.
*/
EXTERN bool uiplib_ipaddrconv(const char *addrstr, uint8_t *addr);
/* Get and set IP/MAC addresses (Ethernet L2 only) */
#ifdef CONFIG_NET_ETHERNET
EXTERN int uip_setmacaddr(const char *ifname, const uint8_t *macaddr);
EXTERN int uip_getmacaddr(const char *ifname, uint8_t *macaddr);
#endif
/* IP address support */
#ifdef CONFIG_NET_IPv6
EXTERN int uip_gethostaddr(const char *ifname, struct in6_addr *addr);
EXTERN int uip_sethostaddr(const char *ifname, const struct in6_addr *addr);
EXTERN int uip_setdraddr(const char *ifname, const struct in6_addr *addr);
EXTERN int uip_setnetmask(const char *ifname, const struct in6_addr *addr);
#else
EXTERN int uip_gethostaddr(const char *ifname, struct in_addr *addr);
EXTERN int uip_sethostaddr(const char *ifname, const struct in_addr *addr);
EXTERN int uip_setdraddr(const char *ifname, const struct in_addr *addr);
EXTERN int uip_setnetmask(const char *ifname, const struct in_addr *addr);
#endif
/* HTTP support */
EXTERN int uip_parsehttpurl(const char *url, uint16_t *port,
char *hostname, int hostlen,
char *filename, int namelen);
/* Generic server logic */
EXTERN int uip_listenon(uint16_t portno);
EXTERN void uip_server(uint16_t portno, pthread_startroutine_t handler, int stacksize);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_UIPLIB_H */
+149
View File
@@ -0,0 +1,149 @@
/****************************************************************************
* apps/include/netutils/webclient.h
* Header file for the HTTP client
*
* Copyright (C) 2007, 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Based remotely on the uIP webclient which also has a BSD style license:
*
* Author: Adam Dunkels <adam@dunkels.com>
* Copyright (c) 2002, Adam Dunkels.
* All rights reserved.
*
* 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. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 __APPS_INCLUDE_NETUTILS_WEBCLIENT_H
#define __APPS_INCLUDE_NETUTILS_WEBCLIENT_H
/****************************************************************************
* Included Files
****************************************************************************/
#ifndef CONFIG_WEBCLIENT_HOST
# include <nuttx/config.h>
#endif
#include <sys/types.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef CONFIG_WEBCLIENT_MAXHTTPLINE
# define CONFIG_WEBCLIENT_MAXHTTPLINE 200
#endif
#ifndef CONFIG_WEBCLIENT_MAXMIMESIZE
# define CONFIG_WEBCLIENT_MAXMIMESIZE 32
#endif
#ifndef CONFIG_WEBCLIENT_MAXHOSTNAME
# define CONFIG_WEBCLIENT_MAXHOSTNAME 40
#endif
#ifndef CONFIG_WEBCLIENT_MAXFILENAME
# define CONFIG_WEBCLIENT_MAXFILENAME 100
#endif
/****************************************************************************
* Public types
****************************************************************************/
/* wget calls a user provided function of the follwoing type to process
* each received chuck of the incoming file data. If the system has a file
* system, then it may just write the data to a file. Or it may buffer the
* file in memory. To facilitate this latter case, the caller may modify
* the buffer address in this callback by writing to buffer and buflen. This
* may be used, for example, to implement double buffering.
*
* Input Parameters:
* buffer - A pointer to a pointer to a buffer. If the callee wishes to
* change the buffer address, it may do so in the callback by writing
* to buffer.
* offset - Offset to the beginning of valid data in the buffer. Offset
* is used to skip over any HTTP header info that may be at the
* beginning of the buffer.
* datend - The end+1 offset of valid data in the buffer. The total number
* of valid bytes is datend - offset.
* buflen - A pointer to the length of the buffer. If the callee wishes
* to change the size of the buffer, it may write to buflen.
*/
typedef void (*wget_callback_t)(FAR char **buffer, int offset,
int datend, FAR int *buflen, FAR void *arg);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C" {
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: wget
*
* Description:
* Obtain the requested file from an HTTP server using the GET method.
*
* Note: If the function is passed a host name, it must already be in
* the resolver cache in order for the function to connect to the web
* server. It is therefore up to the calling module to implement the
* resolver calls and the signal handler used for reporting a resolv
* query answer.
*
* Input Parameters
* url - A pointer to a string containing either the full URL to
* the file to get (e.g., http://www.nutt.org/index.html, or
* http://192.168.23.1:80/index.html).
* buffer - A user provided buffer to receive the file data (also
* used for the outgoing GET request
* buflen - The size of the user provided buffer
* callback - As data is obtained from the host, this function is
* to dispose of each block of file data as it is received.
* arg - User argument passed to callback.
*
* Returned Value:
* 0: if the GET operation completed successfully;
* -1: On a failure with errno set appropriately
*
****************************************************************************/
EXTERN int wget(FAR const char *url, FAR char *buffer, int buflen,
wget_callback_t callback, FAR void *arg);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __APPS_INCLUDE_NETUTILS_WEBCLIENT_H */
+123
View File
@@ -0,0 +1,123 @@
/****************************************************************************
* apps/include/netutils/xmlrpc.h
*
* Copyright (C) 2012 Max Holtzberg. All rights reserved.
* Author: Max Holtzberg <mh@uvc.de>
*
* Based on the embeddable lightweight XML-RPC server code discussed
* in the article at: http://www.drdobbs.com/web-development/\
* an-embeddable-lightweight-xml-rpc-server/184405364
*
* Copyright (c) 2002 Cogito LLC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARAY, 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.
****************************************************************************/
/*
* Lightweight Embedded XML-RPC Server Types and Definitions
*
* mtj@cogitollc.com
*
*/
#ifndef __APPS_INCLUDE_NETUTILS_XMLRPC_H
#define __APPS_INCLUDE_NETUTILS_XMLRPC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Error definitions. */
#define XMLRPC_NO_ERROR (0)
#define XMLRPC_PARSE_ERROR (-1)
#define XMLRPC_NO_SUCH_FUNCTION (-2)
#define XMLRPC_UNEXPECTED_INTEGER_ARG (-3)
#define XMLRPC_UNEXPECTED_BOOLEAN_ARG (-4)
#define XMLRPC_UNEXPECTED_DOUBLE_ARG (-5)
#define XMLRPC_UNEXPECTED_STRING_ARG (-6)
#define XMLRPC_BAD_RESPONSE_ARG (-7)
#define XMLRPC_INTERNAL_ERROR (-99)
#define MAX_ARGS 10
#define MAX_RESPONSE 2048
/****************************************************************************
* Public Types
****************************************************************************/
struct xmlrpc_arg_s
{
union
{
int i;
char boolean;
double d;
char string[CONFIG_XMLRPC_STRINGSIZE+1];
} u;
};
struct xmlrpc_s
{
char name[CONFIG_XMLRPC_STRINGSIZE+1];
struct xmlrpc_arg_s arguments[MAX_ARGS];
char args[MAX_ARGS];
int argsize;
int arg;
char response[MAX_RESPONSE];
int error;
};
struct xmlrpc_entry_s
{
struct xmlrpc_entry_s *next;
int (*func)(struct xmlrpc_s*);
char *name;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
void xmlrpc_register(struct xmlrpc_entry_s *call);
int xmlrpc_parse(int sock, char *buffer);
int xmlrpc_getinteger(struct xmlrpc_s *xmlcall, int *arg);
int xmlrpc_getbool(struct xmlrpc_s *xmlcall, int *arg);
int xmlrpc_getdouble(struct xmlrpc_s *xmlcall, double *arg);
int xmlrpc_getstring(struct xmlrpc_s *xmlcall, char *arg);
int xmlrpc_buildresponse(struct xmlrpc_s *, char *, ...);
#endif /* __APPS_INCLUDE_NETUTILS_XMLRPC_H */