Тема: FTP server
Показать сообщение отдельно

  #2  
Старый 07.06.2008, 01:30
Delimiter
Banned
Регистрация: 08.04.2005
Сообщений: 446
Провел на форуме:
2187381

Репутация: 518
По умолчанию

на сервере порт 21-й с клиентской наплевать какой для режима пользователя(telnet)!
далее при попытке передачи... сервер вернет клиенту PORT N... и открывается 2-й коннект


пусть линуксоиды тебе кинут сорцы типа
ProFTPD - FTP server daemon


небольшой ftp.h
Код:
00001 
00005 /*
00006  * Copyright (c) 1983, 1989 Regents of the University of California.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. All advertising materials mentioning features or use of this software
00018  *    must display the following acknowledgement:
00019  *      This product includes software developed by the University of
00020  *      California, Berkeley and its contributors.
00021  * 4. Neither the name of the University nor the names of its contributors
00022  *    may be used to endorse or promote products derived from this software
00023  *    without specific prior written permission.
00024  *
00025  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00026  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00029  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00031  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00032  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00034  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035  * SUCH DAMAGE.
00036  *
00037  *      @(#)ftp.h       8.1 (Berkeley) 6/2/93
00038  */
00039 
00040 #ifndef __ARPA_FTP_H
00041 #define __ARPA_FTP_H
00042 
00043 /* Definitions for FTP; see RFC-765. */
00044 
00045 /*
00046  * Reply codes.
00047  */
00048 #define PRELIM          1       /* positive preliminary */
00049 #define COMPLETE        2       /* positive completion */
00050 #define CONTINUE        3       /* positive intermediate */
00051 #define TRANSIENT       4       /* transient negative completion */
00052 #undef  ERROR                   /* <wingdi.h> */
00053 #define ERROR           5       /* permanent negative completion */
00054 
00055 /*
00056  * Type codes
00057  */
00058 #define TYPE_A          1       /* ASCII */
00059 #define TYPE_E          2       /* EBCDIC */
00060 #define TYPE_I          3       /* image */
00061 #define TYPE_L          4       /* local byte size */
00062 
00063 #ifdef FTP_NAMES
00064 const char *typenames[] =  {"0", "ASCII", "EBCDIC", "Image", "Local" };
00065 #endif
00066 
00067 /*
00068  * Form codes
00069  */
00070 #define FORM_N          1       /* non-print */
00071 #define FORM_T          2       /* telnet format effectors */
00072 #define FORM_C          3       /* carriage control (ASA) */
00073 #ifdef FTP_NAMES
00074 const char *formnames[] =  {"0", "Nonprint", "Telnet", "Carriage-control" };
00075 #endif
00076 
00077 /*
00078  * Structure codes
00079  */
00080 #define STRU_F          1       /* file (no record structure) */
00081 #define STRU_R          2       /* record structure */
00082 #define STRU_P          3       /* page structure */
00083 #ifdef FTP_NAMES
00084 const char *strunames[] =  {"0", "File", "Record", "Page" };
00085 #endif
00086 
00087 /*
00088  * Mode types
00089  */
00090 #define MODE_S          1       /* stream */
00091 #define MODE_B          2       /* block */
00092 #define MODE_C          3       /* compressed */
00093 #ifdef FTP_NAMES
00094 const char *modenames[] =  {"0", "Stream", "Block", "Compressed" };
00095 #endif
00096 
00097 /*
00098  * Protection levels
00099  */
00100 #define PROT_C          1       /* clear */
00101 #define PROT_S          2       /* safe */
00102 #define PROT_P          3       /* private */
00103 #define PROT_E          4       /* confidential */
00104 
00105 #ifdef FTP_NAMES
00106 const char *levelnames[] =  {"0", "Clear", "Safe", "Private", "Confidential" };
00107 #endif
00108 
00109 #if defined(KERBEROS) && defined(NOENCRYPTION)
00110  /* Define away krb_rd_priv and krb_mk_priv.  Don't need them anyway.
00111   * This might not be the best place for this ...
00112   */
00113   #define krb_rd_priv(o,l,ses,s,h,c,m) krb_rd_safe(o,l,s,h,c,m)
00114   #define krb_mk_priv(i,o,l,ses,s,h,c) krb_mk_safe(i,o,l,s,h,c)
00115 #endif
00116 
00117 /*
00118  * Record Tokens
00119  */
00120 #define REC_ESC         '\377'  /* Record-mode Escape */
00121 #define REC_EOR         '\001'  /* Record-mode End-of-Record */
00122 #define REC_EOF         '\002'  /* Record-mode End-of-File */
00123 
00124 /*
00125  * Block Header
00126  */
00127 #define BLK_EOR         0x80    /* Block is End-of-Record */
00128 #define BLK_EOF         0x40    /* Block is End-of-File */
00129 #define BLK_ERRORS      0x20    /* Block is suspected of containing errors */
00130 #define BLK_RESTART     0x10    /* Block is Restart Marker */
00131 
00132 #define BLK_BYTECOUNT   2       /* Bytes in this block */
00133 
00134 #endif

Последний раз редактировалось Delimiter; 07.06.2008 в 02:10..