Subversion Repositories Kolibri OS

Rev

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

Rev 5201 Rev 5565
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2015. 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: 5201 $
18
$Revision: 5565 $
Line 19... Line 19...
19
 
19
 
20
struct  SOCKET
20
struct  SOCKET
Line 96... Line 96...
96
        SND_SSTHRESH            dd ?    ; slow start threshold
96
        SND_SSTHRESH            dd ?    ; slow start threshold
Line 97... Line 97...
97
 
97
 
98
;----------------------
98
;----------------------
99
; Transmit timing stuff
99
; Transmit timing stuff
100
        t_idle                  dd ?
100
        t_idle                  dd ?
101
        t_rtt                   dd ?
101
        t_rtt                   dd ?    ; round trip time
102
        t_rtseq                 dd ?
102
        t_rtseq                 dd ?
103
        t_srtt                  dd ?
103
        t_srtt                  dd ?    ; smoothed round trip time
104
        t_rttvar                dd ?
104
        t_rttvar                dd ?
105
        t_rttmin                dd ?
105
        t_rttmin                dd ?
Line 106... Line 106...
106
        max_sndwnd              dd ?
106
        max_sndwnd              dd ?
Line 177... Line 177...
177
ends
177
ends
Line 178... Line 178...
178
 
178
 
Line 179... Line 179...
179
struct  socket_queue_entry
179
struct  socket_queue_entry
180
 
-
 
181
        data_ptr                dd ?
180
 
-
 
181
        data_ptr                dd ?
Line 182... Line 182...
182
        buf_ptr                 dd ?
182
        data_size               dd ?
Line 183... Line 183...
183
        data_size               dd ?
183
        buf_ptr                 dd ?
Line 752... Line 752...
752
        push    edi
752
        push    edi
753
        call    [eax + SOCKET.rcv_proc]
753
        call    [eax + SOCKET.rcv_proc]
754
        pop     edi
754
        pop     edi
Line 755... Line 755...
755
 
755
 
756
        test    [eax + SOCKET.state], SS_CANTRCVMORE
756
        test    [eax + SOCKET.state], SS_CANTRCVMORE
Line 757... Line 757...
757
        jnz     .return
757
        jnz     .last_data
758
 
758
 
Line 759... Line 759...
759
        cmp     ebx, EWOULDBLOCK
759
        cmp     ebx, EWOULDBLOCK
Line 777... Line 777...
777
  .return:
777
  .return:
778
        mov     [esp+20], ebx
778
        mov     [esp+20], ebx
779
        mov     [esp+32], ecx
779
        mov     [esp+32], ecx
780
        ret
780
        ret
Line -... Line 781...
-
 
781
 
-
 
782
  .last_data:
-
 
783
        test    ecx, ecx
-
 
784
        jz      .return
-
 
785
        call    SOCKET_notify
Line 781... Line 786...
781
 
786
        jmp     .return
Line 815... Line 820...
815
        test    ecx, ecx
820
        test    ecx, ecx
816
        jz      .nd
821
        jz      .nd
817
        rep movsd
822
        rep movsd
818
  .nd:
823
  .nd:
Line 819... Line 824...
819
 
824
 
820
        call    NET_packet_free
825
        call    NET_BUFF_free
821
        pop     ecx eax                                         ; return number of bytes copied to application
826
        pop     ecx eax                                         ; return number of bytes copied to application
822
        xor     ebx, ebx
827
        xor     ebx, ebx
Line 823... Line 828...
823
        ret
828
        ret
Line 872... Line 877...
872
        add     eax, STREAM_SOCKET.rcv
877
        add     eax, STREAM_SOCKET.rcv
873
        call    SOCKET_ring_read                                ; copy data from kernel buffer to application buffer
878
        call    SOCKET_ring_read                                ; copy data from kernel buffer to application buffer
874
        call    SOCKET_ring_free                                ; free read memory
879
        call    SOCKET_ring_free                                ; free read memory
875
        pop     eax
880
        pop     eax
Line -... Line 881...
-
 
881
 
-
 
