Subversion Repositories Kolibri OS

Rev

Rev 5201 | Rev 5984 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5201 Rev 5565
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
6
;;  Part of the TCP/IP network stack for KolibriOS                 ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
8
;;   Written by hidnplayr@kolibrios.org                            ;;
9
;;                                                                 ;;
9
;;                                                                 ;;
10
;;    Based on the code of 4.4BSD                                  ;;
10
;;    Based on the code of 4.4BSD                                  ;;
11
;;                                                                 ;;
11
;;                                                                 ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
12
;;          GNU GENERAL PUBLIC LICENSE                             ;;
13
;;             Version 2, June 1991                                ;;
13
;;             Version 2, June 1991                                ;;
14
;;                                                                 ;;
14
;;                                                                 ;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16
 
16
 
17
$Revision: 5201 $
17
$Revision: 5565 $
18
 
18
 
19
; Socket states
19
; Socket states
20
TCPS_CLOSED             = 0
20
TCPS_CLOSED             = 0
21
TCPS_LISTEN             = 1
21
TCPS_LISTEN             = 1
22
TCPS_SYN_SENT           = 2
22
TCPS_SYN_SENT           = 2
23
TCPS_SYN_RECEIVED       = 3
23
TCPS_SYN_RECEIVED       = 3
24
TCPS_ESTABLISHED        = 4
24
TCPS_ESTABLISHED        = 4
25
TCPS_CLOSE_WAIT         = 5
25
TCPS_CLOSE_WAIT         = 5
26
TCPS_FIN_WAIT_1         = 6
26
TCPS_FIN_WAIT_1         = 6
27
TCPS_CLOSING            = 7
27
TCPS_CLOSING            = 7
28
TCPS_LAST_ACK           = 8
28
TCPS_LAST_ACK           = 8
29
TCPS_FIN_WAIT_2         = 9
29
TCPS_FIN_WAIT_2         = 9
30
TCPS_TIMED_WAIT         = 10
30
TCPS_TIMED_WAIT         = 10
31
 
31
 
32
; Socket Flags
32
; Socket Flags
33
TF_ACKNOW               = 1 shl 0     ; ack peer immediately
33
TF_ACKNOW               = 1 shl 0     ; ack peer immediately
34
TF_DELACK               = 1 shl 1     ; ack, but try to delay it
34
TF_DELACK               = 1 shl 1     ; ack, but try to delay it
35
TF_NODELAY              = 1 shl 2     ; don't delay packets to coalesce
35
TF_NODELAY              = 1 shl 2     ; don't delay packets to coalesce
36
TF_NOOPT                = 1 shl 3     ; don't use tcp options
36
TF_NOOPT                = 1 shl 3     ; don't use tcp options
37
TF_SENTFIN              = 1 shl 4     ; have sent FIN
37
TF_SENTFIN              = 1 shl 4     ; have sent FIN
38
TF_REQ_SCALE            = 1 shl 5     ; have/will request window scaling
38
TF_REQ_SCALE            = 1 shl 5     ; have/will request window scaling
39
TF_RCVD_SCALE           = 1 shl 6     ; other side has requested scaling
39
TF_RCVD_SCALE           = 1 shl 6     ; other side has requested scaling
40
TF_REQ_TSTMP            = 1 shl 7     ; have/will request timestamps
40
TF_REQ_TSTMP            = 1 shl 7     ; have/will request timestamps
41
TF_RCVD_TSTMP           = 1 shl 8     ; a timestamp was received in SYN
41
TF_RCVD_TSTMP           = 1 shl 8     ; a timestamp was received in SYN
42
TF_SACK_PERMIT          = 1 shl 9     ; other side said I could SACK
42
TF_SACK_PERMIT          = 1 shl 9     ; other side said I could SACK
43
 
43
 
