Subversion Repositories Kolibri OS

Rev

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

Rev 129 Rev 384
Line 12... Line 12...
12
;;  v0.6 : Added reset handling in the established state           ;;
12
;;  v0.6 : Added reset handling in the established state           ;;
13
;;         Added a timer per socket to allow delays when rx window ;;
13
;;         Added a timer per socket to allow delays when rx window ;;
14
;;         gets below 1KB                                          ;;
14
;;         gets below 1KB                                          ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 16...
-
 
16
 
-
 
17
; TCP TCB states
-
 
18
TCB_LISTEN         equ        1
-
 
19
TCB_SYN_SENT       equ        2
-
 
20
TCB_SYN_RECEIVED   equ        3
-
 
21
TCB_ESTABLISHED    equ        4
-
 
22
TCB_FIN_WAIT_1     equ        5
-
 
23
TCB_FIN_WAIT_2     equ        6
-
 
24
TCB_CLOSE_WAIT     equ        7
-
 
25
TCB_CLOSING        equ        8
-
 
26
TCB_LAST_ACK       equ        9
-
 
27
TCB_TIME_WAIT      equ        10
-
 
28
TCB_CLOSED         equ        11
-
 
29
 
-
 
30
TWOMSL              equ     10      ; # of secs to wait before closing socket
-
 
31
 
-
 
32
TCP_RETRIES         equ         5               ; Number of times to resend a packet
Line 16... Line 33...
16
 
33
TCP_TIMEOUT         equ         10              ; resend if not replied to in x hs
17
 
34
 
18
;*******************************************************************
35
;*******************************************************************
19
;   Interface
36
;   Interface
Line 25... Line 42...
25
;       tcp_tcb_handler     1s timer, to erase tcb's in TIME_WAIT state
42
;       tcp_tcb_handler     1s timer, to erase tcb's in TIME_WAIT state
26
;
43
;
27
;*******************************************************************
44
;*******************************************************************
Line -... Line 45...
-
 
45
 
-
 
46
 
-
 
47
;   TCP Payload ( Data field in IP datagram )
-
 
48
;
-
 
49
;    0                   1                   2                   3
-
 
50
;    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-
 
51
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
52
;20 |          Source Port          |       Destination Port        |
-
 
53
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
54
;24 |                        Sequence Number                        |
-
 
55
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
56
;28 |                    Acknowledgment Number                      |
-
 
57
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
58
;32 |  Data |           |U|A|P|R|S|F|                               |
-
 
59
;   | Offset| Reserved  |R|C|S|S|Y|I|            Window             |
-
 
60
;   |       |           |G|K|H|T|N|N|                               |
-
 
61
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
62
;36 |           Checksum            |         Urgent Pointer        |
-
 
63
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
64
;40 |                    Options                    |    Padding    |
-
 
65
;   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
 
66
;   |                             data
-
 
67
 
-
 
68
 
-
 
69
struc TCP_PACKET
-
 
70
{  .SourcePort       dw  ?  ;+00
-
 
71
   .DestinationPort  dw  ?  ;+02
-
 
72
   .SequenceNumber   dd  ?  ;+04
-
 
73
   .AckNumber        dd  ?  ;+08
-
 
74
   .DataOffset       db  ?  ;+12 - DataOffset[0-3 bits] and Reserved[4-7]
-
 
75
   .Flags            db  ?  ;+13 - Reserved[0-1 bits]|URG|ACK|PSH|RST|SYN|FIN
-
 
76
   .Window           dw  ?  ;+14
-
 
77
   .Checksum         dw  ?  ;+16
-
 
78
   .UrgentPointer    dw  ?  ;+18
-
 
79
   .Options          rb  3  ;+20
-
 
80
   .Padding          db  ?  ;+23
-
 
81
   .Data             db  ?  ;+24
-
 
82
}
-
 
83
 
-
 
84
virtual at 0
-
 
85
  TCP_PACKET TCP_PACKET
-
 
86
end virtual
Line 28... Line 87...
28
 
87
 
29
 
88
 
30
 
89
 
31
;***************************************************************************
90
;***************************************************************************
Line 492... Line 551...
492
 
551
 
493
    mov     [edx + 20 + 16], ah
552
    mov     [edx + 20 + 16], ah
Line 494... Line 553...
494
    mov     [edx + 20 + 17], al
553
    mov     [edx + 20 + 17], al
495
 
-
 
496
    ; Fill in the IP header checksum
-
 
497
    mov     eax, edx
554
 
498
    mov     [checkAdd1], eax
-
 
499
    mov     [checkSize1], word 20
555
    ; Fill in the IP header checksum
Line 500... Line -...
500
    mov     [checkAdd2], dword 0
-
 
501
    mov     [checkSize2], word 0
-
 
502
 
-
 
503
    call    checksum
556
    GET_IHL eax,edx              ; get IP-Header length
504
 
557
    stdcall checksum_jb,edx,eax  ; buf_ptr, buf_size
Line 505... Line 558...
505
    mov     ax, [checkResult]
558
 
Line 1002... Line 1055...
1002
    rep     movsb          ; copy the data across
1055
    rep     movsb          ; copy the data across
Line 1003... Line 1056...
1003
 
1056
 
1004
    ; flag an event to the application
1057
    ; flag an event to the application
1005
    pop     eax
1058
    pop     eax
1006
    mov     ecx,1
1059
    mov     ecx,1
Line 1007... Line 1060...
1007
    mov     esi,0x3020+TASKDATA.pid
1060
    mov     esi,TASK_DATA+TASKDATA.pid
1008
 
1061
 
1009
news:
1062
news:
1010
    cmp     [esi],eax
1063
    cmp     [esi],eax
1011
    je      foundPID1
1064
    je      foundPID1
1012
    inc     ecx
1065
    inc     ecx
1013
    add     esi,0x20
1066
    add     esi,0x20
Line 1014... Line 1067...
1014
    cmp     ecx,[0x3004]
1067
    cmp     ecx,[TASK_COUNT]
1015
    jbe     news
1068
    jbe     news
1016
 
1069
 
Line 1017... Line 1070...
1017
foundPID1:
1070
foundPID1:
Line 1018... Line 1071...
1018
    shl     ecx,8
1071
    shl     ecx,8
1019
    or      dword [ecx+0x80000+APPDATA.event_mask],dword 10000000b ; stack event
1072
    or      dword [ecx+SLOT_BASE+APPDATA.event_mask],dword 10000000b ; stack event