/kernel/branches/net/applications/pppoe/pppoe.asm |
---|
32,6 → 32,14 |
include '../network.inc' |
include '../struct.inc' |
; Ethernet protocol numbers |
ETHER_PPP_DISCOVERY = 0x6388 |
ETHER_PPP_SESSION = 0x6488 |
; PPP protocol numbers |
PPP_IPv4 = 0x2100 |
PPP_LCP = 0x21c0 |
; PPP Active Discovery... |
PPPoE_PADI = 0x09 ; .. Initiation |
PPPoE_PADO = 0x07 ; .. Offer |
45,6 → 53,18 |
TAG_HOST_UNIQ = 0x0301 |
TAG_AC_COOKIE = 0x0401 |
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 |
struct ETH_frame |
DestMac dp ? |
SrcMac dp ? |
51,7 → 71,6 |
Type dw ? |
ends |
struct PPPoE_frame ETH_frame |
VersionAndType db ? |
Code db ? |
60,6 → 79,17 |
Payload rb 0 |
ends |
struct PPP_frame PPPoE_frame |
Protocol dw ? |
ends |
struct LCP_frame PPP_frame |
LCP_Code db ? |
LCP_Identifier db ? |
LCP_Length dw ? |
LCP_Data rb 0 |
ends |
; entry point |
start: |
; load libraries |
99,6 → 129,12 |
cmp eax, sizeof.PPPoE_frame |
jb mainloop |
cmp word [buffer + ETH_frame.Type], ETHER_PPP_SESSION |
je LCP_input |
cmp word [buffer + ETH_frame.Type], ETHER_PPP_DISCOVERY |
jne mainloop |
cmp [buffer + PPPoE_frame.Code], PPPoE_PADO |
je pado |
166,6 → 202,35 |
mcall send, [socketnum], PADT, 14 + 6, 0 |
jmp exit |
LCP_input: |
cmp word [buffer + PPP_frame.Protocol], PPP_LCP |
jne mainloop |
cmp [buffer + LCP_frame.LCP_Code], LCP_echo_request |
je .echo |
.dump: |
jmp mainloop |
.echo: |
mov [buffer + LCP_frame.LCP_Code], LCP_echo_reply |
push dword [buffer + ETH_frame.DestMac] |
push dword [buffer + ETH_frame.SrcMac] |
pop dword [buffer + ETH_frame.DestMac] |
pop dword [buffer + ETH_frame.SrcMac] |
push word [buffer + ETH_frame.DestMac + 4] |
push word [buffer + ETH_frame.SrcMac + 4] |
pop word [buffer + ETH_frame.DestMac + 4] |
pop word [buffer + ETH_frame.SrcMac + 4] |
mov esi, eax |
mcall send, [socketnum], buffer, , 0 ; now send it! |
jmp mainloop |
; data |
title db 'PPPoE',0 |
str1 db 'Sending PADI',13,10,0 |
228,6 → 293,7 |
i_end: |
socketnum dd ? |
sid dw ? |
buffer rb 4096 |
rb 4096 ; stack |
mem: |
/kernel/branches/net/network/PPPoE.inc |
---|
22,34 → 22,14 |
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 |
;----------------------------------------------------------------- |
; |
; IPv4_init |
; PPPoE_init |
; |
; This function resets all IP variables |
; |
168,8 → 148,11 |
lea esi, [ebx + ETH_DEVICE.mac] |
movsd |
movsw |
cmp word[edi], ETHER_PPP_SESSION ; Allow only PPP_discovery, or LCP |
je @f |
mov ax, ETHER_PPP_DISCOVERY |
stosw |
@@: |
; And send the packet |
call [ebx + NET_DEVICE.transmit] |
221,7 → 204,7 |
je IPv4_input |
cmp ax, PPP_LCP |
je LCP_input |
je PPPoE_discovery_input ; Send LCP packets to the PPP dialer |
DEBUGF 2,"PPPoE_input: Unknown protocol=%x\n", ax |
290,56 → 273,6 |
ret |
;----------------------------------------------------------------- |
; |
; 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 |