44
; Segment flags
44
; Segment flags
45
TH_FIN                  = 1 shl 0
45
TH_FIN                  = 1 shl 0
46
TH_SYN                  = 1 shl 1
46
TH_SYN                  = 1 shl 1
47
TH_RST                  = 1 shl 2
47
TH_RST                  = 1 shl 2
48
TH_PUSH                 = 1 shl 3
48
TH_PUSH                 = 1 shl 3
49
TH_ACK                  = 1 shl 4
49
TH_ACK                  = 1 shl 4
50
TH_URG                  = 1 shl 5
50
TH_URG                  = 1 shl 5
51
 
51
 
52
; Segment header options
52
; Segment header options
53
TCP_OPT_EOL             = 0           ; End of option list.
53
TCP_OPT_EOL             = 0           ; End of option list.
54
TCP_OPT_NOP             = 1           ; No-Operation.
54
TCP_OPT_NOP             = 1           ; No-Operation.
55
TCP_OPT_MAXSEG          = 2           ; Maximum Segment Size.
55
TCP_OPT_MAXSEG          = 2           ; Maximum Segment Size.
56
TCP_OPT_WINDOW          = 3           ; window scale
56
TCP_OPT_WINDOW          = 3           ; window scale
57
TCP_OPT_SACK_PERMIT     = 4           ; Selective Acknowledgement
57
TCP_OPT_SACK_PERMIT     = 4           ; Selective Acknowledgement
58
TCP_OPT_SACK            = 5
58
TCP_OPT_SACK            = 5
59
TCP_OPT_TIMESTAMP       = 8
59
TCP_OPT_TIMESTAMP       = 8
60
 
60
 
61
; Fundamental timer values
61
; Fundamental timer values
62
TCP_time_MSL            = 47          ; max segment lifetime (30s)
62
TCP_time_MSL            = 47          ; max segment lifetime (30s)
63
TCP_time_re_min         = 2           ; min retransmission (1,28s)
63
TCP_time_re_min         = 2           ; min retransmission (1,28s)
64
TCP_time_re_max         = 100         ; max retransmission (64s)
64
TCP_time_re_max         = 100         ; max retransmission (64s)
65
TCP_time_pers_min       = 8           ; min persist (5,12s)
65
TCP_time_pers_min       = 8           ; min persist (5,12s)
66
TCP_time_pers_max       = 94          ; max persist (60,16s)
66
TCP_time_pers_max       = 94          ; max persist (60,16s)
67
TCP_time_keep_init      = 118         ; connection establishment (75,52s)
67
TCP_time_keep_init      = 118         ; connection establishment (75,52s)
68
TCP_time_keep_idle      = 4608        ; idle time before 1st probe (2h)
68
TCP_time_keep_idle      = 4608        ; idle time before 1st probe (2h)
69
TCP_time_keep_interval  = 118         ; between probes when no response (75,52s)
69
TCP_time_keep_interval  = 118         ; between probes when no response (75,52s)
70
TCP_time_rtt_default    = 5           ; default Round Trip Time (3,2s)
70
TCP_time_rtt_default    = 5           ; default Round Trip Time (3,2s)
71
TCP_time_srtt_default   = 0           ;
71
TCP_time_srtt_default   = 0           ;
72
TCP_time_max_idle       = 8*TCP_time_keep_interval      ; FIXME
72
TCP_time_max_idle       = 8*TCP_time_keep_interval      ; FIXME
73
 
73
 
74
TCP_time_connect        = 300         ; in 1/100s (default=3s)
74
TCP_time_connect        = 300         ; in 1/100s (default=3s)
75
 
75
 
76
; timer constants
76
; timer constants
77
TCP_max_rxtshift        = 12          ; max retransmissions waiting for ACK
77
TCP_max_rxtshift        = 12          ; max retransmissions waiting for ACK
78
TCP_max_keepcnt         = 8           ; max keepalive probes
78
TCP_max_keepcnt         = 8           ; max keepalive probes
79
 
79
 
80
;
80
;
81
TCP_max_winshift        = 14
81
TCP_max_winshift        = 14
82
TCP_max_win             = 65535
82
TCP_max_win             = 65535
83
 
