Subversion Repositories Kolibri OS

Rev

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

Rev 4265 Rev 4423
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: 4265 $
18
$Revision: 4423 $
Line 19... Line 19...
19
 
19
 
20
struct  SOCKET
20
struct  SOCKET
Line 26... Line 26...
26
        mutex                   MUTEX
26
        mutex                   MUTEX
Line 27... Line 27...
27
 
27
 
28
        PID                     dd ? ; process ID
28
        PID                     dd ? ; process ID
29
        TID                     dd ? ; thread ID
29
        TID                     dd ? ; thread ID
30
        Domain                  dd ? ; INET/LOCAL/..
30
        Domain                  dd ? ; INET/LOCAL/..
31
        Type                    dd ? ; RAW/STREAM/DGRAP
31
        Type                    dd ? ; RAW/STREAM/DGRAM
32
        Protocol                dd ? ; ICMP/IPv4/ARP/TCP/UDP
32
        Protocol                dd ? ; ICMP/IPv4/ARP/TCP/UDP
33
        errorcode               dd ?
33
        errorcode               dd ?
Line 34... Line 34...
34
        device                  dd ? ; driver pointer, socket pointer if it's an LOCAL socket
34
        device                  dd ? ; driver pointer, socket pointer if it's an LOCAL socket
Line 90... Line 90...
90
 
90
 
91
; retransmit variables
91
; retransmit variables
Line 92... Line 92...
92
        SND_MAX                 dd ?
92
        SND_MAX                 dd ?
93
 
93
 
94
; congestion control
94
; congestion control
Line 95... Line 95...
95
        SND_CWND                dd ?
95
        SND_CWND                dd ?    ; congestion window
96
        SND_SSTHRESH            dd ?
96
        SND_SSTHRESH            dd ?    ; slow start threshold
97
 
97
 
98
;----------------------
98
;----------------------
Line 139... Line 139...
139
        ts_ecr                  dd ? ; timestamp echo reply
139
        ts_ecr                  dd ? ; timestamp echo reply
140
        ts_val                  dd ?
140
        ts_val                  dd ?
Line 141... Line 141...
141
 
141
 
Line 142... Line -...
142
        seg_next                dd ? ; re-assembly queue
-
 
143
 
-
 
144
        temp_bits               db ?
-
 
145
                                rb 3 ; align
-
 
146
 
142
        seg_next                dd ? ; re-assembly queue
Line 147... Line 143...
147
 
143
 
Line 148... Line 144...
148
ends
144
ends
Line 713... Line 709...
713
  .free:
709
  .free:
714
        call    SOCKET_free
710
        call    SOCKET_free
715
        ret
711
        ret
Line 716... Line 712...
716
 
712
 
717
  .tcp:
-
 
718
        cmp     [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED    ; state must be LISTEN, SYN_SENT or CLOSED
-
 
Line 719... Line 713...
719
        jb      .free
713
  .tcp:
-
 
714
 
720
 
715
        call    TCP_usrclosed
721
        call    TCP_usrclosed
716
 
-
 
717
        test    eax, eax
-
 
718
        jz      @f
Line 722... Line 719...
722
        call    TCP_output      ;;;; Fixme: is this nescessary??
719
        call    TCP_output                                      ; If connection is not closed yet, send the FIN
Line 723... Line 720...
723
        call    SOCKET_free
720
  @@:
Line 1560... Line 1557...
1560
        rep movsd
1557
        rep movsd
1561
  .nd:
1558
  .nd:
1562
        pop     ecx
1559
        pop     ecx
Line 1563... Line 1560...
1563
 
1560
 
1564
; unlock mutex
1561
; unlock mutex
1565
        push    eax ecx
1562
        pusha
1566
        lea     ecx, [eax + RING_BUFFER.mutex]
1563
        lea     ecx, [eax + RING_BUFFER.mutex]
1567
        call    mutex_unlock                                    ; TODO: check what registers this function actually destroys
1564
        call    mutex_unlock                                    ; TODO: check what registers this function actually destroys
Line 1568... Line 1565...
1568
        pop     ecx eax
1565
        popa
Line 1569... Line 1566...
1569
 
1566
 
1570
        ret
1567
        ret
Line 2083... Line 2080...
2083
 
2080
 
2084
  .next_socket:
2081
  .next_socket:
2085
        mov     eax, [eax + SOCKET.NextPtr]
2082
        mov     eax, [eax + SOCKET.NextPtr]
2086
        or      eax, eax
2083
        or      eax, eax
2087
        jz      .error
-
 
2088
                diff16 "tetten", 0, $
2084
        jz      .error
2089
        cmp     [eax + SOCKET.Number], ecx
2085
        cmp     [eax + SOCKET.Number], ecx
Line 2090... Line 2086...
2090
        jne     .next_socket
2086
        jne     .next_socket
Line 2203... Line 2199...
2203
;
2199
;
2204
; SOCKET_process_end
2200
; SOCKET_process_end
2205
;
2201
;
2206
; Kernel calls this function when a certain process ends
2202
; Kernel calls this function when a certain process ends
2207
; This function will check if the process had any open sockets
2203
; This function will check if the process had any open sockets
2208
; And update them accordingly
2204
; And update them accordingly (clean up)
2209
;
2205
;
2210
; IN:  edx = pid
2206
; IN:  edx = pid
2211
; OUT: /
2207
; OUT: /
2212
;
2208
;
2213
;------------------------------------------------------
2209
;------------------------------------------------------
Line 2249... Line 2245...
2249
        jne     .free
2245
        jne     .free
Line 2250... Line 2246...
2250
 
2246
 
2251
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
2247
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
Line 2252... Line 2248...
2252
        jne     .free
2248
        jne     .free
2253
 
2249
 
Line 2254... Line 2250...
2254
        call    TCP_close
2250
        call    TCP_disconnect
2255
        jmp     .closed
2251
        jmp     .closed
Line 2354... Line 2350...
2354
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax
2350
        DEBUGF  DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax
Line 2355... Line 2351...
2355
 
2351
 
2356
        and     [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING)
2352
        and     [eax + SOCKET.state], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING)
Line 2357... Line -...
2357
        or      [eax + SOCKET.state], SS_CANTRCVMORE + SS_CANTSENDMORE
-
 
2358
 
-
 
2359
        cmp     [eax + SOCKET.Protocol], IP_PROTO_TCP
-
 
2360
        je      .tcp
-
 
2361
 
-
 
Line 2362... Line 2353...
2362
        cmp     [eax + SOCKET.Protocol], IP_PROTO_UDP
2353
        or      [eax + SOCKET.state], SS_CANTRCVMORE + SS_CANTSENDMORE
Line 2363... Line -...
2363
        je      .udp
-
 
2364
 
-
 
2365
        jmp     SOCKET_notify
-
 
2366
 
-
 
2367
  .tcp:
-
 
2368
  .udp:
-
 
Line 2369... Line 2354...
2369
        mov     [eax + UDP_SOCKET.LocalPort], 0         ; UDP and TCP structs store localport at the same offset
2354
 
2370
        mov     [eax + UDP_SOCKET.RemotePort], 0
2355
 
2371
 
2356
        jmp     SOCKET_notify