Diff for /embedaddon/quagga/tests/test-checksum.c between versions 1.1.1.2 and 1.1.1.3

version 1.1.1.2, 2013/07/21 23:54:40 version 1.1.1.3, 2016/11/02 10:09:12
Line 1 Line 1
   /* 
    * Copyright (C) 2008 Sun Microsystems, Inc.
    *
    * This file is part of Quagga.
    *
    * Quagga is free software; you can redistribute it and/or modify it
    * under the terms of the GNU General Public License as published by the
    * Free Software Foundation; either version 2, or (at your option) any
    * later version.
    *
    * Quagga is distributed in the hope that it will be useful, but
    * WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    * General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    * along with Quagga; see the file COPYING.  If not, write to the Free
    * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    * 02111-1307, USA.  
    */
   
 #include <zebra.h>  #include <zebra.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <time.h>  #include <time.h>
Line 24  typedef uint16_t testoff_t; Line 45  typedef uint16_t testoff_t;
   
 /* Fletcher Checksum -- Refer to RFC1008. */  /* Fletcher Checksum -- Refer to RFC1008. */
 #define MODX                 4102  #define MODX                 4102
   
 /* Accumulator phase of checksum */  
 static   
 struct acc_vals  
 accumulate (u_char *buffer, testsz_t len, testoff_t off)  
 {  
   u_int8_t *p;  
   u_int16_t *csum;  
   int i, partial_len;  
   struct acc_vals ret;  
     
   csum = (u_int16_t *) (buffer + off);  
   *(csum) = 0;  
     
   p = buffer;  
   ret.c0 = 0;  
   ret.c1 = 0;  
     
   while (len != 0)  
     {  
       partial_len = MIN(len, MODX);  
   
       for (i = 0; i < partial_len; i++)  
         {  
           ret.c0 = ret.c0 + *(p++);  
           ret.c1 += ret.c0;  
         }  
   
       ret.c0 = ret.c0 % 255;  
       ret.c1 = ret.c1 % 255;  
   
       len -= partial_len;  
     }  
   return ret;  
 }  
   
 /* The final reduction phase.  /* The final reduction phase.
  * This one should be the original ospfd version    * This one should be the original ospfd version 
  */   */
Line 263  struct reductions_t { Line 249  struct reductions_t {
   { .name = "isisd-mody",       .f = reduce_isisd_mody },    { .name = "isisd-mody",       .f = reduce_isisd_mody },
   { NULL, NULL },    { NULL, NULL },
 };  };
 /* The original ospfd checksum */  /* The original ospfd checksum */
 static u_int16_t  static u_int16_t
 ospfd_checksum (u_char *buffer, testsz_t len, testoff_t off)  ospfd_checksum (u_char *buffer, testsz_t len, testoff_t off)

Removed from v.1.1.1.2  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>