Subversion Repositories Kolibri OS

Rev

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

Rev 5522 Rev 6011
Line 12... Line 12...
12
;;          GNU GENERAL PUBLIC LICENSE                          ;;
12
;;          GNU GENERAL PUBLIC LICENSE                          ;;
13
;;             Version 2, June 1991                             ;;
13
;;             Version 2, June 1991                             ;;
14
;;                                                              ;;
14
;;                                                              ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 16... Line 16...
16
 
16
 
Line 17... Line 17...
17
$Revision: 5522 $
17
$Revision: 6011 $
18
 
18
 
19
 
19
 
Line 31... Line 31...
31
        PPPoE_SID       dw ?
31
        PPPoE_SID       dw ?
32
        PPPoE_MAC       dp ?
32
        PPPoE_MAC       dp ?
Line 33... Line 33...
33
 
33
 
Line 34... Line 34...
34
endg
34
endg
35
 
-
 
36
;-----------------------------------------------------------------
35
 
37
;
-
 
38
; PPPoE_init
36
;-----------------------------------------------------------------;
39
;
-
 
-
 
37
;                                                                 ;
40
;  This function resets all IP variables
38
; pppoe_init: Reset all pppoe variables                           ;
41
;
39
;                                                                 ;
Line 42... Line 40...
42
;-----------------------------------------------------------------
40
;-----------------------------------------------------------------;
Line 43... Line 41...
43
macro   PPPoE_init {
41
macro   pppoe_init {
Line 44... Line 42...
44
 
42
 
45
        call    PPPoE_stop_connection
-
 
-
 
43
        call    pppoe_stop_connection
46
 
44
 
47
}
-
 
48
 
45
}
49
 
-
 
50
;-----------------------------------------------------------------
-
 
51
;
46
 
52
; PPPoE discovery input
47
 
53
;
48
;-----------------------------------------------------------------;
-
 
49
;                                                                 ;
54
; Handler of received Ethernet packet with type = Discovery
50
; pppoe_discovery_input                                           ;
55
;
51
;                                                                 ;
56
;
52
;  IN:  [esp] = ptr to buffer                                     ;
57
;  IN:  Pointer to buffer in [esp]
-
 
-
 
53
;       [esp+4] = size of buffer                                  ;
58
;       size of buffer in [esp+4]
54
;       ebx = ptr to device struct                                ;
59
;       pointer to device struct in ebx
55
;       ecx = size of PPP packet                                  ;
60
;       pointer to PPP header in edx
56
;       edx = ptr to PPP header                                   ;
Line 61... Line 57...
61
;       size of PPP packet in ecx
57
;                                                                 ;
Line 62... Line 58...
62
;  OUT: /
58
;  OUT: /                                                         ;
Line 95... Line 91...
95
; Now, send it to the this socket
91
; Now, send it to the this socket
Line 96... Line 92...
96
 
92
 
97
        mov     ecx, [esp + 4]
93
        mov     ecx, [esp + 4]
Line 98... Line 94...
98
        mov     esi, [esp]
94
        mov     esi, [esp]
Line 99... Line 95...
99
 
95
 
100
        jmp     SOCKET_input
96
        jmp     socket_input
101
 
97
 
102
  .dump:
98
  .dump:
103
        pusha
99
        pusha
Line 104... Line 100...
104
        mov     ecx, socket_mutex
100
        mov     ecx, socket_mutex
105
        call    mutex_unlock
101
        call    mutex_unlock
106
        popa
102
        popa
Line 107... Line 103...
107
 
103
 
108
        DEBUGF  DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
-
 
-
 
104
        DEBUGF  DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
109
        call    NET_BUFF_free
105
        call    net_buff_free
110
        ret
-
 
-
 
106
        ret
111
 
107
 
112
 
108
 
113
;--------------------------------------
109
;-----------------------------------------------------------------;
114
;
-
 
-
 
