Subversion Repositories Kolibri OS

Rev

Rev 3556 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
9
;;                                                                 ;;
10
;;    Based on the code of 4.4BSD                                  ;;
11
;;                                                                 ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
17
 
18
;-------------------------
19
;
20
; TCP_usrclose
21
;
22
; Move connection to next state, based on process close.
23
;
24
;  IN:  eax = socket ptr
25
;
26
;-------------------------
27
align 4
28
TCP_usrclosed:
29
 
30
        DEBUGF  1,"TCP_usrclosed: %x\n", eax
31
 
32
        push    ebx
33
        mov     ebx, [eax + TCP_SOCKET.t_state]
34
        mov     ebx, dword [.switch + ebx*4]
35
        jmp     ebx
36
 
37
  .switch:
38
 
39
        dd      .close                  ; TCPS_CLOSED
40
        dd      .close                  ; TCPS_LISTEN
41
        dd      .close                  ; TCPS_SYN_SENT
42
        dd      .wait1                  ; TCPS_SYN_RECEIVED
43
        dd      .wait1                  ; TCPS_ESTABLISHED
44
        dd      .last_ack               ; TCPS_CLOSE_WAIT
45
        dd      .ret                    ; TCPS_FIN_WAIT_1
46
        dd      .ret                    ; TCPS_CLOSING
47
        dd      .ret                    ; TCPS_LAST_ACK
48
        dd      .disc                   ; TCPS_FIN_WAIT_2
49
        dd      .disc                   ; TCPS_TIMED_WAIT
50
 
51
 
52
  .close:
53
        mov     [eax + TCP_SOCKET.t_state], TCPS_CLOSED
54
        call    TCP_close
55
        pop     ebx
56
        ret
57
 
58
  .wait1:
59
        mov     [eax + TCP_SOCKET.t_state], TCPS_FIN_WAIT_1
60
        ; TODO: set timer?
61
        pop     ebx
62
        ret
63
 
64
  .last_ack:
65
        mov     [eax + TCP_SOCKET.t_state], TCPS_LAST_ACK
66
        pop     ebx
67
        ret
68
 
69
  .disc:
70
        call    SOCKET_is_disconnected
71
        ; TODO: set timer?
72
  .ret:
73
        pop     ebx
74
        ret
75
 
76
 
77
 
78
 
79
;-------------------------
80
;
81
; TCP_disconnect
82
;
83
;  IN:  eax = socket ptr
84
;  OUT: eax = socket ptr
85
;
86
;-------------------------
87
align 4
88
TCP_disconnect:
89
 
90
        DEBUGF  1,"TCP_disconnect: %x\n", eax
91
 
92
        cmp     [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
93
        jb      TCP_close
94
 
95
 
96
; TODO: implement LINGER ?
97
 
98
        call    SOCKET_is_disconnecting
99
        call    TCP_usrclosed
100
        call    TCP_output
101
 
102
        ret