Rev 1533 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1533 | Rev 1534 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
14 | ;; GNU GENERAL PUBLIC LICENSE ;; |
15 | ;; Version 2, June 1991 ;; |
15 | ;; Version 2, June 1991 ;; |
16 | ;; ;; |
16 | ;; ;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
17 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 18... | Line 18... | ||
18 | 18 | ||
Line 19... | Line 19... | ||
19 | $Revision: 1533 $ |
19 | $Revision: 1534 $ |
20 | 20 | ||
21 | ; Socket states |
21 | ; Socket states |
22 | TCB_CLOSED equ 0 |
22 | TCB_CLOSED equ 0 |
Line 339... | Line 339... | ||
339 | 339 | ||
Line 340... | Line 340... | ||
340 | DEBUGF 1,"Checksum is correct\n" |
340 | DEBUGF 1,"Checksum is correct\n" |
341 | 341 | ||
- | 342 | sub ecx, esi ; update packet size |
|
Line 342... | Line 343... | ||
342 | sub ecx, esi ; update packet size |
343 | jl .drop |
343 | jl .drop |
344 | DEBUGF 1,"we got %u bytes of data\n", ecx |
Line 344... | Line 345... | ||
344 | 345 | ||
Line 432... | Line 433... | ||
432 | 433 | ||
433 | ;---------------------------------------------------------------------------------------- |
434 | ;---------------------------------------------------------------------------------------- |
Line 434... | Line 435... | ||
434 | ; unscale the window into a 32 bit value (notice that SND_SCALE must be initialised to 0) |
435 | ; unscale the window into a 32 bit value (notice that SND_SCALE must be initialised to 0) |
435 | 436 | ||
436 | movzx eax, [edx + TCP_segment.Window] |
437 | movzx eax, [edx + TCP_segment.Window] |
437 | push cx |
438 | push ecx |
438 | mov cl, [ebx + TCP_SOCKET.SND_SCALE] |
439 | mov cl, [ebx + TCP_SOCKET.SND_SCALE] |
Line 439... | Line 440... | ||
439 | shl eax, cl |
440 | shl eax, cl |
Line 440... | Line 441... | ||
440 | pop cx |
441 | pop ecx |
441 | 442 | ||
Line 582... | Line 583... | ||
582 | 583 | ||
583 | mov eax, [ebx + TCP_SOCKET.SND_NXT] |
584 | mov eax, [ebx + TCP_SOCKET.SND_NXT] |
584 | cmp eax, [ebx + TCP_SOCKET.SND_MAX] |
585 | cmp eax, [ebx + TCP_SOCKET.SND_MAX] |
Line -... | Line 586... | ||
- | 586 | jne .not_uni_xfer |
|
- | 587 | ||
585 | jne .not_uni_xfer |
588 | DEBUGF 1,"6\n" |
586 | 589 | ||
Line 587... | Line 590... | ||
587 | ;--------------------------------------- |
590 | ;--------------------------------------- |
588 | ; check if we are sender in the uni-xfer |
591 | ; check if we are sender in the uni-xfer |
589 | 592 | ||
590 | ; If the following 4 conditions are all true, this segment is a pure ACK. |
593 | ; If the following 4 conditions are all true, this segment is a pure ACK. |
591 | ; |
594 | ; |
Line -... | Line 595... | ||
- | 595 | ; - The segment contains no data. |
|
- | 596 | test ecx, ecx |
|
592 | ; - The segment contains no data. |
597 | jnz .not_sender |
593 | test ecx, ecx |
598 | |
594 | jnz .not_sender |
599 | DEBUGF 1,"7\n" |
595 | 600 | ||
596 | ; - The congestion window is greater than or equal to the current send window. |
601 | ; - The congestion window is greater than or equal to the current send window. |
Line -... | Line 602... | ||
- | 602 | ; This test is true only if the window is fully open, that is, the connection is not in the middle of slow start or congestion avoidance. |
|
- | 603 | mov eax, [ebx + TCP_SOCKET.SND_CWND] |
|
597 | ; This test is true only if the window is fully open, that is, the connection is not in the middle of slow start or congestion avoidance. |
604 | cmp eax, [ebx + TCP_SOCKET.SND_WND] |
598 | mov eax, [ebx + TCP_SOCKET.SND_CWND] |
605 | jl .not_uni_xfer |
599 | cmp eax, [ebx + TCP_SOCKET.SND_WND] |
606 | |
600 | jl .not_uni_xfer |
607 | DEBUGF 1,"8\n" |
Line -... | Line 608... | ||
- | 608 | ||
- | 609 | ; - The acknowledgment field in the segment is less than or equal to the maximum sequence number sent. |
|
601 | 610 | mov eax, [edx + TCP_segment.AckNumber] |
|
602 | ; - The acknowledgment field in the segment is less than or equal to the maximum sequence number sent. |
611 | cmp eax, [ebx + TCP_SOCKET.SND_MAX] |
603 | mov ecx, [edx + TCP_segment.AckNumber] |
612 | jg .not_uni_xfer |
Line 604... | Line 613... | ||
604 | cmp ecx, [ebx + TCP_SOCKET.SND_MAX] |
613 | |
Line 605... | Line 614... | ||
605 | jg .not_uni_xfer |
614 | DEBUGF 1,"9\n" |
Line 637... | Line 646... | ||
637 | ; maybe we are the receiver in the uni-xfer then.. |
646 | ; maybe we are the receiver in the uni-xfer then.. |
Line 638... | Line 647... | ||
638 | 647 | ||
639 | .not_sender: |
648 | .not_sender: |
Line -... | Line 649... | ||
- | 649 | ; - The amount of data in the segment is greater than 0 (data count is in ecx) |
|
- | 650 | ||
640 | ; - The amount of data in the segment is greater than 0 (data count is in ecx) |
651 | DEBUGF 1,"10\n" |
641 | 652 | ||
642 | ; - The acknowledgment field equals the largest unacknowledged sequence number. This means no data is acknowledged by this segment. |
653 | ; - The acknowledgment field equals the largest unacknowledged sequence number. This means no data is acknowledged by this segment. |
643 | mov eax, [edx + TCP_segment.AckNumber] |
654 | mov eax, [edx + TCP_segment.AckNumber] |
Line 1041... | Line 1052... | ||
1041 | 1052 | ||
Line 1042... | Line 1053... | ||
1042 | ;;; update stats |
1053 | ;;; update stats |
Line 1043... | Line 1054... | ||
1043 | 1054 | ||
Line 1044... | Line 1055... | ||
1044 | .rst_close: |
1055 | .rst_close: |
1045 | 1056 | ||
Line 1046... | Line 1057... | ||
1046 | DEBUGF 1,"Closing with reset" |
1057 | DEBUGF 1,"Closing with reset\n" |
Line 1059... | Line 1070... | ||
1059 | ;;; tcp_drop ( ECONNRESET) |
1070 | ;;; tcp_drop ( ECONNRESET) |
1060 | jmp .drop_with_reset |
1071 | jmp .drop_with_reset |
Line 1061... | Line 1072... | ||
1061 | 1072 | ||
1062 | test [edx + TCP_segment.Flags], TH_ACK |
1073 | test [edx + TCP_segment.Flags], TH_ACK |
1063 | jz .drop |
1074 | jz .drop |
1064 | 1075 | @@: |
|
1065 | ;---------------- |
1076 | ;---------------- |
Line 1066... | Line 1077... | ||
1066 | ; Process the ACK |
1077 | ; Process the ACK |
1067 | 1078 | ||
1068 | cmp [ebx + TCP_SOCKET.t_state], TCB_SYN_RECEIVED |
1079 | cmp [ebx + TCP_SOCKET.t_state], TCB_SYN_RECEIVED |
Line 1069... | Line 1080... | ||
1069 | jg .ack_dup |
1080 | jg .ack_dup |
Line 1070... | Line 1081... | ||
1070 | jl .ack_nodup |
1081 | jl .ack_nodup |
Line 1071... | Line 1082... | ||
1071 | 1082 | ||
Line 1072... | Line 1083... | ||
1072 | DEBUGF 1,"TCP state = syn received" |
1083 | DEBUGF 1,"TCP state = syn received\n" |
Line 1073... | Line 1084... | ||
1073 | 1084 | ||
Line 1074... | Line 1085... | ||
1074 | ;;;;; |
1085 | ;;;;; |
Line 1075... | Line 1086... | ||
1075 | 1086 | ||
Line 1076... | Line 1087... | ||
1076 | .ack_dup: |
1087 | .ack_dup: |
Line 1077... | Line 1088... | ||
1077 | 1088 | ||
1078 | DEBUGF 1,"Duplicate ACK" |
1089 | DEBUGF 1,"Duplicate ACK\n" |
1079 | 1090 | ||
Line 1112... | Line 1123... | ||
1112 | 1123 | ||
1113 | 1124 | ||
Line -... | Line 1125... | ||
- | 1125 | ;------------------------------------------ |
|
1114 | ;------------------------------------------ |
1126 | ; Remove acknowledged data from send buffer |
- | 1127 | ||
1115 | ; Remove acknowledged data from send buffer |
1128 | push ecx |
1116 | 1129 | mov ecx, [edx + TCP_segment.AckNumber] ;;; |
|
- | 1130 | sub ecx, [ebx + TCP_SOCKET.SND_UNA] ;;; |
|
Line 1117... | Line 1131... | ||
1117 | xor ecx, ecx ;;;;;; |
1131 | lea eax, [ebx + STREAM_SOCKET.snd] |
1118 | lea eax, [ebx + STREAM_SOCKET.snd] |
1132 | call SOCKET_ring_free ;;;; 943 - 956 |
Line 1119... | Line 1133... | ||
1119 | call SOCKET_ring_free ;;;; 943 - 956 |
1133 | pop ecx |
Line 1249... | Line 1263... | ||
1249 | ;-------------------------------- |
1263 | ;-------------------------------- |
1250 | ; process the data in the segment |
1264 | ; process the data in the segment |
Line 1251... | Line 1265... | ||
1251 | 1265 | ||
Line 1252... | Line 1266... | ||
1252 | .do_data: |
1266 | .do_data: |
Line 1253... | Line 1267... | ||
1253 | 1267 | ||
1254 | DEBUGF 1,"TCP: do data\n" |
1268 | DEBUGF 1,"TCP: do data (%u)\n", ecx |
Line 1255... | Line 1269... | ||
1255 | 1269 | ||
Line 1643... | Line 1657... | ||
1643 | .no_window: |
1657 | .no_window: |
Line 1644... | Line 1658... | ||
1644 | 1658 | ||
1645 | ;-------------------------- |
1659 | ;-------------------------- |
Line 1646... | Line 1660... | ||
1646 | ; Should a segment be sent? |
1660 | ; Should a segment be sent? |
1647 | 1661 | ||
Line 1648... | Line 1662... | ||
1648 | test [ebx + TCP_SOCKET.t_flags], TF_ACKNOW |
1662 | test [eax + TCP_SOCKET.t_flags], TF_ACKNOW |
1649 | jnz .send |
1663 | jnz .send |
Line 1650... | Line 1664... | ||
1650 | 1664 | ||
1651 | test dl, TH_SYN + TH_RST |
1665 | test dl, TH_SYN + TH_RST |
1652 | jnz .send |
1666 | jnz .send |
Line 1653... | Line 1667... | ||
1653 | 1667 | ||
1654 | mov eax, [ebx + TCP_SOCKET.SND_UP] |
1668 | mov ebx, [eax + TCP_SOCKET.SND_UP] |
Line 1655... | Line 1669... | ||
1655 | cmp eax, [ebx + TCP_SOCKET.SND_UNA] |
1669 | cmp ebx, [eax + TCP_SOCKET.SND_UNA] |
1656 | jg .send |
1670 | jg .send |
Line 1657... | Line 1671... | ||
1657 | 1671 | ||
1658 | test dl, TH_FIN |
1672 | test dl, TH_FIN |
1659 | jz .enter_persist |
1673 | jz .enter_persist |
Line 1660... | Line 1674... | ||
1660 | 1674 | ||
1661 | test [ebx + TCP_SOCKET.t_flags], TF_SENTFIN |
1675 | test [eax + TCP_SOCKET.t_flags], TF_SENTFIN |