Rev 2598 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2598 | Rev 2602 | ||
---|---|---|---|
Line 94... | Line 94... | ||
94 | movsd |
94 | movsd |
95 | movsd |
95 | movsd |
96 | movsw |
96 | movsw |
Line 97... | Line 97... | ||
97 | 97 | ||
98 | ; initialize console |
- | |
99 | push 1 |
98 | ; initialize console |
100 | call [con_start] |
- | |
101 | - | ||
102 | push title |
- | |
103 | push -1 |
- | |
104 | push -1 |
- | |
105 | push -1 |
- | |
106 | push -1 |
99 | invoke con_start, 1 |
Line 107... | Line 100... | ||
107 | call [con_init] |
100 | invoke con_init, -1, -1, -1, -1, title |
Line 108... | Line 101... | ||
108 | 101 | ||
109 | mcall 40, 1 shl 7 ; we only want network events |
102 | mcall 40, 1 shl 7 ; we only want network events |
Line 114... | Line 107... | ||
114 | mov [serverip], ebx |
107 | mov [serverip], ebx |
Line 115... | Line 108... | ||
115 | 108 | ||
116 | invoke ini.get_int, path, str_ftpd, str_port, 21 |
109 | invoke ini.get_int, path, str_ftpd, str_port, 21 |
Line 117... | Line -... | ||
117 | mov [sockaddr1.port], ax |
- | |
118 | - | ||
119 | push eax |
110 | mov [sockaddr1.port], ax |
Line 120... | Line 111... | ||
120 | push str1 |
111 | |
121 | call [con_printf] |
112 | invoke con_printf, str1, eax |
122 | 113 | ||
123 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
- | |
124 | cmp eax, -1 |
114 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
Line 125... | Line -... | ||
125 | je sock_err |
- | |
126 | 115 | cmp eax, -1 |
|
Line 127... | Line 116... | ||
127 | mov [socketnum], eax |
116 | je sock_err |
128 | 117 | mov [socketnum], eax |
|
129 | push str2 |
118 | |
Line 130... | Line 119... | ||
130 | call [con_write_asciiz] |
119 | invoke con_write_asciiz, str2 |
131 | 120 | ||
132 | ; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
121 | ; mcall setsockopt, [socketnum], SOL_SOCKET, SO_REUSEADDR, &yes, |
Line 133... | Line -... | ||
133 | ; cmp eax, -1 |
- | |
134 | ; je opt_err |
122 | ; cmp eax, -1 |
Line 135... | Line 123... | ||
135 | 123 | ; je opt_err |
|
136 | mcall bind, [socketnum], sockaddr1, sockaddr1.length |
124 | |
Line 137... | Line -... | ||
137 | cmp eax, -1 |
- | |
138 | je bind_err |
125 | mcall bind, [socketnum], sockaddr1, sockaddr1.length |
Line 139... | Line 126... | ||
139 | 126 | cmp eax, -1 |
|
140 | push str2 |
127 | je bind_err |
141 | call [con_write_asciiz] |
128 | |
Line 142... | Line -... | ||
142 | - | ||
143 | invoke ini.get_int, path, str_ftpd, str_conn, 1 ; Backlog (max connections) |
129 | invoke con_write_asciiz, str2 |
Line 144... | Line 130... | ||
144 | mov edx, eax |
130 | |
145 | 131 | invoke ini.get_int, path, str_ftpd, str_conn, 1 ; Backlog (max connections) |
|
Line 146... | Line 132... | ||
146 | push str2 |
132 | mov edx, eax |
Line 170... | Line 156... | ||
170 | push eax ; save pointer to thread_data on stack |
156 | push eax ; save pointer to thread_data on stack |
171 | mov ebp, esp |
157 | mov ebp, esp |
Line 172... | Line 158... | ||
172 | 158 | ||
Line 173... | Line -... | ||
173 | mcall 40, 1 shl 7 ; we only want network events for this thread |
- | |
174 | 159 | mcall 40, 1 shl 7 ; we only want network events for this thread |
|
175 | pushd 0x03 |
- | |
176 | call [con_set_flags] |
160 | |
177 | push str8 |
- | |
178 | call [con_write_asciiz] ; print on the console that we have created the new thread successfully |
161 | invoke con_set_flags, 0x03 |
Line 179... | Line 162... | ||
179 | pushd 0x07 |
162 | invoke con_write_asciiz, str8 ; print on the console that we have created the new thread successfully |
180 | call [con_set_flags] |
163 | invoke con_set_flags, 0x07 |
181 | 164 | ||
182 | mcall accept, [socketnum], sockaddr1, sockaddr1.length ; time to accept the awaiting connection.. |
165 | mcall accept, [socketnum], sockaddr1, sockaddr1.length ; time to accept the awaiting connection.. |
Line 193... | Line 176... | ||
193 | 176 | ||
Line 194... | Line 177... | ||
194 | sendFTP "220 Welcome to KolibriOS FTP daemon" |
177 | sendFTP "220 Welcome to KolibriOS FTP daemon" |
195 | 178 | ||
196 | threadloop: |
- | |
197 | mcall 10 |
179 | threadloop: |
Line 198... | Line 180... | ||
198 | 180 | mcall 10 |
|
199 | mov edx, [ebp] ; pointer to thread_data |
181 | mov edx, [ebp] ; pointer to thread_data |
- | 182 | ||
200 | 183 | cmp [edx + thread_data.mode], MODE_PASSIVE_WAIT |
|
201 | cmp [edx + thread_data.mode], MODE_PASSIVE_WAIT |
184 | jne .not_passive |
202 | jne .not_passive |
185 | mov [edx + thread_data.mode], MODE_PASSIVE_FAILED ; assume that we will fail |
203 | mov ecx, [edx + thread_data.passivesocknum] |
186 | mov ecx, [edx + thread_data.passivesocknum] |
204 | lea edx, [edx + thread_data.datasock] |
187 | lea edx, [edx + thread_data.datasock] |
205 | mov esi, sizeof.thread_data.datasock |
188 | mov esi, sizeof.thread_data.datasock |
206 | mcall accept |
189 | mcall accept |
207 | mov edx, [ebp] ; pointer to thread_data |
190 | mov edx, [ebp] ; pointer to thread_data |
208 | cmp eax, -1 |
191 | cmp eax, -1 |
Line 209... | Line 192... | ||
209 | je .not_passive |
192 | je .not_passive |
210 | mov [edx + thread_data.datasocketnum], eax |
- | |
211 | mov [edx + thread_data.mode], MODE_PASSIVE_FAILED |
193 | mov [edx + thread_data.datasocketnum], eax |
Line 212... | Line 194... | ||
212 | 194 | mov [edx + thread_data.mode], MODE_PASSIVE_OK |
|
213 | push str_datasock |
195 | |
214 | call [con_write_asciiz] ; print on the console that the datasock is now ready |
196 | invoke con_write_asciiz, str_datasock |
Line 232... | Line 214... | ||
232 | mov al, 13 |
214 | mov al, 13 |
233 | repne scasb |
215 | repne scasb |
234 | jne threadloop |
216 | jne threadloop |
Line 235... | Line 217... | ||
235 | 217 | ||
- | 218 | ; We got a command! |
|
236 | ; We got a command! |
219 | mov byte [edi + 1], 0 ; append string with zero byte |
237 | lea eax, [edx + thread_data.buffer] |
220 | lea esi, [edx + thread_data.buffer] |
238 | mov ecx, [edx + thread_data.buffer_ptr] |
221 | mov ecx, [edx + thread_data.buffer_ptr] |
239 | sub ecx, eax |
- | |
240 | push ecx ; push full data size on stack |
222 | sub ecx, esi |
241 | mov [edx + thread_data.buffer_ptr], eax ; reset buffer ptr |
- | |
242 | - | ||
243 | push eax;;;; |
- | |
244 | pushd 0x02 ; print received data to console (in green color) |
- | |
245 | call [con_set_flags] |
- | |
246 | push str_newline |
- | |
247 | call [con_write_asciiz] |
- | |
248 | ;;;; push eax |
- | |
249 | call [con_write_asciiz] |
- | |
250 | pushd 0x07 |
- | |
Line 251... | Line -... | ||
251 | call [con_set_flags] |
- | |
252 | 223 | mov [edx + thread_data.buffer_ptr], esi ; reset buffer ptr |
|
- | 224 | ||
253 | mov edx, [ebp] |
225 | invoke con_set_flags, 0x02 ; print received data to console (in green color) |
254 | pop ecx ; number of bytes read |
226 | invoke con_write_asciiz, str_newline |
Line 255... | Line 227... | ||
255 | lea esi, [edx + thread_data.buffer] |
227 | invoke con_write_asciiz, esi |
- | 228 | invoke con_set_flags, 0x07 |
|
Line 256... | Line 229... | ||
256 | call parse_cmd |
229 | |
257 | - | ||
258 | jmp threadloop |
230 | push threadloop |
259 | - | ||
260 | listen_err: |
231 | jmp parse_cmd |
261 | pushd 0x0c |
232 | |
Line 262... | Line 233... | ||
262 | call [con_set_flags] |
233 | listen_err: |
263 | push str3 |
- | |
264 | call [con_write_asciiz] |
234 | invoke con_set_flags, 0x0c ; print received data to console (in green color) |
265 | jmp done |
- | |
266 | 235 | invoke con_write_asciiz, str3 |
|
267 | bind_err: |
236 | jmp done |
Line 268... | Line 237... | ||
268 | pushd 0x0c |
237 | |
269 | call [con_set_flags] |
- | |
270 | push str4 |
238 | bind_err: |
271 | call [con_write_asciiz] |
- | |
272 | jmp done |
239 | invoke con_set_flags, 0x0c ; print received data to console (in green color) |
273 | 240 | invoke con_write_asciiz, str4 |
|
Line 274... | Line 241... | ||
274 | sock_err: |
241 | jmp done |
275 | pushd 0x0c |
242 | |
276 | call [con_set_flags] |
- | |
277 | push str6 |
243 | sock_err: |
278 | call [con_write_asciiz] |
244 | invoke con_set_flags, 0x0c ; print received data to console (in green color) |
279 | jmp done |
245 | invoke con_write_asciiz, str6 |
Line 280... | Line 246... | ||
280 | 246 | jmp done |
|
281 | done: |
247 | |
282 | call [con_getch2] |
248 | done: |
283 | push 1 |
249 | invoke con_getch2 |
284 | call [con_exit] |
250 | invoke con_exit, 1 |
285 | exit: |
251 | exit: |
Line 308... | Line 274... | ||
308 | str7 db 'Got data!',10,10,0 |
274 | str7 db 'Got data!',10,10,0 |
309 | str8 db 10,'New thread created!',10,0 |
275 | str8 db 10,'New thread created!',10,0 |
310 | str_bye db 10,'Closing thread!',10,0 |
276 | str_bye db 10,'Closing thread!',10,0 |
Line 311... | Line 277... | ||
311 | 277 | ||
312 | str_logged_in db 'Login ok',10,0 |
278 | str_logged_in db 'Login ok',10,0 |
313 | str_pass_ok db 'Password ok - Logged in',10,0 |
279 | str_pass_ok db 'Password ok',10,0 |
314 | str_pwd db 'Current directory is "%s"\n',0 |
280 | str_pwd db 'Current directory is "%s"\n',0 |
315 | str_err2 db 'ERROR: cannot open directory',10,0 |
281 | str_err2 db 'ERROR: cannot open directory',10,0 |
316 | str_datasock db 'Passive data socket connected!',10,0 |
282 | str_datasock db 'Passive data socket connected!',10,0 |
317 | str_notfound db 'ERROR: file not found',10,0 |
283 | str_notfound db 'ERROR: file not found',10,0 |
Line 318... | Line 284... | ||
318 | str_sockerr db 'ERROR: socket error',10,0 |
284 | str_sockerr db 'ERROR: socket error',10,0 |
Line 319... | Line 285... | ||
319 | 285 | ||
320 | str_login_invalid db 'Login invalid',10,0 |
286 | str_login_invalid db 'Login invalid',10,0 |
- | 287 | ||
Line 321... | Line 288... | ||
321 | 288 | str_newline db 10, 0 |
|
322 | str_newline db 10, 0 |
289 | str_mask db '*', 0 |
323 | str_mask db '*', 0 |
290 | str_infinity db 0xff, 0xff, 0xff, 0xff, 0 |
324 | 291 |