Cleanup and fix problems introduce in last commit

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@337 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2007-09-08 22:41:00 +00:00
parent 952db3328f
commit 4283c46855
17 changed files with 237 additions and 201 deletions
+16 -8
View File
@@ -1,10 +1,18 @@
/* main.c /****************************************************************************
* Copyright (c) 2001, Adam Dunkels. * examples/uip/main.c
* All rights reserved. *
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Copyright (c) 2001, Adam Dunkels.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -29,11 +37,11 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack. ****************************************************************************/
*
* $Id: main.c,v 1.4 2007-09-03 20:34:43 patacongo Exp $ /****************************************************************************
* * Included Files
*/ ****************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
+2 -2
View File
@@ -87,8 +87,8 @@
#define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */ #define NSEC2TICK(nsec) (((nsec)+(NSEC_PER_TICK/2))/NSEC_PER_TICK) /* Rounds */
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */ #define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK) /* Rounds */
#define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */ #define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK) /* Rounds */
#define DSEC2TICK(dsec) MSEC2TICK((dsec)*DSEC_PER_MSEC) #define DSEC2TICK(dsec) MSEC2TICK((dsec)*MSEC_PER_DSEC)
#define SEC2TICK(sec) MSEC2TICK((sec)*SEC_PER_MSEC) #define SEC2TICK(sec) MSEC2TICK((sec)*MSEC_PER_SEC)
/**************************************************************************** /****************************************************************************
* Global Data * Global Data
+1 -1
View File
@@ -135,7 +135,7 @@
#define SO_SNDBUF 7 /* Sets send buffer size. arg: integer value (get/set). */ #define SO_SNDBUF 7 /* Sets send buffer size. arg: integer value (get/set). */
#define SO_RCVBUF 8 /* Sets receive buffer size. arg: integer value (get/set). */ #define SO_RCVBUF 8 /* Sets receive buffer size. arg: integer value (get/set). */
#define SO_ERROR 9 /* Reports and clears error status (get only). arg: returns #define SO_ERROR 9 /* Reports and clears error status (get only). arg: returns
* an integer value * an integer value */
#define SO_TYPE 10 /* Reports the socket type (get only). return: int */ #define SO_TYPE 10 /* Reports the socket type (get only). return: int */
#define SO_DONTROUTE 11 /* Requests that outgoing messages bypass standard routing (get/set) #define SO_DONTROUTE 11 /* Requests that outgoing messages bypass standard routing (get/set)
* arg: pointer to integer containing a boolean value */ * arg: pointer to integer containing a boolean value */
+1 -1
View File
@@ -46,7 +46,7 @@ STD_CSRCS = socket.c bind.c connect.c send.c sendto.c recv.c recvfrom.c \
ifeq ($(CONFIG_NET_SOCKOPTS),y) ifeq ($(CONFIG_NET_SOCKOPTS),y)
STD_CSRCS += setsockopt.c getsockopt.c STD_CSRCS += setsockopt.c getsockopt.c
ifneq ($(CONFIG_DISABLE_CLOCK),y) ifneq ($(CONFIG_DISABLE_CLOCK),y)
STD_CSRCS += net-timeout.c net-dsec2timeval.c net-timeval2dsec.c STD_CSRCS += net-timeo.c net-dsec2timeval.c net-timeval2dsec.c
endif endif
endif endif
+8 -5
View File
@@ -110,7 +110,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
/* Verify that the socket option if valid (but might not be supported ) */ /* Verify that the socket option if valid (but might not be supported ) */
if (!_SO_GETVALID(option) || !value) if (!_SO_GETVALID(option) || !value || !value_len)
{ {
err = EINVAL; err = EINVAL;
goto errout; goto errout;
@@ -138,7 +138,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
* that 'value' is properly aligned for an 'int' * that 'value' is properly aligned for an 'int'
*/ */
if (value_len != sizeof(int)) if (*value_len < sizeof(int))
{ {
err = EINVAL; err = EINVAL;
goto errout; goto errout;
@@ -150,8 +150,9 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
* a macro will do. * a macro will do.
*/ */
optionset = psock->options; optionset = psock->s_options;
*(int*)value = _SO_GETOPT(optionset, option); *(int*)value = _SO_GETOPT(optionset, option);
*value_len = sizeof(int);
} }
break; break;
@@ -161,7 +162,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
* that 'value' is properly aligned for an 'int' * that 'value' is properly aligned for an 'int'
*/ */
if (value_len != sizeof(int)) if (*value_len < sizeof(int))
{ {
err = EINVAL; err = EINVAL;
goto errout; goto errout;
@@ -170,6 +171,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
/* Return the socket type */ /* Return the socket type */
*(int*)value = psock->s_type; *(int*)value = psock->s_type;
*value_len = sizeof(int);
} }
break; break;
@@ -185,7 +187,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
* that 'value' is properly aligned for an 'int' * that 'value' is properly aligned for an 'int'
*/ */
if (value_len != sizeof(struct timeval)) if (*value_len < sizeof(struct timeval))
{ {
err = EINVAL; err = EINVAL;
goto errout; goto errout;
@@ -207,6 +209,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_
/* Then return the timeout value to the caller */ /* Then return the timeout value to the caller */
net_dsec2timeval(timeo, (struct timeval *)value); net_dsec2timeval(timeo, (struct timeval *)value);
*value_len = sizeof(struct timeval);
} }
break; break;
#endif #endif
+1 -1
View File
@@ -124,7 +124,7 @@ EXTERN FAR struct socket *sockfd_socket(int sockfd);
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
EXTERN int net_timeo(uint32 start_time, socktimeo_t timeo); EXTERN int net_timeo(uint32 start_time, socktimeo_t timeo);
EXTERN socktimeo_t socktimeo_t net_timeval2dsec(struct timeval *tv); EXTERN socktimeo_t net_timeval2dsec(struct timeval *tv);
EXTERN void net_dsec2timeval(uint16 dsec, struct timeval *tv); EXTERN void net_dsec2timeval(uint16 dsec, struct timeval *tv);
#endif #endif
+17 -7
View File
@@ -59,7 +59,7 @@
struct recvfrom_s struct recvfrom_s
{ {
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
FAR struct socket *rf_sock /* The parent socket structure */ FAR struct socket *rf_sock; /* The parent socket structure */
#endif #endif
sem_t rf_sem; /* Semaphore signals recv completion */ sem_t rf_sem; /* Semaphore signals recv completion */
sint16 rf_buflen; /* Length of receive buffer (error if <0) */ sint16 rf_buflen; /* Length of receive buffer (error if <0) */
@@ -102,7 +102,7 @@ void recvfrom_interrupt(void *private)
/* Don't allow any further call backs. */ /* Don't allow any further call backs. */
uip_conn->private = NULL; uip_conn->private = NULL;
uip_conn->callback = NULL; uip_conn->callback = NULL;
/* Wake up the waiting thread, returning the number of bytes /* Wake up the waiting thread, returning the number of bytes
@@ -113,23 +113,33 @@ void recvfrom_interrupt(void *private)
sem_post(&pstate-> rf_sem); sem_post(&pstate-> rf_sem);
} }
/* No data has been received. If this is a poll event, then check /* No data has been received -- this is some other event... probably a
* for a timeout. * poll -- check for a timeout.
*/ */
#if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK)
else if (uip_newdata() && pstate->rf_sock) else if (pstate->rf_sock)
{ {
/* Check if SO_RCVTIMEO has been selected for this socket */ /* Check if SO_RCVTIMEO has been selected for this socket */
uint rcvtimeo = ;
if (pstate->rf_sock->s_rcvtimeo) if (pstate->rf_sock->s_rcvtimeo)
{ {
/* Yes.. Check if the timeout has elapsed */ /* Yes.. Check if the timeout has elapsed */
if (net_timeo(pstate->rf_starttime, pstate->rf_sock->s_rcvtimeo)) if (net_timeo(pstate->rf_starttime, pstate->rf_sock->s_rcvtimeo))
{ {
} /* Don't allow any further call backs. */
uip_conn->private = NULL;
uip_conn->callback = NULL;
/* Wake up the waiting thread, returning the error -EAGAIN
* that signals the timeout event
*/
pstate->rf_buflen = -EAGAIN;
sem_post(&pstate-> rf_sem);
}
} }
} }
#endif #endif
+1
View File
@@ -43,6 +43,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <errno.h> #include <errno.h>
#include <arch/irq.h>
#include "net-internal.h" #include "net-internal.h"
+16 -9
View File
@@ -1,10 +1,18 @@
/* /****************************************************************************
* Copyright (c) 2004, Swedish Institute of Computer Science. * net/uip/psock.c
* All rights reserved. *
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Copyright (c) 2004, Swedish Institute of Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -26,12 +34,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack ****************************************************************************/
*
* Author: Adam Dunkels <adam@sics.se> /****************************************************************************
* * Included Files
* $Id: psock.c,v 1.2 2007-09-01 18:06:13 patacongo Exp $ ****************************************************************************/
*/
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
+22 -23
View File
@@ -1,21 +1,20 @@
/** /****************************************************************************
* \addtogroup uipfw * net/uip/uip-fw.h
* @{
*/
/**
* \file
* uIP packet forwarding header file. * uIP packet forwarding header file.
* \author Adam Dunkels <adam@sics.se> *
*/ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
/* *
* Copyright (c) 2004, Swedish Institute of Computer Science. * Based on uIP which also has a BSD style license:
* All rights reserved. *
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2004, Swedish Institute of Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -37,21 +36,21 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack ****************************************************************************/
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: uip-fw.h,v 1.1.1.1 2007-08-26 23:04:07 patacongo Exp $
*/
#ifndef __UIP_FW_H__ #ifndef __UIP_FW_H__
#define __UIP_FW_H__ #define __UIP_FW_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <net/uip/uip.h> #include <net/uip/uip.h>
/** /* Representation of a uIP network interface. */
* Representation of a uIP network interface.
*/ struct uip_fw_netif
struct uip_fw_netif { {
struct uip_fw_netif *next; /**< Pointer to the next interface when struct uip_fw_netif *next; /**< Pointer to the next interface when
linked in a list. */ linked in a list. */
uint16 ipaddr[2]; /**< The IP address of this interface. */ uint16 ipaddr[2]; /**< The IP address of this interface. */
+19 -25
View File
@@ -1,10 +1,21 @@
/* /****************************************************************************
* Copyright (c) 2004, Swedish Institute of Computer Science. * net/uip/uip-split.h
* All rights reserved. * Module for splitting outbound TCP segments in two to avoid the
* delayed ACK throughput degradation.
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2004, Swedish Institute of Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -26,20 +37,9 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack ****************************************************************************/
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: uip-split.h,v 1.1.1.1 2007-08-26 23:04:08 patacongo Exp $
*/
/**
* \addtogroup uip
* @{
*/
/** /* uipsplit uIP TCP throughput booster hack
* \defgroup uipsplit uIP TCP throughput booster hack
* @{
* *
* The basic uIP TCP implementation only allows each TCP connection to * The basic uIP TCP implementation only allows each TCP connection to
* have a single TCP segment in flight at any given time. Because of * have a single TCP segment in flight at any given time. Because of
@@ -59,15 +59,9 @@
* to work. * to work.
*/ */
/****************************************************************************
/** * Included Files
* \file ****************************************************************************/
* Module for splitting outbound TCP segments in two to avoid the
* delayed ACK throughput degradation.
* \author
* Adam Dunkels <adam@sics.se>
*
*/
#ifndef __UIP_SPLIT_H__ #ifndef __UIP_SPLIT_H__
#define __UIP_SPLIT_H__ #define __UIP_SPLIT_H__
+33 -34
View File
@@ -1,21 +1,20 @@
/** /****************************************************************************
* \file * netutils/telnetd/shell.h
* Interface for the Contiki shell. * Interface for the Contiki shell.
* \author Adam Dunkels <adam@dunkels.com>
* *
* Some of the functions declared in this file must be implemented as * Copyright (C) 2007 Gregory Nutt. All rights reserved.
* a shell back-end in the architecture specific files of a Contiki * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* port. *
*/ * Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@dunkels.com>
/* * Copyright (c) 2003, Adam Dunkels.
* Copyright (c) 2003, Adam Dunkels. * All rights reserved.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -37,68 +36,68 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the Contiki desktop OS. ****************************************************************************/
*
* $Id: shell.h,v 1.1.1.1 2007-08-26 23:07:06 patacongo Exp $ /* Some of the functions declared in this file must be implemented as
* * a shell back-end in the architecture specific files of a Contiki
* port.
*/ */
#ifndef __SHELL_H__ #ifndef __SHELL_H__
#define __SHELL_H__ #define __SHELL_H__
/** /* Initialize the shell.
* Initialize the shell.
* *
* Called when the shell front-end process starts. This function may * Called when the shell front-end process starts. This function may
* be used to start listening for signals. * be used to start listening for signals.
*/ */
void shell_init(void); void shell_init(void);
/** /* Start the shell back-end.
* Start the shell back-end.
* *
* Called by the front-end when a new shell is started. * Called by the front-end when a new shell is started.
*/ */
void shell_start(void); void shell_start(void);
/** /* Process a shell command.
* Process a shell command.
* *
* This function will be called by the shell GUI / telnet server whan * This function will be called by the shell GUI / telnet server whan
* a command has been entered that should be processed by the shell * a command has been entered that should be processed by the shell
* back-end. * back-end.
* *
* \param command The command to be processed. * command The command to be processed.
*/ */
void shell_input(char *command); void shell_input(char *command);
/** /* Quit the shell. */
* Quit the shell.
*
*/
void shell_quit(char *); void shell_quit(char *);
/** /* Print a string to the shell window.
* Print a string to the shell window.
* *
* This function is implemented by the shell GUI / telnet server and * This function is implemented by the shell GUI / telnet server and
* can be called by the shell back-end to output a string in the * can be called by the shell back-end to output a string in the
* shell window. The string is automatically appended with a linebreak. * shell window. The string is automatically appended with a linebreak.
* *
* \param str1 The first half of the string to be output. * str1 The first half of the string to be output.
* \param str2 The second half of the string to be output. * str2 The second half of the string to be output.
*/ */
void shell_output(char *str1, char *str2); void shell_output(char *str1, char *str2);
/** /* Print a prompt to the shell window.
* Print a prompt to the shell window.
* *
* This function can be used by the shell back-end to print out a * This function can be used by the shell back-end to print out a
* prompt to the shell window. * prompt to the shell window.
* *
* \param prompt The prompt to be printed. * prompt The prompt to be printed.
* *
*/ */
void shell_prompt(char *prompt); void shell_prompt(char *prompt);
#endif /* __SHELL_H__ */ #endif /* __SHELL_H__ */
+20 -14
View File
@@ -1,11 +1,21 @@
/* /****************************************************************************
* Copyright (c) 2004, Adam Dunkels and the Swedish Institute of * netutils/uiplib/uiplib.c
* Computer Science. * Various uIP library functions.
* All rights reserved. *
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2004, Adam Dunkels and the Swedish Institute of
* Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -27,19 +37,17 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack ****************************************************************************/
*
* $Id: uiplib.c,v 1.1.1.1 2007-08-26 23:07:05 patacongo Exp $ /****************************************************************************
* * Included Files
*/ ****************************************************************************/
#include <net/uip/uip.h> #include <net/uip/uip.h>
#include "uiplib.h" #include "uiplib.h"
/*-----------------------------------------------------------------------------------*/ unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
unsigned char
uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
{ {
unsigned char tmp; unsigned char tmp;
char c; char c;
@@ -69,5 +77,3 @@ uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
} }
return 1; return 1;
} }
/*-----------------------------------------------------------------------------------*/
+19 -27
View File
@@ -1,18 +1,20 @@
/** /****************************************************************************
* \file * netutils/uiplib/uiplib.h
* Various uIP library functions. * Various uIP library functions.
* \author
* Adam Dunkels <adam@sics.se>
* *
*/ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
/* *
* Copyright (c) 2002, Adam Dunkels. * Based on uIP which also has a BSD style license:
* All rights reserved. *
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above * 2. Redistributions in binary form must reproduce the above
@@ -35,37 +37,27 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack ****************************************************************************/
*
* $Id: uiplib.h,v 1.1.1.1 2007-08-26 23:07:05 patacongo Exp $
*
*/
#ifndef __UIPLIB_H__ #ifndef __UIPLIB_H__
#define __UIPLIB_H__ #define __UIPLIB_H__
/** /* Convert a textual representation of an IP address to a numerical representation.
* \addtogroup uipconvfunc
* @{
*/
/**
* Convert a textual representation of an IP address to a numerical representation.
* *
* This function takes a textual representation of an IP address in * 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 * the form a.b.c.d and converts it into a 4-byte array that can be
* used by other uIP functions. * used by other uIP functions.
* *
* \param addrstr A pointer to a string containing the IP address in * addrstr A pointer to a string containing the IP address in
* textual form. * textual form.
* *
* \param addr A pointer to a 4-byte array that will be filled in with * addr A pointer to a 4-byte array that will be filled in with
* the numerical representation of the address. * the numerical representation of the address.
* *
* \retval 0 If the IP address could not be parsed. * Return: 0 If the IP address could not be parsed.
* \retval Non-zero If the IP address was parsed. * Return: Non-zero If the IP address was parsed.
*/ */
unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr); unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
/** @} */
#endif /* __UIPLIB_H__ */ #endif /* __UIPLIB_H__ */
+20 -13
View File
@@ -1,15 +1,15 @@
/* webclient.c /****************************************************************************
* netutils/webclient/webclient.c
* Implementation of the HTTP client. * Implementation of the HTTP client.
* Author: Adam Dunkels <adam@dunkels.com>
* *
* This example shows a HTTP client that is able to download web pages * Copyright (C) 2007 Gregory Nutt. All rights reserved.
* and files from web servers. It requires a number of callback * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* functions to be implemented by the module that utilizes the code:
* webclient_datahandler(), webclient_connected(),
* webclient_timedout(), webclient_aborted(), webclient_closed().
* *
* Copyright (c) 2002, Adam Dunkels. * Based on uIP which also has a BSD style license:
* All rights reserved. *
* 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 * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -36,12 +36,19 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* This file is part of the uIP TCP/IP stack. ****************************************************************************/
*
* $Id: webclient.c,v 1.4 2007-09-03 23:35:17 patacongo Exp $ /* This example shows a HTTP client that is able to download web pages
* * and files from web servers. It requires a number of callback
* functions to be implemented by the module that utilizes the code:
* webclient_datahandler(), webclient_connected(),
* webclient_timedout(), webclient_aborted(), webclient_closed().
*/ */
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h> #include <sys/types.h>
#include <string.h> #include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
+24 -22
View File
@@ -1,10 +1,19 @@
/* /****************************************************************************
* Copyright (c) 2001, Swedish Institute of Computer Science. * netutils/webserver/httpd-fs.c
* All rights reserved. *
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
*
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
@@ -26,12 +35,11 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. ****************************************************************************/
*
* Author: Adam Dunkels <adam@sics.se> /****************************************************************************
* * Included Files
* $Id: httpd-fs.c,v 1.1.1.1 2007-08-26 23:07:02 patacongo Exp $ ****************************************************************************/
*/
#include <sys/types.h> #include <sys/types.h>
@@ -49,9 +57,7 @@
static uint16 count[HTTPD_FS_NUMFILES]; static uint16 count[HTTPD_FS_NUMFILES];
#endif /* HTTPD_FS_STATISTICS */ #endif /* HTTPD_FS_STATISTICS */
/*-----------------------------------------------------------------------------------*/ static uint8 httpd_fs_strcmp(const char *str1, const char *str2)
static uint8
httpd_fs_strcmp(const char *str1, const char *str2)
{ {
uint8 i; uint8 i;
i = 0; i = 0;
@@ -71,9 +77,8 @@ httpd_fs_strcmp(const char *str1, const char *str2)
++i; ++i;
goto loop; goto loop;
} }
/*-----------------------------------------------------------------------------------*/
int int httpd_fs_open(const char *name, struct httpd_fs_file *file)
httpd_fs_open(const char *name, struct httpd_fs_file *file)
{ {
#if HTTPD_FS_STATISTICS #if HTTPD_FS_STATISTICS
uint16 i = 0; uint16 i = 0;
@@ -99,9 +104,8 @@ httpd_fs_open(const char *name, struct httpd_fs_file *file)
} }
return 0; return 0;
} }
/*-----------------------------------------------------------------------------------*/
void void httpd_fs_init(void)
httpd_fs_init(void)
{ {
#if HTTPD_FS_STATISTICS #if HTTPD_FS_STATISTICS
uint16 i; uint16 i;
@@ -110,10 +114,9 @@ httpd_fs_init(void)
} }
#endif /* HTTPD_FS_STATISTICS */ #endif /* HTTPD_FS_STATISTICS */
} }
/*-----------------------------------------------------------------------------------*/
#if HTTPD_FS_STATISTICS #if HTTPD_FS_STATISTICS
uint16 httpd_fs_count uint16 httpd_fs_count(char *name)
(char *name)
{ {
struct httpd_fsdata_file_noconst *f; struct httpd_fsdata_file_noconst *f;
uint16 i; uint16 i;
@@ -131,4 +134,3 @@ uint16 httpd_fs_count
return 0; return 0;
} }
#endif /* HTTPD_FS_STATISTICS */ #endif /* HTTPD_FS_STATISTICS */
/*-----------------------------------------------------------------------------------*/
+17 -9
View File
@@ -1,6 +1,14 @@
/* /****************************************************************************
* Copyright (c) 2001, Swedish Institute of Computer Science. * netutils/webserver/httpd-fsdata.h
* All rights reserved. *
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Based on uIP which also has a BSD style license:
*
* Author: Adam Dunkels <adam@sics.se>
* Copyright (c) 2001, Swedish Institute of Computer Science.
* All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -26,15 +34,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* This file is part of the lwIP TCP/IP stack. ****************************************************************************/
*
* Author: Adam Dunkels <adam@sics.se>
*
* $Id: httpd-fsdata.h,v 1.1.1.1 2007-08-26 23:07:04 patacongo Exp $
*/
#ifndef __HTTPD_FSDATA_H__ #ifndef __HTTPD_FSDATA_H__
#define __HTTPD_FSDATA_H__ #define __HTTPD_FSDATA_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h> #include <sys/types.h>
#include <net/uip/uip.h> #include <net/uip/uip.h>