1 
2 /*
3 
4     File: ftpproxy/ftp.h
5 
6     Copyright (C) 1999  Wolfgang Zekoll  <wzk@quietsche-entchen.de>
7     Copyright (C) 2000, 2003  Andreas Schoenberg  <asg@ftpproxy.org>
8 
9     This software is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13 
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 
23  */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #ifndef	_FTP_INCLUDED
30 #define	_FTP_INCLUDED
31 
32 extern char *version;
33 
34 extern char *program;
35 extern char progname[80];
36 
37 extern int debug;
38 extern int extralog;
39 extern int bindport;
40 extern int daemonmode;
41 
42 extern int acceptloop(int sock);
43 
44 #define	FTPMAXBSIZE		4096
45 
46 
47 typedef struct _config {
48     char	configfile[200];
49 
50     int		standalone;
51     int		timeout;
52 
53     int		selectserver;
54     int		allow_anyremote;
55 
56     char	server[200];
57     char	*serverlist;
58 
59     char	acp[200];
60     char	ccp[200];
61     char	ctp[200];
62     char	varname[80];
63 
64     int		allow_blanks;
65     int		allow_passwdblanks;
66     int		use_last_at;
67     int		monitor;
68     int		bsize;
69     char	xferlog[200];
70 
71     int		numeric_only;
72     char	sourceip[200];
73     unsigned int dataport;
74     } config_t;
75 
76 
77 #define	DIR_MAXDEPTH		15
78 
79 
80 #define	CCP_OK			0
81 #define	CCP_ERROR		1
82 
83 
84 #define	PORT_LISTEN		1
85 #define	PORT_CONNECTED		2
86 #define	PORT_CLOSED		3
87 
88 #define	MODE_PORT		1
89 #define	MODE_PASSIVE		2
90 
91 #define	OP_GET			1
92 #define	OP_PUT			2
93 
94 #define	TYPE_ASC		1	/* Transfer modes for xferlog */
95 #define	TYPE_BIN		2
96 
97 typedef struct _port {
98     char	ipnum[80];
99     unsigned int port;
100     } port_t;
101 
102 typedef struct _dtc {
103     int		state;		/* LISTEN, CONNECTED, CLOSED */
104     int		seen150;
105 
106     int		isock;
107     int		osock;
108 
109     int		operation;	/* GET oder PUT */
110     int		active;
111     int		other;
112 
113     int		mode;		/* PORT oder PASV */
114     port_t	server;
115     port_t	outside;
116     port_t	inside;
117     port_t	client;
118 
119     int		type;		/* Transfer type for xferlog */
120     unsigned long started;	/* Timestamp for xferlog */
121 
122     char	command[20];	/* Fuer syslog Meldungen */
123     char	filename[200];
124     unsigned long bytes;
125     } dtc_t;
126 
127 
128 typedef struct _bio {
129     int		here, len;
130     char	buffer[512];
131     } bio_t;
132 
133 
134 typedef struct _ftp {
135     config_t	*config;
136 
137     char	interface[80];
138     unsigned int port;
139 
140     char	client[200];
141     char	client_ip[80];
142 
143     char	username[200];
144     char	password[200];
145 
146     struct {
147 	char	username[80];
148 	char	password[80];
149 	} local;
150 
151     struct {
152 	char	name[80];
153 	unsigned int port;
154 
155 	char	ipnum[80];
156 	} server;
157 
158     struct {
159 	int		server;		/* Kontrollverbindung zum Server */
160 
161 	int		cfd;		/* Datenverbindung zum Client */
162 	int		sfd;		/* Datenverbindung zum Server */
163 
164 	fd_set		fdset;
165 	int		max;
166 	} fd;
167 
168     dtc_t		ch;
169     char		cwd[200];
170     char		home[200];
171     char		filepath[200];
172 
173     bio_t		cbuf, sbuf;
174 
175     char		session[80];
176     int			ccpcoll;
177 
178     FILE		*xlfp;
179     char		logusername[100];
180 
181     int			commands;
182     unsigned long datain, dataout;
183     } ftp_t;
184 
185 
186 extern int readconfig(config_t *config, char *filename, char *section);
187 extern int printconfig(config_t *config);
188 
189 extern int proxy_request(config_t *config);
190 
191 #endif
192 
193