Author: tjansen Date: Tue Oct 6 12:32:33 2009 New Revision: 1019 Log: Use pisa_ prefix for all functions previously prefixed with ps_. For future reference, docs/HACKING has been updated to reflect the new policy. Modified: docs/HACKING trunk/include/checksum.h trunk/libpisa/nat.c Modified: docs/HACKING ============================================================================== --- docs/HACKING Tue Oct 6 12:15:24 2009 (r1018) +++ docs/HACKING Tue Oct 6 12:32:33 2009 (r1019) @@ -51,7 +51,7 @@ - Use under_scores -- PISA code should use the prefix "ps_" in all functions and global variables +- PISA code should use the prefix "pisa_" in all functions and global variables - Use global variables only with GOOD reason Modified: trunk/include/checksum.h ============================================================================== --- trunk/include/checksum.h Tue Oct 6 12:15:24 2009 (r1018) +++ trunk/include/checksum.h Tue Oct 6 12:32:33 2009 (r1019) @@ -13,15 +13,15 @@ #ifndef PISA_CHECKSUM_H #define PISA_CHECKSUM_H -typedef uint16_t ps_csum16; -typedef uint32_t ps_csum32; +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 uint16_t ps_csum_fold(ps_csum32 c) +static inline uint16_t pisa_csum_fold(pisa_csum32 c) { while (c >> 16) c = (c & 0xffff) + (c >> 16); @@ -33,9 +33,9 @@ * @param c checksum that will be unfolded * @return unfolded checksum (32 bit) */ -static inline ps_csum32 ps_csum_unfold(ps_csum16 c) +static inline pisa_csum32 pisa_csum_unfold(pisa_csum16 c) { - return (ps_csum32) c; + return (pisa_csum32) c; } /** @@ -46,12 +46,12 @@ * should be replaced. * @param after 4 bytes that will become part of the new checksum. */ -static inline void ps_csum_replace4(ps_csum16 *addr, uint32_t before, uint32_t after) +static inline void pisa_csum_replace4(pisa_csum16 *addr, uint32_t before, uint32_t after) { - ps_csum32 csum = ps_csum_unfold(~*addr); + pisa_csum32 csum = pisa_csum_unfold(~*addr); csum += ((~before) & 0xffff) + ((~before) >> 16); csum += (after & 0xffff) + (after >> 16); - *addr = ~ps_csum_fold(csum); + *addr = ~pisa_csum_fold(csum); } #endif /* PISA_CHECKSUM_H */ Modified: trunk/libpisa/nat.c ============================================================================== --- trunk/libpisa/nat.c Tue Oct 6 12:15:24 2009 (r1018) +++ trunk/libpisa/nat.c Tue Oct 6 12:32:33 2009 (r1019) @@ -29,7 +29,7 @@ { /* Only the first fragment can contain the TCP or UDP header */ if ((ntohs(ip->frag_off) & IP_OFFMASK) == 0) { - ps_csum16 *csum = NULL; + pisa_csum16 *csum = NULL; if (ip->protocol == IPPROTO_TCP) csum = &(((struct tcphdr *)(ip+1))->check); @@ -42,11 +42,11 @@ * with fragmented packets), we just subtract the old value * and add the new value.*/ if (csum != NULL) - ps_csum_replace4(csum, before->s_addr, after->s_addr); + pisa_csum_replace4(csum, before->s_addr, after->s_addr); } /* The IP header has to be updated in every case. */ - ps_csum_replace4(&ip->check, before->s_addr, after->s_addr); + pisa_csum_replace4(&ip->check, before->s_addr, after->s_addr); /* Overwrite the IP address in the packet only after we don't need the * old value anymore. */