Lines Matching defs:ftp
8 * Simple FTP transparent proxy for in-kernel use. For use with the NAT
50 * Values for FTP commands. Numerics cover 0-999
159 MUTEX_INIT(&ftppxyfr.fr_lock, "FTP Proxy Mutex");
229 ftpinfo_t *ftp;
232 KMALLOC(ftp, ftpinfo_t *);
233 if (ftp == NULL)
238 aps->aps_data = ftp;
243 bzero((char *)ftp, sizeof(*ftp));
244 f = &ftp->ftp_side[0];
247 f = &ftp->ftp_side[1];
250 ftp->ftp_passok = FTPXY_INIT;
251 ftp->ftp_incok = 0;
257 ipf_p_ftp_setpending(ipf_main_softc_t *softc, ftpinfo_t *ftp)
259 if (ftp->ftp_pendnat != NULL)
260 ipf_nat_setpending(softc, ftp->ftp_pendnat);
262 if (ftp->ftp_pendstate != NULL) {
264 ipf_state_setpending(softc, ftp->ftp_pendstate);
273 ftpinfo_t *ftp;
275 ftp = aps->aps_data;
276 if (ftp != NULL)
277 ipf_p_ftp_setpending(softc, ftp);
283 ftpinfo_t *ftp, int dlen)
295 f = &ftp->ftp_side[0];
429 return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, sp, inc);
435 ftpinfo_t *ftp, int dlen, int nport, int inc)
450 if ((ftp->ftp_pendnat != NULL) || (ftp->ftp_pendstate != NULL)) {
453 ftpinfo_t *, ftp);
456 ftp->ftp_pendnat, ftp->ftp_pendstate);
459 ipf_p_ftp_setpending(softc, ftp);
472 DT3(ftp_PORT_error_port, nat_t *, nat, ftpinfo_t *, ftp,
564 nat2 = ipf_nat6_add(&fi, ipn, &ftp->ftp_pendnat, flags,
568 nat2 = ipf_nat_add(&fi, ipn, &ftp->ftp_pendnat, flags,
585 if (ipf_state_add(softc, &fi, (ipstate_t **)&ftp->ftp_pendstate,
595 ftpinfo_t *ftp, int dlen)
602 f = &ftp->ftp_side[0];
616 ftp->ftp_incok = 0;
617 DT2(ftp_client_command, char [], cmd, int, ftp->ftp_passok);
619 if (ftp->ftp_passok == FTPXY_ADOK_1 ||
620 ftp->ftp_passok == FTPXY_AUOK_1) {
621 ftp->ftp_passok = FTPXY_USER_2;
622 ftp->ftp_incok = 1;
624 ftp->ftp_passok = FTPXY_USER_1;
625 ftp->ftp_incok = 1;
628 ftp->ftp_passok = FTPXY_AUTH_1;
629 ftp->ftp_incok = 1;
631 if (ftp->ftp_passok == FTPXY_USOK_1) {
632 ftp->ftp_passok = FTPXY_PASS_1;
633 ftp->ftp_incok = 1;
634 } else if (ftp->ftp_passok == FTPXY_USOK_2) {
635 ftp->ftp_passok = FTPXY_PASS_2;
636 ftp->ftp_incok = 1;
638 } else if ((ftp->ftp_passok == FTPXY_AUOK_1) &&
640 ftp->ftp_passok = FTPXY_ADAT_1;
641 ftp->ftp_incok = 1;
642 } else if ((ftp->ftp_passok == FTPXY_PAOK_1 ||
643 ftp->ftp_passok == FTPXY_PAOK_2) &&
645 ftp->ftp_passok = FTPXY_ACCT_1;
646 ftp->ftp_incok = 1;
647 } else if ((ftp
650 inc = ipf_p_ftp_port(softf, fin, ip, nat, ftp, dlen);
651 } else if ((ftp->ftp_passok == FTPXY_GO) &&
654 inc = ipf_p_ftp_eprt(softf, fin, ip, nat, ftp, dlen);
658 inc = ipf_p_ftp_port(softf, fin, ip, nat, ftp, dlen);
662 cmd, ftp->ftp_passok, ftp->ftp_incok, inc);
664 DT2(ftp_client_passok, char *, cmd, int, ftp->ftp_passok);
674 ftpinfo_t *ftp, int dlen)
684 (ftp->ftp_side[0].ftps_cmd != FTPXY_C_PASV)) {
685 DT2(ftp_PASV_error_state, nat_t *, nat, ftpinfo_t *, ftp);
688 ftp->ftp_side[0].ftps_cmd);
692 f = &ftp->ftp_side[1];
699 DT3(ftp_PASV_error_short, nat_t *, nat, ftpinfo_t *, ftp,
707 DT2(ftp_PASV_error_string, nat_t *, nat, ftpinfo_t *, ftp);
807 return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6),
813 nat_t *nat, ftpinfo_t *ftp, u_int port, char *newmsg, char *s)
832 if ((ftp->ftp_pendnat != NULL) || (ftp->ftp_pendstate != NULL))
833 ipf_p_ftp_setpending(softc, ftp);
842 f = &ftp->ftp_side[1];
888 nat2 = ipf_nat6_add(&fi, ipn, &ftp->ftp_pendnat,
892 nat2 = ipf_nat_add(&fi, ipn, &ftp->ftp_pendnat,
916 if (ipf_state_add(softc, &fi, (ipstate_t **)&ftp->ftp_pendstate,
954 ftpinfo_t *ftp, int dlen)
961 f = &ftp->ftp_side[1];
965 DT2(ftp_server_response, char *, rptr, int, ftp->ftp_passok);
972 rptr, ftp->ftp_passok);
973 if (ftp->ftp_passok == FTPXY_GO) {
975 inc = ipf_p_ftp_pasv(softf, fin, ip, nat, ftp, dlen);
977 inc = ipf_p_ftp_epsv(softf, fin, ip, nat, ftp, dlen);
985 inc = ipf_p_ftp_pasv(softf, fin, ip, nat, ftp, dlen);
987 inc = ipf_p_ftp_epsv(softf, fin, ip, nat, ftp, dlen);
989 ftp->ftp_passok = FTPXY_INIT;
990 else if (ftp->ftp_incok) {
992 if (ftp->ftp_passok == FTPXY_ACCT_1)
993 ftp->ftp_passok = FTPXY_GO;
995 ftp->ftp_passok++;
997 switch (ftp->ftp_passok)
1004 ftp->ftp_passok = FTPXY_GO;
1007 ftp->ftp_passok += 3;
1012 ftp->ftp_incok = 0;
1016 rptr, ftp->ftp_passok);
1017 DT3(ftp_server_passok, char *,rptr, int, ftp->ftp_incok,
1018 int, ftp->ftp_passok);
1034 * being the correct syntax for the FTP protocol.
1201 ipf_p_ftp_valid(ipf_ftp_softc_t *softf, ftpinfo_t *ftp, int side, char *buf,
1207 ftps = &ftp->ftp_side[side];
1227 ftpinfo_t *ftp, int rv)
1243 f = &ftp->ftp_side[rv];
1244 t = &ftp->ftp_side[1 - rv];
1444 f->ftps_junk = ipf_p_ftp_valid(softf, ftp, rv, rptr,
1470 f->ftps_junk = ipf_p_ftp_valid(softf, ftp, rv,
1486 nat, ftp, len);
1489 nat, ftp, len);
1497 * ftp proxy for this connection.
1568 ftpinfo_t *ftp;
1571 ftp = aps->aps_data;
1572 if (ftp == NULL)
1576 if (ftp->ftp_side[1 - rev].ftps_ifp == NULL)
1577 ftp->ftp_side[1 - rev].ftps_ifp = fin->fin_ifp;
1579 return ipf_p_ftp_process(softf, fin, nat, ftp, rev);
1587 ftpinfo_t *ftp;
1590 ftp = aps->aps_data;
1591 if (ftp == NULL)
1595 if (ftp->ftp_side[rev].ftps_ifp == NULL)
1596 ftp->ftp_side[rev].ftps_ifp = fin->fin_ifp;
1598 return ipf_p_ftp_process(softf, fin, nat, ftp, 1 - rev);
1635 ftpinfo_t *ftp, int dlen)
1655 f = &ftp->ftp_side[0];
1660 return ipf_p_ftp_eprt4(softf, fin, ip, nat, ftp, dlen);
1663 return ipf_p_ftp_eprt6(softf, fin, ip, nat, ftp, dlen);
1672 ftpinfo_t *ftp, int dlen)
1685 f = &ftp->ftp_side[0];
1809 return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc);
1815 ftpinfo_t *ftp, int dlen)
1823 (ftp->ftp_side[0].ftps_cmd != FTPXY_C_EPSV)) {
1824 DT1(epsv_cmd, int, ftp->ftp_side[0].ftps_cmd);
1827 ftp->ftp_side[0].ftps_cmd);
1830 f = &ftp->ftp_side[1];
1880 return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap,
1887 nat_t *nat, ftpinfo_t *ftp, int dlen)
1906 f = &ftp->ftp_side[0];
1908 f = &ftp->ftp_side[0];
2066 return ipf_p_ftp_addport(softf, fin, ip, nat, ftp, dlen, port, inc);