882
        cmp     [eax + STREAM_SOCKET.rcv + RING_BUFFER.size], 0
-
 
883
        jne     .more_data
-
 
884
        xor     ebx, ebx                                        ; errorcode = 0 (no error)
-
 
885
        ret
-
 
886
 
-
 
887
  .more_data:
876
 
888
        call    SOCKET_notify                                   ; Queue another network event
877
        xor     ebx, ebx                                        ; errorcode = 0 (no error)
889
        xor     ebx, ebx                                        ; errorcode = 0 (no error)
Line 878... Line 890...
878
        ret
890
        ret
879
 
891
 
Line 1427... Line 1439...
1427
;
1439
;
1428
;  IN:  eax = socket ptr
1440
;  IN:  eax = socket ptr
1429
;       ecx = data size
1441
;       ecx = data size
1430
;       esi = ptr to data
1442
;       esi = ptr to data
1431
;       [esp] = ptr to buf
1443
;       [esp] = ptr to buf
1432
;       [esp + 4] = buf size
-
 
1433
;
1444
;
1434
;  OUT: /
1445
;  OUT: /
1435
;
1446
;
1436
;-----------------------------------------------------------------
1447
;-----------------------------------------------------------------
1437
align 4
1448
align 4
1438
SOCKET_input:
1449
SOCKET_input:
Line 1439... Line 1450...
1439
 
1450
 
Line 1440... Line 1451...
1440
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket=%x, data=%x size=%u\n", eax, esi, ecx
1451
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket=%x, data=%x size=%u\n", eax, esi, ecx
1441
 
1452
 
1442
        mov     [esp+4], ecx
1453
        push    ecx
Line 1443... Line 1454...
1443
        push    esi
1454
        push    esi
Line 1461... Line 1472...
1461
        pusha
1472
        pusha
1462
        lea     ecx, [eax + SOCKET.mutex]
1473
        lea     ecx, [eax + SOCKET.mutex]
1463
        call    mutex_unlock
1474
        call    mutex_unlock
1464
        popa
1475
        popa
Line 1465... Line 1476...
1465
 
1476
 
1466
        call    NET_packet_free
-
 
1467
        add     esp, 8
-
 
1468
 
1477
        call    NET_BUFF_free
Line 1469... Line 1478...
1469
        ret
1478
        ret
1470
 
1479
 
1471
 
1480
 
1472
;--------------------------
-
 
1473
;
1481
;--------------------------
1474
; IN: eax = ptr to ring struct (just a buffer of the right size)
1482
;
1475
; OUT: eax = unchanged / 0 on error
1483
; eax = ptr to ring struct (just a buffer of the right size)
Line 1476... Line 1484...
1476
;
1484
;
1477
align 4
1485
align 4
Line 1478... Line 1486...
1478
SOCKET_ring_create:
1486
SOCKET_ring_create:
1479
 
1487
 
1480
        push    esi
1488
        push    esi
1481
        mov     esi, eax
1489
        mov     esi, eax
1482
 
1490
 
Line 1483... Line 1491...
1483
        push    edx
1491
        push    edx
Line 1960... Line 1968...
1960
 
1968
 
1961
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
1969
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
Line 1962... Line 1970...
1962
        jnz     .no_tcp
1970
        jnz     .no_tcp
1963
 
-
 
1964
        mov     ebx, eax
-
 
1965
        cmp     [ebx + STREAM_SOCKET.rcv.start_ptr], 0
1971
 
1966
        je      @f
-
 
1967
        stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr]
-
 
1968
  @@:
-
 
1969
        cmp     [ebx + STREAM_SOCKET.snd.start_ptr], 0
1972
        mov     ebx, eax
1970
        je      @f
-
 
1971
        stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
1973
        stdcall kernel_free, [ebx + STREAM_SOCKET.rcv.start_ptr]
1972
  @@:
1974
        stdcall kernel_free, [ebx + STREAM_SOCKET.snd.start_ptr]
Line 1973... Line 1975...
1973
        mov     eax, ebx
1975
        mov     eax, ebx
1974
  .no_tcp:
1976
  .no_tcp: