forked from KolibriOS/kolibrios
Further development of the new FTP daemon (net branch)
git-svn-id: svn://kolibrios.org@2557 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c552138150
commit
a3b3514e59
@ -4,14 +4,18 @@
|
|||||||
align 4
|
align 4
|
||||||
parse_cmd: ; esi must point to command
|
parse_cmd: ; esi must point to command
|
||||||
|
|
||||||
|
cmp byte [esi+3], 0x20
|
||||||
|
jae @f
|
||||||
|
mov byte [esi+3], 0
|
||||||
|
@@:
|
||||||
|
|
||||||
mov eax, [esi]
|
mov eax, [esi]
|
||||||
and eax, not 0x20202020 ; convert to upper case
|
and eax, not 0x20202020 ; convert to upper case
|
||||||
; (also convert spaces to null)
|
; (also convert spaces to null)
|
||||||
mov edi, commands ; list of commands to scan
|
mov edi, commands ; list of commands to scan
|
||||||
.scanloop:
|
.scanloop:
|
||||||
cmp eax, [edi]
|
cmp eax, [edi]
|
||||||
jb .error
|
jne .try_next
|
||||||
jl .try_next
|
|
||||||
|
|
||||||
jmp dword [edi+4]
|
jmp dword [edi+4]
|
||||||
|
|
||||||
@ -21,11 +25,13 @@ parse_cmd: ; esi must point to command
|
|||||||
jne .scanloop
|
jne .scanloop
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
|
mcall send, [socketnum2], str500, str500.length, 0
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
commands: ; all commands must be in uppercase, and in alphabetical order.
|
commands: ; all commands must be in uppercase
|
||||||
|
|
||||||
db 'ABOR'
|
db 'ABOR'
|
||||||
dd cmdABOR
|
dd cmdABOR
|
||||||
@ -45,6 +51,9 @@ commands: ; all commands must be in uppercase, and
|
|||||||
db 'NOOP'
|
db 'NOOP'
|
||||||
dd cmdNOOP
|
dd cmdNOOP
|
||||||
|
|
||||||
|
db 'PASS'
|
||||||
|
dd cmdPASS
|
||||||
|
|
||||||
db 'PWD', 0
|
db 'PWD', 0
|
||||||
dd cmdPWD
|
dd cmdPWD
|
||||||
|
|
||||||
@ -105,6 +114,14 @@ cmdNOOP:
|
|||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
|
cmdPASS:
|
||||||
|
|
||||||
|
mcall send, [socketnum2], str230, str230.length, 0
|
||||||
|
mov [state], STATE_ACTIVE
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
cmdPWD:
|
cmdPWD:
|
||||||
|
|
||||||
@ -118,6 +135,9 @@ cmdPORT:
|
|||||||
align 4
|
align 4
|
||||||
cmdQUIT:
|
cmdQUIT:
|
||||||
|
|
||||||
|
mcall send, [socketnum2], str221, str221.length, 0
|
||||||
|
mcall close, [socketnum2]
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -133,6 +153,8 @@ cmdSTOR:
|
|||||||
align 4
|
align 4
|
||||||
cmdSYST:
|
cmdSYST:
|
||||||
|
|
||||||
|
mcall send, [socketnum2], str215, str215.length, 0
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
@ -143,6 +165,9 @@ cmdTYPE:
|
|||||||
align 4
|
align 4
|
||||||
cmdUSER:
|
cmdUSER:
|
||||||
|
|
||||||
|
mcall send, [socketnum2], str331, str331.length, 0
|
||||||
|
mov [state], STATE_LOGIN
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -150,14 +175,19 @@ cmdUSER:
|
|||||||
str150 db '150 Here it comes...', 13, 10
|
str150 db '150 Here it comes...', 13, 10
|
||||||
str200 db '200 Command OK.', 13, 10
|
str200 db '200 Command OK.', 13, 10
|
||||||
str215 db '215 UNIX type: L8', 13, 10
|
str215 db '215 UNIX type: L8', 13, 10
|
||||||
|
.length = $ - str215
|
||||||
str220 db '220 KolibriOS FTP Daemon 1.0', 13, 10
|
str220 db '220 KolibriOS FTP Daemon 1.0', 13, 10
|
||||||
.length = $ - str220
|
.length = $ - str220
|
||||||
str221 db '221 Bye!', 13, 10
|
str221 db '221 Bye!', 13, 10
|
||||||
|
.length = $ - str221
|
||||||
str225 db '225 Abort successful', 13, 10
|
str225 db '225 Abort successful', 13, 10
|
||||||
str226 db '226 Transfer OK, Closing connection', 13, 10
|
str226 db '226 Transfer OK, Closing connection', 13, 10
|
||||||
str230 db '230 You are now logged in.', 13, 10
|
str230 db '230 You are now logged in.', 13, 10
|
||||||
|
.length = $ - str230
|
||||||
str250 db '250 command successful', 13, 10
|
str250 db '250 command successful', 13, 10
|
||||||
str257 db '257 ""', 13, 10
|
str257 db '257 ""', 13, 10
|
||||||
str331 db '331 Please specify the password.', 13, 10
|
str331 db '331 Please specify the password.', 13, 10
|
||||||
|
.length = $ - str331
|
||||||
str500 db '500 Unsupported command', 13, 10
|
str500 db '500 Unsupported command', 13, 10
|
||||||
|
.length = $ - str500
|
||||||
str550 db '550 No such file', 13, 10
|
str550 db '550 No such file', 13, 10
|
||||||
|
@ -6,7 +6,12 @@
|
|||||||
; GPLv2
|
; GPLv2
|
||||||
;
|
;
|
||||||
|
|
||||||
BUFFERSIZE equ 4096
|
BUFFERSIZE = 4096
|
||||||
|
|
||||||
|
STATE_DISCONNECTED = 0
|
||||||
|
STATE_CONNECTED = 1
|
||||||
|
STATE_LOGIN = 2
|
||||||
|
STATE_ACTIVE = 3
|
||||||
|
|
||||||
|
|
||||||
use32
|
use32
|
||||||
@ -93,18 +98,20 @@ start:
|
|||||||
|
|
||||||
mov [socketnum2], eax
|
mov [socketnum2], eax
|
||||||
|
|
||||||
;; mcall close, [socketnum]
|
mcall send, [socketnum2], str220, str220.length, 0 ; send welcome string
|
||||||
|
|
||||||
mcall send, [socketnum2], str220, str220.length ; send welcome string
|
|
||||||
|
|
||||||
.loop:
|
.loop:
|
||||||
mcall 10
|
mcall 10
|
||||||
|
|
||||||
mcall recv, [socketnum2], buffer, buffer.length
|
mcall recv, [socketnum2], buffer, buffer.length
|
||||||
|
cmp eax, -1
|
||||||
|
je .loop
|
||||||
|
push eax
|
||||||
|
|
||||||
push buffer
|
push buffer
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
|
pop ecx
|
||||||
mov esi, buffer
|
mov esi, buffer
|
||||||
call parse_cmd
|
call parse_cmd
|
||||||
|
|
||||||
@ -140,7 +147,7 @@ exit:
|
|||||||
|
|
||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'KolibriOS FTP daemon 1.0',0
|
title db 'KolibriOS FTP daemon 0.1',0
|
||||||
str1 db 'Opening socket',10, 0
|
str1 db 'Opening socket',10, 0
|
||||||
str2 db 'Listening for incoming connections...',10,0
|
str2 db 'Listening for incoming connections...',10,0
|
||||||
str3 db 'Listen error',10,10,0
|
str3 db 'Listen error',10,10,0
|
||||||
@ -196,7 +203,11 @@ import libio, \
|
|||||||
i_end:
|
i_end:
|
||||||
|
|
||||||
socketnum dd ?
|
socketnum dd ?
|
||||||
|
|
||||||
|
|
||||||
|
; thread specific data
|
||||||
socketnum2 dd ?
|
socketnum2 dd ?
|
||||||
|
state dd ?
|
||||||
|
|
||||||
buffer rb BUFFERSIZE
|
buffer rb BUFFERSIZE
|
||||||
.length = BUFFERSIZE
|
.length = BUFFERSIZE
|
||||||
|
Loading…
Reference in New Issue
Block a user