net/: More clean-up of spacing/alignment issues

This commit is contained in:
Gregory Nutt 2015-10-08 15:10:04 -06:00
parent 1e6ffe7677
commit 6209c51206
48 changed files with 311 additions and 278 deletions

View file

@ -805,7 +805,7 @@ static int tmpfs_open(FAR struct file *filep, FAR const char *relpath,
* access is ignored. * access is ignored.
*/ */
if ((oflags & (O_TRUNC|O_WRONLY)) == (O_TRUNC|O_WRONLY)) if ((oflags & (O_TRUNC | O_WRONLY)) == (O_TRUNC | O_WRONLY))
{ {
/* Truncate the file to zero length (if it is not already /* Truncate the file to zero length (if it is not already
* zero length) * zero length)

View file

@ -116,7 +116,7 @@ void arp_arpin(FAR struct net_driver_s *dev)
dev->d_len = 0; dev->d_len = 0;
ipaddr = net_ip4addr_conv32(arp->ah_dipaddr); ipaddr = net_ip4addr_conv32(arp->ah_dipaddr);
switch(arp->ah_opcode) switch (arp->ah_opcode)
{ {
case HTONS(ARP_REQUEST): case HTONS(ARP_REQUEST):
nllvdbg("ARP request for IP %04lx\n", (long)ipaddr); nllvdbg("ARP request for IP %04lx\n", (long)ipaddr);

View file

@ -86,7 +86,7 @@
void arp_dump(FAR struct arp_hdr_s *arp) void arp_dump(FAR struct arp_hdr_s *arp)
{ {
nlldbg(" HW type: %04x Protocol: %04x\n", nlldbg(" HW type: %04x Protocol: %04x\n",
arp->ah_hwtype, arp->ah_protocol);\ arp->ah_hwtype, arp->ah_protocol);
nlldbg(" HW len: %02x Proto len: %02x Operation: %04x\n", nlldbg(" HW len: %02x Proto len: %02x Operation: %04x\n",
arp->ah_hwlen, arp->ah_protolen, arp->ah_opcode); arp->ah_hwlen, arp->ah_protolen, arp->ah_opcode);
nlldbg(" Sender MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n", nlldbg(" Sender MAC: %02x:%02x:%02x:%02x:%02x:%02x IP: %d.%d.%d.%d\n",

View file

@ -73,8 +73,16 @@
/* Support for broadcast address */ /* Support for broadcast address */
static const struct ether_addr g_broadcast_ethaddr = static const struct ether_addr g_broadcast_ethaddr =
{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; {
static const uint16_t g_broadcast_ipaddr[2] = {0xffff, 0xffff}; {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
};
static const uint16_t g_broadcast_ipaddr[2] =
{
0xffff, 0xffff
};
/* Support for IGMP multicast addresses. /* Support for IGMP multicast addresses.
* *
@ -93,7 +101,10 @@ static const uint16_t g_broadcast_ipaddr[2] = {0xffff, 0xffff};
*/ */
#ifdef CONFIG_NET_IGMP #ifdef CONFIG_NET_IGMP
static const uint8_t g_multicast_ethaddr[3] = {0x01, 0x00, 0x5e}; static const uint8_t g_multicast_ethaddr[3] =
{
0x01, 0x00, 0x5e
};
#endif #endif
/**************************************************************************** /****************************************************************************
@ -186,7 +197,7 @@ void arp_out(FAR struct net_driver_s *dev)
* last three bytes of the IP address. * last three bytes of the IP address.
*/ */
FAR const uint8_t *ip = ((uint8_t*)pip->eh_destipaddr) + 1; FAR const uint8_t *ip = ((FAR uint8_t *)pip->eh_destipaddr) + 1;
memcpy(peth->dest, g_multicast_ethaddr, 3); memcpy(peth->dest, g_multicast_ethaddr, 3);
memcpy(&peth->dest[3], ip, 3); memcpy(&peth->dest[3], ip, 3);
} }

View file

@ -130,7 +130,9 @@ static uint8_t g_reassembly_buffer[TCP_REASS_BUFSIZE];
static uint8_t g_reassembly_bitmap[TCP_REASS_BUFSIZE / (8 * 8)]; static uint8_t g_reassembly_bitmap[TCP_REASS_BUFSIZE / (8 * 8)];
static const uint8_t g_bitmap_bits[8] = static const uint8_t g_bitmap_bits[8] =
{0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01}; {
0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01
};
static uint16_t g_reassembly_len; static uint16_t g_reassembly_len;
static uint8_t g_reassembly_flags; static uint8_t g_reassembly_flags;
@ -202,93 +204,97 @@ static uint8_t devif_reassembly(void)
memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len); memcpy(&g_reassembly_buffer[IPv4_HDRLEN + offset], (char *)pbuf + (int)((pbuf->vhl & 0x0f) * 4), len);
/* Update the bitmap. */ /* Update the bitmap. */
if (offset / (8 * 8) == (offset + len) / (8 * 8)) if (offset / (8 * 8) == (offset + len) / (8 * 8))
{ {
/* If the two endpoints are in the same byte, we only update that byte. */ /* If the two endpoints are in the same byte, we only update that byte. */
g_reassembly_bitmap[offset / (8 * 8)] |= g_reassembly_bitmap[offset / (8 * 8)] |=
g_bitmap_bits[(offset / 8 ) & 7] & ~g_bitmap_bits[((offset + len) / 8 ) & 7]; g_bitmap_bits[(offset / 8) & 7] &
~g_bitmap_bits[((offset + len) / 8) & 7];
} }
else else
{ {
/* If the two endpoints are in different bytes, we update the bytes /* If the two endpoints are in different bytes, we update the bytes
* in the endpoints and fill the stuff inbetween with 0xff. * in the endpoints and fill the stuff inbetween with 0xff.
*/ */
g_reassembly_bitmap[offset / (8 * 8)] |= g_bitmap_bits[(offset / 8 ) & 7]; g_reassembly_bitmap[offset / (8 * 8)] |=
for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) g_bitmap_bits[(offset / 8) & 7];
{
g_reassembly_bitmap[i] = 0xff;
}
g_reassembly_bitmap[(offset + len) / (8 * 8)] |= for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i)
~g_bitmap_bits[((offset + len) / 8 ) & 7]; {
} g_reassembly_bitmap[i] = 0xff;
}
/* If this fragment has the More Fragments flag set to zero, we know that g_reassembly_bitmap[(offset + len) / (8 * 8)] |=
* this is the last fragment, so we can calculate the size of the entire ~g_bitmap_bits[((offset + len) / 8) & 7];
* packet. We also set the IP_REASS_FLAG_LASTFRAG flag to indicate that }
* we have received the final fragment.
*/
if ((pbuf->ipoffset[0] & IP_MF) == 0) /* If this fragment has the More Fragments flag set to zero, we know that
{ * this is the last fragment, so we can calculate the size of the entire
g_reassembly_flags |= TCP_REASS_LASTFRAG; * packet. We also set the IP_REASS_FLAG_LASTFRAG flag to indicate that
g_reassembly_len = offset + len; * we have received the final fragment.
} */
/* Finally, we check if we have a full packet in the buffer. We do this if ((pbuf->ipoffset[0] & IP_MF) == 0)
* by checking if we have the last fragment and if all bits in the bitmap {
* are set. g_reassembly_flags |= TCP_REASS_LASTFRAG;
*/ g_reassembly_len = offset + len;
}
if (g_reassembly_flags & TCP_REASS_LASTFRAG) /* Finally, we check if we have a full packet in the buffer. We do this
{ * by checking if we have the last fragment and if all bits in the bitmap
/* Check all bytes up to and including all but the last byte in * are set.
* the bitmap. */
*/
for (i = 0; i < g_reassembly_len / (8 * 8) - 1; ++i) if (g_reassembly_flags & TCP_REASS_LASTFRAG)
{ {
if (g_reassembly_bitmap[i] != 0xff) /* Check all bytes up to and including all but the last byte in
{ * the bitmap.
goto nullreturn; */
}
}
/* Check the last byte in the bitmap. It should contain just the for (i = 0; i < g_reassembly_len / (8 * 8) - 1; ++i)
* right amount of bits. {
*/ if (g_reassembly_bitmap[i] != 0xff)
{
goto nullreturn;
}
}
if (g_reassembly_bitmap[g_reassembly_len / (8 * 8)] != (uint8_t)~g_bitmap_bits[g_reassembly_len / 8 & 7]) /* Check the last byte in the bitmap. It should contain just the
{ * right amount of bits.
goto nullreturn; */
}
/* If we have come this far, we have a full packet in the buffer, if (g_reassembly_bitmap[g_reassembly_len / (8 * 8)] !=
* so we allocate a pbuf and copy the packet into it. We also reset (uint8_t)~g_bitmap_bits[g_reassembly_len / 8 & 7])
* the timer. {
*/ goto nullreturn;
}
g_reassembly_timer = 0; /* If we have come this far, we have a full packet in the buffer,
memcpy(pbuf, pfbuf, g_reassembly_len); * so we allocate a pbuf and copy the packet into it. We also reset
* the timer.
*/
/* Pretend to be a "normal" (i.e., not fragmented) IP packet from g_reassembly_timer = 0;
* now on. memcpy(pbuf, pfbuf, g_reassembly_len);
*/
pbuf->ipoffset[0] = pbuf->ipoffset[1] = 0; /* Pretend to be a "normal" (i.e., not fragmented) IP packet from
pbuf->len[0] = g_reassembly_len >> 8; * now on.
pbuf->len[1] = g_reassembly_len & 0xff; */
pbuf->ipchksum = 0;
pbuf->ipchksum = ~(ipv4_chksum(dev));
return g_reassembly_len; pbuf->ipoffset[0] = pbuf->ipoffset[1] = 0;
} pbuf->len[0] = g_reassembly_len >> 8;
} pbuf->len[1] = g_reassembly_len & 0xff;
pbuf->ipchksum = 0;
pbuf->ipchksum = ~(ipv4_chksum(dev));
return g_reassembly_len;
}
}
nullreturn: nullreturn:
return 0; return 0;
@ -379,11 +385,11 @@ int ipv4_input(FAR struct net_driver_s *dev)
} }
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP) #if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
/* If IP broadcast support is configured, we check for a broadcast /* If IP broadcast support is configured, we check for a broadcast
* UDP packet, which may be destined to us (even if there is no IP * UDP packet, which may be destined to us (even if there is no IP
* address yet assigned to the device as is the case when we are * address yet assigned to the device as is the case when we are
* negotiating over DHCP for an address). * negotiating over DHCP for an address).
*/ */
if (pbuf->proto == IP_PROTO_UDP && if (pbuf->proto == IP_PROTO_UDP &&
net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr),

View file

@ -191,11 +191,11 @@ int ipv6_input(FAR struct net_driver_s *dev)
goto drop; goto drop;
} }
/* If IP broadcast support is configured, we check for a broadcast /* If IP broadcast support is configured, we check for a broadcast
* UDP packet, which may be destined to us (even if there is no IP * UDP packet, which may be destined to us (even if there is no IP
* address yet assigned to the device as is the case when we are * address yet assigned to the device as is the case when we are
* negotiating over DHCP for an address). * negotiating over DHCP for an address).
*/ */
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP) #if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
if (ipv6->proto == IP_PROTO_UDP && if (ipv6->proto == IP_PROTO_UDP &&

View file

@ -390,7 +390,7 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
if (state.png_cb) if (state.png_cb)
{ {
state.png_cb->flags = (ICMP_POLL | ICMP_ECHOREPLY | NETDEV_DOWN); state.png_cb->flags = (ICMP_POLL | ICMP_ECHOREPLY | NETDEV_DOWN);
state.png_cb->priv = (void*)&state; state.png_cb->priv = (FAR void *)&state;
state.png_cb->event = ping_interrupt; state.png_cb->event = ping_interrupt;
state.png_result = -EINTR; /* Assume sem-wait interrupted by signal */ state.png_result = -EINTR; /* Assume sem-wait interrupted by signal */

View file

@ -398,7 +398,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev)
*/ */
lladdr[0] = HTONS(0xfe80); /* 10-bit address + 6 zeroes */ lladdr[0] = HTONS(0xfe80); /* 10-bit address + 6 zeroes */
memset(&lladdr[1], 0, 4* sizeof(uint16_t)); /* 64 more zeroes */ memset(&lladdr[1], 0, 4 * sizeof(uint16_t)); /* 64 more zeroes */
memcpy(&lladdr[5], dev->d_mac.ether_addr_octet, memcpy(&lladdr[5], dev->d_mac.ether_addr_octet,
sizeof(struct ether_addr)); /* 48-bit Ethernet address */ sizeof(struct ether_addr)); /* 48-bit Ethernet address */
@ -546,9 +546,9 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev)
* first step. * first step.
*/ */
/* On success, the new address was already set (in icmpv_rnotify()). We /* On success, the new address was already set (in icmpv_rnotify()). We
* need only to bring the network back to the up state and return success. * need only to bring the network back to the up state and return success.
*/ */
netdev_ifup(dev); netdev_ifup(dev);
net_unlock(save); net_unlock(save);

View file

@ -197,9 +197,9 @@ int icmpv6_wait(FAR struct icmpv6_notify_s *notify,
abstime.tv_nsec -= 1000000000; abstime.tv_nsec -= 1000000000;
} }
/* REVISIT: If net_timedwait() is awakened with signal, we will return /* REVISIT: If net_timedwait() is awakened with signal, we will return
* the wrong error code. * the wrong error code.
*/ */
(void)net_timedwait(&notify->nt_sem, &abstime); (void)net_timedwait(&notify->nt_sem, &abstime);
ret = notify->nt_result; ret = notify->nt_result;

View file

@ -456,7 +456,7 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno,
if (state.png_cb) if (state.png_cb)
{ {
state.png_cb->flags = (ICMPv6_POLL | ICMPv6_ECHOREPLY); state.png_cb->flags = (ICMPv6_POLL | ICMPv6_ECHOREPLY);
state.png_cb->priv = (void*)&state; state.png_cb->priv = (FAR void *)&state;
state.png_cb->event = ping_interrupt; state.png_cb->event = ping_interrupt;
state.png_result = -EINTR; /* Assume sem-wait interrupted by signal */ state.png_result = -EINTR; /* Assume sem-wait interrupted by signal */

View file

@ -293,9 +293,9 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify,
abstime.tv_nsec -= 1000000000; abstime.tv_nsec -= 1000000000;
} }
/* REVISIT: If net_timedwait() is awakened with signal, we will return /* REVISIT: If net_timedwait() is awakened with signal, we will return
* the wrong error code. * the wrong error code.
*/ */
(void)net_timedwait(&notify->rn_sem, &abstime); (void)net_timedwait(&notify->rn_sem, &abstime);
ret = notify->rn_result; ret = notify->rn_result;

View file

@ -174,7 +174,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,
* the four low-order octets OR'ed with the MAC 33:33:00:00:00:00, * the four low-order octets OR'ed with the MAC 33:33:00:00:00:00,
* so for example the IPv6 address FF02:DEAD:BEEF::1:3 would map * so for example the IPv6 address FF02:DEAD:BEEF::1:3 would map
* to the Ethernet MAC address 33:33:00:01:00:03. * to the Ethernet MAC address 33:33:00:01:00:03.
* *
* NOTES: This appears correct for the ICMPv6 Router Solicitation * NOTES: This appears correct for the ICMPv6 Router Solicitation
* Message, but the ICMPv6 Neighbor Solicitation message seems to * Message, but the ICMPv6 Neighbor Solicitation message seems to
* use 33:33:ff:01:00:03. * use 33:33:ff:01:00:03.

View file

@ -265,7 +265,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
/* Add the group structure to the list in the device structure */ /* Add the group structure to the list in the device structure */
sq_addfirst((FAR sq_entry_t*)group, &dev->grplist); sq_addfirst((FAR sq_entry_t *)group, &dev->grplist);
net_unlock(flags); net_unlock(flags);
} }
@ -363,7 +363,7 @@ void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group)
/* Remove the group structure from the group list in the device structure */ /* Remove the group structure from the group list in the device structure */
sq_rem((FAR sq_entry_t*)group, &dev->grplist); sq_rem((FAR sq_entry_t *)group, &dev->grplist);
/* Destroy the wait semaphore */ /* Destroy the wait semaphore */
@ -381,7 +381,7 @@ void igmp_grpfree(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group)
if (IS_PREALLOCATED(group->flags)) if (IS_PREALLOCATED(group->flags))
{ {
grplldbg("Put back on free list\n"); grplldbg("Put back on free list\n");
sq_addlast((FAR sq_entry_t*)group, &g_freelist); sq_addlast((FAR sq_entry_t *)group, &g_freelist);
net_unlock(flags); net_unlock(flags);
} }
else else