83
 
84
TCP_re_xmit_thresh      = 3
84
TCP_re_xmit_thresh      = 3
85
 
85
 
86
TCP_mss_default         = 1480        ; default max segment size
86
TCP_mss_default         = 1480        ; default max segment size
87
 
87
 
88
; smoothed round trip time and estimated variance are stored as fixed point numbers,
88
; smoothed round trip time and estimated variance are stored as fixed point numbers,
89
; shifted by the value below.
89
; shifted by the value below.
90
; With these scales, srtt has 3 bits to the right of the binary point, and thus an "alpha"
90
; With these scales, srtt has 3 bits to the right of the binary point, and thus an "alpha"
91
; of .875. rttvar has 2 bits to the right and thus "alpha" of 0.75
91
; of .875. rttvar has 2 bits to the right and thus "alpha" of 0.75
92
TCP_RTT_SHIFT           = 3
92
TCP_RTT_SHIFT           = 3
93
TCP_RTTVAR_SHIFT        = 2
93
TCP_RTTVAR_SHIFT        = 2
94
 
94
 
95
; bits used by tcp_input and tcp_output
95
; bits used by tcp_input and tcp_output
96
TCP_BIT_NEEDOUTPUT      = 1 shl 0
96
TCP_BIT_NEEDOUTPUT      = 1 shl 0
97
TCP_BIT_TIMESTAMP       = 1 shl 1
97
TCP_BIT_TIMESTAMP       = 1 shl 1
98
TCP_BIT_DROPSOCKET      = 1 shl 2
98
TCP_BIT_DROPSOCKET      = 1 shl 2
99
TCP_BIT_FIN_IS_ACKED    = 1 shl 3
99
TCP_BIT_FIN_IS_ACKED    = 1 shl 3
100
 
100
 
101
TCP_BIT_SENDALOT        = 1 shl 0
101
TCP_BIT_SENDALOT        = 1 shl 0
102
 
102
 
103
TCP_PAWS_IDLE           = 24*24*60*60*100       ; 24 days, in 1/100 seconds
103
TCP_PAWS_IDLE           = 24*24*60*60*100       ; 24 days, in 1/100 seconds
104
 
104
 
105
TCP_QUEUE_SIZE          = 50
105
TCP_QUEUE_SIZE          = 50
106
 
106
 
107
struct  TCP_header
107
struct  TCP_header
108
 
108
 
109
        SourcePort              dw ?
109
        SourcePort              dw ?
110
        DestinationPort         dw ?
110
        DestinationPort         dw ?
111
        SequenceNumber          dd ?
111
        SequenceNumber          dd ?
112
        AckNumber               dd ?
112
        AckNumber               dd ?
113
        DataOffset              db ?    ; DataOffset[0-3 bits] and Reserved[4-7]
113
        DataOffset              db ?    ; DataOffset[0-3 bits] and Reserved[4-7]
114
        Flags                   db ?    ; Reserved[0-1 bits]|URG|ACK|PSH|RST|SYN|FIN
114
        Flags                   db ?    ; Reserved[0-1 bits]|URG|ACK|PSH|RST|SYN|FIN
115
        Window                  dw ?
115
        Window                  dw ?
116
        Checksum                dw ?
116
        Checksum                dw ?
117
        UrgentPointer           dw ?
117
        UrgentPointer           dw ?
118
 
118
 
119
ends
119
ends
120
 
120
 
121
struct  TCP_queue_entry
121
struct  TCP_queue_entry
122
 
122
 
123
        ip_ptr                  dd ?
123
        ip_ptr                  dd ?
124
        segment_ptr             dd ?
124
        segment_ptr             dd ?
125
        segment_size            dd ?
125
        segment_size            dd ?
126
        device_ptr              dd ?
126
        device_ptr              dd ?
127
 
-
 
128
        buffer_ptr              dd ?
-
 
129
        timestamp               dd ?
127
        timestamp               dd ?
-
 
128
        buffer_ptr              dd ?
130
 
