Fixed Unsigned jumps in net branch

git-svn-id: svn://kolibrios.org@2300 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-11-07 20:25:47 +00:00
parent 6a91603b0a
commit b7875fe3bf
9 changed files with 94 additions and 92 deletions

View File

@ -122,7 +122,8 @@ local .exit
.next:
add esi, ARP_ENTRY.size
loop .loop
dec ecx
jnz .loop
jmp .exit
.time_out:
@ -161,7 +162,7 @@ ARP_input:
DEBUGF 1,"ARP_Handler - start\n"
cmp ecx, 28
jl .exit
jb .exit
;---------------------
; Handle Reply packets
@ -183,7 +184,8 @@ ARP_input:
cmp [esi + ARP_ENTRY.IP], eax
je .gotit
add esi, ARP_ENTRY.size
loop .loop
dec ecx
jnz .loop
jmp .exit
@ -349,7 +351,7 @@ ARP_add_entry:
test ecx, ecx ; first entry?
jz .add
cmp ecx, ARP_TABLE_SIZE ; list full ?
jge .error
jae .error
mov eax, dword[esi + ARP_ENTRY.MAC]
mov bx , word[esi + ARP_ENTRY.MAC + 4]
@ -602,7 +604,7 @@ ARP_API:
.read:
cmp ecx, [NumARP]
jge .error
jae .error
; edi = pointer to buffer
; ecx = # entry
imul ecx, ARP_ENTRY.size
@ -622,7 +624,7 @@ ARP_API:
.remove:
; ecx = # entry
cmp ecx, [NumARP]
jge .error
jae .error
imul ecx, ARP_ENTRY.size
lea esi, [ARP_table + ecx]
call ARP_del_entry

View File

@ -597,7 +597,7 @@ IPv4_output:
DEBUGF 1,"IPv4_create_packet: size=%u\n", ecx
cmp ecx, 65500 ; Max IPv4 packet size
jg .too_large
ja .too_large
push ecx eax ebx dx di
@ -673,7 +673,7 @@ IPv4_output_raw:
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
cmp ecx, 1480 ;;;;;
jg .too_large
ja .too_large
sub esp, 8
push esi eax
@ -761,7 +761,7 @@ IPv4_fragment:
and ecx, not 111b ; align 4
cmp ecx, IPv4_Packet.DataOrOptional + 8 ; must be able to put at least 8 bytes
jl .err2
jb .err2
push esi ecx
mov eax, [esi + IPv4_Packet.DestinationAddress]
@ -846,7 +846,7 @@ IPv4_fragment:
DEBUGF 1,"Ipv4_fragment - bytes remaining: %u\n", ecx
cmp ecx, [esp+1*4]
jge .new_fragment
jae .new_fragment
mov [esp+4], ecx ; set fragment size to remaining packet size
jmp .new_fragment

View File

@ -64,7 +64,7 @@ ETH_input:
DEBUGF 1,"ETH_input - size: %u\n", ecx
cmp ecx, 60 ; check packet length
jl .dump
jb .dump
sub ecx, ETH_FRAME.Data
lea edx, [eax + ETH_FRAME.Data]
@ -110,7 +110,7 @@ ETH_output:
DEBUGF 1,"ETH_output: size=%u device:%x\n", ecx, ebx
cmp ecx, [ebx + NET_DEVICE.mtu]
jg .exit
ja .exit
push ecx ; << 1
push di eax edx ; << 2
@ -140,8 +140,8 @@ ETH_output:
pop ecx ; >> 1
cmp edx, 60-1 ; minimum ethernet packet size
jle .adjust_size
cmp edx, 60 ; minimum ethernet packet size
jb .adjust_size
DEBUGF 1,"ETH_output: done: %x total size: %u\n", eax, edx
ret
@ -181,7 +181,7 @@ align 4
ETH_API:
cmp bh, MAX_NET_DEVICES
jg .error
ja .error
movzx eax, bh
shl eax, 2

