-Fixed bug #150: ping reply length

-Fixed bug where some commands were terminated with \n\r instead of \r\n

git-svn-id: svn://kolibrios.org@9979 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2024-02-23 21:15:46 +00:00
parent 32b5aca57d
commit 1c69f80f04
4 changed files with 22 additions and 22 deletions

View File

@ -13,7 +13,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
version equ '0.35' version equ '0.35b'
; connection status ; connection status
STATUS_DISCONNECTED = 0 STATUS_DISCONNECTED = 0

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2021. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Written by hidnplayr@kolibrios.org ;; ;; Written by hidnplayr@kolibrios.org ;;
@ -14,6 +14,7 @@
server_parser: server_parser:
mov esi, servercommand mov esi, servercommand
mov ebx, ecx
cmp byte [esi], ':' cmp byte [esi], ':'
jne .parse jne .parse
@ -27,7 +28,7 @@ server_parser:
.parse: .parse:
mov eax, [esi] mov eax, [esi]
or eax, 0x20202020 or eax, 0x20202020 ; convert to lowercase
mov edi, server_commands mov edi, server_commands
mov ecx, server_commands.number mov ecx, server_commands.number
@ -42,6 +43,7 @@ server_parser:
ret ret
.got_cmd: .got_cmd:
mov ecx, ebx
jmp dword[edi] jmp dword[edi]
@ -232,18 +234,12 @@ cmd_ping:
; Just change PING to PONG ; Just change PING to PONG
mov dword[esi], 'PONG' mov dword[esi], 'PONG'
; Find the end of the command ; Append \r\n
lea edi, [esi + 5] mov word[esi+ecx], 0x0a0d
xor al, al
repne scasb
; Now send it back ; And send the response to the server
mov edx, esi mov edx, esi
mov esi, edi lea esi, [ecx+2]
mov word [esi], 0x0d0a
inc esi
inc esi
sub esi, edx
mcall send, [socketnum], , , 0 mcall send, [socketnum], , , 0
ret ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Written by hidnplayr@kolibrios.org ;; ;; Written by hidnplayr@kolibrios.org ;;
@ -226,26 +226,30 @@ socket_receive:
.nextcommand: .nextcommand:
mov edi, servercommand mov edi, servercommand
.byteloop: .byteloop:
test ecx, ecx
jz .nextpacket
lodsb lodsb
dec ecx
cmp al, 10 cmp al, 10
je .got_command je .got_command
cmp al, 13 cmp al, 13
je .got_command je .got_command
stosb stosb
dec ecx jmp .byteloop
jnz .byteloop
;;; FIXME
jmp .nextpacket
; we have a command, call the serverparser ; we have a command, call the serverparser
.got_command: .got_command:
cmp edi, servercommand + 4
jb .nextcommand
mov byte[edi], 0 ; mark the end of the command mov byte[edi], 0 ; mark the end of the command
push esi ecx push esi ecx
mov ecx, edi
sub ecx, servercommand ; put length in ecx
call server_parser call server_parser
pop ecx esi pop ecx esi
test ecx, ecx jmp .nextcommand
jnz .nextcommand
.done: .done:
popa popa

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2018. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2024. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Written by hidnplayr@kolibrios.org ;; ;; Written by hidnplayr@kolibrios.org ;;
@ -659,7 +659,7 @@ cmd_usr_send:
mov esi, [user_command.size] mov esi, [user_command.size]
mov eax, [user_command.size] mov eax, [user_command.size]
add eax, user_command+1 add eax, user_command+1
mov word[eax], 0x0d0a mov word[eax], 0x0a0d
inc esi inc esi
mcall send, [socketnum], user_command+1, , 0 mcall send, [socketnum], user_command+1, , 0