Fixed TCP and UDP checksum in net branch.

git-svn-id: svn://kolibrios.org@2390 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-02-23 22:21:40 +00:00
parent 4b6a83bfa4
commit 85c176d7f5
3 changed files with 851 additions and 849 deletions

View File

@ -36,13 +36,7 @@ TCP_input:
DEBUGF 1,"TCP_input size=%u\n", ecx
and [esi + TCP_header.DataOffset], 0xf0 ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
shr [esi + TCP_header.DataOffset], 2
cmp [esi + TCP_header.DataOffset], sizeof.TCP_header ; Now see if it's at least the size of a standard TCP header
jb .drop_not_locked ; If not, drop the packet
;-------------------------------
; Now, re-calculate the checksum
; First, re-calculate the checksum
push ecx esi
pushw [esi + TCP_header.Checksum]
@ -51,10 +45,15 @@ TCP_input:
pop cx ; previous checksum
cmp cx, dx
pop edx ecx
jnz .drop_not_locked
jne .drop_not_locked
DEBUGF 1,"Checksum ok\n"
and [edx + TCP_header.DataOffset], 0xf0 ; Calculate TCP segment header size (throwing away unused reserved bits in TCP header)
shr [edx + TCP_header.DataOffset], 2
cmp [edx + TCP_header.DataOffset], sizeof.TCP_header ; Now see if it's at least the size of a standard TCP header
jb .drop_not_locked ; If not, drop the packet
movzx eax, [edx + TCP_header.DataOffset]
sub ecx, eax ; substract TCP header size from total segment size
jb .drop_not_locked ; If total segment size is less then the advertised header size, drop packet

View File

@ -40,6 +40,8 @@ macro TCP_checksum IP1, IP2 {
adc dl, cl
adc dh, ch
adc edx, 0
;---------------------
; Real header and data

View File

@ -121,11 +121,12 @@ UDP_input:
; First validate, checksum
neg [esi + UDP_header.Checksum] ; substract checksum from 0
jz .no_checksum ; if checksum is zero, it is considered valid and we continue processing
jz .no_checksum ; if checksum is zero, it is considered valid
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
UDP_checksum (edi), (edi+4)
;;; jnz .checksum_mismatch
jnz .checksum_mismatch
.no_checksum:
DEBUGF 1,"UDP Checksum is correct\n"
@ -287,7 +288,7 @@ UDP_output:
.fail:
DEBUGF 1,"UDP_output: failed\n"
add esp, 4+4+8
xor eax, eax
or eax, -1
ret