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