Fixed bugs in PPPoE discovery

git-svn-id: svn://kolibrios.org@2950 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-08-28 18:37:10 +00:00
parent e5b4e6fe9d
commit 12409b31b0

View File

@ -86,20 +86,25 @@ PPPoE_discovery_input:
; ;
; Send discovery packet ; Send discovery packet
; ;
; ebx (ecx in app) = device ; IN: eax = socket pointer
; ecx (edx in app) = size packet ; ecx = number of bytes to send
; edx (esi in app) = pointer to packet ; esi = pointer to data
; ;
;-------------------------------------- ;--------------------------------------
align 4 align 4
PPPoE_discovery_output: PPPoE_discovery_output:
DEBUGF 2,"PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
; RFC2516: An entire PADI packet (including the PPPoE header) MUST NOT ; RFC2516: An entire PADI packet (including the PPPoE header) MUST NOT
; exceed 1484 octets. ; exceed 1484 octets.
cmp ecx, 1484 + 14 cmp ecx, 1484 + 14
ja .bad ja .bad
; Check that device exists and is ethernet device ; Check that device exists and is ethernet device
mov ebx, [eax + SOCKET.device]
cmp ebx, MAX_NET_DEVICES cmp ebx, MAX_NET_DEVICES
ja .bad ja .bad
@ -110,16 +115,26 @@ PPPoE_discovery_output:
cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH
jne .bad jne .bad
DEBUGF 2,"PPPoE_discovery_output: device=%x\n", ebx
; Create packet. ; Create packet.
push ecx esi
stdcall kernel_alloc, 1500 stdcall kernel_alloc, 1500
pop esi ecx
test eax, eax test eax, eax
jz .bad jz .bad
push ecx eax mov edx, ecx
mov edi, eax mov edi, eax
rep movsb rep movsb
cmp edx, 60 ; Min ETH size
ja @f
mov edx, 60
@@:
push edx eax ; size and packet ptr for driver send proc
; Overwrite source MAC and protocol type ; Overwrite source MAC and protocol type
lea edi, [eax + ETH_header.SrcMAC] lea edi, [eax + ETH_header.SrcMAC]
lea esi, [ebx + ETH_DEVICE.mac] lea esi, [ebx + ETH_DEVICE.mac]