110
;                                                                 ;
115
; Send discovery packet
111
; pppoe_discovery_output                                          ;
116
;
-
 
117
; IN: eax = socket pointer
112
;                                                                 ;
118
;     ecx = number of bytes to send
113
;  IN:  eax = socket pointer                                      ;
Line 119... Line 114...
119
;     esi = pointer to data
114
;       ecx = number of bytes to send                             ;
Line 120... Line 115...
120
;
115
;       esi = pointer to data                                     ;
121
;--------------------------------------
116
;                                                                 ;
Line 145... Line 140...
145
 
140
 
Line 146... Line 141...
146
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
141
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
147
 
142
 
148
; Create packet.
143
; Create packet.
149
        push    ecx esi
144
        push    ecx esi
150
        stdcall kernel_alloc, 1500
145
;;;; FIXME        stdcall kernel_alloc, 1500
151
        pop     esi ecx
146
        pop     esi ecx
Line 152... Line 147...
152
        test    eax, eax
147
        test    eax, eax
Line 183... Line 178...
183
  .bad:
178
  .bad:
184
        or      eax, -1
179
        or      eax, -1
185
        ret
180
        ret
Line 186... Line 181...
186
 
181
 
187
 
-
 
-
 
182
 
188
;-----------------------------------------------------------------
183
;-----------------------------------------------------------------;
189
;
-
 
190
; PPPoE session input
184
;                                                                 ;
191
;
-
 
192
; Handler of received Ethernet packet with type = Session
-
 
193
;
185
; pppoe_session_input                                             ;
194
;
186
;                                                                 ;
195
;  IN:  Pointer to buffer in [esp]
187
;  IN:  [esp] = ptr to buffer                                     ;
196
;       size of buffer in [esp+4]
188
;       [esp+4] = size of buffer                                  ;
197
;       pointer to device struct in ebx
189
;       ebx = ptr to device struct                                ;
-
 
190
;       edx = ptr to PPP header                                   ;
198
;       pointer to PPP header in edx
191
;       ecx = size of PPP packet                                  ;
199
;       size of PPP packet in ecx
-
 
-
 
192
;                                                                 ;
200
;  OUT: /
193
;  OUT: /                                                         ;
201
;
194
;                                                                 ;
202
;-----------------------------------------------------------------
195
;-----------------------------------------------------------------;
Line 203... Line 196...
203
align 4
196
align 4
204
PPPoE_session_input:
197
pppoe_session_input:
Line 205... Line 198...
205
 
198
 
Line 219... Line 212...
219
 
212
 
220
        mov     ax, word [edx + PPPoE_frame.Payload]
213
        mov     ax, word [edx + PPPoE_frame.Payload]
Line 221... Line 214...
221
        add     edx, PPPoE_frame.Payload + 2
214
        add     edx, PPPoE_frame.Payload + 2
222
 
215
 
Line 223... Line 216...
223
        cmp     ax, PPP_PROTO_IPv4
216
        cmp     ax, PPP_PROTO_IPv4
224
        je      IPv4_input
217
        je      ipv4_input
Line 225... Line 218...
225
 
218
 
226
;        cmp     ax, PPP_PROTO_IPv6
219
;        cmp     ax, PPP_PROTO_IPv6
Line 227... Line 220...
227
;        je      IPv6_input
220
;        je      ipv6_input
228
 
221
 
229
        jmp     PPPoE_discovery_input   ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
222
        jmp     pppoe_discovery_input   ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
230
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
223
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
Line 231... Line 224...
231
 
224
 
232
  .dump:
-
 
-
 
225
  .dump:
233
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
226
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
234
        call    NET_BUFF_free
-
 
-
 
227
        call    net_buff_free
235
        ret
228
        ret
236
 
229
 
237
 
230
 
238
 
-
 
-
 
231
 
239
;-----------------------------------------------------------------
232
;-----------------------------------------------------------------;
-
 