129
 
131
ends
130
ends
132
 
131
 
133
uglobal
132
uglobal
134
align 4
133
align 4
135
 
134
 
136
        TCP_segments_tx         rd NET_DEVICES_MAX
135
        TCP_segments_tx         rd NET_DEVICES_MAX
137
        TCP_segments_rx         rd NET_DEVICES_MAX
136
        TCP_segments_rx         rd NET_DEVICES_MAX
138
        TCP_segments_missed     rd NET_DEVICES_MAX
137
        TCP_segments_missed     rd NET_DEVICES_MAX
139
        TCP_segments_dumped     rd NET_DEVICES_MAX
138
        TCP_segments_dumped     rd NET_DEVICES_MAX
140
;        TCP_bytes_rx            rq NET_DEVICES_MAX
139
;        TCP_bytes_rx            rq NET_DEVICES_MAX
141
;        TCP_bytes_tx            rq NET_DEVICES_MAX
140
;        TCP_bytes_tx            rq NET_DEVICES_MAX
142
        TCP_sequence_num        dd ?
141
        TCP_sequence_num        dd ?
143
        TCP_queue               rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4
142
        TCP_queue               rd (TCP_QUEUE_SIZE*sizeof.TCP_queue_entry + sizeof.queue)/4
144
        TCP_input_event         dd ?
143
        TCP_input_event         dd ?
145
        TCP_timer1_event        dd ?
144
        TCP_timer1_event        dd ?
146
endg
145
endg
147
 
146
 
148
uglobal
147
uglobal
149
align 4
148
align 4
150
 
149
 
151
        TCPS_accepts            dd ?    ; #SYNs received in LISTEN state
150
        TCPS_accepts            dd ?    ; #SYNs received in LISTEN state
152
        TCPS_closed             dd ?    ; #connections closed (includes drops)
151
        TCPS_closed             dd ?    ; #connections closed (includes drops)
153
        TCPS_connattempt        dd ?    ; #connections initiated (calls to connect)
152
        TCPS_connattempt        dd ?    ; #connections initiated (calls to connect)
154
        TCPS_conndrops          dd ?    ; #embryonic connections dropped (before SYN received)
153
        TCPS_conndrops          dd ?    ; #embryonic connections dropped (before SYN received)
155
        TCPS_connects           dd ?    ; #connections established actively or passively
154
        TCPS_connects           dd ?    ; #connections established actively or passively
156
        TCPS_delack             dd ?    ; #delayed ACKs sent
155
        TCPS_delack             dd ?    ; #delayed ACKs sent
157
        TCPS_drops              dd ?    ; #connections dropped (after SYN received)
156
        TCPS_drops              dd ?    ; #connections dropped (after SYN received)
158
        TCPS_keepdrops          dd ?    ; #connections dropped in keepalive (established or awaiting SYN)
157
        TCPS_keepdrops          dd ?    ; #connections dropped in keepalive (established or awaiting SYN)
159
        TCPS_keepprobe          dd ?    ; #keepalive probes sent
158
        TCPS_keepprobe          dd ?    ; #keepalive probes sent
160
        TCPS_keeptimeo          dd ?    ; #times keepalive timer or connections-establishment timer expire
159
        TCPS_keeptimeo          dd ?    ; #times keepalive timer or connections-establishment timer expire
161
        TCPS_pawsdrop           dd ?    ; #segments dropped due to PAWS
160
        TCPS_pawsdrop           dd ?    ; #segments dropped due to PAWS
162
        TCPS_pcbcachemiss       dd ?    ; #times PCB cache comparison fails
161
        TCPS_pcbcachemiss       dd ?    ; #times PCB cache comparison fails
163
        TCPS_persisttimeo       dd ?    ; #times persist timer expires
162
        TCPS_persisttimeo       dd ?    ; #times persist timer expires
164
        TCPS_predack            dd ?    ; #times header prediction correct for ACKs
163
        TCPS_predack            dd ?    ; #times header prediction correct for ACKs
