1
0

-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
kernel/branches/net/network

View File

@ -200,8 +200,7 @@ macro IPv4_checksum ptr {
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
IPv4_input: ; TODO: implement handler for IP options IPv4_input: ; TODO: add code for raw sockets
; TODO2: add code for raw sockets
DEBUGF 1,"IPv4_input, packet from: %u.%u.%u.%u ",\ 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 [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 cmp byte [edx + IPv4_header.TimeToLive], 0
je .dump 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 ; Now, re-calculate the checksum
@ -304,13 +295,13 @@ IPv4_input: ; TODO: implement handler for IP options
mov al , [edx + IPv4_header.Protocol] mov al , [edx + IPv4_header.Protocol]
add esi, edx ; make esi ptr to data add esi, edx ; make esi ptr to data
cmp al , IP_PROTO_TCP cmp al, IP_PROTO_TCP
je TCP_input je TCP_input
cmp al , IP_PROTO_UDP cmp al, IP_PROTO_UDP
je UDP_input je UDP_input
cmp al , IP_PROTO_ICMP cmp al, IP_PROTO_ICMP
je ICMP_input je ICMP_input
DEBUGF 2,"unknown Internet protocol: %u\n", al 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 movzx eax, bh
shl eax, 2 shl eax, 2
and ebx, 0xff and ebx, 0x000000ff
cmp ebx, .number cmp ebx, .number
ja .error ja .error
jmp dword [.table + 4*ebx] jmp dword [.table + 4*ebx]
@ -957,6 +941,7 @@ IPv4_api:
.table: .table:
dd .packets_tx ; 0 dd .packets_tx ; 0
dd .packets_rx ; 1 dd .packets_rx ; 1
dd .read_ip ; 2
dd .write_ip ; 3 dd .write_ip ; 3
dd .read_dns ; 4 dd .read_dns ; 4
dd .write_dns ; 5 dd .write_dns ; 5

View File

@ -814,12 +814,13 @@ SOCKET_send_tcp:
push eax push eax
add eax, STREAM_SOCKET.snd add eax, STREAM_SOCKET.snd
call SOCKET_ring_write call SOCKET_ring_write
mov [esp+32], ecx
pop eax pop eax
test ecx, ecx test ecx, ecx
jz s_error jz s_error
mov [esp+32], ecx
call TCP_output call TCP_output
ret 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 cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running
je .doesnt_exist 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/...) .table:
jnz @f 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 jmp .return
@@: .get_dev_name: ; 1 = Get device name
dec bl ; 1 = Get device name
jnz @f
mov esi, [esi + NET_DRV_LIST] mov esi, [eax + NET_DEVICE.name]
mov esi, [esi + NET_DEVICE.name]
mov edi, ecx mov edi, ecx
mov ecx, 64 ; max length mov ecx, 64/4 ; max length
repnz movsb rep movsd
xor eax, eax xor eax, eax
jmp .return jmp .return
@@: .reset: ; 2 = Reset the device
dec bl ; 2 = Reset the device call [eax + NET_DEVICE.reset]
jnz @f
mov esi, [esi + NET_DRV_LIST]
call [esi + NET_DEVICE.reset]
jmp .return jmp .return
@@: .stop: ; 3 = Stop driver for this device
dec bl ; 3 = Stop driver for this device call [eax + NET_DEVICE.unload]
jnz @f
mov esi, [esi + NET_DRV_LIST]
call [esi + NET_DEVICE.unload]
jmp .return 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 xor eax, eax
jmp .return jmp .return
@@: .set_default: ; 6 = Set default device
dec bl ; 5 = Get driver name
jnz @f
; ..;
xor eax, eax
jmp .return
@@:
dec bl ; 6 = Set default device
jnz @f
mov eax, esi
call NET_set_default call NET_set_default
jmp .return jmp .return
@@:
.doesnt_exist: .doesnt_exist:
DEBUGF 1,"sys_network: invalid device/function specified!\n" DEBUGF 1,"sys_network: invalid device/function specified!\n"
mov eax, -1 mov eax, -1
.return: .return:
mov [esp+28+4], eax mov [esp+32], eax
ret ret

View File

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