Subversion Repositories Kolibri OS

Rev

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

Rev 3673 Rev 3674
Line 15... Line 15...
15
;;                                                                 ;;
15
;;                                                                 ;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 17... Line 17...
17
 
17
 
Line 18... Line -...
18
$Revision: 3514 $
-
 
19
 
-
 
20
ENOBUFS         = 1
-
 
21
EOPNOTSUPP      = 4
-
 
22
EWOULDBLOCK     = 6
-
 
23
ENOTCONN        = 9
-
 
24
EALREADY        = 10
-
 
25
EINVAL          = 11
-
 
26
EMSGSIZE        = 12
-
 
27
ENOMEM          = 18
-
 
28
EADDRINUSE      = 20
-
 
29
 
18
$Revision: 3514 $
Line 30... Line 19...
30
 
19
 
31
struct  SOCKET
20
struct  SOCKET
32
 
21
 
Line 308... Line 297...
308
        mov     [esp+32], edi                   ; return socketnumber
297
        mov     [esp+32], edi                   ; return socketnumber
309
        DEBUGF  DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi
298
        DEBUGF  DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi
Line 310... Line 299...
310
 
299
 
311
;        push    edx
300
;        push    edx
312
;        and     edx, SO_NONBLOCK
301
;        and     edx, SO_NONBLOCK
313
        or      [eax + SOCKET.options], SO_NONBLOCK ;edx
302
        or      [eax + SOCKET.options], SO_NONBLOCK ;edx        ; HACK: make all sockets non-blocking untill API and applications are fixed
314
;        pop     edx
303
;        pop     edx
Line 315... Line 304...
315
;        and     edx, not SO_NONBLOCK
304
;        and     edx, not SO_NONBLOCK
316
 
305
 
Line 592... Line 581...
592
        push    [TCP_sequence_num]
581
        push    [TCP_sequence_num]
593
        add     [TCP_sequence_num], 6400
582
        add     [TCP_sequence_num], 6400
594
        pop     [eax + TCP_SOCKET.ISS]
583
        pop     [eax + TCP_SOCKET.ISS]