165
        TCPS_preddat            dd ?    ; #times header prediction correct for data packets
164
        TCPS_preddat            dd ?    ; #times header prediction correct for data packets
166
        TCPS_rcvackbyte         dd ?    ; #bytes ACKed by received ACKs
165
        TCPS_rcvackbyte         dd ?    ; #bytes ACKed by received ACKs
167
        TCPS_rcvackpack         dd ?    ; #received ACK packets
166
        TCPS_rcvackpack         dd ?    ; #received ACK packets
168
        TCPS_rcvacktoomuch      dd ?    ; #received ACKs for unsent data
167
        TCPS_rcvacktoomuch      dd ?    ; #received ACKs for unsent data
169
        TCPS_rcvafterclose      dd ?    ; #packets received after connection closed
168
        TCPS_rcvafterclose      dd ?    ; #packets received after connection closed
170
        TCPS_rcvbadoff          dd ?    ; #packets received with invalid header length
169
        TCPS_rcvbadoff          dd ?    ; #packets received with invalid header length
171
        TCPS_rcvbadsum          dd ?    ; #packets received with checksum errors
170
        TCPS_rcvbadsum          dd ?    ; #packets received with checksum errors
172
        TCPS_rcvbyte            dd ?    ; #bytes received in sequence
171
        TCPS_rcvbyte            dd ?    ; #bytes received in sequence
173
        TCPS_rcvbyteafterwin    dd ?    ; #bytes received beyond advertised window
172
        TCPS_rcvbyteafterwin    dd ?    ; #bytes received beyond advertised window
174
        TCPS_rcvdupack          dd ?    ; #duplicate ACKs received
173
        TCPS_rcvdupack          dd ?    ; #duplicate ACKs received
175
        TCPS_rcvdupbyte         dd ?    ; #bytes receivedin completely duplicate packets
174
        TCPS_rcvdupbyte         dd ?    ; #bytes receivedin completely duplicate packets
176
        TCPS_rcvduppack         dd ?    ; #packets received with completely duplicate bytes
175
        TCPS_rcvduppack         dd ?    ; #packets received with completely duplicate bytes
177
        TCPS_rcvoobyte          dd ?    ; #out-of-order bytes received
176
        TCPS_rcvoobyte          dd ?    ; #out-of-order bytes received
178
        TCPS_rcvoopack          dd ?    ; #out-of-order packets received
177
        TCPS_rcvoopack          dd ?    ; #out-of-order packets received
179
        TCPS_rcvpack            dd ?    ; #packets received in sequence
178
        TCPS_rcvpack            dd ?    ; #packets received in sequence
180
        TCPS_rcvpackafterwin    dd ?    ; #packets with some data beyond advertised window
179
        TCPS_rcvpackafterwin    dd ?    ; #packets with some data beyond advertised window
181
        TCPS_rcvpartdupbyte     dd ?    ; #duplicate bytes in part-duplicate packets
180
        TCPS_rcvpartdupbyte     dd ?    ; #duplicate bytes in part-duplicate packets
182
        TCPS_rcvpartduppack     dd ?    ; #packets with some duplicate data
181
        TCPS_rcvpartduppack     dd ?    ; #packets with some duplicate data
183
        TCPS_rcvshort           dd ?    ; #packets received too short
182
        TCPS_rcvshort           dd ?    ; #packets received too short
184
        TCPS_rcvtotal           dd ?    ; #total packets received
183
        TCPS_rcvtotal           dd ?    ; #total packets received
185
        TCPS_rcvwinprobe        dd ?    ; #window probe packets received
184
        TCPS_rcvwinprobe        dd ?    ; #window probe packets received
186
        TCPS_rcvwinupd          dd ?    ; #received window update packets
185
        TCPS_rcvwinupd          dd ?    ; #received window update packets
187
        TCPS_rexmttimeo         dd ?    ; #retransmission timeouts
186
        TCPS_rexmttimeo         dd ?    ; #retransmission timeouts
