From 8ce7b46ab61009d05f9d2624240fcc128ab6390e Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 18 Nov 2008 22:14:25 +0000 Subject: Basic setup of network select git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1278 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/net/net-poll.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'nuttx/net') diff --git a/nuttx/net/net-poll.c b/nuttx/net/net-poll.c index 08c2bb1b4..4ceeb421a 100644 --- a/nuttx/net/net-poll.c +++ b/nuttx/net/net-poll.c @@ -42,10 +42,18 @@ #include #include + +#include #include #include +#include +#include #include +#include + +#include + #include "net-internal.h" /**************************************************************************** @@ -57,7 +65,7 @@ * buffering. */ -#if defined(CONFIG_DISABLE_POLL) && CONFIG_NSOCKET_DESCRIPTORS > 0 && \ +#if !defined(CONFIG_DISABLE_POLL) && CONFIG_NSOCKET_DESCRIPTORS > 0 && \ defined(CONFIG_NET_TCP) && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0 # define HAVE_NETPOLL 1 #else @@ -68,11 +76,6 @@ * Private Types ****************************************************************************/ -struct net_poll_s -{ - FAR struct pollfd *fds; /* The descriptor poll info */ -}; - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -101,7 +104,7 @@ struct net_poll_s static uint16 poll_interrupt(struct uip_driver_s *dev, FAR void *conn, FAR void *pvprivate, uint16 flags) { - struct pollfd *fds = (struct recvfrom_s *)pvprivate; + FAR struct pollfd *fds = (FAR struct pollfd *)pvprivate; nvdbg("flags: %04x\n", flags); @@ -134,7 +137,7 @@ static uint16 poll_interrupt(struct uip_driver_s *dev, FAR void *conn, if (eventset) { - fds->revevents |= eventset; + fds->revents |= eventset; sem_post(fds->sem); } } @@ -159,7 +162,7 @@ static uint16 poll_interrupt(struct uip_driver_s *dev, FAR void *conn, ****************************************************************************/ #ifdef HAVE_NETPOLL -static inline int net_pollsetup((FAR struct uip_conn *)conn, struct pollfd *fds) +static inline int net_pollsetup(FAR struct uip_conn *conn, struct pollfd *fds) { FAR struct uip_callback_s *cb; irqstate_t flags; @@ -215,7 +218,6 @@ static inline int net_pollsetup((FAR struct uip_conn *)conn, struct pollfd *fds) errout_with_irq: irqrestore(flags); - free(nps); errout: return ret; } @@ -236,19 +238,17 @@ errout: ****************************************************************************/ #ifdef HAVE_NETPOLL -static inline int net_pollteardown((FAR struct uip_conn *)conn, struct pollfd *fds) +static inline int net_pollteardown(FAR struct uip_conn *conn, struct pollfd *fds) { FAR struct uip_callback_s *cb; irqstate_t flags; - int ret; /* Sanity check */ #ifdef CONFIG_DEBUG if (!conn || !fds || !fds->private) { - ret = -EINVAL; - goto errout; + return -EINVAL; } #endif @@ -294,7 +294,7 @@ static inline int net_pollteardown((FAR struct uip_conn *)conn, struct pollfd *f ****************************************************************************/ #ifndef CONFIG_DISABLE_POLL -int net_poll(int sockfd, struct pollfd *fds) +int net_poll(int sockfd, struct pollfd *fds, boolean setup) { #ifndef HAVE_NETPOLL return -ENOSYS; @@ -334,17 +334,17 @@ int net_poll(int sockfd, struct pollfd *fds) #endif /* Check if we are setting up or tearing down the poll */ - if (fds) + if (setup) { /* Perform the TCP/IP poll() setup */ - ret = net_pollsetup((FAR struct uip_conn *)psock->conn, fds); + ret = net_pollsetup((FAR struct uip_conn *)psock->s_conn, fds); } else { /* Perform the TCP/IP poll() teardown */ - ret = net_pollteardown((FAR struct uip_conn *)psock->conn); + ret = net_pollteardown((FAR struct uip_conn *)psock->s_conn, fds); } errout: -- cgit v1.2.3