summaryrefslogtreecommitdiff
path: root/nuttx/net/uip
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-23 13:31:28 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-23 13:31:28 +0000
commit403a4936c8fc3756003a28328c18c770bc914b6d (patch)
tree1f09ba2f05bd7c92efe529d4f4bc0a065b4b3298 /nuttx/net/uip
parent797f58d1f0e2265f7c3c054eb1b8f7bfe4fcecfc (diff)
downloadpx4-nuttx-403a4936c8fc3756003a28328c18c770bc914b6d.tar.gz
px4-nuttx-403a4936c8fc3756003a28328c18c770bc914b6d.tar.bz2
px4-nuttx-403a4936c8fc3756003a28328c18c770bc914b6d.zip
Debug UDP send logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@401 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip')
-rw-r--r--nuttx/net/uip/uip-send.c8
-rw-r--r--nuttx/net/uip/uip-udpsend.c17
2 files changed, 15 insertions, 10 deletions
diff --git a/nuttx/net/uip/uip-send.c b/nuttx/net/uip/uip-send.c
index 93096168a..c9899db9e 100644
--- a/nuttx/net/uip/uip-send.c
+++ b/nuttx/net/uip/uip-send.c
@@ -93,9 +93,13 @@
void uip_send(struct uip_driver_s *dev, const void *buf, int len)
{
+ /* Some sanity checks -- note that the actually available length in the
+ * buffer is considerably less than CONFIG_NET_BUFSIZE.
+ */
+
if (dev && len > 0 && len < CONFIG_NET_BUFSIZE)
{
+ memcpy(dev->d_snddata, buf, len);
dev->d_sndlen = len;
- memcpy(dev->d_snddata, buf, len );
- }
+ }
}
diff --git a/nuttx/net/uip/uip-udpsend.c b/nuttx/net/uip/uip-udpsend.c
index 8f77f78a2..8936c64bd 100644
--- a/nuttx/net/uip/uip-udpsend.c
+++ b/nuttx/net/uip/uip-udpsend.c
@@ -95,7 +95,7 @@
void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
{
- if (dev->d_sndlen == 0)
+ if (dev->d_sndlen > 0)
{
/* The total lenth to send is the size of the application data plus
* the IP and UDP headers (and, eventually, the ethernet header)
@@ -131,8 +131,8 @@ void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
UDPBUF->ipid[1] = g_ipid & 0xff;
UDPBUF->ipoffset[0] = 0;
UDPBUF->ipoffset[1] = 0;
- UDPBUF->ttl = conn->ttl;
- UDPBUF->proto = UIP_PROTO_UDP;
+ UDPBUF->ttl = conn->ttl;
+ UDPBUF->proto = UIP_PROTO_UDP;
/* Calculate IP checksum. */
@@ -146,20 +146,21 @@ void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
/* Initialize the UDP header */
- UDPBUF->srcport = conn->lport;
- UDPBUF->destport = conn->rport;
- UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
+ UDPBUF->srcport = conn->lport;
+ UDPBUF->destport = conn->rport;
+ UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
#ifdef CONFIG_NET_UDP_CHECKSUMS
/* Calculate UDP checksum. */
- UDPBUF->udpchksum = ~(uip_udpchksum(dev));
+ UDPBUF->udpchksum = 0;
+ UDPBUF->udpchksum = ~(uip_udpchksum(dev));
if (UDPBUF->udpchksum == 0)
{
UDPBUF->udpchksum = 0xffff;
}
#else
- UDPBUF->udpchksum = 0;
+ UDPBUF->udpchksum = 0;
#endif
vdbg("Outgoing UDP packet length: %d (%d)\n",