summaryrefslogtreecommitdiff
path: root/nuttx/net/uip/uip-split.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-15 22:45:45 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-09-15 22:45:45 +0000
commit42027d080b72b8198072e7dc3933d8b70b6b40a5 (patch)
treed471d699ed674cbc615d89cd830e83c1b61d9eea /nuttx/net/uip/uip-split.c
parent8bd136d2202c6706ac2166a31b90f1ec18139dea (diff)
downloadpx4-nuttx-42027d080b72b8198072e7dc3933d8b70b6b40a5.tar.gz
px4-nuttx-42027d080b72b8198072e7dc3933d8b70b6b40a5.tar.bz2
px4-nuttx-42027d080b72b8198072e7dc3933d8b70b6b40a5.zip
Add basic structure to support multiple network interfaces
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@343 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip/uip-split.c')
-rw-r--r--nuttx/net/uip/uip-split.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/nuttx/net/uip/uip-split.c b/nuttx/net/uip/uip-split.c
index a85a8db96..8488bd3d1 100644
--- a/nuttx/net/uip/uip-split.c
+++ b/nuttx/net/uip/uip-split.c
@@ -38,19 +38,17 @@
#include "uip-split.h"
#include "uip-fw.h"
-#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
+#define BUF ((struct uip_tcpip_hdr *)&dev->d_buf[UIP_LLH_LEN])
-/*-----------------------------------------------------------------------------*/
-void
-uip_split_output(void)
+void uip_split_output(struct uip_driver_s *dev)
{
uint16 tcplen, len1, len2;
/* We only try to split maximum sized TCP segments. */
if(BUF->proto == UIP_PROTO_TCP &&
- uip_len == UIP_BUFSIZE - UIP_LLH_LEN) {
+ dev->d_len == UIP_BUFSIZE - UIP_LLH_LEN) {
- tcplen = uip_len - UIP_TCPIP_HLEN;
+ tcplen = dev->d_len - UIP_TCPIP_HLEN;
/* Split the segment in two. If the original packet length was
odd, we make the second packet one byte larger. */
len1 = len2 = tcplen / 2;
@@ -60,49 +58,49 @@ uip_split_output(void)
/* Create the first packet. This is done by altering the length
field of the IP header and updating the checksums. */
- uip_len = len1 + UIP_TCPIP_HLEN;
+ dev->d_len = len1 + UIP_TCPIP_HLEN;
#ifdef CONFIG_NET_IPv6
/* For IPv6, the IP length field does not include the IPv6 IP header
length. */
- BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
- BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+ BUF->len[0] = ((dev->d_len - UIP_IPH_LEN) >> 8);
+ BUF->len[1] = ((dev->d_len - UIP_IPH_LEN) & 0xff);
#else /* CONFIG_NET_IPv6 */
- BUF->len[0] = uip_len >> 8;
- BUF->len[1] = uip_len & 0xff;
+ BUF->len[0] = dev->d_len >> 8;
+ BUF->len[1] = dev->d_len & 0xff;
#endif /* CONFIG_NET_IPv6 */
/* Recalculate the TCP checksum. */
BUF->tcpchksum = 0;
- BUF->tcpchksum = ~(uip_tcpchksum());
+ BUF->tcpchksum = ~(uip_tcpchksum(dev));
#ifndef CONFIG_NET_IPv6
/* Recalculate the IP checksum. */
BUF->ipchksum = 0;
- BUF->ipchksum = ~(uip_ipchksum());
+ BUF->ipchksum = ~(uip_ipchksum(dev));
#endif /* CONFIG_NET_IPv6 */
-
+
/* Transmit the first packet. */
/* uip_fw_output();*/
tcpip_output();
/* Now, create the second packet. To do this, it is not enough to
just alter the length field, but we must also update the TCP
- sequence number and point the uip_appdata to a new place in
+ sequence number and point the d_appdata to a new place in
memory. This place is detemined by the length of the first
packet (len1). */
- uip_len = len2 + UIP_TCPIP_HLEN;
+ dev->d_len = len2 + UIP_TCPIP_HLEN;
#ifdef CONFIG_NET_IPv6
/* For IPv6, the IP length field does not include the IPv6 IP header
length. */
- BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);
- BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);
+ BUF->len[0] = ((dev->d_len - UIP_IPH_LEN) >> 8);
+ BUF->len[1] = ((dev->d_len - UIP_IPH_LEN) & 0xff);
#else /* CONFIG_NET_IPv6 */
- BUF->len[0] = uip_len >> 8;
- BUF->len[1] = uip_len & 0xff;
+ BUF->len[0] = dev->d_len >> 8;
+ BUF->len[1] = dev->d_len & 0xff;
#endif /* CONFIG_NET_IPv6 */
- /* uip_appdata += len1;*/
- memcpy(uip_appdata, (uint8 *)uip_appdata + len1, len2);
+ /* dev->d_appdata += len1;*/
+ memcpy(dev->d_appdata, dev->d_appdata + len1, len2);
uip_add32(BUF->seqno, len1);
BUF->seqno[0] = uip_acc32[0];
@@ -112,12 +110,12 @@ uip_split_output(void)
/* Recalculate the TCP checksum. */
BUF->tcpchksum = 0;
- BUF->tcpchksum = ~(uip_tcpchksum());
+ BUF->tcpchksum = ~(uip_tcpchksum(dev));
#ifndef CONFIG_NET_IPv6
/* Recalculate the IP checksum. */
BUF->ipchksum = 0;
- BUF->ipchksum = ~(uip_ipchksum());
+ BUF->ipchksum = ~(uip_ipchksum(dev));
#endif /* CONFIG_NET_IPv6 */
/* Transmit the second packet. */
@@ -127,6 +125,4 @@ uip_split_output(void)
/* uip_fw_output();*/
tcpip_output();
}
-
}
-/*-----------------------------------------------------------------------------*/