188
        TCPS_rttupdated         dd ?    ; #times RTT estimators updated
187
        TCPS_rttupdated         dd ?    ; #times RTT estimators updated
189
        TCPS_segstimed          dd ?    ; #segments for which TCP tried to measure RTT
188
        TCPS_segstimed          dd ?    ; #segments for which TCP tried to measure RTT
190
        TCPS_sndacks            dd ?    ; #ACK-only packets sent (data length = 0)
189
        TCPS_sndacks            dd ?    ; #ACK-only packets sent (data length = 0)
191
        TCPS_sndbyte            dd ?    ; #data bytes sent
190
        TCPS_sndbyte            dd ?    ; #data bytes sent
192
        TCPS_sndctrl            dd ?    ; #control (SYN, FIN, RST) packets sent (data length = 0)
191
        TCPS_sndctrl            dd ?    ; #control (SYN, FIN, RST) packets sent (data length = 0)
193
        TCPS_sndpack            dd ?    ; #data packets sent (data length > 0)
192
        TCPS_sndpack            dd ?    ; #data packets sent (data length > 0)
194
        TCPS_sndprobe           dd ?    ; #window probes sent (1 byte of data forced by persist timer)
193
        TCPS_sndprobe           dd ?    ; #window probes sent (1 byte of data forced by persist timer)
195
        TCPS_sndrexmitbyte      dd ?    ; #data bytes retransmitted
194
        TCPS_sndrexmitbyte      dd ?    ; #data bytes retransmitted
196
        TCPS_sndrexmitpack      dd ?    ; #data packets retransmitted
195
        TCPS_sndrexmitpack      dd ?    ; #data packets retransmitted
197
        TCPS_sndtotal           dd ?    ; total #packets sent
196
        TCPS_sndtotal           dd ?    ; total #packets sent
198
        TCPS_sndurg             dd ?    ; #packets sent with URG-only (data length=0)
197
        TCPS_sndurg             dd ?    ; #packets sent with URG-only (data length=0)
199
        TCPS_sndwinup           dd ?    ; #window update-only packets sent (data length=0)
198
        TCPS_sndwinup           dd ?    ; #window update-only packets sent (data length=0)
200
        TCPS_timeoutdrop        dd ?    ; #connections dropped in retransmission timeout
199
        TCPS_timeoutdrop        dd ?    ; #connections dropped in retransmission timeout
201
 
200
 
202
endg
201
endg
203
 
202
 
204
 
203
 
205
;-----------------------------------------------------------------
204
;-----------------------------------------------------------------
206
;
205
;
207
; TCP_init
206
; TCP_init
208
;
207
;
209
;  This function resets all TCP variables
208
;  This function resets all TCP variables
210
;
209
;
211
;-----------------------------------------------------------------
210
;-----------------------------------------------------------------
212
macro   TCP_init {
211
macro   TCP_init {
213
 
212
 
214
        xor     eax, eax
213
        xor     eax, eax
215
        mov     edi, TCP_segments_tx
214
        mov     edi, TCP_segments_tx
216
        mov     ecx, (6*NET_DEVICES_MAX)
215
        mov     ecx, (6*NET_DEVICES_MAX)
217
        rep stosd
216
        rep stosd
218
 
217
 
219
        pseudo_random   eax
218
        pseudo_random   eax
220
        mov     [TCP_sequence_num], eax
219
        mov     [TCP_sequence_num], eax
221
 
220
 
222
        init_queue TCP_queue
221
        init_queue TCP_queue
223
 
222
 
224
        movi    ebx, 1
223
        movi    ebx, 1
225
        mov     ecx, TCP_process_input
224
        mov     ecx, TCP_process_input
226
        call    new_sys_threads
225
        call    new_sys_threads
227
        test    eax, eax
226
        test    eax, eax
228
        jns     @f
227
        jns     @f
229
        DEBUGF  DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP input, error %d\n', eax
228
        DEBUGF  DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP input, error %d\n', eax
230
  @@:
229
  @@:
231
 
230
 
232
        movi    ebx, 1
231
        movi    ebx, 1
233
        mov     ecx, TCP_timer_640ms
232
        mov     ecx, TCP_timer_640ms
234
        call    new_sys_threads
233
        call    new_sys_threads
235
        test    eax, eax
234
        test    eax, eax
236
        jns     @f
235
        jns     @f
237
        DEBUGF  DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP timer, error %d\n', eax
236
        DEBUGF  DEBUG_NETWORK_ERROR,'K : cannot create kernel thread for TCP timer, error %d\n', eax
238
  @@:
237
  @@:
239
 
238
 
240
}
239
}
241
 
