The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ip/ptclbsum.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 #include        "u.h"
    2 #include        "../port/lib.h"
    3 #include        "mem.h"
    4 #include        "dat.h"
    5 #include        "fns.h"
    6 #include        "../port/error.h"
    7 #include        "ip.h"
    8 
    9 static  short   endian  = 1;
   10 static  uchar*  aendian = (uchar*)&endian;
   11 #define LITTLE  *aendian
   12 
   13 ushort
   14 ptclbsum(uchar *addr, int len)
   15 {
   16         ulong losum, hisum, mdsum, x;
   17         ulong t1, t2;
   18 
   19         losum = 0;
   20         hisum = 0;
   21         mdsum = 0;
   22 
   23         x = 0;
   24         if((ulong)addr & 1) {
   25                 if(len) {
   26                         hisum += addr[0];
   27                         len--;
   28                         addr++;
   29                 }
   30                 x = 1;
   31         }
   32         while(len >= 16) {
   33                 t1 = *(ushort*)(addr+0);
   34                 t2 = *(ushort*)(addr+2);        mdsum += t1;
   35                 t1 = *(ushort*)(addr+4);        mdsum += t2;
   36                 t2 = *(ushort*)(addr+6);        mdsum += t1;
   37                 t1 = *(ushort*)(addr+8);        mdsum += t2;
   38                 t2 = *(ushort*)(addr+10);       mdsum += t1;
   39                 t1 = *(ushort*)(addr+12);       mdsum += t2;
   40                 t2 = *(ushort*)(addr+14);       mdsum += t1;
   41                 mdsum += t2;
   42                 len -= 16;
   43                 addr += 16;
   44         }
   45         while(len >= 2) {
   46                 mdsum += *(ushort*)addr;
   47                 len -= 2;
   48                 addr += 2;
   49         }
   50         if(x) {
   51                 if(len)
   52                         losum += addr[0];
   53                 if(LITTLE)
   54                         losum += mdsum;
   55                 else
   56                         hisum += mdsum;
   57         } else {
   58                 if(len)
   59                         hisum += addr[0];
   60                 if(LITTLE)
   61                         hisum += mdsum;
   62                 else
   63                         losum += mdsum;
   64         }
   65 
   66         losum += hisum >> 8;
   67         losum += (hisum & 0xff) << 8;
   68         while(hisum = losum>>16)
   69                 losum = hisum + (losum & 0xffff);
   70 
   71         return losum & 0xffff;
   72 }

Cache object: 3d4fcfe4cb0424233530eaef5241ddd1


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.