net: fix nxstyle errors

fix errors reported by nxstyle

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea
2021-04-02 07:28:21 +02:00
committed by Xiang Xiao
parent b10c6d69c4
commit 8975a65197
6 changed files with 105 additions and 59 deletions
+75 -43
View File
@@ -233,7 +233,9 @@ static FAR struct sixlowpan_addrcontext_s *
#if CONFIG_NET_6LOWPAN_MAXADDRCONTEXT > 0 #if CONFIG_NET_6LOWPAN_MAXADDRCONTEXT > 0
int i; int i;
/* Remove code to avoid warnings and save flash if no address context is used */ /* Remove code to avoid warnings and save flash if no address context is
* used
*/
for (i = 0; i < CONFIG_NET_6LOWPAN_MAXADDRCONTEXT; i++) for (i = 0; i < CONFIG_NET_6LOWPAN_MAXADDRCONTEXT; i++)
{ {
@@ -241,7 +243,8 @@ static FAR struct sixlowpan_addrcontext_s *
net_ipv6addr_prefixcmp(&g_hc06_addrcontexts[i].prefix, ipaddr, 64)) net_ipv6addr_prefixcmp(&g_hc06_addrcontexts[i].prefix, ipaddr, 64))
{ {
ninfo("Context found for " ninfo("Context found for "
"ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x Context: %d\n", "ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x "
"Context: %d\n",
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]),
ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]), ntohs(ipaddr[3]), ntohs(ipaddr[4]), ntohs(ipaddr[5]),
ntohs(ipaddr[6]), ntohs(ipaddr[7]), ntohs(ipaddr[6]), ntohs(ipaddr[7]),
@@ -266,24 +269,26 @@ static FAR struct sixlowpan_addrcontext_s *
* prefpost takes a byte where the first nibble specify prefix count * prefpost takes a byte where the first nibble specify prefix count
* and the second postfix count (NOTE: 15/0xf ipaddr=16 bytes copy). * and the second postfix count (NOTE: 15/0xf ipaddr=16 bytes copy).
* *
* compress_tagaddr() accepts a remote, variable length, tagged MAC address; * compress_tagaddr() accepts a remote, variable length, tagged MAC
* address;
* compress_laddr() accepts a local, fixed length MAC address. * compress_laddr() accepts a local, fixed length MAC address.
* compress_ipaddr() is simply the common logic that does not depend on * compress_ipaddr() is simply the common logic that does not depend on
* the size of the MAC address. * the size of the MAC address.
* *
****************************************************************************/ ****************************************************************************/
static uint8_t compress_ipaddr(FAR const net_ipv6addr_t ipaddr, uint8_t bitpos) static uint8_t compress_ipaddr(FAR const net_ipv6addr_t ipaddr,
uint8_t bitpos)
{ {
if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr)) if (SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(ipaddr))
{ {
/* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */ /* Compress IID to 16 bits: xxxx:xxxx:xxxx:xxxx:0000:00ff:fe00:XXXX */
#ifdef CONFIG_ENDIAN_BIG #ifdef CONFIG_ENDIAN_BIG
*g_hc06ptr++ = ipaddr[7] >> 8; /* Preserve big-endian, network order */ *g_hc06ptr++ = ipaddr[7] >> 8; /* Preserve big-endian, network order */
*g_hc06ptr++ = ipaddr[7] & 0xff; *g_hc06ptr++ = ipaddr[7] & 0xff;
#else #else
*g_hc06ptr++ = ipaddr[7] & 0xff; /* Preserve big-endian, network order */ *g_hc06ptr++ = ipaddr[7] & 0xff; /* Preserve big-endian, network order */
*g_hc06ptr++ = ipaddr[7] >> 8; *g_hc06ptr++ = ipaddr[7] >> 8;
#endif #endif
@@ -319,8 +324,10 @@ static uint8_t compress_tagaddr(FAR const net_ipv6addr_t ipaddr,
#ifdef CONFIG_DEBUG_NET_INFO #ifdef CONFIG_DEBUG_NET_INFO
ninfo("Compressing bitpos=%u addrlen=%u\n", bitpos, macaddr->nv_addrlen); ninfo("Compressing bitpos=%u addrlen=%u\n", bitpos, macaddr->nv_addrlen);
ninfo(" ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", ninfo(" ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), ntohs(ipaddr[3]), ntohs(ipaddr[0]), ntohs(ipaddr[1]),
ntohs(ipaddr[4]), ntohs(ipaddr[5]), ntohs(ipaddr[6]), ntohs(ipaddr[7])); ntohs(ipaddr[2]), ntohs(ipaddr[3]),
ntohs(ipaddr[4]), ntohs(ipaddr[5]),
ntohs(ipaddr[6]), ntohs(ipaddr[7]));
switch (macaddr->nv_addrlen) switch (macaddr->nv_addrlen)
{ {
@@ -529,8 +536,8 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
srcptr += 2; srcptr += 2;
} }
/* If the IP is derived from a MAC address big enough to include the U/L bit, /* If the IP is derived from a MAC address big enough to include the
* invert it. * U/L bit, invert it.
*/ */
if (usemac && postcount == 8) if (usemac && postcount == 8)
@@ -552,10 +559,13 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
nwarn("WARNING: No IID based configuration\n"); nwarn("WARNING: No IID based configuration\n");
} }
ninfo("Uncompressing %d + %d ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", ninfo("Uncompressing %d + %d "
"ipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
prefcount, postcount, prefcount, postcount,
ntohs(ipaddr[0]), ntohs(ipaddr[1]), ntohs(ipaddr[2]), ntohs(ipaddr[3]), ntohs(ipaddr[0]), ntohs(ipaddr[1]),
ntohs(ipaddr[4]), ntohs(ipaddr[5]), ntohs(ipaddr[6]), ntohs(ipaddr[7])); ntohs(ipaddr[2]), ntohs(ipaddr[3]),
ntohs(ipaddr[4]), ntohs(ipaddr[5]),
ntohs(ipaddr[6]), ntohs(ipaddr[7]));
} }
/**************************************************************************** /****************************************************************************
@@ -566,12 +576,12 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr,
* Name: sixlowpan_hc06_initialize * Name: sixlowpan_hc06_initialize
* *
* Description: * Description:
* sixlowpan_hc06_initialize() is called during OS initialization at power-up * sixlowpan_hc06_initialize() is called during OS initialization at
* reset. It is called from the common sixlowpan_initialize() function. * power-up reset. It is called from the common sixlowpan_initialize()
* sixlowpan_hc06_initialize() configures HC06 networking data structures. * function. sixlowpan_hc06_initialize() configures HC06 networking data
* It is called prior to platform-specific driver initialization so that * structures. It is called prior to platform-specific driver
* the 6LoWPAN networking subsystem is prepared to deal with network * initialization so that the 6LoWPAN networking subsystem is prepared to
* driver initialization actions. * deal with network driver initialization actions.
* *
* Input Parameters: * Input Parameters:
* None * None
@@ -595,14 +605,22 @@ void sixlowpan_hc06_initialize(void)
g_hc06_addrcontexts[0].used = 1; g_hc06_addrcontexts[0].used = 1;
g_hc06_addrcontexts[0].number = 0; g_hc06_addrcontexts[0].number = 0;
g_hc06_addrcontexts[0].prefix[0] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_0; g_hc06_addrcontexts[0].prefix[0] =
g_hc06_addrcontexts[0].prefix[1] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_1; CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_0;
g_hc06_addrcontexts[0].prefix[2] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_2; g_hc06_addrcontexts[0].prefix[1] =
g_hc06_addrcontexts[0].prefix[3] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_3; CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_1;
g_hc06_addrcontexts[0].prefix[4] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_4; g_hc06_addrcontexts[0].prefix[2] =
g_hc06_addrcontexts[0].prefix[5] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_5; CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_2;
g_hc06_addrcontexts[0].prefix[6] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_6; g_hc06_addrcontexts[0].prefix[3] =
g_hc06_addrcontexts[0].prefix[7] = CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_7; CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_3;
g_hc06_addrcontexts[0].prefix[4] =
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_4;
g_hc06_addrcontexts[0].prefix[5] =
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_5;
g_hc06_addrcontexts[0].prefix[6] =
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_6;
g_hc06_addrcontexts[0].prefix[7] =
CONFIG_NET_6LOWPAN_MAXADDRCONTEXT_PREFIX_0_7;
#if CONFIG_NET_6LOWPAN_MAXADDRCONTEXT > 1 #if CONFIG_NET_6LOWPAN_MAXADDRCONTEXT > 1
for (i = 1; i < CONFIG_NET_6LOWPAN_MAXADDRCONTEXT; i++) for (i = 1; i < CONFIG_NET_6LOWPAN_MAXADDRCONTEXT; i++)
@@ -883,7 +901,8 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
{ {
/* Elide the prefix - indicate by CID and set address context + SAC */ /* Elide the prefix - indicate by CID and set address context + SAC */
ninfo("Compressing src with address context. Setting SAC. Context: %d\n", ninfo("Compressing src with address context."
" Setting SAC. Context: %d\n",
saddrcontext->number); saddrcontext->number);
iphc1 |= SIXLOWPAN_IPHC_SAC; iphc1 |= SIXLOWPAN_IPHC_SAC;
@@ -910,7 +929,8 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
{ {
/* Send the full source address ipaddr: SAC = 0, SAM = 00 */ /* Send the full source address ipaddr: SAC = 0, SAM = 00 */
ninfo("Uncompressable srcipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", ninfo("Uncompressable "
"srcipaddr=%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
ntohs(ipv6->srcipaddr[0]), ntohs(ipv6->srcipaddr[1]), ntohs(ipv6->srcipaddr[0]), ntohs(ipv6->srcipaddr[1]),
ntohs(ipv6->srcipaddr[2]), ntohs(ipv6->srcipaddr[3]), ntohs(ipv6->srcipaddr[2]), ntohs(ipv6->srcipaddr[3]),
ntohs(ipv6->srcipaddr[4]), ntohs(ipv6->srcipaddr[5]), ntohs(ipv6->srcipaddr[4]), ntohs(ipv6->srcipaddr[5]),
@@ -985,7 +1005,8 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
{ {
/* Elide the prefix */ /* Elide the prefix */
ninfo("Compressing dest with address context. Setting DAC. Context: %d\n", ninfo("Compressing dest with address context. "
"Setting DAC. Context: %d\n",
daddrcontext->number); daddrcontext->number);
iphc1 |= SIXLOWPAN_IPHC_DAC; iphc1 |= SIXLOWPAN_IPHC_DAC;
@@ -1044,8 +1065,10 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
ninfo("Remove 12b of both source & dest with prefix 0xf0b*\n"); ninfo("Remove 12b of both source & dest with prefix 0xf0b*\n");
*(g_hc06ptr + 1) = *(g_hc06ptr + 1) =
(uint8_t)((ntohs(udp->srcport) - SIXLOWPAN_UDP_4_BIT_PORT_MIN) << 4) + (uint8_t)((ntohs(udp->srcport) -
(uint8_t)((ntohs(udp->destport) - SIXLOWPAN_UDP_4_BIT_PORT_MIN)); SIXLOWPAN_UDP_4_BIT_PORT_MIN) << 4) +
(uint8_t)((ntohs(udp->destport) -
SIXLOWPAN_UDP_4_BIT_PORT_MIN));
g_hc06ptr += 2; g_hc06ptr += 2;
} }
@@ -1067,12 +1090,14 @@ int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
else if ((ntohs(udp->srcport) & 0xff00) == else if ((ntohs(udp->srcport) & 0xff00) ==
SIXLOWPAN_UDP_8_BIT_PORT_MIN) SIXLOWPAN_UDP_8_BIT_PORT_MIN)
{ {
/* We can compress 8 bits of src, leave dest. Copy compressed port */ /* We can compress 8 bits of src, leave dest.
* Copy compressed port
*/
*g_hc06ptr = SIXLOWPAN_NHC_UDP_CS_P_10; *g_hc06ptr = SIXLOWPAN_NHC_UDP_CS_P_10;
ninfo("Remove 8 bits of source with prefix 0xF0, leave dest. hch: %u\n", ninfo("Remove 8 bits of source with prefix 0xF0, "
*g_hc06ptr); "leave dest. hch: %u\n", *g_hc06ptr);
*(g_hc06ptr + 1) = *(g_hc06ptr + 1) =
(uint8_t)((ntohs(udp->srcport) - SIXLOWPAN_UDP_8_BIT_PORT_MIN)); (uint8_t)((ntohs(udp->srcport) - SIXLOWPAN_UDP_8_BIT_PORT_MIN));
@@ -1228,7 +1253,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
/* Traffic class is inline */ /* Traffic class is inline */
ipv6->vtc = 0x60 | ((*g_hc06ptr >> 2) & 0x0f); ipv6->vtc = 0x60 | ((*g_hc06ptr >> 2) & 0x0f);
ipv6->tcf = ((*g_hc06ptr << 6) & 0xc0) | ((*g_hc06ptr >> 2) & 0x30); ipv6->tcf = ((*g_hc06ptr << 6) & 0xc0) |
((*g_hc06ptr >> 2) & 0x30);
ipv6->flow = 0; ipv6->flow = 0;
g_hc06ptr += 1; g_hc06ptr += 1;
} }
@@ -1283,7 +1309,9 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
FAR struct sixlowpan_addrcontext_s *addrcontext; FAR struct sixlowpan_addrcontext_s *addrcontext;
uint8_t sci = (iphc1 & SIXLOWPAN_IPHC_CID) ? iphc[2] >> 4 : 0; uint8_t sci = (iphc1 & SIXLOWPAN_IPHC_CID) ? iphc[2] >> 4 : 0;
/* Source address - check address context != NULL only if SAM bits are != 0 */ /* Source address - check address context != NULL only if
* SAM bits are != 0
*/
if (tmp != 0) if (tmp != 0)
{ {
@@ -1295,7 +1323,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
} }
} }
/* If tmp == 0 we do not have a address context and therefore no prefix. /* If tmp == 0 we do not have a address context and therefore no
* prefix.
* *
* REVISIT: Source address may not be the same size as the destination * REVISIT: Source address may not be the same size as the destination
* address. * address.
@@ -1376,7 +1405,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
if ((iphc1 & SIXLOWPAN_IPHC_DAC) != 0) if ((iphc1 & SIXLOWPAN_IPHC_DAC) != 0)
{ {
FAR struct sixlowpan_addrcontext_s *addrcontext; FAR struct sixlowpan_addrcontext_s *addrcontext;
uint8_t dci = ((iphc1 & SIXLOWPAN_IPHC_CID) != 0) ? iphc[2] & 0x0f : 0; uint8_t dci = ((iphc1 & SIXLOWPAN_IPHC_CID) != 0) ?
iphc[2] & 0x0f : 0;
addrcontext = find_addrcontext_bynumber(dci); addrcontext = find_addrcontext_bynumber(dci);
@@ -1393,8 +1423,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
} }
else else
{ {
/* Not address context based ipaddr=link local M = 0, DAC = 0 - same /* Not address context based ipaddr=link local M = 0,
* as SAC. * DAC = 0 - same as SAC.
*/ */
uncompress_addr(&addr, g_llprefix, g_unc_llconf[tmp], uncompress_addr(&addr, g_llprefix, g_unc_llconf[tmp],
@@ -1408,7 +1438,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
if ((iphc0 & SIXLOWPAN_IPHC_NH) != 0) if ((iphc0 & SIXLOWPAN_IPHC_NH) != 0)
{ {
FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN); FAR struct udp_hdr_s *udp =
(FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN);
/* The next header is compressed, NHC is following */ /* The next header is compressed, NHC is following */
@@ -1536,7 +1567,8 @@ void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
if (ipv6->proto == IP_PROTO_UDP) if (ipv6->proto == IP_PROTO_UDP)
{ {
FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN); FAR struct udp_hdr_s *udp =
(FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN);
memcpy(&udp->udplen, &ipv6->len[0], 2); memcpy(&udp->udplen, &ipv6->len[0], 2);
} }
} }
+14 -7
View File
@@ -210,7 +210,8 @@ int sixlowpan_compresshdr_hc1(FAR struct radio_driver_s *radio,
* 15 * 15
*/ */
ninfo("local/remote port %04x/%04x\n", udp->srcport, udp->destport); ninfo("local/remote port %04x/%04x\n",
udp->srcport, udp->destport);
if (ntohs(udp->srcport) >= CONFIG_NET_6LOWPAN_MINPORT && if (ntohs(udp->srcport) >= CONFIG_NET_6LOWPAN_MINPORT &&
ntohs(udp->srcport) < (CONFIG_NET_6LOWPAN_MINPORT + 16) && ntohs(udp->srcport) < (CONFIG_NET_6LOWPAN_MINPORT + 16) &&
@@ -233,7 +234,8 @@ int sixlowpan_compresshdr_hc1(FAR struct radio_driver_s *radio,
(uint8_t)((ntohs(udp->destport) - (uint8_t)((ntohs(udp->destport) -
CONFIG_NET_6LOWPAN_MINPORT)); CONFIG_NET_6LOWPAN_MINPORT));
memcpy(&hcudp[SIXLOWPAN_HC1_HC_UDP_CHKSUM], &udp->udpchksum, 2); memcpy(&hcudp[SIXLOWPAN_HC1_HC_UDP_CHKSUM],
&udp->udpchksum, 2);
g_frame_hdrlen += SIXLOWPAN_HC1_HC_UDP_HDR_LEN; g_frame_hdrlen += SIXLOWPAN_HC1_HC_UDP_HDR_LEN;
g_uncomp_hdrlen += UDP_HDRLEN; g_uncomp_hdrlen += UDP_HDRLEN;
@@ -341,7 +343,8 @@ int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
#ifdef CONFIG_NET_UDP #ifdef CONFIG_NET_UDP
case SIXLOWPAN_HC1_NH_UDP: case SIXLOWPAN_HC1_NH_UDP:
{ {
FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN); FAR struct udp_hdr_s *udp =
(FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN);
FAR uint8_t *hcudp = fptr + g_frame_hdrlen; FAR uint8_t *hcudp = fptr + g_frame_hdrlen;
ipv6->proto = IP_PROTO_UDP; ipv6->proto = IP_PROTO_UDP;
@@ -355,7 +358,8 @@ int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
if (hcudp[SIXLOWPAN_HC1_HC_UDP_UDP_ENCODING] != if (hcudp[SIXLOWPAN_HC1_HC_UDP_UDP_ENCODING] !=
SIXLOWPAN_HC_UDP_ALL_C) SIXLOWPAN_HC_UDP_ALL_C)
{ {
nwarn("WARNING: sixlowpan (uncompress_hdr), packet not supported"); nwarn("WARNING: "
"sixlowpan (uncompress_hdr), packet not supported");
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
@@ -372,9 +376,11 @@ int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
htons(CONFIG_NET_6LOWPAN_MINPORT + htons(CONFIG_NET_6LOWPAN_MINPORT +
(hcudp[SIXLOWPAN_HC1_HC_UDP_PORTS] & 0x0f)); (hcudp[SIXLOWPAN_HC1_HC_UDP_PORTS] & 0x0f));
ninfo("UDP srcport=%04x destport=%04x\n", udp->srcport, udp->destport); ninfo("UDP srcport=%04x destport=%04x\n",
udp->srcport, udp->destport);
memcpy(&udp->udpchksum, &hcudp[SIXLOWPAN_HC1_HC_UDP_CHKSUM], 2); memcpy(&udp->udpchksum,
&hcudp[SIXLOWPAN_HC1_HC_UDP_CHKSUM], 2);
g_uncomp_hdrlen += UDP_HDRLEN; g_uncomp_hdrlen += UDP_HDRLEN;
g_frame_hdrlen += SIXLOWPAN_HC1_HC_UDP_HDR_LEN; g_frame_hdrlen += SIXLOWPAN_HC1_HC_UDP_HDR_LEN;
@@ -474,7 +480,8 @@ int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
if (ipv6->proto == IP_PROTO_UDP) if (ipv6->proto == IP_PROTO_UDP)
{ {
FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN); FAR struct udp_hdr_s *udp =
(FAR struct udp_hdr_s *)(bptr + IPv6_HDRLEN);
memcpy(&udp->udplen, &ipv6->len[0], 2); memcpy(&udp->udplen, &ipv6->len[0], 2);
ninfo("IPv6 len=%04x\n", udp->udplen); ninfo("IPv6 len=%04x\n", udp->udplen);
+3 -3
View File
@@ -82,9 +82,9 @@ void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
if (conn->lport != 0) if (conn->lport != 0)
{ {
/* Set up for the callback. We can't know in advance if the application /* Set up for the callback. We can't know in advance if the
* is going to send a IPv4 or an IPv6 packet, so this setup may not * application is going to send a IPv4 or an IPv6 packet, so this setup
* actually be used. * may not actually be used.
*/ */
#if defined(CONFIG_NET_IPv4) #if defined(CONFIG_NET_IPv4)
+3 -1
View File
@@ -117,7 +117,9 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
udpiplen = iplen + UDP_HDRLEN; udpiplen = iplen + UDP_HDRLEN;
/* Get the size of the link layer header, the IP header, and the UDP header */ /* Get the size of the link layer header, the IP header, and the UDP
* header
*/
hdrlen = udpiplen + NET_LL_HDRLEN(dev); hdrlen = udpiplen + NET_LL_HDRLEN(dev);
+2 -1
View File
@@ -144,7 +144,8 @@ static int do_connect_request(FAR struct usrsock_conn_s *conn,
* Perform a usrsock connection * Perform a usrsock connection
* *
* Input Parameters: * Input Parameters:
* psock - A reference to the socket structure of the socket to be connected * psock - A reference to the socket structure of the socket to be
* connected
* addr The address of the remote server to connect to * addr The address of the remote server to connect to
* addrlen Length of address buffer * addrlen Length of address buffer
* *
+8 -4
View File
@@ -154,7 +154,8 @@ static uint16_t poll_event(FAR struct net_driver_s *dev, FAR void *pvconn,
* *
****************************************************************************/ ****************************************************************************/
static int usrsock_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) static int usrsock_pollsetup(FAR struct socket *psock,
FAR struct pollfd *fds)
{ {
FAR struct usrsock_conn_s *conn = psock->s_conn; FAR struct usrsock_conn_s *conn = psock->s_conn;
FAR struct usrsock_poll_s *info; FAR struct usrsock_poll_s *info;
@@ -230,8 +231,10 @@ static int usrsock_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
/* Stream sockets need to be connected or connecting (or listening). */ /* Stream sockets need to be connected or connecting (or listening). */
else if ((conn->type == SOCK_STREAM || conn->type == SOCK_SEQPACKET) && else if ((conn->type == SOCK_STREAM ||
!(conn->connected || conn->state == USRSOCK_CONN_STATE_CONNECTING)) conn->type == SOCK_SEQPACKET) &&
!(conn->connected || conn->state ==
USRSOCK_CONN_STATE_CONNECTING))
{ {
ninfo("stream socket not connected and not connecting.\n"); ninfo("stream socket not connected and not connecting.\n");
@@ -363,7 +366,8 @@ static int usrsock_pollteardown(FAR struct socket *psock,
* *
****************************************************************************/ ****************************************************************************/
int usrsock_poll(FAR struct socket *psock, FAR struct pollfd *fds, bool setup) int usrsock_poll(FAR struct socket *psock,
FAR struct pollfd *fds, bool setup)
{ {
if (setup) if (setup)
{ {