Subversion Repositories Kolibri OS

Rev

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

Rev 1473 Rev 1482
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
 
Line 20... Line 20...
20
$Revision: 1473 $
20
$Revision: 1482 $
21
 
21
 
Line 22... Line 22...
22
__DEBUG_LEVEL_OLD__  equ __DEBUG_LEVEL__
22
__DEBUG_LEVEL_OLD__  equ __DEBUG_LEVEL__
Line 206... Line 206...
206
 
206
 
207
;-----------------------------------------------------------------
207
;-----------------------------------------------------------------
208
;
208
;
209
; checksum_1
209
; checksum_1
210
;
210
;
211
;  This is the first of two functions needed to calculate the TCP checksum.
211
;  This is the first of two functions needed to calculate a checksum.
212
;
212
;
213
;  IN:  edx = start offset for semi-checksum
213
;  IN:  edx = start offset for semi-checksum
214
;       esi = pointer to data
214
;       esi = pointer to data
215
;       ecx = data size
215
;       ecx = data size
Line 287... Line 287...
287
	add	dh, [esi+0]
287
	add	dh, [esi+0]
288
	adc	edx, 0
288
	adc	edx, 0
289
  .end:
289
  .end:
290
	ret
290
	ret
Line 291... Line -...
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
 
-
 
372
	call	checksum_2
-
 
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
 
-
 
430
	neg	word [esi+10]		; zero will stay zero so we jsut get the checksum
-
 
431
	add	word [esi+10], dx	;  , else we will get (new checksum - old checksum) in the end, wich should be 0 :)
-
 
432
 
-
 
433
	ret
-
 
434
 
-
 
435
 
-
 
436
 
291
 
437
;-----------------------------------------------------------------
292
;-----------------------------------------------------------------
438
;
293
;
439
; checksum_2
294
; checksum_2
440
;
295
;
Line 449... Line 304...
449
 
304
 
450
	mov	ecx, edx
305
	mov	ecx, edx
451
	shr	ecx, 16
306
	shr	ecx, 16
452
	and	edx, 0xffff
307
	and	edx, 0xffff
-
 
308
	add	edx, ecx
453
	add	edx, ecx
309
 
454
	mov	eax, edx
310
	mov	ecx, edx
455
	shr	eax, 16
311
	shr	ecx, 16
Line 456... Line 312...
456
	add	edx, eax
312
	add	edx, ecx
457
 
313
 
458
	not	dx
314
	not	dx
459
	jnz	.not_zero
315
	jnz	.not_zero