Subversion Repositories Kolibri OS

Rev

Rev 6915 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2004-2020. 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 algorithms used in 4.4BSD                       ;;
  11. ;;                                                                 ;;
  12. ;;          GNU GENERAL PUBLIC LICENSE                             ;;
  13. ;;             Version 2, June 1991                                ;;
  14. ;;                                                                 ;;
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16.  
  17. $Revision: 7974 $
  18.  
  19. TCP_BIT_NEEDOUTPUT      = 1 shl 0
  20. TCP_BIT_TIMESTAMP       = 1 shl 1
  21. TCP_BIT_DROPSOCKET      = 1 shl 2
  22. TCP_BIT_FIN_IS_ACKED    = 1 shl 3
  23.  
  24. ;-----------------------------------------------------------------;
  25. ;                                                                 ;
  26. ; TCP_input: Add a segment to the incoming TCP queue.             ;
  27. ;                                                                 ;
  28. ;  IN:  [esp] = ptr to buffer                                     ;
  29. ;       ebx = ptr to device struct                                ;
  30. ;       ecx = TCP segment size                                    ;
  31. ;       edx = ptr to IPv4 header                                  ;
  32. ;       esi = ptr to TCP segment                                  ;
  33. ;       edi = interface number*4                                  ;
  34. ;                                                                 ;
  35. ;  OUT: /                                                         ;
  36. ;                                                                 ;
  37. ;-----------------------------------------------------------------;
  38. align 4
  39. tcp_input:
  40.  
  41. ; record the current time
  42.         push    [timer_ticks]           ; in 1/100 seconds
  43.         push    ebx ecx esi edx         ; mind the order (see TCP_queue_entry struct)
  44.         mov     esi, esp
  45.  
  46.         push    edi
  47.         add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
  48.         pop     edi
  49.         add     esp, sizeof.TCP_queue_entry
  50.  
  51.         inc     [TCP_segments_rx + edi]
  52.  
  53.         xor     edx, edx
  54.         mov     eax, [TCP_input_event]
  55.         mov     ebx, [eax + EVENT.id]
  56.         xor     esi, esi
  57.         call    raise_event
  58.  
  59.         ret
  60.  
  61.   .fail:
  62.         pop     edi
  63.         DEBUGF  DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
  64.  
  65.         call    net_ptr_to_num4
  66.         inc     [TCP_segments_missed + edi]
  67.  
  68.         add     esp, sizeof.TCP_queue_entry - 4
  69.         call    net_buff_free
  70.         ret
  71.  
  72.  
  73. ;-----------------------------------------------------------------;
  74. ;                                                                 ;
  75. ; TCP_process_input: Process segments from the incoming TCP queue.;
  76. ;                                                                 ;
  77. ;  IN:  /                                                         ;
  78. ;  OUT: /                                                         ;
  79. ;                                                                 ;
  80. ;-----------------------------------------------------------------;
  81. align 4