Deleted Added
full compact
ip_nat.c (288242) ip_nat.c (292518)
1/* $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.c 288242 2015-09-25 23:07:17Z bz $ */
1/* $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.c 292518 2015-12-20 18:02:13Z cy $ */
2
3/*
4 * Copyright (C) 2012 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
8#if defined(KERNEL) || defined(_KERNEL)
9# undef KERNEL

--- 97 unchanged lines hidden (view full) ---

107#endif
108/* END OF INCLUDES */
109
110#undef SOCKADDR_IN
111#define SOCKADDR_IN struct sockaddr_in
112
113#if !defined(lint)
114static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed";
2
3/*
4 * Copyright (C) 2012 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
8#if defined(KERNEL) || defined(_KERNEL)
9# undef KERNEL

--- 97 unchanged lines hidden (view full) ---

107#endif
108/* END OF INCLUDES */
109
110#undef SOCKADDR_IN
111#define SOCKADDR_IN struct sockaddr_in
112
113#if !defined(lint)
114static const char sccsid[] = "@(#)ip_nat.c 1.11 6/5/96 (C) 1995 Darren Reed";
115static const char rcsid[] = "@(#)$FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.c 288242 2015-09-25 23:07:17Z bz $";
115static const char rcsid[] = "@(#)$FreeBSD: head/sys/contrib/ipfilter/netinet/ip_nat.c 292518 2015-12-20 18:02:13Z cy $";
116/* static const char rcsid[] = "@(#)$Id: ip_nat.c,v 2.195.2.102 2007/10/16 10:08:10 darrenr Exp $"; */
117#endif
118
119
120#define NATFSUM(n,v,f) ((v) == 4 ? (n)->f.in4.s_addr : (n)->f.i6[0] + \
121 (n)->f.i6[1] + (n)->f.i6[2] + (n)->f.i6[3])
122#define NBUMP(x) softn->(x)++
123#define NBUMPD(x, y) do { \

--- 4994 unchanged lines hidden (view full) ---

5118 s2 = LONG_SUM(ntohl(nat->nat_osrcaddr));
5119 }
5120 CALC_SUMD(s1, s2, sumd);
5121 msumd += sumd;
5122
5123 ipf_fix_outcksum(0, &fin->fin_ip->ip_sum, msumd, 0);
5124 }
5125#if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
116/* static const char rcsid[] = "@(#)$Id: ip_nat.c,v 2.195.2.102 2007/10/16 10:08:10 darrenr Exp $"; */
117#endif
118
119
120#define NATFSUM(n,v,f) ((v) == 4 ? (n)->f.in4.s_addr : (n)->f.i6[0] + \
121 (n)->f.i6[1] + (n)->f.i6[2] + (n)->f.i6[3])
122#define NBUMP(x) softn->(x)++
123#define NBUMPD(x, y) do { \

--- 4994 unchanged lines hidden (view full) ---

5118 s2 = LONG_SUM(ntohl(nat->nat_osrcaddr));
5119 }
5120 CALC_SUMD(s1, s2, sumd);
5121 msumd += sumd;
5122
5123 ipf_fix_outcksum(0, &fin->fin_ip->ip_sum, msumd, 0);
5124 }
5125#if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
5126 defined(linux) || defined(BRIDGE_IPF)
5126 defined(linux) || defined(BRIDGE_IPF) || defined(__FreeBSD__)
5127 else {
5128 /*
5129 * Strictly speaking, this isn't necessary on BSD
5130 * kernels because they do checksum calculation after
5131 * this code has run BUT if ipfilter is being used
5132 * to do NAT as a bridge, that code doesn't exist.
5133 */
5134 switch (nat->nat_dir)

--- 95 unchanged lines hidden (view full) ---

5230 ip->ip_len = htons(ip->ip_len);
5231 s2 += ntohs(ip->ip_len);
5232 CALC_SUMD(s1, s2, sumd);
5233
5234 uh = (udphdr_t *)(ip + 1);
5235 uh->uh_ulen += fin->fin_plen;
5236 uh->uh_ulen = htons(uh->uh_ulen);
5237#if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
5127 else {
5128 /*
5129 * Strictly speaking, this isn't necessary on BSD
5130 * kernels because they do checksum calculation after
5131 * this code has run BUT if ipfilter is being used
5132 * to do NAT as a bridge, that code doesn't exist.
5133 */
5134 switch (nat->nat_dir)

--- 95 unchanged lines hidden (view full) ---

5230 ip->ip_len = htons(ip->ip_len);
5231 s2 += ntohs(ip->ip_len);
5232 CALC_SUMD(s1, s2, sumd);
5233
5234 uh = (udphdr_t *)(ip + 1);
5235 uh->uh_ulen += fin->fin_plen;
5236 uh->uh_ulen = htons(uh->uh_ulen);
5237#if !defined(_KERNEL) || defined(MENTAT) || defined(__sgi) || \
5238 defined(linux) || defined(BRIDGE_IPF)
5238 defined(linux) || defined(BRIDGE_IPF) || defined(__FreeBSD)
5239 ipf_fix_outcksum(0, &ip->ip_sum, sumd, 0);
5240#endif
5241
5242 PREP_MB_T(fin, m);
5243
5244 fin->fin_src = ip->ip_src;
5245 fin->fin_dst = ip->ip_dst;
5246 fin->fin_ip = ip;

--- 3350 unchanged lines hidden ---
5239 ipf_fix_outcksum(0, &ip->ip_sum, sumd, 0);
5240#endif
5241
5242 PREP_MB_T(fin, m);
5243
5244 fin->fin_src = ip->ip_src;
5245 fin->fin_dst = ip->ip_dst;
5246 fin->fin_ip = ip;

--- 3350 unchanged lines hidden ---