alias_util.c (26026) | alias_util.c (27864) |
---|---|
1/* 2 Alias_util.h contains general utilities used by other functions 3 in the packet aliasing module. At the moment, there are functions 4 for computing IP header and TCP packet checksums. 5 6 The checksum routines are based upon example code in a Unix networking 7 text written by Stevens (sorry, I can't remember the title -- but 8 at least this is a good author). --- 12 unchanged lines hidden (view full) --- 21*/ 22 23#include <sys/types.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <netinet/tcp.h> 28 | 1/* 2 Alias_util.h contains general utilities used by other functions 3 in the packet aliasing module. At the moment, there are functions 4 for computing IP header and TCP packet checksums. 5 6 The checksum routines are based upon example code in a Unix networking 7 text written by Stevens (sorry, I can't remember the title -- but 8 at least this is a good author). --- 12 unchanged lines hidden (view full) --- 21*/ 22 23#include <sys/types.h> 24#include <netinet/in_systm.h> 25#include <netinet/in.h> 26#include <netinet/ip.h> 27#include <netinet/tcp.h> 28 |
29#include "alias.h" |
|
29#include "alias_local.h" 30 31u_short | 30#include "alias_local.h" 31 32u_short |
32InternetChecksum(u_short *ptr, int nbytes) | 33PacketAliasInternetChecksum(u_short *ptr, int nbytes) |
33{ 34 int sum, oddbyte; 35 36 sum = 0; 37 while (nbytes > 1) 38 { 39 sum += *ptr++; 40 nbytes -= 2; --- 7 unchanged lines hidden (view full) --- 48 sum = (sum >> 16) + (sum & 0xffff); 49 sum += (sum >> 16); 50 return(~sum); 51} 52 53u_short 54IpChecksum(struct ip *pip) 55{ | 34{ 35 int sum, oddbyte; 36 37 sum = 0; 38 while (nbytes > 1) 39 { 40 sum += *ptr++; 41 nbytes -= 2; --- 7 unchanged lines hidden (view full) --- 49 sum = (sum >> 16) + (sum & 0xffff); 50 sum += (sum >> 16); 51 return(~sum); 52} 53 54u_short 55IpChecksum(struct ip *pip) 56{ |
56 return( InternetChecksum((u_short *) pip, (pip->ip_hl << 2)) ); | 57 return( PacketAliasInternetChecksum((u_short *) pip, 58 (pip->ip_hl << 2)) ); |
57 58} 59 60u_short 61TcpChecksum(struct ip *pip) 62{ 63 u_short *ptr; 64 struct tcphdr *tc; --- 71 unchanged lines hidden --- | 59 60} 61 62u_short 63TcpChecksum(struct ip *pip) 64{ 65 u_short *ptr; 66 struct tcphdr *tc; --- 71 unchanged lines hidden --- |