/kernel/branches/net/network/ARP.inc |
---|
161,7 → 161,7 |
ARP_input: |
DEBUGF 1,"ARP_Handler - start\n" |
cmp ecx, 28 |
cmp ecx, ARP_Packet.size |
jb .exit |
;--------------------- |
/kernel/branches/net/network/IPv4.inc |
---|
240,9 → 240,9 |
; check for broadcast |
mov eax, dword[SUBNET_LIST+edi] |
mov eax, [SUBNET_LIST+edi] |
not eax |
or eax, dword[IP_LIST+edi] |
or eax, [IP_LIST+edi] |
cmp [edx + IPv4_Packet.DestinationAddress], eax |
je .ip_ok |
672,7 → 672,7 |
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax |
cmp ecx, 1480 ;;;;; |
cmp ecx, 1480 ;;;;; FIXME |
ja .too_large |
sub esp, 8 |
779,7 → 779,7 |
push esi ; ptr to ip header |
sub ecx, 20 ; substract header size |
sub ecx, IPv4_Packet.DataOrOptional ; substract header size |
push ecx ; max data size |
push dword 0 ; offset |
802,7 → 802,7 |
; copy data |
mov esi, [esp + 2*4] |
add esi, 20 |
add esi, IPv4_Packet.DataOrOptional |
add esi, [esp] ; offset |
mov ecx, [esp + 1*4] |
811,7 → 811,7 |
; now, correct header |
mov ecx, [esp + 1*4] |
add ecx, 20 |
add ecx, IPv4_Packet.DataOrOptional |
xchg cl, ch |
mov [edi + IPv4_Packet.TotalLength], cx |
/kernel/branches/net/network/ethernet.inc |
---|
23,6 → 23,8 |
.Data: ; data (46-1500 bytes for a normal packet) |
ends |
ETH_FRAME_MINIMUM equ 60 |
virtual at NET_DEVICE.end |
ETH_DEVICE: |
63,7 → 65,7 |
mov ecx, [esp+4] |
DEBUGF 1,"ETH_input - size: %u\n", ecx |
cmp ecx, 60 ; check packet length |
cmp ecx, ETH_FRAME_MINIMUM |
jb .dump |
sub ecx, ETH_FRAME.Data |
140,13 → 142,13 |
pop ecx ; >> 1 |
cmp edx, 60 ; minimum ethernet packet size |
cmp edx, ETH_FRAME_MINIMUM |
jb .adjust_size |
DEBUGF 1,"ETH_output: done: %x total size: %u\n", eax, edx |
ret |
.adjust_size: |
mov edx, 60 |
mov edx, ETH_FRAME_MINIMUM |
test edx, edx ; clear zero flag |
ret |
/kernel/branches/net/network/socket.inc |
---|
237,9 → 237,25 |
; Socket API (function 74) |
; |
;----------------------------------------------------------------- |
align 16 |
sock_sysfn_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 |
SOCKET_SYSFUNCS = ($ - sock_sysfn_table)/4 |
align 4 |
sys_socket: |
cmp ebx, 9 ; highest possible number |
cmp ebx, SOCKET_SYSFUNCS-1 |
ja @f |
jmp dword [sock_sysfn_table + 4*ebx] |
@@: |
252,19 → 268,8 |
ret |
align 4 |
sock_sysfn_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 |
;----------------------------------------------------------------- |
; |
; SOCKET_open |
395,10 → 400,10 |
cmp esi, 6 |
jb s_error |
push word [edx + 2] |
pop word [eax + UDP_SOCKET.LocalPort] |
pushw [edx + 2] |
pop [eax + UDP_SOCKET.LocalPort] |
push dword [edx + 4] |
pushd [edx + 4] |
pop [eax + IP_SOCKET.LocalIP] |
DEBUGF 1,"local ip: %u.%u.%u.%u\n",\ |
463,10 → 468,10 |
lea ebx, [eax + SOCKET.lock] |
call wait_mutex |
push word [edx + 2] |
pushw [edx + 2] |
pop [eax + UDP_SOCKET.RemotePort] |
push dword [edx + 4] |
pushd [edx + 4] |
pop [eax + IP_SOCKET.RemoteIP] |
cmp [eax + UDP_SOCKET.LocalPort], 0 |
489,10 → 494,10 |
lea ebx, [eax + SOCKET.lock] |
call wait_mutex |
push word [edx + 2] |
pushw [edx + 2] |
pop [eax + TCP_SOCKET.RemotePort] |
push dword [edx + 4] |
pushd [edx + 4] |
pop [eax + IP_SOCKET.RemoteIP] |
cmp [eax + TCP_SOCKET.LocalPort], 0 |
532,8 → 537,8 |
lea ebx, [eax + SOCKET.lock] |
call wait_mutex |
push dword [edx + 4] |
pop dword [eax + IP_SOCKET.RemoteIP] |
pushd [edx + 4] |
pop [eax + IP_SOCKET.RemoteIP] |
push eax |
init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue |
/kernel/branches/net/network/tcp_input.inc |
---|
45,7 → 45,7 |
DEBUGF 1,"headersize=%u\n", eax |
cmp eax, 20 |
cmp eax, TCP_segment.DataOffset |
jb .drop_not_locked |
;------------------------------- |
72,7 → 72,7 |
;----------------------------------------------------------------------------------------- |
; 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 |
cmp esi, TCP_segment.DataOffset + 12 ; Timestamp option is 12 bytes |
jb .no_timestamp |
je .is_ok |
213,7 → 213,7 |
;-------------------- |
; Process TCP options |
cmp esi, 20 ; esi is headersize |
cmp esi, TCP_segment.DataOffset ; esi is headersize |
je .no_options |
DEBUGF 1,"Segment has options\n" |
/kernel/branches/net/network/tcp_output.inc |
---|
277,7 → 277,7 |
test [eax + TCP_SOCKET.t_flags], TF_NOOPT |
jnz .options_done |
mov ecx, 1460 |
mov ecx, 1460 ;;;; FIXME |
or ecx, TCP_OPT_MAXSEG shl 24 + 4 shl 16 |
bswap ecx |
push ecx |
454,7 → 454,7 |
; set retransmission timer if not already set, and not doing an ACK or keepalive probe |
cmp [eax + TCP_SOCKET.timer_retransmission], 1000 ;;;; |
cmp [eax + TCP_SOCKET.timer_retransmission], 1000 ;;;; FIXME |
jb .retransmit_set |
cmp edx, [eax + TCP_SOCKET.SND_UNA] ; edx = [eax + TCP_SOCKET.SND_NXT] |
/kernel/branches/net/network/tcp_subr.inc |
---|
268,7 → 268,7 |
mov eax, [esi + TCP_SOCKET.RCV_NXT] |
bswap eax |
stosd |
mov al, 0x50 ; Dataoffset: 20 bytes |
mov al, 0x50 ; Dataoffset: 20 bytes (TCP_segment.DataOffset) |
stosb |
mov al, cl |
stosb |
323,8 → 323,8 |
; Create the IP packet |
push cx edx |
mov ebx, [edx - 20 + IPv4_Packet.SourceAddress] ;;;; and what if ip packet had options?! |
mov eax, [edx - 20 + IPv4_Packet.DestinationAddress] ;;; |
mov ebx, [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress] ;;;; FIXME: and what if ip packet had options?! |
mov eax, [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress] ;;; |
mov ecx, TCP_segment.Data |
mov di , IP_PROTO_TCP shl 8 + 128 |
call IPv4_output |
347,7 → 347,7 |
stosd |
xor eax, eax |
stosd |
mov al, 0x50 ; Dataoffset: 20 bytes |
mov al, 0x50 ; Dataoffset: 20 bytes (TCP_segment.Data) |
stosb |
mov al, cl |
stosb |
363,7 → 363,8 |
.checksum: |
lea esi, [edi - TCP_segment.Data] |
mov ecx, TCP_segment.Data |
TCP_checksum (esi - 20 + IPv4_Packet.DestinationAddress), (esi - 20 + IPv4_Packet.DestinationAddress) |
TCP_checksum (esi - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress),\ ; FIXME |
(esi - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress) |
mov [esi+TCP_segment.Checksum], dx |
;-------------------- |