Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 2994 → Rev 2995

/kernel/branches/net/applications/ftpd/commands.inc
763,11 → 763,11
mov al, ','
stosb
; port
movzx eax, byte [ebp + thread_data.datasock.sin_port + 1]
movzx eax, byte [ebp + thread_data.datasock.sin_port]
call dword_to_ascii
mov al, ','
stosb
movzx eax, byte [ebp + thread_data.datasock.sin_port]
movzx eax, byte [ebp + thread_data.datasock.sin_port+1]
call dword_to_ascii
; ')', 13, 10, 0
mov eax, ')' + 0x000a0d00
843,14 → 843,11
; Now the same with portnumber
inc esi
call ascii_to_byte
mov bh, al
mov byte[ebp + thread_data.datasock.sin_port], al
inc esi
call ascii_to_byte
mov bl, al
mov byte[ebp + thread_data.datasock.sin_port+1], al
 
; Save it in datasock too
mov [ebp + thread_data.datasock.sin_port], bx
 
; We will open the socket, but do not connect yet!
mov [ebp + thread_data.datasock.sin_family], AF_INET4
mcall socket, AF_INET4, SOCK_STREAM, 0
/kernel/branches/net/applications/ftpd/ftpd.asm
126,8 → 126,10
mov [serverip], ebx
 
invoke ini.get_int, path, str_ftpd, str_port, 21
xchg al, ah
mov [sockaddr1.port], ax
 
xchg al, ah
invoke con_printf, str1, eax
add esp, 8
 
378,7 → 380,7
 
sockaddr1:
dw AF_INET4
.port dw 21
.port dw 0
.ip dd 0
rb 10
.length = $ - sockaddr1
/kernel/branches/net/applications/libraries/network/network.asm
689,7 → 689,7
push 0
push 0 ; sin_zero
push esi ; sin_addr
push AF_INET4 + (53 shl 16)
push AF_INET4 + (53 shl 24)
; sin_family and sin_port in network byte order
; 8c. Connect.
mcall 75, 4, , esp, sizeof.sockaddr_in
1204,7 → 1204,7
; Just copy port from input __gai_reqdata to output addrinfo.
push edx
mov edx, [ebx+__gai_reqdata.service]
xchg dl, dh ; convert to network byte order
xchg dl, dh ; convert to network byte order ;;;;; CHECKME
mov [edi+sizeof.addrinfo+sockaddr_in.sin_port], dx
pop edx
ret
/kernel/branches/net/applications/synergyc/synergyc.asm
29,7 → 29,9
__DEBUG__ equ 1 ; enable/disable
__DEBUG_LEVEL__ equ 1 ; 1 = all, 2 = errors
 
 
BUFFERSIZE equ 1024
DEFAULTPORT equ 24800
 
include '../macros.inc'
purge mov,add,sub
79,7 → 81,8
test eax, eax
jnz error
 
invoke ini.get_int, path, str_remote, str_port, 24800
invoke ini.get_int, path, str_remote, str_port, DEFAULTPORT
xchg al, ah
mov [sockaddr1.port], ax
 
push str1
337,7 → 340,7
 
sockaddr1:
dw AF_INET4
.port dw 24800
.port dw 0
.ip dd 192 + 168 shl 8 + 1 shl 16 + 115 shl 24
rb 10
 
/kernel/branches/net/applications/tcpserv/tcpserv.asm
135,7 → 135,7
 
sockaddr1:
dw AF_INET4
.port dw 23
.port dw 0x1700 ; 23
.ip dd 0
rb 10
.length = $ - sockaddr1
/kernel/branches/net/applications/telnet/telnet.asm
264,7 → 264,7
 
sockaddr1:
dw AF_INET4
.port dw 23
.port dw 0x1700 ; 23
.ip dd 0
rb 10
 
/kernel/branches/net/applications/tftpc/tftpc.asm
451,7 → 451,7
 
sockaddr:
dw AF_INET4
dw 69
dw 0x4500 ; 69
IP db 192,168,1,115
sockaddr_len = $ - sockaddr
 
/kernel/branches/net/applications/vncc/vncc.asm
238,7 → 238,7
 
sockaddr1:
dw AF_INET4
.port dw 5900
.port dw 0x0c17 ; 5900
.ip dd 0
rb 10
 
/kernel/branches/net/applications/zeroconf/zeroconf.asm
548,7 → 548,7
sockaddr1:
 
dw AF_INET4
dw 68 ; local port
dw 68 shl 8 ; local port
dd 0 ; local IP
 
rb 10
557,7 → 557,7
sockaddr2:
 
dw AF_INET4
dw 67 ; destination port
dw 67 shl 8 ; destination port
dd -1 ; destination IP
 
rb 10
/kernel/branches/net/network/socket.inc
44,15 → 44,15
 
struct IP_SOCKET SOCKET
 
LocalIP rd 4
RemoteIP rd 4
LocalIP rd 4 ; network byte order
RemoteIP rd 4 ; network byte order
 
ends
 
struct TCP_SOCKET IP_SOCKET
 
LocalPort dw ?
RemotePort dw ?
LocalPort dw ? ; network byte order
RemotePort dw ? ; network byte order
 
t_state dd ? ; TCB state
t_rxtshift db ?
141,8 → 141,8
 
struct UDP_SOCKET IP_SOCKET
 
LocalPort dw ?
RemotePort dw ?
LocalPort dw ? ; network byte order
RemotePort dw ? ; network byte order
firstpacket db ?
 
ends
213,6 → 213,7
jb @r
cmp ax, MAX_EPHEMERAL_PORT
ja @r
xchg al, ah
mov [last_UDP_port], ax
 