View file

@ -134,14 +134,14 @@ void igmp_input(struct net_driver_s *dev)
/* Calculate and check the IGMP checksum */ /* Calculate and check the IGMP checksum */
if (net_chksum((uint16_t*)&IGMPBUF->type, IGMP_HDRLEN) != 0) if (net_chksum((FAR uint16_t *)&IGMPBUF->type, IGMP_HDRLEN) != 0)
{ {
IGMP_STATINCR(g_netstats.igmp.chksum_errors); IGMP_STATINCR(g_netstats.igmp.chksum_errors);
nlldbg("Checksum error\n"); nlldbg("Checksum error\n");
return; return;
} }
/* Find the group (or create a new one) using the incoming IP address*/ /* Find the group (or create a new one) using the incoming IP address */
destipaddr = net_ip4addr_conv32(IGMPBUF->destipaddr); destipaddr = net_ip4addr_conv32(IGMPBUF->destipaddr);
group = igmp_grpallocfind(dev, &destipaddr); group = igmp_grpallocfind(dev, &destipaddr);

View file

@ -92,7 +92,7 @@
static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen) static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen)
{ {
uint16_t sum = net_chksum((FAR uint16_t*)buffer, buflen); uint16_t sum = net_chksum((FAR uint16_t *)buffer, buflen);
return sum ? sum : 0xffff; return sum ? sum : 0xffff;
} }

