forked from KolibriOS/kolibrios
User selectable port for telnet client. Also improved the interface a bit.
git-svn-id: svn://kolibrios.org@3574 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
f138c2f662
commit
c6825d97f1
@ -24,9 +24,9 @@ use32
|
|||||||
dd 1 ; header version
|
dd 1 ; header version
|
||||||
dd start ; entry point
|
dd start ; entry point
|
||||||
dd i_end ; initialized size
|
dd i_end ; initialized size
|
||||||
dd mem ; required memory
|
dd mem+4096 ; required memory
|
||||||
dd mem ; stack pointer
|
dd mem+4096 ; stack pointer
|
||||||
dd s ; parameters
|
dd hostname ; parameters
|
||||||
dd 0 ; path
|
dd 0 ; path
|
||||||
|
|
||||||
include '../macros.inc'
|
include '../macros.inc'
|
||||||
@ -53,7 +53,7 @@ start:
|
|||||||
call [con_init]
|
call [con_init]
|
||||||
|
|
||||||
; Check for parameters
|
; Check for parameters
|
||||||
cmp byte [s], 0
|
cmp byte [hostname], 0
|
||||||
jne resolve
|
jne resolve
|
||||||
|
|
||||||
main:
|
main:
|
||||||
@ -62,11 +62,12 @@ main:
|
|||||||
push str1
|
push str1
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
|
prompt:
|
||||||
; write prompt
|
; write prompt
|
||||||
push str2
|
push str2
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
; read string
|
; read string
|
||||||
mov esi, s
|
mov esi, hostname
|
||||||
push 256
|
push 256
|
||||||
push esi
|
push esi
|
||||||
call [con_gets]
|
call [con_gets]
|
||||||
@ -78,32 +79,60 @@ main:
|
|||||||
|
|
||||||
resolve:
|
resolve:
|
||||||
|
|
||||||
|
mov [sockaddr1.port], 23 shl 8
|
||||||
|
|
||||||
; delete terminating '\n'
|
; delete terminating '\n'
|
||||||
mov esi, s
|
mov esi, hostname
|
||||||
@@:
|
@@:
|
||||||
lodsb
|
lodsb
|
||||||
|
cmp al, ':'
|
||||||
|
je .do_port
|
||||||
cmp al, 0x20
|
cmp al, 0x20
|
||||||
ja @r
|
ja @r
|
||||||
mov byte [esi-1], 0
|
mov byte [esi-1], 0
|
||||||
|
jmp .done
|
||||||
|
|
||||||
call [con_cls]
|
.do_port:
|
||||||
push str3
|
xor eax, eax
|
||||||
call [con_write_asciiz]
|
xor ebx, ebx
|
||||||
push s
|
mov byte [esi-1], 0
|
||||||
call [con_write_asciiz]
|
.portloop:
|
||||||
|
lodsb
|
||||||
|
cmp al, 0x20
|
||||||
|
jbe .port_done
|
||||||
|
sub al, '0'
|
||||||
|
jb hostname_error
|
||||||
|
cmp al, 9
|
||||||
|
ja hostname_error
|
||||||
|
lea ebx, [ebx*4 + ebx]
|
||||||
|
shl ebx, 1
|
||||||
|
add ebx, eax
|
||||||
|
jmp .portloop
|
||||||
|
|
||||||
|
.port_done:
|
||||||
|
xchg bl, bh
|
||||||
|
mov [sockaddr1.port], bx
|
||||||
|
|
||||||
|
.done:
|
||||||
|
|
||||||
; resolve name
|
; resolve name
|
||||||
push esp ; reserve stack place
|
push esp ; reserve stack place
|
||||||
push esp ; fourth parameter
|
push esp ; ptr to result
|
||||||
push 0 ; third parameter
|
push 0 ; addrinfo hints
|
||||||
push 0 ; second parameter
|
push 0 ; servname
|
||||||
push s ; first parameter
|
push hostname; hostname
|
||||||
call [getaddrinfo]
|
call [getaddrinfo]
|
||||||
pop esi
|
pop esi
|
||||||
; test for error
|
; test for error
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz fail
|
jnz fail
|
||||||
|
|
||||||
|
call [con_cls]
|
||||||
|
push str3
|
||||||
|
call [con_write_asciiz]
|
||||||
|
push hostname
|
||||||
|
call [con_write_asciiz]
|
||||||
|
|
||||||
; write results
|
; write results
|
||||||
push str8
|
push str8
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
@ -217,16 +246,18 @@ fail2:
|
|||||||
push str6
|
push str6
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
|
|
||||||
jmp fail.wait
|
jmp prompt
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
push str5
|
push str5
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
.wait:
|
|
||||||
push str10
|
jmp prompt
|
||||||
|
|
||||||
|
hostname_error:
|
||||||
|
push str11
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
call [con_getch2]
|
jmp prompt
|
||||||
jmp main
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
push 1
|
push 1
|
||||||
@ -252,19 +283,21 @@ thread:
|
|||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'Telnet',0
|
title db 'Telnet',0
|
||||||
str1 db 'Telnet for KolibriOS v0.11',10,10,'Please enter URL of telnet server (for example: towel.blinkenlights.nl)',10,10,0
|
str1 db 'Telnet for KolibriOS',10,10,\
|
||||||
|
'Please enter URL of telnet server (for example: towel.blinkenlights.nl:23)',10,10,0
|
||||||
str2 db '> ',0
|
str2 db '> ',0
|
||||||
str3 db 'Connecting to: ',0
|
str3 db 'Connecting to ',0
|
||||||
str4 db 10,0
|
str4 db 10,0
|
||||||
str5 db 10,'Name resolution failed.',10,0
|
|
||||||
str6 db 10,'Could not open socket.',10,0
|
|
||||||
str8 db ' (',0
|
str8 db ' (',0
|
||||||
str9 db ')',10,0
|
str9 db ')',10,0
|
||||||
str10 db 'Push any key to continue.',0
|
|
||||||
|
str5 db 'Name resolution failed.',10,10,0
|
||||||
|
str6 db 'Could not open socket.',10,10,0
|
||||||
|
str11 db 'Invalid hostname.',10,10,0
|
||||||
|
|
||||||
sockaddr1:
|
sockaddr1:
|
||||||
dw AF_INET4
|
dw AF_INET4
|
||||||
.port dw 0x1700 ; 23
|
.port dw 0
|
||||||
.ip dd 0
|
.ip dd 0
|
||||||
rb 10
|
rb 10
|
||||||
|
|
||||||
@ -298,8 +331,8 @@ i_end:
|
|||||||
|
|
||||||
socketnum dd ?
|
socketnum dd ?
|
||||||
buffer_ptr rb BUFFERSIZE+1
|
buffer_ptr rb BUFFERSIZE+1
|
||||||
send_data rb 100
|
send_data rb 1
|
||||||
|
|
||||||
|
hostname rb 1024
|
||||||
|
|
||||||
s rb 1024
|
|
||||||
rb 4096 ; stack
|
|
||||||
mem:
|
mem:
|
||||||
|
Loading…
Reference in New Issue
Block a user