forked from KolibriOS/kolibrios
Cosmetical changes in network code, updated TCP timer code.
git-svn-id: svn://kolibrios.org@6011 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
116d2c8d6a
commit
c81c3fbd4f
@ -119,13 +119,13 @@ __exports:
|
|||||||
usb_get_param, 'USBGetParam', \
|
usb_get_param, 'USBGetParam', \
|
||||||
usb_hc_func, 'USBHCFunc', \
|
usb_hc_func, 'USBHCFunc', \
|
||||||
\
|
\
|
||||||
NET_add_device, 'NetRegDev', \
|
net_add_device, 'NetRegDev', \
|
||||||
NET_remove_device, 'NetUnRegDev', \
|
net_remove_device, 'NetUnRegDev', \
|
||||||
NET_ptr_to_num, 'NetPtrToNum', \
|
net_ptr_to_num, 'NetPtrToNum', \
|
||||||
NET_link_changed, 'NetLinkChanged', \
|
net_link_changed, 'NetLinkChanged', \
|
||||||
ETH_input, 'EthInput', \
|
eth_input, 'EthInput', \
|
||||||
NET_BUFF_alloc, 'NetAlloc', \
|
net_buff_alloc, 'NetAlloc', \
|
||||||
NET_BUFF_free, 'NetFree', \
|
net_buff_free, 'NetFree', \
|
||||||
\
|
\
|
||||||
get_pcidev_list, 'GetPCIList', \
|
get_pcidev_list, 'GetPCIList', \
|
||||||
\
|
\
|
||||||
|
@ -2167,7 +2167,7 @@ sys_end:
|
|||||||
pusha
|
pusha
|
||||||
mov edx, [TASK_BASE]
|
mov edx, [TASK_BASE]
|
||||||
mov edx, [edx+TASKDATA.pid]
|
mov edx, [edx+TASKDATA.pid]
|
||||||
call SOCKET_process_end
|
call socket_process_end
|
||||||
popa
|
popa
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
mov ecx, [current_slot]
|
mov ecx, [current_slot]
|
||||||
@ -2297,7 +2297,7 @@ sysfn_terminate: ; 18.2 = TERMINATE
|
|||||||
; terminate all network sockets it used
|
; terminate all network sockets it used
|
||||||
pusha
|
pusha
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
call SOCKET_process_end
|
call socket_process_end
|
||||||
popa
|
popa
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
cmp [_display.select_cursor], 0
|
cmp [_display.select_cursor], 0
|
||||||
|
@ -70,14 +70,12 @@ endg
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_init
|
; arp_init: Resets all ARP variables. ;
|
||||||
;
|
; ;
|
||||||
; This function resets all ARP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro arp_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro ARP_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ARP_entries_num
|
mov edi, ARP_entries_num
|
||||||
@ -86,13 +84,12 @@ macro ARP_init {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_decrease_entry_ttls
|
; arp_decrease_entry_ttls ;
|
||||||
;
|
; ;
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
macro arp_decrease_entry_ttls {
|
||||||
macro ARP_decrease_entry_ttls {
|
|
||||||
|
|
||||||
local .loop
|
local .loop
|
||||||
local .exit
|
local .exit
|
||||||
@ -135,7 +132,7 @@ local .exit
|
|||||||
je .response_timeout
|
je .response_timeout
|
||||||
|
|
||||||
push esi edi ecx
|
push esi edi ecx
|
||||||
call ARP_del_entry
|
call arp_del_entry
|
||||||
pop ecx edi esi
|
pop ecx edi esi
|
||||||
|
|
||||||
jmp .next
|
jmp .next
|
||||||
@ -154,20 +151,21 @@ local .exit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_input
|
; arp_input ;
|
||||||
;
|
; ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; IN: [esp] = Pointer to buffer ;
|
||||||
; size of buffer in [esp+4]
|
; [esp+4] = size of buffer ;
|
||||||
; packet size (without ethernet header) in ecx
|
; ecx = packet size (without ethernet header) ;
|
||||||
; packet ptr in edx
|
; edx = packet ptr ;
|
||||||
; device ptr in ebx
|
; ebx = device ptr ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_input:
|
arp_input:
|
||||||
|
|
||||||
;-----------------------------------------
|
;-----------------------------------------
|
||||||
; Check validity and print some debug info
|
; Check validity and print some debug info
|
||||||
@ -175,7 +173,7 @@ ARP_input:
|
|||||||
cmp ecx, sizeof.ARP_header
|
cmp ecx, sizeof.ARP_header
|
||||||
jb .exit
|
jb .exit
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
@ -294,21 +292,21 @@ ARP_input:
|
|||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: exiting\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: exiting\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_output_request
|
; arp_output_request ;
|
||||||
;
|
; ;
|
||||||
; IN: ebx = device ptr
|
; IN: ebx = device ptr ;
|
||||||
; eax = IP
|
; eax = IP ;
|
||||||
; OUT: /
|
; ;
|
||||||
; scratched: probably everything
|
; OUT: scratched: probably everything ;
|
||||||
;
|
; ;
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_output_request:
|
arp_output_request:
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
@ -318,7 +316,7 @@ ARP_output_request:
|
|||||||
mov ax, ETHER_PROTO_ARP
|
mov ax, ETHER_PROTO_ARP
|
||||||
mov ecx, sizeof.ARP_header
|
mov ecx, sizeof.ARP_header
|
||||||
mov edx, ETH_BROADCAST ; broadcast mac
|
mov edx, ETH_BROADCAST ; broadcast mac
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
||||||
@ -333,7 +331,7 @@ ARP_output_request:
|
|||||||
movsd ;
|
movsd ;
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
||||||
lea esi, [IP_LIST + edi] ; SenderIP
|
lea esi, [IP_LIST + edi] ; SenderIP
|
||||||
pop edi
|
pop edi
|
||||||
@ -354,18 +352,22 @@ ARP_output_request:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_add_entry (or update)
|
; arp_add_entry: Add or update an entry in the ARP table. ;
|
||||||
;
|
; ;
|
||||||
; IN: esi = ptr to entry (can easily be made on the stack)
|
; IN: esi = ptr to entry (can easily be made on the stack) ;
|
||||||
; edi = device num*4
|
; edi = device num*4 ;
|
||||||
; OUT: eax = entry #, -1 on error
|
; ;
|
||||||
; esi = ptr to newly created entry
|
; OUT: eax = entry number on success ;
|
||||||
;
|
; eax = -1 on error ;
|
||||||
;----------------------------------------------------------------- ; TODO: use a mutex
|
; esi = ptr to newly created entry ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_add_entry:
|
arp_add_entry:
|
||||||
|
|
||||||
|
; TODO: use a mutex to lock ARP table
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
||||||
|
|
||||||
@ -421,19 +423,22 @@ ARP_add_entry:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_del_entry
|
; arp_del_entry: Remove an entry from the ARP table. ;
|
||||||
;
|
; ;
|
||||||
; IN: esi = ptr to arp entry
|
; IN: esi = ptr to arp entry ;
|
||||||
; edi = device number
|
; edi = device number ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_del_entry:
|
arp_del_entry:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
|
; TODO: use a mutex to lock ARP table
|
||||||
|
|
||||||
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=0x%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
||||||
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
||||||
|
|
||||||
@ -463,22 +468,22 @@ ARP_del_entry:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_IP_to_MAC
|
; arp_ip_to_mac: Translate an IP address to a MAC address. ;
|
||||||
;
|
; ;
|
||||||
; This function translates an IP address to a MAC address
|
; IN: eax = IPv4 address ;
|
||||||
;
|
; edi = device number * 4 ;
|
||||||
; IN: eax = IPv4 address
|
; ;
|
||||||
; edi = device number * 4
|
; OUT: eax = -1 on error ;
|
||||||
; OUT: eax = -1 on error, -2 means request send
|
; eax = -2 when request send ;
|
||||||
; else, ax = first two bytes of mac (high 16 bits of eax will be 0)
|
; eax = first two bytes of mac on success ;
|
||||||
; ebx = last four bytes of mac
|
; ebx = last four bytes of mac on success ;
|
||||||
; edi = unchanged
|
; edi = unchanged ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_IP_to_MAC:
|
arp_ip_to_mac:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
@ -513,11 +518,11 @@ ARP_IP_to_MAC:
|
|||||||
pushw ARP_AWAITING_RESPONSE ; status
|
pushw ARP_AWAITING_RESPONSE ; status
|
||||||
pushd 0 ; mac
|
pushd 0 ; mac
|
||||||
pushw 0
|
pushw 0
|
||||||
pushd eax ; ip
|
pushd eax ; IP
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
; Add it to the list
|
; Add it to the list
|
||||||
call ARP_add_entry
|
call arp_add_entry
|
||||||
|
|
||||||
; Delete the temporary entry
|
; Delete the temporary entry
|
||||||
add esp, sizeof.ARP_entry ; clear the entry from stack
|
add esp, sizeof.ARP_entry ; clear the entry from stack
|
||||||
@ -534,7 +539,7 @@ ARP_IP_to_MAC:
|
|||||||
|
|
||||||
push esi edi
|
push esi edi
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [NET_DRV_LIST + edi]
|
||||||
call ARP_output_request
|
call arp_output_request
|
||||||
pop edi esi
|
pop edi esi
|
||||||
.found_it:
|
.found_it:
|
||||||
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
||||||
@ -576,21 +581,19 @@ end if
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_API
|
; arp_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 76
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT: ?
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ARP_api:
|
arp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -650,7 +653,7 @@ ARP_api:
|
|||||||
.write:
|
.write:
|
||||||
; esi = pointer to buffer
|
; esi = pointer to buffer
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
call ARP_add_entry ; out: eax = entry number, -1 on error
|
call arp_add_entry ; out: eax = entry number, -1 on error
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.remove:
|
.remove:
|
||||||
@ -661,12 +664,12 @@ ARP_api:
|
|||||||
lea esi, [ARP_table + ecx]
|
lea esi, [ARP_table + ecx]
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
shr edi, 2
|
shr edi, 2
|
||||||
call ARP_del_entry
|
call arp_del_entry
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.send_announce:
|
.send_announce:
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call arp_output_request ; now send a gratuitous ARP
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -92,14 +92,12 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_init
|
; ipv4_init: Resets all IPv4 variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro ipv4_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro IPv4_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IP_LIST
|
mov edi, IP_LIST
|
||||||
@ -109,12 +107,12 @@ macro IPv4_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; Decrease TimeToLive of all fragment slots
|
; Decrease TimeToLive of all fragment slots ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
macro IPv4_decrease_fragment_ttls {
|
macro ipv4_decrease_fragment_ttls {
|
||||||
|
|
||||||
local .loop, .next
|
local .loop, .next
|
||||||
|
|
||||||
@ -141,7 +139,7 @@ local .loop, .next
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro IPv4_checksum ptr {
|
macro ipv4_checksum ptr {
|
||||||
|
|
||||||
; This is the fast procedure to create or check an IP header without options
|
; This is the fast procedure to create or check an IP header without options
|
||||||
; To create a new checksum, the checksum field must be set to 0 before computation
|
; To create a new checksum, the checksum field must be set to 0 before computation
|
||||||
@ -205,24 +203,22 @@ macro IPv4_checksum ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_input:
|
; ipv4_input: Check if IPv4 Packet isnt damaged and call ;
|
||||||
;
|
; appropriate handler. (TCP/UDP/ICMP/..) ;
|
||||||
; Will check if IPv4 Packet isnt damaged
|
; We will also re-construct fragmented packets. ;
|
||||||
; and call appropriate handler. (TCP/UDP/ICMP/..)
|
; ;
|
||||||
;
|
; IN: Pointer to buffer in [esp] ;
|
||||||
; It will also re-construct fragmented packets
|
; pointer to device struct in ebx ;
|
||||||
;
|
; pointer to IPv4 header in edx ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; size of IPv4 packet in ecx ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to IPv4 header in edx
|
; OUT: / ;
|
||||||
; size of IPv4 packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv4_input:
|
ipv4_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
|
||||||
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
|
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
|
||||||
@ -231,14 +227,14 @@ IPv4_input:
|
|||||||
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
|
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
|
||||||
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
|
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
je .invalid_device
|
je .invalid_device
|
||||||
|
|
||||||
;-------------------------------
|
;-------------------------------
|
||||||
; re-calculate the checksum
|
; re-calculate the checksum
|
||||||
|
|
||||||
IPv4_checksum edx
|
ipv4_checksum edx
|
||||||
jnz .dump ; if checksum isn't valid then dump packet
|
jnz .dump ; if checksum isn't valid then dump packet
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
|
||||||
@ -304,13 +300,13 @@ IPv4_input:
|
|||||||
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
|
||||||
|
|
||||||
;-------------------------------
|
;-------------------------------
|
||||||
; Look for a matching RAW socket
|
; Look for a matching RAW socket
|
||||||
@ -347,7 +343,7 @@ IPv4_input:
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.dump_unlock:
|
.dump_unlock:
|
||||||
|
|
||||||
@ -361,12 +357,12 @@ IPv4_input:
|
|||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
|
||||||
inc [IPv4_packets_dumped + edi]
|
inc [IPv4_packets_dumped + edi]
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.invalid_device:
|
.invalid_device:
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -390,7 +386,7 @@ IPv4_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
|
||||||
|
|
||||||
call IPv4_find_fragment_slot
|
call ipv4_find_fragment_slot
|
||||||
cmp esi, -1
|
cmp esi, -1
|
||||||
je .dump
|
je .dump
|
||||||
|
|
||||||
@ -455,7 +451,7 @@ IPv4_input:
|
|||||||
.is_last_fragment:
|
.is_last_fragment:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
|
||||||
|
|
||||||
call IPv4_find_fragment_slot
|
call ipv4_find_fragment_slot
|
||||||
cmp esi, -1
|
cmp esi, -1
|
||||||
je .dump
|
je .dump
|
||||||
|
|
||||||
@ -546,7 +542,7 @@ IPv4_input:
|
|||||||
push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer
|
push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer
|
||||||
push edx ; Push pointer to fragment onto stack
|
push edx ; Push pointer to fragment onto stack
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
|
||||||
call NET_BUFF_free ; free the previous fragment buffer (this uses the value from stack)
|
call net_buff_free ; free the previous fragment buffer (this uses the value from stack)
|
||||||
pop edx ebx eax
|
pop edx ebx eax
|
||||||
cmp edx, -1 ; Check if it is last fragment in chain
|
cmp edx, -1 ; Check if it is last fragment in chain
|
||||||
jne .rebuild_packet_loop
|
jne .rebuild_packet_loop
|
||||||
@ -571,16 +567,17 @@ IPv4_input:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; find fragment slot
|
; ipv4_find_fragment_slot ;
|
||||||
;
|
; ;
|
||||||
; IN: pointer to fragmented packet in edx
|
; IN: pointer to fragmented packet in edx ;
|
||||||
; OUT: pointer to slot in esi, -1 on error
|
; ;
|
||||||
;
|
; OUT: pointer to slot in esi, -1 on error ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_find_fragment_slot:
|
ipv4_find_fragment_slot:
|
||||||
|
|
||||||
;;; TODO: the RFC says we should check protocol number too
|
;;; TODO: the RFC says we should check protocol number too
|
||||||
|
|
||||||
@ -607,26 +604,27 @@ IPv4_find_fragment_slot:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_output
|
; ipv4_output ;
|
||||||
;
|
; ;
|
||||||
; IN: al = protocol
|
; IN: al = protocol ;
|
||||||
; ah = TTL
|
; ah = TTL ;
|
||||||
; ebx = device ptr (or 0 to let IP layer decide)
|
; ebx = device ptr (or 0 to let IP layer decide) ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = Source IP
|
; edx = Source IP ;
|
||||||
; edi = Destination IP
|
; edi = Destination IP ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = pointer to buffer start / 0 on error
|
; OUT: eax = pointer to buffer start ;
|
||||||
; ebx = device ptr (send packet through this device)
|
; eax = 0 on error ;
|
||||||
; ecx = data length
|
; ebx = device ptr (send packet through this device) ;
|
||||||
; edx = size of complete frame
|
; ecx = data length ;
|
||||||
; edi = start of IPv4 payload
|
; edx = size of complete frame ;
|
||||||
;
|
; edi = start of IPv4 payload ;
|
||||||
;------------------------------------------------------------------
|
; ;
|
||||||
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_output:
|
ipv4_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
|
||||||
|
|
||||||
@ -635,12 +633,12 @@ IPv4_output:
|
|||||||
|
|
||||||
push ecx ax edi
|
push ecx ax edi
|
||||||
mov eax, edi
|
mov eax, edi
|
||||||
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
|
call ipv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
|
||||||
push edx
|
push edx
|
||||||
test edi, edi
|
test edi, edi
|
||||||
jz .loopback
|
jz .loopback
|
||||||
|
|
||||||
call ARP_IP_to_MAC
|
call arp_ip_to_mac
|
||||||
test eax, 0xffff0000 ; error bits
|
test eax, 0xffff0000 ; error bits
|
||||||
jnz .arp_error
|
jnz .arp_error
|
||||||
push ebx ; push the mac onto the stack
|
push ebx ; push the mac onto the stack
|
||||||
@ -653,7 +651,7 @@ IPv4_output:
|
|||||||
mov ecx, [esp + 6 + 8 + 2]
|
mov ecx, [esp + 6 + 8 + 2]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
add esp, 6 ; pop the mac out of the stack
|
add esp, 6 ; pop the mac out of the stack
|
||||||
|
|
||||||
@ -674,7 +672,7 @@ IPv4_output:
|
|||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
|
|
||||||
IPv4_checksum edi
|
ipv4_checksum edi
|
||||||
add edi, sizeof.IPv4_header
|
add edi, sizeof.IPv4_header
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
|
||||||
ret
|
ret
|
||||||
@ -704,33 +702,33 @@ IPv4_output:
|
|||||||
mov ecx, [esp + 10]
|
mov ecx, [esp + 10]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edi, AF_INET4
|
mov edi, AF_INET4
|
||||||
call LOOP_output
|
call loop_output
|
||||||
jmp .continue
|
jmp .continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_output_raw
|
; ipv4_output_raw ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket ptr
|
; IN: eax = socket ptr ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; esi = data ptr
|
; esi = data ptr ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = -1 on error
|
; OUT: eax = -1 on error ;
|
||||||
;
|
; ;
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_output_raw:
|
ipv4_output_raw:
|
||||||
|
|
||||||
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
|
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
|
||||||
|
|
||||||
sub esp, 8
|
sub esp, 8
|
||||||
push esi eax
|
push esi eax
|
||||||
|
|
||||||
call IPv4_route
|
call ipv4_route
|
||||||
call ARP_IP_to_MAC
|
call arp_ip_to_mac
|
||||||
|
|
||||||
test eax, 0xffff0000 ; error bits
|
test eax, 0xffff0000 ; error bits
|
||||||
jnz .arp_error
|
jnz .arp_error
|
||||||
@ -744,7 +742,7 @@ IPv4_output_raw:
|
|||||||
mov ecx, [esp + 6 + 4]
|
mov ecx, [esp + 6 + 4]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .error
|
jz .error
|
||||||
add esp, 6 ; pop the mac
|
add esp, 6 ; pop the mac
|
||||||
|
|
||||||
@ -772,7 +770,7 @@ IPv4_output_raw:
|
|||||||
; [edi + IPv4_header.SourceAddress]
|
; [edi + IPv4_header.SourceAddress]
|
||||||
; [edi + IPv4_header.DestinationAddress]
|
; [edi + IPv4_header.DestinationAddress]
|
||||||
|
|
||||||
IPv4_checksum edi ;;;; todo: checksum for IP packet with options!
|
ipv4_checksum edi ;;;; todo: checksum for IP packet with options!
|
||||||
add edi, sizeof.IPv4_header
|
add edi, sizeof.IPv4_header
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
@ -791,17 +789,18 @@ IPv4_output_raw:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;--------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
;
|
; ipv4_fragment ;
|
||||||
; IN: [esp] = pointer to buffer containing ipv4 packet to be fragmented
|
; ;
|
||||||
; edi = pointer to ip header in that buffer
|
; IN: [esp] = ptr to packet buffer to fragment ;
|
||||||
; ebx = device ptr
|
; edi = ptrr to ip header in that buffer ;
|
||||||
;
|
; ebx = device ptr ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;--------------------------------------------------------
|
; ;
|
||||||
proc IPv4_fragment stdcall buffer
|
;-----------------------------------------------------------------;
|
||||||
|
proc ipv4_fragment stdcall buffer
|
||||||
|
|
||||||
locals
|
locals
|
||||||
offset dd ?
|
offset dd ?
|
||||||
@ -910,22 +909,24 @@ endp
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_route
|
; ipv4_route ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = Destination IP
|
; IN: eax = Destination IP ;
|
||||||
; ebx = outgoing device / 0
|
; ebx = outgoing device / 0 ;
|
||||||
; edx = Source IP
|
; edx = Source IP ;
|
||||||
; OUT: eax = Destination IP (or gateway IP)
|
; ;
|
||||||
; edx = Source IP
|
; OUT: eax = Destination IP (or gateway IP) ;
|
||||||
; edi = device number*4
|
; edx = Source IP ;
|
||||||
; DESTROYED:
|
; edi = device number*4 ;
|
||||||
; ecx
|
; ;
|
||||||
;
|
; DESTROYED: ;
|
||||||
;---------------------------------------------------------------------------
|
; ecx ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_route: ; TODO: return error if no valid route found
|
ipv4_route: ; TODO: return error if no valid route found
|
||||||
|
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jnz .got_device
|
jnz .got_device
|
||||||
@ -961,7 +962,7 @@ IPv4_route: ; TODO: return error if no valid route found
|
|||||||
|
|
||||||
.got_device:
|
.got_device:
|
||||||
; Validate device ptr and convert to device number
|
; Validate device ptr and convert to device number
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
je .fail
|
je .fail
|
||||||
|
|
||||||
@ -982,32 +983,35 @@ IPv4_route: ; TODO: return error if no valid route found
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_get_frgmnt_num
|
; ipv4_get_frgmnt_num ;
|
||||||
;
|
; ;
|
||||||
; IN: /
|
; IN: / ;
|
||||||
; OUT: fragment number in ax
|
; ;
|
||||||
;
|
; OUT: ax = fragment number ;
|
||||||
;---------------------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_get_frgmnt_num:
|
ipv4_get_frgmnt_num:
|
||||||
xor ax, ax ;;; TODO: replace this with real code
|
xor ax, ax ;;; TODO: replace this with real code
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_connect
|
; ipv4_connect ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket pointer
|
; IN: eax = socket pointer ;
|
||||||
; OUT: eax = 0 ok / -1 error
|
; ;
|
||||||
; ebx = error code
|
; OUT: eax = 0 on success ;
|
||||||
;
|
; eax = -1 on error ;
|
||||||
;-------------------------
|
; ebx = error code on error ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_connect:
|
ipv4_connect:
|
||||||
|
|
||||||
push eax edx
|
push eax edx
|
||||||
lea ecx, [eax + SOCKET.mutex]
|
lea ecx, [eax + SOCKET.mutex]
|
||||||
@ -1031,21 +1035,19 @@ IPv4_connect:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_API
|
; ipv4_API: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv4_api:
|
ipv4_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -1096,9 +1098,9 @@ IPv4_api:
|
|||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call arp_output_request ; now send a gratuitous ARP
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1108,7 +1110,7 @@ IPv4_api:
|
|||||||
|
|
||||||
.write_dns:
|
.write_dns:
|
||||||
mov [DNS_LIST + eax], ecx
|
mov [DNS_LIST + eax], ecx
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1125,7 +1127,7 @@ IPv4_api:
|
|||||||
or ecx, ebx
|
or ecx, ebx
|
||||||
mov [BROADCAST_LIST + eax], ecx
|
mov [BROADCAST_LIST + eax], ecx
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1136,6 +1138,6 @@ IPv4_api:
|
|||||||
.write_gateway:
|
.write_gateway:
|
||||||
mov [GATEWAY_LIST + eax], ecx
|
mov [GATEWAY_LIST + eax], ecx
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
@ -45,14 +45,12 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_init
|
; ipv6_init: Resets all IPv6 variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro ipv6_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro IPv6_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IPv6
|
mov edi, IPv6
|
||||||
@ -63,25 +61,23 @@ macro IPv6_init {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_input:
|
; ipv6_input: Check if IPv6 Packet isnt damaged and call ;
|
||||||
;
|
; appropriate handler. (TCP/UDP/ICMP/..) ;
|
||||||
; Will check if IPv6 Packet isnt damaged
|
; We will also re-construct fragmented packets ;
|
||||||
; and call appropriate handler. (TCP/UDP/ICMP/..)
|
; ;
|
||||||
;
|
; IN: [esp] = ptr to buffer ;
|
||||||
; It will also re-construct fragmented packets
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; edx = ptr to IPv6 header ;
|
||||||
; size of buffer in [esp+4]
|
; ecx = size of IPv6 packet ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to IPv6 header in edx
|
; OUT: / ;
|
||||||
; size of IPv6 packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv6_input:
|
ipv6_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
|
||||||
[edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\
|
[edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\
|
||||||
@ -147,7 +143,7 @@ IPv6_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.dump_options:
|
.dump_options:
|
||||||
@ -245,21 +241,19 @@ IPv6_input:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_API
|
; ipv6_api: Part of system function 76 ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv6_api:
|
ipv6_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -33,37 +33,33 @@ align 4
|
|||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE_init
|
; pppoe_init: Reset all pppoe variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro pppoe_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro PPPoE_init {
|
|
||||||
|
|
||||||
call PPPoE_stop_connection
|
call pppoe_stop_connection
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE discovery input
|
; pppoe_discovery_input ;
|
||||||
;
|
; ;
|
||||||
; Handler of received Ethernet packet with type = Discovery
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; ecx = size of PPP packet ;
|
||||||
; size of buffer in [esp+4]
|
; edx = ptr to PPP header ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to PPP header in edx
|
; OUT: / ;
|
||||||
; size of PPP packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_discovery_input:
|
pppoe_discovery_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_input\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_input\n"
|
||||||
|
|
||||||
@ -97,7 +93,7 @@ PPPoE_discovery_input:
|
|||||||
mov ecx, [esp + 4]
|
mov ecx, [esp + 4]
|
||||||
mov esi, [esp]
|
mov esi, [esp]
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
pusha
|
pusha
|
||||||
@ -106,22 +102,21 @@ PPPoE_discovery_input:
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
|
DEBUGF DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;--------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; Send discovery packet
|
; pppoe_discovery_output ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket pointer
|
; IN: eax = socket pointer ;
|
||||||
; ecx = number of bytes to send
|
; ecx = number of bytes to send ;
|
||||||
; esi = pointer to data
|
; esi = pointer to data ;
|
||||||
;
|
; ;
|
||||||
;--------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_discovery_output:
|
pppoe_discovery_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
|
||||||
|
|
||||||
@ -147,7 +142,7 @@ PPPoE_discovery_output:
|
|||||||
|
|
||||||
; Create packet.
|
; Create packet.
|
||||||
push ecx esi
|
push ecx esi
|
||||||
stdcall kernel_alloc, 1500
|
;;;; FIXME stdcall kernel_alloc, 1500
|
||||||
pop esi ecx
|
pop esi ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .bad
|
jz .bad
|
||||||
@ -185,23 +180,21 @@ PPPoE_discovery_output:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE session input
|
; pppoe_session_input ;
|
||||||
;
|
; ;
|
||||||
; Handler of received Ethernet packet with type = Session
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; edx = ptr to PPP header ;
|
||||||
; size of buffer in [esp+4]
|
; ecx = size of PPP packet ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to PPP header in edx
|
; OUT: / ;
|
||||||
; size of PPP packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_session_input:
|
pppoe_session_input:
|
||||||
|
|
||||||
cmp [edx + PPPoE_frame.VersionAndType], 0x11
|
cmp [edx + PPPoE_frame.VersionAndType], 0x11
|
||||||
jne .dump
|
jne .dump
|
||||||
@ -221,38 +214,39 @@ PPPoE_session_input:
|
|||||||
add edx, PPPoE_frame.Payload + 2
|
add edx, PPPoE_frame.Payload + 2
|
||||||
|
|
||||||
cmp ax, PPP_PROTO_IPv4
|
cmp ax, PPP_PROTO_IPv4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
; cmp ax, PPP_PROTO_IPv6
|
; cmp ax, PPP_PROTO_IPv6
|
||||||
; je IPv6_input
|
; je ipv6_input
|
||||||
|
|
||||||
jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
jmp pppoe_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE_output
|
; pppoe_output ;
|
||||||
;
|
; ;
|
||||||
; IN: ax = protocol
|
; IN: ax = protocol ;
|
||||||
; ebx = device ptr
|
; ebx = device ptr ;
|
||||||
; ecx = packet size
|
; ecx = packet size ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = buffer start / 0 on error
|
; OUT: eax = buffer start ;
|
||||||
; ebx = device ptr
|
; eax = 0 on error ;
|
||||||
; ecx = packet size
|
; ebx = device ptr ;
|
||||||
; edx = size of complete buffer
|
; ecx = packet size ;
|
||||||
; edi = start of PPP payload
|
; edx = size of complete buffer ;
|
||||||
;
|
; edi = start of PPP payload ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
PPPoE_output:
|
pppoe_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
|
||||||
|
|
||||||
@ -262,7 +256,7 @@ PPPoE_output:
|
|||||||
mov ax, ETHER_PROTO_PPP_SESSION
|
mov ax, ETHER_PROTO_PPP_SESSION
|
||||||
add ecx, PPPoE_frame.Payload + 2
|
add ecx, PPPoE_frame.Payload + 2
|
||||||
lea edx, [PPPoE_MAC]
|
lea edx, [PPPoE_MAC]
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
|
|
||||||
sub ecx, PPPoE_frame.Payload
|
sub ecx, PPPoE_frame.Payload
|
||||||
@ -287,8 +281,8 @@ PPPoE_output:
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
PPPoE_start_connection:
|
pppoe_start_connection:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
|
||||||
|
|
||||||
@ -308,7 +302,7 @@ PPPoE_start_connection:
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_stop_connection:
|
pppoe_stop_connection:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_stop_connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_stop_connection\n"
|
||||||
|
|
||||||
@ -320,21 +314,19 @@ PPPoE_stop_connection:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE API
|
; pppoe_api: Part of system function 76 ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: subfunction number in bl ;
|
||||||
;
|
; device number in bh ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_api:
|
pppoe_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -345,8 +337,8 @@ PPPoE_api:
|
|||||||
jmp dword [.table + 4*ebx]
|
jmp dword [.table + 4*ebx]
|
||||||
|
|
||||||
.table:
|
.table:
|
||||||
dd PPPoE_start_connection ; 0
|
dd pppoe_start_connection ; 0
|
||||||
dd PPPoE_stop_connection ; 1
|
dd pppoe_stop_connection ; 1
|
||||||
.number = ($ - .table) / 4 - 1
|
.number = ($ - .table) / 4 - 1
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
|
@ -50,10 +50,10 @@ align 4
|
|||||||
ETH_input_event dd ?
|
ETH_input_event dd ?
|
||||||
endg
|
endg
|
||||||
|
|
||||||
macro ETH_init {
|
macro eth_init {
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, ETH_process_input
|
mov ecx, eth_process_input
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -62,20 +62,18 @@ macro ETH_init {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ETH_input
|
; eth_input: This function is called by ethernet drivers. ;
|
||||||
;
|
; Push the received ethernet packet onto the ethernet input queue.;
|
||||||
; This function is called by ethernet drivers,
|
; ;
|
||||||
; It pushes the received ethernet packets onto the ethernet input queue
|
; IN: [esp] = Pointer to buffer ;
|
||||||
;
|
; ;
|
||||||
; IN: [esp] = Pointer to buffer
|
; OUT: / ;
|
||||||
;
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ETH_input:
|
eth_input:
|
||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
pushf
|
pushf
|
||||||
@ -109,14 +107,22 @@ ETH_input:
|
|||||||
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
|
||||||
popf
|
popf
|
||||||
push eax
|
push eax
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
|
; ;
|
||||||
|
; eth_process_input: Process packets from ethernet input queue. ;
|
||||||
|
; ;
|
||||||
|
; IN: / ;
|
||||||
|
; ;
|
||||||
|
; OUT: / ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ETH_process_input:
|
eth_process_input:
|
||||||
|
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
mov ecx, MANUAL_DESTROY
|
mov ecx, MANUAL_DESTROY
|
||||||
@ -163,44 +169,46 @@ ETH_process_input:
|
|||||||
|
|
||||||
; Place protocol handlers here
|
; Place protocol handlers here
|
||||||
cmp ax, ETHER_PROTO_IPv4
|
cmp ax, ETHER_PROTO_IPv4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
cmp ax, ETHER_PROTO_ARP
|
cmp ax, ETHER_PROTO_ARP
|
||||||
je ARP_input
|
je arp_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_IPv6
|
; cmp ax, ETHER_PROTO_IPv6
|
||||||
; je IPv6_input
|
; je ipv6_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_PPP_DISCOVERY
|
; cmp ax, ETHER_PROTO_PPP_DISCOVERY
|
||||||
; je PPPoE_discovery_input
|
; je pppoe_discovery_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_PPP_SESSION
|
; cmp ax, ETHER_PROTO_PPP_SESSION
|
||||||
; je PPPoE_session_input
|
; je pppoe_session_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; ETH_output
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IN: ax = protocol
|
; eth_output ;
|
||||||
; ebx = device ptr
|
; ;
|
||||||
; ecx = payload size
|
; IN: ax = protocol ;
|
||||||
; edx = pointer to destination mac
|
; ebx = device ptr ;
|
||||||
;
|
; ecx = payload size ;
|
||||||
; OUT: eax = start of net frame / 0 on error
|
; edx = pointer to destination mac ;
|
||||||
; ebx = device ptr
|
; ;
|
||||||
; ecx = payload size
|
; OUT: eax = start of net frame / 0 on error ;
|
||||||
; edi = start of payload
|
; ebx = device ptr ;
|
||||||
;
|
; ecx = payload size ;
|
||||||
;-----------------------------------------------------------------
|
; edi = start of payload ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ETH_output:
|
eth_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
|
||||||
|
|
||||||
@ -211,7 +219,7 @@ ETH_output:
|
|||||||
push ax edx
|
push ax edx
|
||||||
|
|
||||||
add ecx, sizeof.ETH_header + NET_BUFF.data
|
add ecx, sizeof.ETH_header + NET_BUFF.data
|
||||||
stdcall NET_BUFF_alloc, ecx
|
stdcall net_buff_alloc, ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .out_of_ram
|
jz .out_of_ram
|
||||||
mov [eax + NET_BUFF.type], NET_BUFF_ETH
|
mov [eax + NET_BUFF.type], NET_BUFF_ETH
|
||||||
@ -257,21 +265,19 @@ ETH_output:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ETH_API
|
; eth_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 76
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ETH_api:
|
eth_api:
|
||||||
|
|
||||||
cmp bh, NET_DEVICES_MAX
|
cmp bh, NET_DEVICES_MAX
|
||||||
ja .error
|
ja .error
|
||||||
|
@ -85,7 +85,6 @@ ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed
|
|||||||
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
|
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ICMP_header
|
struct ICMP_header
|
||||||
|
|
||||||
Type db ?
|
Type db ?
|
||||||
@ -107,13 +106,13 @@ endg
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_init
|
; ICMP_init ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
macro ICMP_init {
|
macro icmp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ICMP_PACKETS_TX
|
mov edi, ICMP_PACKETS_TX
|
||||||
@ -123,25 +122,23 @@ macro ICMP_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_input:
|
; icmp_input: Send a reply's to an ICMP echo or insert packets ;
|
||||||
;
|
; into socket. ;
|
||||||
; This procedure will send reply's to ICMP echo's
|
; ;
|
||||||
; and insert packets into sockets when needed
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; ecx = ICMP Packet size ;
|
||||||
; ebx = pointer to device struct
|
; edx = ptr to IPv4 header ;
|
||||||
; ecx = ICMP Packet size
|
; esi = ptr to ICMP Packet data ;
|
||||||
; edx = ptr to IPv4 header
|
; edi = interface number*4 ;
|
||||||
; esi = ptr to ICMP Packet data
|
; ;
|
||||||
; edi = interface number*4
|
; OUT: / ;
|
||||||
;
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ICMP_input:
|
icmp_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
||||||
|
|
||||||
@ -204,7 +201,7 @@ ICMP_input:
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -274,7 +271,7 @@ ICMP_input:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -293,26 +290,26 @@ ICMP_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_output
|
; icmp_output ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = dest ip
|
; IN: eax = dest ip ;
|
||||||
; bh = type
|
; bh = type ;
|
||||||
; bl = code
|
; bl = code ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = source ip
|
; edx = source ip ;
|
||||||
; esi = data offset
|
; esi = data offset ;
|
||||||
; edi = identifier shl 16 + sequence number
|
; edi = identifier shl 16 + sequence number ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ICMP_output:
|
icmp_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
|
||||||
|
|
||||||
@ -364,17 +361,17 @@ end if
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_output_raw
|
; icmp_output_raw ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket ptr
|
; IN: eax = socket ptr ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = data pointer
|
; edx = data pointer ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ICMP_output_raw:
|
icmp_output_raw:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
|
||||||
|
|
||||||
@ -384,7 +381,7 @@ ICMP_output_raw:
|
|||||||
mov edi, [eax + IP_SOCKET.RemoteIP]
|
mov edi, [eax + IP_SOCKET.RemoteIP]
|
||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_ICMP
|
mov ah, IP_PROTO_ICMP
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
@ -407,7 +404,7 @@ ICMP_output_raw:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -422,21 +419,19 @@ ICMP_output_raw:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_API
|
; icmp_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ICMP_api:
|
icmp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -27,7 +27,7 @@ LOOPBACK_DEVICE:
|
|||||||
|
|
||||||
.unload dd .dummy_fn
|
.unload dd .dummy_fn
|
||||||
.reset dd .dummy_fn
|
.reset dd .dummy_fn
|
||||||
.transmit dd LOOP_input
|
.transmit dd loop_input
|
||||||
|
|
||||||
.bytes_tx dq 0
|
.bytes_tx dq 0
|
||||||
.bytes_rx dq 0
|
.bytes_rx dq 0
|
||||||
@ -45,11 +45,11 @@ LOOPBACK_DEVICE:
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
macro LOOP_init {
|
macro loop_init {
|
||||||
local .fail
|
local .fail
|
||||||
|
|
||||||
mov ebx, LOOPBACK_DEVICE
|
mov ebx, LOOPBACK_DEVICE
|
||||||
call NET_add_device
|
call net_add_device
|
||||||
|
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .fail
|
je .fail
|
||||||
@ -63,7 +63,7 @@ local .fail
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; LOOP_input ;
|
; loop_input ;
|
||||||
; ;
|
; ;
|
||||||
; IN: [esp+4] = Pointer to buffer ;
|
; IN: [esp+4] = Pointer to buffer ;
|
||||||
; ;
|
; ;
|
||||||
@ -71,7 +71,7 @@ local .fail
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
LOOP_input:
|
loop_input:
|
||||||
|
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
|
|
||||||
@ -95,19 +95,19 @@ LOOP_input:
|
|||||||
|
|
||||||
; Place protocol handlers here
|
; Place protocol handlers here
|
||||||
cmp eax, AF_INET4
|
cmp eax, AF_INET4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", eax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; LOOP_output ;
|
; loop_output ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ecx = packet size ;
|
; IN: ecx = packet size ;
|
||||||
; edi = address family ;
|
; edi = address family ;
|
||||||
@ -119,7 +119,7 @@ LOOP_input:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
LOOP_output:
|
loop_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ LOOP_output:
|
|||||||
|
|
||||||
push ecx edi
|
push ecx edi
|
||||||
add ecx, NET_BUFF.data
|
add ecx, NET_BUFF.data
|
||||||
stdcall NET_BUFF_alloc, ecx
|
stdcall net_buff_alloc, ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .out_of_ram
|
jz .out_of_ram
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -258,16 +258,14 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; stack_init
|
; stack_init: Initialize all network variables ;
|
||||||
;
|
; ;
|
||||||
; This function calls all network init procedures
|
; IN: / ;
|
||||||
;
|
; OUT: / ;
|
||||||
; IN: /
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
stack_init:
|
stack_init:
|
||||||
|
|
||||||
@ -294,21 +292,21 @@ stack_init:
|
|||||||
mov ecx, (NET_DEVICES_MAX + 1)
|
mov ecx, (NET_DEVICES_MAX + 1)
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
ETH_init
|
eth_init
|
||||||
|
|
||||||
PPPoE_init
|
pppoe_init
|
||||||
|
|
||||||
IPv4_init
|
ipv4_init
|
||||||
; IPv6_init
|
; ipv6_init
|
||||||
ICMP_init
|
icmp_init
|
||||||
|
|
||||||
ARP_init
|
arp_init
|
||||||
UDP_init
|
udp_init
|
||||||
TCP_init
|
tcp_init
|
||||||
|
|
||||||
SOCKET_init
|
socket_init
|
||||||
|
|
||||||
LOOP_init
|
loop_init
|
||||||
|
|
||||||
mov [net_tmr_count], 0
|
mov [net_tmr_count], 0
|
||||||
ret
|
ret
|
||||||
@ -329,16 +327,14 @@ proc stack_handler_has_work?
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; stack_handler
|
; stack_handler: Network handlers called from os_loop. ;
|
||||||
;
|
; ;
|
||||||
; This function is called in kernel loop
|
; IN: / ;
|
||||||
;
|
; OUT: / ;
|
||||||
; IN: /
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
stack_handler:
|
stack_handler:
|
||||||
|
|
||||||
@ -354,13 +350,13 @@ stack_handler:
|
|||||||
test [net_10ms], 0x0f ; 160ms
|
test [net_10ms], 0x0f ; 160ms
|
||||||
jnz .exit
|
jnz .exit
|
||||||
|
|
||||||
TCP_timer_160ms
|
tcp_timer_160ms
|
||||||
|
|
||||||
test [net_10ms], 0x3f ; 640ms
|
test [net_10ms], 0x3f ; 640ms
|
||||||
jnz .exit
|
jnz .exit
|
||||||
|
|
||||||
ARP_decrease_entry_ttls
|
arp_decrease_entry_ttls
|
||||||
IPv4_decrease_fragment_ttls
|
ipv4_decrease_fragment_ttls
|
||||||
|
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov eax, [TCP_timer1_event]
|
mov eax, [TCP_timer1_event]
|
||||||
@ -373,7 +369,8 @@ stack_handler:
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc NET_BUFF_alloc stdcall, buffersize
|
proc net_buff_alloc stdcall, buffersize
|
||||||
|
|
||||||
cmp [buffersize], NET_BUFFER_SIZE
|
cmp [buffersize], NET_BUFFER_SIZE
|
||||||
ja .too_large
|
ja .too_large
|
||||||
|
|
||||||
@ -387,27 +384,27 @@ proc NET_BUFF_alloc stdcall, buffersize
|
|||||||
|
|
||||||
spin_unlock_irqrestore
|
spin_unlock_irqrestore
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "net alloc: 0x%x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_alloc: 0x%x\n", eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.out_of_mem:
|
.out_of_mem:
|
||||||
spin_unlock_irqrestore
|
spin_unlock_irqrestore
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "NET_BUFF_alloc: out of mem!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: out of mem!\n"
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.too_large:
|
.too_large:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "NET_BUFF_alloc: too large!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: too large!\n"
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc NET_BUFF_free stdcall, buffer
|
proc net_buff_free stdcall, buffer
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "net free: 0x%x\n", [buffer]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_free: 0x%x\n", [buffer]
|
||||||
|
|
||||||
spin_lock_irqsave
|
spin_lock_irqsave
|
||||||
|
|
||||||
@ -423,14 +420,14 @@ endp
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_link_changed:
|
net_link_changed:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_send_event:
|
net_send_event:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_send_event\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_send_event\n"
|
||||||
|
|
||||||
; Send event to all applications
|
; Send event to all applications
|
||||||
push edi ecx
|
push edi ecx
|
||||||
@ -446,21 +443,20 @@ NET_send_event:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_add_device:
|
; net_add_device: Called by network driver to register interface. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by the network drivers,
|
; IN: ebx = ptr to device structure ;
|
||||||
; to register each running NIC to the kernel
|
; ;
|
||||||
;
|
; OUT: eax = device num on success ;
|
||||||
; IN: Pointer to device structure in ebx
|
; eax = -1 on error ;
|
||||||
; OUT: Device num in eax, -1 on error
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
NET_add_device:
|
net_add_device:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_add_device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
||||||
|
|
||||||
cmp [NET_RUNNING], NET_DEVICES_MAX
|
cmp [NET_RUNNING], NET_DEVICES_MAX
|
||||||
jae .error
|
jae .error
|
||||||
@ -495,7 +491,7 @@ NET_add_device:
|
|||||||
|
|
||||||
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
||||||
ret
|
ret
|
||||||
@ -507,19 +503,17 @@ NET_add_device:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_Remove_Device:
|
; net_remove_device: Called by network driver to unregister dev. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by network drivers,
|
; IN: ebx = ptr to device ;
|
||||||
; to unregister network devices from the kernel
|
; ;
|
||||||
;
|
; OUT: eax: -1 on error ;
|
||||||
; IN: Pointer to device structure in ebx
|
; ;
|
||||||
; OUT: eax: -1 on error
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
NET_remove_device:
|
net_remove_device:
|
||||||
|
|
||||||
cmp [NET_RUNNING], 0
|
cmp [NET_RUNNING], 0
|
||||||
je .error
|
je .error
|
||||||
@ -541,7 +535,7 @@ NET_remove_device:
|
|||||||
mov dword [edi-4], eax
|
mov dword [edi-4], eax
|
||||||
dec [NET_RUNNING]
|
dec [NET_RUNNING]
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -552,25 +546,27 @@ NET_remove_device:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_ptr_to_num
|
; net_ptr_to_num ;
|
||||||
;
|
; ;
|
||||||
; IN: ebx = ptr to device struct
|
; IN: ebx = ptr to device struct ;
|
||||||
; OUT: edi = -1 on error, device number otherwise
|
; ;
|
||||||
;
|
; OUT: edi = device number ;
|
||||||
;-----------------------------------------------------------------
|
; edi = -1 on error ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
NET_ptr_to_num:
|
net_ptr_to_num:
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
ror edi, 2 ; If -1, stay -1
|
ror edi, 2 ; If -1, stay -1
|
||||||
; valid device numbers have last two bits 0, so do just shr
|
; valid device numbers have last two bits 0, so do just shr
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_ptr_to_num4: ; Todo, place number in device structure so we only need to verify?
|
net_ptr_to_num4: ; Todo, place number in device structure so we only need to verify?
|
||||||
|
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jz .fail
|
jz .fail
|
||||||
@ -595,21 +591,17 @@ NET_ptr_to_num4: ; Todo, place number in device structure so we o
|
|||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; checksum_1
|
; checksum_1: Calculate semi-checksum for network packets. ;
|
||||||
;
|
; ;
|
||||||
; This is the first of two functions needed to calculate a checksum.
|
; IN: edx = start offset for semi-checksum ;
|
||||||
;
|
; esi = pointer to data ;
|
||||||
; IN: edx = start offset for semi-checksum
|
; ecx = data size ;
|
||||||
; esi = pointer to data
|
; ;
|
||||||
; ecx = data size
|
; OUT: edx = semi-checksum ;
|
||||||
; OUT: edx = semi-checksum
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
; Code was optimized by diamond
|
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
checksum_1:
|
checksum_1:
|
||||||
|
|
||||||
@ -679,16 +671,15 @@ checksum_1:
|
|||||||
.end:
|
.end:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; checksum_2
|
; checksum_2: Calculate the final ip/tcp/udp checksum. ;
|
||||||
;
|
; ;
|
||||||
; This function calculates the final ip/tcp/udp checksum for you
|
; IN: edx = semi-checksum ;
|
||||||
;
|
; ;
|
||||||
; IN: edx = semi-checksum
|
; OUT: dx = checksum (in INET byte order) ;
|
||||||
; OUT: dx = checksum (in INET byte order)
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
checksum_2:
|
checksum_2:
|
||||||
|
|
||||||
@ -713,11 +704,11 @@ checksum_2:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; System function to work with network devices (74)
|
; System function 74: Low level access to network devices. ;
|
||||||
;
|
; ;
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
sys_network:
|
sys_network:
|
||||||
|
|
||||||
@ -834,11 +825,11 @@ sys_network:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; System function to work with protocols (76)
|
; System function 76: Low level access to protocol handlers. ;
|
||||||
;
|
; ;
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
sys_protocols:
|
sys_protocols:
|
||||||
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
||||||
@ -856,28 +847,28 @@ sys_protocols:
|
|||||||
shr eax, 16 ;
|
shr eax, 16 ;
|
||||||
|
|
||||||
cmp ax, API_ETH
|
cmp ax, API_ETH
|
||||||
je ETH_api
|
je eth_api
|
||||||
|
|
||||||
cmp ax, API_IPv4
|
cmp ax, API_IPv4
|
||||||
je IPv4_api
|
je ipv4_api
|
||||||
|
|
||||||
cmp ax, API_ICMP
|
cmp ax, API_ICMP
|
||||||
je ICMP_api
|
je icmp_api
|
||||||
|
|
||||||
cmp ax, API_UDP
|
cmp ax, API_UDP
|
||||||
je UDP_api
|
je udp_api
|
||||||
|
|
||||||
cmp ax, API_TCP
|
cmp ax, API_TCP
|
||||||
je TCP_api
|
je tcp_api
|
||||||
|
|
||||||
cmp ax, API_ARP
|
cmp ax, API_ARP
|
||||||
je ARP_api
|
je arp_api
|
||||||
|
|
||||||
cmp ax, API_PPPOE
|
cmp ax, API_PPPOE
|
||||||
je PPPoE_api
|
je pppoe_api
|
||||||
|
|
||||||
cmp ax, API_IPv6
|
cmp ax, API_IPv6
|
||||||
je IPv6_api
|
je ipv6_api
|
||||||
|
|
||||||
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ endg
|
|||||||
; TCP_init: Resets all TCP variables. ;
|
; TCP_init: Resets all TCP variables. ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
macro TCP_init {
|
macro tcp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, TCP_segments_tx
|
mov edi, TCP_segments_tx
|
||||||
@ -219,7 +219,7 @@ macro TCP_init {
|
|||||||
init_queue TCP_queue
|
init_queue TCP_queue
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, TCP_process_input
|
mov ecx, tcp_process_input
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -227,7 +227,7 @@ macro TCP_init {
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, TCP_timer_640ms
|
mov ecx, tcp_timer_640ms
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -246,7 +246,7 @@ include 'tcp_output.inc'
|
|||||||
|
|
||||||
;------------------------------------------------------------------;
|
;------------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_api: This function is called by system function 76 ;
|
; tcp_api: Part of system function 76 ;
|
||||||
; ;
|
; ;
|
||||||
; IN: bl = subfunction number ;
|
; IN: bl = subfunction number ;
|
||||||
; bh = device number ;
|
; bh = device number ;
|
||||||
@ -256,7 +256,7 @@ include 'tcp_output.inc'
|
|||||||
; ;
|
; ;
|
||||||
;------------------------------------------------------------------;
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_api:
|
tcp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -31,7 +31,7 @@ $Revision$
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_input:
|
tcp_input:
|
||||||
|
|
||||||
; record the current time
|
; record the current time
|
||||||
push [timer_ticks] ; in 1/100 seconds
|
push [timer_ticks] ; in 1/100 seconds
|
||||||
@ -57,17 +57,17 @@ TCP_input:
|
|||||||
pop edi
|
pop edi
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_missed + edi]
|
inc [TCP_segments_missed + edi]
|
||||||
|
|
||||||
add esp, sizeof.TCP_queue_entry - 4
|
add esp, sizeof.TCP_queue_entry - 4
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc TCP_process_input
|
proc tcp_process_input
|
||||||
|
|
||||||
locals
|
locals
|
||||||
dataoffset dd ?
|
dataoffset dd ?
|
||||||
@ -111,7 +111,7 @@ endl
|
|||||||
push ecx esi
|
push ecx esi
|
||||||
pushw [esi + TCP_header.Checksum]
|
pushw [esi + TCP_header.Checksum]
|
||||||
mov [esi + TCP_header.Checksum], 0
|
mov [esi + TCP_header.Checksum], 0
|
||||||
TCP_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
|
tcp_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
|
||||||
pop cx ; previous checksum
|
pop cx ; previous checksum
|
||||||
cmp cx, dx
|
cmp cx, dx
|
||||||
pop edx ecx
|
pop edx ecx
|
||||||
@ -234,7 +234,7 @@ endl
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
push ecx edx esi edi
|
push ecx edx esi edi
|
||||||
call SOCKET_fork
|
call socket_fork
|
||||||
pop edi esi edx ecx
|
pop edi esi edx ecx
|
||||||
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -312,7 +312,7 @@ endl
|
|||||||
lodsw
|
lodsw
|
||||||
rol ax, 8
|
rol ax, 8
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax
|
||||||
call TCP_mss
|
call tcp_mss
|
||||||
@@:
|
@@:
|
||||||
jmp .opt_loop
|
jmp .opt_loop
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ endl
|
|||||||
pusha
|
pusha
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
popa
|
popa
|
||||||
|
|
||||||
; Update RTT estimators
|
; Update RTT estimators
|
||||||
@ -483,7 +483,7 @@ endl
|
|||||||
mov eax, [timestamp]
|
mov eax, [timestamp]
|
||||||
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
||||||
inc eax
|
inc eax
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .rtt_done
|
jmp .rtt_done
|
||||||
.no_timestamp_rtt:
|
.no_timestamp_rtt:
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ endl
|
|||||||
cmp eax, [ebx + TCP_SOCKET.t_rtseq]
|
cmp eax, [ebx + TCP_SOCKET.t_rtseq]
|
||||||
jbe .rtt_done
|
jbe .rtt_done
|
||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
.rtt_done:
|
.rtt_done:
|
||||||
|
|
||||||
; update window pointers
|
; update window pointers
|
||||||
@ -511,10 +511,10 @@ endl
|
|||||||
|
|
||||||
; Awaken waiting processes
|
; Awaken waiting processes
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
; Generate more output
|
; Generate more output
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
@ -540,11 +540,11 @@ endl
|
|||||||
mov esi, [dataoffset]
|
mov esi, [dataoffset]
|
||||||
add esi, edx
|
add esi, edx
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_write ; Add the data to the socket buffer
|
call socket_ring_write ; Add the data to the socket buffer
|
||||||
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag
|
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag
|
||||||
|
|
||||||
@ -661,7 +661,7 @@ endl
|
|||||||
jz .not_terminated
|
jz .not_terminated
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
inc [TCPS_rcvafterclose]
|
inc [TCPS_rcvafterclose]
|
||||||
jmp .respond_seg_reset
|
jmp .respond_seg_reset
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ endl
|
|||||||
; cmp edx, [edx + TCP_header.SequenceNumber]
|
; cmp edx, [edx + TCP_header.SequenceNumber]
|
||||||
; add edx, 64000 ; TCP_ISSINCR FIXME
|
; add edx, 64000 ; TCP_ISSINCR FIXME
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .findpcb ; FIXME: skip code for unscaling window, ...
|
jmp .findpcb ; FIXME: skip code for unscaling window, ...
|
||||||
.no_new_request:
|
.no_new_request:
|
||||||
|
|
||||||
@ -779,14 +779,14 @@ endl
|
|||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
;;; TODO: update stats (tcp drops)
|
;;; TODO: update stats (tcp drops)
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.rst_close:
|
.rst_close:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.no_rst:
|
.no_rst:
|
||||||
@ -799,7 +799,7 @@ endl
|
|||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ebx, ECONNRESET
|
mov ebx, ECONNRESET
|
||||||
call TCP_drop
|
call tcp_drop
|
||||||
jmp .drop_with_reset
|
jmp .drop_with_reset
|
||||||
.not_syn_full:
|
.not_syn_full:
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ endl
|
|||||||
;;; TODO: update stats
|
;;; TODO: update stats
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
|
|
||||||
; Do window scaling?
|
; Do window scaling?
|
||||||
@ -838,7 +838,7 @@ endl
|
|||||||
pop word [ebx + TCP_SOCKET.SND_SCALE]
|
pop word [ebx + TCP_SOCKET.SND_SCALE]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
call TCP_reassemble
|
call tcp_reassemble
|
||||||
|
|
||||||
mov eax, [edx + TCP_header.SequenceNumber]
|
mov eax, [edx + TCP_header.SequenceNumber]
|
||||||
dec eax
|
dec eax
|
||||||
@ -916,7 +916,7 @@ endl
|
|||||||
|
|
||||||
; retransmit missing segment
|
; retransmit missing segment
|
||||||
mov eax, [esp]
|
mov eax, [esp]
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
; Lock the socket again
|
; Lock the socket again
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
@ -955,7 +955,7 @@ endl
|
|||||||
|
|
||||||
; retransmit missing segment
|
; retransmit missing segment
|
||||||
mov eax, [esp]
|
mov eax, [esp]
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
; Lock the socket again
|
; Lock the socket again
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
@ -1005,7 +1005,7 @@ endl
|
|||||||
mov eax, [timestamp]
|
mov eax, [timestamp]
|
||||||
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
||||||
inc eax
|
inc eax
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .rtt_done_
|
jmp .rtt_done_
|
||||||
|
|
||||||
; If no timestamp but transmit timer is running and timed sequence number was acked,
|
; If no timestamp but transmit timer is running and timed sequence number was acked,
|
||||||
@ -1020,7 +1020,7 @@ endl
|
|||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .rtt_done_
|
jz .rtt_done_
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
|
|
||||||
.rtt_done_:
|
.rtt_done_:
|
||||||
|
|
||||||
@ -1085,7 +1085,7 @@ endl
|
|||||||
mov ecx, [ebx + STREAM_SOCKET.snd.size]
|
mov ecx, [ebx + STREAM_SOCKET.snd.size]
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
pop ebx edx ecx
|
pop ebx edx ecx
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
|
||||||
@ -1097,7 +1097,7 @@ endl
|
|||||||
push ecx edx ebx
|
push ecx edx ebx
|
||||||
mov ecx, edi
|
mov ecx, edi
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
pop ebx
|
pop ebx
|
||||||
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
||||||
pop edx ecx
|
pop edx ecx
|
||||||
@ -1109,7 +1109,7 @@ endl
|
|||||||
|
|
||||||
.wakeup:
|
.wakeup:
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
; Update TCPS
|
; Update TCPS
|
||||||
mov eax, [edx + TCP_header.AckNumber]
|
mov eax, [edx + TCP_header.AckNumber]
|
||||||
@ -1147,7 +1147,7 @@ endl
|
|||||||
test [ebx + SOCKET.state], SS_CANTRCVMORE
|
test [ebx + SOCKET.state], SS_CANTRCVMORE
|
||||||
jnz @f
|
jnz @f
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
@@:
|
@@:
|
||||||
@ -1160,11 +1160,11 @@ endl
|
|||||||
|
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call tcp_cancel_timers
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
jmp .ack_processed
|
jmp .ack_processed
|
||||||
|
|
||||||
.ack_la:
|
.ack_la:
|
||||||
@ -1177,7 +1177,7 @@ endl
|
|||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.ack_tw:
|
.ack_tw:
|
||||||
@ -1224,8 +1224,8 @@ align 4
|
|||||||
mov [ebx + TCP_SOCKET.ISS], eax
|
mov [ebx + TCP_SOCKET.ISS], eax
|
||||||
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
||||||
|
|
||||||
TCP_sendseqinit ebx
|
tcp_sendseqinit ebx
|
||||||
TCP_rcvseqinit ebx
|
tcp_rcvseqinit ebx
|
||||||
|
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
@ -1233,12 +1233,12 @@ align 4
|
|||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .drop
|
jz .drop
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .drop
|
jz .drop
|
||||||
|
|
||||||
@ -1246,7 +1246,7 @@ align 4
|
|||||||
|
|
||||||
pusha
|
pusha
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp .trim
|
jmp .trim
|
||||||
@ -1278,7 +1278,7 @@ align 4
|
|||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ebx, ECONNREFUSED
|
mov ebx, ECONNREFUSED
|
||||||
call TCP_drop
|
call tcp_drop
|
||||||
|
|
||||||
jmp .drop
|
jmp .drop
|
||||||
@@:
|
@@:
|
||||||
@ -1306,7 +1306,7 @@ align 4
|
|||||||
push [edx + TCP_header.SequenceNumber]
|
push [edx + TCP_header.SequenceNumber]
|
||||||
pop [ebx + TCP_SOCKET.IRS]
|
pop [ebx + TCP_SOCKET.IRS]
|
||||||
|
|
||||||
TCP_rcvseqinit ebx
|
tcp_rcvseqinit ebx
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
|
|
||||||
@ -1324,7 +1324,7 @@ align 4
|
|||||||
; set socket state to connected
|
; set socket state to connected
|
||||||
push eax
|
push eax
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
pop eax
|
pop eax
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
|
|
||||||
@ -1343,7 +1343,7 @@ align 4
|
|||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
je .trim
|
je .trim
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .trim
|
jmp .trim
|
||||||
|
|
||||||
.simultaneous_open:
|
.simultaneous_open:
|
||||||
@ -1485,13 +1485,13 @@ align 4
|
|||||||
mov esi, [dataoffset]
|
mov esi, [dataoffset]
|
||||||
add esi, edx
|
add esi, edx
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_write ; Add the data to the socket buffer
|
call socket_ring_write ; Add the data to the socket buffer
|
||||||
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
||||||
popa
|
popa
|
||||||
|
|
||||||
; Wake up the sleeping process
|
; Wake up the sleeping process
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
jmp .data_done
|
jmp .data_done
|
||||||
|
|
||||||
@ -1501,7 +1501,7 @@ align 4
|
|||||||
|
|
||||||
; Uh-oh, some data is out of order, lets call TCP reassemble for help
|
; Uh-oh, some data is out of order, lets call TCP reassemble for help
|
||||||
|
|
||||||
call TCP_reassemble
|
call tcp_reassemble
|
||||||
|
|
||||||
; Generate ACK immediately, to let the other end know that a segment was received out of order,
|
; Generate ACK immediately, to let the other end know that a segment was received out of order,
|
||||||
; and to tell it what sequence number is expected. This aids the fast-retransmit algorithm.
|
; and to tell it what sequence number is expected. This aids the fast-retransmit algorithm.
|
||||||
@ -1522,7 +1522,7 @@ align 4
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_cant_recv_more
|
call socket_cant_recv_more
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
inc [ebx + TCP_SOCKET.RCV_NXT]
|
inc [ebx + TCP_SOCKET.RCV_NXT]
|
||||||
@ -1556,8 +1556,8 @@ align 4
|
|||||||
.fin_wait2:
|
.fin_wait2:
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call tcp_cancel_timers
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
|
|
||||||
.fin_timed:
|
.fin_timed:
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
@ -1583,12 +1583,12 @@ align 4
|
|||||||
|
|
||||||
.need_output:
|
.need_output:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
|
||||||
|
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
|
|
||||||
@ -1621,7 +1621,7 @@ align 4
|
|||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jnz .done
|
jnz .done
|
||||||
|
|
||||||
;;; if its a multicast/broadcast, also drop
|
; TODO: if its a multicast/broadcast, also drop
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jnz .respond_ack
|
jnz .respond_ack
|
||||||
@ -1636,14 +1636,14 @@ align 4
|
|||||||
.respond_ack:
|
.respond_ack:
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_RST
|
mov cl, TH_RST
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
pop ebx
|
pop ebx
|
||||||
jmp .destroy_new_socket
|
jmp .destroy_new_socket
|
||||||
|
|
||||||
.respond_syn:
|
.respond_syn:
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_RST + TH_ACK
|
mov cl, TH_RST + TH_ACK
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
pop ebx
|
pop ebx
|
||||||
jmp .destroy_new_socket
|
jmp .destroy_new_socket
|
||||||
|
|
||||||
@ -1660,7 +1660,7 @@ align 4
|
|||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jnz .drop_no_socket
|
jnz .drop_no_socket
|
||||||
|
|
||||||
;;; TODO: if its a multicast/broadcast, also drop
|
; TODO: if its a multicast/broadcast, also drop
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jnz .respond_seg_ack
|
jnz .respond_seg_ack
|
||||||
@ -1673,13 +1673,13 @@ align 4
|
|||||||
.respond_seg_ack:
|
.respond_seg_ack:
|
||||||
mov cl, TH_RST
|
mov cl, TH_RST
|
||||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||||
call TCP_respond_segment
|
call tcp_respond_segment
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.respond_seg_syn:
|
.respond_seg_syn:
|
||||||
mov cl, TH_RST + TH_ACK
|
mov cl, TH_RST + TH_ACK
|
||||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||||
call TCP_respond_segment
|
call tcp_respond_segment
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
;------------------------------------------------
|
;------------------------------------------------
|
||||||
@ -1701,7 +1701,7 @@ align 4
|
|||||||
jz .drop_no_socket
|
jz .drop_no_socket
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_free
|
call socket_free
|
||||||
|
|
||||||
;------------------
|
;------------------
|
||||||
; Drop the segment
|
; Drop the segment
|
||||||
@ -1709,7 +1709,7 @@ align 4
|
|||||||
.drop_no_socket:
|
.drop_no_socket:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
|
||||||
|
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
endp
|
endp
|
||||||
|
@ -18,7 +18,7 @@ $Revision$
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_output ;
|
; tcp_output ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ;
|
; ;
|
||||||
@ -26,7 +26,7 @@ $Revision$
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
proc TCP_output
|
proc tcp_output
|
||||||
|
|
||||||
locals
|
locals
|
||||||
temp_bits db ?
|
temp_bits db ?
|
||||||
@ -72,7 +72,7 @@ endl
|
|||||||
mov ecx, [eax + TCP_SOCKET.SND_CWND] ;
|
mov ecx, [eax + TCP_SOCKET.SND_CWND] ;
|
||||||
@@: ;
|
@@: ;
|
||||||
|
|
||||||
call TCP_outflags ; flags in dl
|
call tcp_outflags ; flags in dl
|
||||||
|
|
||||||
;------------------------
|
;------------------------
|
||||||
; data being forced out ?
|
; data being forced out ?
|
||||||
@ -279,7 +279,7 @@ endl
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
call TCP_set_persist
|
call tcp_set_persist
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
@ -509,7 +509,7 @@ endl
|
|||||||
mov edi, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
mov edi, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_TCP
|
mov ah, IP_PROTO_TCP
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .ip_error
|
jz .ip_error
|
||||||
|
|
||||||
;------------------------------------------
|
;------------------------------------------
|
||||||
@ -549,7 +549,7 @@ endl
|
|||||||
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
||||||
sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset
|
sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset
|
||||||
add eax, STREAM_SOCKET.snd
|
add eax, STREAM_SOCKET.snd
|
||||||
call SOCKET_ring_read
|
call socket_ring_read
|
||||||
.nodata:
|
.nodata:
|
||||||
pop edi
|
pop edi
|
||||||
pop esi ; begin of data
|
pop esi ; begin of data
|
||||||
@ -606,7 +606,7 @@ endl
|
|||||||
test [ebx + NET_DEVICE.hwacc], NET_HWACC_TCP_IPv4_OUT
|
test [ebx + NET_DEVICE.hwacc], NET_HWACC_TCP_IPv4_OUT
|
||||||
jnz .checksum_ok
|
jnz .checksum_ok
|
||||||
|
|
||||||
TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
|
tcp_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
|
||||||
|
|
||||||
.checksum_ok:
|
.checksum_ok:
|
||||||
mov [esi + TCP_header.Checksum], dx
|
mov [esi + TCP_header.Checksum], dx
|
||||||
@ -624,7 +624,7 @@ endl
|
|||||||
pop ecx
|
pop ecx
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
inc [TCPS_sndtotal]
|
inc [TCPS_sndtotal]
|
||||||
|
|
||||||
@ -658,7 +658,7 @@ endl
|
|||||||
; Check if we need more output
|
; Check if we need more output
|
||||||
|
|
||||||
test [temp_bits], TCP_BIT_SENDALOT
|
test [temp_bits], TCP_BIT_SENDALOT
|
||||||
jnz TCP_output.again
|
jnz tcp_output.again
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ iglobal
|
|||||||
TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6
|
TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6
|
||||||
endg
|
endg
|
||||||
|
|
||||||
macro TCP_checksum IP1, IP2 {
|
macro tcp_checksum IP1, IP2 {
|
||||||
|
|
||||||
;-------------
|
;-------------
|
||||||
; Pseudoheader
|
; Pseudoheader
|
||||||
@ -60,9 +60,9 @@ macro TCP_checksum IP1, IP2 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_sendseqinit ptr {
|
macro tcp_sendseqinit ptr {
|
||||||
|
|
||||||
push edi ;;;; i dont like this static use of edi
|
push edi ;;;; FIXME: i dont like this static use of edi
|
||||||
mov edi, [ptr + TCP_SOCKET.ISS]
|
mov edi, [ptr + TCP_SOCKET.ISS]
|
||||||
mov [ptr + TCP_SOCKET.SND_UP], edi
|
mov [ptr + TCP_SOCKET.SND_UP], edi
|
||||||
mov [ptr + TCP_SOCKET.SND_MAX], edi
|
mov [ptr + TCP_SOCKET.SND_MAX], edi
|
||||||
@ -74,7 +74,7 @@ macro TCP_sendseqinit ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_rcvseqinit ptr {
|
macro tcp_rcvseqinit ptr {
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi, [ptr + TCP_SOCKET.IRS]
|
mov edi, [ptr + TCP_SOCKET.IRS]
|
||||||
@ -87,7 +87,7 @@ macro TCP_rcvseqinit ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_init_socket socket {
|
macro tcp_init_socket socket {
|
||||||
|
|
||||||
mov [socket + TCP_SOCKET.t_maxseg], TCP_mss_default
|
mov [socket + TCP_SOCKET.t_maxseg], TCP_mss_default
|
||||||
mov [socket + TCP_SOCKET.t_flags], TF_REQ_SCALE or TF_REQ_TSTMP
|
mov [socket + TCP_SOCKET.t_flags], TF_REQ_SCALE or TF_REQ_TSTMP
|
||||||
@ -106,7 +106,7 @@ macro TCP_init_socket socket {
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_pull_out_of_band ;
|
; tcp_pull_out_of_band ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = ? ;
|
; IN: eax = ? ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -116,9 +116,9 @@ macro TCP_init_socket socket {
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_pull_out_of_band:
|
tcp_pull_out_of_band:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_pull_out_of_band\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_pull_out_of_band\n"
|
||||||
|
|
||||||
;;;; 1282-1305
|
;;;; 1282-1305
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ TCP_pull_out_of_band:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_drop ;
|
; tcp_drop ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ebx = error number ;
|
; ebx = error number ;
|
||||||
@ -137,9 +137,9 @@ TCP_pull_out_of_band:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_drop: ; FIXME CHECKME TODO
|
tcp_drop: ; FIXME CHECKME TODO
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_drop: %x\n", eax
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
jb .no_syn_received
|
jb .no_syn_received
|
||||||
@ -147,12 +147,12 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
;;; TODO: update stats
|
;;; TODO: update stats
|
||||||
|
|
||||||
jmp TCP_close
|
jmp tcp_close
|
||||||
|
|
||||||
.no_syn_received:
|
.no_syn_received:
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_disconnect ;
|
; tcp_disconnect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -175,22 +175,22 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_disconnect:
|
tcp_disconnect:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_disconnect: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_disconnect: %x\n", eax
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
jb TCP_close ; Connection not yet synchronised, just get rid of the socket
|
jb tcp_close ; Connection not yet synchronised, just get rid of the socket
|
||||||
|
|
||||||
; TODO: implement LINGER
|
; TODO: implement LINGER
|
||||||
|
|
||||||
call SOCKET_is_disconnecting
|
call socket_is_disconnecting
|
||||||
call TCP_usrclosed
|
call tcp_usrclosed
|
||||||
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -198,7 +198,7 @@ TCP_disconnect:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_close ;
|
; tcp_close ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -206,15 +206,15 @@ TCP_disconnect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_close:
|
tcp_close:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_close: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_close: %x\n", eax
|
||||||
|
|
||||||
;;; TODO: update RTT and mean deviation
|
;;; TODO: update RTT and mean deviation
|
||||||
;;; TODO: update slow start threshold
|
;;; TODO: update slow start threshold
|
||||||
|
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
call SOCKET_free
|
call socket_free
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -223,7 +223,7 @@ TCP_close:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_outflags ;
|
; tcp_outflags ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -231,7 +231,7 @@ TCP_close:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_outflags:
|
tcp_outflags:
|
||||||
|
|
||||||
mov edx, [eax + TCP_SOCKET.t_state]
|
mov edx, [eax + TCP_SOCKET.t_state]
|
||||||
movzx edx, byte[edx + .flaglist]
|
movzx edx, byte[edx + .flaglist]
|
||||||
@ -270,7 +270,7 @@ TCP_outflags:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_respond:
|
tcp_respond:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: socket=%x flags=%x\n", ebx, cl
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: socket=%x flags=%x\n", ebx, cl
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ TCP_respond:
|
|||||||
mov ah, IP_PROTO_TCP
|
mov ah, IP_PROTO_TCP
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov ebx, [ebx + IP_SOCKET.device]
|
mov ebx, [ebx + IP_SOCKET.device]
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .error
|
jz .error
|
||||||
pop esi cx
|
pop esi cx
|
||||||
push eax
|
push eax
|
||||||
@ -320,7 +320,7 @@ TCP_respond:
|
|||||||
sub edi, sizeof.TCP_header
|
sub edi, sizeof.TCP_header
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
xchg esi, edi
|
xchg esi, edi
|
||||||
TCP_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
|
tcp_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
|
||||||
mov [esi+TCP_header.Checksum], dx
|
mov [esi+TCP_header.Checksum], dx
|
||||||
|
|
||||||
;--------------------
|
;--------------------
|
||||||
@ -329,7 +329,7 @@ TCP_respond:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -343,7 +343,7 @@ TCP_respond:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_respond_segment ;
|
; tcp_respond_segment ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ebx = device ptr ;
|
; IN: ebx = device ptr ;
|
||||||
; edx = segment ptr (a previously received segment) ;
|
; edx = segment ptr (a previously received segment) ;
|
||||||
@ -354,7 +354,7 @@ TCP_respond:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_respond_segment:
|
tcp_respond_segment:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: frame=%x flags=%x\n", edx, cl
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: frame=%x flags=%x\n", edx, cl
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ TCP_respond_segment:
|
|||||||
mov edi, [edi + IPv4_header.SourceAddress]
|
mov edi, [edi + IPv4_header.SourceAddress]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov ax, IP_PROTO_TCP shl 8 + 128
|
mov ax, IP_PROTO_TCP shl 8 + 128
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .error
|
jz .error
|
||||||
pop esi cx
|
pop esi cx
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ TCP_respond_segment:
|
|||||||
|
|
||||||
lea esi, [edi - sizeof.TCP_header]
|
lea esi, [edi - sizeof.TCP_header]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
TCP_checksum (esi - sizeof.IPv4_header + IPv4_header.DestinationAddress),\ ; FIXME
|
tcp_checksum (esi - sizeof.IPv4_header + IPv4_header.DestinationAddress),\ ; FIXME
|
||||||
(esi - sizeof.IPv4_header + IPv4_header.SourceAddress)
|
(esi - sizeof.IPv4_header + IPv4_header.SourceAddress)
|
||||||
mov [esi + TCP_header.Checksum], dx
|
mov [esi + TCP_header.Checksum], dx
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ TCP_respond_segment:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -421,7 +421,7 @@ TCP_respond_segment:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
macro TCPT_RANGESET timer, value, min, max {
|
macro tcpt_rangeset timer, value, min, max {
|
||||||
|
|
||||||
local .min
|
local .min
|
||||||
local .max
|
local .max
|
||||||
@ -448,11 +448,11 @@ local .done
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_set_persist ;
|
; tcp_set_persist ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_set_persist:
|
tcp_set_persist:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_set_persist\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_set_persist\n"
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ TCP_set_persist:
|
|||||||
|
|
||||||
; Start/restart persistance timer.
|
; Start/restart persistance timer.
|
||||||
|
|
||||||
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
tcpt_rangeset [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ TCP_set_persist:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_xmit_timer: Calculate new smoothed RTT. ;
|
; tcp_xmit_timer: Calculate new smoothed RTT. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = rtt ;
|
; IN: eax = rtt ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -498,7 +498,7 @@ TCP_set_persist:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_xmit_timer:
|
tcp_xmit_timer:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=0x%x rtt=%d0ms\n", ebx, eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=0x%x rtt=%d0ms\n", ebx, eax
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ TCP_xmit_timer:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_mss: Update maximum segment size ;
|
; tcp_mss: Update maximum segment size ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = max segment size ;
|
; IN: eax = max segment size ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -572,7 +572,7 @@ TCP_xmit_timer:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_mss:
|
tcp_mss:
|
||||||
|
|
||||||
cmp eax, 1420 ; FIXME
|
cmp eax, 1420 ; FIXME
|
||||||
jbe @f
|
jbe @f
|
||||||
@ -587,7 +587,7 @@ TCP_mss:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_reassemble ;
|
; tcp_reassemble ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ebx = socket ptr ;
|
; IN: ebx = socket ptr ;
|
||||||
; edx = segment ptr ;
|
; edx = segment ptr ;
|
||||||
@ -596,7 +596,7 @@ TCP_mss:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_reassemble:
|
tcp_reassemble:
|
||||||
|
|
||||||
;;;;; TODO
|
;;;;; TODO
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ timer_flag_persist = 1 shl 3
|
|||||||
timer_flag_wait = 1 shl 4
|
timer_flag_wait = 1 shl 4
|
||||||
|
|
||||||
|
|
||||||
macro TCP_timer_160ms {
|
macro tcp_timer_160ms {
|
||||||
|
|
||||||
local .loop
|
local .loop
|
||||||
local .exit
|
local .exit
|
||||||
@ -45,10 +45,7 @@ local .exit
|
|||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_ACK
|
mov cl, TH_ACK
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;;
|
|
||||||
; mov eax, ebx ;;
|
|
||||||
; call TCP_output ;;
|
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
inc [TCPS_delack] ; update stats
|
inc [TCPS_delack] ; update stats
|
||||||
@ -61,7 +58,7 @@ local .exit
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
proc tcp_timer_640ms
|
||||||
|
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
mov ecx, MANUAL_DESTROY
|
mov ecx, MANUAL_DESTROY
|
||||||
@ -77,8 +74,8 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
|
|
||||||
add [TCP_sequence_num], 64000
|
add [TCP_sequence_num], 64000
|
||||||
|
|
||||||
; scan through all the active TCP sockets, decrementing ALL timers
|
; Scan through all the active TCP sockets, decrementing all active timers
|
||||||
; When a timer reaches zero, we'll check wheter it was active or not
|
; When a timer reaches zero, run its handler.
|
||||||
|
|
||||||
mov eax, net_sockets
|
mov eax, net_sockets
|
||||||
.loop:
|
.loop:
|
||||||
@ -95,22 +92,22 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
|
|
||||||
inc [eax + TCP_SOCKET.t_idle]
|
inc [eax + TCP_SOCKET.t_idle]
|
||||||
|
|
||||||
dec [eax + TCP_SOCKET.timer_retransmission]
|
|
||||||
jnz .check_more2
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
jz .check_more2
|
jz .check_more2
|
||||||
|
dec [eax + TCP_SOCKET.timer_retransmission]
|
||||||
|
jnz .check_more2
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
.check_more2:
|
.check_more2:
|
||||||
dec [eax + TCP_SOCKET.timer_keepalive]
|
|
||||||
jnz .check_more3
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
jz .check_more3
|
jz .check_more3
|
||||||
|
dec [eax + TCP_SOCKET.timer_keepalive]
|
||||||
|
jnz .check_more3
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
||||||
|
|
||||||
@ -118,7 +115,7 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
ja .dont_kill
|
ja .dont_kill
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_disconnect
|
call tcp_disconnect
|
||||||
pop eax
|
pop eax
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
@ -129,7 +126,7 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
push eax
|
push eax
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
xor cl, cl
|
xor cl, cl
|
||||||
call TCP_respond ; send keepalive
|
call tcp_respond ; send keepalive
|
||||||
pop eax
|
pop eax
|
||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
|
||||||
jmp .check_more3
|
jmp .check_more3
|
||||||
@ -138,38 +135,38 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
||||||
|
|
||||||
.check_more3:
|
.check_more3:
|
||||||
dec [eax + TCP_SOCKET.timer_timed_wait]
|
|
||||||
jnz .check_more5
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_2msl
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_2msl
|
||||||
jz .check_more5
|
jz .check_more5
|
||||||
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
||||||
|
jnz .check_more5
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
||||||
|
|
||||||
.check_more5:
|
.check_more5:
|
||||||
dec [eax + TCP_SOCKET.timer_persist]
|
|
||||||
jnz .check_more6
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
jz .check_more6
|
jz .check_more6
|
||||||
|
dec [eax + TCP_SOCKET.timer_persist]
|
||||||
|
jnz .check_more6
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
||||||
|
|
||||||
call TCP_set_persist
|
call tcp_set_persist
|
||||||
mov [eax + TCP_SOCKET.t_force], 1
|
mov [eax + TCP_SOCKET.t_force], 1
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
mov [eax + TCP_SOCKET.t_force], 0
|
mov [eax + TCP_SOCKET.t_force], 0
|
||||||
|
|
||||||
.check_more6:
|
.check_more6:
|
||||||
dec [eax + TCP_SOCKET.timer_timed_wait]
|
|
||||||
jnz .loop
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_wait
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
jz .loop
|
jz .loop
|
||||||
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
||||||
|
jnz .loop
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: timed wait timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: timed wait timer expired\n", eax
|
||||||
|
|
||||||
push [eax + SOCKET.NextPtr]
|
push [eax + SOCKET.NextPtr]
|
||||||
call TCP_close
|
call tcp_close
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
jmp .check_only
|
jmp .check_only
|
||||||
@ -187,7 +184,7 @@ endp
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_cancel_timers:
|
tcp_cancel_timers:
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.timer_flags], 0
|
mov [eax + TCP_SOCKET.timer_flags], 0
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ $Revision$
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_usrclosed ;
|
; tcp_usrclosed ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -27,7 +27,7 @@ $Revision$
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_usrclosed:
|
tcp_usrclosed:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_usrclosed: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_usrclosed: %x\n", eax
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ TCP_usrclosed:
|
|||||||
|
|
||||||
.close:
|
.close:
|
||||||
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
call TCP_close
|
call tcp_close
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ TCP_usrclosed:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.disc:
|
.disc:
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
.ret:
|
.ret:
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
@ -74,7 +74,7 @@ TCP_usrclosed:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_connect ;
|
; tcp_connect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -84,7 +84,7 @@ TCP_usrclosed:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_connect:
|
tcp_connect:
|
||||||
|
|
||||||
test [eax + SOCKET.state], SS_ISCONNECTED
|
test [eax + SOCKET.state], SS_ISCONNECTED
|
||||||
jnz .eisconn
|
jnz .eisconn
|
||||||
@ -112,7 +112,7 @@ TCP_connect:
|
|||||||
; Find a local port, if user didnt define one
|
; Find a local port, if user didnt define one
|
||||||
cmp [eax + TCP_SOCKET.LocalPort], 0
|
cmp [eax + TCP_SOCKET.LocalPort], 0
|
||||||
jne @f
|
jne @f
|
||||||
call SOCKET_find_port
|
call socket_find_port
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; Start the TCP sequence
|
; Start the TCP sequence
|
||||||
@ -124,16 +124,16 @@ TCP_connect:
|
|||||||
pop [eax + TCP_SOCKET.ISS]
|
pop [eax + TCP_SOCKET.ISS]
|
||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
|
||||||
|
|
||||||
TCP_sendseqinit eax
|
tcp_sendseqinit eax
|
||||||
|
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nomem
|
jz .nomem
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nomem
|
jz .nomem
|
||||||
|
|
||||||
@ -142,11 +142,11 @@ TCP_connect:
|
|||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call SOCKET_is_connecting
|
call socket_is_connecting
|
||||||
|
|
||||||
; Now send the SYN packet to remote end
|
; Now send the SYN packet to remote end
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
.block:
|
.block:
|
||||||
@ -183,14 +183,14 @@ TCP_connect:
|
|||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
je .established
|
je .established
|
||||||
|
|
||||||
call SOCKET_block
|
call socket_block
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
.timeout:
|
.timeout:
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
mov [eax + SOCKET.errorcode], ETIMEDOUT
|
mov [eax + SOCKET.errorcode], ETIMEDOUT
|
||||||
and [eax + SOCKET.state], not SS_ISCONNECTING
|
and [eax + SOCKET.state], not SS_ISCONNECTING
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
|
@ -38,10 +38,10 @@ endg
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_init: This function resets all UDP variables ;
|
; udp_init: This function resets all UDP variables ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
macro UDP_init {
|
macro udp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, UDP_PACKETS_TX
|
mov edi, UDP_PACKETS_TX
|
||||||
@ -50,7 +50,7 @@ macro UDP_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size, destroys: ecx, edx
|
macro udp_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size, destroys: ecx, edx
|
||||||
|
|
||||||
; Pseudoheader
|
; Pseudoheader
|
||||||
mov edx, IP_PROTO_UDP
|
mov edx, IP_PROTO_UDP
|
||||||
@ -98,7 +98,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_input: Inject the UDP data in the application sockets. ;
|
; udp_input: Inject the UDP data in the application sockets. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: [esp] = ptr to buffer ;
|
; IN: [esp] = ptr to buffer ;
|
||||||
; ebx = ptr to device struct ;
|
; ebx = ptr to device struct ;
|
||||||
@ -111,7 +111,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_input:
|
udp_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ UDP_input:
|
|||||||
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
|
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
|
||||||
|
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
UDP_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress)
|
udp_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress)
|
||||||
jnz .checksum_mismatch
|
jnz .checksum_mismatch
|
||||||
|
|
||||||
.no_checksum:
|
.no_checksum:
|
||||||
@ -194,7 +194,7 @@ UDP_input:
|
|||||||
sub ecx, sizeof.UDP_header
|
sub ecx, sizeof.UDP_header
|
||||||
add esi, sizeof.UDP_header
|
add esi, sizeof.UDP_header
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.updateport:
|
.updateport:
|
||||||
pusha
|
pusha
|
||||||
@ -220,14 +220,14 @@ UDP_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_output: Create an UDP packet. ;
|
; udp_output: Create an UDP packet. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ecx = number of bytes to send ;
|
; ecx = number of bytes to send ;
|
||||||
@ -238,7 +238,7 @@ UDP_input:
|
|||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
UDP_output:
|
udp_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ UDP_output:
|
|||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_UDP
|
mov ah, IP_PROTO_UDP
|
||||||
add ecx, sizeof.UDP_header
|
add ecx, sizeof.UDP_header
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .fail
|
jz .fail
|
||||||
mov [esp + 8], eax ; pointer to buffer start
|
mov [esp + 8], eax ; pointer to buffer start
|
||||||
|
|
||||||
@ -279,13 +279,13 @@ UDP_output:
|
|||||||
; Checksum
|
; Checksum
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
mov [edi + UDP_header.Checksum], 0
|
mov [edi + UDP_header.Checksum], 0
|
||||||
UDP_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options..
|
udp_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options..
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: sending with device %x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: sending with device %x\n", ebx
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [UDP_PACKETS_TX + edi]
|
inc [UDP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ UDP_output:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_connect ;
|
; udp_connect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ;
|
; ;
|
||||||
@ -312,11 +312,11 @@ UDP_output:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_connect:
|
udp_connect:
|
||||||
|
|
||||||
test [eax + SOCKET.state], SS_ISCONNECTED
|
test [eax + SOCKET.state], SS_ISCONNECTED
|
||||||
jz @f
|
jz @f
|
||||||
call UDP_disconnect
|
call udp_disconnect
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
push eax edx
|
push eax edx
|
||||||
@ -340,7 +340,7 @@ UDP_connect:
|
|||||||
; Find a local port, if user didnt define one
|
; Find a local port, if user didnt define one
|
||||||
cmp [eax + UDP_SOCKET.LocalPort], 0
|
cmp [eax + UDP_SOCKET.LocalPort], 0
|
||||||
jne @f
|
jne @f
|
||||||
call SOCKET_find_port
|
call socket_find_port
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
@ -348,7 +348,7 @@ UDP_connect:
|
|||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -364,11 +364,11 @@ UDP_connect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_disconnect:
|
udp_disconnect:
|
||||||
|
|
||||||
; TODO: remove the pending received data
|
; TODO: remove the pending received data
|
||||||
|
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ UDP_disconnect:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_api: This function is called by system function 76 ;
|
; UDP_api: Part of system function 76 ;
|
||||||
; ;
|
; ;
|
||||||
; IN: bl = subfunction number in bl ;
|
; IN: bl = subfunction number in bl ;
|
||||||
; bh = device number in bh ;
|
; bh = device number in bh ;
|
||||||
@ -388,7 +388,7 @@ UDP_disconnect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_api:
|
udp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
Loading…
Reference in New Issue
Block a user