mirror of
https://github.com/apache/nuttx.git
synced 2026-09-22 06:04:28 +08:00
Rename static functions from uip_* to something more appropriate. Globally scoped functions will take more work
This commit is contained in:
+28
-28
@@ -108,7 +108,7 @@
|
||||
/* Macros. */
|
||||
|
||||
#define BUF ((FAR struct net_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
|
||||
#define FBUF ((FAR struct net_iphdr_s *)&uip_reassbuf[0])
|
||||
#define FBUF ((FAR struct net_iphdr_s *)&g_reassembly_buffer[0])
|
||||
|
||||
/* IP fragment re-assembly */
|
||||
|
||||
@@ -125,11 +125,11 @@
|
||||
****************************************************************************/
|
||||
|
||||
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
|
||||
static uint8_t uip_reassbuf[UIP_REASS_BUFSIZE];
|
||||
static uint8_t uip_reassbitmap[UIP_REASS_BUFSIZE / (8 * 8)];
|
||||
static const uint8_t bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
static uint16_t uip_reasslen;
|
||||
static uint8_t uip_reassflags;
|
||||
static uint8_t g_reassembly_buffer[UIP_REASS_BUFSIZE];
|
||||
static uint8_t g_reassembly_bitmap[UIP_REASS_BUFSIZE / (8 * 8)];
|
||||
static const uint8_t g_bitmap_bits[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
|
||||
static uint16_t g_reassembly_len;
|
||||
static uint8_t g_reassembly_flags;
|
||||
#endif /* UIP_REASSEMBLY */
|
||||
|
||||
/****************************************************************************
|
||||
@@ -137,7 +137,7 @@ static uint8_t uip_reassflags;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_reass
|
||||
* Function: devif_reassembly
|
||||
*
|
||||
* Description:
|
||||
* IP fragment reassembly: not well-tested.
|
||||
@@ -147,7 +147,7 @@ static uint8_t uip_reassflags;
|
||||
****************************************************************************/
|
||||
|
||||
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
|
||||
static uint8_t uip_reass(void)
|
||||
static uint8_t devif_reassembly(void)
|
||||
{
|
||||
FAR struct net_iphdr_s *pbuf = BUF;
|
||||
FAR struct net_iphdr_s *pfbuf = FBUF;
|
||||
@@ -162,13 +162,13 @@ static uint8_t uip_reass(void)
|
||||
|
||||
if (!g_reassembly_timer)
|
||||
{
|
||||
memcpy(uip_reassbuf, &pbuf->vhl, UIP_IPH_LEN);
|
||||
memcpy(g_reassembly_buffer, &pbuf->vhl, UIP_IPH_LEN);
|
||||
g_reassembly_timer = UIP_REASS_MAXAGE;
|
||||
uip_reassflags = 0;
|
||||
g_reassembly_flags = 0;
|
||||
|
||||
/* Clear the bitmap. */
|
||||
|
||||
memset(uip_reassbitmap, 0, sizeof(uip_reassbitmap));
|
||||
memset(g_reassembly_bitmap, 0, sizeof(g_reassembly_bitmap));
|
||||
}
|
||||
|
||||
/* Check if the incoming fragment matches the one currently present
|
||||
@@ -195,7 +195,7 @@ static uint8_t uip_reass(void)
|
||||
|
||||
/* Copy the fragment into the reassembly buffer, at the right offset. */
|
||||
|
||||
memcpy(&uip_reassbuf[UIP_IPH_LEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len);
|
||||
memcpy(&g_reassembly_buffer[UIP_IPH_LEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len);
|
||||
|
||||
/* Update the bitmap. */
|
||||
|
||||
@@ -203,8 +203,8 @@ static uint8_t uip_reass(void)
|
||||
{
|
||||
/* If the two endpoints are in the same byte, we only update that byte. */
|
||||
|
||||
uip_reassbitmap[offset / (8 * 8)] |=
|
||||
bitmap_bits[(offset / 8 ) & 7] & ~bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
g_reassembly_bitmap[offset / (8 * 8)] |=
|
||||
g_bitmap_bits[(offset / 8 ) & 7] & ~g_bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
|
||||
}
|
||||
else
|
||||
@@ -213,12 +213,12 @@ static uint8_t uip_reass(void)
|
||||
* in the endpoints and fill the stuff inbetween with 0xff.
|
||||
*/
|
||||
|
||||
uip_reassbitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8 ) & 7];
|
||||
g_reassembly_bitmap[offset / (8 * 8)] |= g_bitmap_bits[(offset / 8 ) & 7];
|
||||
for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i)
|
||||
{
|
||||
uip_reassbitmap[i] = 0xff;
|
||||
g_reassembly_bitmap[i] = 0xff;
|
||||
}
|
||||
uip_reassbitmap[(offset + len) / (8 * 8)] |= ~bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
g_reassembly_bitmap[(offset + len) / (8 * 8)] |= ~g_bitmap_bits[((offset + len) / 8 ) & 7];
|
||||
}
|
||||
|
||||
/* If this fragment has the More Fragments flag set to zero, we know that
|
||||
@@ -229,8 +229,8 @@ static uint8_t uip_reass(void)
|
||||
|
||||
if ((pbuf->ipoffset[0] & IP_MF) == 0)
|
||||
{
|
||||
uip_reassflags |= UIP_REASS_FLAG_LASTFRAG;
|
||||
uip_reasslen = offset + len;
|
||||
g_reassembly_flags |= UIP_REASS_FLAG_LASTFRAG;
|
||||
g_reassembly_len = offset + len;
|
||||
}
|
||||
|
||||
/* Finally, we check if we have a full packet in the buffer. We do this
|
||||
@@ -238,15 +238,15 @@ static uint8_t uip_reass(void)
|
||||
* are set.
|
||||
*/
|
||||
|
||||
if (uip_reassflags & UIP_REASS_FLAG_LASTFRAG)
|
||||
if (g_reassembly_flags & UIP_REASS_FLAG_LASTFRAG)
|
||||
{
|
||||
/* Check all bytes up to and including all but the last byte in
|
||||
* the bitmap.
|
||||
*/
|
||||
|
||||
for (i = 0; i < uip_reasslen / (8 * 8) - 1; ++i)
|
||||
for (i = 0; i < g_reassembly_len / (8 * 8) - 1; ++i)
|
||||
{
|
||||
if (uip_reassbitmap[i] != 0xff)
|
||||
if (g_reassembly_bitmap[i] != 0xff)
|
||||
{
|
||||
goto nullreturn;
|
||||
}
|
||||
@@ -256,7 +256,7 @@ static uint8_t uip_reass(void)
|
||||
* right amount of bits.
|
||||
*/
|
||||
|
||||
if (uip_reassbitmap[uip_reasslen / (8 * 8)] != (uint8_t)~bitmap_bits[uip_reasslen / 8 & 7])
|
||||
if (g_reassembly_bitmap[g_reassembly_len / (8 * 8)] != (uint8_t)~g_bitmap_bits[g_reassembly_len / 8 & 7])
|
||||
{
|
||||
goto nullreturn;
|
||||
}
|
||||
@@ -267,19 +267,19 @@ static uint8_t uip_reass(void)
|
||||
*/
|
||||
|
||||
g_reassembly_timer = 0;
|
||||
memcpy(pbuf, pfbuf, uip_reasslen);
|
||||
memcpy(pbuf, pfbuf, g_reassembly_len);
|
||||
|
||||
/* Pretend to be a "normal" (i.e., not fragmented) IP packet from
|
||||
* now on.
|
||||
*/
|
||||
|
||||
pbuf->ipoffset[0] = pbuf->ipoffset[1] = 0;
|
||||
pbuf->len[0] = uip_reasslen >> 8;
|
||||
pbuf->len[1] = uip_reasslen & 0xff;
|
||||
pbuf->len[0] = g_reassembly_len >> 8;
|
||||
pbuf->len[1] = g_reassembly_len & 0xff;
|
||||
pbuf->ipchksum = 0;
|
||||
pbuf->ipchksum = ~(ip_chksum(dev));
|
||||
|
||||
return uip_reasslen;
|
||||
return g_reassembly_len;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ int uip_input(FAR struct net_driver_s *dev)
|
||||
if ((pbuf->ipoffset[0] & 0x3f) != 0 || pbuf->ipoffset[1] != 0)
|
||||
{
|
||||
#if UIP_REASSEMBLY
|
||||
dev->d_len = uip_reass();
|
||||
dev->d_len = devif_reassembly();
|
||||
if (dev->d_len == 0)
|
||||
{
|
||||
goto drop;
|
||||
|
||||
+30
-30
@@ -62,7 +62,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_pollpktconnections
|
||||
* Function: devif_poll_pkt_connections
|
||||
*
|
||||
* Description:
|
||||
* Poll all packet connections for available packets to send.
|
||||
@@ -74,8 +74,8 @@
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_PKT)
|
||||
static int uip_pollpktconnections(struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
static int devif_poll_pkt_connections(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
FAR struct pkt_conn_s *pkt_conn = NULL;
|
||||
int bstop = 0;
|
||||
@@ -98,7 +98,7 @@ static int uip_pollpktconnections(struct net_driver_s *dev,
|
||||
#endif /* CONFIG_NET_PKT */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_pollicmp
|
||||
* Function: devif_poll_icmp
|
||||
*
|
||||
* Description:
|
||||
* Poll all UDP connections for available packets to send.
|
||||
@@ -110,8 +110,8 @@ static int uip_pollpktconnections(struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
|
||||
static inline int uip_pollicmp(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
static inline int devif_poll_icmp(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
/* Perform the UDP TX poll */
|
||||
|
||||
@@ -124,7 +124,7 @@ static inline int uip_pollicmp(FAR struct net_driver_s *dev,
|
||||
#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_polligmp
|
||||
* Function: devif_poll_igmp
|
||||
*
|
||||
* Description:
|
||||
* Poll all IGMP connections for available packets to send.
|
||||
@@ -136,8 +136,8 @@ static inline int uip_pollicmp(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
static inline int uip_polligmp(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
static inline int devif_poll_igmp(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
/* Perform the IGMP TX poll */
|
||||
|
||||
@@ -150,7 +150,7 @@ static inline int uip_polligmp(FAR struct net_driver_s *dev,
|
||||
#endif /* CONFIG_NET_IGMP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_polludpconnections
|
||||
* Function: devif_poll_udp_connections
|
||||
*
|
||||
* Description:
|
||||
* Poll all UDP connections for available packets to send.
|
||||
@@ -162,8 +162,8 @@ static inline int uip_polligmp(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
static int uip_polludpconnections(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
static int devif_poll_udp_connections(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
FAR struct udp_conn_s *conn = NULL;
|
||||
int bstop = 0;
|
||||
@@ -186,7 +186,7 @@ static int uip_polludpconnections(FAR struct net_driver_s *dev,
|
||||
#endif /* CONFIG_NET_UDP */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_polltcpconnections
|
||||
* Function: devif_poll_tcp_connections
|
||||
*
|
||||
* Description:
|
||||
* Poll all UDP connections for available packets to send.
|
||||
@@ -198,8 +198,8 @@ static int uip_polludpconnections(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline int uip_polltcpconnections(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback)
|
||||
{
|
||||
FAR struct tcp_conn_s *conn = NULL;
|
||||
int bstop = 0;
|
||||
@@ -220,11 +220,11 @@ static inline int uip_polltcpconnections(FAR struct net_driver_s *dev,
|
||||
return bstop;
|
||||
}
|
||||
#else
|
||||
# define uip_polltcpconnections(dev, callback) (0)
|
||||
# define devif_poll_tcp_connections(dev, callback) (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_polltcptimer
|
||||
* Function: devif_poll_tcp_timer
|
||||
*
|
||||
* Description:
|
||||
* The TCP timer has expired. Update TCP timing state in each active,
|
||||
@@ -237,8 +237,8 @@ static inline int uip_polltcpconnections(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_TCP
|
||||
static inline int uip_polltcptimer(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback, int hsec)
|
||||
static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev,
|
||||
uip_poll_callback_t callback, int hsec)
|
||||
{
|
||||
FAR struct tcp_conn_s *conn = NULL;
|
||||
int bstop = 0;
|
||||
@@ -259,7 +259,7 @@ static inline int uip_polltcptimer(FAR struct net_driver_s *dev,
|
||||
return bstop;
|
||||
}
|
||||
#else
|
||||
# define uip_polltcptimer(dev, callback, hsec) (0)
|
||||
# define devif_poll_tcp_timer(dev, callback, hsec) (0)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -300,14 +300,14 @@ int uip_poll(FAR struct net_driver_s *dev, uip_poll_callback_t callback)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
bstop = uip_pollpktconnections(dev, callback);
|
||||
bstop = devif_poll_pkt_connections(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
/* Check for pendig IGMP messages */
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
bstop = uip_polligmp(dev, callback);
|
||||
bstop = devif_poll_igmp(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
@@ -315,7 +315,7 @@ int uip_poll(FAR struct net_driver_s *dev, uip_poll_callback_t callback)
|
||||
* action.
|
||||
*/
|
||||
|
||||
bstop = uip_polltcpconnections(dev, callback);
|
||||
bstop = devif_poll_tcp_connections(dev, callback);
|
||||
if (!bstop)
|
||||
{
|
||||
#ifdef CONFIG_NET_UDP
|
||||
@@ -323,7 +323,7 @@ int uip_poll(FAR struct net_driver_s *dev, uip_poll_callback_t callback)
|
||||
* the poll action
|
||||
*/
|
||||
|
||||
bstop = uip_polludpconnections(dev, callback);
|
||||
bstop = devif_poll_udp_connections(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
@@ -332,7 +332,7 @@ int uip_poll(FAR struct net_driver_s *dev, uip_poll_callback_t callback)
|
||||
* request.
|
||||
*/
|
||||
|
||||
bstop = uip_pollicmp(dev, callback);
|
||||
bstop = devif_poll_icmp(dev, callback);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -385,14 +385,14 @@ int uip_timer(FAR struct net_driver_s *dev, uip_poll_callback_t callback,
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
bstop = uip_pollpktconnections(dev, callback);
|
||||
bstop = devif_poll_pkt_connections(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
/* Check for pending IGMP messages */
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
bstop = uip_polligmp(dev, callback);
|
||||
bstop = devif_poll_igmp(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
@@ -400,7 +400,7 @@ int uip_timer(FAR struct net_driver_s *dev, uip_poll_callback_t callback,
|
||||
* timer action.
|
||||
*/
|
||||
|
||||
bstop = uip_polltcptimer(dev, callback, hsec);
|
||||
bstop = devif_poll_tcp_timer(dev, callback, hsec);
|
||||
if (!bstop)
|
||||
{
|
||||
/* Traverse all of the allocated UDP connections and perform
|
||||
@@ -408,7 +408,7 @@ int uip_timer(FAR struct net_driver_s *dev, uip_poll_callback_t callback,
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_UDP
|
||||
bstop = uip_polludpconnections(dev, callback);
|
||||
bstop = devif_poll_udp_connections(dev, callback);
|
||||
if (!bstop)
|
||||
#endif
|
||||
{
|
||||
@@ -417,7 +417,7 @@ int uip_timer(FAR struct net_driver_s *dev, uip_poll_callback_t callback,
|
||||
* request.
|
||||
*/
|
||||
|
||||
bstop = uip_pollicmp(dev, callback);
|
||||
bstop = devif_poll_icmp(dev, callback);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_mcastmac
|
||||
* Name: igmp_mcastmac
|
||||
*
|
||||
* Description:
|
||||
* Given an IP address (in network order), create a IGMP multicast MAC
|
||||
@@ -72,7 +72,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void uip_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
|
||||
static void igmp_mcastmac(uip_ipaddr_t *ip, FAR uint8_t *mac)
|
||||
{
|
||||
/* This mapping is from the IETF IN RFC 1700 */
|
||||
|
||||
@@ -106,7 +106,7 @@ void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR uip_ipaddr_t *ip)
|
||||
nvdbg("Adding: IP %08x\n", *ip);
|
||||
if (dev->d_addmac)
|
||||
{
|
||||
uip_mcastmac(ip, mcastmac);
|
||||
igmp_mcastmac(ip, mcastmac);
|
||||
dev->d_addmac(dev, mcastmac);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR uip_ipaddr_t *ip)
|
||||
nvdbg("Removing: IP %08x\n", *ip);
|
||||
if (dev->d_rmmac)
|
||||
{
|
||||
uip_mcastmac(ip, mcastmac);
|
||||
igmp_mcastmac(ip, mcastmac);
|
||||
dev->d_rmmac(dev, mcastmac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,10 +65,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_schedsend
|
||||
* Name: igmp_sched_send
|
||||
*
|
||||
* Description:
|
||||
* Construct the .
|
||||
* Construct and send the IGMP message.
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns a non-zero value if an IGMP message is sent.
|
||||
@@ -79,7 +79,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void uip_schedsend(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group)
|
||||
static inline void igmp_sched_send(FAR struct net_driver_s *dev,
|
||||
FAR struct igmp_group_s *group)
|
||||
{
|
||||
uip_ipaddr_t *dest;
|
||||
|
||||
@@ -168,7 +169,7 @@ void igmp_poll(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Yes, create the IGMP message in the driver buffer */
|
||||
|
||||
uip_schedsend(dev, group);
|
||||
igmp_sched_send(dev, group);
|
||||
|
||||
/* Mark the message as sent and break out */
|
||||
|
||||
|
||||
+7
-7
@@ -81,14 +81,14 @@ static dq_queue_t g_active_pkt_connections;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _uip_semtake() and _uip_semgive()
|
||||
* Name: _pkt_semtake() and _pkt_semgive()
|
||||
*
|
||||
* Description:
|
||||
* Take/give semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void _uip_semtake(sem_t *sem)
|
||||
static inline void _pkt_semtake(sem_t *sem)
|
||||
{
|
||||
/* Take the semaphore (perhaps waiting) */
|
||||
|
||||
@@ -102,7 +102,7 @@ static inline void _uip_semtake(sem_t *sem)
|
||||
}
|
||||
}
|
||||
|
||||
#define _uip_semgive(sem) sem_post(sem)
|
||||
#define _pkt_semgive(sem) sem_post(sem)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@@ -151,7 +151,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
|
||||
* is protected by a semaphore (that behaves like a mutex).
|
||||
*/
|
||||
|
||||
_uip_semtake(&g_free_sem);
|
||||
_pkt_semtake(&g_free_sem);
|
||||
conn = (FAR struct pkt_conn_s *)dq_remfirst(&g_free_pkt_connections);
|
||||
if (conn)
|
||||
{
|
||||
@@ -164,7 +164,7 @@ FAR struct pkt_conn_s *pkt_alloc(void)
|
||||
dq_addlast(&conn->node, &g_active_pkt_connections);
|
||||
}
|
||||
|
||||
_uip_semgive(&g_free_sem);
|
||||
_pkt_semgive(&g_free_sem);
|
||||
return conn;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
||||
|
||||
DEBUGASSERT(conn->crefs == 0);
|
||||
|
||||
_uip_semtake(&g_free_sem);
|
||||
_pkt_semtake(&g_free_sem);
|
||||
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
@@ -194,7 +194,7 @@ void pkt_free(FAR struct pkt_conn_s *conn)
|
||||
/* Free the connection */
|
||||
|
||||
dq_addlast(&conn->node, &g_free_pkt_connections);
|
||||
_uip_semgive(&g_free_sem);
|
||||
_pkt_semgive(&g_free_sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+4
-4
@@ -88,7 +88,7 @@ static uint16_t g_last_tcp_port;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_selectport()
|
||||
* Name: tcp_selectport()
|
||||
*
|
||||
* Description:
|
||||
* If the port number is zero; select an unused port for the connection.
|
||||
@@ -112,7 +112,7 @@ static uint16_t g_last_tcp_port;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int uip_selectport(uint16_t portno)
|
||||
static int tcp_selectport(uint16_t portno)
|
||||
{
|
||||
if (portno == 0)
|
||||
{
|
||||
@@ -589,7 +589,7 @@ int tcp_bind(FAR struct tcp_conn_s *conn,
|
||||
/* Verify or select a local port */
|
||||
|
||||
flags = net_lock();
|
||||
port = uip_selectport(ntohs(addr->sin_port));
|
||||
port = tcp_selectport(ntohs(addr->sin_port));
|
||||
net_unlock(flags);
|
||||
|
||||
if (port < 0)
|
||||
@@ -661,7 +661,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn,
|
||||
*/
|
||||
|
||||
flags = net_lock();
|
||||
port = uip_selectport(ntohs(conn->lport));
|
||||
port = tcp_selectport(ntohs(conn->lport));
|
||||
net_unlock(flags);
|
||||
|
||||
if (port < 0)
|
||||
|
||||
+15
-19
@@ -36,10 +36,6 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Compilation Switches
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
@@ -90,14 +86,14 @@ static uint16_t g_last_udp_port;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _uip_semtake() and _uip_semgive()
|
||||
* Name: _udp_semtake() and _udp_semgive()
|
||||
*
|
||||
* Description:
|
||||
* Take/give semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void _uip_semtake(FAR sem_t *sem)
|
||||
static inline void _udp_semtake(FAR sem_t *sem)
|
||||
{
|
||||
/* Take the semaphore (perhaps waiting) */
|
||||
|
||||
@@ -111,10 +107,10 @@ static inline void _uip_semtake(FAR sem_t *sem)
|
||||
}
|
||||
}
|
||||
|
||||
#define _uip_semgive(sem) sem_post(sem)
|
||||
#define _udp_semgive(sem) sem_post(sem)
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_find_conn()
|
||||
* Name: udp_find_conn()
|
||||
*
|
||||
* Description:
|
||||
* Find the UDP connection that uses this local port number. Called only
|
||||
@@ -122,7 +118,7 @@ static inline void _uip_semtake(FAR sem_t *sem)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR struct udp_conn_s *uip_find_conn(uint16_t portno)
|
||||
static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -140,7 +136,7 @@ static FAR struct udp_conn_s *uip_find_conn(uint16_t portno)
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: uip_selectport()
|
||||
* Name: udp_select_port()
|
||||
*
|
||||
* Description:
|
||||
* Select an unused port number.
|
||||
@@ -159,7 +155,7 @@ static FAR struct udp_conn_s *uip_find_conn(uint16_t portno)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t uip_selectport(void)
|
||||
static uint16_t udp_select_port(void)
|
||||
{
|
||||
uint16_t portno;
|
||||
|
||||
@@ -183,7 +179,7 @@ static uint16_t uip_selectport(void)
|
||||
g_last_udp_port = 4096;
|
||||
}
|
||||
}
|
||||
while (uip_find_conn(htons(g_last_udp_port)));
|
||||
while (udp_find_conn(htons(g_last_udp_port)));
|
||||
|
||||
/* Initialize and return the connection structure, bind it to the
|
||||
* port number
|
||||
@@ -245,7 +241,7 @@ FAR struct udp_conn_s *udp_alloc(void)
|
||||
* is protected by a semaphore (that behaves like a mutex).
|
||||
*/
|
||||
|
||||
_uip_semtake(&g_free_sem);
|
||||
_udp_semtake(&g_free_sem);
|
||||
conn = (FAR struct udp_conn_s *)dq_remfirst(&g_free_udp_connections);
|
||||
if (conn)
|
||||
{
|
||||
@@ -258,7 +254,7 @@ FAR struct udp_conn_s *udp_alloc(void)
|
||||
dq_addlast(&conn->node, &g_active_udp_connections);
|
||||
}
|
||||
|
||||
_uip_semgive(&g_free_sem);
|
||||
_udp_semgive(&g_free_sem);
|
||||
return conn;
|
||||
}
|
||||
|
||||
@@ -280,7 +276,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
||||
|
||||
DEBUGASSERT(conn->crefs == 0);
|
||||
|
||||
_uip_semtake(&g_free_sem);
|
||||
_udp_semtake(&g_free_sem);
|
||||
conn->lport = 0;
|
||||
|
||||
/* Remove the connection from the active list */
|
||||
@@ -290,7 +286,7 @@ void udp_free(FAR struct udp_conn_s *conn)
|
||||
/* Free the connection */
|
||||
|
||||
dq_addlast(&conn->node, &g_free_udp_connections);
|
||||
_uip_semgive(&g_free_sem);
|
||||
_udp_semgive(&g_free_sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -391,7 +387,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
|
||||
{
|
||||
/* Yes.. Find an unused local port number */
|
||||
|
||||
conn->lport = htons(uip_selectport());
|
||||
conn->lport = htons(udp_select_port());
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
@@ -402,7 +398,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
|
||||
|
||||
/* Is any other UDP connection bound to this port? */
|
||||
|
||||
if (!uip_find_conn(addr->sin_port))
|
||||
if (!udp_find_conn(addr->sin_port))
|
||||
{
|
||||
/* No.. then bind the socket to the port */
|
||||
|
||||
@@ -452,7 +448,7 @@ int udp_connect(FAR struct udp_conn_s *conn,
|
||||
* connection structure.
|
||||
*/
|
||||
|
||||
conn->lport = htons(uip_selectport());
|
||||
conn->lport = htons(udp_select_port());
|
||||
}
|
||||
|
||||
/* Is there a remote port (rport) */
|
||||
|
||||
@@ -71,14 +71,14 @@ static unsigned int g_count = 0;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: uip_takesem
|
||||
* Function: _net_takesem
|
||||
*
|
||||
* Description:
|
||||
* Take the semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void uip_takesem(void)
|
||||
static void _net_takesem(void)
|
||||
{
|
||||
while (sem_wait(&g_uipsem) != 0)
|
||||
{
|
||||
@@ -131,7 +131,7 @@ net_lock_t net_lock(void)
|
||||
{
|
||||
/* No.. take the semaphore (perhaps waiting) */
|
||||
|
||||
uip_takesem();
|
||||
_net_takesem();
|
||||
|
||||
/* Now this thread holds the semaphore */
|
||||
|
||||
@@ -204,7 +204,7 @@ int net_lockedwait(sem_t *sem)
|
||||
|
||||
/* Recover the uIP semaphore at the proper count */
|
||||
|
||||
uip_takesem();
|
||||
_net_takesem();
|
||||
g_holder = me;
|
||||
g_count = count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user