Subversion Repositories Kolibri OS

Rev

Rev 2960 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2960 Rev 2962
Line 30... Line 30...
30
include '../proc32.inc'
30
include '../proc32.inc'
31
include '../dll.inc'
31
include '../dll.inc'
32
include '../network.inc'
32
include '../network.inc'
33
include '../struct.inc'
33
include '../struct.inc'
Line -... Line 34...
-
 
34
 
-
 
35
; Ethernet protocol numbers
-
 
36
ETHER_PPP_DISCOVERY     = 0x6388
-
 
37
ETHER_PPP_SESSION       = 0x6488
-
 
38
 
-
 
39
; PPP protocol numbers
-
 
40
PPP_IPv4                = 0x2100
-
 
41
PPP_LCP                 = 0x21c0
34
 
42
 
35
; PPP Active Discovery...
43
; PPP Active Discovery...
36
PPPoE_PADI      = 0x09  ; .. Initiation
44
PPPoE_PADI      = 0x09  ; .. Initiation
37
PPPoE_PADO      = 0x07  ; .. Offer
45
PPPoE_PADO      = 0x07  ; .. Offer
38
PPPoE_PADR      = 0x19  ; .. Request
46
PPPoE_PADR      = 0x19  ; .. Request
Line 43... Line 51...
43
TAG_SERVICE_NAME= 0x0101
51
TAG_SERVICE_NAME= 0x0101
44
TAG_AC_NAME     = 0x0201
52
TAG_AC_NAME     = 0x0201
45
TAG_HOST_UNIQ   = 0x0301
53
TAG_HOST_UNIQ   = 0x0301
46
TAG_AC_COOKIE   = 0x0401
54
TAG_AC_COOKIE   = 0x0401
Line -... Line 55...
-
 
55
 
-
 
56
LCP_config_request      = 1
-
 
57
LCP_config_ack          = 2
-
 
58
LCP_config_nak          = 3
-
 
59
LCP_config_reject       = 4
-
 
60
LCP_terminate_request   = 5
-
 
61
LCP_terminate_ack       = 6
-
 
62
LCP_code_reject         = 7
-
 
63
LCP_protocol_reject     = 8
-
 
64
LCP_echo_request        = 9
-
 
65
LCP_echo_reply          = 10
-
 
66
LCP_discard_request     = 11
47
 
67
 
48
struct  ETH_frame
68
struct  ETH_frame
49
        DestMac         dp ?
69
        DestMac         dp ?
50
        SrcMac          dp ?
70
        SrcMac          dp ?
51
        Type            dw ?
71
        Type            dw ?
Line 52... Line -...
52
ends
-
 
53
 
72
ends
54
 
73
 
55
struct  PPPoE_frame     ETH_frame
74
struct  PPPoE_frame     ETH_frame
56
        VersionAndType  db ?
75
        VersionAndType  db ?
57
        Code            db ?
76
        Code            db ?
58
        SessionID       dw ?
77
        SessionID       dw ?
59
        Length          dw ?            ; Length of payload, does NOT include the length PPPoE header.
78
        Length          dw ?            ; Length of payload, does NOT include the length PPPoE header.
Line -... Line 79...
-
 
79
        Payload         rb 0
-
 
80
ends
-
 
81
 
-
 
82
struct  PPP_frame       PPPoE_frame
-
 
83
        Protocol        dw ?
-
 
84
ends
-
 
85
 
-
 
86
struct  LCP_frame       PPP_frame
-
 
87
        LCP_Code        db ?
-
 
88
        LCP_Identifier  db ?
-
 
89
        LCP_Length      dw ?
60
        Payload         rb 0
90
        LCP_Data        rb 0
61
ends
91
ends
62
 
92
 
63
; entry point
93
; entry point
64
start:
94
start:
Line 97... Line 127...
97
 
127
 
98
        mcall   recv, [socketnum], buffer, 4096
128
        mcall   recv, [socketnum], buffer, 4096
99
        cmp     eax, sizeof.PPPoE_frame
129
        cmp     eax, sizeof.PPPoE_frame
Line -... Line 130...
-
 
130
        jb      mainloop
-
 
131
 
-
 
132
        cmp     word [buffer + ETH_frame.Type], ETHER_PPP_SESSION
-
 
133
        je      LCP_input
-
 
134
 
-
 
135
        cmp     word [buffer + ETH_frame.Type], ETHER_PPP_DISCOVERY
100
        jb      mainloop
136
        jne     mainloop
101
 
137
 
Line 102... Line 138...
102
        cmp     [buffer + PPPoE_frame.Code], PPPoE_PADO
138
        cmp     [buffer + PPPoE_frame.Code], PPPoE_PADO
103
        je      pado
139
        je      pado
Line 164... Line 200...
164
close_conn:
200
close_conn:
Line 165... Line 201...
165
 
201
 
166
        mcall   send, [socketnum], PADT, 14 + 6, 0
202
        mcall   send, [socketnum], PADT, 14 + 6, 0
Line -... Line 203...
-
 
203
        jmp     exit
-
 
204
 
-
 
205
 
-
 
206
LCP_input:
-
 
207
 
-
 
208
        cmp     word [buffer + PPP_frame.Protocol], PPP_LCP
-
 
209
        jne     mainloop
-
 
210
 
-
 
211
        cmp     [buffer + LCP_frame.LCP_Code], LCP_echo_request
-
 
212
        je      .echo
-
 
213
 
-
 
214
  .dump:
-
 
215
        jmp     mainloop
-
 
216
 
-
 
217
  .echo:
-
 
218
        mov     [buffer + LCP_frame.LCP_Code], LCP_echo_reply
-
 
219
 
-
 
220
        push    dword [buffer + ETH_frame.DestMac]
-
 
221
        push    dword [buffer + ETH_frame.SrcMac]
-
 
222
        pop     dword [buffer + ETH_frame.DestMac]
-
 
223
        pop     dword [buffer + ETH_frame.SrcMac]
-
 
224
        push    word [buffer + ETH_frame.DestMac + 4]
-
 
225
        push    word [buffer + ETH_frame.SrcMac + 4]
-
 
226
        pop     word [buffer + ETH_frame.DestMac + 4]
-
 
227
        pop     word [buffer + ETH_frame.SrcMac + 4]
-
 
228
 
-
 
229
        mov     esi, eax
-
 
230
        mcall   send, [socketnum], buffer, , 0  ; now send it!
-
 
231
 
167
        jmp     exit
232
        jmp     mainloop
168
 
233
 
169
; data
234
; data
170
title   db      'PPPoE',0
235
title   db      'PPPoE',0
171
str1    db      'Sending PADI',13,10,0
236
str1    db      'Sending PADI',13,10,0
Line 226... Line 291...
226
 
291
 
Line 227... Line 292...
227
 
292
 
-
 
293
i_end:
228
i_end:
294
 
229
 
295
socketnum       dd ?
230
socketnum       dd ?
296
sid             dw ?