mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
Move files to net/utils; make appropriate name changes, most for uip_lock to net_lock
This commit is contained in:
@@ -1543,14 +1543,14 @@ static void enc_pktif(FAR struct enc_driver_s *priv)
|
||||
static void enc_irqworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
uint8_t eir;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to both uIP and the SPI bus. */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
enc_lock(priv);
|
||||
|
||||
/* Disable further interrupts by clearing the global interrupt enable bit.
|
||||
@@ -1746,7 +1746,7 @@ static void enc_irqworker(FAR void *arg)
|
||||
/* Release lock on the SPI bus and uIP */
|
||||
|
||||
enc_unlock(priv);
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1808,7 +1808,7 @@ static int enc_interrupt(int irq, FAR void *context)
|
||||
static void enc_toworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
int ret;
|
||||
|
||||
nlldbg("Tx timeout\n");
|
||||
@@ -1816,7 +1816,7 @@ static void enc_toworker(FAR void *arg)
|
||||
|
||||
/* Get exclusive access to uIP */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
|
||||
/* Increment statistics and dump debug info */
|
||||
|
||||
@@ -1839,7 +1839,7 @@ static void enc_toworker(FAR void *arg)
|
||||
|
||||
/* Release lock on uIP */
|
||||
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1902,13 +1902,13 @@ static void enc_txtimeout(int argc, uint32_t arg, ...)
|
||||
static void enc_pollworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to both uIP and the SPI bus. */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
enc_lock(priv);
|
||||
|
||||
/* Verify that the hardware is ready to send another packet. The driver
|
||||
@@ -1930,7 +1930,7 @@ static void enc_pollworker(FAR void *arg)
|
||||
/* Release lock on the SPI bus and uIP */
|
||||
|
||||
enc_unlock(priv);
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
|
||||
/* Setup the watchdog poll timer again */
|
||||
|
||||
|
||||
@@ -1762,14 +1762,14 @@ static void enc_rxabtif(FAR struct enc_driver_s *priv)
|
||||
static void enc_irqworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
uint16_t eir;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to both uIP and the SPI bus. */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
enc_lock(priv);
|
||||
|
||||
/* A good practice is for the host controller to clear the Global Interrupt
|
||||
@@ -1915,7 +1915,7 @@ static void enc_irqworker(FAR void *arg)
|
||||
/* Release lock on the SPI bus and uIP */
|
||||
|
||||
enc_unlock(priv);
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1977,7 +1977,7 @@ static int enc_interrupt(int irq, FAR void *context)
|
||||
static void enc_toworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
int ret;
|
||||
|
||||
nlldbg("Tx timeout\n");
|
||||
@@ -1985,7 +1985,7 @@ static void enc_toworker(FAR void *arg)
|
||||
|
||||
/* Get exclusive access to uIP. */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
|
||||
/* Increment statistics and dump debug info */
|
||||
|
||||
@@ -2009,7 +2009,7 @@ static void enc_toworker(FAR void *arg)
|
||||
|
||||
/* Release uIP */
|
||||
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -2073,13 +2073,13 @@ static void enc_txtimeout(int argc, uint32_t arg, ...)
|
||||
static void enc_pollworker(FAR void *arg)
|
||||
{
|
||||
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)arg;
|
||||
uip_lock_t lock;
|
||||
net_lock_t lock;
|
||||
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to both uIP and the SPI bus. */
|
||||
|
||||
lock = uip_lock();
|
||||
lock = net_lock();
|
||||
enc_lock(priv);
|
||||
|
||||
/* Verify that the hardware is ready to send another packet. The driver
|
||||
@@ -2101,7 +2101,7 @@ static void enc_pollworker(FAR void *arg)
|
||||
/* Release lock on the SPI bus and uIP */
|
||||
|
||||
enc_unlock(priv);
|
||||
uip_unlock(lock);
|
||||
net_unlock(lock);
|
||||
|
||||
/* Setup the watchdog poll timer again */
|
||||
|
||||
|
||||
+6
-6
@@ -457,7 +457,7 @@ static void slip_txtask(int argc, char *argv[])
|
||||
{
|
||||
FAR struct slip_driver_s *priv;
|
||||
unsigned int index = *(argv[1]) - '0';
|
||||
uip_lock_t flags;
|
||||
net_lock_t flags;
|
||||
|
||||
ndbg("index: %d\n", index);
|
||||
DEBUGASSERT(index < CONFIG_SLIP_NINTERFACES);
|
||||
@@ -493,10 +493,10 @@ static void slip_txtask(int argc, char *argv[])
|
||||
* (above), it may be larger.
|
||||
*/
|
||||
|
||||
flags = uip_lock();
|
||||
flags = net_lock();
|
||||
priv->dev.d_buf = priv->txbuf;
|
||||
(void)uip_timer(&priv->dev, slip_uiptxpoll, SLIP_POLLHSEC);
|
||||
uip_unlock(flags);
|
||||
net_unlock(flags);
|
||||
slip_semgive(priv);
|
||||
}
|
||||
}
|
||||
@@ -646,7 +646,7 @@ static int slip_rxtask(int argc, char *argv[])
|
||||
{
|
||||
FAR struct slip_driver_s *priv;
|
||||
unsigned int index = *(argv[1]) - '0';
|
||||
uip_lock_t flags;
|
||||
net_lock_t flags;
|
||||
int ch;
|
||||
|
||||
ndbg("index: %d\n", index);
|
||||
@@ -717,7 +717,7 @@ static int slip_rxtask(int argc, char *argv[])
|
||||
priv->dev.d_buf = priv->rxbuf;
|
||||
priv->dev.d_len = priv->rxlen;
|
||||
|
||||
flags = uip_lock();
|
||||
flags = net_lock();
|
||||
uip_input(&priv->dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should
|
||||
@@ -729,7 +729,7 @@ static int slip_rxtask(int argc, char *argv[])
|
||||
{
|
||||
slip_transmit(priv);
|
||||
}
|
||||
uip_unlock(flags);
|
||||
net_unlock(flags);
|
||||
slip_semgive(priv);
|
||||
}
|
||||
else
|
||||
|
||||
+23
-23
@@ -5,7 +5,7 @@
|
||||
* are used by uIP programs as well as internal uIP structures and function
|
||||
* declarations.
|
||||
*
|
||||
* Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* This logic was leveraged from uIP which also has a BSD-style license:
|
||||
@@ -259,37 +259,37 @@ void uip_setipid(uint16_t id);
|
||||
|
||||
/* Semaphore based locking for non-interrupt based logic.
|
||||
*
|
||||
* uip_lock_t -- Not used. Only for compatibility
|
||||
* uip_lockinit() -- Initializes an underlying semaphore/mutex
|
||||
* uip_lock() -- Takes the semaphore(). Implements a re-entrant mutex.
|
||||
* uip_unlock() -- Gives the semaphore().
|
||||
* uip_lockedwait() -- Like pthread_cond_wait(); releases the semaphore
|
||||
* momemtarily to wait on another semaphore()
|
||||
* net_lock_t -- Not used. Only for compatibility
|
||||
* net_lockinitialize() -- Initializes an underlying semaphore/mutex
|
||||
* net_lock() -- Takes the semaphore(). Implements a re-entrant mutex.
|
||||
* net_unlock() -- Gives the semaphore().
|
||||
* net_lockedwait() -- Like pthread_cond_wait(); releases the semaphore
|
||||
* momemtarily to wait on another semaphore()
|
||||
*/
|
||||
|
||||
typedef uint8_t uip_lock_t; /* Not really used */
|
||||
typedef uint8_t net_lock_t; /* Not really used */
|
||||
|
||||
void uip_lockinit(void);
|
||||
uip_lock_t uip_lock(void);
|
||||
void uip_unlock(uip_lock_t flags);
|
||||
int uip_lockedwait(sem_t *sem);
|
||||
void net_lockinitialize(void);
|
||||
net_lock_t net_lock(void);
|
||||
void net_unlock(net_lock_t flags);
|
||||
int net_lockedwait(sem_t *sem);
|
||||
|
||||
#else
|
||||
|
||||
/* Enable/disable locking for interrupt based logic:
|
||||
*
|
||||
* uip_lock_t -- The processor specific representation of interrupt state.
|
||||
* uip_lockinit() -- (Does not exist).
|
||||
* uip_lock() -- Disables interrupts.
|
||||
* uip_unlock() -- Conditionally restores interrupts.
|
||||
* uip_lockedwait() -- Just wait for the semaphore.
|
||||
* net_lock_t -- The processor specific representation of interrupt state.
|
||||
* net_lockinitialize() -- (Does not exist).
|
||||
* net_lock() -- Disables interrupts.
|
||||
* net_unlock() -- Conditionally restores interrupts.
|
||||
* net_lockedwait() -- Just wait for the semaphore.
|
||||
*/
|
||||
|
||||
# define uip_lock_t irqstate_t
|
||||
# define uip_lockinit()
|
||||
# define uip_lock() irqsave()
|
||||
# define uip_unlock(f) irqrestore(f)
|
||||
# define uip_lockedwait(s) sem_wait(s)
|
||||
# define net_lock_t irqstate_t
|
||||
# define net_lockinitialize()
|
||||
# define net_lock() irqsave()
|
||||
# define net_unlock(f) irqrestore(f)
|
||||
# define net_lockedwait(s) sem_wait(s)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -448,7 +448,7 @@ int uip_lockedwait(sem_t *sem);
|
||||
((in_addr_t)(addr2) & (in_addr_t)(mask)))
|
||||
#else
|
||||
bool uip_ipaddr_maskcmp(uip_ipaddr_t addr1, uip_ipaddr_t addr2,
|
||||
uip_ipaddr_t mask);
|
||||
uip_ipaddr_t mask);
|
||||
#endif
|
||||
|
||||
/* Mask out the network part of an IP address.
|
||||
|
||||
@@ -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"
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
+8
-8
@@ -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);
|
||||
|
||||
+6
-6
@@ -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 */
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "net.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
|
||||
@@ -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.
|
||||
|
||||
+10
-10
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+9
-9
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ************************************************************/
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -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 */
|
||||
|
||||
+7
-7
@@ -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 */
|
||||
|
||||
|
||||
+4
-4
@@ -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:
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+3
-3
@@ -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)
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+7
-7
@@ -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)
|
||||
|
||||
+18
-18
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -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 */
|
||||
|
||||
+5
-5
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+6
-6
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
@@ -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
|
||||
@@ -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 */
|
||||
@@ -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;
|
||||
@@ -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 */
|
||||
Reference in New Issue
Block a user