Subversion Repositories Kolibri OS

Rev

Rev 6476 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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