233
;                                                                 ;
240
;
234
; pppoe_output                                                    ;
241
; PPPoE_output
235
;                                                                 ;
242
;
236
;  IN:  ax = protocol                                             ;
243
; IN:  ax = protocol
237
;       ebx = device ptr                                          ;
244
;     ebx = device ptr
-
 
-
 
238
;       ecx = packet size                                         ;
245
;     ecx = packet size
239
;                                                                 ;
246
;
240
; OUT:  eax = buffer start                                        ;
247
; OUT: eax = buffer start / 0 on error
241
;       eax = 0 on error                                          ;
Line 248... Line 242...
248
;      ebx = device ptr
242
;       ebx = device ptr                                          ;
Line 249... Line 243...
249
;      ecx = packet size
243
;       ecx = packet size                                         ;
250
;      edx = size of complete buffer
244
;       edx = size of complete buffer                             ;
Line 251... Line 245...
251
;      edi = start of PPP payload
245
;       edi = start of PPP payload                                ;
252
;
246
;                                                                 ;
253
;-----------------------------------------------------------------
247
;-----------------------------------------------------------------;
254
align 4
248
align 4
255
PPPoE_output:
249
pppoe_output:
Line 256... Line 250...
256
 
250
 
257
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
251
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
258
 
252
 
Line 285... Line 279...
285
  .eth_error:
279
  .eth_error:
286
        add     esp, 4
280
        add     esp, 4
287
        xor     eax, eax
281
        xor     eax, eax
288
        ret
282
        ret
Line 289... Line 283...
289
 
283
 
290
 
284
align 4
Line 291... Line 285...
291
PPPoE_start_connection:
285
pppoe_start_connection:
Line 292... Line 286...
292
 
286
 
293
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
287
        DEBUGF  DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
Line 306... Line 300...
306
        or      eax, -1
300
        or      eax, -1
307
        ret
301
        ret
Line 308... Line 302...
308
 
302
 
309
 
303
 
Line 310... Line 304...
310
align 4
304
align 4
Line 311... Line 305...
311
PPPoE_stop_connection:
305
pppoe_stop_connection:
312
 
306
 
Line 318... Line 312...
318
        mov     word [PPPoE_MAC + 4], ax
312
        mov     word [PPPoE_MAC + 4], ax
Line 319... Line 313...
319
 
313
 
Line 320... Line 314...
320
        ret
314
        ret
321
 
-
 
322
 
315
 
323
;---------------------------------------------------------------------------
-
 
324
;
316
 
325
; PPPoE API
-
 
-
 
317
;-----------------------------------------------------------------;
326
;
318
;                                                                 ;
327
; This function is called by system function 75
319
; pppoe_api: Part of system function 76                           ;
328
;
320
;                                                                 ;
329
; IN:  subfunction number in bl
-
 
-
 
321
; IN:  subfunction number in bl                                   ;
330
;      device number in bh
322
;      device number in bh                                        ;
331
;      ecx, edx, .. depends on subfunction
-
 
-
 
323
;      ecx, edx, .. depends on subfunction                        ;
332
;
324
;                                                                 ;
333
; OUT:
325
; OUT:                                                            ;
334
;
326
;                                                                 ;
Line 335... Line 327...
335
;---------------------------------------------------------------------------
327
;-----------------------------------------------------------------;
336
align 4
328
align 4
Line 337... Line 329...
337
PPPoE_api:
329
pppoe_api:
338
 
330
 
339
        movzx   eax, bh
331
        movzx   eax, bh
340
        shl     eax, 2
332
        shl     eax, 2
Line 341... Line 333...
341
 
333
 
342
        and     ebx, 0xff
334
        and     ebx, 0xff
343
        cmp     ebx, .number
335
        cmp     ebx, .number
344
        ja      .error
336
        ja      .error
Line 345... Line 337...
345
        jmp     dword [.table + 4*ebx]
337
        jmp     dword [.table + 4*ebx]
346
 
338
 
347
  .table:
339
  .table: