diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2015-01-16 15:03:10 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2015-01-16 15:03:10 -0600 |
commit | 25899ddde960f404256bda7848e7f044105dea9e (patch) | |
tree | 639b4c72043bdc3f94a926562044391b2dabed9f /nuttx/net/udp | |
parent | 8b011e3350a04464334ab5e0fc3b8e5d44bdccbc (diff) | |
download | px4-nuttx-25899ddde960f404256bda7848e7f044105dea9e.tar.gz px4-nuttx-25899ddde960f404256bda7848e7f044105dea9e.tar.bz2 px4-nuttx-25899ddde960f404256bda7848e7f044105dea9e.zip |
Networking: UDP and TCP MSS depends on the IP header size (as well as the link layer header size) and cannot be represented with a single value.
Diffstat (limited to 'nuttx/net/udp')
-rw-r--r-- | nuttx/net/udp/udp_input.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/nuttx/net/udp/udp_input.c b/nuttx/net/udp/udp_input.c index d53b9185c..9062b6dd5 100644 --- a/nuttx/net/udp/udp_input.c +++ b/nuttx/net/udp/udp_input.c @@ -93,10 +93,11 @@ * ****************************************************************************/ -static int udp_input(FAR struct net_driver_s *dev, FAR struct udp_hdr_s *udp, - unsigned int udpiplen) +static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen) { + FAR struct udp_hdr_s *udp; FAR struct udp_conn_s *conn; + unsigned int udpiplen; unsigned int hdrlen; int ret = OK; @@ -106,17 +107,27 @@ static int udp_input(FAR struct net_driver_s *dev, FAR struct udp_hdr_s *udp, g_netstats.udp.recv++; #endif - /* UDP processing is really just a hack. We don't do anything to the UDP/IP - * headers, but let the UDP application do all the hard work. If the - * application sets d_sndlen, it has a packet to send. + /* Get a pointer to the UDP header. The UDP header lies just after the + * the link layer header and the IP header. */ - dev->d_len -= udpiplen; + udp = (FAR struct udp_hdr_s *)&dev->d_buf[iplen + NET_LL_HDRLEN(dev)]; + + /* Get the size of the IP header and the UDP header */ + + udpiplen = iplen + UDP_HDRLEN; /* Get the size of the link layer header, the IP header, and the UDP header */ hdrlen = udpiplen + NET_LL_HDRLEN(dev); + /* UDP processing is really just a hack. We don't do anything to the UDP/IP + * headers, but let the UDP application do all the hard work. If the + * application sets d_sndlen, it has a packet to send. + */ + + dev->d_len -= udpiplen; + #ifdef CONFIG_NET_UDP_CHECKSUMS dev->d_appdata = &dev->d_buf[hdrlen]; @@ -219,9 +230,7 @@ static int udp_input(FAR struct net_driver_s *dev, FAR struct udp_hdr_s *udp, #ifdef CONFIG_NET_IPv4 int udp_ipv4_input(FAR struct net_driver_s *dev) { - unsigned int offset = IPv4_HDRLEN + NET_LL_HDRLEN(dev); - return udp_input(dev, (FAR struct udp_hdr_s *)&dev->d_buf[offset], - IPv4UDP_HDRLEN); + return udp_input(dev, IPv4_HDRLEN); } #endif @@ -247,9 +256,7 @@ int udp_ipv4_input(FAR struct net_driver_s *dev) #ifdef CONFIG_NET_IPv6 int udp_ipv6_input(FAR struct net_driver_s *dev) { - unsigned int offset = IPv6_HDRLEN + NET_LL_HDRLEN(dev); - return udp_input(dev, (FAR struct udp_hdr_s *)&dev->d_buf[offset], - IPv6UDP_HDRLEN); + return udp_input(dev, IPv6_HDRLEN); } #endif |