Rev 7680 | Rev 8026 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7680 | Rev 7974 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2020. 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 13... | Line 13... | ||
13 | ;; GNU GENERAL PUBLIC LICENSE ;; |
13 | ;; GNU GENERAL PUBLIC LICENSE ;; |
14 | ;; Version 2, June 1991 ;; |
14 | ;; Version 2, June 1991 ;; |
15 | ;; ;; |
15 | ;; ;; |
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 17... | Line 17... | ||
17 | 17 | ||
Line 18... | Line 18... | ||
18 | $Revision: 7680 $ |
18 | $Revision: 7974 $ |
Line 19... | Line 19... | ||
19 | 19 | ||
20 | struct SOCKET |
20 | struct SOCKET |
Line 290... | Line 290... | ||
290 | ; ; |
290 | ; ; |
291 | ;-----------------------------------------------------------------; |
291 | ;-----------------------------------------------------------------; |
292 | align 4 |
292 | align 4 |
293 | socket_open: |
293 | socket_open: |
Line 294... | Line 294... | ||
294 | 294 | ||
Line 295... | Line 295... | ||
295 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi |
295 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x\n", ecx, edx, esi |
296 | 296 | ||
297 | push ecx edx esi |
297 | push ecx edx esi |
298 | call socket_alloc |
298 | call socket_alloc |
299 | pop esi edx ecx |
299 | pop esi edx ecx |
Line 300... | Line 300... | ||
300 | test eax, eax |
300 | test eax, eax |
301 | jz .nobuffs |
301 | jz .nobuffs |
Line 302... | Line 302... | ||
302 | 302 | ||
303 | mov [esp+32], edi ; return socketnumber |
303 | mov [esp+32], edi ; return socketnumber |
304 | DEBUGF DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi |
304 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: socknum=%u\n", edi |
305 | 305 | ||
Line 372... | Line 372... | ||
372 | 372 | ||
373 | align 4 |
373 | align 4 |
374 | .tcp: |
374 | .tcp: |
375 | mov [eax + SOCKET.Protocol], IP_PROTO_TCP |
375 | mov [eax + SOCKET.Protocol], IP_PROTO_TCP |
376 | mov [eax + SOCKET.snd_proc], socket_send_tcp |
376 | mov [eax + SOCKET.snd_proc], socket_send_tcp |
377 | mov [eax + SOCKET.rcv_proc], socket_receive_stream |
377 | mov [eax + SOCKET.rcv_proc], socket_receive_tcp |
Line 378... | Line 378... | ||
378 | mov [eax + SOCKET.connect_proc], tcp_connect |
378 | mov [eax + SOCKET.connect_proc], tcp_connect |
379 | 379 | ||
Line 894... | Line 894... | ||
894 | mov esi, [eax + SOCKET_QUEUE_LOCATION + queue.r_ptr] |
894 | mov esi, [eax + SOCKET_QUEUE_LOCATION + queue.r_ptr] |
895 | mov ecx, [esi + socket_queue_entry.data_size] |
895 | mov ecx, [esi + socket_queue_entry.data_size] |
896 | @@: |
896 | @@: |
897 | ret |
897 | ret |
Line -... | Line 898... | ||
- | 898 | ||
- | 899 | align 4 |
|
- | 900 | socket_receive_tcp: |
|
- | 901 | ||
- | 902 | call socket_receive_stream |
|
- | 903 | ||
- | 904 | test ecx, ecx |
|
- | 905 | jz @f |
|
- | 906 | push eax ebx ecx |
|
- | 907 | call tcp_output |
|
- | 908 | pop ecx ebx eax |
|
- | 909 | @@: |
|
- | 910 | ||
- | 911 | ret |
|
Line 898... | Line 912... | ||
898 | 912 | ||
899 | 913 | ||
Line 900... | Line 914... | ||
900 | align 4 |
914 | align 4 |
Line 1827... | Line 1841... | ||
1827 | 1841 | ||
Line 1828... | Line 1842... | ||
1828 | push eax |
1842 | push eax |
1829 | 1843 | ||
1830 | pushf |
- | |
1831 | cli |
1844 | pushf |
1832 | 1845 | cli |
|
Line 1833... | Line 1846... | ||
1833 | ; Set the 'socket is blocked' flag |
1846 | ; Set the 'socket is blocked' flag |
1834 | or [eax + SOCKET.state], SS_BLOCKED |
1847 | or [eax + SOCKET.state], SS_BLOCKED |
1835 | 1848 | ||
1836 | ; Suspend the thread |
1849 | ; Suspend the thread |
Line 1837... | Line 1850... | ||
1837 | push edx |
1850 | push edx |
1838 | mov edx, [TASK_BASE] |
1851 | mov edx, [TASK_BASE] |
1839 | mov [edx + TASKDATA.state], 1 ; Suspended |
1852 | mov [edx + TASKDATA.state], TSTATE_RUN_SUSPENDED |
1840 | 1853 | ||
Line 1880... | Line 1893... | ||
1880 | mov esi, TASK_DATA |
1893 | mov esi, TASK_DATA |
1881 | .next: |
1894 | .next: |
1882 | cmp [esi + TASKDATA.pid], ebx |
1895 | cmp [esi + TASKDATA.pid], ebx |
1883 | je .found |
1896 | je .found |
1884 | inc ecx |
1897 | inc ecx |
1885 | add esi, 0x20 |
1898 | add esi, sizeof.TASKDATA |
1886 | cmp ecx, [TASK_COUNT] |
1899 | cmp ecx, [TASK_COUNT] |
1887 | jbe .next |
1900 | jbe .next |
Line 1888... | Line 1901... | ||
1888 | 1901 | ||
1889 | .error2: |
1902 | .error2: |
Line 1912... | Line 1925... | ||
1912 | 1925 | ||
1913 | .un_block: |
1926 | .un_block: |
1914 | ; Socket and thread exists and socket is of blocking type |
1927 | ; Socket and thread exists and socket is of blocking type |
1915 | ; We'll try to unblock it. |
1928 | ; We'll try to unblock it. |
1916 | and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag |
1929 | and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag |
Line 1917... | Line 1930... | ||
1917 | mov [esi + TASKDATA.state], 0 ; Run the thread |
1930 | mov [esi + TASKDATA.state], TSTATE_RUNNING ; Run the thread |
1918 | 1931 | ||
1919 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" |
1932 | DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" |