Subversion Repositories Kolibri OS

Rev

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

Rev 1318 Rev 1473
Line 15... Line 15...
15
;;          GNU GENERAL PUBLIC LICENSE                             ;;
15
;;          GNU GENERAL PUBLIC LICENSE                             ;;
16
;;             Version 2, June 1991                                ;;
16
;;             Version 2, June 1991                                ;;
17
;;                                                                 ;;
17
;;                                                                 ;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 19... Line 19...
19
 
19
 
-
 
20
$Revision: 1473 $
-
 
21
 
-
 
22
__DEBUG_LEVEL_OLD__  equ __DEBUG_LEVEL__
Line 20... Line 23...
20
$Revision: 1318 $
23
__DEBUG_LEVEL__ equ 1			; this sets the debug level for network part of kernel
21
 
24
 
22
uglobal
25
uglobal
23
	last_1sTick	db ?
26
	last_1sTick	db ?
Line 24... Line 27...
24
	last_1hsTick	dd ?
27
	last_1hsTick	dd ?
25
endg
28
endg
Line 26... Line 29...
26
 
29
 
27
MAX_NET_DEVICES 	equ 16
30
MAX_NET_DEVICES 	equ 16
Line 28... Line 31...
28
QUEUE_BEFORE_SENDING	equ 1 ; 1 or 0 (enable or disable) currently only affects ethernet
31
QUEUE_BEFORE_SENDING	equ 0		; 1 or 0 (enable or disable) currently only affects ethernet
Line 205... Line 208...
205
;
208
;
206
; checksum_1
209
; checksum_1
207
;
210
;
208
;  This is the first of two functions needed to calculate the TCP checksum.
211
;  This is the first of two functions needed to calculate the TCP checksum.
209
;
212
;
210
;  IN:  edx = start offeset for semi-checksum
213
;  IN:  edx = start offset for semi-checksum
211
;       esi = pointer to data
214
;       esi = pointer to data
212
;       ecx = data size
215
;       ecx = data size
213
;  OUT: edx = semi-checksum
216
;  OUT: edx = semi-checksum
214
;
217
;
-
 
218
;
-
 
219
; Code was optimized by diamond
-
 
220
;
215
;-----------------------------------------------------------------
221
;-----------------------------------------------------------------
216
align 4
222
align 4
217
checksum_1:
223
checksum_1:
Line 218... Line -...
218
 
-
 
219
	xor	eax, eax
224
 
220
	shr	ecx, 1
225
	shr	ecx, 1
-
 
226
	pushf
-
 
227
	jz	.no_2
-
 
228
 
-
 
229
	shr	ecx, 1
-
 
230
	pushf
-
 
231
	jz	.no_4
-
 
232
 
-
 
233
	shr	ecx, 1
-
 
234
	pushf
-
 
235
	jz	.no_8
221
	pushf
236
 
-
 
237
  .loop:
222
.loop:
238
	add	dl, [esi+1]
-
 
239
	adc	dh, [esi+0]
223
	lodsw
240
 
224
	xchg	al, ah
241
	adc	dl, [esi+3]
-
 
242
	adc	dh, [esi+2]
225
	add	edx, eax
243
 
-
 
244
	adc	dl, [esi+5]
Line -... Line 245...
-
 
245
	adc	dh, [esi+4]
-
 
246
 
-
 
247
	adc	dl, [esi+7]
-
 
248
	adc	dh, [esi+6]
-
 
249
 
-
 
250
	adc	edx, 0
-
 
251
	add	esi, 8
-
 
252
 
-
 
253
	dec	ecx
-
 
254
	jnz	.loop
-
 
255
 
-
 
256
	adc	edx, 0
226
	loop	.loop
257
 
227
 
258
  .no_8:
-
 
259
	popf
-
 
260
	jnc	.no_4
-
 
261
 
-
 
262
	add	dl, [esi+1]
-
 
263
	adc	dh, [esi+0]
-
 
264
 
-
 
265
	adc	dl, [esi+3]
-
 
266
	adc	dh, [esi+2]
-
 
267
 
-
 
268
	adc	edx, 0
-
 
269
	add	esi, 4
-
 
270
 
-
 
271
  .no_4:
-
 
272
	popf
-
 
273
	jnc	.no_2
-
 
274
 
Line 228... Line -...
228
	popf
-
 
229
	jnc	.end
275
	add	dl, [esi+1]
Line -... Line 276...
-
 
276
	adc	dh, [esi+0]
-
 
277
 
-
 
278
	adc	edx, 0
-
 
279
 
-
 
280
	inc	ecx
-
 
281
	inc	ecx
-
 
282
 
-
 
283
  .no_2:
-
 
284
	popf
230
 
285
	jnc	.end
-
 
286
 
-
 
287
	add	dh, [esi+0]
-
 
288
	adc	edx, 0
-
 
289
  .end:
-
 
290
	ret
-
 
291
 
-
 
292
 
-
 
293
 
-
 
294
 
-
 
295
 
-
 
296
;IN: 12 bytes of pseudoheader pushed onto the stack
-
 
297
;    edx = start offset
-
 
298
;
-
 
299
; OUT: pseudochecksum in edx
-
 
300
 
-
 
301
 
-
 
302
align 4
-
 
303
checksum_pseudoheader:
-
 
304
 
-
 
305
	add	dl, [esp+5]
-
 
306
	adc	dh, [esp+4]
-
 
307
 
-
 
308
	adc	dl, [esp+7]
-
 
309
	adc	dh, [esp+6]
