home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / internet / netlite2 / NET / c / LCSUM < prev    next >
Encoding:
Text File  |  1992-02-16  |  612 b   |  22 lines

  1. #include "global.h"
  2. #include "timer.h"
  3. #include "ip.h"
  4. /*
  5.  * Word aligned linear buffer checksum routine.  Called from mbuf checksum
  6.  * routine with simple args.  Intent is that this routine may be replaced
  7.  * by assembly language routine for speed if so desired.
  8.  */
  9. int16 lcsum(register int16 *wp, register int16 len)
  10. {
  11.         register int32 sum = 0;
  12.         int16 result;
  13.  
  14.         while(len-- != 0)
  15.                 sum += *wp++;
  16.         result = eac(sum);
  17.         /* Swap the result because of the (char *) to (int *) type punning */
  18.         result = (result << 8) | (result >> 8);
  19.         return result;
  20. }
  21.  
  22.