From ecd3b8c85c7faf6f4317856f90bdd64cb57e1afc Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 2 Aug 2009 16:31:50 +0000 Subject: Fix accept() -- it wanted parts of return address initialized git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2008 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/TODO | 7 ++++++- nuttx/net/accept.c | 18 +++++++++++++----- nuttx/netutils/thttpd/libhttpd.c | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/nuttx/TODO b/nuttx/TODO index 90bc12847..b129aea6d 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -1,4 +1,4 @@ -NuttX TODO List (Last updated June 26, 2009) +NuttX TODO List (Last updated August 3, 2009) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (5) Task/Scheduler (sched/) @@ -234,6 +234,11 @@ o Network (net/, netutils/) Status: Open, depends on UDP read-ahead support Priority: Medium + Description: sockets do not support any modes except for O_NONBLOCK (that + that is not implemented in a very general way at present) + Status: Open + Priority: Low. + o USB (drivers/usbdev) ^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c index c2e64153c..81ac8dbff 100644 --- a/nuttx/net/accept.c +++ b/nuttx/net/accept.c @@ -1,7 +1,7 @@ /**************************************************************************** * net/accept.c * - * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -102,10 +102,17 @@ struct accept_s #ifdef CONFIG_NET_IPv6 static inline void accept_tcpsender(FAR struct uip_conn *conn, FAR struct sockaddr_in6 *addr) +{ + if (addr) + { + addr->sin_family = AF_INET6; + addr->sin_port = conn->rport; + uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr); + } +} #else static inline void accept_tcpsender(FAR struct uip_conn *conn, FAR struct sockaddr_in *addr) -#endif { if (addr) { @@ -114,7 +121,8 @@ static inline void accept_tcpsender(FAR struct uip_conn *conn, uip_ipaddr_copy(addr->sin_addr.s_addr, conn->ripaddr); } } -#endif +#endif /* CONFIG_NET_IPv6 */ +#endif /* CONFIG_NET_TCP */ /**************************************************************************** * Function: accept_interrupt @@ -304,9 +312,9 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) if (addr) { #ifdef CONFIG_NET_IPv6 - if (addr->sa_family != AF_INET6 || *addrlen < sizeof(struct sockaddr_in6)) + if (*addrlen < sizeof(struct sockaddr_in6)) #else - if (addr->sa_family != AF_INET || *addrlen < sizeof(struct sockaddr_in)) + if (*addrlen < sizeof(struct sockaddr_in)) #endif { err = EBADF; diff --git a/nuttx/netutils/thttpd/libhttpd.c b/nuttx/netutils/thttpd/libhttpd.c index ad5091c1b..fa294f392 100644 --- a/nuttx/netutils/thttpd/libhttpd.c +++ b/nuttx/netutils/thttpd/libhttpd.c @@ -3551,7 +3551,7 @@ char *httpd_method_str(int method) } } -int httpd_get_conn(httpd_server * hs, int listen_fd, httpd_conn *hc) +int httpd_get_conn(httpd_server *hs, int listen_fd, httpd_conn *hc) { httpd_sockaddr sa; socklen_t sz; @@ -3596,7 +3596,7 @@ int httpd_get_conn(httpd_server * hs, int listen_fd, httpd_conn *hc) return GC_NO_MORE; } - ndbg("accept: %d\n", errno); + ndbg("accept failed: %d\n", errno); return GC_FAIL; } -- cgit v1.2.3