1 | /*
|
---|
2 | * TINET (TCP/IP Protocol Stack)
|
---|
3 | *
|
---|
4 | * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
|
---|
5 | * Tomakomai National College of Technology, JAPAN
|
---|
6 | *
|
---|
7 | * ä¸è¨èä½æ¨©è
|
---|
8 | ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
9 | * ã«ãã£ã¦å
|
---|
10 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
11 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
12 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
13 | å¸ï¼ä»¥ä¸ï¼
|
---|
14 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
15 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
16 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
17 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
18 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
19 | * ç¨ã§ããå½¢ã§åé
|
---|
20 | å¸ããå ´åã«ã¯ï¼åé
|
---|
21 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
22 | * è
|
---|
23 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
24 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
25 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
26 | * ç¨ã§ããªãå½¢ã§åé
|
---|
27 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
28 | * (a) åé
|
---|
29 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
30 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
31 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
32 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
33 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
34 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
35 | 責ãããã¨ï¼
|
---|
36 | *
|
---|
37 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
38 | ã
|
---|
39 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
40 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
41 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
42 | *
|
---|
43 | * @(#) $Id: tcp_output.c 313 2017-07-23 04:50:32Z coas-nagasima $
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
|
---|
48 | * The Regents of the University of California. All rights reserved.
|
---|
49 | *
|
---|
50 | * Redistribution and use in source and binary forms, with or without
|
---|
51 | * modification, are permitted provided that the following conditions
|
---|
52 | * are met:
|
---|
53 | * 1. Redistributions of source code must retain the above copyright
|
---|
54 | * notice, this list of conditions and the following disclaimer.
|
---|
55 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
56 | * notice, this list of conditions and the following disclaimer in the
|
---|
57 | * documentation and/or other materials provided with the distribution.
|
---|
58 | * 3. All advertising materials mentioning features or use of this software
|
---|
59 | * must display the following acknowledgement:
|
---|
60 | * This product includes software developed by the University of
|
---|
61 | * California, Berkeley and its contributors.
|
---|
62 | * 4. Neither the name of the University nor the names of its contributors
|
---|
63 | * may be used to endorse or promote products derived from this software
|
---|
64 | * without specific prior written permission.
|
---|
65 | *
|
---|
66 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
67 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
68 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
69 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
70 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
71 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
72 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
73 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
74 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
75 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
76 | * SUCH DAMAGE.
|
---|
77 | *
|
---|
78 | * @(#)tcp_output.c 8.4 (Berkeley) 5/24/95
|
---|
79 | * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.32.2.2 1999/08/29 16:29:55 peter Exp $
|
---|
80 | */
|
---|
81 |
|
---|
82 | #ifdef TARGET_KERNEL_ASP
|
---|
83 |
|
---|
84 | #include <kernel.h>
|
---|
85 | #include <sil.h>
|
---|
86 | #include <t_syslog.h>
|
---|
87 | #include "kernel_cfg.h"
|
---|
88 |
|
---|
89 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
90 |
|
---|
91 | #ifdef TARGET_KERNEL_JSP
|
---|
92 |
|
---|
93 | #include <s_services.h>
|
---|
94 | #include <t_services.h>
|
---|
95 | #include "kernel_id.h"
|
---|
96 |
|
---|
97 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
98 |
|
---|
99 | #include <tinet_defs.h>
|
---|
100 | #include <tinet_config.h>
|
---|
101 |
|
---|
102 | #include <net/if.h>
|
---|
103 | #include <net/if_ppp.h>
|
---|
104 | #include <net/if_loop.h>
|
---|
105 | #include <net/ethernet.h>
|
---|
106 | #include <net/net.h>
|
---|
107 | #include <net/net_endian.h>
|
---|
108 | #include <net/net_var.h>
|
---|
109 | #include <net/net_buf.h>
|
---|
110 | #include <net/net_timer.h>
|
---|
111 | #include <net/net_count.h>
|
---|
112 |
|
---|
113 | #include <netinet/in.h>
|
---|
114 | #include <netinet/in_var.h>
|
---|
115 | #include <netinet/in_itron.h>
|
---|
116 | #include <netinet/ip.h>
|
---|
117 | #include <netinet/ip_var.h>
|
---|
118 | #include <netinet/tcp.h>
|
---|
119 | #include <netinet/tcp_var.h>
|
---|
120 | #include <netinet/tcp_fsm.h>
|
---|
121 | #include <netinet/tcp_seq.h>
|
---|
122 | #include <netinet/tcp_timer.h>
|
---|
123 |
|
---|
124 | #ifdef SUPPORT_TCP
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * é¢æ°
|
---|
128 | */
|
---|
129 |
|
---|
130 | static ER send_segment (bool_t *sendalot, T_TCP_CEP *cep, uint_t doff, uint_t win, uint_t len, uint8_t flags);
|
---|
131 | static void tcp_output (T_TCP_CEP *cep);
|
---|
132 |
|
---|
133 | /*
|
---|
134 | * å¤æ°
|
---|
135 | */
|
---|
136 |
|
---|
137 | /* åºåæã®ãã©ã°ã FSM ç¶æ
|
---|
138 | ã«ããé¸æããããã®è¡¨ */
|
---|
139 |
|
---|
140 | const static uint8_t tcp_outflags[] = {
|
---|
141 | TCP_FLG_RST | TCP_FLG_ACK, /* 0, ã¯ãã¼ãº */
|
---|
142 | 0, /* 1, ååãªã¼ãã³ */
|
---|
143 | TCP_FLG_SYN, /* 2, è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿ */
|
---|
144 | TCP_FLG_SYN | TCP_FLG_ACK, /* 3, SYM ãåä¿¡ããSYN éä¿¡æ¸ã¿ */
|
---|
145 | TCP_FLG_ACK, /* 4, ã³ãã¯ã·ã§ã³éè¨å®äº */
|
---|
146 | TCP_FLG_ACK, /* 5, FIN åä¿¡ãã¯ãã¼ãºå¾
|
---|
147 | ã¡ */
|
---|
148 | TCP_FLG_FIN | TCP_FLG_ACK, /* 6, çµäºãã¦ãFIN éä¿¡æ¸ã¿ */
|
---|
149 | TCP_FLG_FIN | TCP_FLG_ACK, /* 7, çµäºãFIN 交ææ¸ã¿ãACK å¾
|
---|
150 | ã¡ */
|
---|
151 | TCP_FLG_FIN | TCP_FLG_ACK, /* 8, FIN åä¿¡ãçµäºãACK å¾
|
---|
152 | ã¡ */
|
---|
153 | TCP_FLG_ACK, /* 9, çµäºãFIN ä¼é確èªåä¿¡ãFINå¾
|
---|
154 | ã¡ */
|
---|
155 | TCP_FLG_ACK, /* 10, çµäºãæéå¾
|
---|
156 | ã¡ */
|
---|
157 | };
|
---|
158 |
|
---|
159 | /*
|
---|
160 | * send_segment -- TCP åºåå¦ç
|
---|
161 | */
|
---|
162 |
|
---|
163 | static ER
|
---|
164 | send_segment (bool_t *sendalot, T_TCP_CEP *cep, uint_t doff, uint_t win, uint_t len, uint8_t flags)
|
---|
165 | {
|
---|
166 | T_NET_BUF *output;
|
---|
167 | T_TCP_HDR *tcph;
|
---|
168 | uint_t optlen, hdr_offset;
|
---|
169 | ER error;
|
---|
170 |
|
---|
171 | #ifdef TCP_CFG_OPT_MSS
|
---|
172 |
|
---|
173 | uint8_t *optp;
|
---|
174 |
|
---|
175 | if (flags & TCP_FLG_SYN)
|
---|
176 | optlen = TCP_OPT_LEN_MAXSEG;
|
---|
177 | else
|
---|
178 | optlen = 0;
|
---|
179 |
|
---|
180 | #else/* of #ifdef TCP_CFG_OPT_MSS */
|
---|
181 |
|
---|
182 | optlen = 0;
|
---|
183 |
|
---|
184 | #endif/* of #ifdef TCP_CFG_OPT_MSS */
|
---|
185 |
|
---|
186 | NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_SEGS], 1);
|
---|
187 | NET_COUNT_MIB(tcp_stats.tcpOutSegs, 1);
|
---|
188 |
|
---|
189 | /*
|
---|
190 | * ã»ã°ã¡ã³ãé·ããç¸æã®æ大åä¿¡ã»ã°ã¡ã³ãé·ã«èª¿æ´ããã
|
---|
191 | * ãããè¶
|
---|
192 | ãã¦ããå ´åã¯ãè¶
|
---|
193 | ããåãå¾ã§éä¿¡ããã
|
---|
194 | * ãã®ãããFIN ããããã¯ãªã¢ããã
|
---|
195 | *
|
---|
196 | * ãªãªã¸ãã«ã§ã¯ãt_maxopd ãå¶éé·ã«ãã¦ãããã
|
---|
197 | * æ¬å®è£
|
---|
198 | ã§ã¯ãç¸æã®æ大åä¿¡ã»ã°ã¡ã³ãã«ããã
|
---|
199 | */
|
---|
200 | if (len + optlen > cep->maxseg) {
|
---|
201 | flags &= ~TCP_FLG_FIN;
|
---|
202 | len = cep->maxseg - optlen;
|
---|
203 | *sendalot = true;
|
---|
204 | }
|
---|
205 |
|
---|
206 | /*
|
---|
207 | * éä¿¡ãããã¡ã空ã«ãªãã¨ã㯠PUSH ãã©ã°ãè¨å®ããã
|
---|
208 | */
|
---|
209 | if (len && doff + len >= cep->swbuf_count)
|
---|
210 | flags |= TCP_FLG_PUSH;
|
---|
211 |
|
---|
212 | #if defined(TCP_CFG_SWBUF_CSAVE_ONLY)
|
---|
213 |
|
---|
214 | if (len > 0 && ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY ||
|
---|
215 | (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SENT)) {
|
---|
216 |
|
---|
217 | /*
|
---|
218 | * éä¿¡ã¦ã¤ã³ããããã¡ãéæ¾ãããªãããã«ãã¦ã
|
---|
219 | * ãããã¯ã¼ã¯ãããã¡ãåºåã«ç§»ãã
|
---|
220 | */
|
---|
221 | cep->swbufq->flags |= NB_FLG_NOREL_IFOUT;
|
---|
222 | output = cep->swbufq;
|
---|
223 | }
|
---|
224 | else {
|
---|
225 |
|
---|
226 | /*
|
---|
227 | * ACK å®äºç¶æ
|
---|
228 | ã§ããã®é¢æ°ãå¼ã³åºããããã¨ãããã
|
---|
229 | * ãã®æã¯ãlen ã 0 ã«ãã¦ãå¦çãç¶ç¶ããã
|
---|
230 | */
|
---|
231 | len = 0;
|
---|
232 | if ((error = tcpn_get_segment(&output, cep, optlen,
|
---|
233 | len, (uint_t)net_buf_max_siz(),
|
---|
234 | NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
|
---|
235 | if (cep->timer[TCP_TIM_REXMT] == 0)
|
---|
236 | cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
|
---|
237 | goto err_ret;
|
---|
238 | }
|
---|
239 | }
|
---|
240 |
|
---|
241 | #elif defined(TCP_CFG_SWBUF_CSAVE) /* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
|
---|
242 |
|
---|
243 | if (IS_PTR_DEFINED(cep->sbuf)) {
|
---|
244 | if ((error = tcpn_get_segment(&output, cep, optlen,
|
---|
245 | len, (uint_t)net_buf_max_siz(),
|
---|
246 | NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
|
---|
247 | if (cep->timer[TCP_TIM_REXMT] == 0)
|
---|
248 | cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
|
---|
249 | goto err_ret;
|
---|
250 | }
|
---|
251 | }
|
---|
252 | else if (len > 0 && ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY ||
|
---|
253 | (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SENT)) {
|
---|
254 |
|
---|
255 | /*
|
---|
256 | * éä¿¡ã¦ã¤ã³ããããã¡ãéæ¾ãããªãããã«ãã¦ã
|
---|
257 | * ãããã¯ã¼ã¯ãããã¡ãåºåã«ç§»ãã
|
---|
258 | */
|
---|
259 | cep->swbufq->flags |= NB_FLG_NOREL_IFOUT;
|
---|
260 | output = cep->swbufq;
|
---|
261 | }
|
---|
262 | else {
|
---|
263 |
|
---|
264 | /*
|
---|
265 | * ACK å®äºç¶æ
|
---|
266 | ã§ããã®é¢æ°ãå¼ã³åºããããã¨ãããã
|
---|
267 | * ãã®æã¯ãlen ã 0 ã«ãã¦ãå¦çãç¶ç¶ããã
|
---|
268 | */
|
---|
269 | len = 0;
|
---|
270 | if ((error = tcpn_get_segment(&output, cep, optlen,
|
---|
271 | len, (uint_t)net_buf_max_siz(),
|
---|
272 | NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
|
---|
273 | if (cep->timer[TCP_TIM_REXMT] == 0)
|
---|
274 | cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
|
---|
275 | goto err_ret;
|
---|
276 | }
|
---|
277 | }
|
---|
278 |
|
---|
279 | #else /* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
|
---|
280 |
|
---|
281 | if ((error = tcpn_get_segment(&output, cep, optlen,
|
---|
282 | len, (uint_t)net_buf_max_siz(),
|
---|
283 | NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
|
---|
284 | if (cep->timer[TCP_TIM_REXMT] == 0)
|
---|
285 | cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
|
---|
286 | goto err_ret;
|
---|
287 | }
|
---|
288 |
|
---|
289 | #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
|
---|
290 |
|
---|
291 | /*
|
---|
292 | * TCP ãªãã·ã§ã³ã®è¨å®ãè¡ãã
|
---|
293 | * æ¬å®è£
|
---|
294 | ã§ã¯ãæ大ã»ã°ã¡ã³ããµã¤ãºã®ã¿è¨å®ããã
|
---|
295 | */
|
---|
296 | hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
|
---|
297 | if (flags & TCP_FLG_SYN) {
|
---|
298 | cep->snd_nxt = cep->iss;
|
---|
299 |
|
---|
300 | #ifdef TCP_CFG_OPT_MSS
|
---|
301 |
|
---|
302 | optp = GET_TCP_OPT(output, hdr_offset);
|
---|
303 | *optp ++ = TCP_OPT_MAXSEG;
|
---|
304 | *optp ++ = TCP_OPT_LEN_MAXSEG;
|
---|
305 | *(uint16_t*)optp = htons(DEF_TCP_RCV_SEG);
|
---|
306 |
|
---|
307 | #endif/* of #ifdef TCP_CFG_OPT_MSS */
|
---|
308 |
|
---|
309 | }
|
---|
310 |
|
---|
311 | /* TCP SDU ã«éä¿¡ãã¼ã¿ãã³ãã¼ããã*/
|
---|
312 |
|
---|
313 | if (len > 0) {
|
---|
314 | if (SEQ_LT(cep->snd_nxt, cep->snd_max)) {
|
---|
315 | NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_REXMIT_SEGS], 1);
|
---|
316 | NET_COUNT_MIB(tcp_stats.tcpRetransSegs, 1);
|
---|
317 | }
|
---|
318 | TCP_READ_SWBUF(cep, output, len, doff);
|
---|
319 | }
|
---|
320 | else {
|
---|
321 | if (cep->flags & TCP_CEP_FLG_ACK_NOW)
|
---|
322 | NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_ACKS], 1);
|
---|
323 | if (flags & (TCP_FLG_FIN | TCP_FLG_SYN | TCP_FLG_RST))
|
---|
324 | NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_CNTL_SEGS], 1);
|
---|
325 |
|
---|
326 |
|
---|
327 | #ifdef TCP_CFG_EXTENTIONS
|
---|
328 |
|
---|
329 | if (SEQ_LT(cep->snd_up, cep->snd_una))
|
---|
330 | NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_URG_SEGS], 1);
|
---|
331 |
|
---|
332 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
333 |
|
---|
334 | }
|
---|
335 |
|
---|
336 | /*
|
---|
337 | * snd_max: éä¿¡ããæ大 SEQ
|
---|
338 | * snd_nxt: 次ã«éä¿¡ãã SEQ
|
---|
339 | *
|
---|
340 | * ç¸æãã FIN ãåä¿¡ããã¾ã FIN ãéä¿¡ãã¦ããªããã
|
---|
341 | * éããã¼ã¿ããªãã¨ãã¯ãFIN ãç¸æã«å±ããããã
|
---|
342 | * ã»ã°ã¡ã³ããéä¿¡ããããSEQ ã¯é²ããªãã
|
---|
343 | */
|
---|
344 | if ((flags & TCP_FLG_FIN) && (cep->flags & TCP_CEP_FLG_SENT_FIN) &&
|
---|
345 | cep->snd_nxt == cep->snd_max) {
|
---|
346 | cep->snd_nxt --;
|
---|
347 | }
|
---|
348 |
|
---|
349 | tcph = GET_TCP_HDR(output, hdr_offset);
|
---|
350 |
|
---|
351 | /*
|
---|
352 | * SEQãACKããã©ã°ã®è¨å®ã
|
---|
353 | */
|
---|
354 | if (len > 0 || (flags & (TCP_FLG_SYN | TCP_FLG_FIN)) || cep->timer[TCP_TIM_PERSIST] != 0)
|
---|
355 | tcph->seq = htonl(cep->snd_nxt);
|
---|
356 | else
|
---|
357 | tcph->seq = htonl(cep->snd_max);
|
---|
358 |
|
---|
359 | /*
|
---|
360 | * rcv_nxt: åä¿¡ãæå¾
|
---|
361 | ãã¦ããæå°ã® SEQ
|
---|
362 | */
|
---|
363 | tcph->ack = htonl(cep->rcv_nxt);
|
---|
364 | tcph->flags = flags;
|
---|
365 |
|
---|
366 | /*
|
---|
367 | * åä¿¡ã¦ã£ã³ãã®è¨ç®
|
---|
368 | *
|
---|
369 | * rbufsz: åä¿¡ç¨ãããã¡ãµã¤ãº
|
---|
370 | * maxseg: ç¸æã®æ大åä¿¡ã»ã°ã¡ã³ããµã¤ãº
|
---|
371 | */
|
---|
372 | if (win < (cep->rbufsz / 4) && win < cep->maxseg)
|
---|
373 | win = 0;
|
---|
374 |
|
---|
375 | /*
|
---|
376 | * rcv_nxt: åä¿¡ãæå¾
|
---|
377 | ãã¦ããæå°ã® SEQ
|
---|
378 | * rcv_adv: åä¿¡ãæå¾
|
---|
379 | ãã¦ããæ大㮠SEQ
|
---|
380 | */
|
---|
381 | if ((int32_t)win < (int32_t)(cep->rcv_adv - cep->rcv_nxt))
|
---|
382 | win = (uint_t)(cep->rcv_adv - cep->rcv_nxt);
|
---|
383 |
|
---|
384 | tcph->win = htons(win);
|
---|
385 |
|
---|
386 | #ifdef TCP_CFG_EXTENTIONS
|
---|
387 |
|
---|
388 | /*
|
---|
389 | * ç·æ¥ãã¤ã³ã¿ã®è¨å®
|
---|
390 | */
|
---|
391 | if (SEQ_GT(cep->snd_up, cep->snd_nxt)) {
|
---|
392 | if (TCP_CFG_URG_OFFSET)
|
---|
393 | tcph->urp = htons((uint16_t)(cep->snd_up - cep->snd_nxt));
|
---|
394 | else
|
---|
395 | tcph->urp = htons((uint16_t)(cep->snd_up - cep->snd_nxt - 1));
|
---|
396 | tcph->flags |= TCP_FLG_URG;
|
---|
397 | }
|
---|
398 | else
|
---|
399 | cep->snd_up = cep->snd_una;
|
---|
400 |
|
---|
401 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
402 |
|
---|
403 | /*
|
---|
404 | * ãã§ãã¯ãµã ãè¨å®ããã
|
---|
405 | */
|
---|
406 | tcph->sum = 0;
|
---|
407 | tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, GET_TCP_HDR_SIZE(output, hdr_offset) + len);
|
---|
408 |
|
---|
409 | /* ãããã¯ã¼ã¯ãããã¡é·ã調æ´ããã*/
|
---|
410 | output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset) + len);
|
---|
411 |
|
---|
412 | /*
|
---|
413 | * ã¿ã¤ãã®èª¿æ´
|
---|
414 | */
|
---|
415 | if ((cep->flags & TCP_CEP_FLG_FORCE) == 0 || cep->timer[TCP_TIM_PERSIST] == 0) {
|
---|
416 | T_TCP_SEQ startseq = cep->snd_nxt;
|
---|
417 |
|
---|
418 | /*
|
---|
419 | * 次ã«éä¿¡ãã SEQ (snd_nxt) ãä»åéä¿¡ãããã¼ã¿æ°åé²ããã
|
---|
420 | */
|
---|
421 | if (flags & TCP_FLG_SYN)
|
---|
422 | cep->snd_nxt ++;
|
---|
423 | if (flags & TCP_FLG_FIN) {
|
---|
424 | cep->flags |= TCP_CEP_FLG_SENT_FIN;
|
---|
425 | cep->snd_nxt ++;
|
---|
426 | }
|
---|
427 |
|
---|
428 | cep->snd_nxt += len;
|
---|
429 |
|
---|
430 | /*
|
---|
431 | * 次ã«éä¿¡ãã SEQ (snd_nxt) ã
|
---|
432 | * éä¿¡ããæ大 SEQ (snd_max) ããé²ãã§ããã°ã
|
---|
433 | * éä¿¡ããæ大 SEQ (snd_max) ãæ´æ°ããã
|
---|
434 | */
|
---|
435 | if (SEQ_GT(cep->snd_nxt, cep->snd_max)) {
|
---|
436 | cep->snd_max = cep->snd_nxt;
|
---|
437 | /*
|
---|
438 | * ãããå¾å¾©æéè¨æ¸¬ãè¡ã£ã¦ããªããã°ã
|
---|
439 | * ãã®éä¿¡ã«æéãåãããã
|
---|
440 | */
|
---|
441 | if (cep->rtt == 0) {
|
---|
442 | cep->rtt = 1;
|
---|
443 | cep->rtseq = startseq; /* æ´æ°åã® cep->snd_nxt */
|
---|
444 | }
|
---|
445 | }
|
---|
446 |
|
---|
447 | /*
|
---|
448 | * ããè¨å®ããã¦ããªãããACK ã¾ãã¯ä¿çãçºçãã¦ããªããã°ã
|
---|
449 | * åéã¿ã¤ããè¨å®ãããè¨å®ããåæå¤ã¯ã
|
---|
450 | * ãæ»ãããªå¾å¾©æé + 2 à å¾å¾©æéå¤åãã§ããã
|
---|
451 | * åéæéã®ããã¯ãªãã«ä½¿ãããã·ããã«ã¦ã³ããåæåããã
|
---|
452 | */
|
---|
453 | if (cep->timer[TCP_TIM_REXMT] == 0 && cep->snd_nxt != cep->snd_una) {
|
---|
454 | cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
|
---|
455 | if (cep->timer[TCP_TIM_PERSIST] != 0) {
|
---|
456 | cep->timer[TCP_TIM_PERSIST] = 0;
|
---|
457 | cep->rxtshift = 0;
|
---|
458 | }
|
---|
459 | }
|
---|
460 | }
|
---|
461 |
|
---|
462 | /*
|
---|
463 | * 次ã«éä¿¡ãã SEQ (snd_nxt) + ä»åéä¿¡ãããã¼ã¿æ° (len) ã
|
---|
464 | * éä¿¡ããæ大 SEQ (snd_max) ããé²ãã§ããã°ã
|
---|
465 | * éä¿¡ããæ大 SEQ (snd_max) ãæ´æ°ããã
|
---|
466 | */
|
---|
467 | else if (SEQ_GT(cep->snd_nxt + len, cep->snd_max))
|
---|
468 | cep->snd_max = cep->snd_nxt + len;
|
---|
469 |
|
---|
470 | #ifdef TCP_CFG_SWBUF_CSAVE
|
---|
471 |
|
---|
472 | if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY)
|
---|
473 | cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_SENT;
|
---|
474 |
|
---|
475 | #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */
|
---|
476 |
|
---|
477 | #ifdef TCP_CFG_TRACE
|
---|
478 |
|
---|
479 | tcp_output_trace(output, cep);
|
---|
480 |
|
---|
481 | #endif /* of #ifdef TCP_CFG_TRACE */
|
---|
482 |
|
---|
483 | /* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
|
---|
484 | if ((error = IP_OUTPUT(output, TMO_TCP_OUTPUT)) != E_OK)
|
---|
485 | goto err_ret;
|
---|
486 |
|
---|
487 | /*
|
---|
488 | * ç¸æã«ä¼ããã¦ã£ã³ãã¦ãµã¤ãº (win) ã 0 以ä¸ã§ã
|
---|
489 | * åä¿¡ãæå¾
|
---|
490 | ãã¦ããæå°ã® SEQ (rcv_nxt) + win ã
|
---|
491 | * åä¿¡ãæå¾
|
---|
492 | ãã¦ããæ大㮠SEQ (rcv_adv) ããé²ãã§ããã°
|
---|
493 | * åä¿¡ãæå¾
|
---|
494 | ãã¦ããæ大㮠SEQ ãæ´æ°ããã
|
---|
495 | */
|
---|
496 | if (win > 0 && SEQ_GT(cep->rcv_nxt + win, cep->rcv_adv)) {
|
---|
497 | cep->rcv_adv = cep->rcv_nxt + win;
|
---|
498 | }
|
---|
499 |
|
---|
500 | /*
|
---|
501 | * æå¾ã«éä¿¡ãã ACK (last_ack_sent) ãæ´æ°ããã
|
---|
502 | */
|
---|
503 | cep->last_ack_sent = cep->rcv_nxt;
|
---|
504 |
|
---|
505 | /*
|
---|
506 | * ãã©ã°ã®è¨å®ãè¡ãã
|
---|
507 | */
|
---|
508 | cep->flags &= ~(TCP_CEP_FLG_ACK_NOW | TCP_CEP_FLG_DEL_ACK);
|
---|
509 | if (cep->flags & TCP_CEP_FLG_FORCE_CLEAR)
|
---|
510 | cep->flags &= ~(TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR);
|
---|
511 |
|
---|
512 | return E_OK;
|
---|
513 |
|
---|
514 | err_ret:
|
---|
515 | /*
|
---|
516 | * 以ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
|
---|
517 | * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
|
---|
518 | * ã»åçãªé信端ç¹ã®çæã»åé¤æ©è½
|
---|
519 | */
|
---|
520 | cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
|
---|
521 |
|
---|
522 | return error;
|
---|
523 | }
|
---|
524 |
|
---|
525 | /*
|
---|
526 | * tcp_output -- TCP åºåå¦ç
|
---|
527 | */
|
---|
528 |
|
---|
529 | void
|
---|
530 | tcp_output (T_TCP_CEP *cep)
|
---|
531 | {
|
---|
532 | bool_t sendalot = true, idle;
|
---|
533 | ER error = E_OK;
|
---|
534 | int32_t len;
|
---|
535 | uint_t doff, win;
|
---|
536 | uint8_t flags;
|
---|
537 |
|
---|
538 | /*
|
---|
539 | * snd_una: æªç¢ºèªã®æå°éä¿¡ SEQ ã¾ãã¯ã確èªãããæ大éä¿¡ SEQ
|
---|
540 | * snd_max: éä¿¡ããæ大 SEQ
|
---|
541 | */
|
---|
542 | idle = (cep->snd_max == cep->snd_una);
|
---|
543 |
|
---|
544 | /*
|
---|
545 | * idle: ã¢ã¤ãã«æé
|
---|
546 | * rxtcur: ç¾å¨ã®åéã¿ã¤ã ã¢ã¦ã
|
---|
547 | */
|
---|
548 | if (idle && cep->idle >= cep->rxtcur)
|
---|
549 |
|
---|
550 | /*
|
---|
551 | * snd_cwnd: 輻輳ã¦ã£ã³ããµã¤ãº
|
---|
552 | * maxseg : ç¸æã®æ大åä¿¡ã»ã°ã¡ã³ããµã¤ãº
|
---|
553 | *
|
---|
554 | * é·æéã¢ã¤ãã«ã ã£ãã®ã§ã¹ãã¼ã¹ã¿ã¼ãå¶å¾¡ã«è¨å®ããã
|
---|
555 | */
|
---|
556 | cep->snd_cwnd = cep->maxseg;
|
---|
557 |
|
---|
558 | while (error == E_OK && sendalot) {
|
---|
559 | sendalot = false;
|
---|
560 |
|
---|
561 | /*
|
---|
562 | * snd_nxt: 次ã«éä¿¡ãã SEQããã®æç¹ã§ã¯ãååéä¿¡ãã SEQ
|
---|
563 | * snd_una: æªç¢ºèªã®æå°éä¿¡ SEQãã¾ãã¯ç¢ºèªãããæ大éä¿¡ SEQ
|
---|
564 | *
|
---|
565 | * doff: éä¿¡ãéå§ãããªãã»ããã
|
---|
566 | * swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
|
---|
567 | * 0 V
|
---|
568 | * +-------------------------------------------+
|
---|
569 | * | sbuf |
|
---|
570 | * +-------------------------------------------+
|
---|
571 | * ^ ^
|
---|
572 | * |<------------->snd_nxt (ååéä¿¡ãã SEQ)
|
---|
573 | * | doff
|
---|
574 | * snd_una (ã¾ã 確èªããã¦ããªã)
|
---|
575 | */
|
---|
576 | doff = (uint_t)(cep->snd_nxt - cep->snd_una);
|
---|
577 |
|
---|
578 | /*
|
---|
579 | * snd_wnd: ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
|
---|
580 | * snd_cwnd: 輻輳ã¦ã£ã³ããµã¤ãº
|
---|
581 | *
|
---|
582 | * win: ã©ã¡ããå°ããã¦ã£ã³ããµã¤ãºã«è¨å®ããã
|
---|
583 | */
|
---|
584 | win = cep->snd_wnd < cep->snd_cwnd ? cep->snd_wnd : cep->snd_cwnd;
|
---|
585 |
|
---|
586 | /* åºåãã©ã°ã®è¨å® */
|
---|
587 | flags = tcp_outflags[cep->fsm_state];
|
---|
588 | if (cep->flags & TCP_CEP_FLG_NEED_FIN)
|
---|
589 | flags |= TCP_FLG_FIN;
|
---|
590 | if (cep->flags & TCP_CEP_FLG_NEED_SYN)
|
---|
591 | flags |= TCP_FLG_SYN;
|
---|
592 | if (cep->flags & TCP_CEP_FLG_FORCE) {
|
---|
593 |
|
---|
594 | /*
|
---|
595 | * ãããéä¿¡ã¦ã¤ã³ããµã¤ãº (win) ã 0 ãªã 1 ãªã¯ãããéä¿¡ããã
|
---|
596 | * ããã§ãªããã°ãæç¶ã¿ã¤ã ã¢ã¦ãããã£ã³ã»ã«ãã
|
---|
597 | * åéä¿¡åæ° (rxtshift) ã 0 ã«ããã
|
---|
598 | */
|
---|
599 | if (win == 0) {
|
---|
600 |
|
---|
601 | /*
|
---|
602 | * doff: éä¿¡ãããªã¯ãããæ°ã
|
---|
603 | * swbuf_count: éä¿¡ãããã¡ã®ä½¿ç¨ä¸ãµã¤ãº
|
---|
604 | *
|
---|
605 | * éä¿¡ãããã¡ã«æ®ã£ã¦ãããªã¯ããããããããã
|
---|
606 | * éä¿¡ãããã¨ãã¦ãããªã¯ãããæ°ããå¤ããã°
|
---|
607 | * FIN ãã©ã°ãã¯ãªã¢ããã
|
---|
608 | */
|
---|
609 | if (doff < cep->swbuf_count)
|
---|
610 | flags &=~TCP_FLG_FIN;
|
---|
611 | win = 1;
|
---|
612 | }
|
---|
613 | else {
|
---|
614 | /*
|
---|
615 | * TCP_TIM_PERSIST: æç¶ã¿ã¤ã
|
---|
616 | * rxtshift: åéä¿¡åæ°ã® log(2)
|
---|
617 | */
|
---|
618 | cep->timer[TCP_TIM_PERSIST] = 0;
|
---|
619 | cep->rxtshift = 0;
|
---|
620 | }
|
---|
621 | }
|
---|
622 |
|
---|
623 | /*
|
---|
624 | * len: ä»åéä¿¡ãããªã¯ãããæ°
|
---|
625 | * swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
|
---|
626 | * |
|
---|
627 | * 0 V
|
---|
628 | * +-------------------------------------------+
|
---|
629 | * | sbuf | |
|
---|
630 | * +-------------------------------------------+
|
---|
631 | * ^ ^<------------->
|
---|
632 | * | | len
|
---|
633 | * |<------------->snd_nxt (ååéä¿¡ãã SEQ)
|
---|
634 | * | doff
|
---|
635 | * snd_una (ã¾ã 確èªããã¦ããªã)
|
---|
636 | */
|
---|
637 | if (cep->swbuf_count < win)
|
---|
638 | len = (int32_t)cep->swbuf_count - doff;
|
---|
639 | else
|
---|
640 | len = (int32_t)win - doff;
|
---|
641 |
|
---|
642 | /*
|
---|
643 | * ãã§ã«éä¿¡ããã¦ããã°ãSYN ãããããªãããã
|
---|
644 | * ãããã以ä¸ã®æ¡ä»¶ã§ã¯éä¿¡ãæ§ããã
|
---|
645 | *
|
---|
646 | * ã»ç¶æ
|
---|
647 | ã SYN éä¿¡ã
|
---|
648 | * ã»ã»ã°ã¡ã³ãããã¼ã¿ãå«ãã§ããã
|
---|
649 | */
|
---|
650 | if ((flags & TCP_FLG_SYN) && SEQ_GT(cep->snd_nxt, cep->snd_una)) {
|
---|
651 | flags &= ~TCP_FLG_SYN;
|
---|
652 | doff --; /* -1 㯠SYN ãã©ã°å */
|
---|
653 | len ++; /* +1 㯠SYN ãã©ã°å */
|
---|
654 | if (len > 0 && cep->fsm_state == TCP_FSM_SYN_SENT)
|
---|
655 | break;
|
---|
656 | }
|
---|
657 |
|
---|
658 | if (flags & TCP_FLG_SYN) {
|
---|
659 | len = 0;
|
---|
660 | flags &= ~TCP_FLG_FIN;
|
---|
661 | }
|
---|
662 |
|
---|
663 | if (len < 0) {
|
---|
664 |
|
---|
665 | /*
|
---|
666 | * len ã 0 以ä¸ãªãã0 ã«è¨å®ããã
|
---|
667 | * ãããéä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã 0 ãªãã
|
---|
668 | * åéä¿¡ã¿ã¤ãããã£ã³ã»ã«ãã
|
---|
669 | * ååéä¿¡ãã SEQ (snd_nxt) ã
|
---|
670 | * 確èªãããæ大éä¿¡ SEQ (snd_una) ã«æ»ãã
|
---|
671 | * ããã¦ãæç¶ã¿ã¤ãã¼ãæ¢ã¾ã£ã¦ããã°ãåè¨å®ããã
|
---|
672 | */
|
---|
673 | len = 0;
|
---|
674 | if (win == 0) {
|
---|
675 | cep->timer[TCP_TIM_REXMT] = 0;
|
---|
676 | cep->rxtshift = 0;
|
---|
677 | cep->snd_nxt = cep->snd_una;
|
---|
678 | if (cep->timer[TCP_TIM_PERSIST] == 0)
|
---|
679 | tcp_set_persist_timer(cep);
|
---|
680 | }
|
---|
681 | }
|
---|
682 |
|
---|
683 |
|
---|
684 | /*
|
---|
685 | * ä»åéä¿¡ãããªã¯ãããæ° (len) ã¯ã
|
---|
686 | * ç¸æã®æ大åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ãè¶
|
---|
687 | ããªãããã«ããã
|
---|
688 | */
|
---|
689 | if (len > cep->maxseg) {
|
---|
690 | len = cep->maxseg;
|
---|
691 | sendalot = true;
|
---|
692 | }
|
---|
693 |
|
---|
694 | /*
|
---|
695 | * swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
|
---|
696 | * |
|
---|
697 | * 0 V
|
---|
698 | * +-------------------------------------------+
|
---|
699 | * | sbuf | |
|
---|
700 | * +-------------------------------------------+
|
---|
701 | * ^ ^<------------->
|
---|
702 | * | | len
|
---|
703 | * |<------------->snd_nxt (ååéä¿¡ãã SEQ)
|
---|
704 | * | doff
|
---|
705 | * snd_una (ã¾ã 確èªããã¦ããªã)
|
---|
706 | *
|
---|
707 | * ä»åéä¿¡å¾ããéä¿¡ãããã¡ã«ãã¼ã¿ãæ®ã£ã¦ããã°
|
---|
708 | * FIN ãã©ã°ãã¯ãªã¢ããã
|
---|
709 | */
|
---|
710 | if (SEQ_LT(cep->snd_nxt + len, cep->snd_una + cep->swbuf_count))
|
---|
711 | flags &= ~TCP_FLG_FIN;
|
---|
712 |
|
---|
713 | /*
|
---|
714 | * ãããã win ã¯ãåä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã
|
---|
715 | * åä¿¡ãããã¡ã®ç©ºã容é
|
---|
716 | */
|
---|
717 | win = cep->rbufsz - cep->rwbuf_count;
|
---|
718 |
|
---|
719 | /*
|
---|
720 | * æããªã¦ã£ã³ãã¦ã»ã·ã³ããã¼ã ã®åé¿å¦ç (éä¿¡å´)
|
---|
721 | *
|
---|
722 | * 以ä¸ã®æ¡ä»¶ã§ãéä¿¡ãè¡ãã
|
---|
723 | *
|
---|
724 | * ã»ãã«ãµã¤ãº (maxseg) ã®ã»ã°ã¡ã³ããéããã¨ãã§ããã
|
---|
725 | * ã»ç¸æã®æ大ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã® 1/2 ã®ãã¼ã¿ã
|
---|
726 | * éããã¨ãã§ããã
|
---|
727 | * ã»éä¿¡ãããã¡ã空ã«ã§ããã¢ã¤ãã«ãéé
|
---|
728 | 延ãªãã·ã§ã³ãæå¹ãªã¨ãã
|
---|
729 | */
|
---|
730 | if (len) {
|
---|
731 |
|
---|
732 | /*
|
---|
733 | * ä»åéä¿¡ãããªã¯ãããæ° (len) ã
|
---|
734 | * ç¸æã®æ大åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ã«
|
---|
735 | * ä¸è´ããã¨ãã¯éä¿¡ããã
|
---|
736 | */
|
---|
737 | if (len == cep->maxseg) {
|
---|
738 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
739 | continue;
|
---|
740 | }
|
---|
741 |
|
---|
742 | /*
|
---|
743 | * ä»åã®éä¿¡ã§ãéä¿¡ãããã¡ã空ã«ã§ãã
|
---|
744 | * ã¢ã¤ãã«ãé PUSH ãªãã·ã§ã³ãæå¹ãªã¨ãã
|
---|
745 | */
|
---|
746 | if ((idle || (cep->flags & TCP_CEP_FLG_NO_DELAY)) &&
|
---|
747 | (cep->flags & TCP_CEP_FLG_NO_PUSH) == 0 &&
|
---|
748 | len + doff >= cep->swbuf_count) {
|
---|
749 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
750 | continue;
|
---|
751 | }
|
---|
752 |
|
---|
753 | /*
|
---|
754 | * max_sndwnd: ä»ã¾ã§ã®æ大éä¿¡ã¦ã£ã³ããµã¤ãº
|
---|
755 | * snd_nxt: 次ã«éä¿¡ãã SEQ
|
---|
756 | * snd_max: éä¿¡ããæ大 SEQ
|
---|
757 | *
|
---|
758 | * 次ã®æ¡ä»¶ã§ã¯éä¿¡ãè¡ãã
|
---|
759 | *
|
---|
760 | * ã»å¼·å¶éä¿¡ãã©ã°ãã»ããããã¦ããã
|
---|
761 | * ã»ãã¼ã¿é·ãç¸æã®æ大ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã® 1/2 以ä¸ã§ã
|
---|
762 | * ç¸æã®æ大ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã 0 ãã大ããã
|
---|
763 | * ã»æ¬¡ã«éä¿¡ãã SEQ ãéä¿¡ããæ大 SEQ ããå°ããã
|
---|
764 | * ã¤ã¾ããåéããã¨ãã
|
---|
765 | */
|
---|
766 | if ((cep->flags & TCP_CEP_FLG_FORCE) ||
|
---|
767 | (len >= cep->max_sndwnd / 2 && cep->max_sndwnd > 0) ||
|
---|
768 | SEQ_LT(cep->snd_nxt, cep->snd_max)) {
|
---|
769 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
770 | continue;
|
---|
771 | }
|
---|
772 | }
|
---|
773 |
|
---|
774 |
|
---|
775 | /*
|
---|
776 | * æããªã¦ã£ã³ãã¦ã»ã·ã³ããã¼ã ã®åé¿å¦ç (åä¿¡å´)
|
---|
777 | *
|
---|
778 | * ã¦ã£ã³ãã¦ãµã¤ãºããã«ãµã¤ãºã® 2 åã®ã»ã°ã¡ã³ãããããã¯
|
---|
779 | * åä¿¡ãããã¡å®¹éã® 1/2 ã®ãããããå°ããã»ãã®
|
---|
780 | * ãµã¤ãºã§å¢å ãããå ´åã¯ãã¦ã£ã³ãã¦ãµã¤ãºã®æ´æ°ãè¡ãã
|
---|
781 | */
|
---|
782 | if (win > 0) {
|
---|
783 | long adv;
|
---|
784 |
|
---|
785 | /*
|
---|
786 | * win: åä¿¡ãããã¡ã®ç©ºã容é
|
---|
787 | * MAX_TCP_WIN_SIZE: TCP ãããã® win ãã£ã¼ã«ãã«è¨å®ã§ããæ大å¤
|
---|
788 | * rcv_adv: åä¿¡ãæå¾
|
---|
789 | ãã¦ããæ大㮠SEQ
|
---|
790 | * rcv_nxt: åä¿¡ãæå¾
|
---|
791 | ãã¦ããæå°ã® SEQ
|
---|
792 | */
|
---|
793 | if (win < MAX_TCP_WIN_SIZE)
|
---|
794 | adv = win - (cep->rcv_adv - cep->rcv_nxt);
|
---|
795 | else
|
---|
796 | adv = MAX_TCP_WIN_SIZE - (cep->rcv_adv - cep->rcv_nxt);
|
---|
797 |
|
---|
798 | if (adv >= (long)(cep->maxseg * 2) ||
|
---|
799 | adv * 2 >= (long) cep->rbufsz) {
|
---|
800 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
801 | continue;
|
---|
802 | }
|
---|
803 | }
|
---|
804 |
|
---|
805 | /*
|
---|
806 | * ACK ãéä¿¡ããã
|
---|
807 | */
|
---|
808 | if (cep->flags & TCP_CEP_FLG_ACK_NOW) {
|
---|
809 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
810 | continue;
|
---|
811 | }
|
---|
812 |
|
---|
813 | if ( (flags & TCP_FLG_RST) ||
|
---|
814 | ((flags & TCP_FLG_SYN) && (cep->flags & TCP_CEP_FLG_NEED_SYN) == 0)) {
|
---|
815 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
816 | continue;
|
---|
817 | }
|
---|
818 |
|
---|
819 | #ifdef TCP_CFG_EXTENTIONS
|
---|
820 |
|
---|
821 | if (SEQ_GT(cep->snd_up, cep->snd_una)) {
|
---|
822 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
823 | continue;
|
---|
824 | }
|
---|
825 |
|
---|
826 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
827 |
|
---|
828 | /*
|
---|
829 | * snd_nxt: 次ã«éä¿¡ãã SEQ
|
---|
830 | * snd_una: æªç¢ºèªã®æå°éä¿¡ SEQãã¾ãã¯ç¢ºèªãããæ大éä¿¡ SEQ
|
---|
831 | *
|
---|
832 | * ç¸æãã FIN ãåä¿¡ããã¾ã FIN ãéä¿¡ãã¦ããªããã
|
---|
833 | * éããã¼ã¿ããªãã¨ãã¯ãFIN ãç¸æã«å±ããããã
|
---|
834 | * ã»ã°ã¡ã³ããéä¿¡ããã
|
---|
835 | */
|
---|
836 | if ((flags & TCP_FLG_FIN) &&
|
---|
837 | ((cep->flags & TCP_CEP_FLG_SENT_FIN) == 0 || cep->snd_nxt == cep->snd_una)) {
|
---|
838 | error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
|
---|
839 | continue;
|
---|
840 | }
|
---|
841 |
|
---|
842 | /*
|
---|
843 | * éä¿¡ãã¹ããã¼ã¿ããããåéã¿ã¤ãã¨æç¶ã¿ã¤ããåãã¦ããã¨ãã¯
|
---|
844 | * æç¶ã¿ã¤ããè¨å®ããã
|
---|
845 | */
|
---|
846 | if (cep->swbuf_count && cep->timer[TCP_TIM_REXMT ] == 0 &&
|
---|
847 | cep->timer[TCP_TIM_PERSIST] == 0) {
|
---|
848 | cep->rxtshift = 0;
|
---|
849 | tcp_set_persist_timer(cep);
|
---|
850 | break;
|
---|
851 | }
|
---|
852 |
|
---|
853 | }
|
---|
854 | }
|
---|
855 |
|
---|
856 | #ifdef TCP_CFG_SWBUF_CSAVE
|
---|
857 |
|
---|
858 | /*
|
---|
859 | * tcptsk_alloc_swbufq -- éä¿¡ã¦ã£ã³ããããã¡å²ãå½ã¦
|
---|
860 | */
|
---|
861 |
|
---|
862 | static void
|
---|
863 | tcptsk_alloc_swbufq (T_TCP_CEP *cep)
|
---|
864 | {
|
---|
865 | ER error;
|
---|
866 | uint_t win;
|
---|
867 |
|
---|
868 | /*
|
---|
869 | * snd_wnd: ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
|
---|
870 | * snd_cwnd: 輻輳ã¦ã£ã³ããµã¤ãº
|
---|
871 | *
|
---|
872 | * win: ã©ã¡ããå°ããã¦ã£ã³ããµã¤ãºã«è¨å®ããã
|
---|
873 | */
|
---|
874 | win = cep->snd_wnd < cep->snd_cwnd ? cep->snd_wnd : cep->snd_cwnd;
|
---|
875 |
|
---|
876 | /*
|
---|
877 | * ç¸æã®åä¿¡ã¦ã£ã³ããéãã¦ããå ´åã¯ãéãã¾ã§å¾
|
---|
878 | æ©ããã
|
---|
879 | */
|
---|
880 | if (win == 0) {
|
---|
881 | cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_WOPEN_PEND;
|
---|
882 | }
|
---|
883 | else {
|
---|
884 |
|
---|
885 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
886 |
|
---|
887 | /* ãã³ããããã³ã°ã³ã¼ã« */
|
---|
888 | if (!IS_PTR_DEFINED(cep->callback)) {
|
---|
889 | syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
|
---|
890 |
|
---|
891 | /* è¨æ¶ããã¦ããã¿ã¹ã¯ ID 㨠API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
|
---|
892 | cep->snd_tskid = TA_NULL;
|
---|
893 | cep->snd_tfn = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
|
---|
894 | return;
|
---|
895 | }
|
---|
896 |
|
---|
897 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
898 |
|
---|
899 | if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
|
---|
900 | (uint_t)TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
|
---|
901 | (uint_t)TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
|
---|
902 | (ATR)(NBA_SEARCH_DESCENT |
|
---|
903 | NBA_RESERVE_TCP |
|
---|
904 | (GET_TCP_CEPID(cep) & NBA_ID_MASK)), TMO_POL)) != E_OK) {
|
---|
905 |
|
---|
906 | /* ãããã¯ã¼ã¯ãããã¡ãäºç´ããã*/
|
---|
907 | cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_NBUF_PEND;
|
---|
908 | }
|
---|
909 | else {
|
---|
910 |
|
---|
911 | /* éä¿¡ã¦ã£ã³ããããã¡ãåæåããã*/
|
---|
912 | tcp_init_swbuf(cep);
|
---|
913 |
|
---|
914 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
915 |
|
---|
916 | if (cep->snd_nblk_tfn == TFN_TCP_GET_BUF) {
|
---|
917 |
|
---|
918 | uint_t len;
|
---|
919 |
|
---|
920 | /* éä¿¡ã¦ã£ã³ããããã¡ã®æ¸ãè¾¼ã¿ã¢ãã¬ã¹ãè¨å®ããã*/
|
---|
921 | len = TCP_GET_SWBUF_ADDR(cep, cep->snd_p_buf);
|
---|
922 |
|
---|
923 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
924 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
925 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
|
---|
926 | #else
|
---|
927 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
|
---|
928 | #endif
|
---|
929 |
|
---|
930 |
|
---|
931 | /* è¨æ¶ããã¦ããã¿ã¹ã¯ ID 㨠API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
|
---|
932 | cep->snd_tskid = TA_NULL;
|
---|
933 | cep->snd_tfn = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
|
---|
934 | }
|
---|
935 |
|
---|
936 | else { /* cep->snd_nblk_tfn == TFN_TCP_SND_DAT || */
|
---|
937 | /* cep->snd_nblk_tfn == TFN_TCP_SND_OOB */
|
---|
938 |
|
---|
939 | uint_t len;
|
---|
940 |
|
---|
941 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
|
---|
942 | len = TCP_WRITE_SWBUF(cep, cep->snd_data, (uint_t)cep->snd_len);
|
---|
943 |
|
---|
944 | #ifdef TCP_CFG_EXTENTIONS
|
---|
945 |
|
---|
946 | /* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨å®ããã*/
|
---|
947 | if (cep->snd_nblk_tfn == TFN_TCP_SND_OOB)
|
---|
948 | cep->snd_up = cep->snd_una + len;
|
---|
949 |
|
---|
950 | #endif /* of #ifdef TCP_CFG_EXTENTIONS */
|
---|
951 |
|
---|
952 | /* ãã©ã°ããéä¿¡å¯è½ã«è¨å®ããå¼·å¶çã«éä¿¡ããã*/
|
---|
953 | cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT;
|
---|
954 |
|
---|
955 | /* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
|
---|
956 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
957 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
|
---|
958 | #else
|
---|
959 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
|
---|
960 | #endif
|
---|
961 |
|
---|
962 |
|
---|
963 | /* è¨æ¶ããã¦ããã¿ã¹ã¯ ID 㨠API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
|
---|
964 | cep->snd_tskid = TA_NULL;
|
---|
965 | cep->snd_tfn = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
|
---|
966 | }
|
---|
967 |
|
---|
968 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
969 |
|
---|
970 | }
|
---|
971 | }
|
---|
972 | }
|
---|
973 |
|
---|
974 | /*
|
---|
975 | * tcptsk_free_swbufq -- éä¿¡ã¦ã£ã³ããããã¡éæ¾
|
---|
976 | */
|
---|
977 |
|
---|
978 | static void
|
---|
979 | tcptsk_free_swbufq (T_TCP_CEP *cep)
|
---|
980 | {
|
---|
981 | /*
|
---|
982 | * å信確èªãå®äºãããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããã®
|
---|
983 | * åºåãå®äºããã¨ãã¯ãéä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã解æ¾ããã
|
---|
984 | */
|
---|
985 |
|
---|
986 | /* éä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸ãµã¤ãºããªã»ããããã*/
|
---|
987 | cep->swbuf_count = 0;
|
---|
988 |
|
---|
989 | /* éä¿¡ã¦ã£ã³ããããã¡ãã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã解æ¾ããã*/
|
---|
990 | syscall(rel_net_buf(cep->swbufq));
|
---|
991 | cep->swbufq = NULL;
|
---|
992 |
|
---|
993 | /* ãã©ã°ã空ãã«è¨å®ããã*/
|
---|
994 | cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_FREE;
|
---|
995 |
|
---|
996 | /* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããã§ãããã¨ãç¥ãããã*/
|
---|
997 | syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
|
---|
998 |
|
---|
999 | /* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãå¾
|
---|
1000 | ã¡ã®ã¨ãã¯ãTCP åºåã¿ã¹ã¯ãèµ·åããã*/
|
---|
1001 | if ((cep->flags & TCP_CEP_FLG_WBCS_NBUF_REQ) != 0) {
|
---|
1002 | sig_sem(SEM_TCP_POST_OUTPUT);
|
---|
1003 | }
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 | #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */
|
---|
1007 |
|
---|
1008 | /*
|
---|
1009 | * TCP åºåã¿ã¹ã¯
|
---|
1010 | */
|
---|
1011 |
|
---|
1012 | void
|
---|
1013 | tcp_output_task (intptr_t exinf)
|
---|
1014 | {
|
---|
1015 | static int_t last_ix = 0;
|
---|
1016 |
|
---|
1017 | T_TCP_CEP *cep;
|
---|
1018 | ID tskid;
|
---|
1019 | int_t ix, sel_ix;
|
---|
1020 |
|
---|
1021 | get_tid(&tskid);
|
---|
1022 | syslog(LOG_NOTICE, "[TCP OUTPUT:%d] started.", tskid);
|
---|
1023 |
|
---|
1024 | tcp_init();
|
---|
1025 |
|
---|
1026 | #ifdef _IP6_CFG
|
---|
1027 |
|
---|
1028 | /* IPv6 ã®ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨å®ãå®è¡ããã*/
|
---|
1029 | in6_if_up(IF_GET_IFNET());
|
---|
1030 |
|
---|
1031 | #endif /* of #ifdef _IP6_CFG */
|
---|
1032 |
|
---|
1033 | while (true) {
|
---|
1034 |
|
---|
1035 | /* åºåããã¹ããããã¾ã§å¾
|
---|
1036 | ã¤ã*/
|
---|
1037 | syscall(wai_sem(SEM_TCP_POST_OUTPUT));
|
---|
1038 |
|
---|
1039 | if (++ last_ix == tmax_tcp_cepid)
|
---|
1040 | last_ix = 0;
|
---|
1041 | sel_ix = ix = last_ix;
|
---|
1042 | do {
|
---|
1043 | cep = &tcp_cep[ix];
|
---|
1044 |
|
---|
1045 | #ifdef TCP_CFG_SWBUF_CSAVE
|
---|
1046 |
|
---|
1047 | if ((cep->flags & TCP_CEP_FLG_WBCS_NBUF_REQ) != 0 &&
|
---|
1048 | ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_FREE ||
|
---|
1049 | (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_RSVD)) {
|
---|
1050 | tcptsk_alloc_swbufq(cep);
|
---|
1051 | sel_ix = ix;
|
---|
1052 | }
|
---|
1053 |
|
---|
1054 | if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_ACKED &&
|
---|
1055 | (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) == 0) {
|
---|
1056 | tcptsk_free_swbufq(cep);
|
---|
1057 | sel_ix = ix;
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 | /*
|
---|
1061 | * ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããéä¿¡ãçµãã£ã¦ããªãã¨ãã¯ã
|
---|
1062 | * éä¿¡ãäºç´ããã
|
---|
1063 | */
|
---|
1064 | if (cep->flags & TCP_CEP_FLG_POST_OUTPUT &&
|
---|
1065 | (cep->flags & TCP_CEP_FLG_WBCS_MASK) >= TCP_CEP_FLG_WBCS_SENT) {
|
---|
1066 | syscall(wai_sem(cep->semid_lock));
|
---|
1067 | if (cep->swbufq == NULL)
|
---|
1068 | cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
|
---|
1069 | else if (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) {
|
---|
1070 | cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
|
---|
1071 | cep->flags |= TCP_CEP_FLG_RESERVE_OUTPUT;
|
---|
1072 | }
|
---|
1073 | syscall(sig_sem(cep->semid_lock));
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | /*
|
---|
1077 | * éä¿¡äºç´ä¸ã«ããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããéä¿¡ãçµäºãããã
|
---|
1078 | * éä¿¡ãéå§ããããã ããå®å
|
---|
1079 | ¨ã«éä¿¡ãçµäºããã¨ãã¯ä½ãããªãã
|
---|
1080 | */
|
---|
1081 | if (cep->flags & TCP_CEP_FLG_RESERVE_OUTPUT) {
|
---|
1082 | syscall(wai_sem(cep->semid_lock));
|
---|
1083 | if (cep->swbufq != NULL && (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) == 0) {
|
---|
1084 | cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
|
---|
1085 | }
|
---|
1086 | syscall(sig_sem(cep->semid_lock));
|
---|
1087 | cep->flags &= ~TCP_CEP_FLG_RESERVE_OUTPUT;
|
---|
1088 | }
|
---|
1089 |
|
---|
1090 | #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */
|
---|
1091 |
|
---|
1092 | if (cep->flags & TCP_CEP_FLG_POST_OUTPUT) {
|
---|
1093 |
|
---|
1094 | cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
|
---|
1095 |
|
---|
1096 | #ifdef TCP_CFG_NON_BLOCKING
|
---|
1097 |
|
---|
1098 | if (cep->snd_nblk_tfn == TFN_TCP_CON_CEP && cep->myaddr.portno == TCP_PORTANY) {
|
---|
1099 | ER error;
|
---|
1100 |
|
---|
1101 | /*
|
---|
1102 | * tcp_con_cep ã®ãã³ããããã³ã°ã³ã¼ã«ã§ã
|
---|
1103 | * æªå²å½ã®ã®å ´åã¯ããã¼ãçªå·ãå²ãå½ã¦ãã
|
---|
1104 | * p_myaddr ã NADR (-1) ãã
|
---|
1105 | * èªãã¼ãçªå·ã TCP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
|
---|
1106 | */
|
---|
1107 | if (cep->p_myaddr == NADR || cep->p_myaddr->portno == TCP_PORTANY)
|
---|
1108 | tcp_alloc_auto_port(cep);
|
---|
1109 | else if ((error = tcp_alloc_port(cep, cep->p_myaddr->portno)) != E_OK) {
|
---|
1110 |
|
---|
1111 | if (IS_PTR_DEFINED(cep->callback))
|
---|
1112 | #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
|
---|
1113 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
|
---|
1114 | #else
|
---|
1115 | (*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
|
---|
1116 | #endif
|
---|
1117 | else
|
---|
1118 | syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
|
---|
1119 |
|
---|
1120 | /* è¨æ¶ããã¦ããã¿ã¹ã¯ ID 㨠API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
|
---|
1121 | cep->snd_tfn = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
|
---|
1122 | cep->snd_tskid = TA_NULL;
|
---|
1123 | continue;
|
---|
1124 | }
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | #endif /* of #ifdef TCP_CFG_NON_BLOCKING */
|
---|
1128 |
|
---|
1129 | tcp_output(cep);
|
---|
1130 |
|
---|
1131 | if (cep->flags & TCP_CEP_FLG_CLOSE_AFTER_OUTPUT) {
|
---|
1132 | /* ã³ãã¯ã·ã§ã³ãéããã*/
|
---|
1133 | tcp_close(cep);
|
---|
1134 | cep->flags &= ~TCP_CEP_FLG_CLOSE_AFTER_OUTPUT;
|
---|
1135 | }
|
---|
1136 |
|
---|
1137 | if (cep->flags & TCP_CEP_FLG_RESTORE_NEXT_OUTPUT) {
|
---|
1138 | /* snd_nxt ãå
|
---|
1139 | ã«æ»ãã*/
|
---|
1140 | if (SEQ_GT(cep->snd_old_nxt, cep->snd_nxt))
|
---|
1141 | cep->snd_nxt = cep->snd_old_nxt;
|
---|
1142 | cep->flags &= ~TCP_CEP_FLG_RESTORE_NEXT_OUTPUT;
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | sel_ix = ix;
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 | if (++ ix == tmax_tcp_cepid)
|
---|
1149 | ix = 0;
|
---|
1150 | } while (ix != last_ix);
|
---|
1151 |
|
---|
1152 | /* 次åã¯ãå¦çããé信端ç¹ãå¾åãã«ããã*/
|
---|
1153 | last_ix = sel_ix;
|
---|
1154 | }
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | #endif /* of #ifdef SUPPORT_TCP */
|
---|