diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-09-08 22:41:00 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-09-08 22:41:00 +0000 |
commit | 712b9f5349a81fe56fa060ccb8aa13e0db830657 (patch) | |
tree | dfbb89ff177cb40a24945fa3925c9e75230a6a5b /nuttx/net | |
parent | 255e1fe83691a2c5a3328bcec13e2bce0a140696 (diff) | |
download | px4-nuttx-712b9f5349a81fe56fa060ccb8aa13e0db830657.tar.gz px4-nuttx-712b9f5349a81fe56fa060ccb8aa13e0db830657.tar.bz2 px4-nuttx-712b9f5349a81fe56fa060ccb8aa13e0db830657.zip |
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
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/Makefile | 2 | ||||
-rw-r--r-- | nuttx/net/getsockopt.c | 13 | ||||
-rw-r--r-- | nuttx/net/net-internal.h | 2 | ||||
-rw-r--r-- | nuttx/net/recvfrom.c | 24 | ||||
-rw-r--r-- | nuttx/net/setsockopt.c | 1 | ||||
-rw-r--r-- | nuttx/net/uip/psock.c | 25 | ||||
-rw-r--r-- | nuttx/net/uip/uip-fw.h | 45 | ||||
-rw-r--r-- | nuttx/net/uip/uip-split.h | 44 |
8 files changed, 85 insertions, 71 deletions
diff --git a/nuttx/net/Makefile b/nuttx/net/Makefile index f341e0a67..31ccd2a26 100644 --- a/nuttx/net/Makefile +++ b/nuttx/net/Makefile @@ -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) STD_CSRCS += setsockopt.c getsockopt.c 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 diff --git a/nuttx/net/getsockopt.c b/nuttx/net/getsockopt.c index 1cd4485ac..5b96762c0 100644 --- a/nuttx/net/getsockopt.c +++ b/nuttx/net/getsockopt.c @@ -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 ) */ - if (!_SO_GETVALID(option) || !value) + if (!_SO_GETVALID(option) || !value || !value_len) { err = EINVAL; 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' */ - if (value_len != sizeof(int)) + if (*value_len < sizeof(int)) { err = EINVAL; goto errout; @@ -150,8 +150,9 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_ * a macro will do. */ - optionset = psock->options; + optionset = psock->s_options; *(int*)value = _SO_GETOPT(optionset, option); + *value_len = sizeof(int); } 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' */ - if (value_len != sizeof(int)) + if (*value_len < sizeof(int)) { err = EINVAL; goto errout; @@ -170,6 +171,7 @@ int getsockopt(int sockfd, int level, int option, void *value, socklen_t *value_ /* Return the socket type */ *(int*)value = psock->s_type; + *value_len = sizeof(int); } 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' */ - if (value_len != sizeof(struct timeval)) + if (*value_len < sizeof(struct timeval)) { err = EINVAL; 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 */ net_dsec2timeval(timeo, (struct timeval *)value); + *value_len = sizeof(struct timeval); } break; #endif diff --git a/nuttx/net/net-internal.h b/nuttx/net/net-internal.h index f4345adb2..9f7fcaea0 100644 --- a/nuttx/net/net-internal.h +++ b/nuttx/net/net-internal.h @@ -124,7 +124,7 @@ EXTERN FAR struct socket *sockfd_socket(int sockfd); #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) 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); #endif diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index d008262bf..d4a1898c9 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -59,7 +59,7 @@ struct recvfrom_s { #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 sem_t rf_sem; /* Semaphore signals recv completion */ 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. */ - uip_conn->private = NULL; + uip_conn->private = NULL; uip_conn->callback = NULL; /* Wake up the waiting thread, returning the number of bytes @@ -113,23 +113,33 @@ void recvfrom_interrupt(void *private) sem_post(&pstate-> rf_sem); } - /* No data has been received. If this is a poll event, then check - * for a timeout. + /* No data has been received -- this is some other event... probably a + * poll -- check for a timeout. */ #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 */ - uint rcvtimeo = ; if (pstate->rf_sock->s_rcvtimeo) { /* Yes.. Check if the timeout has elapsed */ 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 diff --git a/nuttx/net/setsockopt.c b/nuttx/net/setsockopt.c index b90b9ae3a..0c4e3d9e4 100644 --- a/nuttx/net/setsockopt.c +++ b/nuttx/net/setsockopt.c @@ -43,6 +43,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <errno.h> +#include <arch/irq.h> #include "net-internal.h" diff --git a/nuttx/net/uip/psock.c b/nuttx/net/uip/psock.c index 24269a60a..55676c3c2 100644 --- a/nuttx/net/uip/psock.c +++ b/nuttx/net/uip/psock.c @@ -1,10 +1,18 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. +/**************************************************************************** + * net/uip/psock.c + * + * 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 * 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 @@ -26,12 +34,11 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * This file is part of the uIP TCP/IP stack - * - * Author: Adam Dunkels <adam@sics.se> - * - * $Id: psock.c,v 1.2 2007-09-01 18:06:13 patacongo Exp $ - */ + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ #include <stdio.h> #include <string.h> diff --git a/nuttx/net/uip/uip-fw.h b/nuttx/net/uip/uip-fw.h index cba0bea13..b3153cd31 100644 --- a/nuttx/net/uip/uip-fw.h +++ b/nuttx/net/uip/uip-fw.h @@ -1,21 +1,20 @@ -/** - * \addtogroup uipfw - * @{ - */ - -/** - * \file +/**************************************************************************** + * net/uip/uip-fw.h * uIP packet forwarding header file. - * \author Adam Dunkels <adam@sics.se> - */ - -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * 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, 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 @@ -37,21 +36,21 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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__ #define __UIP_FW_H__ +/**************************************************************************** + * Included Files + ****************************************************************************/ + #include <net/uip/uip.h> -/** - * Representation of a uIP network interface. - */ -struct uip_fw_netif { +/* Representation of a uIP network interface. */ + +struct uip_fw_netif +{ struct uip_fw_netif *next; /**< Pointer to the next interface when linked in a list. */ uint16 ipaddr[2]; /**< The IP address of this interface. */ diff --git a/nuttx/net/uip/uip-split.h b/nuttx/net/uip/uip-split.h index 99f36ccdb..4779b017a 100644 --- a/nuttx/net/uip/uip-split.h +++ b/nuttx/net/uip/uip-split.h @@ -1,10 +1,21 @@ -/* - * Copyright (c) 2004, Swedish Institute of Computer Science. - * All rights reserved. +/**************************************************************************** + * net/uip/uip-split.h + * 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 * 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 @@ -26,20 +37,9 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * 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 - * @{ - */ + ****************************************************************************/ -/** - * \defgroup uipsplit uIP TCP throughput booster hack - * @{ +/* uipsplit uIP TCP throughput booster hack * * The basic uIP TCP implementation only allows each TCP connection to * have a single TCP segment in flight at any given time. Because of @@ -59,15 +59,9 @@ * to work. */ - -/** - * \file - * Module for splitting outbound TCP segments in two to avoid the - * delayed ACK throughput degradation. - * \author - * Adam Dunkels <adam@sics.se> - * - */ +/**************************************************************************** + * Included Files + ****************************************************************************/ #ifndef __UIP_SPLIT_H__ #define __UIP_SPLIT_H__ |