diff --git a/kernel/trunk/core/exports.inc b/kernel/trunk/core/exports.inc index 672fc4417b..3108eeaf11 100644 --- a/kernel/trunk/core/exports.inc +++ b/kernel/trunk/core/exports.inc @@ -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', \ \ diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 249080cc37..98d2e967bb 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -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 diff --git a/kernel/trunk/network/ARP.inc b/kernel/trunk/network/ARP.inc index d203599820..5e81805dd9 100644 --- a/kernel/trunk/network/ARP.inc +++ b/kernel/trunk/network/ARP.inc @@ -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 diff --git a/kernel/trunk/network/IPv4.inc b/kernel/trunk/network/IPv4.inc index fb7baa42c1..61cfcd9753 100644 --- a/kernel/trunk/network/IPv4.inc +++ b/kernel/trunk/network/IPv4.inc @@ -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 \ No newline at end of file diff --git a/kernel/trunk/network/IPv6.inc b/kernel/trunk/network/IPv6.inc index 4919318d4f..4ae7e2f591 100644 --- a/kernel/trunk/network/IPv6.inc +++ b/kernel/trunk/network/IPv6.inc @@ -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 diff --git a/kernel/trunk/network/PPPoE.inc b/kernel/trunk/network/PPPoE.inc index 206fa1a789..3c2bed02a9 100644 --- a/kernel/trunk/network/PPPoE.inc +++ b/kernel/trunk/network/PPPoE.inc @@ -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: diff --git a/kernel/trunk/network/ethernet.inc b/kernel/trunk/network/ethernet.inc index 843c4e6bf5..6d9c46bc55 100644 --- a/kernel/trunk/network/ethernet.inc +++ b/kernel/trunk/network/ethernet.inc @@ -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 diff --git a/kernel/trunk/network/icmp.inc b/kernel/trunk/network/icmp.inc index d1d7d50939..4032284cbf 100644 --- a/kernel/trunk/network/icmp.inc +++ b/kernel/trunk/network/icmp.inc @@ -20,70 +20,69 @@ $Revision$ ; ICMP types & codes -ICMP_ECHOREPLY = 0 ; echo reply message +ICMP_ECHOREPLY = 0 ; echo reply message ICMP_UNREACH = 3 -ICMP_UNREACH_NET = 0 ; bad net -ICMP_UNREACH_HOST = 1 ; bad host -ICMP_UNREACH_PROTOCOL = 2 ; bad protocol -ICMP_UNREACH_PORT = 3 ; bad port -ICMP_UNREACH_NEEDFRAG = 4 ; IP_DF caused drop -ICMP_UNREACH_SRCFAIL = 5 ; src route failed -ICMP_UNREACH_NET_UNKNOWN = 6 ; unknown net -ICMP_UNREACH_HOST_UNKNOWN = 7 ; unknown host -ICMP_UNREACH_ISOLATED = 8 ; src host isolated -ICMP_UNREACH_NET_PROHIB = 9 ; prohibited access -ICMP_UNREACH_HOST_PROHIB = 10 ; ditto -ICMP_UNREACH_TOSNET = 11 ; bad tos for net -ICMP_UNREACH_TOSHOST = 12 ; bad tos for host -ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib -ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio. -ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff +ICMP_UNREACH_NET = 0 ; bad net +ICMP_UNREACH_HOST = 1 ; bad host +ICMP_UNREACH_PROTOCOL = 2 ; bad protocol +ICMP_UNREACH_PORT = 3 ; bad port +ICMP_UNREACH_NEEDFRAG = 4 ; IP_DF caused drop +ICMP_UNREACH_SRCFAIL = 5 ; src route failed +ICMP_UNREACH_NET_UNKNOWN = 6 ; unknown net +ICMP_UNREACH_HOST_UNKNOWN = 7 ; unknown host +ICMP_UNREACH_ISOLATED = 8 ; src host isolated +ICMP_UNREACH_NET_PROHIB = 9 ; prohibited access +ICMP_UNREACH_HOST_PROHIB = 10 ; ditto +ICMP_UNREACH_TOSNET = 11 ; bad tos for net +ICMP_UNREACH_TOSHOST = 12 ; bad tos for host +ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib +ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio. +ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff -ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down +ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down -ICMP_REDIRECT = 5 ; shorter route, codes: -ICMP_REDIRECT_NET = 0 ; for network -ICMP_REDIRECT_HOST = 1 ; for host -ICMP_REDIRECT_TOSNET = 2 ; for tos and net -ICMP_REDIRECT_TOSHOST = 3 ; for tos and host +ICMP_REDIRECT = 5 ; shorter route, codes: +ICMP_REDIRECT_NET = 0 ; for network +ICMP_REDIRECT_HOST = 1 ; for host +ICMP_REDIRECT_TOSNET = 2 ; for tos and net +ICMP_REDIRECT_TOSHOST = 3 ; for tos and host -ICMP_ALTHOSTADDR = 6 ; alternate host address -ICMP_ECHO = 8 ; echo service -ICMP_ROUTERADVERT = 9 ; router advertisement -ICMP_ROUTERADVERT_NORMAL = 0 ; normal advertisement -ICMP_ROUTERADVERT_NOROUTE_COMMON= 16 ; selective routing +ICMP_ALTHOSTADDR = 6 ; alternate host address +ICMP_ECHO = 8 ; echo service +ICMP_ROUTERADVERT = 9 ; router advertisement +ICMP_ROUTERADVERT_NORMAL = 0 ; normal advertisement +ICMP_ROUTERADVERT_NOROUTE_COMMON= 16 ; selective routing -ICMP_ROUTERSOLICIT = 10 ; router solicitation -ICMP_TIMXCEED = 11 ; time exceeded, code: -ICMP_TIMXCEED_INTRANS = 0 ; ttl==0 in transit -ICMP_TIMXCEED_REASS = 1 ; ttl==0 in reass +ICMP_ROUTERSOLICIT = 10 ; router solicitation +ICMP_TIMXCEED = 11 ; time exceeded, code: +ICMP_TIMXCEED_INTRANS = 0 ; ttl==0 in transit +ICMP_TIMXCEED_REASS = 1 ; ttl==0 in reass -ICMP_PARAMPROB = 12 ; ip header bad -ICMP_PARAMPROB_ERRATPTR = 0 ; error at param ptr -ICMP_PARAMPROB_OPTABSENT = 1 ; req. opt. absent -ICMP_PARAMPROB_LENGTH = 2 ; bad length +ICMP_PARAMPROB = 12 ; ip header bad +ICMP_PARAMPROB_ERRATPTR = 0 ; error at param ptr +ICMP_PARAMPROB_OPTABSENT = 1 ; req. opt. absent +ICMP_PARAMPROB_LENGTH = 2 ; bad length -ICMP_TSTAMP = 13 ; timestamp request -ICMP_TSTAMPREPLY = 14 ; timestamp reply -ICMP_IREQ = 15 ; information request -ICMP_IREQREPLY = 16 ; information reply -ICMP_MASKREQ = 17 ; address mask request -ICMP_MASKREPLY = 18 ; address mask reply -ICMP_TRACEROUTE = 30 ; traceroute -ICMP_DATACONVERR = 31 ; data conversion error -ICMP_MOBILE_REDIRECT = 32 ; mobile host redirect -ICMP_IPV6_WHEREAREYOU = 33 ; IPv6 where-are-you -ICMP_IPV6_IAMHERE = 34 ; IPv6 i-am-here -ICMP_MOBILE_REGREQUEST = 35 ; mobile registration req -ICMP_MOBILE_REGREPLY = 36 ; mobile registreation reply -ICMP_SKIP = 39 ; SKIP - -ICMP_PHOTURIS = 40 ; Photuris -ICMP_PHOTURIS_UNKNOWN_INDEX = 1 ; unknown sec index -ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed -ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed +ICMP_TSTAMP = 13 ; timestamp request +ICMP_TSTAMPREPLY = 14 ; timestamp reply +ICMP_IREQ = 15 ; information request +ICMP_IREQREPLY = 16 ; information reply +ICMP_MASKREQ = 17 ; address mask request +ICMP_MASKREPLY = 18 ; address mask reply +ICMP_TRACEROUTE = 30 ; traceroute +ICMP_DATACONVERR = 31 ; data conversion error +ICMP_MOBILE_REDIRECT = 32 ; mobile host redirect +ICMP_IPV6_WHEREAREYOU = 33 ; IPv6 where-are-you +ICMP_IPV6_IAMHERE = 34 ; IPv6 i-am-here +ICMP_MOBILE_REGREQUEST = 35 ; mobile registration req +ICMP_MOBILE_REGREPLY = 36 ; mobile registreation reply +ICMP_SKIP = 39 ; SKIP +ICMP_PHOTURIS = 40 ; Photuris +ICMP_PHOTURIS_UNKNOWN_INDEX = 1 ; unknown sec index +ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed +ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed struct ICMP_header @@ -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 diff --git a/kernel/trunk/network/loopback.inc b/kernel/trunk/network/loopback.inc index 0cd73ef89f..cf11f35155 100644 --- a/kernel/trunk/network/loopback.inc +++ b/kernel/trunk/network/loopback.inc @@ -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 diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 7137259162..5d8cf906ca 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -207,10 +207,10 @@ endg ;-----------------------------------------------------------------; ; ; -; SOCKET_init ; +; socket_init ; ; ; ;-----------------------------------------------------------------; -macro SOCKET_init { +macro socket_init { xor eax, eax mov edi, net_sockets @@ -251,24 +251,24 @@ sys_socket: mov dword[esp+20], 0 ; Set error code to 0 cmp ebx, 255 - jz SOCKET_debug + jz socket_debug cmp ebx, .number ja .error jmp dword [.table + 4*ebx] .table: - dd SOCKET_open ; 0 - dd SOCKET_close ; 1 - dd SOCKET_bind ; 2 - dd SOCKET_listen ; 3 - dd SOCKET_connect ; 4 - dd SOCKET_accept ; 5 - dd SOCKET_send ; 6 - dd SOCKET_receive ; 7 - dd SOCKET_set_opt ; 8 - dd SOCKET_get_opt ; 9 - dd SOCKET_pair ; 10 + dd socket_open ; 0 + dd socket_close ; 1 + dd socket_bind ; 2 + dd socket_listen ; 3 + dd socket_connect ; 4 + dd socket_accept ; 5 + dd socket_send ; 6 + dd socket_receive ; 7 + dd socket_set_opt ; 8 + dd socket_get_opt ; 9 + dd socket_pair ; 10 .number = ($ - .table) / 4 - 1 .error: @@ -279,7 +279,7 @@ sys_socket: ;-----------------------------------------------------------------; ; ; -; SOCKET_open: Create a new socket. ; +; socket_open: Create a new socket. ; ; ; ; IN: ecx = domain ; ; edx = type ; @@ -291,12 +291,12 @@ sys_socket: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_open: +socket_open: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi push ecx edx esi - call SOCKET_alloc + call socket_alloc pop esi edx ecx test eax, eax jz .nobuffs @@ -339,7 +339,7 @@ SOCKET_open: .no_ppp: .unsupported: push eax - call SOCKET_free + call socket_free pop eax mov dword[esp+20], EOPNOTSUPP mov dword[esp+32], -1 @@ -366,19 +366,19 @@ align 4 pop eax mov [eax + SOCKET.Protocol], IP_PROTO_UDP - mov [eax + SOCKET.snd_proc], SOCKET_send_udp - mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram - mov [eax + SOCKET.connect_proc], UDP_connect + mov [eax + SOCKET.snd_proc], socket_send_udp + mov [eax + SOCKET.rcv_proc], socket_receive_dgram + mov [eax + SOCKET.connect_proc], udp_connect ret align 4 .tcp: mov [eax + SOCKET.Protocol], IP_PROTO_TCP - mov [eax + SOCKET.snd_proc], SOCKET_send_tcp - mov [eax + SOCKET.rcv_proc], SOCKET_receive_stream - mov [eax + SOCKET.connect_proc], TCP_connect + mov [eax + SOCKET.snd_proc], socket_send_tcp + mov [eax + SOCKET.rcv_proc], socket_receive_stream + mov [eax + SOCKET.connect_proc], tcp_connect - TCP_init_socket eax + tcp_init_socket eax ret @@ -388,9 +388,9 @@ align 4 init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue pop eax - mov [eax + SOCKET.snd_proc], SOCKET_send_ip - mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram - mov [eax + SOCKET.connect_proc], IPv4_connect + mov [eax + SOCKET.snd_proc], socket_send_ip + mov [eax + SOCKET.rcv_proc], socket_receive_dgram + mov [eax + SOCKET.connect_proc], ipv4_connect ret @@ -400,9 +400,9 @@ align 4 init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue pop eax - mov [eax + SOCKET.snd_proc], SOCKET_send_icmp - mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram - mov [eax + SOCKET.connect_proc], IPv4_connect + mov [eax + SOCKET.snd_proc], socket_send_icmp + mov [eax + SOCKET.rcv_proc], socket_receive_dgram + mov [eax + SOCKET.connect_proc], ipv4_connect ret align 4 @@ -411,14 +411,14 @@ align 4 init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue pop eax - mov [eax + SOCKET.snd_proc], SOCKET_send_pppoe - mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram + mov [eax + SOCKET.snd_proc], socket_send_pppoe + mov [eax + SOCKET.rcv_proc], socket_receive_dgram ret ;-----------------------------------------------------------------; ; ; -; SOCKET_bind: Bind to a local port. ; +; socket_bind: Bind to a local port. ; ; ; ; IN: ecx = socket number ; ; edx = pointer to sockaddr struct ; @@ -430,11 +430,11 @@ align 4 ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_bind: +socket_bind: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_bind: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -444,10 +444,10 @@ SOCKET_bind: cmp [eax + UDP_SOCKET.LocalPort], 0 ; Socket can only be bound once jnz .invalid - cmp word [edx], AF_INET4 + cmp word[edx], AF_INET4 je .af_inet4 - cmp word [edx], AF_LOCAL + cmp word[edx], AF_LOCAL je .af_local .notsupp: @@ -479,18 +479,17 @@ SOCKET_bind: .tcp: .udp: - pushd [edx + 4] ; First, fill in the IP popd [eax + IP_SOCKET.LocalIP] mov bx, [edx + 2] ; Did caller specify a local port? test bx, bx jnz .just_check - call SOCKET_find_port ; Nope, find an ephemeral one + call socket_find_port ; Nope, find an ephemeral one jmp .done .just_check: - call SOCKET_check_port ; Yes, check if it's still available + call socket_check_port ; Yes, check if it's still available jz .addrinuse ; ZF is set by socket_check_port on error .done: @@ -511,7 +510,7 @@ SOCKET_bind: ;-----------------------------------------------------------------; ; ; -; SOCKET_connect: Connect to the remote host. ; +; socket_connect: Connect to the remote host. ; ; ; ; IN: ecx = socket number ; ; edx = pointer to sockaddr struct ; @@ -523,11 +522,11 @@ SOCKET_bind: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_connect: +socket_connect: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_connect: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -572,7 +571,7 @@ connect_notsupp: ;-----------------------------------------------------------------; ; ; -; SOCKET_listen: Listen for incoming connections. ; +; socket_listen: Listen for incoming connections. ; ; ; ; IN: ecx = socket number ; ; edx = backlog in edx ; @@ -583,11 +582,11 @@ connect_notsupp: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_listen: +socket_listen: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_listen: socknum=%u backlog=%u\n", ecx, edx - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -641,7 +640,7 @@ SOCKET_listen: ;-----------------------------------------------------------------; ; ; -; SOCKET_accept: Accept an incoming connection. ; +; socket_accept: Accept an incoming connection. ; ; ; ; IN: ecx = socket number (of listening socket) ; ; edx = ptr to sockaddr struct ; @@ -653,11 +652,11 @@ SOCKET_listen: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_accept: +socket_accept: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_accept: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -677,7 +676,7 @@ SOCKET_accept: mov eax, [esi] ; Verify that it is (still) a valid socket - call SOCKET_check + call socket_check jz .invalid ; Change sockets thread owner ID to that of the current thread @@ -694,7 +693,7 @@ SOCKET_accept: test [eax + SOCKET.options], SO_NONBLOCK jnz .wouldblock - call SOCKET_block + call socket_block jmp .loop .wouldblock: @@ -714,7 +713,7 @@ SOCKET_accept: ;-----------------------------------------------------------------; ; ; -; SOCKET_close: Close the socket (and connection). ; +; socket_close: Close the socket (and connection). ; ; ; ; IN: ecx = socket number ; ; ; @@ -724,11 +723,11 @@ SOCKET_accept: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_close: +socket_close: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_close: socknum=%u\n", ecx - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -738,7 +737,7 @@ SOCKET_close: test [eax + SOCKET.state], SS_BLOCKED ; Is the socket still in blocked state? jz @f - call SOCKET_notify ; Unblock it. + call socket_notify ; Unblock it. @@: cmp [eax + SOCKET.Domain], AF_INET4 @@ -748,15 +747,15 @@ SOCKET_close: je .tcp .free: - call SOCKET_free + call socket_free ret .tcp: - call TCP_usrclosed + call tcp_usrclosed test eax, eax jz @f - call TCP_output ; If connection is not closed yet, send the FIN + call tcp_output ; If connection is not closed yet, send the FIN @@: ret @@ -769,7 +768,7 @@ SOCKET_close: ;-----------------------------------------------------------------; ; ; -; SOCKET_receive: Receive some data from the remote end. ; +; socket_receive: Receive some data from the remote end. ; ; ; ; IN: ecx = socket number ; ; edx = addr to application buffer ; @@ -783,11 +782,11 @@ SOCKET_close: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_receive: +socket_receive: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: socknum=%u bufaddr=%x buflength=%u flags=%x\n", ecx, edx, esi, edi - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -808,7 +807,7 @@ SOCKET_receive: test [eax + SOCKET.options], SO_NONBLOCK jnz .return_err - call SOCKET_block + call socket_block jmp .loop @@ -825,14 +824,14 @@ SOCKET_receive: .last_data: test ecx, ecx jz .return - call SOCKET_notify ; Call me again! + call socket_notify ; Call me again! jmp .return align 4 -SOCKET_receive_dgram: +socket_receive_dgram: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: DGRAM\n" @@ -868,11 +867,11 @@ SOCKET_receive_dgram: rep movsd .nd: - call NET_BUFF_free + call net_buff_free pop ecx eax ; return number of bytes copied to application cmp [eax + SOCKET_QUEUE_LOCATION + queue.size], 0 je @f - call SOCKET_notify ; Queue another network event + call socket_notify ; Queue another network event @@: xor ebx, ebx ; errorcode = 0 (no error) ret @@ -900,7 +899,7 @@ SOCKET_receive_dgram: align 4 -SOCKET_receive_local: +socket_receive_local: ; does this socket have a PID yet? cmp [eax + SOCKET.PID], 0 @@ -913,12 +912,12 @@ SOCKET_receive_local: mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( @@: - mov [eax + SOCKET.rcv_proc], SOCKET_receive_stream + mov [eax + SOCKET.rcv_proc], socket_receive_stream ; ... continue to SOCKET_receive_stream align 4 -SOCKET_receive_stream: +socket_receive_stream: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: STREAM\n" @@ -934,8 +933,8 @@ SOCKET_receive_stream: push eax add eax, STREAM_SOCKET.rcv - call SOCKET_ring_read ; copy data from kernel buffer to application buffer - call SOCKET_ring_free ; free read memory + call socket_ring_read ; copy data from kernel buffer to application buffer + call socket_ring_free ; free read memory pop eax cmp [eax + STREAM_SOCKET.rcv + RING_BUFFER.size], 0 @@ -944,7 +943,7 @@ SOCKET_receive_stream: ret .more_data: - call SOCKET_notify ; Queue another network event + call socket_notify ; Queue another network event xor ebx, ebx ; errorcode = 0 (no error) ret @@ -962,7 +961,7 @@ SOCKET_receive_stream: ;-----------------------------------------------------------------; ; ; -; SOCKET_send: Send some data to the remote end. ; +; socket_send: Send some data to the remote end. ; ; ; ; IN: ecx = socket number ; ; edx = pointer to data ; @@ -975,11 +974,11 @@ SOCKET_receive_stream: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_send: +socket_send: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: socknum=%u data ptr=%x length=%u flags=%x\n", ecx, edx, esi, edi - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -995,12 +994,12 @@ SOCKET_send: align 4 -SOCKET_send_udp: +socket_send_udp: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: UDP\n" mov [esp+32], ecx - call UDP_output + call udp_output cmp eax, -1 je .error ret @@ -1012,19 +1011,19 @@ SOCKET_send_udp: align 4 -SOCKET_send_tcp: +socket_send_tcp: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: TCP\n" push eax add eax, STREAM_SOCKET.snd - call SOCKET_ring_write + call socket_ring_write pop eax mov [esp+32], ecx mov [eax + SOCKET.errorcode], 0 push eax - call TCP_output ; FIXME: this doesnt look pretty, does it? + call tcp_output ; FIXME: this doesnt look pretty, does it? pop eax mov eax, [eax + SOCKET.errorcode] mov [esp+20], eax @@ -1032,12 +1031,12 @@ SOCKET_send_tcp: align 4 -SOCKET_send_ip: +socket_send_ip: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: IPv4\n" mov [esp+32], ecx - call IPv4_output_raw + call ipv4_output_raw cmp eax, -1 je .error ret @@ -1049,12 +1048,12 @@ SOCKET_send_ip: align 4 -SOCKET_send_icmp: +socket_send_icmp: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: ICMP\n" mov [esp+32], ecx - call ICMP_output_raw + call icmp_output_raw cmp eax, -1 je .error ret @@ -1066,14 +1065,14 @@ SOCKET_send_icmp: align 4 -SOCKET_send_pppoe: +socket_send_pppoe: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n" mov [esp+32], ecx mov ebx, [eax + SOCKET.device] - call PPPoE_discovery_output ; FIXME: errorcodes + call pppoe_discovery_output ; FIXME: errorcodes cmp eax, -1 je .error ret @@ -1086,7 +1085,7 @@ SOCKET_send_pppoe: align 4 -SOCKET_send_local: +socket_send_local: ; does this socket have a PID yet? cmp [eax + SOCKET.PID], 0 @@ -1098,29 +1097,29 @@ SOCKET_send_local: mov [eax + SOCKET.PID], ebx mov [eax + SOCKET.TID], ebx ; currently TID = PID in kolibrios :( @@: - mov [eax + SOCKET.snd_proc], SOCKET_send_local_ + mov [eax + SOCKET.snd_proc], socket_send_local_initialized align 4 -SOCKET_send_local_: +socket_send_local_initialized: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: LOCAL\n" ; get the other side's socket and check if it still exists mov eax, [eax + SOCKET.device] - call SOCKET_check + call socket_check jz .invalid ; allright, shove in the data! push eax add eax, STREAM_SOCKET.rcv - call SOCKET_ring_write + call socket_ring_write pop eax ; return the number of written bytes (or errorcode) to application mov [esp+32], ecx ; and notify the other end - call SOCKET_notify + call socket_notify ret @@ -1132,7 +1131,7 @@ SOCKET_send_local_: ;-----------------------------------------------------------------; ; ; -; SOCKET_get_options: Read a socket option ; +; socket_get_opt: Read a socket option ; ; ; ; IN: ecx = socket number ; ; edx = pointer to socket options struct ; @@ -1143,7 +1142,7 @@ SOCKET_send_local_: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_get_opt: +socket_get_opt: ; FIXME: ; At moment, uses only pseudo-optname -2 for get last_ack_number for TCP. @@ -1152,7 +1151,7 @@ SOCKET_get_opt: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_get_opt\n" - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -1194,7 +1193,7 @@ SOCKET_get_opt: ;-----------------------------------------------------------------; ; ; -; SOCKET_set_options: Set a socket option. ; +; socket_set_options: Set a socket option. ; ; ; ; IN: ecx = socket number ; ; edx = pointer to socket options struct ; @@ -1205,11 +1204,11 @@ SOCKET_get_opt: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_set_opt: +socket_set_opt: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_set_opt\n" - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -1272,7 +1271,7 @@ SOCKET_set_opt: ;-----------------------------------------------------------------; ; ; -; SOCKET_pair: Allocate a pair of linked local sockets. ; +; socket_pair: Allocate a pair of linked local sockets. ; ; ; ; IN: / ; ; ; @@ -1283,11 +1282,11 @@ SOCKET_set_opt: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_pair: +socket_pair: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n" - call SOCKET_alloc + call socket_alloc test eax, eax jz .nomem1 mov [esp+32], edi ; application's eax @@ -1295,12 +1294,12 @@ SOCKET_pair: mov [eax + SOCKET.Domain], AF_LOCAL mov [eax + SOCKET.Type], SOCK_STREAM mov [eax + SOCKET.Protocol], 0 ;;; CHECKME - mov [eax + SOCKET.snd_proc], SOCKET_send_local - mov [eax + SOCKET.rcv_proc], SOCKET_receive_local + mov [eax + SOCKET.snd_proc], socket_send_local + mov [eax + SOCKET.rcv_proc], socket_receive_local mov [eax + SOCKET.PID], 0 mov ebx, eax - call SOCKET_alloc + call socket_alloc test eax, eax jz .nomem2 mov [esp+20], edi ; application's ebx @@ -1308,8 +1307,8 @@ SOCKET_pair: mov [eax + SOCKET.Domain], AF_LOCAL mov [eax + SOCKET.Type], SOCK_STREAM mov [eax + SOCKET.Protocol], 0 ;;; CHECKME - mov [eax + SOCKET.snd_proc], SOCKET_send_local - mov [eax + SOCKET.rcv_proc], SOCKET_receive_local + mov [eax + SOCKET.snd_proc], socket_send_local + mov [eax + SOCKET.rcv_proc], socket_receive_local mov [eax + SOCKET.PID], 0 ; Link the two sockets to eachother @@ -1317,12 +1316,12 @@ SOCKET_pair: mov [ebx + SOCKET.device], eax lea eax, [eax + STREAM_SOCKET.rcv] - call SOCKET_ring_create + call socket_ring_create test eax, eax jz .nomem2 lea eax, [ebx + STREAM_SOCKET.rcv] - call SOCKET_ring_create + call socket_ring_create test eax, eax jz .nomem2 @@ -1330,11 +1329,11 @@ SOCKET_pair: .nomem2: mov eax, [esp+20] - call SOCKET_free + call socket_free .nomem1: mov eax, [esp+32] - call SOCKET_free + call socket_free mov dword[esp+32], -1 mov dword[esp+20], ENOMEM @@ -1344,7 +1343,7 @@ SOCKET_pair: ;-----------------------------------------------------------------; ; ; -; SOCKET_debug: Copy socket variables to application buffer. ; +; socket_debug: Copy socket variables to application buffer. ; ; ; ; IN: ecx = socket number ; ; edx = pointer to application buffer ; @@ -1355,7 +1354,7 @@ SOCKET_pair: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_debug: +socket_debug: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_debug\n" @@ -1364,7 +1363,7 @@ SOCKET_debug: test ecx, ecx jz .returnall - call SOCKET_num_to_ptr + call socket_num_to_ptr test eax, eax jz .invalid @@ -1407,7 +1406,7 @@ SOCKET_debug: ;-----------------------------------------------------------------; ; ; -; SOCKET_find_port: ; +; socket_find_port: ; ; Fill in the local port number for TCP and UDP sockets ; ; This procedure always works because the number of sockets is ; ; limited to a smaller number then the number of possible ports ; @@ -1418,7 +1417,7 @@ SOCKET_debug: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_find_port: +socket_find_port: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_find_port\n" @@ -1459,7 +1458,7 @@ SOCKET_find_port: add bh, 1 adc bl, 0 - call SOCKET_check_port + call socket_check_port jz .findit ret @@ -1467,11 +1466,10 @@ SOCKET_find_port: ;-----------------------------------------------------------------; ; ; -; SOCKET_check_port (to be used with AF_INET only!) ; -; ; +; socket_check_port: (to be used with AF_INET only!) ; ; Checks if a local port number is unused ; ; If the proposed port number is unused, it is filled in in the ; -; socket structure ; +; socket structure. ; ; ; ; IN: eax = socket ptr ; ; bx = proposed socket number (network byte order) ; @@ -1480,7 +1478,7 @@ SOCKET_find_port: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_check_port: +socket_check_port: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_port: " @@ -1530,7 +1528,7 @@ SOCKET_check_port: ;-----------------------------------------------------------------; ; ; -; SOCKET_input: Update a (stateless) socket with received data. ; +; socket_input: Update a (stateless) socket with received data. ; ; ; ; Note: The socket's mutex should already be set ! ; ; ; @@ -1543,7 +1541,7 @@ SOCKET_check_port: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_input: +socket_input: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket=%x, data=%x size=%u\n", eax, esi, ecx @@ -1551,7 +1549,7 @@ SOCKET_input: push esi mov esi, esp - add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, SOCKET_input.full + add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, .full DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: success\n" add esp, sizeof.socket_queue_entry @@ -1561,7 +1559,7 @@ SOCKET_input: call mutex_unlock popa - jmp SOCKET_notify + jmp socket_notify .full: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket %x is full!\n", eax @@ -1572,13 +1570,13 @@ SOCKET_input: popa add esp, 8 - call NET_BUFF_free + call net_buff_free ret ;-----------------------------------------------------------------; ; ; -; SOCKET_ring_create: Create a ringbuffer for sockets. ; +; socket_ring_create: Create a ringbuffer for sockets. ; ; ; ; IN: eax = ptr to ring struct ; ; ; @@ -1587,7 +1585,7 @@ SOCKET_input: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_ring_create: +socket_ring_create: push esi mov esi, eax @@ -1623,7 +1621,7 @@ SOCKET_ring_create: ;-----------------------------------------------------------------; ; ; -; SOCKET_ring_write: Write data to ring buffer. ; +; socket_ring_write: Write data to ring buffer. ; ; ; ; IN: eax = ptr to ring struct ; ; ecx = data size ; @@ -1633,7 +1631,7 @@ SOCKET_ring_create: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_ring_write: +socket_ring_write: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_write: ringbuff=%x ptr=%x size=%u\n", eax, esi, ecx @@ -1693,7 +1691,7 @@ SOCKET_ring_write: ;-----------------------------------------------------------------; ; ; -; SOCKET_ring_read: Read from ring buffer ; +; socket_ring_read: Read from ring buffer ; ; ; ; IN: eax = ring struct ptr ; ; ecx = bytes to read ; @@ -1708,7 +1706,7 @@ SOCKET_ring_write: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_ring_read: +socket_ring_read: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_read: ringbuff=%x ptr=%x size=%u offset=%x\n", eax, edi, ecx, edx @@ -1767,7 +1765,7 @@ SOCKET_ring_read: ;-----------------------------------------------------------------; ; ; -; SOCKET_ring_free: Free data from a ringbuffer ; +; socket_ring_free: Free data from a ringbuffer. ; ; ; ; IN: eax = ptr to ring struct ; ; ecx = data size ; @@ -1776,7 +1774,7 @@ SOCKET_ring_read: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_ring_free: +socket_ring_free: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_free: %u bytes from ring %x\n", ecx, eax @@ -1817,7 +1815,7 @@ SOCKET_ring_free: ;-----------------------------------------------------------------; ; ; -; SOCKET_block: Suspend the thread attached to a socket. ; +; socket_block: Suspend the thread attached to a socket. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -1825,7 +1823,7 @@ SOCKET_ring_free: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_block: +socket_block: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax @@ -1859,7 +1857,7 @@ SOCKET_block: ;-----------------------------------------------------------------; ; ; -; SOCKET_notify: Wake up socket owner thread. ; +; socket_notify: Wake up socket owner thread. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -1867,11 +1865,11 @@ SOCKET_block: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_notify: +socket_notify: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax - call SOCKET_check + call socket_check jz .error ; Find the associated thread's TASK_DATA @@ -1927,10 +1925,9 @@ SOCKET_notify: ;-----------------------------------------------------------------; ; ; -; SOCKET_alloc: ; -; Allocate memory for socket and put new socket into the list. ; -; Newly created socket is initialized with calling PID and socket ; -; number. ; +; socket_alloc: Allocate memory for socket and put new socket ; +; into the list. Newly created socket is initialized with calling ; +; PID and given a socket number. ; ; ; ; IN: / ; ; ; @@ -1940,7 +1937,7 @@ SOCKET_notify: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_alloc: +socket_alloc: push ebx @@ -2045,9 +2042,8 @@ SOCKET_alloc: ;-----------------------------------------------------------------; ; ; -; SOCKET_free: ; -; Free socket data memory and remove socket from the list. ; -; Caller should lock and unlock socket_mutex. ; +; socket_free: Free socket data memory and remove socket from ; +; the list. Caller should lock and unlock socket_mutex. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2055,11 +2051,11 @@ SOCKET_alloc: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_free: +socket_free: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: %x\n", eax - call SOCKET_check + call socket_check jz .error push ebx @@ -2117,7 +2113,7 @@ SOCKET_free: ;-----------------------------------------------------------------; ; ; -; SOCKET_fork: Create a child socket. ; +; socket_fork: Create a child socket. ; ; ; ; IN: ebx = socket number ; ; ; @@ -2126,7 +2122,7 @@ SOCKET_free: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_fork: +socket_fork: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_fork: %x\n", ebx @@ -2137,7 +2133,7 @@ SOCKET_fork: ; Allocate new socket push ebx - call SOCKET_alloc + call socket_alloc pop ebx test eax, eax jz .fail @@ -2160,7 +2156,7 @@ SOCKET_fork: ; Notify owner of parent socket push eax mov eax, ebx - call SOCKET_notify + call socket_notify pop eax ret @@ -2175,7 +2171,7 @@ SOCKET_fork: ;-----------------------------------------------------------------; ; ; -; SOCKET_num_to_ptr: Get socket structure address by its number. ; +; socket_num_to_ptr: Get socket structure address by its number. ; ; ; ; IN: ecx = socket number ; ; ; @@ -2184,7 +2180,7 @@ SOCKET_fork: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_num_to_ptr: +socket_num_to_ptr: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_num_to_ptr: num=%u ", ecx @@ -2222,7 +2218,7 @@ SOCKET_num_to_ptr: ;-----------------------------------------------------------------; ; ; -; SOCKET_ptr_to_num: Get socket number by its address. ; +; socket_ptr_to_num: Get socket number by its address. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2232,11 +2228,11 @@ SOCKET_num_to_ptr: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_ptr_to_num: +socket_ptr_to_num: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ptr_to_num: ptr=%x ", eax - call SOCKET_check + call socket_check jz .error mov eax, [eax + SOCKET.Number] @@ -2251,7 +2247,7 @@ SOCKET_ptr_to_num: ;-----------------------------------------------------------------; ; ; -; SOCKET_check: Checks if the given ptr is really a socket ptr. ; +; socket_check: Checks if the given ptr is really a socket ptr. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2260,7 +2256,7 @@ SOCKET_ptr_to_num: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_check: +socket_check: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check: %x\n", eax @@ -2291,7 +2287,7 @@ SOCKET_check: ;-----------------------------------------------------------------; ; ; -; SOCKET_check_owner: Check if the caller app owns the socket. ; +; socket_check_owner: Check if the caller app owns the socket. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2299,7 +2295,7 @@ SOCKET_check: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_check_owner: +socket_check_owner: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_owner: %x\n", eax @@ -2316,10 +2312,9 @@ SOCKET_check_owner: ;-----------------------------------------------------------------; ; ; -; SOCKET_process_end: ; -; Kernel calls this function when a certain process ends. ; -; This function will check if the process had any open sockets, ; -; and update them accordingly (clean up). ; +; socket_process_end: Kernel calls this function when a certain ; +; process ends. This function will check if the process had any ; +; open sockets and update them accordingly (clean up). ; ; ; ; IN: edx = pid ; ; ; @@ -2327,7 +2322,7 @@ SOCKET_check_owner: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_process_end: +socket_process_end: ret ; FIXME @@ -2368,11 +2363,11 @@ SOCKET_process_end: cmp [eax + SOCKET.Protocol], IP_PROTO_TCP jne .free - call TCP_disconnect + call tcp_disconnect jmp .closed .free: - call SOCKET_free + call socket_free .closed: popa @@ -2394,7 +2389,7 @@ SOCKET_process_end: ;-----------------------------------------------------------------; ; ; -; SOCKET_is_connecting: Update socket state. ; +; socket_is_connecting: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2402,7 +2397,7 @@ SOCKET_process_end: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_is_connecting: +socket_is_connecting: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_connecting: %x\n", eax @@ -2414,7 +2409,7 @@ SOCKET_is_connecting: ;-----------------------------------------------------------------; ; ; -; SOCKET_is_connected: Update socket state. ; +; socket_is_connected: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2422,20 +2417,20 @@ SOCKET_is_connecting: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_is_connected: +socket_is_connected: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_connected: %x\n", eax and [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISDISCONNECTING + SS_ISCONFIRMING) or [eax + SOCKET.state], SS_ISCONNECTED - jmp SOCKET_notify + jmp socket_notify ;-----------------------------------------------------------------; ; ; -; SOCKET_is_disconnecting: Update socket state. ; +; socket_is_disconnecting: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2443,19 +2438,19 @@ SOCKET_is_connected: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_is_disconnecting: +socket_is_disconnecting: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnecting: %x\n", eax and [eax + SOCKET.state], not (SS_ISCONNECTING) or [eax + SOCKET.state], SS_ISDISCONNECTING + SS_CANTRCVMORE + SS_CANTSENDMORE - jmp SOCKET_notify + jmp socket_notify ;-----------------------------------------------------------------; ; ; -; SOCKET_is_disconnected: Update socket state. ; +; socket_is_disconnected: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2463,19 +2458,19 @@ SOCKET_is_disconnecting: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_is_disconnected: +socket_is_disconnected: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax and [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING) or [eax + SOCKET.state], SS_CANTRCVMORE + SS_CANTSENDMORE - jmp SOCKET_notify + jmp socket_notify ;-----------------------------------------------------------------; ; ; -; SOCKET_cant_recv_more: Update socket state. ; +; socket_cant_recv_more: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2483,18 +2478,18 @@ SOCKET_is_disconnected: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_cant_recv_more: +socket_cant_recv_more: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_recv_more: %x\n", eax or [eax + SOCKET.state], SS_CANTRCVMORE - jmp SOCKET_notify + jmp socket_notify ;-----------------------------------------------------------------; ; ; -; SOCKET_cant_send_more: Update socket state. ; +; socket_cant_send_more: Update socket state. ; ; ; ; IN: eax = socket ptr ; ; ; @@ -2502,13 +2497,13 @@ SOCKET_cant_recv_more: ; ; ;-----------------------------------------------------------------; align 4 -SOCKET_cant_send_more: +socket_cant_send_more: DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax or [eax + SOCKET.state], SS_CANTSENDMORE mov [eax + SOCKET.snd_proc], .notconn - jmp SOCKET_notify + jmp socket_notify .notconn: mov dword[esp+20], ENOTCONN diff --git a/kernel/trunk/network/stack.inc b/kernel/trunk/network/stack.inc index ec10d5a9ee..670a6778d0 100644 --- a/kernel/trunk/network/stack.inc +++ b/kernel/trunk/network/stack.inc @@ -163,8 +163,8 @@ NET_HWACC_TCP_IPv4_IN = 1 shl 0 NET_HWACC_TCP_IPv4_OUT = 1 shl 1 ; Network frame types -NET_BUFF_LOOPBACK = 0 -NET_BUFF_ETH = 1 +NET_BUFF_LOOPBACK = 0 +NET_BUFF_ETH = 1 struct NET_DEVICE @@ -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: @@ -736,7 +727,7 @@ sys_network: and esi, 0x0000ff00 shr esi, 6 - cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running + cmp dword[esi + NET_DRV_LIST], 0 ; check if driver is running je .doesnt_exist mov eax, [esi + NET_DRV_LIST] @@ -809,16 +800,16 @@ sys_network: ret .bytes_tx: - mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4] + mov ebx, dword[eax + NET_DEVICE.bytes_tx + 4] mov [esp+20], ebx - mov eax, dword [eax + NET_DEVICE.bytes_tx] + mov eax, dword[eax + NET_DEVICE.bytes_tx] mov [esp+32], eax ret .bytes_rx: - mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4] + mov ebx, dword[eax + NET_DEVICE.bytes_rx + 4] mov [esp+20], ebx - mov eax, dword [eax + NET_DEVICE.bytes_rx] + mov eax, dword[eax + NET_DEVICE.bytes_rx] mov [esp+32], eax ret @@ -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 diff --git a/kernel/trunk/network/tcp.inc b/kernel/trunk/network/tcp.inc index ea772dfd45..71a632011e 100644 --- a/kernel/trunk/network/tcp.inc +++ b/kernel/trunk/network/tcp.inc @@ -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 diff --git a/kernel/trunk/network/tcp_input.inc b/kernel/trunk/network/tcp_input.inc index 0765cd9b92..afc754110e 100644 --- a/kernel/trunk/network/tcp_input.inc +++ b/kernel/trunk/network/tcp_input.inc @@ -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 @@ -1334,8 +1334,8 @@ align 4 cmp eax, TF_REQ_SCALE or TF_RCVD_SCALE jne .no_scaling - mov ax, word [ebx + TCP_SOCKET.requested_s_scale] - mov word [ebx + TCP_SOCKET.SND_SCALE], ax + mov ax, word[ebx + TCP_SOCKET.requested_s_scale] + mov word[ebx + TCP_SOCKET.SND_SCALE], ax .no_scaling: ;;; TODO: reassemble packets queue @@ -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 diff --git a/kernel/trunk/network/tcp_output.inc b/kernel/trunk/network/tcp_output.inc index 75f607b735..56d50731fe 100644 --- a/kernel/trunk/network/tcp_output.inc +++ b/kernel/trunk/network/tcp_output.inc @@ -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" diff --git a/kernel/trunk/network/tcp_subr.inc b/kernel/trunk/network/tcp_subr.inc index c06f5fb44b..c7034dfb8d 100644 --- a/kernel/trunk/network/tcp_subr.inc +++ b/kernel/trunk/network/tcp_subr.inc @@ -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,10 +231,10 @@ TCP_close: ; ; ;-----------------------------------------------------------------; align 4 -TCP_outflags: +tcp_outflags: mov edx, [eax + TCP_SOCKET.t_state] - movzx edx, byte [edx + .flaglist] + movzx edx, byte[edx + .flaglist] DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_outflags: socket=%x flags=%x\n", eax, dl @@ -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 diff --git a/kernel/trunk/network/tcp_timer.inc b/kernel/trunk/network/tcp_timer.inc index f47f9d11c3..850af138d0 100644 --- a/kernel/trunk/network/tcp_timer.inc +++ b/kernel/trunk/network/tcp_timer.inc @@ -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 diff --git a/kernel/trunk/network/tcp_usreq.inc b/kernel/trunk/network/tcp_usreq.inc index 6fc1d5494a..630c855635 100644 --- a/kernel/trunk/network/tcp_usreq.inc +++ b/kernel/trunk/network/tcp_usreq.inc @@ -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: diff --git a/kernel/trunk/network/udp.inc b/kernel/trunk/network/udp.inc index 6c88f1c06b..54aacd211b 100644 --- a/kernel/trunk/network/udp.inc +++ b/kernel/trunk/network/udp.inc @@ -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