-
 
310
 
-
 
311
	adc	dl, [esp+9]
-
 
312
	adc	dh, [esp+8]
-
 
313
 
-
 
314
	adc	dl, [esp+11]
-
 
315
	adc	dh, [esp+10]
-
 
316
 
-
 
317
	adc	dl, [esp+13]
-
 
318
	adc	dh, [esp+12]
-
 
319
 
-
 
320
	adc	dl, [esp+15]
-
 
321
	adc	dh, [esp+14]
-
 
322
 
-
 
323
	adc	edx,0
-
 
324
	ret	12
-
 
325
 
-
 
326
 
-
 
327
 
-
 
328
 
-
 
329
 
-
 
330
align 4
-
 
331
checksum_ip_header:
-
 
332
 
-
 
333
; This is the fast procedure to create or check a IP header without options
-
 
334
;
-
 
335
; To create a new checksum, the checksum field must be set to 0 before computation
-
 
336
;
-
 
337
; To check an existing checksum, leave the checksum as is, and it will be 0 after this procedure, if it was correct
-
 
338
 
-
 
339
	xor	edx, edx
-
 
340
 
-
 
341
	add	dl, [esi+1]
-
 
342
	adc	dh, [esi+0]
-
 
343
 
-
 
344
	adc	dl, [esi+3]
-
 
345
	adc	dh, [esi+2]
-
 
346
 
-
 
347
	adc	dl, [esi+5]
-
 
348
	adc	dh, [esi+4]
-
 
349
 
-
 
350
	adc	dl, [esi+7]
-
 
351
	adc	dh, [esi+6]
-
 
352
 
-
 
353
	adc	dl, [esi+9]
-
 
354
	adc	dh, [esi+8]
-
 
355
 
-
 
356
; we skip 11th and 12th byte, they are the checksum bytes and should be 0 for re-calculation
-
 
357
 
-
 
358
	adc	dl, [esi+13]
-
 
359
	adc	dh, [esi+12]
-
 
360
 
-
 
361
	adc	dl, [esi+15]
-
 
362
	adc	dh, [esi+14]
-
 
363
 
-
 
364
	adc	dl, [esi+17]
-
 
365
	adc	dh, [esi+16]
-
 
366
 
-
 
367
	adc	dl, [esi+19]
-
 
368
	adc	dh, [esi+18]
-
 
369
 
-
 
370
	adc	edx, 0
-
 
371
 
Line 231... Line 372...
231
	add	dh, [esi]
372
	call	checksum_2
Line -... Line 373...
-
 
373
 
-
 
374
	neg	word [esi+10]		; zero will stay zero so we jsut get the checksum
-
 
375
	add	word [esi+10], dx	;  , else we will get (new checksum - old checksum) in the end, wich should be 0 :)
-
 
376
 
-
 
377
	ret
-
 
378
 
-
 
379
 
-
 
380
 
-
 
381
 
-
 
382
 
-
 
383
 
-
 
384
 
-
 
385
 
-
 
386
align 4
-
 
387
checksum_udp:
-
 
388
 
-
 
389
; This is the fast procedure to create or check a IP header without options
-
 
390
;
-
 
391
; To create a new checksum, the checksum field must be set to 0 before computation
-
 
392
;
-
 
393
; To check an existing checksum, leave the checksum as is, and it will be 0 after this procedure, if it was correct
-
 
394
 
-
 
395
	xor	edx, edx
-
 
396
 
-
 
397
	add	dl, [esi+1]
-
 
398
	adc	dh, [esi+0]
-
 
399
 
-
 
400
	adc	dl, [esi+3]
-
 
401
	adc	dh, [esi+2]
-
 
402
 
-
 
403
	adc	dl, [esi+5]
-
 
404
	adc	dh, [esi+4]
-
 
405
 
-
 
406
	adc	dl, [esi+7]
-
 
407
	adc	dh, [esi+6]
-
 
408
 
-
 
409
	adc	dl, [esi+9]
-
 
410
	adc	dh, [esi+8]
-
 
411
 
-
 
412
; we skip 11th and 12th byte, they are the checksum bytes and should be 0 for re-calculation
-
 
413
 
-
 
414
	adc	dl, [esi+13]
-
 
415
	adc	dh, [esi+12]
-
 
416
 
-
 
417
	adc	dl, [esi+15]
-
 
418
	adc	dh, [esi+14]
-
 
419
 
-
 
420
	adc	dl, [esi+17]
-
 
421
	adc	dh, [esi+16]
-
 
422
 
-
 
423
	adc	dl, [esi+19]
-
 
424
	adc	dh, [esi+18]
-
 
425
 
-
 
426
	adc	edx, 0
-
 
427
 
-
 
428
	call	checksum_2
-
 
429
 
232
	adc	edx, 0
430
	neg	word [esi+10]		; zero will stay zero so we jsut get the checksum
233
 
431
	add	word [esi+10], dx	;  , else we will get (new checksum - old checksum) in the end, wich should be 0 :)
234
.end:
432
 
235
 
433
	ret
236
	ret
434
 
Line 398... Line 596...
398
	mov	eax, -1
596
	mov	eax, -1
Line 399... Line 597...
399
 
597
 
400
  .return:
598
  .return:
401
	mov	[esp+28+4], eax
599
	mov	[esp+28+4], eax
-
 
600
	ret
-
 
601
 
-
 
602
 
402
	ret
603
__DEBUG_LEVEL__ equ __DEBUG_LEVEL_OLD__