Rev 3144 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3144 | Rev 3251 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; Part of the TCP/IP network stack for KolibriOS ;; |
6 | ;; Part of the TCP/IP network stack for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
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: 3144 $ |
17 | $Revision: 3251 $ |
18 | 18 | ||
19 | ;----------------------------------------------------------------- |
19 | ;----------------------------------------------------------------- |
20 | ; |
20 | ; |
- | 21 | ; TCP_input: |
|
- | 22 | ; |
|
21 | ; TCP_input: |
23 | ; Add a segment to the incoming TCP queue |
22 | ; |
24 | ; |
23 | ; IN: [esp] = ptr to buffer |
25 | ; IN: [esp] = ptr to buffer |
24 | ; [esp+4] = buffer size |
26 | ; [esp+4] = buffer size |
25 | ; ebx = ptr to device struct |
27 | ; ebx = ptr to device struct |
Line 32... | Line 34... | ||
32 | ;----------------------------------------------------------------- |
34 | ;----------------------------------------------------------------- |
Line 33... | Line 35... | ||
33 | 35 | ||
34 | align 4 |
36 | align 4 |
Line -... | Line 37... | ||
- | 37 | TCP_input: |
|
- | 38 | ||
- | 39 | push ebx ecx esi edi ; mind the order |
|
35 | TCP_input: |
40 | mov esi, esp |
36 | 41 | ||
Line -... | Line 42... | ||
- | 42 | pushf |
|
- | 43 | cli |
|
- | 44 | ||
- | 45 | add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail |
|
- | 46 | ||
- | 47 | popf |
|
- | 48 | ||
- | 49 | add esp, sizeof.TCP_queue_entry |
|
- | 50 | ret |
|
- | 51 | ||
- | 52 | .fail: |
|
- | 53 | DEBUGF 2, "TCP incoming queue is full, discarding packet!\n" |
|
- | 54 | ||
- | 55 | add esp, sizeof.TCP_queue_entry - 8 |
|
- | 56 | call kernel_free |
|
- | 57 | add esp, 4 |
|
- | 58 | .done: |
|
- | 59 | ret |
|
- | 60 | ||
- | 61 | ||
- | 62 | ||
- | 63 | align 4 |
|
- | 64 | TCP_process_input: |
|
- | 65 | ||
- | 66 | .loop: |
|
- | 67 | get_from_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, TCP_input.done |
|
- | 68 | ||
- | 69 | push .loop |
|
- | 70 | push [esi + TCP_queue_entry.buffer_size] |
|
- | 71 | push [esi + TCP_queue_entry.buffer_ptr] |
|
- | 72 | ||
- | 73 | mov ebx, [esi + TCP_queue_entry.device_ptr] |
|
- | 74 | mov ecx, [esi + TCP_queue_entry.segment_size] |
|
- | 75 | mov edi, [esi + TCP_queue_entry.ip_ptr] |
|
- | 76 | mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last |
|
- | 77 | ||
- | 78 | ;----------------------------------------------------------------- |
|
- | 79 | ; |
|
- | 80 | ; IN: [esp] = ptr to buffer |
|
- | 81 | ; [esp+4] = buffer size - actually, we dont care |
|
- | 82 | ; ebx = ptr to device struct |
|
- | 83 | ; ecx = segment size |
|
- | 84 | ; esi = ptr to TCP segment |
|
- | 85 | ; edi = ptr to ipv4 source address, followed by ipv4 dest address |
|
- | 86 | ; |
|
- | 87 | ; OUT: / |
|
37 | pushfd |
88 | ; |
Line 38... | Line 89... | ||
38 | cli |
89 | ;----------------------------------------------------------------- |
39 | 90 | ||
40 | DEBUGF 1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks] |
91 | DEBUGF 1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks] |
Line 41... | Line 92... | ||
41 | 92 | ||
42 | ; First, record the current time |
93 | ; First, record the current time |
43 | mov eax, [timer_ticks] ; in 1/100 seconds |
94 | mov eax, [timer_ticks] ; in 1/100 seconds |
Line 311... | Line 362... | ||
311 | cmp eax, [ebx + TCP_SOCKET.ts_val] |
362 | cmp eax, [ebx + TCP_SOCKET.ts_val] |
312 | jge .no_paws |
363 | jge .no_paws |
Line 313... | Line 364... | ||
313 | 364 | ||
Line 314... | Line 365... | ||
314 | DEBUGF 1,"TCP_input: PAWS: detected an old segment\n" |
365 | DEBUGF 1,"TCP_input: PAWS: detected an old segment\n" |
315 | 366 | ||
316 | mov eax, [esp+4+4+4] ; tcp_now |
367 | mov eax, [esp+4+4] ; tcp_now |
317 | sub eax, [ebx + TCP_SOCKET.ts_recent_age] |
368 | sub eax, [ebx + TCP_SOCKET.ts_recent_age] |
Line 318... | Line 369... | ||
318 | cmp eax, TCP_PAWS_IDLE |
369 | cmp eax, TCP_PAWS_IDLE |
Line 400... | Line 451... | ||
400 | 451 | ||
Line 401... | Line 452... | ||
401 | ; Update RTT estimators |
452 | ; Update RTT estimators |
402 | 453 | ||
403 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
454 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
404 | jz .no_timestamp_rtt |
455 | jz .no_timestamp_rtt |
405 | mov eax, [esp + 4+4] ; timestamp when this segment was received |
456 | mov eax, [esp + 4] ; timestamp when this segment was received |
406 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
457 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
407 | inc eax |
458 | inc eax |
Line 667... | Line 718... | ||
667 | sub eax, ecx |
718 | sub eax, ecx |
668 | jae .no_timestamp |
719 | jae .no_timestamp |
Line 669... | Line 720... | ||
669 | 720 | ||
Line 670... | Line 721... | ||
670 | DEBUGF 1,"Recording timestamp\n" |
721 | DEBUGF 1,"Recording timestamp\n" |
671 | 722 | ||
672 | mov eax, [esp + 4+4] ; tcp_now |
723 | mov eax, [esp + 4] ; tcp_now |
673 | mov [ebx + TCP_SOCKET.ts_recent_age], eax |
724 | mov [ebx + TCP_SOCKET.ts_recent_age], eax |
674 | mov eax, [ebx + TCP_SOCKET.ts_val] |
725 | mov eax, [ebx + TCP_SOCKET.ts_val] |
Line 916... | Line 967... | ||
916 | 967 | ||
Line 917... | Line 968... | ||
917 | ; If we have a timestamp, update smoothed RTT |
968 | ; If we have a timestamp, update smoothed RTT |
918 | 969 | ||
919 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
970 | test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_TIMESTAMP |
920 | jz .timestamp_not_present |
971 | jz .timestamp_not_present |
921 | mov eax, [esp+4+4] |
972 | mov eax, [esp+4] |
922 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
973 | sub eax, [ebx + TCP_SOCKET.ts_ecr] |
923 | inc eax |
974 | inc eax |
Line 1023... | Line 1074... | ||
1023 | ;---------------------------------------- |
1074 | ;---------------------------------------- |
1024 | ; Wake up process waiting on send buffer |
1075 | ; Wake up process waiting on send buffer |
Line 1025... | Line 1076... | ||
1025 | 1076 | ||
Line 1026... | Line 1077... | ||
1026 | .wakeup: |
1077 | .wakeup: |
1027 | 1078 | ||
1028 | pushf |
1079 | pushf ; Why? |
Line 1029... | Line 1080... | ||
1029 | mov eax, ebx |
1080 | mov eax, ebx |
Line 1489... | Line 1540... | ||
1489 | call TCP_output |
1540 | call TCP_output |
Line 1490... | Line 1541... | ||
1490 | 1541 | ||
1491 | .dumpit: |
1542 | .dumpit: |
Line 1492... | Line -... | ||
1492 | DEBUGF 1,"TCP_input: dumping\n" |
- | |
1493 | 1543 | DEBUGF 1,"TCP_input: dumping\n" |
|
1494 | popf |
1544 | |
Line 1495... | Line 1545... | ||
1495 | call kernel_free |
1545 | call kernel_free |
Line 1536... | Line 1586... | ||
1536 | call SOCKET_free |
1586 | call SOCKET_free |
Line 1537... | Line 1587... | ||
1537 | 1587 | ||
1538 | .drop_no_socket: |
1588 | .drop_no_socket: |
Line 1539... | Line -... | ||
1539 | DEBUGF 1,"TCP_input: Drop (no socket)\n" |
- | |
1540 | 1589 | DEBUGF 1,"TCP_input: Drop (no socket)\n" |
|
1541 | popf |
1590 | |
Line 1542... | Line 1591... | ||
1542 | call kernel_free |
1591 | call kernel_free |