ip_ftp_pxy.c (64580) | ip_ftp_pxy.c (67614) |
---|---|
1/* 2 * Simple FTP transparent proxy for in-kernel use. For use with the NAT 3 * code. | 1/* 2 * Simple FTP transparent proxy for in-kernel use. For use with the NAT 3 * code. |
4 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c 64580 2000-08-13 04:31:06Z darrenr $ | 4 * $FreeBSD: head/sys/contrib/ipfilter/netinet/ip_ftp_pxy.c 67614 2000-10-26 12:33:42Z darrenr $ |
5 */ 6#if SOLARIS && defined(_KERNEL) 7extern kmutex_t ipf_rw; 8#endif 9 10#define isdigit(x) ((x) >= '0' && (x) <= '9') 11#define isupper(x) (((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z')) 12#define islower(x) (((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z')) --- 127 unchanged lines hidden (view full) --- 140 if (*s == '\n') 141 s--; 142 if ((*s == '\r') && (*(s + 1) == '\n')) { 143 s += 2; 144 a6 = a5 & 0xff; 145 } else 146 return 0; 147 a5 >>= 8; | 5 */ 6#if SOLARIS && defined(_KERNEL) 7extern kmutex_t ipf_rw; 8#endif 9 10#define isdigit(x) ((x) >= '0' && (x) <= '9') 11#define isupper(x) (((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z')) 12#define islower(x) (((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z')) --- 127 unchanged lines hidden (view full) --- 140 if (*s == '\n') 141 s--; 142 if ((*s == '\r') && (*(s + 1) == '\n')) { 143 s += 2; 144 a6 = a5 & 0xff; 145 } else 146 return 0; 147 a5 >>= 8; |
148 a5 &= 0xff; |
|
148 /* 149 * Calculate new address parts for PORT command 150 */ 151 a1 = ntohl(ip->ip_src.s_addr); 152 a2 = (a1 >> 16) & 0xff; 153 a3 = (a1 >> 8) & 0xff; 154 a4 = a1 & 0xff; 155 a1 >>= 24; --- 52 unchanged lines hidden (view full) --- 208 sum2 = ip->ip_len + inc; 209 210 /* Because ~1 == -2, We really need ~1 == -1 */ 211 if (sum1 > sum2) 212 sum2--; 213 sum2 -= sum1; 214 sum2 = (sum2 & 0xffff) + (sum2 >> 16); 215 | 149 /* 150 * Calculate new address parts for PORT command 151 */ 152 a1 = ntohl(ip->ip_src.s_addr); 153 a2 = (a1 >> 16) & 0xff; 154 a3 = (a1 >> 8) & 0xff; 155 a4 = a1 & 0xff; 156 a1 >>= 24; --- 52 unchanged lines hidden (view full) --- 209 sum2 = ip->ip_len + inc; 210 211 /* Because ~1 == -2, We really need ~1 == -1 */ 212 if (sum1 > sum2) 213 sum2--; 214 sum2 -= sum1; 215 sum2 = (sum2 & 0xffff) + (sum2 >> 16); 216 |
216 fix_outcksum(&ip->ip_sum, sum2, 0); | 217 fix_outcksum(&ip->ip_sum, sum2); |
217#endif 218 ip->ip_len += inc; 219 } 220 221 /* 222 * Add skeleton NAT entry for connection which will come back the 223 * other way. 224 */ --- 210 unchanged lines hidden (view full) --- 435 sum2 = ip->ip_len + inc; 436 437 /* Because ~1 == -2, We really need ~1 == -1 */ 438 if (sum1 > sum2) 439 sum2--; 440 sum2 -= sum1; 441 sum2 = (sum2 & 0xffff) + (sum2 >> 16); 442 | 218#endif 219 ip->ip_len += inc; 220 } 221 222 /* 223 * Add skeleton NAT entry for connection which will come back the 224 * other way. 225 */ --- 210 unchanged lines hidden (view full) --- 436 sum2 = ip->ip_len + inc; 437 438 /* Because ~1 == -2, We really need ~1 == -1 */ 439 if (sum1 > sum2) 440 sum2--; 441 sum2 -= sum1; 442 sum2 = (sum2 & 0xffff) + (sum2 >> 16); 443 |
443 fix_outcksum(&ip->ip_sum, sum2, 0); | 444 fix_outcksum(&ip->ip_sum, sum2); |
444#endif /* SOLARIS || defined(__sgi) */ 445 ip->ip_len += inc; 446 } 447#endif /* 0 */ 448 449 /* 450 * Add skeleton NAT entry for connection which will come back the 451 * other way. --- 212 unchanged lines hidden (view full) --- 664 rptr = f->ftps_rptr; 665 } 666 } 667 668 while ((f->ftps_junk == 1) && (rptr < wptr)) { 669 while ((rptr < wptr) && (*rptr != '\r')) 670 rptr++; 671 | 445#endif /* SOLARIS || defined(__sgi) */ 446 ip->ip_len += inc; 447 } 448#endif /* 0 */ 449 450 /* 451 * Add skeleton NAT entry for connection which will come back the 452 * other way. --- 212 unchanged lines hidden (view full) --- 665 rptr = f->ftps_rptr; 666 } 667 } 668 669 while ((f->ftps_junk == 1) && (rptr < wptr)) { 670 while ((rptr < wptr) && (*rptr != '\r')) 671 rptr++; 672 |
672 if ((*rptr == '\r') && (rptr + 1 < wptr)) { 673 if (*(rptr + 1) == '\n') { 674 rptr += 2; 675 f->ftps_junk = 0; | 673 if (*rptr == '\r') { 674 if (rptr + 1 < wptr) { 675 if (*(rptr + 1) == '\n') { 676 rptr += 2; 677 f->ftps_junk = 0; 678 } else 679 rptr++; |
676 } else | 680 } else |
677 rptr++; | 681 break; |
678 } | 682 } |
679 f->ftps_rptr = rptr; | |
680 } | 683 } |
684 f->ftps_rptr = rptr; |
|
681 682 if (rptr == wptr) { 683 rptr = wptr = f->ftps_buf; 684 } else { 685 if ((wptr > f->ftps_buf + FTP_BUFSZ / 2)) { 686 i = wptr - rptr; 687 if ((rptr == f->ftps_buf) || 688 (wptr - rptr > FTP_BUFSZ / 2)) { --- 67 unchanged lines hidden (view full) --- 756 *ptr = NULL; 757 return 0; 758 } 759 while ((c = *s++) && isdigit(c)) { 760 j *= 10; 761 j += c - '0'; 762 } 763 *ptr = s; | 685 686 if (rptr == wptr) { 687 rptr = wptr = f->ftps_buf; 688 } else { 689 if ((wptr > f->ftps_buf + FTP_BUFSZ / 2)) { 690 i = wptr - rptr; 691 if ((rptr == f->ftps_buf) || 692 (wptr - rptr > FTP_BUFSZ / 2)) { --- 67 unchanged lines hidden (view full) --- 760 *ptr = NULL; 761 return 0; 762 } 763 while ((c = *s++) && isdigit(c)) { 764 j *= 10; 765 j += c - '0'; 766 } 767 *ptr = s; |
768 i &= 0xff; 769 j &= 0xff; |
|
764 return (i << 8) | j; 765} | 770 return (i << 8) | j; 771} |