diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-06-26 14:23:21 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-06-26 14:23:21 -0600 |
commit | 54e2e924a10fe187c991ccad392b161007163bf5 (patch) | |
tree | d7d5e49406a82224ca8166948d700f82d0044c80 /nuttx/net | |
parent | f6156f8cce3bc7a944b295aeb9c027e46eeddcf3 (diff) | |
download | px4-nuttx-54e2e924a10fe187c991ccad392b161007163bf5.tar.gz px4-nuttx-54e2e924a10fe187c991ccad392b161007163bf5.tar.bz2 px4-nuttx-54e2e924a10fe187c991ccad392b161007163bf5.zip |
Move files to net/utils; make appropriate name changes, most for uip_lock to net_lock
Diffstat (limited to 'nuttx/net')
40 files changed, 340 insertions, 196 deletions
diff --git a/nuttx/net/Kconfig b/nuttx/net/Kconfig index 76807288a..294ea523e 100644 --- a/nuttx/net/Kconfig +++ b/nuttx/net/Kconfig @@ -131,6 +131,7 @@ source "net/icmp/Kconfig" source "net/igmp/Kconfig" source "net/arp/Kconfig" source "net/iob/Kconfig" +source "net/utils/Kconfig" config NET_STATISTICS bool "Collect network statistics" diff --git a/nuttx/net/Makefile b/nuttx/net/Makefile index f81257483..adaaf1c22 100644 --- a/nuttx/net/Makefile +++ b/nuttx/net/Makefile @@ -58,7 +58,7 @@ endif ifeq ($(CONFIG_NET_SOCKOPTS),y) SOCK_CSRCS += setsockopt.c getsockopt.c ifneq ($(CONFIG_DISABLE_CLOCK),y) -SOCK_CSRCS += net_timeo.c net_dsec2timeval.c net_timeval2dsec.c +SOCK_CSRCS += net_timeo.c net_timeval2dsec.c endif endif diff --git a/nuttx/net/accept.c b/nuttx/net/accept.c index 3f0ca106c..6c04fa1c0 100644 --- a/nuttx/net/accept.c +++ b/nuttx/net/accept.c @@ -265,7 +265,7 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) #else FAR struct sockaddr_in *inaddr = (struct sockaddr_in *)addr; #endif - uip_lock_t save; + net_lock_t save; int newfd; int err; int ret; @@ -347,7 +347,7 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) * this listener. */ - save = uip_lock(); + save = net_lock(); conn = (struct tcp_conn_s *)psock->s_conn; #ifdef CONFIG_NET_TCPBACKLOG @@ -396,12 +396,12 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) conn->accept = accept_interrupt; /* Wait for the send to complete or an error to occur: NOTES: (1) - * uip_lockedwait will also terminate if a signal is received, (2) interrupts + * net_lockedwait will also terminate if a signal is received, (2) interrupts * may be disabled! They will be re-enabled while the task sleeps and * automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state.acpt_sem); + ret = net_lockedwait(&state.acpt_sem); /* Make sure that no further interrupts are processed */ @@ -424,8 +424,8 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) goto errout_with_lock; } - /* If uip_lockedwait failed, then we were probably reawakened by a signal. In - * this case, uip_lockedwait will have set errno appropriately. + /* If net_lockedwait failed, then we were probably reawakened by a signal. In + * this case, net_lockedwait will have set errno appropriately. */ if (ret < 0) @@ -448,11 +448,11 @@ int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen) /* Begin monitoring for TCP connection events on the newly connected socket */ net_startmonitor(pnewsock); - uip_unlock(save); + net_unlock(save); return newfd; errout_with_lock: - uip_unlock(save); + net_unlock(save); errout_with_socket: sockfd_release(newfd); diff --git a/nuttx/net/connect.c b/nuttx/net/connect.c index e80c83d93..cb0a1a606 100644 --- a/nuttx/net/connect.c +++ b/nuttx/net/connect.c @@ -286,7 +286,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, #endif { struct tcp_connect_s state; - uip_lock_t flags; + net_lock_t flags; int ret = OK; /* Interrupts must be disabled through all of the following because @@ -294,7 +294,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, * setup. */ - flags = uip_lock(); + flags = net_lock(); /* Get the connection reference from the socket */ @@ -317,19 +317,19 @@ static inline int psock_tcp_connect(FAR struct socket *psock, if (ret >= 0) { /* Wait for either the connect to complete or for an error/timeout - * to occur. NOTES: (1) uip_lockedwait will also terminate if a signal + * to occur. NOTES: (1) net_lockedwait will also terminate if a signal * is received, (2) interrupts may be disabled! They will be re- * enabled while the task sleeps and automatically re-disabled * when the task restarts. */ - ret = uip_lockedwait(&state.tc_sem); + ret = net_lockedwait(&state.tc_sem); /* Uninitialize the state structure */ (void)sem_destroy(&state.tc_sem); - /* If uip_lockedwait failed, recover the negated error (probably -EINTR) */ + /* If net_lockedwait failed, recover the negated error (probably -EINTR) */ if (ret < 0) { @@ -357,7 +357,7 @@ static inline int psock_tcp_connect(FAR struct socket *psock, } } - uip_unlock(flags); + net_unlock(flags); return ret; } #endif /* CONFIG_NET_TCP */ diff --git a/nuttx/net/getsockopt.c b/nuttx/net/getsockopt.c index d1b8578c4..7d106b591 100644 --- a/nuttx/net/getsockopt.c +++ b/nuttx/net/getsockopt.c @@ -45,6 +45,7 @@ #include <errno.h> #include "net.h" +#include "utils/utils.h" /**************************************************************************** * Global Functions diff --git a/nuttx/net/icmp/icmp_ping.c b/nuttx/net/icmp/icmp_ping.c index e99ec944e..006086ef3 100644 --- a/nuttx/net/icmp/icmp_ping.c +++ b/nuttx/net/icmp/icmp_ping.c @@ -328,7 +328,7 @@ int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, int dsecs) { struct icmp_ping_s state; - uip_lock_t save; + net_lock_t save; /* Initialize the state structure */ @@ -341,7 +341,7 @@ int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, state.png_datlen = datalen; /* The length of data to send in the ECHO request */ state.png_sent = false; /* ECHO request not yet sent */ - save = uip_lock(); + save = net_lock(); state.png_time = clock_systimer(); /* Set up the callback */ @@ -359,19 +359,19 @@ int uip_ping(uip_ipaddr_t addr, uint16_t id, uint16_t seqno, netdev_txnotify(state.png_addr); /* Wait for either the full round trip transfer to complete or - * for timeout to occur. (1) uip_lockedwait will also terminate if a + * for timeout to occur. (1) net_lockedwait will also terminate if a * signal is received, (2) interrupts may be disabled! They will * be re-enabled while the task sleeps and automatically * re-enabled when the task restarts. */ nlldbg("Start time: 0x%08x seqno: %d\n", state.png_time, seqno); - uip_lockedwait(&state.png_sem); + net_lockedwait(&state.png_sem); icmp_callbackfree(state.png_cb); } - uip_unlock(save); + net_unlock(save); /* Return the negated error number in the event of a failure, or the * sequence number of the ECHO reply on success. diff --git a/nuttx/net/igmp/igmp_group.c b/nuttx/net/igmp/igmp_group.c index 1244377bc..85bfa1a0c 100644 --- a/nuttx/net/igmp/igmp_group.c +++ b/nuttx/net/igmp/igmp_group.c @@ -223,7 +223,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct uip_driver_s *dev, FAR const uip_ipaddr_t *addr) { FAR struct igmp_group_s *group; - uip_lock_t flags; + net_lock_t flags; nllvdbg("addr: %08x dev: %p\n", *addr, dev); if (up_interrupt_context()) @@ -260,12 +260,12 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct uip_driver_s *dev, /* Interrupts must be disabled in order to modify the group list */ - flags = uip_lock(); + flags = net_lock(); /* Add the group structure to the list in the device structure */ sq_addfirst((FAR sq_entry_t*)group, &dev->grplist); - uip_unlock(flags); + net_unlock(flags); } return group; @@ -286,7 +286,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct uip_driver_s *dev, FAR const uip_ipaddr_t *addr) { FAR struct igmp_group_s *group; - uip_lock_t flags; + net_lock_t flags; grplldbg("Searching for addr %08x\n", (int)*addr); @@ -294,7 +294,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct uip_driver_s *dev, * called from. */ - flags = uip_lock(); + flags = net_lock(); for (group = (FAR struct igmp_group_s *)dev->grplist.head; group; group = group->next) @@ -307,7 +307,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct uip_driver_s *dev, } } - uip_unlock(flags); + net_unlock(flags); return group; } @@ -351,13 +351,13 @@ FAR struct igmp_group_s *igmp_grpallocfind(FAR struct uip_driver_s *dev, void igmp_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group) { - uip_lock_t flags; + net_lock_t flags; grplldbg("Free: %p flags: %02x\n", group, group->flags); /* Cancel the wdog */ - flags = uip_lock(); + flags = net_lock(); wd_cancel(group->wdog); /* Remove the group structure from the group list in the device structure */ @@ -381,7 +381,7 @@ void igmp_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group) { grplldbg("Put back on free list\n"); sq_addlast((FAR sq_entry_t*)group, &g_freelist); - uip_unlock(flags); + net_unlock(flags); } else #endif @@ -390,7 +390,7 @@ void igmp_grpfree(FAR struct uip_driver_s *dev, FAR struct igmp_group_s *group) * this function is executing within an interrupt handler. */ - uip_unlock(flags); + net_unlock(flags); grplldbg("Call sched_kfree()\n"); sched_kfree(group); } diff --git a/nuttx/net/igmp/igmp_leave.c b/nuttx/net/igmp/igmp_leave.c index 0665d12e9..58e28771c 100644 --- a/nuttx/net/igmp/igmp_leave.c +++ b/nuttx/net/igmp/igmp_leave.c @@ -132,7 +132,7 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr) { struct igmp_group_s *group; - uip_lock_t flags; + net_lock_t flags; DEBUGASSERT(dev && grpaddr); @@ -148,11 +148,11 @@ int igmp_leavegroup(struct uip_driver_s *dev, FAR const struct in_addr *grpaddr) * could interfere with the Leave Group. */ - flags = uip_lock(); + flags = net_lock(); wd_cancel(group->wdog); CLR_SCHEDMSG(group->flags); CLR_WAITMSG(group->flags); - uip_unlock(flags); + net_unlock(flags); IGMP_STATINCR(g_netstats.igmp.leaves); diff --git a/nuttx/net/igmp/igmp_msg.c b/nuttx/net/igmp/igmp_msg.c index 79a8bd966..5a42cadbd 100644 --- a/nuttx/net/igmp/igmp_msg.c +++ b/nuttx/net/igmp/igmp_msg.c @@ -80,15 +80,15 @@ void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid) { - uip_lock_t flags; + net_lock_t flags; /* The following should be atomic */ - flags = uip_lock(); + flags = net_lock(); DEBUGASSERT(!IS_SCHEDMSG(group->flags)); group->msgid = msgid; SET_SCHEDMSG(group->flags); - uip_unlock(flags); + net_unlock(flags); } /**************************************************************************** @@ -100,17 +100,17 @@ void igmp_schedmsg(FAR struct igmp_group_s *group, uint8_t msgid) * * Assumptions: * This function cannot be called from an interrupt handler (if you try it, - * uip_lockedwait will assert). + * net_lockedwait will assert). * ****************************************************************************/ void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) { - uip_lock_t flags; + net_lock_t flags; /* Schedule to send the message */ - flags = uip_lock(); + flags = net_lock(); DEBUGASSERT(!IS_WAITMSG(group->flags)); SET_WAITMSG(group->flags); igmp_schedmsg(group, msgid); @@ -121,9 +121,9 @@ void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) { /* Wait for the semaphore to be posted */ - while (uip_lockedwait(&group->sem) != 0) + while (net_lockedwait(&group->sem) != 0) { - /* The only error that should occur from uip_lockedwait() is if + /* The only error that should occur from net_lockedwait() is if * the wait is awakened by a signal. */ @@ -134,7 +134,7 @@ void igmp_waitmsg(FAR struct igmp_group_s *group, uint8_t msgid) /* The message has been sent and we are no longer waiting */ CLR_WAITMSG(group->flags); - uip_unlock(flags); + net_unlock(flags); } #endif /* CONFIG_NET_IGMP */ diff --git a/nuttx/net/igmp/igmp_timer.c b/nuttx/net/igmp/igmp_timer.c index 3b39d5a53..5feebdd2e 100644 --- a/nuttx/net/igmp/igmp_timer.c +++ b/nuttx/net/igmp/igmp_timer.c @@ -153,10 +153,10 @@ static void igmp_timeout(int argc, uint32_t arg, ...) ****************************************************************************/ /**************************************************************************** - * Name: igmp_starttimer + * Name: igmp_decisec2tick * * Description: - * Start the IGMP timer. + * Convert the deci-second value to units of system clock ticks. * * Assumptions: * This function may be called from most any context. @@ -225,14 +225,14 @@ void igmp_starttimer(FAR struct igmp_group_s *group, uint8_t decisecs) bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks) { - uip_lock_t flags; + net_lock_t flags; int remaining; /* Disable interrupts so that there is no race condition with the actual * timer expiration. */ - flags = uip_lock(); + flags = net_lock(); /* Get the timer remaining on the watchdog. A time of <= zero means that * the watchdog was never started. @@ -251,11 +251,11 @@ bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks) /* Cancel the watchdog timer and return true */ wd_cancel(group->wdog); - uip_unlock(flags); + net_unlock(flags); return true; } - uip_unlock(flags); + net_unlock(flags); return false; } diff --git a/nuttx/net/net.h b/nuttx/net/net.h index 0f9463158..8ff311aae 100644 --- a/nuttx/net/net.h +++ b/nuttx/net/net.h @@ -184,7 +184,6 @@ int psock_close(FAR struct socket *psock); #if defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) int net_timeo(uint32_t start_time, socktimeo_t timeo); socktimeo_t net_timeval2dsec(FAR struct timeval *tv); -void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv); #endif /* net_register.c ************************************************************/ diff --git a/nuttx/net/net_clone.c b/nuttx/net/net_clone.c index 99dd44739..52905da5e 100644 --- a/nuttx/net/net_clone.c +++ b/nuttx/net/net_clone.c @@ -64,12 +64,12 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2) { - uip_lock_t flags; + net_lock_t flags; int ret = OK; /* Parts of this operation need to be atomic */ - flags = uip_lock(); + flags = net_lock(); /* Duplicate the socket state */ @@ -119,7 +119,7 @@ int net_clone(FAR struct socket *psock1, FAR struct socket *psock2) ret = -EBADF; } - uip_unlock(flags); + net_unlock(flags); return ret; } diff --git a/nuttx/net/net_close.c b/nuttx/net/net_close.c index ed47f0cf5..f74a4119f 100644 --- a/nuttx/net/net_close.c +++ b/nuttx/net/net_close.c @@ -278,7 +278,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) { struct tcp_close_s state; FAR struct tcp_conn_s *conn; - uip_lock_t flags; + net_lock_t flags; #ifdef CONFIG_NET_SOLINGER bool linger; #endif @@ -286,7 +286,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) /* Interrupts are disabled here to avoid race conditions */ - flags = uip_lock(); + flags = net_lock(); conn = (FAR struct tcp_conn_s *)psock->s_conn; /* If we have a semi-permanent write buffer callback in place, then @@ -367,7 +367,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) { /* Wait for the disconnect event */ - (void)uip_lockedwait(&state.cl_sem); + (void)net_lockedwait(&state.cl_sem); /* We are now disconnected */ @@ -390,7 +390,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) tcp_free(conn); } - uip_unlock(flags); + net_unlock(flags); return ret; } #endif /* CONFIG_NET_TCP */ diff --git a/nuttx/net/net_poll.c b/nuttx/net/net_poll.c index ca454e182..f7d27de35 100644 --- a/nuttx/net/net_poll.c +++ b/nuttx/net/net_poll.c @@ -188,7 +188,7 @@ static inline int net_pollsetup(FAR struct socket *psock, FAR struct tcp_conn_s *conn = psock->s_conn; FAR struct net_poll_s *info; FAR struct uip_callback_s *cb; - uip_lock_t flags; + net_lock_t flags; int ret; /* Sanity check */ @@ -210,7 +210,7 @@ static inline int net_pollsetup(FAR struct socket *psock, /* Some of the following must be atomic */ - flags = uip_lock(); + flags = net_lock(); /* Allocate a TCP/IP callback structure */ @@ -316,12 +316,12 @@ static inline int net_pollsetup(FAR struct socket *psock, sem_post(fds->sem); } - uip_unlock(flags); + net_unlock(flags); return OK; errout_with_lock: kfree(info); - uip_unlock(flags); + net_unlock(flags); return ret; } #endif /* HAVE_NETPOLL */ @@ -346,7 +346,7 @@ static inline int net_pollteardown(FAR struct socket *psock, { FAR struct tcp_conn_s *conn = psock->s_conn; FAR struct net_poll_s *info; - uip_lock_t flags; + net_lock_t flags; /* Sanity check */ @@ -365,9 +365,9 @@ static inline int net_pollteardown(FAR struct socket *psock, { /* Release the callback */ - flags = uip_lock(); + flags = net_lock(); tcp_callbackfree(conn, info->cb); - uip_unlock(flags); + net_unlock(flags); /* Release the poll/select data slot */ diff --git a/nuttx/net/net_sendfile.c b/nuttx/net/net_sendfile.c index ad7924d53..b023b9dac 100644 --- a/nuttx/net/net_sendfile.c +++ b/nuttx/net/net_sendfile.c @@ -451,7 +451,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, FAR struct socket *psock = sockfd_socket(outfd); FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s*)psock->s_conn; struct sendfile_s state; - uip_lock_t save; + net_lock_t save; int err; /* Verify that the sockfd corresponds to valid, allocated socket */ @@ -479,7 +479,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, * are ready. */ - save = uip_lock(); + save = net_lock(); memset(&state, 0, sizeof(struct sendfile_s)); sem_init(&state. snd_sem, 0, 0); /* Doesn't really fail */ @@ -542,7 +542,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, netdev_txnotify(conn->ripaddr); - uip_lockedwait(&state.snd_sem); + net_lockedwait(&state.snd_sem); } while (state.snd_sent >= 0 && state.snd_acked < state.snd_flen); @@ -558,7 +558,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, errout_locked: sem_destroy(&state. snd_sem); - uip_unlock(save); + net_unlock(save); errout: diff --git a/nuttx/net/net_sockets.c b/nuttx/net/net_sockets.c index df19c216a..63120b913 100644 --- a/nuttx/net/net_sockets.c +++ b/nuttx/net/net_sockets.c @@ -81,7 +81,7 @@ static void _net_semtake(FAR struct socketlist *list) { /* Take the semaphore (perhaps waiting) */ - while (uip_lockedwait(&list->sl_sem) != 0) + while (net_lockedwait(&list->sl_sem) != 0) { /* The only case that an error should occr here is if * the wait was awakened by a signal. diff --git a/nuttx/net/net_vfcntl.c b/nuttx/net/net_vfcntl.c index 7db7fdb77..50da8a020 100644 --- a/nuttx/net/net_vfcntl.c +++ b/nuttx/net/net_vfcntl.c @@ -62,7 +62,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) { FAR struct socket *psock = sockfd_socket(sockfd); - uip_lock_t flags; + net_lock_t flags; int err = 0; int ret = 0; @@ -76,7 +76,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) /* Interrupts must be disabled in order to perform operations on socket structures */ - flags = uip_lock(); + flags = net_lock(); switch (cmd) { case F_DUPFD: @@ -219,7 +219,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap) break; } - uip_unlock(flags); + net_unlock(flags); errout: if (err != 0) diff --git a/nuttx/net/netdev_sem.c b/nuttx/net/netdev_sem.c index b56f7cba2..f07ad5367 100644 --- a/nuttx/net/netdev_sem.c +++ b/nuttx/net/netdev_sem.c @@ -129,7 +129,7 @@ void netdev_semtake(void) { /* No.. take the semaphore (perhaps waiting) */ - while (uip_lockedwait(&g_devlock.sem) != 0) + while (net_lockedwait(&g_devlock.sem) != 0) { /* The only case that an error should occur here is if * the wait was awakened by a signal. diff --git a/nuttx/net/pkt/pkt_conn.c b/nuttx/net/pkt/pkt_conn.c index c984bb9b0..55a8a3506 100644 --- a/nuttx/net/pkt/pkt_conn.c +++ b/nuttx/net/pkt/pkt_conn.c @@ -92,7 +92,7 @@ static inline void _uip_semtake(sem_t *sem) { /* Take the semaphore (perhaps waiting) */ - while (uip_lockedwait(sem) != 0) + while (net_lockedwait(sem) != 0) { /* The only case that an error should occur here is if * the wait was awakened by a signal. diff --git a/nuttx/net/pkt/pkt_send.c b/nuttx/net/pkt/pkt_send.c index 768bd403c..7dbbd83e8 100644 --- a/nuttx/net/pkt/pkt_send.c +++ b/nuttx/net/pkt/pkt_send.c @@ -206,7 +206,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, size_t len) { struct send_s state; - uip_lock_t save; + net_lock_t save; int err; int ret = OK; @@ -229,7 +229,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, * are ready. */ - save = uip_lock(); + save = net_lock(); memset(&state, 0, sizeof(struct send_s)); (void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */ state.snd_sock = psock; /* Socket descriptor to use */ @@ -271,12 +271,12 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, dev->d_txavail(dev); /* Wait for the send to complete or an error to occure: NOTES: (1) - * uip_lockedwait will also terminate if a signal is received, (2) + * net_lockedwait will also terminate if a signal is received, (2) * interrupts may be disabled! They will be re-enabled while the * task sleeps and automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state.snd_sem); + ret = net_lockedwait(&state.snd_sem); /* Make sure that no further interrupts are processed */ @@ -289,7 +289,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, } sem_destroy(&state.snd_sem); - uip_unlock(save); + net_unlock(save); /* Set the socket state to idle */ @@ -305,8 +305,8 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf, goto errout; } - /* If uip_lockedwait failed, then we were probably reawakened by a signal. In - * this case, uip_lockedwait will have set errno appropriately. + /* If net_lockedwait failed, then we were probably reawakened by a signal. In + * this case, net_lockedwait will have set errno appropriately. */ if (ret < 0) diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index 256150624..824b360e9 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -986,7 +986,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len, * Evaluate the result of the recv operations * * Parameters: - * result The result of the uip_lockedwait operation (may indicate EINTR) + * result The result of the net_lockedwait operation (may indicate EINTR) * pstate A pointer to the state structure to be initialized * * Returned Value: @@ -1014,8 +1014,8 @@ static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate) return pstate->rf_result; } - /* If uip_lockedwait failed, then we were probably reawakened by a signal. In - * this case, uip_lockedwait will have set errno appropriately. + /* If net_lockedwait failed, then we were probably reawakened by a signal. In + * this case, net_lockedwait will have set errno appropriately. */ if (result < 0) @@ -1047,7 +1047,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, { FAR struct pkt_conn_s *conn = (FAR struct pkt_conn_s *)psock->s_conn; struct recvfrom_s state; - uip_lock_t save; + net_lock_t save; int ret; /* Perform the packet recvfrom() operation */ @@ -1057,7 +1057,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * are ready. */ - save = uip_lock(); + save = net_lock(); recvfrom_init(psock, buf, len, (struct sockaddr_in *)from, &state); /* TODO recvfrom_init() expects from to be of type sockaddr_in, but @@ -1086,12 +1086,12 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* netdev_rxnotify(conn->ripaddr); */ /* Wait for either the receive to complete or for an error/timeout to occur. - * NOTES: (1) uip_lockedwait will also terminate if a signal is received, (2) + * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) * interrupts are disabled! They will be re-enabled while the task sleeps * and automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state.rf_sem); + ret = net_lockedwait(&state.rf_sem); /* Make sure that no further interrupts are processed */ @@ -1106,7 +1106,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #if 0 /* Not used */ errout_with_state: #endif - uip_unlock(save); + net_unlock(save); recvfrom_uninit(&state); return ret; } @@ -1143,7 +1143,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, { FAR struct udp_conn_s *conn = (FAR struct udp_conn_s *)psock->s_conn; struct recvfrom_s state; - uip_lock_t save; + net_lock_t save; int ret; /* Perform the UDP recvfrom() operation */ @@ -1153,7 +1153,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * are ready. */ - save = uip_lock(); + save = net_lock(); recvfrom_init(psock, buf, len, infrom, &state); /* Setup the UDP remote connection */ @@ -1180,12 +1180,12 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, netdev_rxnotify(conn->ripaddr); /* Wait for either the receive to complete or for an error/timeout to occur. - * NOTES: (1) uip_lockedwait will also terminate if a signal is received, (2) + * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) * interrupts are disabled! They will be re-enabled while the task sleeps * and automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state. rf_sem); + ret = net_lockedwait(&state. rf_sem); /* Make sure that no further interrupts are processed */ @@ -1198,7 +1198,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, } errout_with_state: - uip_unlock(save); + net_unlock(save); recvfrom_uninit(&state); return ret; } @@ -1234,7 +1234,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, #endif { struct recvfrom_s state; - uip_lock_t save; + net_lock_t save; int ret; /* Initialize the state structure. This is done with interrupts @@ -1242,7 +1242,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, * are ready. */ - save = uip_lock(); + save = net_lock(); recvfrom_init(psock, buf, len, infrom, &state); /* Handle any any TCP data already buffered in a read-ahead buffer. NOTE @@ -1361,12 +1361,12 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, state.rf_cb->event = recvfrom_tcpinterrupt; /* Wait for either the receive to complete or for an error/timeout to occur. - * NOTES: (1) uip_lockedwait will also terminate if a signal is received, (2) + * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) * interrupts may be disabled! They will be re-enabled while the task sleeps * and automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state.rf_sem); + ret = net_lockedwait(&state.rf_sem); /* Make sure that no further interrupts are processed */ @@ -1379,7 +1379,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, } } - uip_unlock(save); + net_unlock(save); recvfrom_uninit(&state); return (ssize_t)ret; } diff --git a/nuttx/net/route/net_addroute.c b/nuttx/net/route/net_addroute.c index a29e5b461..8c842a1e2 100644 --- a/nuttx/net/route/net_addroute.c +++ b/nuttx/net/route/net_addroute.c @@ -80,7 +80,7 @@ int net_addroute(uip_ipaddr_t target, uip_ipaddr_t netmask, uip_ipaddr_t router) { FAR struct net_route_s *route; - uip_lock_t save; + net_lock_t save; /* Allocate a route entry */ @@ -99,12 +99,12 @@ int net_addroute(uip_ipaddr_t target, uip_ipaddr_t netmask, /* Get exclusive address to the networking data structures */ - save = uip_lock(); + save = net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_routes); - uip_unlock(save); + net_unlock(save); return OK; } diff --git a/nuttx/net/route/net_allocroute.c b/nuttx/net/route/net_allocroute.c index bcb82be2b..9efa120ed 100644 --- a/nuttx/net/route/net_allocroute.c +++ b/nuttx/net/route/net_allocroute.c @@ -127,18 +127,18 @@ void net_initroute(void) FAR struct net_route_s *net_allocroute(void) { FAR struct net_route_s *route; - uip_lock_t save; + net_lock_t save; /* Get exclusive address to the networking data structures */ - save = uip_lock(); + save = net_lock(); /* Then add the new entry to the table */ route = (FAR struct net_route_s *) sq_remfirst((FAR sq_queue_t *)&g_freeroutes); - uip_unlock(save); + net_unlock(save); return route; } @@ -158,18 +158,18 @@ FAR struct net_route_s *net_allocroute(void) void net_freeroute(FAR struct net_route_s *route) { - uip_lock_t save; + net_lock_t save; DEBUGASSERT(route); /* Get exclusive address to the networking data structures */ - save = uip_lock(); + save = net_lock(); /* Then add the new entry to the table */ sq_addlast((FAR sq_entry_t *)route, (FAR sq_queue_t *)&g_freeroutes); - uip_unlock(save); + net_unlock(save); } #endif /* CONFIG_NET && CONFIG_NET_ROUTE */ diff --git a/nuttx/net/route/net_foreachroute.c b/nuttx/net/route/net_foreachroute.c index fb2b7e87b..aaf92b14c 100644 --- a/nuttx/net/route/net_foreachroute.c +++ b/nuttx/net/route/net_foreachroute.c @@ -74,12 +74,12 @@ int net_foreachroute(route_handler_t handler, FAR void *arg) { FAR struct net_route_s *route; FAR struct net_route_s *next; - uip_lock_t save; + net_lock_t save; int ret = 0; /* Prevent concurrent access to the routing table */ - save = uip_lock(); + save = net_lock(); /* Visit each entry in the routing table */ @@ -95,7 +95,7 @@ int net_foreachroute(route_handler_t handler, FAR void *arg) /* Unlock uIP */ - uip_unlock(save); + net_unlock(save); return ret; } diff --git a/nuttx/net/sendto.c b/nuttx/net/sendto.c index 54a9beff8..a38a09f25 100644 --- a/nuttx/net/sendto.c +++ b/nuttx/net/sendto.c @@ -306,7 +306,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, FAR const struct sockaddr_in *into = (const struct sockaddr_in *)to; #endif struct sendto_s state; - uip_lock_t save; + net_lock_t save; int ret; #endif int err; @@ -365,7 +365,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, * are ready. */ - save = uip_lock(); + save = net_lock(); memset(&state, 0, sizeof(struct sendto_s)); sem_init(&state.st_sem, 0, 0); state.st_buflen = len; @@ -384,7 +384,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, ret = udp_connect(conn, into); if (ret < 0) { - uip_unlock(save); + net_unlock(save); err = -ret; goto errout; } @@ -403,19 +403,19 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, netdev_txnotify(conn->ripaddr); /* Wait for either the receive to complete or for an error/timeout to occur. - * NOTES: (1) uip_lockedwait will also terminate if a signal is received, (2) + * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) * interrupts may be disabled! They will be re-enabled while the task sleeps * and automatically re-enabled when the task restarts. */ - uip_lockedwait(&state.st_sem); + net_lockedwait(&state.st_sem); /* Make sure that no further interrupts are processed */ udp_callbackfree(conn, state.st_cb); } - uip_unlock(save); + net_unlock(save); sem_destroy(&state.st_sem); /* Set the socket state to idle */ diff --git a/nuttx/net/setsockopt.c b/nuttx/net/setsockopt.c index 40e12c7a0..e6fc2d092 100644 --- a/nuttx/net/setsockopt.c +++ b/nuttx/net/setsockopt.c @@ -101,7 +101,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, FAR const void *value, socklen_t value_len) { - uip_lock_t flags; + net_lock_t flags; int err; /* Verify that the socket option if valid (but might not be supported ) */ @@ -149,7 +149,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * level access to options. */ - flags = uip_lock(); + flags = net_lock(); /* Set or clear the option bit */ @@ -162,7 +162,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, _SO_CLROPT(psock->s_options, option); } - uip_unlock(flags); + net_unlock(flags); } break; @@ -232,7 +232,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, * level access to options. */ - flags = uip_lock(); + flags = net_lock(); /* Set or clear the linger option bit and linger time (in deciseconds) */ @@ -251,7 +251,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option, #endif } - uip_unlock(flags); + net_unlock(flags); } break; #endif diff --git a/nuttx/net/tcp/tcp_backlog.c b/nuttx/net/tcp/tcp_backlog.c index 9899d7af0..64692b367 100644 --- a/nuttx/net/tcp/tcp_backlog.c +++ b/nuttx/net/tcp/tcp_backlog.c @@ -80,7 +80,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) { FAR struct tcp_backlog_s *bls = NULL; FAR struct tcp_blcontainer_s *blc; - uip_lock_t flags; + net_lock_t flags; int size; int offset; int i; @@ -133,7 +133,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) /* Destroy any existing backlog (shouldn't be any) */ - flags = uip_lock(); + flags = net_lock(); tcp_backlogdestroy(conn); /* Now install the backlog tear-off in the connection. NOTE that bls may @@ -143,7 +143,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg) */ conn->backlog = bls; - uip_unlock(flags); + net_unlock(flags); return OK; } diff --git a/nuttx/net/tcp/tcp_conn.c b/nuttx/net/tcp/tcp_conn.c index f4f20f714..f664776ad 100644 --- a/nuttx/net/tcp/tcp_conn.c +++ b/nuttx/net/tcp/tcp_conn.c @@ -206,14 +206,14 @@ void tcp_initialize(void) FAR struct tcp_conn_s *tcp_alloc(void) { FAR struct tcp_conn_s *conn; - uip_lock_t flags; + net_lock_t flags; /* Because this routine is called from both interrupt level and * and from user level, we have not option but to disable interrupts * while accessing g_free_tcp_connections[]; */ - flags = uip_lock(); + flags = net_lock(); /* Return the entry from the head of the free list */ @@ -292,7 +292,7 @@ FAR struct tcp_conn_s *tcp_alloc(void) } #endif - uip_unlock(flags); + net_unlock(flags); /* Mark the connection allocated */ @@ -321,7 +321,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) #ifdef CONFIG_NET_TCP_WRITE_BUFFERS FAR struct tcp_wrbuffer_s *wrbuffer; #endif - uip_lock_t flags; + net_lock_t flags; /* Because g_free_tcp_connections is accessed from user level and interrupt * level, code, it is necessary to keep interrupts disabled during this @@ -329,7 +329,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) */ DEBUGASSERT(conn->crefs == 0); - flags = uip_lock(); + flags = net_lock(); /* Free remaining callbacks, actually there should be only the close callback * left. @@ -394,7 +394,7 @@ void tcp_free(FAR struct tcp_conn_s *conn) conn->tcpstateflags = UIP_CLOSED; dq_addlast(&conn->node, &g_free_tcp_connections); - uip_unlock(flags); + net_unlock(flags); } /**************************************************************************** @@ -583,14 +583,14 @@ int tcp_bind(FAR struct tcp_conn_s *conn, FAR const struct sockaddr_in *addr) #endif { - uip_lock_t flags; + net_lock_t flags; int port; /* Verify or select a local port */ - flags = uip_lock(); + flags = net_lock(); port = uip_selectport(ntohs(addr->sin_port)); - uip_unlock(flags); + net_unlock(flags); if (port < 0) { @@ -643,7 +643,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr_in *addr) #endif { - uip_lock_t flags; + net_lock_t flags; int port; /* The connection is expected to be in the UIP_ALLOCATED state.. i.e., @@ -660,9 +660,9 @@ int tcp_connect(FAR struct tcp_conn_s *conn, * one now. */ - flags = uip_lock(); + flags = net_lock(); port = uip_selectport(ntohs(conn->lport)); - uip_unlock(flags); + net_unlock(flags); if (port < 0) { @@ -715,9 +715,9 @@ int tcp_connect(FAR struct tcp_conn_s *conn, * this operation. */ - flags = uip_lock(); + flags = net_lock(); dq_addlast(&conn->node, &g_active_tcp_connections); - uip_unlock(flags); + net_unlock(flags); return OK; } diff --git a/nuttx/net/tcp/tcp_listen.c b/nuttx/net/tcp/tcp_listen.c index 278ce2bcb..1b48dc2ee 100644 --- a/nuttx/net/tcp/tcp_listen.c +++ b/nuttx/net/tcp/tcp_listen.c @@ -141,11 +141,11 @@ void tcp_listeninit(void) int tcp_unlisten(FAR struct tcp_conn_s *conn) { - uip_lock_t flags; + net_lock_t flags; int ndx; int ret = -EINVAL; - flags = uip_lock(); + flags = net_lock(); for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++) { if (tcp_listenports[ndx] == conn) @@ -156,7 +156,7 @@ int tcp_unlisten(FAR struct tcp_conn_s *conn) } } - uip_unlock(flags); + net_unlock(flags); return ret; } @@ -173,7 +173,7 @@ int tcp_unlisten(FAR struct tcp_conn_s *conn) int tcp_listen(FAR struct tcp_conn_s *conn) { - uip_lock_t flags; + net_lock_t flags; int ndx; int ret; @@ -181,7 +181,7 @@ int tcp_listen(FAR struct tcp_conn_s *conn) * is accessed from interrupt level as well. */ - flags = uip_lock(); + flags = net_lock(); /* First, check if there is already a socket listening on this port */ @@ -216,7 +216,7 @@ int tcp_listen(FAR struct tcp_conn_s *conn) } } - uip_unlock(flags); + net_unlock(flags); return ret; } diff --git a/nuttx/net/tcp/tcp_send_buffered.c b/nuttx/net/tcp/tcp_send_buffered.c index 21e5d635b..bf4c3ec6a 100644 --- a/nuttx/net/tcp/tcp_send_buffered.c +++ b/nuttx/net/tcp/tcp_send_buffered.c @@ -719,7 +719,7 @@ static uint16_t psock_send_interrupt(FAR struct uip_driver_s *dev, ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, size_t len) { - uip_lock_t save; + net_lock_t save; ssize_t result = 0; int err; int ret = OK; @@ -744,7 +744,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND); - save = uip_lock(); + save = net_lock(); if (len > 0) { @@ -817,7 +817,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, } } - uip_unlock(save); + net_unlock(save); /* Set the socket state to idle */ @@ -833,8 +833,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, goto errout; } - /* If uip_lockedwait failed, then we were probably reawakened by a signal. - * In this case, uip_lockedwait will have set errno appropriately. + /* If net_lockedwait failed, then we were probably reawakened by a signal. + * In this case, net_lockedwait will have set errno appropriately. */ if (ret < 0) diff --git a/nuttx/net/tcp/tcp_send_unbuffered.c b/nuttx/net/tcp/tcp_send_unbuffered.c index 97dea655b..a8ffaa0af 100644 --- a/nuttx/net/tcp/tcp_send_unbuffered.c +++ b/nuttx/net/tcp/tcp_send_unbuffered.c @@ -505,7 +505,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, size_t len) { struct send_s state; - uip_lock_t save; + net_lock_t save; int err; int ret = OK; @@ -536,7 +536,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, * are ready. */ - save = uip_lock(); + save = net_lock(); memset(&state, 0, sizeof(struct send_s)); (void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */ state.snd_sock = psock; /* Socket descriptor to use */ @@ -578,12 +578,12 @@ ssize_t psock_tcp_send(FAR struct socket *psock, netdev_txnotify(conn->ripaddr); /* Wait for the send to complete or an error to occur: NOTES: (1) - * uip_lockedwait will also terminate if a signal is received, (2) interrupts + * net_lockedwait will also terminate if a signal is received, (2) interrupts * may be disabled! They will be re-enabled while the task sleeps and * automatically re-enabled when the task restarts. */ - ret = uip_lockedwait(&state.snd_sem); + ret = net_lockedwait(&state.snd_sem); /* Make sure that no further interrupts are processed */ @@ -592,7 +592,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, } sem_destroy(&state.snd_sem); - uip_unlock(save); + net_unlock(save); /* Set the socket state to idle */ @@ -608,8 +608,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, goto errout; } - /* If uip_lockedwait failed, then we were probably reawakened by a signal. In - * this case, uip_lockedwait will have set errno appropriately. + /* If net_lockedwait failed, then we were probably reawakened by a signal. In + * this case, net_lockedwait will have set errno appropriately. */ if (ret < 0) diff --git a/nuttx/net/udp/udp_conn.c b/nuttx/net/udp/udp_conn.c index f95e86165..51fb7dd8a 100644 --- a/nuttx/net/udp/udp_conn.c +++ b/nuttx/net/udp/udp_conn.c @@ -101,7 +101,7 @@ static inline void _uip_semtake(FAR sem_t *sem) { /* Take the semaphore (perhaps waiting) */ - while (uip_lockedwait(sem) != 0) + while (net_lockedwait(sem) != 0) { /* The only case that an error should occur here is if * the wait was awakened by a signal. @@ -167,7 +167,7 @@ static uint16_t uip_selectport(void) * listen port number that is not being used by any other connection. */ - uip_lock_t flags = uip_lock(); + net_lock_t flags = net_lock(); do { /* Guess that the next available port number will be the one after @@ -190,7 +190,7 @@ static uint16_t uip_selectport(void) */ portno = g_last_udp_port; - uip_unlock(flags); + net_unlock(flags); return portno; } @@ -383,7 +383,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr) #endif { int ret = -EADDRINUSE; - uip_lock_t flags; + net_lock_t flags; /* Is the user requesting to bind to any port? */ @@ -398,7 +398,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr) { /* Interrupts must be disabled while access the UDP connection list */ - flags = uip_lock(); + flags = net_lock(); /* Is any other UDP connection bound to this port? */ @@ -410,7 +410,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr) ret = OK; } - uip_unlock(flags); + net_unlock(flags); } return ret; diff --git a/nuttx/net/uip/Make.defs b/nuttx/net/uip/Make.defs index c80ed64b6..d759a9f00 100644 --- a/nuttx/net/uip/Make.defs +++ b/nuttx/net/uip/Make.defs @@ -52,12 +52,6 @@ ifeq ($(CONFIG_NET_PKT),y) NET_CSRCS += uip_pktsend.c endif -# Non-interrupt level support required? - -ifeq ($(CONFIG_NET_NOINTS),y) -NET_CSRCS += uip_lock.c -endif - # IPv6-specific logic ifeq ($(CONFIG_NET_IPv6),y) diff --git a/nuttx/net/uip/uip_callback.c b/nuttx/net/uip/uip_callback.c index a40dc1d8a..e036dc562 100644 --- a/nuttx/net/uip/uip_callback.c +++ b/nuttx/net/uip/uip_callback.c @@ -104,11 +104,11 @@ void uip_callbackinit(void) FAR struct uip_callback_s *uip_callbackalloc(FAR struct uip_callback_s **list) { struct uip_callback_s *ret; - uip_lock_t save; + net_lock_t save; /* Check the head of the free list */ - save = uip_lock(); + save = net_lock(); ret = g_cbfreelist; if (ret) { @@ -136,7 +136,7 @@ FAR struct uip_callback_s *uip_callbackalloc(FAR struct uip_callback_s **list) } #endif - uip_unlock(save); + net_unlock(save); return ret; } @@ -158,11 +158,11 @@ void uip_callbackfree(FAR struct uip_callback_s *cb, { FAR struct uip_callback_s *prev; FAR struct uip_callback_s *curr; - uip_lock_t save; + net_lock_t save; if (cb) { - save = uip_lock(); + save = net_lock(); #ifdef CONFIG_DEBUG /* Check for double freed callbacks */ @@ -203,7 +203,7 @@ void uip_callbackfree(FAR struct uip_callback_s *cb, cb->flink = g_cbfreelist; g_cbfreelist = cb; - uip_unlock(save); + net_unlock(save); } } @@ -224,13 +224,13 @@ uint16_t uip_callbackexecute(FAR struct uip_driver_s *dev, void *pvconn, uint16_t flags, FAR struct uip_callback_s *list) { FAR struct uip_callback_s *next; - uip_lock_t save; + net_lock_t save; /* Loop for each callback in the list and while there are still events * set in the flags set. */ - save = uip_lock(); + save = net_lock(); while (list && flags) { /* Save the pointer to the next callback in the lists. This is done @@ -258,7 +258,7 @@ uint16_t uip_callbackexecute(FAR struct uip_driver_s *dev, void *pvconn, list = next; } - uip_unlock(save); + net_unlock(save); return flags; } diff --git a/nuttx/net/uip/uip_initialize.c b/nuttx/net/uip/uip_initialize.c index a4c21134a..e7e303f27 100644 --- a/nuttx/net/uip/uip_initialize.c +++ b/nuttx/net/uip/uip_initialize.c @@ -122,13 +122,13 @@ void uip_initialize(void) { /* Initialize the locking facility */ - uip_lockinit(); + net_lockinitialize(); /* Initialize callback support */ uip_callbackinit(); - /* Initialize packet socket suport */ + /* Initialize packet socket support */ #ifdef CONFIG_NET_PKT pkt_initialize(); diff --git a/nuttx/net/utils/Kconfig b/nuttx/net/utils/Kconfig new file mode 100644 index 000000000..ae2bf3130 --- /dev/null +++ b/nuttx/net/utils/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# diff --git a/nuttx/net/utils/Make.defs b/nuttx/net/utils/Make.defs new file mode 100644 index 000000000..5363cb02f --- /dev/null +++ b/nuttx/net/utils/Make.defs @@ -0,0 +1,52 @@ +############################################################################ +# net/utils/Make.defs +# +# Copyright (C) 2014 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. +# +############################################################################ + +ifeq ($(CONFIG_NET),y) + +NET_CSRCS += net_dsec2timeval.c + +# Non-interrupt level support required? + +ifeq ($(CONFIG_NET_NOINTS),y) +NET_CSRCS += net_lock.c +endif + +# Include utility build support + +DEPPATH += --dep-path utils +VPATH += :utils + +endif +endif diff --git a/nuttx/net/net_dsec2timeval.c b/nuttx/net/utils/net_dsec2timeval.c index cad43ae03..92b93cd42 100644 --- a/nuttx/net/net_dsec2timeval.c +++ b/nuttx/net/utils/net_dsec2timeval.c @@ -1,7 +1,7 @@ /**************************************************************************** - * net/net_dsec2timeval.c + * net/utils/net_dsec2timeval.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -38,7 +38,6 @@ ****************************************************************************/ #include <nuttx/config.h> -#if defined(CONFIG_NET) && defined(CONFIG_NET_SOCKOPTS) && !defined(CONFIG_DISABLE_CLOCK) #include <sys/socket.h> #include <stdint.h> @@ -48,7 +47,7 @@ #include "net.h" /**************************************************************************** - * Global Functions + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -69,12 +68,10 @@ * ****************************************************************************/ -void net_dsec2timeval(uint16_t dsec, struct timeval *tv) +void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv) { uint16_t remainder; tv->tv_sec = dsec / DSEC_PER_SEC; remainder = dsec - tv->tv_sec * DSEC_PER_SEC; tv->tv_usec = remainder * USEC_PER_DSEC; } - -#endif /* CONFIG_NET && CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */ diff --git a/nuttx/net/uip/uip_lock.c b/nuttx/net/utils/net_lock.c index 0bb17b941..8f200dd01 100644 --- a/nuttx/net/uip/uip_lock.c +++ b/nuttx/net/utils/net_lock.c @@ -1,7 +1,7 @@ /**************************************************************************** - * net/uip/uip_lock.c + * net/utils/net_lock.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -48,6 +48,8 @@ #include <nuttx/arch.h> #include <nuttx/net/uip.h> +#include "utils/utils.h" + #if defined(CONFIG_NET) && defined(CONFIG_NET_NOINTS) /**************************************************************************** @@ -93,27 +95,27 @@ static void uip_takesem(void) ****************************************************************************/ /**************************************************************************** - * Function: uip_lockinit + * Function: net_lockinitialize * * Description: * Initialize the locking facility * ****************************************************************************/ -void uip_lockinit(void) +void net_lockinitialize(void) { sem_init(&g_uipsem, 0, 1); } /**************************************************************************** - * Function: uip_lock + * Function: net_lock * * Description: * Take the lock * ****************************************************************************/ -uip_lock_t uip_lock(void) +net_lock_t net_lock(void) { pid_t me = getpid(); @@ -141,14 +143,14 @@ uip_lock_t uip_lock(void) } /**************************************************************************** - * Function: uip_unlock + * Function: net_unlock * * Description: * Release the lock. * ****************************************************************************/ -void uip_unlock(uip_lock_t flags) +void net_unlock(net_lock_t flags) { DEBUGASSERT(g_holder == getpid() && g_count > 0); @@ -171,14 +173,14 @@ void uip_unlock(uip_lock_t flags) } /**************************************************************************** - * Function: uip_lockedwait + * Function: net_lockedwait * * Description: * Atomically wait for sem while temporarily releasing g_uipsem. * ****************************************************************************/ -int uip_lockedwait(sem_t *sem) +int net_lockedwait(sem_t *sem) { pid_t me = getpid(); unsigned int count; diff --git a/nuttx/net/utils/utils.h b/nuttx/net/utils/utils.h new file mode 100644 index 000000000..98395315b --- /dev/null +++ b/nuttx/net/utils/utils.h @@ -0,0 +1,94 @@ +/**************************************************************************** + * net/utils/utils.h + * + * Copyright (C) 2014 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 __NET_UTILS_UTILS_H +#define __NET_UTILS_UTILS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Function: net_dsec2timeval + * + * Description: + * Convert a decisecond timeout value to a struct timeval. Needed by + * getsockopt() to report timeout values. + * + * Parameters: + * dsec The decisecond value to convert + * tv The struct timeval to receive the converted value + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv); + +#undef EXTERN +#ifdef __cplusplus +} +#endif + +#endif /* __NET_UTILS_UTILS_H */ |