forked from KolibriOS/kolibrios
Improved RAW sockets. Added ability to set TTL thorugh setsockopt, Improved ping program.
git-svn-id: svn://kolibrios.org@5842 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -24,9 +24,10 @@ $Revision$
|
||||
;
|
||||
; IN: [esp] = ptr to buffer
|
||||
; ebx = ptr to device struct
|
||||
; ecx = segment size
|
||||
; ecx = TCP segment size
|
||||
; edx = ptr to IPv4 header
|
||||
; esi = ptr to TCP segment
|
||||
; edi = ptr to ipv4 source address, followed by ipv4 dest address
|
||||
; edi = interface number*4
|
||||
;
|
||||
; OUT: /
|
||||
;
|
||||
@@ -37,13 +38,14 @@ TCP_input:
|
||||
|
||||
; record the current time
|
||||
push [timer_ticks] ; in 1/100 seconds
|
||||
push ebx ecx esi edi ; mind the order (see TCP_queue_entry struct)
|
||||
push ebx ecx esi edx ; mind the order (see TCP_queue_entry struct)
|
||||
mov esi, esp
|
||||
|
||||
push edi
|
||||
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
|
||||
pop edi
|
||||
add esp, sizeof.TCP_queue_entry
|
||||
|
||||
call NET_ptr_to_num4
|
||||
inc [TCP_segments_rx + edi]
|
||||
|
||||
xor edx, edx
|
||||
@@ -55,6 +57,7 @@ TCP_input:
|
||||
ret
|
||||
|
||||
.fail:
|
||||
pop edi
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
|
||||
|
||||
call NET_ptr_to_num4
|
||||
@@ -94,7 +97,7 @@ endl
|
||||
|
||||
mov ebx, [esi + TCP_queue_entry.device_ptr]
|
||||
mov ecx, [esi + TCP_queue_entry.segment_size]
|
||||
mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 source address, followed by ipv4 destination address
|
||||
mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 header
|
||||
mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
|
||||
@@ -111,8 +114,8 @@ endl
|
||||
push ecx esi
|
||||
pushw [esi + TCP_header.Checksum]
|
||||
mov [esi + TCP_header.Checksum], 0
|
||||
TCP_checksum (edi), (edi+4)
|
||||
pop cx ; previous checksum
|
||||
TCP_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
|
||||
pop cx ; previous checksum
|
||||
cmp cx, dx
|
||||
pop edx ecx
|
||||
jne .drop_no_socket
|
||||
@@ -170,7 +173,7 @@ endl
|
||||
jne .socket_loop
|
||||
|
||||
mov eax, [ebx + IP_SOCKET.RemoteIP]
|
||||
cmp eax, [edi] ; Ipv4 source address
|
||||
cmp eax, [edi + IPv4_header.SourceAddress]
|
||||
je @f
|
||||
test eax, eax
|
||||
jnz .socket_loop
|
||||
@@ -233,7 +236,7 @@ endl
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
push ecx edx esi edi ;;;
|
||||
push ecx edx esi edi
|
||||
call SOCKET_fork
|
||||
pop edi esi edx ecx
|
||||
|
||||
@@ -244,7 +247,7 @@ endl
|
||||
|
||||
mov [temp_bits], TCP_BIT_DROPSOCKET
|
||||
|
||||
push dword [edi + 4] ; Ipv4 destination addres
|
||||
push [edi + IPv4_header.DestinationAddress]
|
||||
pop [ebx + IP_SOCKET.LocalIP]
|
||||
|
||||
push [edx + TCP_header.DestinationPort]
|
||||
@@ -1211,7 +1214,7 @@ align 4
|
||||
|
||||
;;; TODO: check if it's a broadcast or multicast, and drop if so
|
||||
|
||||
push dword [edi] ; Ipv4 source addres
|
||||
push [edi + IPv4_header.SourceAddress]
|
||||
pop [ebx + IP_SOCKET.RemoteIP]
|
||||
|
||||
push [edx + TCP_header.SourcePort]
|
||||
@@ -1673,11 +1676,13 @@ align 4
|
||||
|
||||
.respond_seg_ack:
|
||||
mov cl, TH_RST
|
||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||
call TCP_respond_segment
|
||||
jmp .drop_no_socket
|
||||
|
||||
.respond_seg_syn:
|
||||
mov cl, TH_RST + TH_ACK
|
||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||
call TCP_respond_segment
|
||||
jmp .drop_no_socket
|
||||
|
||||
|
Reference in New Issue
Block a user