This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Net - fix checksum problems on big endian machines
- From: Gary Thomas <gary at chez-thomas dot org>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: 31 Jul 2002 08:03:55 -0600
- Subject: Net - fix checksum problems on big endian machines
Index: net/bsd_tcpip/current/ChangeLog
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/bsd_tcpip/current/ChangeLog,v
retrieving revision 1.7
diff -u -5 -p -r1.7 ChangeLog
--- net/bsd_tcpip/current/ChangeLog 26 Jul 2002 15:04:01 -0000 1.7
+++ net/bsd_tcpip/current/ChangeLog 31 Jul 2002 14:01:59 -0000
@@ -1,5 +1,9 @@
+2002-07-31 Gary Thomas <gary@chez-thomas.org>
+
+ * src/sys/netinet/in_cksum.c: Fix problem on big endian machines.
+
2002-07-26 Gary Thomas <gary@chez-thomas.org>
2002-07-26 Ken Cox <jkc@redhat.com>
* src/ecos/support.c (ovbcopy): ovbcopy() must handle the case
where the src and dst regions are overlayed. memcpy() does not
Index: net/bsd_tcpip/current/src/sys/netinet/in_cksum.c
===================================================================
RCS file: /misc/cvsfiles/ecos-opt/net/net/bsd_tcpip/current/src/sys/netinet/in_cksum.c,v
retrieving revision 1.1
diff -u -5 -p -r1.1 in_cksum.c
--- net/bsd_tcpip/current/src/sys/netinet/in_cksum.c 20 May 2002 22:25:02 -0000 1.1
+++ net/bsd_tcpip/current/src/sys/netinet/in_cksum.c 31 Jul 2002 13:59:08 -0000
@@ -86,15 +86,23 @@
sum = l_util.s[0] + l_util.s[1]; \
ADDCARRY(sum); \
}
static const u_int32_t in_masks[] = {
+#if BYTE_ORDER == BIG_ENDIAN
+ /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/
+ 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00, /* offset 0 */
+ 0x00000000, 0x00FF0000, 0x00FFFF00, 0x00FFFFFF, /* offset 1 */
+ 0x00000000, 0x0000FF00, 0x0000FFFF, 0x0000FFFF, /* offset 2 */
+ 0x00000000, 0x000000FF, 0x000000FF, 0x000000FF, /* offset 3 */
+#else
/*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/
0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */
0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */
0x00000000, 0x00FF0000, 0xFFFF0000, 0xFFFF0000, /* offset 2 */
0x00000000, 0xFF000000, 0xFF000000, 0xFF000000, /* offset 3 */
+#endif
};
union l_util {
u_int16_t s[2];
u_int32_t l;