2009-09-17 13:55:38 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2010-07-12 01:13:12 +02:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
2009-11-06 21:45:08 +01:00
|
|
|
;; IPv4.INC ;;
|
2009-09-17 13:55:38 +02:00
|
|
|
;; ;;
|
|
|
|
;; Part of the tcp/ip network stack for KolibriOS ;;
|
|
|
|
;; ;;
|
|
|
|
;; Based on the work of [Johnny_B] and [smb] ;;
|
|
|
|
;; ;;
|
|
|
|
;; Written by hidnplayr@kolibrios.org ;;
|
|
|
|
;; ;;
|
|
|
|
;; GNU GENERAL PUBLIC LICENSE ;;
|
|
|
|
;; Version 2, June 1991 ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2009-10-12 16:39:59 +02:00
|
|
|
$Revision$
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
MAX_FRAGMENTS equ 64
|
2009-09-17 13:55:38 +02:00
|
|
|
MAX_IP equ MAX_NET_DEVICES
|
2010-07-12 01:13:12 +02:00
|
|
|
IP_MAX_INTERFACES equ MAX_IP
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
struct IPv4_Packet
|
|
|
|
.VersionAndIHL db ? ; Version[0-3 bits] and IHL(header length)[4-7 bits]
|
2010-07-12 01:13:12 +02:00
|
|
|
.TypeOfService db ? ; precedence [7-5] minimize delay [4], maximize throughput [3], maximize riliability [2] minimize momentary cost [1] and zero [0]
|
2009-09-17 13:55:38 +02:00
|
|
|
.TotalLength dw ?
|
|
|
|
.Identification dw ?
|
|
|
|
.FlagsAndFragmentOffset dw ? ; Flags[0-2] and FragmentOffset[3-15]
|
|
|
|
.TimeToLive db ? ;
|
|
|
|
.Protocol db ?
|
|
|
|
.HeaderChecksum dw ?
|
|
|
|
.SourceAddress dd ?
|
|
|
|
.DestinationAddress dd ?
|
|
|
|
.DataOrOptional:
|
|
|
|
ends
|
|
|
|
|
|
|
|
struct FRAGMENT_slot
|
|
|
|
.ttl dw ? ; Time to live for this entry, 0 for empty slot's
|
|
|
|
.id dw ? ; Identification field from IP header
|
|
|
|
.SrcIP dd ? ; .. from IP header
|
|
|
|
.DstIP dd ? ; .. from IP header
|
|
|
|
.ptr dd ? ; Pointer to first packet
|
|
|
|
.size:
|
|
|
|
ends
|
|
|
|
|
|
|
|
struct FRAGMENT_entry ; This structure will replace the ethernet header in fragmented ip packets
|
|
|
|
.PrevPtr dd ? ; Pointer to previous fragment entry (-1 for first packet)
|
|
|
|
.NextPtr dd ? ; Pointer to next fragment entry (-1 for last packet)
|
|
|
|
.Owner dd ? ; Pointer to structure of driver
|
2009-11-06 21:45:08 +01:00
|
|
|
rb 2 ; to match ethernet header size ; TODO: fix this hack
|
2009-09-17 13:55:38 +02:00
|
|
|
.Data: ; Ip header begins here (we will need the IP header to re-construct the complete packet)
|
|
|
|
ends
|
|
|
|
|
|
|
|
align 4
|
|
|
|
uglobal
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
IP_LIST rd MAX_IP
|
|
|
|
SUBNET_LIST rd MAX_IP
|
|
|
|
DNS_LIST rd MAX_IP
|
|
|
|
GATEWAY_LIST rd MAX_IP
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
IP_PACKETS_TX rd MAX_IP
|
|
|
|
IP_PACKETS_RX rd MAX_IP
|
2010-07-12 01:13:12 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
FRAGMENT_LIST rb MAX_FRAGMENTS*FRAGMENT_slot.size
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; IPv4_init
|
|
|
|
;
|
|
|
|
; This function resets all IP variables
|
|
|
|
;
|
|
|
|
; IN: /
|
|
|
|
; OUT: /
|
|
|
|
;
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_init:
|
|
|
|
|
|
|
|
or eax, -1
|
2010-07-12 01:13:12 +02:00
|
|
|
mov edi, IP_LIST
|
|
|
|
mov ecx, 4*MAX_IP
|
2009-09-17 13:55:38 +02:00
|
|
|
rep stosd
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
inc eax
|
2009-09-17 13:55:38 +02:00
|
|
|
mov edi, FRAGMENT_LIST
|
|
|
|
mov ecx, FRAGMENT_slot.size*MAX_FRAGMENTS/4 + 2*MAX_IP
|
|
|
|
rep stosd
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
;
|
2009-11-06 21:45:08 +01:00
|
|
|
; IPv4_Handler:
|
2009-09-17 13:55:38 +02:00
|
|
|
;
|
2009-11-06 21:45:08 +01:00
|
|
|
; Will check if IP Packet isnt damaged
|
2009-09-17 13:55:38 +02:00
|
|
|
; 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 IP Packet data in edx
|
|
|
|
; OUT: /
|
|
|
|
;
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
align 4
|
2010-05-28 22:47:32 +02:00
|
|
|
IPv4_handler: ; TODO: implement handler for IP options
|
2010-07-12 01:13:12 +02:00
|
|
|
; TODO2: add code for raw sockets
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
DEBUGF 1,"IPv4_Handler, packet from: %u.%u.%u.%u ",\
|
|
|
|
[edx + IPv4_Packet.SourceAddress]:1,[edx + IPv4_Packet.SourceAddress + 1]:1,[edx + IPv4_Packet.SourceAddress + 2]:1,[edx + IPv4_Packet.SourceAddress + 3]:1
|
|
|
|
DEBUGF 1,"to: %u.%u.%u.%u\n",\
|
|
|
|
[edx + IPv4_Packet.DestinationAddress]:1,[edx + IPv4_Packet.DestinationAddress + 1]:1,[edx + IPv4_Packet.DestinationAddress + 2]:1,[edx + IPv4_Packet.DestinationAddress + 3]:1
|
2009-11-06 21:45:08 +01:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;-------------------------------------------
|
|
|
|
; Check if the packet still has time to live
|
|
|
|
|
|
|
|
cmp byte [edx + IPv4_Packet.TimeToLive], 0
|
|
|
|
je .dump
|
|
|
|
|
|
|
|
;--------------------------------------
|
|
|
|
; First, check if IP packet has options
|
|
|
|
|
|
|
|
movzx eax, [edx + IPv4_Packet.VersionAndIHL]
|
|
|
|
and al , 0x0f ; get IHL(header length)
|
|
|
|
cmp al , 0x05 ; IHL!= 5*4(20 bytes)
|
|
|
|
jnz .has_options
|
|
|
|
|
|
|
|
;-------------------------------
|
2010-07-12 01:13:12 +02:00
|
|
|
; Now, re-calculate the checksum
|
2009-11-06 21:45:08 +01:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
push edx ebx
|
2009-11-06 21:45:08 +01:00
|
|
|
mov esi, edx
|
2010-06-07 11:37:13 +02:00
|
|
|
call IPv4_checksum
|
2009-11-06 21:45:08 +01:00
|
|
|
pop ebx edx
|
2010-05-28 22:47:32 +02:00
|
|
|
|
|
|
|
cmp [edx + IPv4_Packet.HeaderChecksum], 0
|
2009-11-06 21:45:08 +01:00
|
|
|
jne .dump ; if checksum isn't valid then dump packet
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
DEBUGF 1,"IPv4 Checksum is correct\n"
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
;-----------------------------------
|
|
|
|
; Check if destination IP is correct
|
2010-05-28 22:47:32 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
call NET_ptr_to_num
|
|
|
|
shl edi, 2
|
2009-11-08 19:00:01 +01:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; check if it matches local ip
|
2010-05-28 22:47:32 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
mov eax, dword[IP_LIST+edi]
|
|
|
|
cmp [edx + IPv4_Packet.DestinationAddress], eax
|
|
|
|
je .ip_ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; check for broadcast
|
|
|
|
|
|
|
|
mov eax, dword[SUBNET_LIST+edi]
|
2009-09-17 13:55:38 +02:00
|
|
|
not eax
|
2010-07-12 01:13:12 +02:00
|
|
|
or eax, dword[IP_LIST+edi]
|
|
|
|
cmp [edx + IPv4_Packet.DestinationAddress], eax
|
|
|
|
je .ip_ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; or a special broadcast
|
2010-05-28 22:47:32 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
cmp [edx + IPv4_Packet.DestinationAddress], -1
|
|
|
|
je .ip_ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; ; maybe it's a multicast then
|
|
|
|
;
|
|
|
|
; mov eax, [edx + IPv4_Packet.DestinationAddress]
|
|
|
|
; and eax, 0xff000000
|
|
|
|
; cmp eax, 224 shl 24
|
|
|
|
; je .ip_ok
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; or a loopback address
|
2010-05-28 22:47:32 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
cmp eax, 127 shl 24
|
|
|
|
je .ip_ok
|
2010-05-28 22:47:32 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
; or it's not meant for us..
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
DEBUGF 2,"Destination address does not match!\n"
|
|
|
|
jmp .dump
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
;------------------------
|
|
|
|
; Now we can update stats
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
.ip_ok:
|
|
|
|
inc [IP_PACKETS_RX+edi]
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;----------------------------------
|
|
|
|
; Check if the packet is fragmented
|
|
|
|
|
|
|
|
test [edx + IPv4_Packet.FlagsAndFragmentOffset], 1 shl 5 ; Is 'more fragments' flag set ?
|
|
|
|
jnz .has_fragments ; If so, we definately have a fragmented packet
|
|
|
|
|
|
|
|
test [edx + IPv4_Packet.FlagsAndFragmentOffset], 0xff1f ; If flag is not set, but there is a fragment offset, the packet is last in series of fragmented packets
|
|
|
|
jnz .is_last_fragment
|
|
|
|
|
|
|
|
;-------------------------------------------------------------------
|
|
|
|
; No, it's just a regular IP packet, pass it to the higher protocols
|
|
|
|
|
|
|
|
.handle_it: ; We reach here if packet hasnt been fragmented, or when it already has been re-constructed
|
2009-09-17 13:55:38 +02:00
|
|
|
movzx eax, byte [edx + IPv4_Packet.VersionAndIHL] ; Calculate Header length by using IHL field
|
2010-07-12 01:13:12 +02:00
|
|
|
and eax, 0x0000000f ;
|
2009-09-17 13:55:38 +02:00
|
|
|
shl eax, 2 ;
|
|
|
|
movzx ecx, word [edx + IPv4_Packet.TotalLength] ; Calculate length of encapsulated Packet
|
|
|
|
xchg cl , ch ;
|
|
|
|
sub ecx, eax ;
|
|
|
|
|
|
|
|
add eax, edx
|
|
|
|
push eax
|
2010-05-28 22:47:32 +02:00
|
|
|
|
|
|
|
mov esi, [edx + IPv4_Packet.SourceAddress] ; These values might be of interest to the higher protocols
|
|
|
|
mov edi, [edx + IPv4_Packet.DestinationAddress] ;
|
2009-09-17 13:55:38 +02:00
|
|
|
mov al , [edx + IPv4_Packet.Protocol]
|
|
|
|
pop edx ; Offset to data (tcp/udp/icmp/.. Packet)
|
|
|
|
|
|
|
|
cmp al , IP_PROTO_TCP
|
2010-07-12 01:13:12 +02:00
|
|
|
je TCP_input
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
cmp al , IP_PROTO_UDP
|
2010-07-12 01:13:12 +02:00
|
|
|
je UDP_input
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
cmp al , IP_PROTO_ICMP
|
2010-07-12 01:13:12 +02:00
|
|
|
je ICMP_input
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
DEBUGF 2,"unknown Internet protocol: %u\n", al
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.dump:
|
2010-05-28 22:47:32 +02:00
|
|
|
DEBUGF 2,"IP_Handler - dumping\n"
|
2009-09-17 13:55:38 +02:00
|
|
|
; inc [dumped_rx_count]
|
|
|
|
call kernel_free
|
|
|
|
add esp, 4 ; pop (balance stack)
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;---------------------------
|
|
|
|
; Fragmented packet handler
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.has_fragments:
|
|
|
|
movzx eax, [edx + IPv4_Packet.FlagsAndFragmentOffset]
|
|
|
|
xchg al , ah
|
|
|
|
shl ax , 3
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
DEBUGF 1,"Fragmented packet, offset:%u, id:%x\n", ax, [edx + IPv4_Packet.Identification]:4
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
test ax , ax ; Is this the first packet of the fragment?
|
|
|
|
jz .is_first_fragment
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;-------------------------------------------------------
|
|
|
|
; We have a fragmented IP packet, but it's not the first
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
DEBUGF 1,"Middle fragmented packet received!\n"
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
call IPv4_find_fragment_slot
|
2009-09-17 13:55:38 +02:00
|
|
|
cmp esi, -1
|
|
|
|
je .dump
|
|
|
|
|
|
|
|
mov word [esi + FRAGMENT_slot.ttl], 15 ; Reset the ttl
|
|
|
|
mov esi, [esi + FRAGMENT_slot.ptr]
|
|
|
|
or edi, -1
|
2010-05-28 22:47:32 +02:00
|
|
|
.find_last_entry: ; The following routine will try to find the last entry
|
2009-09-17 13:55:38 +02:00
|
|
|
cmp edi, [esi + FRAGMENT_entry.PrevPtr]
|
|
|
|
jne .destroy_slot ; Damn, something screwed up, remove the whole slot (and free buffers too if possible!)
|
|
|
|
mov edi, esi
|
|
|
|
mov esi, [esi + FRAGMENT_entry.NextPtr]
|
|
|
|
cmp esi, -1
|
|
|
|
jne .find_last_entry
|
2010-05-28 22:47:32 +02:00
|
|
|
; We found the last entry (pointer is now in edi)
|
2009-09-17 13:55:38 +02:00
|
|
|
; We are going to overwrite the ethernet header in received packet with a FRAGMENT_entry structure
|
|
|
|
|
|
|
|
pop eax ; pointer to packet
|
|
|
|
mov [edi + FRAGMENT_entry.NextPtr], eax ; update pointer of previous entry to the new entry
|
|
|
|
mov [eax + FRAGMENT_entry.NextPtr], -1
|
|
|
|
mov [eax + FRAGMENT_entry.PrevPtr], edi
|
|
|
|
mov [eax + FRAGMENT_entry.Owner], ebx
|
|
|
|
|
|
|
|
add esp, 4
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;------------------------------------
|
|
|
|
; We have received the first fragment
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.is_first_fragment:
|
|
|
|
DEBUGF 1,"First fragmented packet received!\n"
|
|
|
|
; try to locate a free slot..
|
|
|
|
mov ecx, MAX_FRAGMENTS
|
|
|
|
mov esi, FRAGMENT_LIST
|
|
|
|
.find_free_slot:
|
|
|
|
cmp word [esi + FRAGMENT_slot.ttl], 0
|
|
|
|
je .found_free_slot
|
|
|
|
add esi, FRAGMENT_slot.size
|
|
|
|
loop .find_free_slot
|
|
|
|
jmp .dump ; If no free slot was found, dump the packet
|
|
|
|
|
|
|
|
.found_free_slot: ; We found a free slot, let's fill in the FRAGMENT_slot structure
|
|
|
|
mov word [esi + FRAGMENT_slot.ttl], 15 ; RFC recommends 15 secs as ttl
|
|
|
|
mov ax , word [edx + IPv4_Packet.Identification]
|
|
|
|
mov word [esi + FRAGMENT_slot.id], ax
|
|
|
|
mov eax, dword [edx + IPv4_Packet.SourceAddress]
|
|
|
|
mov dword [esi + FRAGMENT_slot.SrcIP], eax
|
|
|
|
mov eax, dword [edx + IPv4_Packet.DestinationAddress]
|
|
|
|
mov dword [esi + FRAGMENT_slot.DstIP], eax
|
|
|
|
pop eax
|
|
|
|
mov dword [esi + FRAGMENT_slot.ptr], eax
|
|
|
|
; Now, replace ethernet header in original buffer with a FRAGMENT_entry structure
|
|
|
|
mov [eax + FRAGMENT_entry.NextPtr], -1
|
|
|
|
mov [eax + FRAGMENT_entry.PrevPtr], -1
|
|
|
|
mov [eax + FRAGMENT_entry.Owner], ebx
|
|
|
|
|
|
|
|
add esp, 4 ; balance stack and exit
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
;-----------------------------------
|
|
|
|
; We have received the last fragment
|
|
|
|
|
|
|
|
.is_last_fragment:
|
2009-09-17 13:55:38 +02:00
|
|
|
DEBUGF 1,"Last fragmented packet received!\n"
|
2010-05-28 22:47:32 +02:00
|
|
|
|
|
|
|
call IPv4_find_fragment_slot
|
2009-09-17 13:55:38 +02:00
|
|
|
cmp esi, -1
|
|
|
|
je .dump
|
|
|
|
|
|
|
|
mov esi, [esi + FRAGMENT_slot.ptr] ; We found the first entry, let's calculate total size of the packet in eax, so we can allocate a buffer
|
|
|
|
push esi
|
2010-05-28 22:47:32 +02:00
|
|
|
xor eax, eax
|
2009-09-17 13:55:38 +02:00
|
|
|
or edi, -1
|
2010-05-28 22:47:32 +02:00
|
|
|
|
|
|
|
.count_bytes:
|
2009-09-17 13:55:38 +02:00
|
|
|
cmp [esi + FRAGMENT_entry.PrevPtr], edi
|
2010-05-28 22:47:32 +02:00
|
|
|
jne .destroy_slot_pop ; Damn, something screwed up, remove the whole slot (and free buffers too if possible!)
|
2009-09-17 13:55:38 +02:00
|
|
|
mov cx, word [esi + FRAGMENT_entry.Data + IPv4_Packet.TotalLength] ; Add total length
|
|
|
|
xchg cl, ch
|
|
|
|
DEBUGF 1,"Packet size: %u\n", cx
|
|
|
|
add ax, cx
|
|
|
|
movzx cx, byte [esi + FRAGMENT_entry.Data + IPv4_Packet.VersionAndIHL] ; Sub Header length
|
|
|
|
and cx, 0x000F
|
|
|
|
shl cx, 2
|
|
|
|
DEBUGF 1,"Header size: %u\n", cx
|
|
|
|
sub ax, cx
|
|
|
|
mov edi, esi
|
|
|
|
mov esi, [esi + FRAGMENT_entry.NextPtr]
|
|
|
|
cmp esi, -1
|
|
|
|
jne .count_bytes
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
mov esi, [esp+4]
|
2009-09-17 13:55:38 +02:00
|
|
|
mov [edi + FRAGMENT_entry.NextPtr], esi ; Add this packet to the chain, this simplifies the following code
|
|
|
|
mov [esi + FRAGMENT_entry.NextPtr], -1
|
|
|
|
mov [esi + FRAGMENT_entry.PrevPtr], edi
|
|
|
|
mov [esi + FRAGMENT_entry.Owner], ebx
|
|
|
|
|
|
|
|
mov cx, [edx + IPv4_Packet.TotalLength] ; Note: This time we dont substract Header length
|
|
|
|
xchg cl , ch
|
|
|
|
DEBUGF 1,"Packet size: %u\n", cx
|
|
|
|
add ax , cx
|
|
|
|
DEBUGF 1,"Total Received data size: %u\n", eax
|
|
|
|
|
|
|
|
push eax
|
|
|
|
mov ax , [edx + IPv4_Packet.FlagsAndFragmentOffset]
|
|
|
|
xchg al , ah
|
|
|
|
shl ax , 3
|
|
|
|
add cx , ax
|
|
|
|
pop eax
|
|
|
|
DEBUGF 1,"Total Fragment size: %u\n", ecx
|
|
|
|
|
|
|
|
cmp ax, cx
|
|
|
|
jne .destroy_slot_pop
|
|
|
|
|
|
|
|
push eax
|
|
|
|
push eax
|
|
|
|
call kernel_alloc
|
|
|
|
test eax, eax
|
|
|
|
je .destroy_slot_pop ; If we dont have enough space to allocate the buffer, discard all packets in slot
|
|
|
|
mov edx, [esp+4] ; Get pointer to first fragment entry back in edx
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.rebuild_packet_loop:
|
2009-09-17 13:55:38 +02:00
|
|
|
movzx ecx, word [edx + FRAGMENT_entry.Data + IPv4_Packet.FlagsAndFragmentOffset] ; Calculate the fragment offset
|
2010-05-28 22:47:32 +02:00
|
|
|
xchg cl , ch ; intel byte order
|
2009-09-17 13:55:38 +02:00
|
|
|
shl cx , 3 ; multiply by 8 and clear first 3 bits
|
|
|
|
DEBUGF 1,"Fragment offset: %u\n", cx
|
|
|
|
|
|
|
|
lea edi, [eax + ecx] ; Notice that edi will be equal to eax for first fragment
|
|
|
|
movzx ebx, byte [edx + FRAGMENT_entry.Data + IPv4_Packet.VersionAndIHL] ; Find header size (in ebx) of fragment
|
|
|
|
and bx , 0x000F ;
|
|
|
|
shl bx , 2 ;
|
|
|
|
|
|
|
|
lea esi, [edx + FRAGMENT_entry.Data] ; Set esi to the correct begin of fragment
|
|
|
|
movzx ecx, word [edx + FRAGMENT_entry.Data + IPv4_Packet.TotalLength] ; Calculate total length of fragment
|
|
|
|
xchg cl, ch ; intel byte order
|
|
|
|
|
|
|
|
cmp edi, eax ; Is this packet the first fragment ?
|
|
|
|
je .first_fragment
|
|
|
|
sub cx, bx ; If not, dont copy the header
|
|
|
|
add esi, ebx ;
|
2010-05-28 22:47:32 +02:00
|
|
|
.first_fragment:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
push cx ; First copy dword-wise, then byte-wise
|
|
|
|
shr cx, 2 ;
|
|
|
|
rep movsd ;
|
|
|
|
pop cx ;
|
|
|
|
and cx, 3 ;
|
|
|
|
rep movsb ;
|
|
|
|
|
|
|
|
push eax
|
|
|
|
push edx ; Push pointer to fragment onto stack
|
2010-05-28 22:47:32 +02:00
|
|
|
mov ebx, [edx + FRAGMENT_entry.Owner] ; we need to remeber the owner, in case this is the last packet
|
2009-09-17 13:55:38 +02:00
|
|
|
mov edx, [edx + FRAGMENT_entry.NextPtr] ; Set edx to the next pointer
|
|
|
|
call kernel_free ; free the previous fragment buffer (this uses the value from stack)
|
|
|
|
pop eax
|
|
|
|
cmp edx, -1 ; Check if it is last fragment in chain
|
|
|
|
jne .rebuild_packet_loop
|
|
|
|
|
|
|
|
pop ecx ;
|
|
|
|
xchg cl, ch
|
|
|
|
mov edx, eax
|
|
|
|
mov word [edx + IPv4_Packet.TotalLength], cx
|
|
|
|
add esp, 8
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
xchg cl, ch ;
|
|
|
|
|
|
|
|
push ecx ;;;;
|
|
|
|
push eax ;;;;
|
|
|
|
|
|
|
|
; mov esi, edx ; This prints the IP packet to the debug board (usefull when using serial output debug..)
|
2009-09-17 13:55:38 +02:00
|
|
|
; ;
|
|
|
|
; @@: ;
|
|
|
|
; lodsb ;
|
|
|
|
; DEBUGF 1,"%x ", eax:2 ;
|
|
|
|
; loop @r ;
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
jmp .handle_it ; edx = buf ptr, ecx = size, [esp] buf ptr, [esp+4], total size, ebx=device ptr
|
2009-11-06 21:45:08 +01:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.destroy_slot_pop:
|
|
|
|
add esp, 4
|
|
|
|
.destroy_slot:
|
|
|
|
DEBUGF 1,"Destroy fragment slot!\n"
|
|
|
|
; TODO!
|
|
|
|
jmp .dump
|
2009-11-06 21:45:08 +01:00
|
|
|
|
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
;-----------------------------------
|
|
|
|
; The IP packet has some options
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.has_options:
|
|
|
|
jmp .dump
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
2009-09-18 16:31:34 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; find fragment slot
|
|
|
|
;
|
2010-07-12 01:13:12 +02:00
|
|
|
; IN: pointer to fragmented packet in edx
|
2009-09-17 13:55:38 +02:00
|
|
|
; OUT: pointer to slot in edi, -1 on error
|
|
|
|
;
|
|
|
|
;-----------------------------------------------------------------
|
2010-05-28 22:47:32 +02:00
|
|
|
align 4
|
|
|
|
IPv4_find_fragment_slot:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
;;; TODO: the RFC says we should check protocol number too
|
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
push eax ebx ecx edx
|
|
|
|
mov ax , word [edx + IPv4_Packet.Identification]
|
|
|
|
mov ecx, MAX_FRAGMENTS
|
|
|
|
mov esi, FRAGMENT_LIST
|
|
|
|
mov ebx, dword [edx + IPv4_Packet.SourceAddress]
|
|
|
|
mov edx, dword [edx + IPv4_Packet.DestinationAddress]
|
|
|
|
.find_slot:
|
|
|
|
cmp word [esi + FRAGMENT_slot.id], ax
|
|
|
|
jne .try_next
|
|
|
|
cmp dword [esi + FRAGMENT_slot.SrcIP], ebx
|
|
|
|
jne .try_next
|
|
|
|
cmp dword [esi + FRAGMENT_slot.DstIP], edx
|
|
|
|
je .found_slot
|
|
|
|
.try_next:
|
|
|
|
add esi, FRAGMENT_slot.size
|
|
|
|
loop .find_slot
|
2010-05-28 22:47:32 +02:00
|
|
|
; pop edx ebx
|
2009-09-17 13:55:38 +02:00
|
|
|
or esi, -1
|
|
|
|
; ret
|
|
|
|
|
|
|
|
.found_slot:
|
|
|
|
pop edx ecx ebx eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; Decrease TimeToLive of all fragment slots
|
|
|
|
;
|
|
|
|
; IN: /
|
|
|
|
; OUT: /
|
|
|
|
;
|
|
|
|
;-----------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_decrease_fragment_ttls:
|
|
|
|
|
|
|
|
mov esi, FRAGMENT_LIST
|
|
|
|
mov ecx, MAX_FRAGMENTS
|
|
|
|
.loop:
|
|
|
|
cmp [esi + FRAGMENT_slot.ttl], 0
|
|
|
|
je .try_next
|
|
|
|
dec [esi + FRAGMENT_slot.ttl]
|
|
|
|
jnz .try_next
|
|
|
|
DEBUGF 1,"Fragment slot timed-out!\n"
|
2010-07-12 01:13:12 +02:00
|
|
|
;;; TODO: clear all entry's of timed-out slot
|
2009-09-17 13:55:38 +02:00
|
|
|
.try_next:
|
|
|
|
add esi, 4
|
|
|
|
loop .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
;------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
;
|
|
|
|
; IN: dword [esp] = pointer to packet to be fragmented
|
|
|
|
; dword [esp+4] = buffer size
|
|
|
|
; edx = pointer to IPv4 header in that packet
|
|
|
|
; ecx = data length
|
|
|
|
; ebx = device structure
|
|
|
|
;
|
|
|
|
; OUT: /
|
|
|
|
;
|
|
|
|
;------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_fragment:
|
|
|
|
|
|
|
|
;;; TODO: write code here
|
|
|
|
|
|
|
|
|
|
|
|
call kernel_free
|
|
|
|
add esp, 4
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;------------------------------------------------------------------
|
2009-09-17 13:55:38 +02:00
|
|
|
;
|
|
|
|
; Create_IPv4_Packet
|
|
|
|
;
|
|
|
|
; IN: eax = dest ip
|
|
|
|
; ebx = source ip
|
|
|
|
; ecx = data length
|
2010-07-12 01:13:12 +02:00
|
|
|
; dx = fragment id ;;;;
|
2009-09-17 13:55:38 +02:00
|
|
|
; di = protocol
|
|
|
|
;
|
2009-11-06 21:45:08 +01:00
|
|
|
; OUT: eax = pointer to buffer start
|
|
|
|
; ebx = pointer to device struct (needed for sending procedure)
|
2009-09-17 13:55:38 +02:00
|
|
|
; ecx = unchanged (packet size of embedded data)
|
2009-11-06 21:45:08 +01:00
|
|
|
; edx = size of complete buffer
|
2010-07-12 01:13:12 +02:00
|
|
|
; edi = pointer to start of data (0 on error)
|
2009-09-17 13:55:38 +02:00
|
|
|
;
|
2010-07-12 01:13:12 +02:00
|
|
|
;------------------------------------------------------------------
|
2009-09-17 13:55:38 +02:00
|
|
|
align 4
|
2009-10-05 22:47:27 +02:00
|
|
|
IPv4_create_packet:
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2009-10-12 16:39:59 +02:00
|
|
|
DEBUGF 1,"Create IPv4 Packet (size=%u)\n", ecx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
cmp ecx, 65500 ; Max IPv4 packet size
|
2009-09-17 13:55:38 +02:00
|
|
|
jg .exit_
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
test ebx, ebx ; if source ip = 0
|
2009-10-12 20:14:14 +02:00
|
|
|
jnz .ip_ok ; and local ip is valid
|
|
|
|
; use local ip instead
|
|
|
|
cmp [IP_LIST],0xffffffff ;
|
|
|
|
je .ip_ok ; TODO: find solution to send broadcast
|
2010-07-12 01:13:12 +02:00
|
|
|
; on device other then device 0
|
2009-10-12 20:14:14 +02:00
|
|
|
mov ebx, [IP_LIST] ;
|
|
|
|
;
|
|
|
|
.ip_ok: ;
|
|
|
|
|
2009-10-12 16:39:59 +02:00
|
|
|
push ecx eax ebx dx di
|
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
cmp eax, -1
|
2010-07-12 01:13:12 +02:00
|
|
|
je .broadcast ; If it is broadcast, just send
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2009-10-05 22:47:27 +02:00
|
|
|
call ARP_IP_to_MAC
|
|
|
|
|
|
|
|
cmp eax, -1
|
2009-10-12 16:39:59 +02:00
|
|
|
je .not_found
|
2009-09-17 13:55:38 +02:00
|
|
|
|
2009-10-05 22:47:27 +02:00
|
|
|
push ebx
|
2009-10-12 16:39:59 +02:00
|
|
|
push ax
|
2009-10-05 22:47:27 +02:00
|
|
|
|
|
|
|
jmp .send
|
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
.broadcast:
|
2009-10-05 22:47:27 +02:00
|
|
|
push word -1
|
|
|
|
push dword -1
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
.send:
|
|
|
|
call IPv4_dest_to_dev
|
2009-09-22 18:42:54 +02:00
|
|
|
inc [IP_PACKETS_TX+4*edi]
|
2010-07-12 01:13:12 +02:00
|
|
|
mov edx, [NET_DRV_LIST + 4*edi]
|
2009-10-12 16:39:59 +02:00
|
|
|
lea eax, [edx + ETH_DEVICE.mac]
|
|
|
|
mov ebx, esp
|
|
|
|
mov ecx, [esp+18] ;; 18 or 22 ??
|
2009-09-17 13:55:38 +02:00
|
|
|
add ecx, IPv4_Packet.DataOrOptional
|
|
|
|
mov di , ETHER_IPv4
|
2010-07-12 01:13:12 +02:00
|
|
|
;;; TODO: detect if packet is too large for ethernet, if so, call IPv4_fragment
|
|
|
|
call ETH_create_packet ;;; TODO: figure out a way to make this work with other protocols too
|
2009-10-12 16:39:59 +02:00
|
|
|
add esp, 6
|
2010-07-12 01:13:12 +02:00
|
|
|
test edi, edi
|
|
|
|
jz .exit
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
mov [edi + IPv4_Packet.VersionAndIHL], 0x45 ; IPv4, normal length (no Optional header)
|
|
|
|
mov [edi + IPv4_Packet.TypeOfService], 0
|
|
|
|
xchg ch, cl
|
|
|
|
mov [edi + IPv4_Packet.TotalLength], cx
|
|
|
|
mov [edi + IPv4_Packet.FlagsAndFragmentOffset], 0x0000
|
|
|
|
mov [edi + IPv4_Packet.TimeToLive], 128
|
|
|
|
mov [edi + IPv4_Packet.HeaderChecksum], 0
|
|
|
|
pop cx
|
|
|
|
mov [edi + IPv4_Packet.Protocol], cl
|
|
|
|
pop cx
|
|
|
|
mov [edi + IPv4_Packet.Identification], cx
|
|
|
|
pop ecx
|
|
|
|
mov [edi + IPv4_Packet.SourceAddress], ecx
|
|
|
|
pop ecx
|
|
|
|
mov [edi + IPv4_Packet.DestinationAddress], ecx
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
push eax edx esi
|
2009-11-06 21:45:08 +01:00
|
|
|
mov esi, edi
|
2010-06-07 11:37:13 +02:00
|
|
|
call IPv4_checksum
|
2010-05-28 22:47:32 +02:00
|
|
|
pop esi edx eax ecx
|
2009-09-17 13:55:38 +02:00
|
|
|
add edi, IPv4_Packet.DataOrOptional
|
|
|
|
|
2010-07-12 01:13:12 +02:00
|
|
|
DEBUGF 1,"IPv4 Packet for device %x created successfully\n", ebx
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
2009-10-12 16:39:59 +02:00
|
|
|
|
|
|
|
.not_found:
|
2010-07-12 01:13:12 +02:00
|
|
|
DEBUGF 1,"Create IPv4 Packet - ARP entry not found!\n"
|
|
|
|
;;;;;;
|
2009-09-17 13:55:38 +02:00
|
|
|
.exit:
|
2009-10-12 16:39:59 +02:00
|
|
|
add esp, 16
|
2009-09-17 13:55:38 +02:00
|
|
|
.exit_:
|
2010-07-12 01:13:12 +02:00
|
|
|
DEBUGF 1,"Create IPv4 Packet - failed\n"
|
|
|
|
and edi, 0
|
2009-09-17 13:55:38 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-07 11:37:13 +02:00
|
|
|
align 4
|
|
|
|
IPv4_checksum:
|
|
|
|
|
|
|
|
; This is the fast procedure to create or check a IP header without options
|
|
|
|
;
|
|
|
|
; To create a new checksum, the checksum field must be set to 0 before computation
|
|
|
|
;
|
|
|
|
; To check an existing checksum, leave the checksum as is, and it will be 0 after this procedure, if it was correct
|
|
|
|
|
|
|
|
xor edx, edx
|
|
|
|
|
|
|
|
add dl, [esi+1]
|
|
|
|
adc dh, [esi+0]
|
|
|
|
|
|
|
|
adc dl, [esi+3]
|
|
|
|
adc dh, [esi+2]
|
|
|
|
|
|
|
|
adc dl, [esi+5]
|
|
|
|
adc dh, [esi+4]
|
|
|
|
|
|
|
|
adc dl, [esi+7]
|
|
|
|
adc dh, [esi+6]
|
|
|
|
|
|
|
|
adc dl, [esi+9]
|
|
|
|
adc dh, [esi+8]
|
|
|
|
|
|
|
|
; we skip 11th and 12th byte, they are the checksum bytes and should be 0 for re-calculation
|
|
|
|
|
|
|
|
adc dl, [esi+13]
|
|
|
|
adc dh, [esi+12]
|
|
|
|
|
|
|
|
adc dl, [esi+15]
|
|
|
|
adc dh, [esi+14]
|
|
|
|
|
|
|
|
adc dl, [esi+17]
|
|
|
|
adc dh, [esi+16]
|
|
|
|
|
|
|
|
adc dl, [esi+19]
|
|
|
|
adc dh, [esi+18]
|
|
|
|
|
|
|
|
adc edx, 0
|
|
|
|
|
|
|
|
call checksum_2
|
|
|
|
|
|
|
|
neg word [esi+10] ; zero will stay zero so we just get the checksum
|
|
|
|
add word [esi+10], dx ; , else we will get (new checksum - old checksum) in the end, wich should be 0 :)
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-10-12 16:39:59 +02:00
|
|
|
|
2009-09-17 13:55:38 +02:00
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; IPv4_dest_to_dev
|
|
|
|
;
|
|
|
|
; IN: Destination IP in eax
|
|
|
|
; OUT: device id in edi
|
|
|
|
;
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_dest_to_dev:
|
|
|
|
|
|
|
|
DEBUGF 1,"IPv4 destination to device: "
|
|
|
|
|
|
|
|
xor edi, edi
|
|
|
|
mov ecx, MAX_IP
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
mov ebx, [IP_LIST+edi] ; we dont need to worry about non exisiting ip interfaces
|
|
|
|
and ebx, [SUBNET_LIST+edi] ; they have IP and SUBNET set to all one's, so they will have no match except 255.255.255.255
|
|
|
|
; (only a moron would insert that ip into this function..)
|
|
|
|
mov edx, eax
|
|
|
|
and edx, [SUBNET_LIST+edi]
|
|
|
|
|
|
|
|
cmp ebx, edx
|
|
|
|
je .found_it
|
|
|
|
|
|
|
|
add edi, 4
|
|
|
|
loop .loop
|
|
|
|
|
|
|
|
xor edi, edi ; if none found, use device 0 as default device
|
|
|
|
|
|
|
|
.found_it:
|
|
|
|
shr edi, 2
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
DEBUGF 1,"%u\n",edi
|
2009-09-17 13:55:38 +02:00
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
;
|
|
|
|
; IPv4_get_frgmnt_num
|
|
|
|
;
|
|
|
|
; IN: /
|
|
|
|
; OUT: fragment number in ax
|
|
|
|
;
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_get_frgmnt_num:
|
|
|
|
xor ax, ax ;;; TODO: replace this with real code
|
|
|
|
|
|
|
|
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:
|
|
|
|
;
|
|
|
|
;---------------------------------------------------------------------------
|
|
|
|
align 4
|
|
|
|
IPv4_API:
|
|
|
|
|
|
|
|
movzx eax, bh
|
|
|
|
shl eax, 2
|
|
|
|
|
|
|
|
test bl, bl
|
|
|
|
jz .packets_tx ; 0
|
|
|
|
dec bl
|
|
|
|
jz .packets_rx ; 1
|
|
|
|
dec bl
|
|
|
|
jz .read_ip ; 2
|
|
|
|
dec bl
|
|
|
|
jz .write_ip ; 3
|
|
|
|
dec bl
|
|
|
|
jz .read_dns ; 4
|
|
|
|
dec bl
|
|
|
|
jz .write_dns ; 5
|
|
|
|
dec bl
|
|
|
|
jz .read_subnet ; 6
|
|
|
|
dec bl
|
|
|
|
jz .write_subnet ; 7
|
|
|
|
dec bl
|
|
|
|
jz .read_gateway ; 8
|
|
|
|
dec bl
|
|
|
|
jz .write_gateway ; 9
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.error:
|
2009-09-17 13:55:38 +02:00
|
|
|
mov eax, -1
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.packets_tx:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, IP_PACKETS_TX
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.packets_rx:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, IP_PACKETS_RX
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.read_ip:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, IP_LIST
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.write_ip:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, IP_LIST
|
|
|
|
mov [eax], ecx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.read_dns:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, DNS_LIST
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.write_dns:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, DNS_LIST
|
|
|
|
mov [eax], ecx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.read_subnet:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, SUBNET_LIST
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.write_subnet:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, SUBNET_LIST
|
|
|
|
mov [eax], ecx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.read_gateway:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, GATEWAY_LIST
|
|
|
|
mov eax, [eax]
|
|
|
|
ret
|
|
|
|
|
2010-05-28 22:47:32 +02:00
|
|
|
.write_gateway:
|
2009-09-17 13:55:38 +02:00
|
|
|
add eax, GATEWAY_LIST
|
|
|
|
mov [eax], ecx
|
|
|
|
xor eax, eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|