View file

@ -133,7 +133,7 @@ int psock_local_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
/* Loop as necessary if we have to wait for a connection */ /* Loop as necessary if we have to wait for a connection */
for (;;) for (; ; )
{ {
/* Are there pending connections. Remove the client from the /* Are there pending connections. Remove the client from the
* head of the waiting list. * head of the waiting list.

View file

@ -143,7 +143,7 @@ int inline local_stream_connect(FAR struct local_conn_s *client,
return -ECONNREFUSED; return -ECONNREFUSED;
} }
/* Increment the number of pending server connection s*/ /* Increment the number of pending server connection s */
server->u.server.lc_pending++; server->u.server.lc_pending++;
DEBUGASSERT(server->u.server.lc_pending != 0); DEBUGASSERT(server->u.server.lc_pending != 0);
@ -271,7 +271,7 @@ int psock_local_connect(FAR struct socket *psock,
/* Find the matching server connection */ /* Find the matching server connection */
state = net_lock(); state = net_lock();
for(conn = (FAR struct local_conn_s *)g_local_listeners.head; for (conn = (FAR struct local_conn_s *)g_local_listeners.head;
conn; conn;
conn = (FAR struct local_conn_s *)dq_next(&conn->lc_node)) conn = (FAR struct local_conn_s *)dq_next(&conn->lc_node))
{ {

View file

@ -94,7 +94,7 @@ static int psock_fifo_read(FAR struct socket *psock, FAR void *buf,
* eventually be reported as ENOTCONN. * eventually be reported as ENOTCONN.
*/ */
psock->s_flags &= ~(_SF_CONNECTED |_SF_CLOSED); psock->s_flags &= ~(_SF_CONNECTED | _SF_CLOSED);
conn->lc_state = LOCAL_STATE_DISCONNECTED; conn->lc_state = LOCAL_STATE_DISCONNECTED;
/* Did we receive any data? */ /* Did we receive any data? */
@ -351,7 +351,7 @@ psock_dgram_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
close(conn->lc_infd); close(conn->lc_infd);
conn->lc_infd = -1; conn->lc_infd = -1;
/* Release our reference to the half duplex FIFO*/ /* Release our reference to the half duplex FIFO */
(void)local_release_halfduplex(conn); (void)local_release_halfduplex(conn);
@ -375,7 +375,7 @@ errout_with_infd:
conn->lc_infd = -1; conn->lc_infd = -1;
errout_with_halfduplex: errout_with_halfduplex:
/* Release our reference to the half duplex FIFO*/ /* Release our reference to the half duplex FIFO */
(void)local_release_halfduplex(conn); (void)local_release_halfduplex(conn);
return ret; return ret;

View file

@ -168,7 +168,7 @@ ssize_t psock_local_sendto(FAR struct socket *psock, FAR const void *buf,
conn->lc_outfd = -1; conn->lc_outfd = -1;
errout_with_halfduplex: errout_with_halfduplex:
/* Release our reference to the half duplex FIFO*/ /* Release our reference to the half duplex FIFO */
(void)local_release_halfduplex(conn); (void)local_release_halfduplex(conn);
return nsent; return nsent;

View file

@ -67,7 +67,11 @@
/* Support for broadcast address */ /* Support for broadcast address */
static const struct ether_addr g_broadcast_ethaddr = static const struct ether_addr g_broadcast_ethaddr =
{{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; {
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
}
};
/* Support for IGMP multicast addresses. /* Support for IGMP multicast addresses.
* *
@ -86,7 +90,10 @@ static const struct ether_addr g_broadcast_ethaddr =
*/ */
#ifdef CONFIG_NET_IGMP #ifdef CONFIG_NET_IGMP
static const uint8_t g_multicast_ethaddr[3] = {0x01, 0x00, 0x5e}; static const uint8_t g_multicast_ethaddr[3] =
{
0x01, 0x00, 0x5e
};
#endif #endif
/**************************************************************************** /****************************************************************************

View file

@ -289,12 +289,12 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
*/ */
#ifndef CONFIG_NETDEV_MULTINIC #ifndef CONFIG_NETDEV_MULTINIC
/* If there is only a single, registered network interface, then the /* If there is only a single, registered network interface, then the
* decision is pretty easy. Use that device and its default router * decision is pretty easy. Use that device and its default router
* address. * address.
*/ */
dev = g_netdevices; dev = g_netdevices;
#endif #endif
/* If we will did not find the network device, then we might as well fail /* If we will did not find the network device, then we might as well fail
@ -407,12 +407,12 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
*/ */
#ifndef CONFIG_NETDEV_MULTINIC #ifndef CONFIG_NETDEV_MULTINIC
/* If there is only a single, registered network interface, then the /* If there is only a single, registered network interface, then the
* decision is pretty easy. Use that device and its default router * decision is pretty easy. Use that device and its default router
* address. * address.
*/ */
dev = g_netdevices; dev = g_netdevices;
#endif #endif
/* If we will did not find the network device, then we might as well fail /* If we will did not find the network device, then we might as well fail

View file

@ -713,7 +713,7 @@ static int netdev_ifrioctl(FAR struct socket *psock, int cmd,
{ {
ret = -ENOTTY; ret = -ENOTTY;
} }
break;; break;
} }
return ret; return ret;
@ -964,18 +964,18 @@ int netdev_ioctl(int sockfd, int cmd, unsigned long arg)
/* Execute the command */ /* Execute the command */
ret = netdev_ifrioctl(psock, cmd, (FAR struct ifreq*)((uintptr_t)arg)); ret = netdev_ifrioctl(psock, cmd, (FAR struct ifreq *)((uintptr_t)arg));
#ifdef CONFIG_NET_IGMP #ifdef CONFIG_NET_IGMP
if (ret == -ENOTTY) if (ret == -ENOTTY)
{ {
ret = netdev_imsfioctl(psock, cmd, (FAR struct ip_msfilter*)((uintptr_t)arg)); ret = netdev_imsfioctl(psock, cmd, (FAR struct ip_msfilter *)((uintptr_t)arg));
} }
#endif #endif
#ifdef CONFIG_NET_ROUTE #ifdef CONFIG_NET_ROUTE
if (ret == -ENOTTY) if (ret == -ENOTTY)
{ {
ret = netdev_rtioctl(psock, cmd, (FAR struct rtentry*)((uintptr_t)arg)); ret = netdev_rtioctl(psock, cmd, (FAR struct rtentry *)((uintptr_t)arg));
} }
#endif #endif

View file

@ -294,7 +294,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
} }
#endif #endif
snprintf(dev->d_ifname, IFNAMSIZ, devfmt, devnum ); snprintf(dev->d_ifname, IFNAMSIZ, devfmt, devnum);
/* Add the device to the list of known network devices */ /* Add the device to the list of known network devices */

View file

@ -114,7 +114,7 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
if (dev->d_sndlen > 0) if (dev->d_sndlen > 0)
{ {
// devif_pkt_send(dev, conn); //devif_pkt_send(dev, conn);
return; return;
} }
} }

View file

@ -266,7 +266,7 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
/* Set up the callback in the connection */ /* Set up the callback in the connection */
state.snd_cb->flags = PKT_POLL; state.snd_cb->flags = PKT_POLL;
state.snd_cb->priv = (void*)&state; state.snd_cb->priv = (FAR void *)&state;
state.snd_cb->event = psock_send_interrupt; state.snd_cb->event = psock_send_interrupt;
/* Notify the device driver that new TX data is available. */ /* Notify the device driver that new TX data is available. */

View file

@ -93,7 +93,7 @@ struct route_match_ipv6_s
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
static int net_match(FAR struct net_route_s *route, FAR void *arg) static int net_match(FAR struct net_route_s *route, FAR void *arg)
{ {
FAR struct route_match_s *match = ( FAR struct route_match_s *)arg; FAR struct route_match_s *match = (FAR struct route_match_s *)arg;
/* To match, the masked target address must be the same, and the masks /* To match, the masked target address must be the same, and the masks
* must be the same. * must be the same.
@ -133,7 +133,7 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
static int net_match_ipv6(FAR struct net_route_ipv6_s *route, FAR void *arg) static int net_match_ipv6(FAR struct net_route_ipv6_s *route, FAR void *arg)
{ {
FAR struct route_match_ipv6_s *match = ( FAR struct route_match_ipv6_s *)arg; FAR struct route_match_ipv6_s *match = (FAR struct route_match_ipv6_s *)arg;
/* To match, the masked target address must be the same, and the masks /* To match, the masked target address must be the same, and the masks
* must be the same. * must be the same.

View file

@ -60,7 +60,7 @@
struct route_ipv4_match_s struct route_ipv4_match_s
{ {
in_addr_t target; /* Target IPv4 address on an external network to match */ in_addr_t target; /* Target IPv4 address on an external network to match */
in_addr_t router; /* IPv4 address of the router on one of our networks*/ in_addr_t router; /* IPv4 address of the router on one of our networks */
}; };
#endif #endif
@ -68,7 +68,7 @@ struct route_ipv4_match_s
struct route_ipv6_match_s struct route_ipv6_match_s
{ {
net_ipv6addr_t target; /* Target IPv6 address on an external network to match */ net_ipv6addr_t target; /* Target IPv6 address on an external network to match */
net_ipv6addr_t router; /* IPv6 address of the router on one of our networks*/ net_ipv6addr_t router; /* IPv6 address of the router on one of our networks */
}; };
#endif #endif

View file

@ -60,7 +60,7 @@ struct route_ipv4_devmatch_s
{ {
FAR struct net_driver_s *dev; /* The route must use this device */ FAR struct net_driver_s *dev; /* The route must use this device */
in_addr_t target; /* Target IPv4 address on an external network to match */ in_addr_t target; /* Target IPv4 address on an external network to match */
in_addr_t router; /* IPv6 address of the router on one of our networks*/ in_addr_t router; /* IPv6 address of the router on one of our networks */
}; };
#endif #endif
@ -69,7 +69,7 @@ struct route_ipv6_devmatch_s
{ {
FAR struct net_driver_s *dev; /* The route must use this device */ FAR struct net_driver_s *dev; /* The route must use this device */
net_ipv6addr_t target; /* Target IPv4 address on an external network to match */ net_ipv6addr_t target; /* Target IPv4 address on an external network to match */
net_ipv6addr_t router; /* IPv6 address of the router on one of our networks*/ net_ipv6addr_t router; /* IPv6 address of the router on one of our networks */
}; };
#endif #endif

View file

@ -86,9 +86,15 @@ static int pkt_bind(FAR struct pkt_conn_s *conn,
{ {
int ifindex; int ifindex;
#if 0 #if 0
char hwaddr[6] = {0x00, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1}; /* our MAC for debugging */ char hwaddr[6] = /* our MAC for debugging */
{
0x00, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1
};
#endif #endif
char hwaddr[6] = {0x00, 0xe0, 0xde, 0xad, 0xbe, 0xef}; /* MAC from ifconfig */ char hwaddr[6] = /* MAC from ifconfig */
{
0x00, 0xe0, 0xde, 0xad, 0xbe, 0xef
};
/* Look at the addr and identify network interface */ /* Look at the addr and identify network interface */

View file

@ -121,7 +121,7 @@ static inline int psock_setup_callbacks(FAR struct socket *psock,
pstate->tc_cb->flags = (TCP_NEWDATA | TCP_CLOSE | TCP_ABORT | pstate->tc_cb->flags = (TCP_NEWDATA | TCP_CLOSE | TCP_ABORT |
TCP_TIMEDOUT | TCP_CONNECTED | NETDEV_DOWN); TCP_TIMEDOUT | TCP_CONNECTED | NETDEV_DOWN);
pstate->tc_cb->priv = (void*)pstate; pstate->tc_cb->priv = (FAR void *)pstate;
pstate->tc_cb->event = psock_connect_interrupt; pstate->tc_cb->event = psock_connect_interrupt;
ret = OK; ret = OK;
} }
@ -217,7 +217,7 @@ static uint16_t psock_connect_interrupt(FAR struct net_driver_s *dev,
else if ((flags & TCP_TIMEDOUT) != 0) else if ((flags & TCP_TIMEDOUT) != 0)
{ {
/* Indicate that the connection timedout?)*/ /* Indicate that the connection timedout?) */
pstate->tc_result = -ETIMEDOUT; pstate->tc_result = -ETIMEDOUT;
} }

View file

@ -228,14 +228,14 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
/* Check if enough space has been provided for the full address */ /* Check if enough space has been provided for the full address */
if (*addrlen < sizeof(struct sockaddr_in6)) if (*addrlen < sizeof(struct sockaddr_in6))
{ {
/* This function is supposed to return the partial address if /* This function is supposed to return the partial address if
* a smaller buffer has been provided. This support has not * a smaller buffer has been provided. This support has not
* been implemented. * been implemented.
*/ */
return -ENOSYS; return -ENOSYS;
} }
/* Set the port number */ /* Set the port number */

View file

@ -141,9 +141,9 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
* a macro will do. * a macro will do.
*/ */
optionset = psock->s_options; optionset = psock->s_options;
*(int*)value = _SO_GETOPT(optionset, option); *(FAR int *)value = _SO_GETOPT(optionset, option);
*value_len = sizeof(int); *value_len = sizeof(int);
} }
break; break;
@ -161,8 +161,8 @@ int psock_getsockopt(FAR struct socket *psock, int level, int option,
/* Return the socket type */ /* Return the socket type */
*(int*)value = psock->s_type; *(FAR int *)value = psock->s_type;
*value_len = sizeof(int); *value_len = sizeof(int);
} }
break; break;

View file

@ -117,17 +117,17 @@ static inline int close_timeout(FAR struct tcp_close_s *pstate)
if (pstate) if (pstate)
{ {
/* Yes Check for a timeout configured via setsockopts(SO_LINGER). /* Yes Check for a timeout configured via setsockopts(SO_LINGER).
* If none... we well let the send wait forever. * If none... we well let the send wait forever.
*/ */
psock = pstate->cl_psock; psock = pstate->cl_psock;
if (psock && psock->s_linger != 0) if (psock && psock->s_linger != 0)
{ {
/* Check if the configured timeout has elapsed */ /* Check if the configured timeout has elapsed */
return net_timeo(pstate->cl_start, psock->s_linger); return net_timeo(pstate->cl_start, psock->s_linger);
} }
} }
/* No timeout */ /* No timeout */
@ -179,7 +179,7 @@ static uint16_t netclose_interrupt(FAR struct net_driver_s *dev,
/* The disconnection is complete */ /* The disconnection is complete */
#ifdef CONFIG_NET_SOLINGER #ifdef CONFIG_NET_SOLINGER
/* pstate non-NULL means that we are performing a LINGERing close.*/ /* pstate non-NULL means that we are performing a LINGERing close. */
if (pstate) if (pstate)
{ {

View file

@ -117,7 +117,7 @@ static void connection_closed(FAR struct socket *psock, uint16_t flags)
* be reported as an ENOTCONN error. * be reported as an ENOTCONN error.
*/ */
psock->s_flags &= ~(_SF_CONNECTED |_SF_CLOSED); psock->s_flags &= ~(_SF_CONNECTED | _SF_CLOSED);
} }
} }
@ -262,7 +262,7 @@ int net_startmonitor(FAR struct socket *psock)
if (cb != NULL) if (cb != NULL)
{ {
cb->event = connection_event; cb->event = connection_event;
cb->priv = (void*)psock; cb->priv = (FAR void *)psock;
cb->flags = NETDEV_DOWN; cb->flags = NETDEV_DOWN;
} }
@ -270,7 +270,7 @@ int net_startmonitor(FAR struct socket *psock)
/* Set up to receive callbacks on connection-related events */ /* Set up to receive callbacks on connection-related events */
conn->connection_private = (void*)psock; conn->connection_private = (FAR void *)psock;
conn->connection_event = connection_event; conn->connection_event = connection_event;
net_unlock(save); net_unlock(save);

View file

@ -320,7 +320,7 @@ static inline bool sendfile_addrcheck(FAR struct tcp_conn_s *conn)
static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn, static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvconn,
FAR void *pvpriv, uint16_t flags) FAR void *pvpriv, uint16_t flags)
{ {
FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s*)pvconn; FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn;
FAR struct sendfile_s *pstate = (FAR struct sendfile_s *)pvpriv; FAR struct sendfile_s *pstate = (FAR struct sendfile_s *)pvpriv;
int ret; int ret;
@ -720,7 +720,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
/* Set up the ACK callback in the connection */ /* Set up the ACK callback in the connection */
state.snd_ackcb->flags = (TCP_ACKDATA | TCP_REXMIT | TCP_DISCONN_EVENTS); state.snd_ackcb->flags = (TCP_ACKDATA | TCP_REXMIT | TCP_DISCONN_EVENTS);
state.snd_ackcb->priv = (void*)&state; state.snd_ackcb->priv = (FAR void *)&state;
state.snd_ackcb->event = ack_interrupt; state.snd_ackcb->event = ack_interrupt;
/* Perform the TCP send operation */ /* Perform the TCP send operation */
@ -728,7 +728,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
do do
{ {
state.snd_datacb->flags = TCP_POLL; state.snd_datacb->flags = TCP_POLL;
state.snd_datacb->priv = (void*)&state; state.snd_datacb->priv = (FAR void *)&state;
state.snd_datacb->event = sendfile_interrupt; state.snd_datacb->event = sendfile_interrupt;
/* Notify the device driver of the availability of TX data */ /* Notify the device driver of the availability of TX data */

View file

@ -297,7 +297,7 @@ FAR struct socket *sockfd_socket(int sockfd)
FAR struct socketlist *list; FAR struct socketlist *list;
int ndx = sockfd - __SOCKFD_OFFSET; int ndx = sockfd - __SOCKFD_OFFSET;
if (ndx >=0 && ndx < CONFIG_NSOCKET_DESCRIPTORS) if (ndx >= 0 && ndx < CONFIG_NSOCKET_DESCRIPTORS)
{ {
list = sched_getsockets(); list = sched_getsockets();
if (list) if (list)

View file

@ -450,12 +450,12 @@ static inline void recvfrom_udpreadahead(struct recvfrom_s *pstate)
goto out; goto out;
} }
if ( 0 if (0
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
|| src_addr_size == sizeof(struct sockaddr_in6) || src_addr_size == sizeof(struct sockaddr_in6)
#endif #endif
#ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv4
|| src_addr_size == sizeof(struct sockaddr_in) || src_addr_size == sizeof(struct sockaddr_in)
#endif #endif
) )
{ {
@ -845,11 +845,11 @@ static uint16_t recvfrom_tcpinterrupt(FAR struct net_driver_s *dev,
} }
#ifdef CONFIG_NET_SOCKOPTS #ifdef CONFIG_NET_SOCKOPTS
/* Reset the timeout. We will want a short timeout to terminate /* Reset the timeout. We will want a short timeout to terminate
* the TCP receive. * the TCP receive.
*/ */
pstate->rf_starttime = clock_systimer(); pstate->rf_starttime = clock_systimer();
#endif #endif
} }
@ -1017,7 +1017,8 @@ static inline void recvfrom_udpsender(struct net_driver_s *dev, struct recvfrom_
if (infrom) if (infrom)
{ {
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
FAR struct udp_conn_s *conn = (FAR struct udp_conn_s*)pstate->rf_sock->s_conn; FAR struct udp_conn_s *conn =
(FAR struct udp_conn_s *)pstate->rf_sock->s_conn;
/* Hybrid dual-stack IPv6/IPv4 implementations recognize a special /* Hybrid dual-stack IPv6/IPv4 implementations recognize a special
* class of addresses, the IPv4-mapped IPv6 addresses. * class of addresses, the IPv4-mapped IPv6 addresses.
@ -1426,7 +1427,7 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
if (state.rf_cb) if (state.rf_cb)
{ {
state.rf_cb->flags = (PKT_NEWDATA | PKT_POLL); state.rf_cb->flags = (PKT_NEWDATA | PKT_POLL);
state.rf_cb->priv = (void*)&state; state.rf_cb->priv = (FAR void *)&state;
state.rf_cb->event = recvfrom_pktinterrupt; state.rf_cb->event = recvfrom_pktinterrupt;
/* Notify the device driver of the receive call */ /* Notify the device driver of the receive call */
@ -1567,7 +1568,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
/* Set up the callback in the connection */ /* Set up the callback in the connection */
state.rf_cb->flags = (UDP_NEWDATA | UDP_POLL | NETDEV_DOWN); state.rf_cb->flags = (UDP_NEWDATA | UDP_POLL | NETDEV_DOWN);
state.rf_cb->priv = (void*)&state; state.rf_cb->priv = (FAR void *)&state;
state.rf_cb->event = recvfrom_udp_interrupt; state.rf_cb->event = recvfrom_udp_interrupt;
/* Notify the device driver of the receive call */ /* Notify the device driver of the receive call */
@ -1749,7 +1750,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
if (state.rf_cb) if (state.rf_cb)
{ {
state.rf_cb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS); state.rf_cb->flags = (TCP_NEWDATA | TCP_POLL | TCP_DISCONN_EVENTS);
state.rf_cb->priv = (void*)&state; state.rf_cb->priv = (FAR void *)&state;
state.rf_cb->event = recvfrom_tcpinterrupt; state.rf_cb->event = recvfrom_tcpinterrupt;
/* Wait for either the receive to complete or for an error/timeout /* Wait for either the receive to complete or for an error/timeout

View file

@ -147,7 +147,7 @@ int psock_setsockopt(FAR struct socket *psock, int level, int option,
/* Get the value. Is the option being set or cleared? */ /* Get the value. Is the option being set or cleared? */
setting = *(int*)value; setting = *(FAR int *)value;
/* Disable interrupts so that there is no conflict with interrupt /* Disable interrupts so that there is no conflict with interrupt
* level access to options. * level access to options.

View file

@ -96,7 +96,7 @@ struct accept_s
* *
* Assumptions: * Assumptions:
* Running at the interrupt level * Running at the interrupt level
* *
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_TCP
@ -291,7 +291,7 @@ int psock_tcp_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
/* Set up the callback in the connection */ /* Set up the callback in the connection */
conn->accept_private = (void*)&state; conn->accept_private = (FAR void *)&state;
conn->accept = accept_interrupt; conn->accept = accept_interrupt;
/* Wait for the send to complete or an error to occur: NOTES: (1) /* Wait for the send to complete or an error to occur: NOTES: (1)

View file

@ -123,7 +123,7 @@ int tcp_backlogcreate(FAR struct tcp_conn_s *conn, int nblg)
/* Then add all of the pre-allocated containers to the free list */ /* Then add all of the pre-allocated containers to the free list */
blc = (FAR struct tcp_blcontainer_s*)(((FAR uint8_t*)bls) + offset); blc = (FAR struct tcp_blcontainer_s *)(((FAR uint8_t *)bls) + offset);
for (i = 0; i < nblg; i++) for (i = 0; i < nblg; i++)
{ {
sq_addfirst(&blc->bc_node, &bls->bl_free); sq_addfirst(&blc->bc_node, &bls->bl_free);
@ -189,7 +189,7 @@ int tcp_backlogdestroy(FAR struct tcp_conn_s *conn)
/* Handle any pending connections in the backlog */ /* Handle any pending connections in the backlog */
while ((blc = (FAR struct tcp_blcontainer_s*)sq_remfirst(&blg->bl_pending)) != NULL) while ((blc = (FAR struct tcp_blcontainer_s *)sq_remfirst(&blg->bl_pending)) != NULL)
{ {
blconn = blc->bc_conn; blconn = blc->bc_conn;
if (blconn) if (blconn)
@ -242,25 +242,26 @@ int tcp_backlogadd(FAR struct tcp_conn_s *conn, FAR struct tcp_conn_s *blconn)
bls = conn->backlog; bls = conn->backlog;
if (bls && blconn) if (bls && blconn)
{ {
/* Allocate a container for the connection from the free list */ /* Allocate a container for the connection from the free list */
blc = (FAR struct tcp_blcontainer_s *)sq_remfirst(&bls->bl_free); blc = (FAR struct tcp_blcontainer_s *)sq_remfirst(&bls->bl_free);
if (!blc) if (!blc)
{ {
nlldbg("Failed to allocate container\n"); nlldbg("Failed to allocate container\n");
ret = -ENOMEM; ret = -ENOMEM;
} }
else else
{ {
/* Save the connection reference in the container and put the /* Save the connection reference in the container and put the
* container at the end of the pending connection list (FIFO). * container at the end of the pending connection list (FIFO).
*/ */
blc->bc_conn = blconn; blc->bc_conn = blconn;
sq_addlast(&blc->bc_node, &bls->bl_pending); sq_addlast(&blc->bc_node, &bls->bl_pending);
ret = OK; ret = OK;
} }
} }
return ret; return ret;
} }
@ -311,21 +312,21 @@ FAR struct tcp_conn_s *tcp_backlogremove(FAR struct tcp_conn_s *conn)
bls = conn->backlog; bls = conn->backlog;
if (bls) if (bls)
{ {
/* Remove the a container at the head of the pending connection list /* Remove the a container at the head of the pending connection list
* (FIFO) * (FIFO)
*/ */
blc = (FAR struct tcp_blcontainer_s *)sq_remfirst(&bls->bl_pending); blc = (FAR struct tcp_blcontainer_s *)sq_remfirst(&bls->bl_pending);
if (blc) if (blc)
{ {
/* Extract the connection reference from the container and put /* Extract the connection reference from the container and put
* container in the free list * container in the free list
*/ */
blconn = blc->bc_conn; blconn = blc->bc_conn;
blc->bc_conn = NULL; blc->bc_conn = NULL;
sq_addlast(&blc->bc_node, &bls->bl_free); sq_addlast(&blc->bc_node, &bls->bl_free);
} }
} }
nllvdbg("conn=%p, returning %p\n", conn, blconn); nllvdbg("conn=%p, returning %p\n", conn, blconn);
@ -364,41 +365,41 @@ int tcp_backlogdelete(FAR struct tcp_conn_s *conn,
bls = conn->backlog; bls = conn->backlog;
if (bls) if (bls)
{ {
/* Find the container hold the connection */ /* Find the container hold the connection */
for (blc = (FAR struct tcp_blcontainer_s *)sq_peek(&bls->bl_pending), prev = NULL; for (blc = (FAR struct tcp_blcontainer_s *)sq_peek(&bls->bl_pending), prev = NULL;
blc; blc;
prev = blc, blc = (FAR struct tcp_blcontainer_s *)sq_next(&blc->bc_node)) prev = blc, blc = (FAR struct tcp_blcontainer_s *)sq_next(&blc->bc_node))
{ {
if (blc->bc_conn == blconn) if (blc->bc_conn == blconn)
{ {
if (prev) if (prev)
{ {
/* Remove the a container from the middle of the list of /* Remove the a container from the middle of the list of
* pending connections * pending connections
*/ */
(void)sq_remafter(&prev->bc_node, &bls->bl_pending); (void)sq_remafter(&prev->bc_node, &bls->bl_pending);
} }
else else
{ {
/* Remove the a container from the head of the list of /* Remove the a container from the head of the list of
* pending connections * pending connections
*/ */
(void)sq_remfirst(&bls->bl_pending); (void)sq_remfirst(&bls->bl_pending);
} }
/* Put container in the free list */ /* Put container in the free list */
blc->bc_conn = NULL; blc->bc_conn = NULL;
sq_addlast(&blc->bc_node, &bls->bl_free); sq_addlast(&blc->bc_node, &bls->bl_free);
return OK; return OK;
} }
} }
nlldbg("Failed to find pending connection\n"); nlldbg("Failed to find pending connection\n");
return -EINVAL; return -EINVAL;
} }
return OK; return OK;

View file

@ -228,7 +228,7 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen)
if ((tcp->tcpoffset & 0xf0) > 0x50) if ((tcp->tcpoffset & 0xf0) > 0x50)
{ {
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ;) for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
{ {
opt = dev->d_buf[hdrlen + i]; opt = dev->d_buf[hdrlen + i];
if (opt == TCP_OPT_END) if (opt == TCP_OPT_END)
@ -520,7 +520,7 @@ found:
if ((tcp->tcpoffset & 0xf0) > 0x50) if ((tcp->tcpoffset & 0xf0) > 0x50)
{ {
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ;) for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
{ {
opt = dev->d_buf[hdrlen + i]; opt = dev->d_buf[hdrlen + i];
if (opt == TCP_OPT_END) if (opt == TCP_OPT_END)
@ -682,7 +682,8 @@ found:
{ {
dev->d_urglen = 0; dev->d_urglen = 0;
#else /* CONFIG_NET_TCPURGDATA */ #else /* CONFIG_NET_TCPURGDATA */
dev->d_appdata = ((uint8_t*)dev->d_appdata) + ((tcp->urgp[0] << 8) | tcp->urgp[1]); dev->d_appdata = ((FAR uint8_t *)dev->d_appdata) + ((tcp->urgp[0] << 8) |
tcp->urgp[1]);
dev->d_len -= (tcp->urgp[0] << 8) | tcp->urgp[1]; dev->d_len -= (tcp->urgp[0] << 8) | tcp->urgp[1];
#endif /* CONFIG_NET_TCPURGDATA */ #endif /* CONFIG_NET_TCPURGDATA */
} }

View file

@ -131,13 +131,13 @@
static void psock_insert_segment(FAR struct tcp_wrbuffer_s *wrb, static void psock_insert_segment(FAR struct tcp_wrbuffer_s *wrb,
FAR sq_queue_t *q) FAR sq_queue_t *q)
{ {
sq_entry_t *entry = (sq_entry_t*)wrb; FAR sq_entry_t *entry = (FAR sq_entry_t *)wrb;
sq_entry_t *insert = NULL; FAR sq_entry_t *insert = NULL;
sq_entry_t *itr; FAR sq_entry_t *itr;
for (itr = sq_peek(q); itr; itr = sq_next(itr)) for (itr = sq_peek(q); itr; itr = sq_next(itr))
{ {
FAR struct tcp_wrbuffer_s *wrb0 = (FAR struct tcp_wrbuffer_s*)itr; FAR struct tcp_wrbuffer_s *wrb0 = (FAR struct tcp_wrbuffer_s *)itr;
if (WRB_SEQNO(wrb0) < WRB_SEQNO(wrb)) if (WRB_SEQNO(wrb0) < WRB_SEQNO(wrb))
{ {
insert = itr; insert = itr;
@ -403,7 +403,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
/* Check of some or all of this write buffer has been ACKed. */ /* Check of some or all of this write buffer has been ACKed. */
next = sq_next(entry); next = sq_next(entry);
wrb = (FAR struct tcp_wrbuffer_s*)entry; wrb = (FAR struct tcp_wrbuffer_s *)entry;
/* If the ACKed sequence number is greater than the start /* If the ACKed sequence number is greater than the start
* sequence number of the write buffer, then some or all of * sequence number of the write buffer, then some or all of
@ -469,7 +469,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
* before the entire write buffer has even been sent. * before the entire write buffer has even been sent.
*/ */
wrb = (FAR struct tcp_wrbuffer_s*)sq_peek(&conn->write_q); wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q);
if (wrb && WRB_SENT(wrb) > 0 && ackno > WRB_SEQNO(wrb)) if (wrb && WRB_SENT(wrb) > 0 && ackno > WRB_SEQNO(wrb))
{ {
uint32_t nacked; uint32_t nacked;
@ -597,7 +597,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
while ((entry = sq_remlast(&conn->unacked_q)) != NULL) while ((entry = sq_remlast(&conn->unacked_q)) != NULL)
{ {
wrb = (FAR struct tcp_wrbuffer_s*)entry; wrb = (FAR struct tcp_wrbuffer_s *)entry;
uint16_t sent; uint16_t sent;
/* Reset the number of bytes sent sent from the write buffer */ /* Reset the number of bytes sent sent from the write buffer */
@ -1036,7 +1036,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
psock->s_sndcb->flags = (TCP_ACKDATA | TCP_REXMIT | TCP_POLL | psock->s_sndcb->flags = (TCP_ACKDATA | TCP_REXMIT | TCP_POLL |
TCP_DISCONN_EVENTS); TCP_DISCONN_EVENTS);
psock->s_sndcb->priv = (void*)psock; psock->s_sndcb->priv = (FAR void *)psock;
psock->s_sndcb->event = psock_send_interrupt; psock->s_sndcb->event = psock_send_interrupt;
/* Initialize the write buffer */ /* Initialize the write buffer */

View file

@ -399,17 +399,17 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev,
goto end_wait; goto end_wait;
} }
/* Check if the outgoing packet is available (it may have been claimed /* Check if the outgoing packet is available (it may have been claimed
* by a sendto interrupt serving a different thread). * by a sendto interrupt serving a different thread).
*/ */
#if 0 /* We can't really support multiple senders on the same TCP socket */ #if 0 /* We can't really support multiple senders on the same TCP socket */
else if (dev->d_sndlen > 0) else if (dev->d_sndlen > 0)
{ {
/* Another thread has beat us sending data, wait for the next poll */ /* Another thread has beat us sending data, wait for the next poll */
return flags; return flags;
} }
#endif #endif
/* We get here if (1) not all of the data has been ACKed, (2) we have been /* We get here if (1) not all of the data has been ACKed, (2) we have been

View file

@ -174,7 +174,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con
* any failure to allocated, the entire I/O buffer chain will be discarded. * any failure to allocated, the entire I/O buffer chain will be discarded.
*/ */
ret = iob_trycopyin(iob, (FAR const uint8_t*)&src_addr_size, ret = iob_trycopyin(iob, (FAR const uint8_t *)&src_addr_size,
sizeof(uint8_t), 0, true); sizeof(uint8_t), 0, true);
if (ret < 0) if (ret < 0)
{ {
@ -187,7 +187,7 @@ static uint16_t udp_datahandler(FAR struct net_driver_s *dev, FAR struct udp_con
return 0; return 0;
} }
ret = iob_trycopyin(iob, (FAR const uint8_t*)src_addr, src_addr_size, ret = iob_trycopyin(iob, (FAR const uint8_t *)src_addr, src_addr_size,
sizeof(uint8_t), true); sizeof(uint8_t), true);
if (ret < 0) if (ret < 0)
{ {

View file

@ -141,7 +141,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
FAR struct udp_conn_s *conn; FAR struct udp_conn_s *conn;
int i; int i;
/* Now search each connection structure.*/ /* Now search each connection structure. */
for (i = 0; i < CONFIG_NET_UDP_CONNS; i++) for (i = 0; i < CONFIG_NET_UDP_CONNS; i++)
{ {

View file

@ -247,10 +247,10 @@ static uint16_t sendto_interrupt(FAR struct net_driver_s *dev, FAR void *conn,
else if (dev->d_sndlen > 0 || (flags & UDP_NEWDATA) != 0) else if (dev->d_sndlen > 0 || (flags & UDP_NEWDATA) != 0)
{ {
/* Another thread has beat us sending data or the buffer is busy, /* Another thread has beat us sending data or the buffer is busy,
* Check for a timeout. If not timed out, wait for the next * Check for a timeout. If not timed out, wait for the next
* polling cycle and check again. * polling cycle and check again.
*/ */
#ifdef CONFIG_NET_SENDTO_TIMEOUT #ifdef CONFIG_NET_SENDTO_TIMEOUT
if (send_timeout(pstate)) if (send_timeout(pstate))
@ -441,7 +441,7 @@ ssize_t psock_udp_sendto(FAR struct socket *psock, FAR const void *buf,
if (state.st_cb) if (state.st_cb)
{ {
state.st_cb->flags = (UDP_POLL | NETDEV_DOWN); state.st_cb->flags = (UDP_POLL | NETDEV_DOWN);
state.st_cb->priv = (void*)&state; state.st_cb->priv = (FAR void *)&state;
state.st_cb->event = sendto_interrupt; state.st_cb->event = sendto_interrupt;
/* Notify the device driver of the availability of TX data */ /* Notify the device driver of the availability of TX data */

View file

@ -122,7 +122,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (conn->domain == PF_INET || if (conn->domain == PF_INET ||
(conn->domain == PF_INET6 && (conn->domain == PF_INET6 &&
ip6_is_ipv4addr((FAR struct in6_addr*)conn->u.ipv6.raddr))) ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr)))
#endif #endif
{ {
/* Get pointers to the IPv4 header and the offset TCP header */ /* Get pointers to the IPv4 header and the offset TCP header */
@ -148,9 +148,9 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (conn->domain == PF_INET6 && if (conn->domain == PF_INET6 &&
ip6_is_ipv4addr((FAR struct in6_addr*)conn->u.ipv6.raddr)) ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr))
{ {
in_addr_t raddr = ip6_get_ipv4addr((FAR struct in6_addr*)conn->u.ipv6.raddr); in_addr_t raddr = ip6_get_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr);
net_ipv4addr_hdrcopy(ipv4->destipaddr, &raddr); net_ipv4addr_hdrcopy(ipv4->destipaddr, &raddr);
} }
else else
@ -242,7 +242,7 @@ void udp_send(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
if (conn->domain == PF_INET || if (conn->domain == PF_INET ||
(conn->domain == PF_INET6 && (conn->domain == PF_INET6 &&
ip6_is_ipv4addr((FAR struct in6_addr*)conn->u.ipv6.raddr))) ip6_is_ipv4addr((FAR struct in6_addr *)conn->u.ipv6.raddr)))
#endif #endif
{ {
udp->udpchksum = ~udp_ipv4_chksum(dev); udp->udpchksum = ~udp_ipv4_chksum(dev);

View file

@ -413,7 +413,7 @@ uint16_t udp_ipv6_chksum(FAR struct net_driver_s *dev)
uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len) uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len)
{ {
FAR struct icmp_iphdr_s *icmp = ICMPBUF; FAR struct icmp_iphdr_s *icmp = ICMPBUF;
return net_chksum((uint16_t*)&icmp->type, len); return net_chksum((FAR uint16_t *)&icmp->type, len);
} }
#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */ #endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */