ARP_IP_to_MAC no longer blocks. Updated SOCKET_process_end (altough kernel does not call it yet). Updated TCP_output to time a retransmit on ARP error.

git-svn-id: svn://kolibrios.org@2629 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-04-18 16:01:38 +00:00
parent 2f09cfb23e
commit 1e3b48239a
4 changed files with 28 additions and 42 deletions

View File

@ -156,6 +156,7 @@ local .exit
; IN: Pointer to buffer in [esp] ; IN: Pointer to buffer in [esp]
; size of buffer in [esp+4] ; size of buffer in [esp+4]
; packet size (without ethernet header) in ecx ; packet size (without ethernet header) in ecx
; packet ptr in edx
; OUT: / ; OUT: /
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
@ -173,7 +174,8 @@ ARP_input:
jne .maybe_request jne .maybe_request
DEBUGF 1,"ARP_input - it's a reply packet from %u.%u.%u.%u\n",\ DEBUGF 1,"ARP_input - it's a reply packet from %u.%u.%u.%u\n",\
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP+1]:1, [edx + ARP_header.SenderIP+2]:1, [edx + ARP_header.SenderIP+3]:1 [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP+1]:1,\
[edx + ARP_header.SenderIP+2]:1, [edx + ARP_header.SenderIP+3]:1
mov ecx, [NumARP] mov ecx, [NumARP]
test ecx, ecx test ecx, ecx
@ -204,8 +206,8 @@ ARP_input:
mov eax, dword [edx + ARP_header.SenderMAC] mov eax, dword [edx + ARP_header.SenderMAC]
mov dword [esi+ARP_entry.MAC], eax mov dword [esi+ARP_entry.MAC], eax
mov ax , word [edx + ARP_header.SenderMAC + 4] mov cx, word [edx + ARP_header.SenderMAC + 4]
mov word [esi+ARP_entry.MAC+4], ax mov word [esi+ARP_entry.MAC+4], cx
jmp .exit jmp .exit
@ -225,7 +227,7 @@ ARP_input:
mov eax, [IP_LIST+4*edi] mov eax, [IP_LIST+4*edi]
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address? cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
jne .exit ; TODO: instead of quitting, update local entrys with matching IP's ? jne .exit
push eax push eax
push edi push edi
@ -259,7 +261,7 @@ ARP_input:
lea esi, [edx + ARP_header.SenderMAC] lea esi, [edx + ARP_header.SenderMAC]
movsd movsd
movsw movsw
; mov ax , ETHER_ARP ; mov ax , ETHER_ARP ; It's already there, I'm sure of it!
; stosw ; stosw
DEBUGF 1,"ARP_input - Sending reply \n" DEBUGF 1,"ARP_input - Sending reply \n"
@ -267,7 +269,7 @@ ARP_input:
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
ret ret
.exit: .exit:
call kernel_free call kernel_free
add esp, 4 ; pop (balance stack) add esp, 4 ; pop (balance stack)
@ -492,13 +494,14 @@ ARP_IP_to_MAC:
;-------------------- ;--------------------
; Send an ARP request ; Send an ARP request
push eax push eax ; save IP for ARP_output_request
pushw ARP_REQUEST_TTL ; Now create the ARP entry
pushw ARP_AWAITING_RESPONSE pushw ARP_REQUEST_TTL ; TTL
pushd 0 pushw ARP_AWAITING_RESPONSE ; status
pushd 0 ; mac
pushw 0 pushw 0
pushd eax pushd eax ; ip
mov esi, esp mov esi, esp
call ARP_add_entry call ARP_add_entry
add esp, sizeof.ARP_entry add esp, sizeof.ARP_entry
@ -506,36 +509,19 @@ ARP_IP_to_MAC:
cmp eax, -1 cmp eax, -1
je .full je .full
mov ecx, eax ; And send a request
pop eax pop eax
push ecx call ARP_output_request ; IP in eax
call ARP_output_request
;; TODO: check if driver could transmit packet ;; TODO: check if driver could transmit packet
pop esi mov eax, -2 ; request send
imul esi, sizeof.ARP_entry
add esi, ARP_table
mov ecx, 25
.wait_loop:
cmp [esi + ARP_entry.Status], 1
je .got_it
push esi
mov esi, 10
call delay_ms
pop esi
loop .wait_loop
mov eax, -2 ; request send
ret ret
.found_it: .found_it:
DEBUGF 1,"found IP in ARPTable\n" DEBUGF 1,"found IP in ARPTable\n"
cmp [esi + ARP_entry.Status], 1 cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING
jne .invalid jne .invalid
.got_it:
movzx eax, word [esi + ARP_entry.MAC] movzx eax, word [esi + ARP_entry.MAC]
mov ebx, dword[esi + ARP_entry.MAC+2] mov ebx, dword[esi + ARP_entry.MAC+2]
ret ret

View File

@ -592,8 +592,6 @@ IPv4_output:
test eax, 0xffff0000 ; error bits test eax, 0xffff0000 ; error bits
jnz .arp_error jnz .arp_error
.continue:
push ebx ; push the mac push ebx ; push the mac
push ax push ax

View File

@ -1323,6 +1323,8 @@ SOCKET_notify_owner:
; socket exists, now try to flag an event to the application ; socket exists, now try to flag an event to the application
mov eax, [eax + SOCKET.PID] mov eax, [eax + SOCKET.PID]
test eax, eax
jz .error2
mov ecx, 1 mov ecx, 1
mov esi, TASK_DATA + TASKDATA.pid mov esi, TASK_DATA + TASKDATA.pid
@ -1719,15 +1721,11 @@ SOCKET_process_end:
mov [ebx + SOCKET.PID], 0 mov [ebx + SOCKET.PID], 0
cmp [ebx + SOCKET.Protocol], IP_PROTO_UDP
je .udp
cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP cmp [ebx + SOCKET.Protocol], IP_PROTO_TCP
je .tcp je .tcp
jmp .next_socket ; kill all sockets for given PID ; The socket is stateless, just kill it right away!
.udp:
mov eax, ebx mov eax, ebx
mov ebx, [ebx + SOCKET.NextPtr] mov ebx, [ebx + SOCKET.NextPtr]
call SOCKET_free call SOCKET_free
@ -1735,9 +1733,11 @@ SOCKET_process_end:
.tcp: .tcp:
;;; TODO push [ebx + SOCKET.NextPtr]
mov eax, ebx
jmp .next_socket call TCP_close
pop ebx
jmp .test_socket
.done: .done:
pop ebx pop ebx

View File

@ -534,6 +534,8 @@ TCP_output:
pop eax pop eax
add esp, 8 add esp, 8
mov [eax + TCP_SOCKET.timer_retransmission], TCP_time_re_min
pusha pusha
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock