[pisa-src] r1651 - in trunk/libpisa: checksum.h nat.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 12 Nov 2009 12:53:03 +0100

Author: tjansen
Date: Thu Nov 12 12:53:03 2009
New Revision: 1651

Log:
Replaced checksum typedefs by the generic types.

pisa_csum16 -> uint16_t 
pisa_csum32 -> uint32_t

Modified:
   trunk/libpisa/checksum.h
   trunk/libpisa/nat.c

Modified: trunk/libpisa/checksum.h
==============================================================================
--- trunk/libpisa/checksum.h    Wed Nov 11 15:31:00 2009        (r1650)
+++ trunk/libpisa/checksum.h    Thu Nov 12 12:53:03 2009        (r1651)
@@ -15,15 +15,12 @@
 
 #include <stdint.h>
 
-typedef uint16_t pisa_csum16;
-typedef uint32_t pisa_csum32;
-
 /**
  * Fold a 32-bit checksum into a 16-bit checksum.
  * @param c checksum that will be folded
  * @return folded checksum (16 bit)
  */
-static inline pisa_csum16 pisa_csum_fold(pisa_csum32 c)
+static inline uint16_t pisa_csum_fold(uint32_t c)
 {
        while (c >> 16)
                c = (c & 0xffff) + (c >> 16);
@@ -35,9 +32,9 @@
  * @param c checksum that will be unfolded
  * @return unfolded checksum (32 bit)
  */
-static inline pisa_csum32 pisa_csum_unfold(pisa_csum16 c)
+static inline uint32_t pisa_csum_unfold(uint16_t c)
 {
-       return (pisa_csum32) c;
+       return (uint32_t) c;
 }
 
 /**
@@ -48,9 +45,9 @@
  *     should be replaced.
  * @param after 4 bytes that will become part of the new checksum.
  */
-static inline void pisa_csum_replace4(pisa_csum16 *addr, uint32_t before, 
uint32_t after)
+static inline void pisa_csum_replace4(uint16_t *addr, uint32_t before, 
uint32_t after)
 {
-       pisa_csum32 csum = pisa_csum_unfold(~*addr);
+       uint32_t csum = pisa_csum_unfold(~*addr);
        csum += ((~before) & 0xffff) + ((~before) >> 16);
        csum += (after & 0xffff) + (after >> 16);
        *addr = ~pisa_csum_fold(csum);

Modified: trunk/libpisa/nat.c
==============================================================================
--- trunk/libpisa/nat.c Wed Nov 11 15:31:00 2009        (r1650)
+++ trunk/libpisa/nat.c Thu Nov 12 12:53:03 2009        (r1651)
@@ -31,7 +31,7 @@
 {
        /* Only the first fragment can contain the TCP or UDP header */
        if ((ntohs(ip->ip_off) & IP_OFFMASK) == 0) {
-               pisa_csum16 *csum = NULL;
+               uint16_t *csum = NULL;
 
                if (ip->ip_p == IPPROTO_TCP)
                        csum = &(((struct tcphdr *)(ip+1))->th_sum);

Other related posts:

  • » [pisa-src] r1651 - in trunk/libpisa: checksum.h nat.c - Thomas Jansen