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$
|
---|
44 | */
|
---|
45 |
|
---|
46 | /*
|
---|
47 | * TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
|
---|
48 | */
|
---|
49 |
|
---|
50 | #include <stdlib.h>
|
---|
51 |
|
---|
52 | #ifdef TARGET_KERNEL_ASP
|
---|
53 |
|
---|
54 | #include <kernel.h>
|
---|
55 | #include <sil.h>
|
---|
56 | #include <t_syslog.h>
|
---|
57 | #include "kernel_cfg.h"
|
---|
58 | #include "tinet_cfg.h"
|
---|
59 |
|
---|
60 | #endif /* of #ifdef TARGET_KERNEL_ASP */
|
---|
61 |
|
---|
62 | #ifdef TARGET_KERNEL_JSP
|
---|
63 |
|
---|
64 | #include <t_services.h>
|
---|
65 | #include "kernel_id.h"
|
---|
66 | #include "tinet_id.h"
|
---|
67 |
|
---|
68 | #endif /* of #ifdef TARGET_KERNEL_JSP */
|
---|
69 |
|
---|
70 | #include <netinet/in.h>
|
---|
71 | #include <netinet/in_itron.h>
|
---|
72 |
|
---|
73 | #include <netapp/netapp.h>
|
---|
74 | #include <netapp/netapp_var.h>
|
---|
75 | #include <netapp/tcp_echo_cli.h>
|
---|
76 |
|
---|
77 | #ifdef USE_TCP_ECHO_CLI
|
---|
78 |
|
---|
79 | /* 表示 */
|
---|
80 |
|
---|
81 | //#define SHOW_TIME_OUT
|
---|
82 | //#define SHOW_RCV_RANGE
|
---|
83 |
|
---|
84 | /* ã¿ã¤ã ã¢ã¦ã */
|
---|
85 |
|
---|
86 | #ifdef TOPPERS_S810_CLG3_85
|
---|
87 |
|
---|
88 | #define CLS_TMO TMO_FEVR /* Close Wait ã¯æ¨æºã§ 60ç§ */
|
---|
89 | //#define RCV_TMO TMO_FEVR
|
---|
90 | #define RCV_TMO (30*SYSTIM_HZ)
|
---|
91 |
|
---|
92 | #else /* of #ifdef TOPPERS_S810_CLG3_85 */
|
---|
93 |
|
---|
94 | //#define CLS_TMO TMO_FEVR /* Close Wait ã¯æ¨æºã§ 60ç§ */
|
---|
95 | #define CLS_TMO (70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
|
---|
96 | //#define RCV_TMO TMO_FEVR
|
---|
97 | #define RCV_TMO (40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
|
---|
98 |
|
---|
99 | #endif /* of #ifdef TOPPERS_S810_CLG3_85 */
|
---|
100 |
|
---|
101 | /*
|
---|
102 | * API IPãããã³ã«ã®æå®
|
---|
103 | */
|
---|
104 |
|
---|
105 | #undef DEFAULT_API_PROTO
|
---|
106 |
|
---|
107 | #if defined(SUPPORT_INET6)
|
---|
108 | #if defined(SUPPORT_INET4)
|
---|
109 | #define DEFAULT_API_PROTO API_PROTO_IPVn
|
---|
110 | #else
|
---|
111 | #define DEFAULT_API_PROTO API_PROTO_IPV6
|
---|
112 | #endif
|
---|
113 | #else
|
---|
114 | #define DEFAULT_API_PROTO API_PROTO_IPV4
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | /*
|
---|
118 | * TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
|
---|
119 | */
|
---|
120 |
|
---|
121 | #ifdef USE_TCP_NON_BLOCKING
|
---|
122 |
|
---|
123 | #ifdef USE_COPYSAVE_API
|
---|
124 |
|
---|
125 | void
|
---|
126 | tcp_echo_cli_rcv_task (intptr_t exinf)
|
---|
127 | {
|
---|
128 | ID tskid, cepid;
|
---|
129 | ER error;
|
---|
130 | SYSTIM time;
|
---|
131 | uint32_t total, rcount;
|
---|
132 | uint16_t roff, rlen;
|
---|
133 | char *rmsg, head, tail, apip = DEFAULT_API_PROTO;
|
---|
134 |
|
---|
135 | get_tid(&tskid);
|
---|
136 | syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK,CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
|
---|
137 | while (true) {
|
---|
138 | if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
|
---|
139 | syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
|
---|
140 | DEFAULT_API_PROTO, cepid, itron_strerror(error));
|
---|
141 | }
|
---|
142 | else {
|
---|
143 |
|
---|
144 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
|
---|
145 |
|
---|
146 | #ifdef USE_TCP_EXTENTIONS
|
---|
147 |
|
---|
148 | apip = API_PROTO_IPVn;
|
---|
149 |
|
---|
150 | #else /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
151 |
|
---|
152 | if (cepid == TCP4_ECHO_CLI_CEPID)
|
---|
153 | apip = API_PROTO_IPV4;
|
---|
154 | else
|
---|
155 | apip = API_PROTO_IPV6;
|
---|
156 |
|
---|
157 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
158 |
|
---|
159 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
|
---|
160 |
|
---|
161 | roff = rcount = total = 0;
|
---|
162 | while (true) {
|
---|
163 | if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {
|
---|
164 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
|
---|
165 | break;
|
---|
166 | }
|
---|
167 |
|
---|
168 | /* åä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
|
---|
169 | ã¤ã*/
|
---|
170 | syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
|
---|
171 | if (tcp_echo_cli_nblk_error < 0)
|
---|
172 | break;
|
---|
173 |
|
---|
174 | rlen = tcp_echo_cli_nblk_error;
|
---|
175 | head = *rmsg;
|
---|
176 | tail = *(rmsg + rlen - 1);
|
---|
177 | if (rlen > 0) {
|
---|
178 | roff += rlen;
|
---|
179 | total += rlen;
|
---|
180 | rcount ++;
|
---|
181 | #ifdef SHOW_RCV_RANGE
|
---|
182 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
|
---|
183 | "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
|
---|
184 | apip, cepid, rcount, rlen, roff, head, tail);
|
---|
185 | #endif /* of #ifdef SHOW_RCV_RANGE */
|
---|
186 | }
|
---|
187 | else
|
---|
188 | break;
|
---|
189 |
|
---|
190 | if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
|
---|
191 | syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s",
|
---|
192 | apip, cepid, itron_strerror(error));
|
---|
193 | }
|
---|
194 |
|
---|
195 | if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
|
---|
196 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
|
---|
197 |
|
---|
198 | /* åæãå®äºããã¾ã§å¾
|
---|
199 | ã¤ã*/
|
---|
200 | syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
|
---|
201 |
|
---|
202 | get_tim(&time);
|
---|
203 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
|
---|
204 | apip, cepid, time / SYSTIM_HZ, total);
|
---|
205 | }
|
---|
206 |
|
---|
207 | syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
|
---|
208 | }
|
---|
209 | }
|
---|
210 |
|
---|
211 | #else /* of #ifdef USE_COPYSAVE_API */
|
---|
212 |
|
---|
213 | void
|
---|
214 | tcp_echo_cli_rcv_task (intptr_t exinf)
|
---|
215 | {
|
---|
216 | static char rmsg[RCV_BUF_SIZE];
|
---|
217 |
|
---|
218 | ID tskid, cepid;
|
---|
219 | ER error;
|
---|
220 | SYSTIM time;
|
---|
221 | uint32_t total, rcount;
|
---|
222 | uint16_t roff, rlen;
|
---|
223 | char head, tail, apip = DEFAULT_API_PROTO;
|
---|
224 |
|
---|
225 | get_tid(&tskid);
|
---|
226 | syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
|
---|
227 | while (true) {
|
---|
228 | if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
|
---|
229 | syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
|
---|
230 | DEFAULT_API_PROTO, cepid, itron_strerror(error));
|
---|
231 | }
|
---|
232 | else {
|
---|
233 |
|
---|
234 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
|
---|
235 |
|
---|
236 | if (cepid == TCP4_ECHO_CLI_CEPID)
|
---|
237 | apip = API_PROTO_IPV4;
|
---|
238 | else
|
---|
239 | apip = API_PROTO_IPV6;
|
---|
240 |
|
---|
241 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
|
---|
242 |
|
---|
243 | roff = rcount = total = 0;
|
---|
244 | while (true) {
|
---|
245 | if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {
|
---|
246 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
|
---|
247 | break;
|
---|
248 | }
|
---|
249 |
|
---|
250 | /* åä¿¡ãå®äºããã¾ã§å¾
|
---|
251 | ã¤ã*/
|
---|
252 | syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
|
---|
253 | if (tcp_echo_cli_nblk_error < 0)
|
---|
254 | break;
|
---|
255 |
|
---|
256 | rlen = tcp_echo_cli_nblk_error;
|
---|
257 | head = *rmsg;
|
---|
258 | tail = *(rmsg + rlen - 1);
|
---|
259 | rcount ++;
|
---|
260 | if (rlen > 0) {
|
---|
261 | roff += rlen;
|
---|
262 | total += rlen;
|
---|
263 | #ifdef SHOW_RCV_RANGE
|
---|
264 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
|
---|
265 | "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
|
---|
266 | apip, cepid, rcount, rlen, roff, head, tail);
|
---|
267 | #endif /* of #ifdef SHOW_RCV_RANGE */
|
---|
268 | }
|
---|
269 | else
|
---|
270 | break;
|
---|
271 | }
|
---|
272 |
|
---|
273 | if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
|
---|
274 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
|
---|
275 |
|
---|
276 | /* åæãå®äºããã¾ã§å¾
|
---|
277 | ã¤ã*/
|
---|
278 | syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
|
---|
279 |
|
---|
280 | get_tim(&time);
|
---|
281 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
|
---|
282 | apip, cepid, time / SYSTIM_HZ, total);
|
---|
283 | }
|
---|
284 |
|
---|
285 | syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
|
---|
286 | }
|
---|
287 | }
|
---|
288 |
|
---|
289 | #endif /* of #ifdef USE_COPYSAVE_API */
|
---|
290 |
|
---|
291 | #else /* of #ifdef USE_TCP_NON_BLOCKING */
|
---|
292 |
|
---|
293 | #ifdef USE_COPYSAVE_API
|
---|
294 |
|
---|
295 | void
|
---|
296 | tcp_echo_cli_rcv_task (intptr_t exinf)
|
---|
297 | {
|
---|
298 | ID tskid, cepid;
|
---|
299 | ER_UINT rlen;
|
---|
300 | ER error;
|
---|
301 | SYSTIM time, tmo;
|
---|
302 | uint32_t total = 0, rcount;
|
---|
303 | uint16_t roff;
|
---|
304 | char *rmsg, apip = DEFAULT_API_PROTO;
|
---|
305 |
|
---|
306 | get_tid(&tskid);
|
---|
307 | syslog(LOG_NOTICE, "[TCP%c ECHO CLI (CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
|
---|
308 | while (true) {
|
---|
309 | if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
|
---|
310 | syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
|
---|
311 | DEFAULT_API_PROTO, cepid, itron_strerror(error));
|
---|
312 |
|
---|
313 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
|
---|
314 |
|
---|
315 | #ifdef USE_TCP_EXTENTIONS
|
---|
316 |
|
---|
317 | if (tcp6_is_cepid(cepid))
|
---|
318 | apip = API_PROTO_IPV6;
|
---|
319 | else
|
---|
320 | apip = API_PROTO_IPV4;
|
---|
321 |
|
---|
322 | #else /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
323 |
|
---|
324 | if (cepid == TCP4_ECHO_CLI_CEPID)
|
---|
325 | apip = API_PROTO_IPV4;
|
---|
326 | else
|
---|
327 | apip = API_PROTO_IPV6;
|
---|
328 |
|
---|
329 | #endif /* of #ifdef USE_TCP_EXTENTIONS */
|
---|
330 |
|
---|
331 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
|
---|
332 |
|
---|
333 | }
|
---|
334 | else {
|
---|
335 | roff = rcount = total = 0;
|
---|
336 | while (true) {
|
---|
337 | tmo = RCV_TMO;
|
---|
338 | #ifdef SHOW_TIME_OUT
|
---|
339 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo: %7lu", apip, cepid, tmo);;
|
---|
340 | #endif /* of #ifdef SHOW_TIME_OUT */
|
---|
341 | if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, tmo)) < 0) {
|
---|
342 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s",
|
---|
343 | apip, cepid, itron_strerror(rlen));
|
---|
344 | break;
|
---|
345 | }
|
---|
346 | else if (rlen > 0) {
|
---|
347 | roff += (uint16_t)rlen;
|
---|
348 | total += rlen;
|
---|
349 | rcount ++;
|
---|
350 | #ifdef SHOW_RCV_RANGE
|
---|
351 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
|
---|
352 | apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
|
---|
353 | #endif /* of #ifdef SHOW_RCV_RANGE */
|
---|
354 | }
|
---|
355 | else
|
---|
356 | break;
|
---|
357 | if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
|
---|
358 | syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s", apip, cepid, itron_strerror(error));
|
---|
359 | }
|
---|
360 |
|
---|
361 | tmo = CLS_TMO;
|
---|
362 | #ifdef SHOW_TIME_OUT
|
---|
363 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo: %7lu", apip, cepid, tmo);;
|
---|
364 | #endif /* of #ifdef SHOW_TIME_OUT */
|
---|
365 | if ((error = tcp_cls_cep(cepid, tmo)) < 0)
|
---|
366 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
|
---|
367 |
|
---|
368 | get_tim(&time);
|
---|
369 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
|
---|
370 | apip, cepid, time / SYSTIM_HZ, total);
|
---|
371 | }
|
---|
372 |
|
---|
373 | syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
|
---|
374 | }
|
---|
375 | }
|
---|
376 |
|
---|
377 | #else /* of #ifdef USE_COPYSAVE_API */
|
---|
378 |
|
---|
379 | void
|
---|
380 | tcp_echo_cli_rcv_task (intptr_t exinf)
|
---|
381 | {
|
---|
382 | static char rmsg[RCV_BUF_SIZE];
|
---|
383 |
|
---|
384 | ID tskid, cepid;
|
---|
385 | ER_UINT rlen;
|
---|
386 | ER error;
|
---|
387 | SYSTIM time, tmo;
|
---|
388 | uint32_t total, rcount;
|
---|
389 | uint16_t roff;
|
---|
390 | char apip = DEFAULT_API_PROTO;
|
---|
391 |
|
---|
392 | get_tid(&tskid);
|
---|
393 | syslog(LOG_NOTICE, "[TCP%c ECHO CLI RCV:%d] started.", DEFAULT_API_PROTO, tskid);
|
---|
394 | while (true) {
|
---|
395 | if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
|
---|
396 | syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
|
---|
397 | DEFAULT_API_PROTO, cepid, itron_strerror(error));
|
---|
398 | }
|
---|
399 | else {
|
---|
400 |
|
---|
401 | #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
|
---|
402 |
|
---|
403 | if (cepid == TCP4_ECHO_CLI_CEPID)
|
---|
404 | apip = API_PROTO_IPV4;
|
---|
405 | else
|
---|
406 | apip = API_PROTO_IPV6;
|
---|
407 |
|
---|
408 | #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
|
---|
409 |
|
---|
410 | roff = rcount = total = 0;
|
---|
411 | while (true) {
|
---|
412 | #ifdef SHOW_TIME_OUT
|
---|
413 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo: %7lu", apip, cepid, tmo);;
|
---|
414 | #endif /* of #ifdef SHOW_TIME_OUT */
|
---|
415 | tmo = RCV_TMO;
|
---|
416 | if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), tmo)) < 0) {
|
---|
417 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(rlen));
|
---|
418 | tcp_can_cep(cepid, TFN_TCP_ALL);
|
---|
419 | break;
|
---|
420 | }
|
---|
421 | else if (rlen > 0) {
|
---|
422 | roff += (uint16_t)rlen;
|
---|
423 | total += rlen;
|
---|
424 | rcount ++;
|
---|
425 | #ifdef SHOW_RCV_RANGE
|
---|
426 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
|
---|
427 | apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
|
---|
428 | #endif /* of #ifdef SHOW_RCV_RANGE */
|
---|
429 | }
|
---|
430 | else
|
---|
431 | break;
|
---|
432 | }
|
---|
433 |
|
---|
434 | #ifdef SHOW_TIME_OUT
|
---|
435 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo: %7lu", apip, cepid, tmo);;
|
---|
436 | #endif /* of #ifdef SHOW_TIME_OUT */
|
---|
437 | tmo = CLS_TMO;
|
---|
438 | if ((error = tcp_cls_cep(cepid, tmo)) < 0)
|
---|
439 | syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
|
---|
440 |
|
---|
441 | get_tim(&time);
|
---|
442 | syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
|
---|
443 | apip, cepid, time / SYSTIM_HZ, total);
|
---|
444 | }
|
---|
445 |
|
---|
446 | syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
|
---|
447 | }
|
---|
448 | }
|
---|
449 |
|
---|
450 | #endif /* of #ifdef USE_COPYSAVE_API */
|
---|
451 |
|
---|
452 | #endif /* of #ifdef USE_TCP_NON_BLOCKING */
|
---|
453 |
|
---|
454 | #endif /* of #ifdef USE_TCP_ECHO_CLI */
|
---|