57,15 → 57,15 |
; Pseudoheader |
mov edx, IP_PROTO_UDP |
|
add dl, [IP1+1] |
adc dh, [IP1+0] |
adc dl, [IP1+3] |
adc dh, [IP1+2] |
add dl, byte[IP1+1] |
adc dh, byte[IP1+0] |
adc dl, byte[IP1+3] |
adc dh, byte[IP1+2] |
|
adc dl, [IP2+1] |
adc dh, [IP2+0] |
adc dl, [IP2+3] |
adc dh, [IP2+2] |
adc dl, byte[IP2+1] |
adc dh, byte[IP2+0] |
adc dl, byte[IP2+3] |
adc dh, byte[IP2+2] |
|
adc dl, cl ; byte[esi+UDP_header.Length+1] |
adc dh, ch ; byte[esi+UDP_header.Length+0] |
103,14 → 103,14 |
; UDP_input: |
; |
; Called by IPv4_input, |
; this procedure will inject the udp data diagrams in the application sockets. |
; this procedure will inject the UDP data in the application sockets. |
; |
; IN: [esp] = Pointer to buffer |
; [esp+4] = size of buffer |
; IN: [esp] = ptr to buffer |
; ebx = ptr to device struct |
; ecx = UDP Packet size |
; esi = ptr to UDP header |
; edi = ptr to ipv4 source and dest address |
; ecx = UDP packet size |
; edx = ptr to IPv4 header |
; esi = ptr to UDP packet data |
; edi = interface number*4 |
; |
; OUT: / |
; |
127,7 → 127,8 |
|
; 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) |
mov eax, edx |
UDP_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress) |
jnz .checksum_mismatch |
|
.no_checksum: |
148,9 → 149,7 |
|
mov cx, [esi + UDP_header.SourcePort] |
mov dx, [esi + UDP_header.DestinationPort] |
mov edi, [edi + 4] ; ipv4 source address |
mov eax, net_sockets |
|
.next_socket: |
mov eax, [eax + SOCKET.NextPtr] |
or eax, eax |
172,15 → 171,15 |
call mutex_unlock |
popa |
|
;;; TODO: when packet is processed, check more sockets! |
;;; TODO: when packet is processed, check more sockets?! |
|
; FIXME: check remote IP if possible |
; |
; cmp [eax + IP_SOCKET.RemoteIP], 0xffffffff |
; je @f |
; cmp [eax + IP_SOCKET.RemoteIP], edi |
; cmp [eax + IP_SOCKET.RemoteIP], |
; jne .next_socket |
; @@: |
; |
; FIXME: UDP should check remote IP, but not under all circumstances! |
|
cmp [eax + UDP_SOCKET.RemotePort], 0 |
je .updateport |
194,7 → 193,6 |
popa |
|
.updatesock: |
call NET_ptr_to_num4 |
inc [UDP_PACKETS_RX + edi] |
|
movzx ecx, [esi + UDP_header.Length] |
257,10 → 255,11 |
|
sub esp, 4 ; Data ptr will be placed here |
push edx esi |
mov ebx, [eax + IP_SOCKET.device] |
mov edx, [eax + IP_SOCKET.LocalIP] |
mov ebx, [eax + IP_SOCKET.device] |
mov eax, [eax + IP_SOCKET.RemoteIP] |
mov di, IP_PROTO_UDP shl 8 + 128 |
mov edi, [eax + IP_SOCKET.RemoteIP] |
mov al, [eax + IP_SOCKET.ttl] |
mov ah, IP_PROTO_UDP |
add ecx, sizeof.UDP_header |
call IPv4_output |
jz .fail |
348,10 → 347,6 |
@@: |
|
push eax |
init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue |
pop eax |
|
push eax |
lea ecx, [eax + SOCKET.mutex] |
call mutex_unlock |
pop eax |