Rev 2937 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2937 | Rev 2942 | ||
---|---|---|---|
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: 2937 $ |
17 | $Revision: 2942 $ |
18 | 18 | ||
19 | ;----------------------------------------------------------------- |
19 | ;----------------------------------------------------------------- |
20 | ; |
20 | ; |
Line 32... | Line 32... | ||
32 | ;----------------------------------------------------------------- |
32 | ;----------------------------------------------------------------- |
Line 33... | Line 33... | ||
33 | 33 | ||
34 | align 4 |
34 | align 4 |
Line -... | Line 35... | ||
- | 35 | TCP_input: |
|
- | 36 | ||
- | 37 | pushfd |
|
35 | TCP_input: |
38 | cli |
Line 36... | Line 39... | ||
36 | 39 | ||
37 | DEBUGF 1,"TCP_input: size=%u\n", ecx |
40 | DEBUGF 1,"TCP_input: size=%u\n", ecx |
38 | 41 | ||
Line 39... | Line 42... | ||
39 | ; First, record the current time |
42 | ; First, record the current time |
40 | mov eax, [timer_ticks] ; in 1/100 seconds |
43 | mov eax, [timer_ticks] ; in 1/100 seconds |
41 | mov [esp+4], eax |
44 | mov [esp+8], eax |
Line 212... | Line 215... | ||
212 | jz @f |
215 | jz @f |
Line 213... | Line 216... | ||
213 | 216 | ||
214 | movzx eax, word[esi+2] |
217 | movzx eax, word[esi+2] |
215 | rol ax, 8 |
218 | rol ax, 8 |
216 | DEBUGF 1,"TCP_input: Maxseg=%u\n", ax |
- | |
217 | 219 | DEBUGF 1,"TCP_input: Maxseg=%u\n", ax |
|
Line 218... | Line 220... | ||
218 | mov [ebx + TCP_SOCKET.t_maxseg], eax |
220 | mov [ebx + TCP_SOCKET.t_maxseg], eax |
219 | 221 | ||
220 | @@: |
222 | @@: |
Line 328... | Line 330... | ||
328 | 330 | ||
Line 329... | Line 331... | ||
329 | ; Update RTT estimators |
331 | ; Update RTT estimators |
330 | 332 | ||
331 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
333 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
332 | jz .no_timestamp_rtt |
334 | jz .no_timestamp_rtt |
333 | mov eax, [esp + 4] ; timestamp when this segment was received |
335 | mov eax, [esp + 4+4] ; timestamp when this segment was received |
334 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
336 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
335 | inc eax |
337 | inc eax |
Line 415... | Line 417... | ||
415 | 417 | ||
Line 416... | Line 418... | ||
416 | DEBUGF 1,"TCP_input: Header prediction failed\n" |
418 | DEBUGF 1,"TCP_input: Header prediction failed\n" |
Line -... | Line 419... | ||
- | 419 | ||
417 | 420 | ; Calculate receive window size |
|
418 | ; Calculate receive window size |
421 | |
419 | 422 | push edx |
|
420 | mov eax, SOCKETBUFFSIZE |
423 | mov eax, SOCKETBUFFSIZE |
421 | sub eax, [ebx + STREAM_SOCKET.rcv.size] |
424 | sub eax, [ebx + STREAM_SOCKET.rcv.size] |
422 | mov edx, [ebx + TCP_SOCKET.RCV_ADV] |
425 | mov edx, [ebx + TCP_SOCKET.RCV_ADV] |
423 | sub edx, [ebx + TCP_SOCKET.RCV_NXT] |
426 | sub edx, [ebx + TCP_SOCKET.RCV_NXT] |
424 | cmp eax, edx |
427 | cmp eax, edx |
- | 428 | jg @f |
|
425 | ja @f |
429 | mov eax, edx |
- | 430 | @@: |
|
Line 426... | Line 431... | ||
426 | mov eax, edx |
431 | DEBUGF 1,"Receive window size=%d\n", ax |
Line 427... | Line 432... | ||
427 | @@: |
432 | mov [ebx + TCP_SOCKET.RCV_WND], ax |
428 | mov [ebx + TCP_SOCKET.RCV_WND], ax |
433 | pop edx |
Line 460... | Line 465... | ||
460 | 465 | ||
Line 461... | Line 466... | ||
461 | ; check for duplicate data at beginning of segment |
466 | ; check for duplicate data at beginning of segment |
462 | 467 | ||
463 | mov eax, [ebx + TCP_SOCKET.RCV_NXT] |
468 | mov eax, [ebx + TCP_SOCKET.RCV_NXT] |
Line 464... | Line 469... | ||
464 | sub eax, [edx + TCP_header.SequenceNumber] |
469 | sub eax, [edx + TCP_header.SequenceNumber] |
Line 465... | Line 470... | ||
465 | jbe .no_duplicate |
470 | jle .no_duplicate |
466 | 471 | ||
Line 467... | Line 472... | ||
467 | DEBUGF 1,"TCP_input: %u bytes duplicate data!\n", eax |
472 | DEBUGF 1,"TCP_input: %u bytes duplicate data!\n", eax |
Line 468... | Line 473... | ||
468 | 473 | ||
469 | test [edx + TCP_header.Flags], TH_SYN |
474 | test [edx + TCP_header.Flags], TH_SYN |
Line 470... | Line 475... | ||
470 | jz .no_dup_syn |
475 | jz .no_dup_syn |
Line 509... | Line 514... | ||
509 | ;;; TODO: 677 |
514 | ;;; TODO: 677 |
510 | add [edx + TCP_header.SequenceNumber], eax |
515 | add [edx + TCP_header.SequenceNumber], eax |
511 | sub ecx, eax |
516 | sub ecx, eax |
Line 512... | Line 517... | ||
512 | 517 | ||
513 | sub [edx + TCP_header.UrgentPointer], ax |
518 | sub [edx + TCP_header.UrgentPointer], ax |
514 | ja @f |
519 | jg @f |
515 | and [edx + TCP_header.Flags], not (TH_URG) |
520 | and [edx + TCP_header.Flags], not (TH_URG) |
516 | mov [edx + TCP_header.UrgentPointer], 0 |
521 | mov [edx + TCP_header.UrgentPointer], 0 |
Line 517... | Line 522... | ||
517 | @@: |
522 | @@: |
Line 538... | Line 543... | ||
538 | .not_terminated: |
543 | .not_terminated: |
539 | mov eax, [edx + TCP_header.SequenceNumber] |
544 | mov eax, [edx + TCP_header.SequenceNumber] |
540 | add eax, ecx |
545 | add eax, ecx |
541 | sub eax, [ebx + TCP_SOCKET.RCV_NXT] |
546 | sub eax, [ebx + TCP_SOCKET.RCV_NXT] |
542 | sub ax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop |
547 | sub ax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop |
543 | jbe .no_excess_data |
548 | jle .no_excess_data |
- | 549 | ||
- | 550 | DEBUGF 1,"%d bytes beyond right edge of window\n", eax |
|
Line 544... | Line 551... | ||
544 | 551 | ||
545 | ;;; TODO: update stats |
552 | ;;; TODO: update stats |
546 | cmp eax, ecx |
553 | cmp eax, ecx |
547 | jb .dont_drop_all |
554 | jl .dont_drop_all |
548 | ; If a new connection request is received while in TIME_WAIT, drop the old connection and start over, |
555 | ; If a new connection request is received while in TIME_WAIT, drop the old connection and start over, |
Line 549... | Line 556... | ||
549 | ; if the sequence numbers are above the previous ones |
556 | ; if the sequence numbers are above the previous ones |
550 | 557 | ||
551 | test [edx + TCP_header.Flags], TH_SYN |
558 | test [edx + TCP_header.Flags], TH_SYN |
552 | jz .no_new_request |
559 | jz .no_new_request |
553 | cmp [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT |
560 | cmp [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT |
554 | jne .no_new_request |
561 | jne .no_new_request |
555 | mov edx, [ebx + TCP_SOCKET.RCV_NXT] |
562 | ; mov edx, [ebx + TCP_SOCKET.RCV_NXT] |
556 | cmp edx, [edx + TCP_header.SequenceNumber] |
563 | ; cmp edx, [edx + TCP_header.SequenceNumber] |
557 | add edx, 64000 ; TCP_ISSINCR |
564 | ; add edx, 64000 ; TCP_ISSINCR FIXME |
558 | mov eax, ebx |
565 | mov eax, ebx |
559 | call TCP_close |
566 | call TCP_close |
Line 593... | Line 600... | ||
593 | dec eax |
600 | dec eax |
594 | @@: |
601 | @@: |
595 | sub eax, ecx |
602 | sub eax, ecx |
596 | jae .no_timestamp |
603 | jae .no_timestamp |
Line 597... | Line 604... | ||
597 | 604 | ||
598 | mov eax, [esp + 4] ; tcp_now |
605 | mov eax, [esp + 4+4] ; tcp_now |
599 | mov [ebx + TCP_SOCKET.ts_recent_age], eax |
606 | mov [ebx + TCP_SOCKET.ts_recent_age], eax |
600 | mov eax, [ebx + TCP_SOCKET.ts_val] |
607 | mov eax, [ebx + TCP_SOCKET.ts_val] |
601 | mov [ebx + TCP_SOCKET.ts_recent], eax |
608 | mov [ebx + TCP_SOCKET.ts_recent], eax |
Line 842... | Line 849... | ||
842 | 849 | ||
Line 843... | Line 850... | ||
843 | ; If we have a timestamp, update smoothed RTT |
850 | ; If we have a timestamp, update smoothed RTT |
844 | 851 | ||
845 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
852 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
846 | jne .timestamp_not_present |
853 | jne .timestamp_not_present |
847 | mov eax, [esp+4] |
854 | mov eax, [esp+4+4] |
848 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
855 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
849 | inc eax |
856 | inc eax |
Line 1455... | Line 1462... | ||
1455 | call TCP_output |
1462 | call TCP_output |
Line 1456... | Line 1463... | ||
1456 | 1463 | ||
1457 | .dumpit: |
1464 | .dumpit: |
Line -... | Line 1465... | ||
- | 1465 | DEBUGF 1,"TCP_input: dumping\n" |
|
1458 | DEBUGF 1,"TCP_input: dumping\n" |
1466 | |
1459 | 1467 | popf |
|
- | 1468 | call kernel_free |
|
1460 | call kernel_free |
1469 | add esp, 4 |
Line 1461... | Line 1470... | ||
1461 | add esp, 4 |
1470 | |
1462 | ret |
1471 | ret |
Line 1500... | Line 1509... | ||
1500 | call SOCKET_free |
1509 | call SOCKET_free |
Line 1501... | Line 1510... | ||
1501 | 1510 | ||
1502 | .drop_no_socket: |
1511 | .drop_no_socket: |
Line -... | Line 1512... | ||
- | 1512 | DEBUGF 1,"TCP_input: Drop (no socket)\n" |
|
1503 | DEBUGF 1,"TCP_input: Drop (no socket)\n" |
1513 | |
1504 | 1514 | popf |
|
- | 1515 | call kernel_free |
|
1505 | call kernel_free |
1516 | add esp, 4 |
Line 1506... | Line 1517... | ||
1506 | add esp, 4 |
1517 | |
Line 1507... | Line 1518... | ||
1507 | ret |
1518 | ret |