Debug UDP send logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@401 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
961336e574
commit
ef651cc6bc
@ -239,4 +239,4 @@
|
|||||||
* Moved urgent data info into device structure.
|
* Moved urgent data info into device structure.
|
||||||
* TCP and ICMP protocols can now be disabled.
|
* TCP and ICMP protocols can now be disabled.
|
||||||
* Added UDP test in examples/udp
|
* Added UDP test in examples/udp
|
||||||
|
* Verified/debugged UDP send logic using examples/udp
|
||||||
|
@ -710,6 +710,7 @@ Other memory:
|
|||||||
* Moved urgent data info into device structure.
|
* Moved urgent data info into device structure.
|
||||||
* TCP and ICMP protocols can now be disabled.
|
* TCP and ICMP protocols can now be disabled.
|
||||||
* Added UDP test in examples/udp
|
* Added UDP test in examples/udp
|
||||||
|
* Verified/debugged UDP send logic using examples/udp
|
||||||
</pre></ul>
|
</pre></ul>
|
||||||
|
|
||||||
<table width ="100%">
|
<table width ="100%">
|
||||||
|
@ -14,11 +14,11 @@ configuration as follows:
|
|||||||
|
|
||||||
netconfig
|
netconfig
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
The alternative configuration file, netconfig, may be used
|
This alternative configuration file, netconfig, may be used
|
||||||
instead of the default configuration (defconfig). This
|
instead of the default configuration (defconfig). This
|
||||||
configuration enables networking using the OSDs DM9000A
|
configuration enables networking using the OSDs DM9000A
|
||||||
Ethernet interface. It uses examples/nettest to excercise
|
Ethernet interface. It uses examples/nettest to excercise
|
||||||
the network.
|
the TCP/IP network.
|
||||||
|
|
||||||
uipconfig
|
uipconfig
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
@ -30,3 +30,8 @@ These alternative configurations can be selected by
|
|||||||
(Seleted the default configuration as show above)
|
(Seleted the default configuration as show above)
|
||||||
cp config/ntosd-dm320/uiponfig .config
|
cp config/ntosd-dm320/uiponfig .config
|
||||||
|
|
||||||
|
udpconfig
|
||||||
|
^^^^^^^^^
|
||||||
|
This alternative configuration file, is similar to netconfig
|
||||||
|
except that is use examples/upd to exercise UDP.
|
||||||
|
|
||||||
|
@ -61,3 +61,9 @@ examples/netttest
|
|||||||
This is a simple network test for verifying client- and server-
|
This is a simple network test for verifying client- and server-
|
||||||
functionality in a TCP/IP connection.
|
functionality in a TCP/IP connection.
|
||||||
|
|
||||||
|
examples/udp
|
||||||
|
^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This is a simple network test for verifying client- and server-
|
||||||
|
functionality over UDP.
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ TARG_BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
|
|||||||
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_HOST=1
|
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_HOST=1
|
||||||
ifeq ($(CONFIG_EXAMPLE_UDP_SERVER),y)
|
ifeq ($(CONFIG_EXAMPLE_UDP_SERVER),y)
|
||||||
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_SERVER=1 \
|
HOSTCFLAGS += -DCONFIG_EXAMPLE_UDP_SERVER=1 \
|
||||||
-DCONFIG_EXAMPLE_UDP_CLIENTIP="$(CONFIG_EXAMPLE_UDP_CLIENTIP)"
|
-DCONFIG_EXAMPLE_UDP_SERVERIP="$(CONFIG_EXAMPLE_UDP_SERVERIP)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HOST_SRCS = host.c
|
HOST_SRCS = host.c
|
||||||
|
@ -107,7 +107,7 @@ void send_client(void)
|
|||||||
message("client: %d. Sending %d bytes\n", offset, SENDSIZE);
|
message("client: %d. Sending %d bytes\n", offset, SENDSIZE);
|
||||||
nbytes = sendto(sockfd, outbuf, SENDSIZE, 0,
|
nbytes = sendto(sockfd, outbuf, SENDSIZE, 0,
|
||||||
(struct sockaddr*)&server, sizeof(struct sockaddr_in));
|
(struct sockaddr*)&server, sizeof(struct sockaddr_in));
|
||||||
message("client: %d. Sent %d bytes\n", nbytes);
|
message("client: %d. Sent %d bytes\n", offset, nbytes);
|
||||||
|
|
||||||
if (nbytes < 0)
|
if (nbytes < 0)
|
||||||
{
|
{
|
||||||
|
15
net/sendto.c
15
net/sendto.c
@ -95,18 +95,19 @@ void sendto_interrupt(struct uip_driver_s *dev, struct uip_udp_conn *conn, uint8
|
|||||||
struct sendto_s *pstate = (struct sendto_s *)conn->private;
|
struct sendto_s *pstate = (struct sendto_s *)conn->private;
|
||||||
if (pstate)
|
if (pstate)
|
||||||
{
|
{
|
||||||
/* Check if the connectin was rejected */
|
/* Check if the connection was rejected */
|
||||||
|
|
||||||
if ((flags & (UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT)) != 0)
|
if ((flags & (UIP_CLOSE|UIP_ABORT|UIP_TIMEDOUT)) != 0)
|
||||||
{
|
{
|
||||||
|
/* Yes.. then terminate with an error */
|
||||||
|
|
||||||
pstate->st_sndlen = -ENOTCONN;
|
pstate->st_sndlen = -ENOTCONN;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Copy the user data into d_appdata and send it */
|
/* No.. Copy the user data into d_snddata and send it */
|
||||||
|
|
||||||
memcpy(dev->d_appdata, pstate->st_buffer, pstate->st_buflen);
|
uip_send(dev, pstate->st_buffer, pstate->st_buflen);
|
||||||
uip_send(dev, dev->d_appdata, pstate->st_buflen);
|
|
||||||
pstate->st_sndlen = pstate->st_buflen;
|
pstate->st_sndlen = pstate->st_buflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +265,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
|||||||
* are ready.
|
* are ready.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
save = irqsave();
|
save = irqsave();
|
||||||
memset(&state, 0, sizeof(struct sendto_s));
|
memset(&state, 0, sizeof(struct sendto_s));
|
||||||
sem_init(&state.st_sem, 0, 0);
|
sem_init(&state.st_sem, 0, 0);
|
||||||
state.st_buflen = len;
|
state.st_buflen = len;
|
||||||
@ -282,7 +283,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
|||||||
|
|
||||||
/* Set up the callback in the connection */
|
/* Set up the callback in the connection */
|
||||||
|
|
||||||
udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
udp_conn = (struct uip_udp_conn *)psock->s_conn;
|
||||||
udp_conn->private = (void*)&state;
|
udp_conn->private = (void*)&state;
|
||||||
udp_conn->event = sendto_interrupt;
|
udp_conn->event = sendto_interrupt;
|
||||||
|
|
||||||
@ -290,7 +291,7 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
|
|||||||
|
|
||||||
uip_udpenable(psock->s_conn);
|
uip_udpenable(psock->s_conn);
|
||||||
|
|
||||||
/* Notify the device driver of the availaibilty of TX data */
|
/* Notify the device driver of the availabilty of TX data */
|
||||||
|
|
||||||
netdev_txnotify(&udp_conn->ripaddr);
|
netdev_txnotify(&udp_conn->ripaddr);
|
||||||
|
|
||||||
|
@ -93,9 +93,13 @@
|
|||||||
|
|
||||||
void uip_send(struct uip_driver_s *dev, const void *buf, int len)
|
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)
|
if (dev && len > 0 && len < CONFIG_NET_BUFSIZE)
|
||||||
{
|
{
|
||||||
|
memcpy(dev->d_snddata, buf, len);
|
||||||
dev->d_sndlen = len;
|
dev->d_sndlen = len;
|
||||||
memcpy(dev->d_snddata, buf, len );
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
|
|
||||||
void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
|
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 total lenth to send is the size of the application data plus
|
||||||
* the IP and UDP headers (and, eventually, the ethernet header)
|
* 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->ipid[1] = g_ipid & 0xff;
|
||||||
UDPBUF->ipoffset[0] = 0;
|
UDPBUF->ipoffset[0] = 0;
|
||||||
UDPBUF->ipoffset[1] = 0;
|
UDPBUF->ipoffset[1] = 0;
|
||||||
UDPBUF->ttl = conn->ttl;
|
UDPBUF->ttl = conn->ttl;
|
||||||
UDPBUF->proto = UIP_PROTO_UDP;
|
UDPBUF->proto = UIP_PROTO_UDP;
|
||||||
|
|
||||||
/* Calculate IP checksum. */
|
/* Calculate IP checksum. */
|
||||||
|
|
||||||
@ -146,20 +146,21 @@ void uip_udpsend(struct uip_driver_s *dev, struct uip_udp_conn *conn)
|
|||||||
|
|
||||||
/* Initialize the UDP header */
|
/* Initialize the UDP header */
|
||||||
|
|
||||||
UDPBUF->srcport = conn->lport;
|
UDPBUF->srcport = conn->lport;
|
||||||
UDPBUF->destport = conn->rport;
|
UDPBUF->destport = conn->rport;
|
||||||
UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
|
UDPBUF->udplen = HTONS(dev->d_sndlen + UIP_UDPH_LEN);
|
||||||
|
|
||||||
#ifdef CONFIG_NET_UDP_CHECKSUMS
|
#ifdef CONFIG_NET_UDP_CHECKSUMS
|
||||||
/* Calculate UDP checksum. */
|
/* Calculate UDP checksum. */
|
||||||
|
|
||||||
UDPBUF->udpchksum = ~(uip_udpchksum(dev));
|
UDPBUF->udpchksum = 0;
|
||||||
|
UDPBUF->udpchksum = ~(uip_udpchksum(dev));
|
||||||
if (UDPBUF->udpchksum == 0)
|
if (UDPBUF->udpchksum == 0)
|
||||||
{
|
{
|
||||||
UDPBUF->udpchksum = 0xffff;
|
UDPBUF->udpchksum = 0xffff;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UDPBUF->udpchksum = 0;
|
UDPBUF->udpchksum = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vdbg("Outgoing UDP packet length: %d (%d)\n",
|
vdbg("Outgoing UDP packet length: %d (%d)\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user