[331] | 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 | * UDP6 ECHO ã¯ã©ã¤ã¢ã³ã
|
---|
| 48 | */
|
---|
| 49 |
|
---|
| 50 | #include <string.h>
|
---|
| 51 |
|
---|
| 52 | #if defined(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 #if defined(TARGET_KERNEL_ASP) */
|
---|
| 61 |
|
---|
| 62 | #if defined(TARGET_KERNEL_JSP)
|
---|
| 63 |
|
---|
| 64 | #include <t_services.h>
|
---|
| 65 | #include "kernel_id.h"
|
---|
| 66 | #include "tinet_id.h"
|
---|
| 67 |
|
---|
| 68 | #endif /* of #if defined(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/udp4_echo_cli.h>
|
---|
| 76 | #include <netapp/udp6_echo_cli.h>
|
---|
| 77 |
|
---|
| 78 | #if defined(USE_UDP6_ECHO_CLI_TSK)
|
---|
| 79 |
|
---|
| 80 | /* echo ãµã¼ãã®ãã¼ãçªå· */
|
---|
| 81 |
|
---|
| 82 | #define ECHO_SRV_PORTNO UINT_C(7)
|
---|
| 83 |
|
---|
| 84 | /* éä¿¡éé */
|
---|
| 85 |
|
---|
| 86 | #if defined(TOPPERS_S810_CLG3_85)
|
---|
| 87 |
|
---|
| 88 | #define SLP_ITV (30*SYSTIM_HZ)
|
---|
| 89 |
|
---|
| 90 | #else /* of #if defined(TOPPERS_S810_CLG3_85) */
|
---|
| 91 |
|
---|
| 92 | #define SLP_ITV (60*SYSTIM_HZ)
|
---|
| 93 |
|
---|
| 94 | #endif /* of #if defined(TOPPERS_S810_CLG3_85) */
|
---|
| 95 |
|
---|
| 96 | /* èªåå®è¡ */
|
---|
| 97 |
|
---|
| 98 | #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
|
---|
| 99 | #else
|
---|
| 100 | #if 0
|
---|
| 101 | #define UDP6_ECHO_CLI_AUTO_RUN_STR "fe80::211:2fff:fe8a:e8c0 - 1000"
|
---|
| 102 | #endif
|
---|
| 103 | #endif
|
---|
| 104 |
|
---|
| 105 | /*
|
---|
| 106 | * å
|
---|
| 107 | ¨åå¤æ°
|
---|
| 108 | */
|
---|
| 109 |
|
---|
| 110 | bool_t udp6_echo_cli_valid;
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | * å¤æ°
|
---|
| 114 | */
|
---|
| 115 |
|
---|
| 116 | #define BUF_SIZE 2048
|
---|
| 117 |
|
---|
| 118 | static char udp_buf[BUF_SIZE];
|
---|
| 119 | static T_IPV6EP dst;
|
---|
| 120 |
|
---|
| 121 | #if defined(USE_UDP_NON_BLOCKING)
|
---|
| 122 |
|
---|
| 123 | static ER_UINT nblk_len;
|
---|
| 124 | static ID nblk_tskid;
|
---|
| 125 |
|
---|
| 126 | /*
|
---|
| 127 | * ãã³ããããã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
|
---|
| 128 | */
|
---|
| 129 |
|
---|
| 130 | ER
|
---|
| 131 | callback_nblk_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
|
---|
| 132 | {
|
---|
| 133 | nblk_len = *(ER_UINT*)p_parblk;
|
---|
| 134 | syscall(wup_tsk(nblk_tskid));
|
---|
| 135 | return E_OK;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | /*
|
---|
| 139 | * udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ãã³ããããã³ã°ã³ã¼ã«ä½¿ç¨)ã
|
---|
| 140 | */
|
---|
| 141 |
|
---|
| 142 | static ER
|
---|
| 143 | udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
|
---|
| 144 | {
|
---|
| 145 | ER_UINT error;
|
---|
| 146 | SYSTIM time;
|
---|
| 147 | uint_t len;
|
---|
| 148 |
|
---|
| 149 | dst.ipaddr = *ipaddr;
|
---|
| 150 | dst.portno = portno;
|
---|
| 151 | len = strlen(line);
|
---|
| 152 | get_tim(&time);
|
---|
| 153 | get_tid(&nblk_tskid);
|
---|
| 154 | if ((error = udp6_snd_dat(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
|
---|
| 155 | syslog(LOG_NOTICE, "[UEC6:%02u SDN] error: %7lu,%s",
|
---|
| 156 | cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
|
---|
| 157 | return error;
|
---|
| 158 | }
|
---|
| 159 | else
|
---|
| 160 | syslog(LOG_NOTICE, "[UEC6:%02u SDN] send: %7lu, to: %s.%d\n"
|
---|
| 161 | " msg: %s",
|
---|
| 162 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
|
---|
| 163 |
|
---|
| 164 | syscall(slp_tsk());
|
---|
| 165 | get_tim(&time);
|
---|
| 166 | if (nblk_len < 0) { /* 0 以ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
|
---|
| 167 | syslog(LOG_NOTICE, "[UEC6:%02u CBR] error: %7lu,%s",
|
---|
| 168 | cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
|
---|
| 169 | return nblk_len;
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | if ((error = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
|
---|
| 173 | syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
|
---|
| 174 | cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
|
---|
| 175 | return error;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | syscall(slp_tsk());
|
---|
| 179 | get_tim(&time);
|
---|
| 180 | if (nblk_len < 0) { /* 0 以ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
|
---|
| 181 | syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
|
---|
| 182 | cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
|
---|
| 183 | return nblk_len;
|
---|
| 184 | }
|
---|
| 185 | else {
|
---|
| 186 | udp_buf[nblk_len] = '\0';
|
---|
| 187 | get_tim(&time);
|
---|
| 188 | syslog(LOG_NOTICE, "[UEC6:%02u RVN] recv: %7lu,from: %s.%d\n"
|
---|
| 189 | " msg: %s",
|
---|
| 190 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
|
---|
| 191 | nblk_len = E_OK;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | return nblk_len;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | #else /* of #if defined(USE_UDP_NON_BLOCKING) */
|
---|
| 198 |
|
---|
| 199 | #if defined(USE_UDP_CALL_BACK)
|
---|
| 200 |
|
---|
| 201 | /*
|
---|
| 202 | * ã³ã¼ã«ããã¯é¢æ°
|
---|
| 203 | */
|
---|
| 204 |
|
---|
| 205 | ER
|
---|
| 206 | callback_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
|
---|
| 207 | {
|
---|
| 208 | SYSTIM time;
|
---|
| 209 | ER_UINT len;
|
---|
| 210 |
|
---|
| 211 | get_tim(&time);
|
---|
| 212 | if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
|
---|
| 213 | *(udp_buf + len) = '\0';
|
---|
| 214 | syslog(LOG_NOTICE, "[UEC6:%02u RVC)] recv: %7lu,from: %s.%d\n"
|
---|
| 215 | " msg: %s",
|
---|
| 216 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
|
---|
| 217 | }
|
---|
| 218 | else
|
---|
| 219 | syslog(LOG_NOTICE, "[UEC6:%02u RVC] error: %7lu,%s",
|
---|
| 220 | cepid, time / SYSTIM_HZ, itron_strerror(len));
|
---|
| 221 |
|
---|
| 222 | return E_OK;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | /*
|
---|
| 226 | * udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°ä½¿ç¨)ã
|
---|
| 227 | */
|
---|
| 228 |
|
---|
| 229 | static ER
|
---|
| 230 | udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
|
---|
| 231 | {
|
---|
| 232 | SYSTIM time;
|
---|
| 233 | ER_UINT len;
|
---|
| 234 |
|
---|
| 235 | dst.ipaddr = *ipaddr;
|
---|
| 236 | dst.portno = portno;
|
---|
| 237 | len = strlen(line);
|
---|
| 238 | get_tim(&time);
|
---|
| 239 | syslog(LOG_NOTICE, "[UEC6:%02u SDC)] send: %7lu, to: %s.%d\n"
|
---|
| 240 | " msg: %s",
|
---|
| 241 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
|
---|
| 242 | if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0)
|
---|
| 243 | syslog(LOG_NOTICE, "[UEC6:%02u SDC] error: %7lu,%s",
|
---|
| 244 | cepid, time / SYSTIM_HZ, itron_strerror(len));
|
---|
| 245 |
|
---|
| 246 | return E_OK;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | #else /* of #if defined(USE_UDP_CALL_BACK) */
|
---|
| 250 |
|
---|
| 251 | /*
|
---|
| 252 | * udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°æªä½¿ç¨)ã
|
---|
| 253 | */
|
---|
| 254 |
|
---|
| 255 | static ER
|
---|
| 256 | udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
|
---|
| 257 | {
|
---|
| 258 | SYSTIM time;
|
---|
| 259 | ER_UINT len;
|
---|
| 260 |
|
---|
| 261 | dst.ipaddr = *ipaddr;
|
---|
| 262 | dst.portno = portno;
|
---|
| 263 | len = strlen(line);
|
---|
| 264 | get_tim(&time);
|
---|
| 265 | syslog(LOG_NOTICE, "[UEC6:%02u SND] send: %7lu, to: %s.%d\n"
|
---|
| 266 | " msg: %s",
|
---|
| 267 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
|
---|
| 268 | if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0) {
|
---|
| 269 | syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
|
---|
| 270 | cepid, time / SYSTIM_HZ, itron_strerror(len));
|
---|
| 271 | return len;
|
---|
| 272 | }
|
---|
| 273 |
|
---|
| 274 | if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
|
---|
| 275 | *(udp_buf + len) = '\0';
|
---|
| 276 | get_tim(&time);
|
---|
| 277 | syslog(LOG_NOTICE, "[UEC6:%02u RCV] recv: %7lu,from: %s.%d\n"
|
---|
| 278 | " msg: %s",
|
---|
| 279 | cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
|
---|
| 280 | return E_OK;
|
---|
| 281 | }
|
---|
| 282 | else {
|
---|
| 283 | get_tim(&time);
|
---|
| 284 | syslog(LOG_NOTICE, "[UEC6:%02u RCV] error: %7lu,%s",
|
---|
| 285 | cepid, time / SYSTIM_HZ, itron_strerror(len));
|
---|
| 286 | return len;
|
---|
| 287 | }
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | #endif /* of #if defined(USE_UDP_CALL_BACK) */
|
---|
| 291 |
|
---|
| 292 | #endif /* of #if defined(USE_UDP_NON_BLOCKING) */
|
---|
| 293 |
|
---|
| 294 | /*
|
---|
| 295 | * getcomd -- ã³ãã³ããå¾ãã
|
---|
| 296 | */
|
---|
| 297 |
|
---|
| 298 | #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
|
---|
| 299 |
|
---|
| 300 | static char *
|
---|
| 301 | getcomd (ID cepid, bool_t retry)
|
---|
| 302 | {
|
---|
| 303 | ER error;
|
---|
| 304 | char *line = NULL;
|
---|
| 305 | static char auto_run_str[] = UDP6_ECHO_CLI_AUTO_RUN_STR;
|
---|
| 306 | static int_t count = 0;
|
---|
| 307 |
|
---|
| 308 | if (retry || count == 0) {
|
---|
| 309 | line = auto_run_str;
|
---|
| 310 | dly_tsk(6 * 1000);
|
---|
| 311 | }
|
---|
| 312 | else {
|
---|
| 313 | while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
|
---|
| 314 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
|
---|
| 315 | dly_tsk(SLP_ITV);
|
---|
| 316 | }
|
---|
| 317 | }
|
---|
| 318 |
|
---|
| 319 | count ++;
|
---|
| 320 | return line;
|
---|
| 321 | }
|
---|
| 322 |
|
---|
| 323 | #else /* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
|
---|
| 324 |
|
---|
| 325 | static char *
|
---|
| 326 | getcomd (ID cepid, bool_t retry)
|
---|
| 327 | {
|
---|
| 328 | ER error;
|
---|
| 329 | char *line = NULL;
|
---|
| 330 |
|
---|
| 331 | while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
|
---|
| 332 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
|
---|
| 333 | dly_tsk(SLP_ITV);
|
---|
| 334 | }
|
---|
| 335 | return line;
|
---|
| 336 | }
|
---|
| 337 |
|
---|
| 338 | #endif /* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
|
---|
| 339 |
|
---|
| 340 | #define MESSAGE_FORMAT "MSG 1000000"
|
---|
| 341 |
|
---|
| 342 | /*
|
---|
| 343 | * UDP6 ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
|
---|
| 344 | */
|
---|
| 345 |
|
---|
| 346 | void
|
---|
| 347 | udp6_echo_cli_task (intptr_t exinf)
|
---|
| 348 | {
|
---|
| 349 | static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
|
---|
| 350 |
|
---|
| 351 | ID tskid, cepid;
|
---|
| 352 | ER error = E_OK;
|
---|
| 353 | SYSTIM time;
|
---|
| 354 | T_IN6_ADDR addr;
|
---|
| 355 | char *line, *p;
|
---|
| 356 | int_t rep;
|
---|
| 357 | uint32_t count, msgno;
|
---|
| 358 | bool_t retry = false;
|
---|
| 359 | uint16_t portno = ECHO_SRV_PORTNO;
|
---|
| 360 |
|
---|
| 361 | #if defined(USE_UDP_EXTENTIONS)
|
---|
| 362 | T_UDP6_CCEP ccep;
|
---|
| 363 | #endif
|
---|
| 364 |
|
---|
| 365 | dly_tsk(10*1000);
|
---|
| 366 | get_tid(&tskid);
|
---|
| 367 | syslog(LOG_NOTICE, "[UDP6 ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
|
---|
| 368 | while (true) {
|
---|
| 369 | line = skip_blanks(getcomd((ID)exinf, retry));
|
---|
| 370 |
|
---|
| 371 | if ((line = lookup_ipaddr(&addr, line, API_PROTO_IPV6)) == NULL) {
|
---|
| 372 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] sleep %d.%03u[s], unknown host.",
|
---|
| 373 | (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
|
---|
| 374 | dly_tsk(SLP_ITV);
|
---|
| 375 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] resume.", (ID)exinf);
|
---|
| 376 | retry = true;
|
---|
| 377 | continue;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | line = skip_blanks(line);
|
---|
| 381 | if ('0' <= *line && *line <= '9') { /* Port No */
|
---|
| 382 | line = get_int(&rep, line);
|
---|
| 383 | portno = (uint16_t)rep;
|
---|
| 384 | }
|
---|
| 385 | else if (*line == '-')
|
---|
| 386 | line ++;
|
---|
| 387 |
|
---|
| 388 | #if defined(USE_UDP_EXTENTIONS)
|
---|
| 389 |
|
---|
| 390 | ccep.cepatr = UINT_C(0);
|
---|
| 391 | ccep.myaddr.portno = UDP_PORTANY;
|
---|
| 392 | memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
|
---|
| 393 |
|
---|
| 394 | #ifdef USE_UDP_NON_BLOCKING
|
---|
| 395 | ccep.callback = (FP)callback_nblk_udp6_echo_cli;
|
---|
| 396 | #else
|
---|
| 397 | ccep.callback = NULL;
|
---|
| 398 | #endif
|
---|
| 399 |
|
---|
| 400 | if ((error = alloc_udp6_cep(&cepid, tskid, &ccep)) != E_OK) {
|
---|
| 401 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
|
---|
| 402 | continue;
|
---|
| 403 | }
|
---|
| 404 |
|
---|
| 405 | #else/* of #ifdef USE_UDP_EXTENTIONS */
|
---|
| 406 |
|
---|
| 407 | cepid = (ID)exinf;
|
---|
| 408 |
|
---|
| 409 | #endif /* of #if defined(USE_UDP_EXTENTIONS) */
|
---|
| 410 |
|
---|
| 411 | line = skip_blanks(line);
|
---|
| 412 | if ('0' <= *line && *line <= '9') { /* Repeat */
|
---|
| 413 | line = get_int(&rep, line);
|
---|
| 414 | #if 0
|
---|
| 415 | if (rep > 1000000)
|
---|
| 416 | rep = 1000000;
|
---|
| 417 | #endif
|
---|
| 418 | udp6_echo_cli_valid = true;
|
---|
| 419 | count = 0;
|
---|
| 420 | while (rep == 0 || count < rep) {
|
---|
| 421 | if (!udp6_echo_cli_valid) {
|
---|
| 422 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] canceled.", cepid);
|
---|
| 423 | break;
|
---|
| 424 | }
|
---|
| 425 |
|
---|
| 426 | count ++;
|
---|
| 427 | p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
|
---|
| 428 | for (msgno = count; msgno > 0; msgno /= 10)
|
---|
| 429 | *(-- p) = msgno % 10 + '0';
|
---|
| 430 | while (*(p - 2) != 'G')
|
---|
| 431 | *(-- p) = ' ';
|
---|
| 432 |
|
---|
| 433 | if ((error = udp6_echo_cli(cepid, &addr, portno, msg)) != E_OK)
|
---|
| 434 | dly_tsk(30 * SYSTIM_HZ);
|
---|
| 435 |
|
---|
| 436 | dly_tsk(25 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
|
---|
| 437 | }
|
---|
| 438 | }
|
---|
| 439 |
|
---|
| 440 | else /* Single Message */
|
---|
| 441 |
|
---|
| 442 | error = udp6_echo_cli(cepid, &addr, portno, line);
|
---|
| 443 |
|
---|
| 444 | if (error != E_OK) {
|
---|
| 445 | get_tim(&time);
|
---|
| 446 | syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
|
---|
| 447 | cepid, time / SYSTIM_HZ, itron_strerror(error));
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 | #if defined(USE_UDP_EXTENTIONS)
|
---|
| 451 |
|
---|
| 452 | if ((error = free_udp6_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
|
---|
| 453 | syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
|
---|
| 454 |
|
---|
| 455 | #endif /* of #if defined(USE_UDP_EXTENTIONS) */
|
---|
| 456 |
|
---|
| 457 | }
|
---|
| 458 | }
|
---|
| 459 |
|
---|
| 460 | #endif /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
|
---|