-Bugfix for 2614 (had forgotten read_ip subfunction)

-Bugfix in socket_send_tcp
-IPv4 now simply ignores options, but does not drop the packet
-refactored sys_network api code 

git-svn-id: svn://kolibrios.org@2621 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-04-17 18:41:58 +00:00
parent 263603725b
commit a83978c197
4 changed files with 43 additions and 68 deletions

View File

@ -200,8 +200,7 @@ macro IPv4_checksum ptr {
;
;-----------------------------------------------------------------
align 4
IPv4_input: ; TODO: implement handler for IP options
; TODO2: add code for raw sockets
IPv4_input: ; TODO: add code for raw sockets
DEBUGF 1,"IPv4_input, packet from: %u.%u.%u.%u ",\
[edx + IPv4_header.SourceAddress]:1,[edx + IPv4_header.SourceAddress + 1]:1,[edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1
@ -214,14 +213,6 @@ IPv4_input: ; TODO: implement handler for IP options
cmp byte [edx + IPv4_header.TimeToLive], 0
je .dump
;--------------------------------------
; First, check if IP packet has options
movzx eax, [edx + IPv4_header.VersionAndIHL]
and al , 0x0f ; get IHL(header length)
cmp al , 0x05 ; IHL!= 5*4(20 bytes)
jnz .has_options
;-------------------------------
; Now, re-calculate the checksum
@ -304,13 +295,13 @@ IPv4_input: ; TODO: implement handler for IP options
mov al , [edx + IPv4_header.Protocol]
add esi, edx ; make esi ptr to data
cmp al , IP_PROTO_TCP
cmp al, IP_PROTO_TCP
je TCP_input
cmp al , IP_PROTO_UDP
cmp al, IP_PROTO_UDP
je UDP_input
cmp al , IP_PROTO_ICMP
cmp al, IP_PROTO_ICMP
je ICMP_input
DEBUGF 2,"unknown Internet protocol: %u\n", al
@ -530,13 +521,6 @@ IPv4_input: ; TODO: implement handler for IP options
;-----------------------------------
; The IP packet has some options
.has_options:
jmp .dump
;-----------------------------------------------------------------
;
@ -949,7 +933,7 @@ IPv4_api:
movzx eax, bh
shl eax, 2
and ebx, 0xff
and ebx, 0x000000ff
cmp ebx, .number
ja .error
jmp dword [.table + 4*ebx]
@ -957,6 +941,7 @@ IPv4_api:
.table:
dd .packets_tx ; 0
dd .packets_rx ; 1
dd .read_ip ; 2
dd .write_ip ; 3
dd .read_dns ; 4
dd .write_dns ; 5

View File

@ -814,12 +814,13 @@ SOCKET_send_tcp:
push eax
add eax, STREAM_SOCKET.snd
call SOCKET_ring_write
mov [esp+32], ecx
pop eax
test ecx, ecx
jz s_error
mov [esp+32], ecx
call TCP_output
ret

View File

@ -589,82 +589,73 @@ sys_network: ; FIXME: make default device easily accessible
cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running
je .doesnt_exist
mov eax, [esi + NET_DRV_LIST]
and ebx, 0x000000ff
cmp ebx, .number
ja .doesnt_exist
jmp dword [.table + 4*ebx]
test bl, bl ; 0 = Get device type (ethernet/token ring/...)
jnz @f
.table:
dd .get_type ; 0
dd .get_dev_name ; 1
dd .reset ; 2
dd .stop ; 3
dd .get_ptr ; 4
dd .get_drv_name ; 5
dd .set_default ; 6
.number = ($ - .table) / 4 - 1
xor eax, eax
.get_type: ; 0 = Get device type (ethernet/token ring/...)
mov eax, [eax + NET_DEVICE.type]
jmp .return
@@:
dec bl ; 1 = Get device name
jnz @f
.get_dev_name: ; 1 = Get device name
mov esi, [esi + NET_DRV_LIST]
mov esi, [esi + NET_DEVICE.name]
mov esi, [eax + NET_DEVICE.name]
mov edi, ecx
mov ecx, 64 ; max length
repnz movsb
mov ecx, 64/4 ; max length
rep movsd
xor eax, eax
jmp .return
@@:
.reset: ; 2 = Reset the device
dec bl ; 2 = Reset the device
jnz @f
mov esi, [esi + NET_DRV_LIST]
call [esi + NET_DEVICE.reset]
call [eax + NET_DEVICE.reset]
jmp .return
@@:
.stop: ; 3 = Stop driver for this device
dec bl ; 3 = Stop driver for this device
jnz @f
mov esi, [esi + NET_DRV_LIST]
call [esi + NET_DEVICE.unload]
call [eax + NET_DEVICE.unload]
jmp .return
@@:
dec bl ; 4 = Get driver pointer
jnz @f
; ..;
.get_ptr: ; 4 = Get driver pointer
jmp .return
.get_drv_name: ; 5 = Get driver name
xor eax, eax
jmp .return
@@:
dec bl ; 5 = Get driver name
jnz @f
.set_default: ; 6 = Set default device
; ..;
xor eax, eax
jmp .return
@@:
dec bl ; 6 = Set default device
jnz @f
mov eax, esi
call NET_set_default
jmp .return
@@:
.doesnt_exist:
DEBUGF 1,"sys_network: invalid device/function specified!\n"
mov eax, -1
.return:
mov [esp+28+4], eax
mov [esp+32], eax
ret

View File

@ -589,9 +589,7 @@ align 4
;;; TODO: update stats
; set socket state to connected
mov [ebx + SOCKET.state],1 ;;;; FIXME
mov [ebx + SOCKET.state], SS_ISCONNECTED
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
;;; TODO: check if we should scale the connection (567-572)