Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  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.         pop     ebx
  61.         ret
  62.  
  63.   .last_ack:
  64.         mov     [eax + TCP_SOCKET.t_state], TCPS_LAST_ACK
  65.         pop     ebx
  66.         ret
  67.  
  68.   .disc:
  69.         call    SOCKET_is_disconnected
  70.   .ret:
  71.         pop     ebx
  72.         ret
  73.  
  74.  
  75.  
  76.  
  77. ;-------------------------
  78. ;
  79. ; TCP_disconnect
  80. ;
  81. ;  IN:  eax = socket ptr
  82. ;  OUT: eax = socket ptr
  83. ;
  84. ;-------------------------
  85. align 4
  86. TCP_disconnect:
  87.  
  88.         DEBUGF  1,"TCP_disconnect: %x\n", eax
  89.  
  90.         cmp     [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
  91.         jb      TCP_close
  92.  
  93.  
  94. ; TODO: implement LINGER ?
  95.  
  96.         call    SOCKET_is_disconnecting
  97.         call    TCP_usrclosed
  98.         call    TCP_output
  99.  
  100.         ret