595
        mov     [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
584
        mov     [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
Line 596... Line -...
596
 
-
 
597
 
585
 
598
        TCP_sendseqinit eax
-
 
599
 
586
        TCP_sendseqinit eax
Line 600... Line 587...
600
;        mov     [ebx + TCP_SOCKET.timer_retransmission],   ;; todo: create macro to set retransmission timer
587
;        mov     [ebx + TCP_SOCKET.timer_retransmission],   ;; todo: create macro to set retransmission timer
601
 
-
 
602
        mov     ebx, eax
588
 
603
 
589
        mov     ebx, eax
Line 604... Line 590...
604
        lea     eax, [ebx + STREAM_SOCKET.snd]
590
        lea     eax, [ebx + STREAM_SOCKET.snd]
605
        call    SOCKET_ring_create              ; TODO: check if memory was available or not
591
        call    SOCKET_ring_create              ; TODO: check if memory was available or not
Line 610... Line 596...
610
        pusha
596
        pusha
611
        lea     ecx, [ebx + SOCKET.mutex]
597
        lea     ecx, [ebx + SOCKET.mutex]
612
        call    mutex_unlock
598
        call    mutex_unlock
613
        popa
599
        popa
Line -... Line 600...
-
 
600
 
614
 
601
        push    ebx
615
        mov     eax, ebx
602
        mov     eax, ebx
-
 
603
        call    TCP_output
-
 
604
        pop     eax
-
 
605
 
-
 
606
  .block:
-
 
607
        test    [eax + SOCKET.options], SO_NONBLOCK
-
 
608
        jz      .loop
-
 
609
 
-
 
610
        mov     dword[esp+20], EWOULDBLOCK
-
 
611
        mov     dword[esp+32], 0                 ; Should be -1? or not?
-
 
612
        ret
-
 
613
 
-
 
614
  .loop:
-
 
615
        cmp     [eax + TCP_SOCKET.t_state], TCPS_CLOSED
-
 
616
        je      .fail
-
 
617
        cmp     [eax + TCP_SOCKET.t_state], TCPS_SYN_SENT
Line -... Line 618...
-
 
618
        jne     .syn_received
-
 
619
 
-
 
620
        call    SOCKET_block
-
 
621
        jmp     .loop
616
        call    TCP_output
622
 
-
 
623
  .fail:
-
 
624
        mov     eax, [eax + SOCKET.errorcode]
-
 
625
        mov     [esp+20], eax
Line -... Line 626...
-
 
626
        mov     dword[esp+32], -1
617
 
627
        ret
618
;;; TODO: wait for successfull connection if blocking socket
628
 
Line -... Line 629...
-
 
629
  .syn_received:
619
 
630
        mov     dword[esp+32], 0
620
        mov     dword[esp+32], 0
631
        ret
621
        ret
632
 
622
 
633
 
623
align 4
634
align 4
Line 1813... Line 1824...
1813
; SOCKET_block
1824
; SOCKET_block
1814
;
1825
;
1815
; Suspends the thread attached to a socket
1826
; Suspends the thread attached to a socket
1816
;
1827
;
1817
;  IN:  eax = socket ptr
1828
;  IN:  eax = socket ptr
1818
;  OUT: /
1829
;  OUT: eax = unchanged
1819
;
1830
;
1820
;-----------------------------------------------------------------
1831
;-----------------------------------------------------------------
1821
align 4
1832
align 4
1822
SOCKET_block:
1833
SOCKET_block:
Line 1823... Line 1834...
1823
 
1834
 
Line 1824... Line 1835...
1824
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
1835
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
-
 
1836
 
1825
 
1837
        pushf
Line 1826... Line 1838...
1826
        pushf
1838
        push    eax
1827
        cli
1839
        cli
Line 1839... Line 1851...
1839
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx
1851
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx
1840
        mov     [eax + SOCKET.TID], edx
1852
        mov     [eax + SOCKET.TID], edx
1841
        pop     edx
1853
        pop     edx
Line 1842... Line 1854...
1842
 
1854
 
-
 
1855
        call    change_task
1843
        call    change_task
1856
        pop     eax
Line 1844... Line 1857...
1844
        popf
1857
        popf
Line 1845... Line 1858...
1845
 
1858
 
Line 1853... Line 1866...
1853
; SOCKET_notify
1866
; SOCKET_notify
1854
;
1867
;
1855
; notify's the owner of a socket that something happened
1868
; notify's the owner of a socket that something happened
1856
;
1869
;
1857
;  IN:  eax = socket ptr
1870
;  IN:  eax = socket ptr
1858
;  OUT: /
1871
;  OUT: eax = unchanged
1859
;
1872
;
1860
;-----------------------------------------------------------------
1873
;-----------------------------------------------------------------
1861
align 4
1874
align 4
1862
SOCKET_notify:
1875
SOCKET_notify:
Line 2432... Line 2445...
2432
align 4
2445
align 4
2433
SOCKET_is_connected:
2446
SOCKET_is_connected:
Line 2434... Line 2447...
2434
 
2447
 
Line 2435... Line 2448...
2435
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_connected: %x\n", eax
2448
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_connected: %x\n", eax
2436
 
2449
 
Line 2437... Line 2450...
2437
        and     [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISDISCONNECTING + SS_ISCONFIRMING)
2450
        and     [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISDISCONNECTING + SS_ISCONFIRMING)
Line 2454... Line 2467...
2454
align 4
2467
align 4
2455
SOCKET_is_disconnecting:
2468
SOCKET_is_disconnecting:
Line 2456... Line 2469...
2456
 
2469
 
Line 2457... Line 2470...
2457
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnecting: %x\n", eax
2470
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnecting: %x\n", eax
2458
 
2471
 
Line 2459... Line 2472...
2459
        and     [eax + SOCKET.options], not (SS_ISCONNECTING)
2472
        and     [eax + SOCKET.state], not (SS_ISCONNECTING)
Line 2475... Line 2488...
2475
align 4
2488
align 4
2476
SOCKET_is_disconnected:
2489
SOCKET_is_disconnected:
Line 2477... Line 2490...
2477
 
2490
 
Line 2478... Line 2491...
2478
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax
2491
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax
2479
 
2492
 
Line 2480... Line 2493...
2480
        and     [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING)
2493
        and     [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING)
2481
        or      [eax + SOCKET.options], SS_CANTRCVMORE + SS_CANTSENDMORE
2494
        or      [eax + SOCKET.state], SS_CANTRCVMORE + SS_CANTSENDMORE
Line 2482... Line 2495...
2482
 
2495
 
Line 2508... Line 2521...
2508
align 4
2521
align 4
2509
SOCKET_cant_recv_more:
2522
SOCKET_cant_recv_more:
Line 2510... Line 2523...
2510
 
2523
 
Line 2511... Line 2524...
2511
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_cant_recv_more: %x\n", eax
2524
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_cant_recv_more: %x\n", eax
Line 2512... Line 2525...
2512
 
2525
 
Line 2513... Line 2526...
2513
        or      [eax + SOCKET.options], SS_CANTRCVMORE
2526
        or      [eax + SOCKET.state], SS_CANTRCVMORE
Line 2530... Line 2543...
2530
align 4
2543
align 4
2531
SOCKET_cant_send_more:
2544
SOCKET_cant_send_more:
Line 2532... Line 2545...
2532
 
2545
 
Line 2533... Line 2546...
2533
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax
2546
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax
2534
 
2547
 
Line 2535... Line 2548...
2535
        or      [eax + SOCKET.options], SS_CANTSENDMORE
2548
        or      [eax + SOCKET.state], SS_CANTSENDMORE
Line 2536... Line 2549...
2536
        mov     [eax + SOCKET.snd_proc], .notconn
2549
        mov     [eax + SOCKET.snd_proc], .notconn