]> git.sur5r.net Git - freertos/blobdiff - Demo/Common/ethernet/FreeRTOS-uIP/uip-split.c
Add faster version code.
[freertos] / Demo / Common / ethernet / FreeRTOS-uIP / uip-split.c
index 3365f2e5569950b0a4c976e330a4188017d53e0b..6828f3c746a6e231c68a78e401db2be233f5f5a9 100644 (file)
@@ -32,7 +32,6 @@
  *\r
  * $Id: uip-split.c,v 1.2 2006/06/12 08:00:30 adam Exp $\r
  */\r
-\r
 #include <string.h>\r
 \r
 #include "uip-split.h"\r
 #include "uip-fw.h"\r
 #include "uip_arch.h"\r
 \r
-\r
-\r
-#define BUF ((struct uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])\r
+#define BUF ( ( struct uip_tcpip_hdr * ) &uip_buf[UIP_LLH_LEN] )\r
 \r
 /*-----------------------------------------------------------------------------*/\r
-void\r
-uip_split_output(void)\r
+void uip_split_output( void )\r
 {\r
-  u16_t tcplen, len1, len2;\r
+       u16_t   tcplen, len1, len2;\r
 \r
-  /* We only try to split maximum sized TCP segments. */\r
-  if(BUF->proto == UIP_PROTO_TCP &&\r
-     uip_len == UIP_BUFSIZE - UIP_LLH_LEN) {\r
+       /* We only try to split maximum sized TCP segments. */\r
+       if( BUF->proto == UIP_PROTO_TCP && uip_len == UIP_BUFSIZE - UIP_LLH_LEN )\r
+       {\r
+               tcplen = uip_len - UIP_TCPIP_HLEN;\r
 \r
-    tcplen = uip_len - UIP_TCPIP_HLEN;\r
-    /* Split the segment in two. If the original packet length was\r
+               /* Split the segment in two. If the original packet length was\r
        odd, we make the second packet one byte larger. */\r
-    len1 = len2 = tcplen / 2;\r
-    if(len1 + len2 < tcplen) {\r
-      ++len2;\r
-    }\r
+               len1 = len2 = tcplen / 2;\r
+               if( len1 + len2 < tcplen )\r
+               {\r
+                       ++len2;\r
+               }\r
 \r
-    /* Create the first packet. This is done by altering the length\r
+               /* Create the first packet. This is done by altering the length\r
        field of the IP header and updating the checksums. */\r
-    uip_len = len1 + UIP_TCPIP_HLEN;\r
-#if UIP_CONF_IPV6\r
-    /* For IPv6, the IP length field does not include the IPv6 IP header\r
+               uip_len = len1 + UIP_TCPIP_HLEN;\r
+               #if UIP_CONF_IPV6\r
+\r
+               /* For IPv6, the IP length field does not include the IPv6 IP header\r
        length. */\r
-    BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);\r
-    BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);\r
-#else /* UIP_CONF_IPV6 */\r
-    BUF->len[0] = uip_len >> 8;\r
-    BUF->len[1] = uip_len & 0xff;\r
-#endif /* UIP_CONF_IPV6 */\r
-\r
-    /* Recalculate the TCP checksum. */\r
-    BUF->tcpchksum = 0;\r
-    BUF->tcpchksum = ~(uip_tcpchksum());\r
-\r
-#if !UIP_CONF_IPV6\r
-    /* Recalculate the IP checksum. */\r
-    BUF->ipchksum = 0;\r
-    BUF->ipchksum = ~(uip_ipchksum());\r
-#endif /* UIP_CONF_IPV6 */\r
-\r
-    /* Transmit the first packet. */\r
-    /*    uip_fw_output();*/\r
-//    tcpip_output();\r
-\r
-    /* Now, create the second packet. To do this, it is not enough to\r
+               BUF->len[0] = ( (uip_len - UIP_IPH_LEN) >> 8 );\r
+               BUF->len[1] = ( (uip_len - UIP_IPH_LEN) & 0xff );\r
+               #else /* UIP_CONF_IPV6 */\r
+               BUF->len[0] = uip_len >> 8;\r
+               BUF->len[1] = uip_len & 0xff;\r
+               #endif /* UIP_CONF_IPV6 */\r
+\r
+               /* Recalculate the TCP checksum. */\r
+               BUF->tcpchksum = 0;\r
+               BUF->tcpchksum = ~( uip_tcpchksum() );\r
+\r
+               #if !UIP_CONF_IPV6\r
+\r
+               /* Recalculate the IP checksum. */\r
+               BUF->ipchksum = 0;\r
+               BUF->ipchksum = ~( uip_ipchksum() );\r
+               #endif /* UIP_CONF_IPV6 */\r
+\r
+               /* Transmit the first packet. */\r
+\r
+               /*    uip_fw_output();*/\r
+\r
+               //    tcpip_output();\r
+\r
+               /* Now, create the second packet. To do this, it is not enough to\r
        just alter the length field, but we must also update the TCP\r
        sequence number and point the uip_appdata to a new place in\r
        memory. This place is detemined by the length of the first\r
        packet (len1). */\r
-    uip_len = len2 + UIP_TCPIP_HLEN;\r
-#if UIP_CONF_IPV6\r
-    /* For IPv6, the IP length field does not include the IPv6 IP header\r
+               uip_len = len2 + UIP_TCPIP_HLEN;\r
+               #if UIP_CONF_IPV6\r
+\r
+               /* For IPv6, the IP length field does not include the IPv6 IP header\r
        length. */\r
-    BUF->len[0] = ((uip_len - UIP_IPH_LEN) >> 8);\r
-    BUF->len[1] = ((uip_len - UIP_IPH_LEN) & 0xff);\r
-#else /* UIP_CONF_IPV6 */\r
-    BUF->len[0] = uip_len >> 8;\r
-    BUF->len[1] = uip_len & 0xff;\r
-#endif /* UIP_CONF_IPV6 */\r
-\r
-    /*    uip_appdata += len1;*/\r
-    memcpy(uip_appdata, (u8_t *)uip_appdata + len1, len2);\r
-\r
-    uip_add32(BUF->seqno, len1);\r
-    BUF->seqno[0] = uip_acc32[0];\r
-    BUF->seqno[1] = uip_acc32[1];\r
-    BUF->seqno[2] = uip_acc32[2];\r
-    BUF->seqno[3] = uip_acc32[3];\r
-\r
-    /* Recalculate the TCP checksum. */\r
-    BUF->tcpchksum = 0;\r
-    BUF->tcpchksum = ~(uip_tcpchksum());\r
-\r
-#if !UIP_CONF_IPV6\r
-    /* Recalculate the IP checksum. */\r
-    BUF->ipchksum = 0;\r
-    BUF->ipchksum = ~(uip_ipchksum());\r
-#endif /* UIP_CONF_IPV6 */\r
-\r
-    /* Transmit the second packet. */\r
-    /*    uip_fw_output();*/\r
-//    tcpip_output();\r
-  } else {\r
-    /*    uip_fw_output();*/\r
-//    tcpip_output();\r
-  }\r
+               BUF->len[0] = ( (uip_len - UIP_IPH_LEN) >> 8 );\r
+               BUF->len[1] = ( (uip_len - UIP_IPH_LEN) & 0xff );\r
+               #else /* UIP_CONF_IPV6 */\r
+               BUF->len[0] = uip_len >> 8;\r
+               BUF->len[1] = uip_len & 0xff;\r
+               #endif /* UIP_CONF_IPV6 */\r
+\r
+               /*    uip_appdata += len1;*/\r
+               memcpy( uip_appdata, ( u8_t * ) uip_appdata + len1, len2 );\r
+\r
+               uip_add32( BUF->seqno, len1 );\r
+               BUF->seqno[0] = uip_acc32[0];\r
+               BUF->seqno[1] = uip_acc32[1];\r
+               BUF->seqno[2] = uip_acc32[2];\r
+               BUF->seqno[3] = uip_acc32[3];\r
+\r
+               /* Recalculate the TCP checksum. */\r
+               BUF->tcpchksum = 0;\r
+               BUF->tcpchksum = ~( uip_tcpchksum() );\r
+\r
+               #if !UIP_CONF_IPV6\r
 \r
+               /* Recalculate the IP checksum. */\r
+               BUF->ipchksum = 0;\r
+               BUF->ipchksum = ~( uip_ipchksum() );\r
+               #endif /* UIP_CONF_IPV6 */\r
+\r
+               /* Transmit the second packet. */\r
+\r
+               /*    uip_fw_output();*/\r
+\r
+               //    tcpip_output();\r
+       }\r
+       else\r
+       {\r
+               /*    uip_fw_output();*/\r
+\r
+               //    tcpip_output();\r
+       }\r
 }\r
+\r
 /*-----------------------------------------------------------------------------*/\r