ptclbsum.c
authorRonald G. Minnich <rminnich@google.com>
Thu, 16 Jan 2014 23:54:07 +0000 (15:54 -0800)
committerRonald G. Minnich <rminnich@google.com>
Thu, 16 Jan 2014 23:54:07 +0000 (15:54 -0800)
Signed-off-by: Ronald G. Minnich <rminnich@google.com>
kern/src/net/Kbuild
kern/src/net/ptclbsum.c

index 1a2b399..3537e21 100644 (file)
@@ -1,5 +1,6 @@
 obj-y                                          += nullmedium.o
 obj-y                                          += loopbackmedium.o
 obj-y                                          += netdevmedium.o
+obj-y                                          += ptclbsum.o
 obj-y                                          += pktmedium.o
 
index 4b895ec..2fad0ea 100644 (file)
@@ -1,27 +1,34 @@
-#include       "u.h"
-#include       "../port/lib.h"
-#include       "mem.h"
-#include       "dat.h"
-#include       "fns.h"
-#include       "../port/error.h"
-#include       "ip.h"
+// INFERNO
+#include <vfs.h>
+#include <kfs.h>
+#include <slab.h>
+#include <kmalloc.h>
+#include <kref.h>
+#include <string.h>
+#include <stdio.h>
+#include <assert.h>
+#include <error.h>
+#include <cpio.h>
+#include <pmap.h>
+#include <smp.h>
+#include <ip.h>
 
 static short   endian  = 1;
-static uchar*  aendian = (uchar*)&endian;
+static uint8_t*        aendian = ( uint8_t *)&endian;
 #define        LITTLE  *aendian
 
-ushort
-ptclbsum(uchar *addr, int len)
+uint16_t
+ptclbsum(uint8_t *addr, int len)
 {
-       ulong losum, hisum, mdsum, x;
-       ulong t1, t2;
+       uint32_t losum, hisum, mdsum, x;
+       uint32_t t1, t2;
 
        losum = 0;
        hisum = 0;
        mdsum = 0;
 
        x = 0;
-       if((ulong)addr & 1) {
+       if((uint32_t)addr & 1) {
                if(len) {
                        hisum += addr[0];
                        len--;
@@ -30,20 +37,20 @@ ptclbsum(uchar *addr, int len)
                x = 1;
        }
        while(len >= 16) {
-               t1 = *(ushort*)(addr+0);
-               t2 = *(ushort*)(addr+2);        mdsum += t1;
-               t1 = *(ushort*)(addr+4);        mdsum += t2;
-               t2 = *(ushort*)(addr+6);        mdsum += t1;
-               t1 = *(ushort*)(addr+8);        mdsum += t2;
-               t2 = *(ushort*)(addr+10);       mdsum += t1;
-               t1 = *(ushort*)(addr+12);       mdsum += t2;
-               t2 = *(ushort*)(addr+14);       mdsum += t1;
+               t1 = *(uint16_t*)(addr+0);
+               t2 = *(uint16_t*)(addr+2);      mdsum += t1;
+               t1 = *(uint16_t*)(addr+4);      mdsum += t2;
+               t2 = *(uint16_t*)(addr+6);      mdsum += t1;
+               t1 = *(uint16_t*)(addr+8);      mdsum += t2;
+               t2 = *(uint16_t*)(addr+10);     mdsum += t1;
+               t1 = *(uint16_t*)(addr+12);     mdsum += t2;
+               t2 = *(uint16_t*)(addr+14);     mdsum += t1;
                mdsum += t2;
                len -= 16;
                addr += 16;
        }
        while(len >= 2) {
-               mdsum += *(ushort*)addr;
+               mdsum += *(uint16_t*)addr;
                len -= 2;
                addr += 2;
        }