240
 
242
 
241
 
243
include 'tcp_timer.inc'
242
include 'tcp_timer.inc'
244
include 'tcp_subr.inc'
243
include 'tcp_subr.inc'
245
include 'tcp_usreq.inc'
244
include 'tcp_usreq.inc'
246
include 'tcp_input.inc'
245
include 'tcp_input.inc'
247
include 'tcp_output.inc'
246
include 'tcp_output.inc'
248
 
247
 
249
 
248
 
250
;---------------------------------------------------------------------------
249
;---------------------------------------------------------------------------
251
;
250
;
252
; TCP_API
251
; TCP_API
253
;
252
;
254
; This function is called by system function 76
253
; This function is called by system function 76
255
;
254
;
256
; IN:  subfunction number in bl
255
; IN:  subfunction number in bl
257
;      device number in bh
256
;      device number in bh
258
;      ecx, edx, .. depends on subfunction
257
;      ecx, edx, .. depends on subfunction
259
;
258
;
260
; OUT:
259
; OUT:
261
;
260
;
262
;---------------------------------------------------------------------------
261
;---------------------------------------------------------------------------
263
align 4
262
align 4
264
TCP_api:
263
TCP_api:
265
 
264
 
266
        movzx   eax, bh
265
        movzx   eax, bh
267
        shl     eax, 2
266
        shl     eax, 2
268
 
267
 
269
        test    bl, bl
268
        test    bl, bl
270
        jz      .packets_tx     ; 0
269
        jz      .packets_tx     ; 0
271
        dec     bl
270
        dec     bl
272
        jz      .packets_rx     ; 1
271
        jz      .packets_rx     ; 1
273
        dec     bl
272
        dec     bl
274
        jz      .packets_missed ; 2
273
        jz      .packets_missed ; 2
275
        dec     bl
274
        dec     bl
276
        jz      .packets_dumped ; 3
275
        jz      .packets_dumped ; 3
277
        dec     bl
276
        dec     bl
278
        jz      .packets_queued ; 4
277
        jz      .packets_queued ; 4
279
 
278
 
280
  .error:
279
  .error:
281
        mov     eax, -1
280
        mov     eax, -1
282
        ret
281
        ret
283
 
282
 
284
  .packets_tx:
283
  .packets_tx:
285
        mov     eax, [TCP_segments_tx + eax]
284
        mov     eax, [TCP_segments_tx + eax]
286
        ret
285
        ret
287
 
286
 
288
  .packets_rx:
287
  .packets_rx:
289
        mov     eax, [TCP_segments_rx + eax]
288
        mov     eax, [TCP_segments_rx + eax]
290
        ret
289
        ret
291
 
290
 
292
  .packets_missed:
291
  .packets_missed:
293
        mov     eax, [TCP_segments_missed + eax]
292
        mov     eax, [TCP_segments_missed + eax]
294
        ret
293
        ret
295
 
294
 
296
  .packets_dumped:
295
  .packets_dumped:
297
        mov     eax, [TCP_segments_dumped + eax]
296
        mov     eax, [TCP_segments_dumped + eax]
298
        ret
297
        ret
299
 
298
 
300
  .packets_queued:
299
  .packets_queued:
301
        mov     eax, [TCP_queue + queue.size]
300
        mov     eax, [TCP_queue + queue.size]
302
        ret
301
        ret