Basic LCP implementation, starting with echo request->reply

git-svn-id: svn://kolibrios.org@2961 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-08-30 20:32:29 +00:00
parent 7c750c97d3
commit 05d2a70ed6
2 changed files with 74 additions and 4 deletions

View File

@ -15,23 +15,37 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
struct PPPoE_frame
VersionAndType db ?
Code db ?
SessionID dw ?
Length dw ? ; Length of payload, does NOT include the length PPPoE header.
Payload rb 0
ends
struct LCP_frame
Code db ?
Identifier db ?
Length dw ?
Data rb 0
ends
uglobal
PPPoE_SID dw ?
PPPoE_MAC dp ?
endg
LCP_config_request = 1
LCP_config_ack = 2
LCP_config_nak = 3
LCP_config_reject = 4
LCP_terminate_request = 5
LCP_terminate_ack = 6
LCP_code_reject = 7
LCP_protocol_reject = 8
LCP_echo_request = 9
LCP_echo_reply = 10
LCP_discard_request = 11
;-----------------------------------------------------------------
;
@ -206,6 +220,9 @@ PPPoE_session_input:
cmp ax, PPP_IPv4
je IPv4_input
cmp ax, PPP_LCP
je LCP_input
DEBUGF 2,"PPPoE_input: Unknown protocol=%x\n", ax
.dump:
@ -274,9 +291,59 @@ PPPoE_output:
;-----------------------------------------------------------------
;
; LCP_input:
;
; IN: Pointer to buffer in [esp]
; size of buffer in [esp+4]
; pointer to device struct in ebx
; pointer to LCP header in edx
; size of LCP packet in ecx
; OUT: /
;
;-----------------------------------------------------------------
align 4
LCP_input:
DEBUGF 1,"LCP_input\n"
cmp [edx + LCP_frame.Code], LCP_echo_request
je .echo
jmp .dump
.echo:
mov [edx + LCP_frame.Code], LCP_echo_reply
mov esi, [esp]
push dword [esi + ETH_header.DstMAC]
push dword [esi + ETH_header.SrcMAC]
pop dword [esi + ETH_header.DstMAC]
pop dword [esi + ETH_header.SrcMAC]
push word [esi + ETH_header.DstMAC + 4]
push word [esi + ETH_header.SrcMAC + 4]
pop word [esi + ETH_header.DstMAC + 4]
pop word [esi + ETH_header.SrcMAC + 4]
call [ebx + NET_DEVICE.transmit]
ret
.dump:
DEBUGF 2,"LCP_input: dumping\n"
call kernel_free
add esp, 4
ret
align 4
PPPoE_start_connection:
DEBUGF 2,"PPPoE_start_connection: %x\n", cx
cmp [PPPoE_SID], 0
jne .fail
@ -295,6 +362,8 @@ PPPoE_start_connection:
align 4
PPPoE_stop_connection:
DEBUGF 2,"PPPoE_stop_connection\n"
xor eax, eax
mov [PPPoE_SID], ax
mov dword [PPPoE_MAC], eax

View File

@ -45,6 +45,7 @@ ETHER_PPP_SESSION = 0x6488
; PPP protocol numbers
PPP_IPv4 = 0x2100
PPP_LCP = 0x21c0
;Protocol family
AF_UNSPEC = 0