@@:
221,6 → 222,7
jb @r
cmp ax, MAX_EPHEMERAL_PORT
ja @r
xchg al, ah
mov [last_TCP_port], ax
 
}
446,7 → 448,7
@@:
mov [eax + IP_SOCKET.LocalIP], ebx
 
mov bx, [edx + 2] ; Now fill in the port if it's still available
mov bx, [edx + 2] ; Now fill in the local port if it's still available
call SOCKET_check_port
jz s_error ; ZF is set by socket_check_port, on error
 
1106,11 → 1108,6
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
je .tcp
 
jmp .error
 
.done:
mov [eax + UDP_SOCKET.LocalPort], bx
.error:
pop ecx esi ebx
ret
 
1118,26 → 1115,30
mov bx, [last_UDP_port]
call .findit
mov [last_UDP_port], bx
jmp .done
 
pop ecx esi ebx
ret
 
.tcp:
mov bx, [last_TCP_port]
call .findit
mov [last_TCP_port], bx
jmp .done
 
pop ecx esi ebx
ret
 
 
.restart:
mov bx, MIN_EPHEMERAL_PORT
mov bx, MIN_EPHEMERAL_PORT_N
.findit:
inc bx
cmp bx, MAX_EPHEMERAL_PORT_N
je .restart
 
cmp bx, MAX_EPHEMERAL_PORT
jz .restart
add bh, 1
adc bl, 0
 
call SOCKET_check_port
jz .findit
 
ret
 
 
1150,9 → 1151,9
; If the proposed port number is unused, it is filled in in the socket structure
;
; IN: eax = socket ptr (to find out if its a TCP/UDP socket)
; bx = proposed socket number
; bx = proposed socket number (network byte order)
;
; OUT: ZF = cleared on error
; OUT: ZF = set on error
;
;-----------------------------------------------------------------
align 4
1182,10 → 1183,9
ret
 
.port_ok:
DEBUGF 1,"local port %u is free\n", bx
DEBUGF 1,"local port %x is free\n", bx ; FIXME: find a way to print big endian values with debugf
mov [eax + UDP_SOCKET.LocalPort], bx
or bx, bx ; set the zero-flag
 
or bx, bx ; clear the zero-flag
ret
 
 
/kernel/branches/net/network/stack.inc
34,7 → 34,9
MAX_NET_DEVICES = 16
 
MIN_EPHEMERAL_PORT = 49152
MIN_EPHEMERAL_PORT_N = 0x00C0 ; same in Network byte order (FIXME)
MAX_EPHEMERAL_PORT = 61000
MAX_EPHEMERAL_PORT_N = 0x48EE ; same in Network byte order (FIXME)
 
; Ethernet protocol numbers
ETHER_ARP = 0x0608
/kernel/branches/net/network/tcp_input.inc
76,8 → 76,6
 
ntohw [edx + TCP_header.Window]
ntohw [edx + TCP_header.UrgentPointer]
ntohw [edx + TCP_header.SourcePort]
ntohw [edx + TCP_header.DestinationPort]
 
;------------------------
; Find the socket pointer
/kernel/branches/net/network/tcp_output.inc
425,10 → 425,7
ntohd [esp]
 
push [eax + TCP_SOCKET.RemotePort] ; .DestinationPort dw ?
ntohw [esp]
 
push [eax + TCP_SOCKET.LocalPort] ; .SourcePort dw ?
ntohw [esp]
 
push edi ; header size
 
/kernel/branches/net/network/tcp_subr.inc
348,10 → 348,8
; Fill in the TCP header by using the socket ptr
 
mov ax, [esi + TCP_SOCKET.LocalPort]
rol ax, 8
stosw
mov ax, [esi + TCP_SOCKET.RemotePort]
rol ax, 8
stosw
mov eax, [esi + TCP_SOCKET.SND_NXT]
bswap eax
429,10 → 427,8
; Fill in the TCP header by using a received segment
 
mov ax, [esi + TCP_header.DestinationPort]
rol ax, 8
stosw
mov ax, [esi + TCP_header.SourcePort]
rol ax, 8
stosw
mov eax, [esi + TCP_header.AckNumber]
bswap eax
/kernel/branches/net/network/udp.inc
131,10 → 131,8
.no_checksum:
DEBUGF 1,"UDP_input: checksum ok\n"
 
; Convert port numbers to intel format
; Convert length to little endian
 
rol [esi + UDP_header.DestinationPort], 8
rol [esi + UDP_header.SourcePort], 8
rol [esi + UDP_header.Length], 8
 
; Look for a socket where
198,7 → 196,7
call mutex_lock
popa
 
DEBUGF 1,"UDP_input: new remote port=%u\n", cx
DEBUGF 1,"UDP_input: new remote port=%x\n", cx ; FIXME: find a way to print big endian values with debugf
mov [eax + UDP_SOCKET.RemotePort], cx
inc [eax + UDP_SOCKET.firstpacket]
 
234,12 → 232,10
DEBUGF 1,"UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
 
mov dx, [eax + UDP_SOCKET.RemotePort]
DEBUGF 1,"UDP_output: remote port=%u, ", dx
rol dx, 8
DEBUGF 1,"UDP_output: remote port=%x, ", dx ; FIXME: find a way to print big endian values with debugf
rol edx, 16
mov dx, [eax + UDP_SOCKET.LocalPort]
DEBUGF 1,"local port=%u\n", dx
rol dx, 8
DEBUGF 1,"local port=%x\n", dx
 
sub esp, 8 ; Data ptr and data size will be placed here
push edx esi