View File

@ -44,7 +44,7 @@ ends
macro add_to_queue ptr, size, entry_size, failaddr {
cmp [ptr + queue.size], size ; Check if queue isnt full
jge failaddr
jae failaddr
inc [ptr + queue.size] ; if not full, queue one more
@ -54,7 +54,7 @@ macro add_to_queue ptr, size, entry_size, failaddr {
lea ecx, [size*entry_size+ptr+queue.data]
cmp edi, ecx ; entry size
jl .no_wrap
jb .no_wrap
sub edi, size*entry_size
@ -79,7 +79,7 @@ macro get_from_queue ptr, size, entry_size, failaddr {
lea ecx, [size*entry_size+ptr+queue.data]
cmp esi, ecx ; entry size
jl .no_wrap
jb .no_wrap
sub esi, size*entry_size

View File

@ -216,17 +216,17 @@ macro SOCKET_init {
@@:
pseudo_random eax
cmp ax, MIN_EPHEMERAL_PORT
jl @r
jb @r
cmp ax, MAX_EPHEMERAL_PORT
jg @r
ja @r
mov [last_UDP_port], ax
@@:
pseudo_random eax
cmp ax, MIN_EPHEMERAL_PORT
jl @r
jb @r
cmp ax, MAX_EPHEMERAL_PORT
jg @r
ja @r
mov [last_TCP_port], ax
}
@ -240,7 +240,7 @@ macro SOCKET_init {
align 4
sys_socket:
cmp ebx, 9 ; highest possible number
jg @f
ja @f
jmp dword [sock_sysfn_table + 4*ebx]
@@:
cmp ebx, 255
@ -372,7 +372,7 @@ SOCKET_bind:
jz s_error
cmp esi, 2
jl s_error
jb s_error
cmp word [edx], AF_INET4
je .af_inet4
@ -393,7 +393,7 @@ SOCKET_bind:
DEBUGF 1,"af_inet4\n"
cmp esi, 6
jl s_error
jb s_error
push word [edx + 2]
pop word [eax + UDP_SOCKET.LocalPort]
@ -430,7 +430,7 @@ SOCKET_connect:
jz s_error
cmp esi, 8
jl s_error
jb s_error
cmp word [edx], AF_INET4
je .af_inet4
@ -577,7 +577,7 @@ SOCKET_listen:
@@:
cmp edx, MAX_backlog
jle @f
jbe @f
mov edx, MAX_backlog
@@:
@ -665,7 +665,7 @@ SOCKET_close:
.tcp:
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED ; state must be LISTEN, SYN_SENT or CLOSED
jl .free
jb .free
call TCP_output
mov dword [esp+32], 0
@ -715,7 +715,7 @@ SOCKET_receive_dgram:
DEBUGF 1,"Got %u bytes of data\n", ecx
cmp ecx, ebx
jg .too_small
ja .too_small
push [esi + socket_queue_entry.buf_ptr] ; save the buffer addr so we can clear it later
mov esi, [esi + socket_queue_entry.data_ptr]
@ -1119,7 +1119,7 @@ SOCKET_ring_write:
add [eax + RING_BUFFER.size], ecx
cmp [eax + RING_BUFFER.size], SOCKET_MAXDATA
jg .too_large
ja .too_large
.copy:
mov edi, [eax + RING_BUFFER.write_ptr]
@ -1141,7 +1141,7 @@ SOCKET_ring_write:
pop ecx
cmp edi, [eax + RING_BUFFER.end_ptr]
jge .wrap
jae .wrap
mov [eax + RING_BUFFER.write_ptr], edi
ret
@ -1155,7 +1155,7 @@ SOCKET_ring_write:
.too_large:
mov ecx, SOCKET_MAXDATA ; calculate number of bytes available in buffer
sub ecx, [eax + RING_BUFFER.size]
jge .full
jae .full
mov [eax + RING_BUFFER.size], SOCKET_MAXDATA ; update size, we will fill buffer completely
jmp .copy
@ -1185,7 +1185,7 @@ SOCKET_ring_read:
DEBUGF 1,"SOCKET_ring_read: ringbuff=%x ptr=%x size=%u\n", eax, edi, ecx
cmp ecx, [eax + RING_BUFFER.size]
jg .less_data
ja .less_data
.copy:
mov esi, [eax + RING_BUFFER.read_ptr]
@ -1234,12 +1234,12 @@ SOCKET_ring_free:
DEBUGF 1,"SOCKET_ring_free: %u bytes from ring %x\n", ecx, eax
sub [eax + RING_BUFFER.size], ecx
jl .sumthinwong
jb .sumthinwong
add [eax + RING_BUFFER.read_ptr], ecx
mov edx, [eax + RING_BUFFER.end_ptr]
cmp [eax + RING_BUFFER.read_ptr], edx
jl @f
jb @f
sub [eax + RING_BUFFER.read_ptr], SOCKET_MAXDATA
@@:
ret
@ -1468,7 +1468,7 @@ SOCKET_fork:
; Exit if backlog queue is full
mov eax, [ebx + SOCKET_QUEUE_LOCATION + queue.size]
cmp ax, [ebx + SOCKET.backlog]
jge .fail
jae .fail
; Allocate new socket
call SOCKET_alloc

View File

@ -274,7 +274,7 @@ NET_add_device:
mov eax, [NET_RUNNING]
cmp eax, MAX_NET_DEVICES
jge .error
jae .error
;----------------------------------
; Check if device is already listed
@ -339,7 +339,7 @@ NET_set_default:
DEBUGF 1,"NET_set_default %x\n", eax
cmp eax, MAX_NET_DEVICES
jge .error
jae .error
cmp [NET_DRV_LIST+eax*4], 0
je .error
@ -583,7 +583,7 @@ sys_network:
@@:
cmp bh, MAX_NET_DEVICES ; Check if device number exists
jge .doesnt_exist
jae .doesnt_exist
mov esi, ebx
and esi, 0x0000ff00
@ -679,7 +679,7 @@ sys_network:
align 4
sys_protocols:
cmp bh, MAX_NET_DEVICES ; Check if device number exists
jge .doesnt_exist
jae .doesnt_exist
mov esi, ebx
and esi, 0x0000ff00

View File

@ -46,7 +46,7 @@ TCP_input:
DEBUGF 1,"headersize=%u\n", eax
cmp eax, 20
jl .drop_not_locked
jb .drop_not_locked
;-------------------------------
; Now, re-calculate the checksum
@ -66,14 +66,14 @@ TCP_input:
DEBUGF 1,"Checksum is correct\n"
sub ecx, esi ; update packet size
jl .drop_not_locked
jb .drop_not_locked
DEBUGF 1,"we got %u bytes of data\n", ecx
;-----------------------------------------------------------------------------------------
; Check if this packet has a timestamp option (We do it here so we can process it quickly)
cmp esi, 20 + 12 ; Timestamp option is 12 bytes
jl .no_timestamp
jb .no_timestamp
je .is_ok
cmp byte [edx + TCP_segment.Data + 12], TCP_OPT_EOL ; end of option list
@ -226,7 +226,7 @@ TCP_input:
.opt_loop:
cmp edi, eax
jge .no_options
jae .no_options
cmp byte [edi], TCP_OPT_EOL ; end of option list?
jz .no_options
@ -349,16 +349,16 @@ TCP_input:
; This test is true only if the window is fully open, that is, the connection is not in the middle of slow start or congestion avoidance.
mov eax, [ebx + TCP_SOCKET.SND_CWND]
cmp eax, [ebx + TCP_SOCKET.SND_WND]
jl .not_uni_xfer
jb .not_uni_xfer
; - The acknowledgment field in the segment is less than or equal to the maximum sequence number sent.
mov eax, [edx + TCP_segment.AckNumber]
cmp eax, [ebx + TCP_SOCKET.SND_MAX]
jg .not_uni_xfer
ja .not_uni_xfer
; - The acknowledgment field in the segment is greater than the largest unacknowledged sequence number.
sub eax, [ebx + TCP_SOCKET.SND_UNA]
jle .not_uni_xfer
jbe .not_uni_xfer
DEBUGF 1,"Header prediction: we are sender\n"
@ -527,10 +527,10 @@ align 4
mov eax, [edx + TCP_segment.AckNumber]
cmp eax, [ebx + TCP_SOCKET.ISS]
jle .drop_with_reset
jbe .drop_with_reset
cmp eax, [ebx + TCP_SOCKET.SND_MAX]
jg .drop_with_reset
ja .drop_with_reset
@@:
test [edx + TCP_segment.Flags], TH_RST
@ -559,7 +559,7 @@ align 4
mov eax, [edx + TCP_segment.AckNumber]
mov [ebx + TCP_SOCKET.SND_UNA], eax
cmp eax, [ebx + TCP_SOCKET.SND_NXT]
jle @f
jbe @f
mov [ebx + TCP_SOCKET.SND_NXT], eax
@@:
@ -576,7 +576,7 @@ align 4
mov eax, [ebx + TCP_SOCKET.SND_UNA]
cmp eax, [ebx + TCP_SOCKET.ISS]
jle .simultaneous_open
jbe .simultaneous_open
test [edx + TCP_segment.Flags], TH_ACK
jz .simultaneous_open
@ -660,7 +660,7 @@ align 4
mov eax, [ebx + TCP_SOCKET.RCV_NXT]
sub eax, [edx + TCP_segment.SequenceNumber]
jle .no_duplicate
jbe .no_duplicate
DEBUGF 1,"Uh oh.. %u bytes of duplicate data!\n", eax
@ -673,7 +673,7 @@ align 4
inc [edx + TCP_segment.SequenceNumber]
cmp [edx + TCP_segment.UrgentPointer], 1
jle @f
jbe @f
dec [edx + TCP_segment.UrgentPointer]
jmp .dup_syn
@@:
@ -687,7 +687,7 @@ align 4
; Check for entire duplicate packet
cmp eax, ecx
jge .duplicate
jae .duplicate
DEBUGF 1,"Going to drop %u out of %u bytes\n", eax, ecx
@ -743,7 +743,7 @@ align 4
;;; TODO
sub [edx + TCP_segment.UrgentPointer], ax
jg @f
ja @f
and [edx + TCP_segment.Flags], not (TH_URG)
mov [edx + TCP_segment.UrgentPointer], 0
@ -753,10 +753,10 @@ align 4
; Handle data that arrives after process terminates
cmp [ebx + SOCKET.PID], 0
jg @f
ja @f
cmp [ebx + TCP_SOCKET.t_state], TCPS_CLOSE_WAIT
jle @f
jbe @f
test ecx, ecx
jz @f
@ -777,12 +777,12 @@ align 4
; eax now holds the number of bytes to drop
jle .no_excess_data
jbe .no_excess_data
;;; TODO: update stats
cmp eax, ecx
jl .dont_drop_all
jb .dont_drop_all
;;; TODO 700-736
@ -898,9 +898,9 @@ align 4
mov eax, [edx + TCP_segment.AckNumber]
cmp [ebx + TCP_SOCKET.SND_UNA], eax
jg .drop_with_reset
ja .drop_with_reset
cmp eax, [ebx + TCP_SOCKET.SND_MAX]
jg .drop_with_reset
ja .drop_with_reset
;;; update stats
mov eax, ebx
@ -931,7 +931,7 @@ align 4
mov eax, [edx + TCP_segment.AckNumber]
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
jg .not_dup_ack
ja .not_dup_ack
test ecx, ecx
jnz .reset_dupacks
@ -943,7 +943,7 @@ align 4
DEBUGF 1,"Processing a duplicate ACK..\n"
cmp [ebx + TCP_SOCKET.timer_retransmission], 10000 ;;;;
jg @f
ja @f
mov eax, [edx + TCP_segment.AckNumber]
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
@ -968,7 +968,7 @@ align 4
xor edx, edx
div [ebx + TCP_SOCKET.t_maxseg]
cmp eax, 2
jge @f
jae @f
mov ax, 2
@@:
mul [ebx + TCP_SOCKET.t_maxseg]
@ -995,7 +995,7 @@ align 4
pop eax ; <<<<
cmp eax, [ebx + TCP_SOCKET.SND_NXT]
jl @f
jb @f
mov [ebx + TCP_SOCKET.SND_NXT], eax
@@:
@ -1003,7 +1003,7 @@ align 4
.no_re_xmit:
jle .not_dup_ack
jbe .not_dup_ack
DEBUGF 1,"Increasing congestion window\n"
@ -1028,9 +1028,9 @@ align 4
mov eax, [ebx + TCP_SOCKET.SND_SSTHRESH]
cmp eax, [ebx + TCP_SOCKET.SND_CWND]
jg @f
ja @f
cmp [ebx + TCP_SOCKET.t_dupacks], TCP_re_xmit_thresh
jle @f
jbe @f
mov [ebx + TCP_SOCKET.SND_CWND], eax
@@:
@ -1038,7 +1038,7 @@ align 4
mov eax, [edx + TCP_segment.AckNumber]
cmp eax, [ebx + TCP_SOCKET.SND_MAX]
jle @f
jbe @f
;;; TODO: update stats
jmp .drop_after_ack
@ -1084,7 +1084,7 @@ align 4
mov eax, [ebx + TCP_SOCKET.t_maxseg]
cmp esi, [ebx + TCP_SOCKET.SND_SSTHRESH]
jle @f
jbe @f
push edx
push eax
mul eax
@ -1135,7 +1135,7 @@ align 4
mov [ebx + TCP_SOCKET.SND_UNA], eax
cmp eax, [ebx + TCP_SOCKET.SND_NXT]
jl @f
jb @f
mov [ebx + TCP_SOCKET.SND_NXT], eax
@@:
@ -1226,13 +1226,13 @@ align 4
mov eax, [ebx + TCP_SOCKET.SND_WL1]
cmp eax, [edx + TCP_segment.SequenceNumber]
jl .update_window
jg @f
jb .update_window
ja @f
mov eax, [ebx + TCP_SOCKET.SND_WL2]
cmp eax, [edx + TCP_segment.AckNumber]
jl .update_window
jg .no_window_update
jb .update_window
ja .no_window_update
@@:
mov eax, [ebx + TCP_SOCKET.SND_WL2]
@ -1241,7 +1241,7 @@ align 4
movzx eax, [edx + TCP_segment.Window]
cmp eax, [ebx + TCP_SOCKET.SND_WND]
jle .no_window_update
jbe .no_window_update
.update_window:
@ -1258,7 +1258,7 @@ align 4
;
; ;; mov eax, tiwin
; cmp eax, [ebx + TCP_SOCKET.SND_WND]
; jle @f
; jbe @f
;
; ;;; update stats
;
@ -1266,7 +1266,7 @@ align 4
mov eax, dword [edx + TCP_segment.Window]
cmp eax, [ebx + TCP_SOCKET.max_sndwnd]
jle @f
jbe @f
mov [ebx + TCP_SOCKET.max_sndwnd], eax
@@:
mov [ebx + TCP_SOCKET.SND_WND], eax
@ -1306,7 +1306,7 @@ align 4
movzx eax, [edx + TCP_segment.UrgentPointer]
add eax, [ebx + STREAM_SOCKET.rcv + RING_BUFFER.size]
cmp eax, SOCKET_MAXDATA
jle .not_urgent
jbe .not_urgent
mov [edx + TCP_segment.UrgentPointer], 0
and [edx + TCP_segment.Flags], not (TH_URG)
@ -1336,7 +1336,7 @@ align 4
jnz .process_fin
cmp [ebx + TCP_SOCKET.t_state], TCPS_FIN_WAIT_1
jge .dont_do_data
jae .dont_do_data
test ecx, ecx
jz .final_processing

View File

@ -41,7 +41,7 @@ TCP_output:
mov ebx, [eax + TCP_SOCKET.t_idle]
cmp ebx, [eax + TCP_SOCKET.t_rxtcur]
jle .not_idle
jbe .not_idle
; We have been idle for a while and no ACKS are expected to clock out any data we send..
; Slow start to get ack "clock" running again.
@ -56,7 +56,7 @@ TCP_output:
mov ecx, [eax + TCP_SOCKET.SND_WND] ; determine window
cmp ecx, [eax + TCP_SOCKET.SND_CWND] ;
jl @f ;
jb @f ;
mov ecx, [eax + TCP_SOCKET.SND_CWND] ;
@@: ;
@ -76,7 +76,7 @@ TCP_output:
jnz .no_zero_window
cmp ebx, [eax + STREAM_SOCKET.snd + RING_BUFFER.size]
jge @f
jae @f
and dl, not (TH_FIN) ; clear the FIN flag ??? how can it be set before?
@ -95,7 +95,7 @@ TCP_output:
mov esi, [eax + STREAM_SOCKET.snd + RING_BUFFER.size]
cmp esi, ecx
jl @f
jb @f
mov esi, ecx
@@:
sub esi, ebx
@ -132,7 +132,7 @@ TCP_output:
; Send one segment at a time (124)
cmp esi, [eax + TCP_SOCKET.t_maxseg]
jle @f
jbe @f
mov esi, [eax + TCP_SOCKET.t_maxseg]
@ -176,11 +176,11 @@ TCP_output:
mov ebx, [eax + TCP_SOCKET.max_sndwnd]
shr ebx, 1
cmp esi, ebx
jge .send
jae .send
mov ebx, [eax + TCP_SOCKET.SND_NXT]
cmp ebx, [eax + TCP_SOCKET.SND_MAX]
jl .send
jb .send
.len_zero:
@ -205,7 +205,7 @@ TCP_output:
mov ebx, [eax + TCP_SOCKET.SND_UP] ; when urgent pointer is beyond start of send bufer
cmp ebx, [eax + TCP_SOCKET.SND_UNA]
jg .send
ja .send
test dl, TH_FIN
jz .enter_persist ; no reason to send, enter persist state
@ -347,7 +347,7 @@ TCP_output:
add esi, edi ; total TCP segment size
cmp esi, [eax + TCP_SOCKET.t_maxseg]
jle .no_overflow
jbe .no_overflow
mov esi, [eax + TCP_SOCKET.t_maxseg]
@ -445,7 +445,7 @@ TCP_output:
mov edx, [eax + TCP_SOCKET.SND_NXT]
cmp edx, [eax + TCP_SOCKET.SND_MAX]
jle @f
jbe @f
mov [eax + TCP_SOCKET.SND_MAX], edx
;;;; TODO: time transmission (420)
@ -455,7 +455,7 @@ TCP_output:
; set retransmission timer if not already set, and not doing an ACK or keepalive probe
cmp [eax + TCP_SOCKET.timer_retransmission], 1000 ;;;;
jl .retransmit_set
jb .retransmit_set
cmp edx, [eax + TCP_SOCKET.SND_UNA] ; edx = [eax + TCP_SOCKET.SND_NXT]
je .retransmit_set

View File

@ -131,7 +131,7 @@ TCP_drop:
DEBUGF 1,"TCP_drop\n"
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
jl .no_syn_received
jb .no_syn_received
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED