Changeset 331 for EcnlProtoTool/trunk/asp3_dcre/tinet/netapp
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp
- Files:
-
- 59 added
- 9 deleted
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp
r321 r331 2 2 # TINET (TCP/IP Protocol Stack) 3 3 # 4 # Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 # Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 # Tomakomai National College of Technology, JAPAN 6 6 # … … 50 50 51 51 TINET_ROOT = $(SRCDIR)/tinet 52 NETAPP_DIR = $(TINET_ROOT)/netapp52 NETAPP_DIRS = $(TINET_ROOT)/netapp 53 53 NETAPP_COBJS := $(NETAPP_COBJS) netapp_subr.o 54 54 55 ifeq ($(USE_LCD),true) 56 57 NETAPP_COBJS := $(NETAPP_COBJS) lcd.o 58 59 ifeq ($(TARGET_KERNEL),ASP) 60 NETAPP_COBJS := $(NETAPP_COBJS) target_lcd.o sc1602.o 61 endif 62 63 ifeq ($(TARGET_KERNEL),JSP) 64 NETAPP_COBJS := $(NETAPP_COBJS) hw_lcd.o sc1602.o 65 endif 66 67 endif 68 55 69 # トランスポート層の選択 56 70 57 SUPPORT_TCP = false58 SUPPORT_UDP = false71 #SUPPORT_TCP = false 72 #SUPPORT_UDP = false 59 73 60 74 # … … 62 76 # 63 77 78 ifeq ($(USE_WWW4_SRV),true) 79 USE_WWW_SRV = true 80 CDEFS := $(CDEFS) -DUSE_WWW4_SRV 81 endif 82 64 83 ifeq ($(USE_WWW_SRV),true) 65 SUPPORT_TCP = true 66 TCP_CFG_PASSIVE_OPEN= true84 85 SUPPORT_TCP = true 67 86 USE_NETAPP_SUBR = true 68 87 CDEFS := $(CDEFS) -DUSE_WWW_SRV 69 88 NETAPP_COBJS := $(NETAPP_COBJS) wwws.o 70 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/wwws.cfg 89 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/wwws.cfg 90 91 endif 92 93 ifeq ($(USE_TCP4_ECHO_SRV),true) 94 TCP_ECHO_SRV = tcp_echo_srv1 95 CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_SRV 71 96 endif 72 97 73 98 ifeq ($(TCP_ECHO_SRV),tcp_echo_srv1) # 送受信タスク同一型 74 SUPPORT_TCP = true 75 TCP_CFG_PASSIVE_OPEN= true99 100 SUPPORT_TCP = true 76 101 USE_NETAPP_SUBR = true 77 102 CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV1 78 103 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1.o 79 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv1.cfg 104 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv1.cfg 105 106 ifeq ($(USE_TCP_NON_BLOCKING),true) 107 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_nblk.o 108 endif 109 110 ifeq ($(USE_TCP_EXTENTIONS),true) 111 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_ext.o 112 endif 113 80 114 endif 81 115 82 116 ifeq ($(TCP_ECHO_SRV),tcp_echo_srv2) # 送受信タスク分離型 83 117 SUPPORT_TCP = true 84 TCP_CFG_PASSIVE_OPEN = true85 118 USE_NETAPP_SUBR = true 86 119 CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV2 87 120 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv2.o 88 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv2.cfg 121 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv2.cfg 122 endif 123 124 ifeq ($(USE_UDP4_ECHO_SRV),true) 125 USE_UDP_ECHO_SRV = true 89 126 endif 90 127 91 128 ifeq ($(USE_UDP_ECHO_SRV),true) 92 SUPPORT_UDP = true 93 USE_NETAPP_SUBR = true 129 94 130 CDEFS := $(CDEFS) -DUSE_UDP_ECHO_SRV 95 NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_srv.o 96 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_srv.cfg 131 132 ifeq ($(SUPPORT_INET6),true) 133 SUPPORT_UDP = true 134 USE_NETAPP_SUBR = true 135 CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_SRV_TSK 136 NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_srv.o 137 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_srv.cfg 138 139 ifeq ($(SUPPORT_INET4),true) 140 ifeq ($(USE_UDP4_ECHO_SRV),true) 141 CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK 142 NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o 143 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg 144 endif 145 endif 146 else 147 ifeq ($(SUPPORT_INET4),true) 148 SUPPORT_UDP = true 149 USE_NETAPP_SUBR = true 150 CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK 151 NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o 152 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg 153 endif 154 endif 155 endif 156 157 158 ifeq ($(USE_TCP4_ECHO_CLI),true) 159 USE_TCP_ECHO_CLI = true 160 CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_CLI 97 161 endif 98 162 … … 101 165 USE_NETAPP_SUBR = true 102 166 CDEFS := $(CDEFS) -DUSE_TCP_ECHO_CLI 103 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o 104 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_cli.cfg 167 NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o tcp_echo_cli_snd.o tcp_echo_cli_rcv.o 168 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_cli.cfg 169 endif 170 171 ifeq ($(USE_UDP4_ECHO_CLI),true) 172 USE_UDP_ECHO_CLI = true 105 173 endif 106 174 107 175 ifeq ($(USE_UDP_ECHO_CLI),true) 108 SUPPORT_UDP = true 109 USE_NETAPP_SUBR = true 176 110 177 CDEFS := $(CDEFS) -DUSE_UDP_ECHO_CLI 111 NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_cli.o 112 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_cli.cfg 178 179 ifeq ($(SUPPORT_INET6),true) 180 SUPPORT_UDP = true 181 USE_NETAPP_SUBR = true 182 CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_CLI_TSK 183 NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o 184 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg 185 186 ifeq ($(SUPPORT_INET4),true) 187 ifeq ($(USE_UDP4_ECHO_CLI),true) 188 CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK 189 NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o 190 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg 191 endif 192 endif 193 else 194 ifeq ($(SUPPORT_INET4),true) 195 SUPPORT_UDP = true 196 USE_NETAPP_SUBR = true 197 CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK 198 NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o 199 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg 200 endif 201 202 endif 113 203 endif 114 204 115 205 ifeq ($(USE_TCP_DISCARD_SRV),true) 116 206 SUPPORT_TCP = true 117 TCP_CFG_PASSIVE_OPEN = true118 207 USE_NETAPP_SUBR = true 119 208 CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_SRV 120 209 NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_srv.o 121 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR )/tcp_discard_srv.cfg210 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_srv.cfg 122 211 endif 123 212 … … 127 216 CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_CLI 128 217 NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_cli.o 129 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR )/tcp_discard_cli.cfg218 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_cli.cfg 130 219 endif 131 220 … … 135 224 CDEFS := $(CDEFS) -DUSE_UDP_DISCARD_CLI 136 225 NETAPP_COBJS := $(NETAPP_COBJS) udp_discard_cli.o 137 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR )/udp_discard_cli.cfg226 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp_discard_cli.cfg 138 227 endif 139 228 … … 141 230 ifeq ($(TCP_CFG_NON_BLOCKING),true) 142 231 SUPPORT_TCP = true 143 TCP_CFG_PASSIVE_OPEN = true144 232 USE_DBG_CONS = true 145 233 USE_NETAPP_SUBR = true 146 234 CDEFS := $(CDEFS) -DUSE_NET_CONS 147 235 NETAPP_COBJS := $(NETAPP_COBJS) net_cons.o 148 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR )/net_cons.cfg236 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/net_cons.cfg 149 237 endif 150 238 endif 151 239 152 240 ifeq ($(USE_DBG_CONS),true) 153 154 241 USE_NETAPP_SUBR = true 155 242 CDEFS := $(CDEFS) -DUSE_DBG_CONS 156 243 NETAPP_COBJS := $(NETAPP_COBJS) dbg_cons.o 157 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/dbg_cons.cfg 158 244 NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/dbg_cons.cfg 245 ifeq ($(USE_DBG_CONS_PARSER),true) 246 CDEFS := $(CDEFS) -DUSE_DBG_CONS_PARSER 247 endif 248 ifeq ($(USE_DBG_CONS_EXTRA_PARSE),true) 249 CDEFS := $(CDEFS) -DUSE_DBG_CONS_EXTRA_PARSE 250 endif 159 251 endif 160 252 161 253 ifeq ($(USE_PING),true) 162 163 254 USE_NETAPP_SUBR = true 164 255 CDEFS := $(CDEFS) -DUSE_PING 165 166 256 ifeq ($(SUPPORT_INET4),true) 167 168 257 NETAPP_COBJS := $(NETAPP_COBJS) ping.o 169 258 endif 170 171 259 ifeq ($(SUPPORT_INET6),true) 172 173 260 NETAPP_COBJS := $(NETAPP_COBJS) ping6.o 174 261 endif 175 262 endif 263 264 ifeq ($(USE_RESOLVER),true) 265 SUPPORT_UDP = true 266 CDEFS := $(CDEFS) -DUSE_RESOLVER 267 NETAPP_COBJS := $(NETAPP_COBJS) resolver.o 268 269 endif 270 271 ifeq ($(USE_DHCP6_CLI),true) 272 ifeq ($(SUPPORT_INET6),true) 273 SUPPORT_UDP = true 274 UDP_CFG_NON_BLOCKING = true 275 USE_UDP_NON_BLOCKING = true 276 CDEFS := $(CDEFS) -DDHCP6_CLI_CFG 277 NETAPP_COBJS := $(NETAPP_COBJS) dhcp6_cli.o 278 endif 279 endif 280 281 ifeq ($(USE_DHCP4_CLI),true) 282 ifeq ($(SUPPORT_INET4),true) 283 SUPPORT_UDP = true 284 UDP_CFG_NON_BLOCKING = true 285 USE_UDP_NON_BLOCKING = true 286 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG 287 NETAPP_COBJS := $(NETAPP_COBJS) dhcp4_cli.o 288 endif 176 289 endif 177 290 … … 180 293 endif 181 294 295 ifeq ($(API_CFG_IP4MAPPED_ADDR),true) 296 CDEFS := $(CDEFS) -DAPI_CFG_IP4MAPPED_ADDR 297 endif 298 182 299 ifeq ($(USE_COPYSAVE_API),true) 183 300 CDEFS := $(CDEFS) -DUSE_COPYSAVE_API 184 endif185 186 ifndef TCP_CFG_PASSIVE_OPEN187 CDEFS := $(CDEFS) -DUNDEF_TCP_CFG_PASSIVE_OPEN188 301 endif 189 302 … … 241 354 endif 242 355 356 ifeq ($(USE_LCD),true) 357 CDEFS := $(CDEFS) -DUSE_LCD 358 endif 359 243 360 # 244 361 # アプリケーションプログラムに関する定義への追加 … … 247 364 ifeq ($(TARGET_KERNEL),ASP) 248 365 249 APPLDIR := $(APPLDIR) $(NETAPP_DIR )366 APPLDIR := $(APPLDIR) $(NETAPP_DIRS) 250 367 APPL_COBJS := $(APPL_COBJS) $(NETAPP_COBJS) 251 368 APPL_CFLAGS := $(APPL_CFLAGS) -fno-strict-aliasing … … 255 372 ifeq ($(TARGET_KERNEL),JSP) 256 373 257 UTASK_DIR := $(UTASK_DIR):$(NETAPP_DIR)374 UTASK_DIRS := $(UTASK_DIRS):$(NETAPP_DIRS) 258 375 UTASK_COBJS := $(UTASK_COBJS) $(NETAPP_COBJS) 259 376 UTASK_CFLAGS := $(UTASK_CFLAGS) -fno-strict-aliasing … … 261 378 endif 262 379 380 ifeq ($(USE_LCD),true) 381 382 ifeq ($(TARGET_KERNEL),ASP) 383 384 APPLDIR := $(APPLDIR) $(SRCDIR)/pdic/sc1602 385 386 endif 387 388 ifeq ($(TARGET_KERNEL),JSP) 389 390 UTASK_DIRS := $(UTASK_DIRS):$(SRCDIR)/pdic/sc1602 391 392 endif 393 394 endif 395 263 396 # 264 397 # TINET コンフィギュレーションファイルの定義への追加 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 37 37 38 38 #include <stdlib.h> 39 #include <string.h> 39 40 40 41 #ifdef TARGET_KERNEL_ASP … … 44 45 #include <syssvc/serial.h> 45 46 #include <syssvc/logtask.h> 46 #include "kernel_cfg.h"47 47 #include "kernel/kernel_impl.h" 48 48 #include "kernel/task.h" 49 #include "kernel_cfg.h" 50 #include "tinet_cfg.h" 49 51 50 52 #endif /* of #ifdef TARGET_KERNEL_ASP */ … … 55 57 #include <t_services.h> 56 58 #include "kernel_id.h" 59 #include "tinet_id.h" 57 60 58 61 #include "../kernel/jsp_kernel.h" … … 69 72 #include <net/ethernet.h> 70 73 #include <net/net.h> 74 #include <net/net_endian.h> 71 75 #include <net/net_buf.h> 72 76 #include <net/net_timer.h> … … 83 87 #include <netinet/ip.h> 84 88 #include <netinet/ip_var.h> 85 #include <netinet/ip6.h>86 #include <netinet6/ip6_var.h>87 #include <netinet6/nd6.h>88 89 #include <netinet/if_ether.h> 89 90 #include <netinet/tcp.h> 90 #include <netinet/tcp_timer.h>91 91 #include <netinet/tcp_var.h> 92 92 #include <netinet/tcp_fsm.h> 93 #include <netinet/tcp_timer.h> 93 94 #include <netinet/udp.h> 94 95 #include <netinet/udp_var.h> 95 96 97 #include <netinet6/nd6.h> 98 96 99 #include <net/if_var.h> 97 #include <net/if6_var.h>98 100 99 101 #include <netapp/netapp.h> 100 102 #include <netapp/netapp_var.h> 101 #include <netapp/echo.h> 102 #include <netapp/discard.h> 103 #include <netapp/wwws.h> 104 #include <netapp/tcp_echo_srv1.h> 105 #include <netapp/tcp_echo_srv2.h> 106 #include <netapp/tcp_echo_cli.h> 107 #include <netapp/tcp_discard_cli.h> 108 #include <netapp/udp6_echo_srv.h> 109 #include <netapp/udp4_echo_srv.h> 110 #include <netapp/udp6_echo_cli.h> 111 #include <netapp/udp4_echo_cli.h> 112 #include <netapp/udp_discard_cli.h> 113 #include <netapp/resolver.h> 103 114 #include <netapp/dbg_cons.h> 104 105 #ifdef USE_LCD 106 107 #include "sc1602/lcd.h" 108 109 #endif /* of #ifdef USE_LCD */ 115 #include <netapp/dhcp6_cli.h> 116 #include <netapp/dhcp4_cli.h> 117 #include "lcd.h" 110 118 111 119 #ifdef USE_DBG_CONS 112 120 113 #define DBG_LINE_SIZE 63114 115 121 /* 116 * task_status -- タスクの状態の出力122 * dbg_cons_task_status -- タスクの状態の出力 117 123 */ 118 124 … … 127 133 }; 128 134 129 staticvoid130 task_status (ID portid, char *line)135 void 136 dbg_cons_task_status (ID portid, char *line) 131 137 { 132 138 TCB *tcb; … … 149 155 st >>= 1; 150 156 } 151 cons_p rintf(portid, "\n");157 cons_putchar(portid, '\n'); 152 158 } 153 159 … … 176 182 }; 177 183 184 #if defined(SUPPORT_INET6) 185 186 static void 187 tcp_cep_status (ID portid, char *line) 188 { 189 T_TCP_CEP* cep; 190 int len; 191 192 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 193 194 T_TCP_TWCEP* twcep; 195 196 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 197 198 cons_printf(portid, 199 "TCP CEP Status\n" 200 "ID Snd-Q Rcv-Q Foreign Address State\n"); 201 202 for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) 203 if (!VALID_TCP_CEP(cep)) { 204 cons_printf(portid, 205 "%2d%c%c 0 0" 206 " - " 207 " INVALID\n", 208 GET_TCP_CEPID(cep), 209 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 210 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 211 } 212 else if (cep->fsm_state == TCP_FSM_CLOSED) { 213 cons_printf(portid, 214 "%2d%c%c 0 0" 215 " - " 216 " CLOSED\n", 217 GET_TCP_CEPID(cep), 218 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 219 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 220 } 221 else if (cep->fsm_state == TCP_FSM_LISTEN) { 222 cons_printf(portid, 223 "%2d%c%c 0 0" 224 " - " 225 " LISTEN\n", 226 GET_TCP_CEPID(cep), 227 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 228 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 229 } 230 else { 231 cons_printf(portid, 232 "%2d%c%c %5d %5d ", 233 GET_TCP_CEPID(cep), 234 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 235 TCP_IS_CEP_IPV6(cep) ? '6' : '4', 236 cep->swbuf_count, cep->rwbuf_count); 237 178 238 #if defined(SUPPORT_INET4) 179 239 240 if (TCP_IS_CEP_IPV4(cep)) { 241 T_IN4_ADDR addr; 242 243 addr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]); 244 len = put_ipv4addr(portid, &addr, 0); 245 } 246 else 247 len = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0); 248 249 #else /* of #if defined(SUPPORT_INET4) */ 250 251 len = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0); 252 253 #endif /* of #if defined(SUPPORT_INET4) */ 254 255 cons_putchar(portid, '.'); 256 len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' '); 257 for (len = 44 - len; len -- > 0; ) 258 cons_putchar(portid, ' '); 259 if (cep->fsm_state == TCP_FSM_TIME_WAIT) 260 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state], 261 cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ); 262 else 263 cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]); 264 } 265 266 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 267 268 for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) { 269 if (twcep->fsm_state == TCP_FSM_CLOSED) { 270 cons_printf(portid, 271 "%2dTW 0 0" 272 " - " 273 " CLOSED\n", 274 GET_TCP_TWCEPID(twcep)); 275 } 276 else { 277 cons_printf(portid, "%2dTW 0 0 ", GET_TCP_TWCEPID(twcep)); 278 279 #if defined(SUPPORT_INET4) 280 281 if (TCP_IS_CEP_IPV4(twcep)) { 282 T_IN4_ADDR addr; 283 284 addr = ntohl(twcep->dstaddr.ipaddr.s6_addr32[3]); 285 len = put_ipv4addr(portid, &addr, 0); 286 } 287 else 288 len = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0); 289 290 #else /* of #if defined(SUPPORT_INET4) */ 291 292 len = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0); 293 294 #endif /* of #if defined(SUPPORT_INET4) */ 295 296 cons_putchar(portid, '.'); 297 len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' '); 298 for (len = 44 - len; len -- > 0; ) 299 cons_putchar(portid, ' '); 300 if (twcep->fsm_state == TCP_FSM_TIME_WAIT) 301 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state], 302 twcep->timer_2msl / TCP_SLOW_HZ); 303 else 304 cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]); 305 } 306 } 307 308 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 309 310 } 311 312 #else /* of #if defined(SUPPORT_INET6) */ 313 314 #if defined(SUPPORT_INET4) 315 180 316 static void 181 tcp_ status (ID portid, char *line)317 tcp_cep_status (ID portid, char *line) 182 318 { 183 319 T_TCP_CEP* cep; … … 190 326 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 191 327 192 #ifdef TCP_CFG_PASSIVE_OPEN193 194 T_TCP_REP* rep;195 int_t cnt;196 197 #endif /* of #ifdef TCP_CFG_PASSIVE_OPEN */198 199 WAI_NET_CONS_PRINTF();200 328 cons_printf(portid, 201 329 "TCP CEP Status\n" … … 205 333 if (!VALID_TCP_CEP(cep)) { 206 334 cons_printf(portid, 207 "%2d%c 0 0"335 "%2d%c%c 0 0" 208 336 " - " 209 337 " - " 210 338 " INVALID\n", 211 339 GET_TCP_CEPID(cep), 212 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 340 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 341 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 213 342 } 214 343 else if (cep->fsm_state == TCP_FSM_CLOSED) { 215 344 cons_printf(portid, 216 "%2d%c 0 0"345 "%2d%c%c 0 0" 217 346 " - " 218 347 " - " 219 348 " CLOSED\n", 220 349 GET_TCP_CEPID(cep), 221 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 350 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 351 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 222 352 } 223 353 else if (cep->fsm_state == TCP_FSM_LISTEN) { 224 354 cons_printf(portid, 225 "%2d%c 0 0 ",355 "%2d%c%c 0 0 ", 226 356 GET_TCP_CEPID(cep), 227 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 357 DYNAMIC_TCP_CEP(cep) ? 'D' : '.', 358 TCP_IS_CEP_IPV6(cep) ? '6' : '4'); 228 359 len = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0); 229 360 cons_putchar(portid, ':'); … … 263 394 if (twcep->fsm_state == TCP_FSM_CLOSED) { 264 395 cons_printf(portid, 265 "%2dTW 0 0"396 "%2dTW 0 0" 266 397 " - " 267 398 " - " … … 270 401 } 271 402 else { 272 cons_printf(portid, "%2dTW 0 0 ", GET_TCP_TWCEPID(twcep));403 cons_printf(portid, "%2dTW 0 0 ", GET_TCP_TWCEPID(twcep)); 273 404 len = PUT_IPADDR(portid, &twcep->myaddr.ipaddr, 0); 274 405 cons_putchar(portid, ':'); … … 291 422 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 292 423 293 #ifdef TCP_CFG_PASSIVE_OPEN 424 } 425 426 #endif /* of #if defined(SUPPORT_INET4) */ 427 428 #endif /* of #if defined(SUPPORT_INET6) */ 429 430 #if TNUM_TCP6_REPID > 0 431 432 static void 433 tcp6_rep_status (ID portid, char *line) 434 { 435 T_TCP_CEP* cep; 436 T_TCP6_REP* rep; 437 ID repid; 438 int_t cnt; 439 uint_t len; 294 440 295 441 cons_printf(portid, 296 "TCP REP Status\n"442 "TCP6 REP Status\n" 297 443 "ID Local Address CEP\n"); 298 for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) { 299 cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' '); 300 if (VALID_TCP_REP(rep)) { 301 len = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0); 302 cons_putchar(portid, ':'); 303 len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' '); 304 for (len = 21 - len; len -- > 0; ) 305 cons_putchar(portid, ' '); 306 cnt = 0; 307 for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) { 308 if (cep->rep == rep) { 309 if (cnt > 0) 310 cons_printf(portid, ",%d", GET_TCP_CEPID(cep)); 311 else 312 cons_printf(portid, "%d", GET_TCP_CEPID(cep)); 313 cnt ++; 314 } 315 } 316 } 317 else 318 cons_printf(portid, "INVALID"); 319 cons_putchar(portid, '\n'); 320 } 321 322 #endif /* of #ifdef TCP_CFG_PASSIVE_OPEN */ 323 324 SIG_NET_CONS_PRINTF(); 325 FLUSH_SND_BUFF(); 326 } 327 328 #endif /* of #if defined(SUPPORT_INET4) */ 329 330 #if defined(SUPPORT_INET6) 331 332 static void 333 tcp_status (ID portid, char *line) 334 { 335 T_TCP_CEP* cep; 336 uint_t len; 337 338 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 339 340 T_TCP_TWCEP* twcep; 341 342 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 343 344 #ifdef TCP_CFG_PASSIVE_OPEN 345 346 T_TCP_REP* rep; 347 int_t cnt; 348 349 #endif /* of #ifdef TCP_CFG_PASSIVE_OPEN */ 350 351 WAI_NET_CONS_PRINTF(); 352 cons_printf(portid, 353 "TCP CEP Status\n" 354 "ID Snd-Q Rcv-Q Foreign Address State\n"); 355 356 for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) 357 if (!VALID_TCP_CEP(cep)) { 358 cons_printf(portid, 359 "%2d%c 0 0" 360 " - " 361 " INVALID\n", 362 GET_TCP_CEPID(cep), 363 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 364 } 365 else if (cep->fsm_state == TCP_FSM_CLOSED) { 366 cons_printf(portid, 367 "%2d%c 0 0" 368 " - " 369 " CLOSED\n", 370 GET_TCP_CEPID(cep), 371 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 372 } 373 else if (cep->fsm_state == TCP_FSM_LISTEN) { 374 cons_printf(portid, 375 "%2d%c 0 0" 376 " - " 377 " LISTEN\n", 378 GET_TCP_CEPID(cep), 379 DYNAMIC_TCP_CEP(cep) ? 'D' : ' '); 380 } 381 else { 382 cons_printf(portid, 383 "%2d%c %5d %5d ", 384 GET_TCP_CEPID(cep), 385 DYNAMIC_TCP_CEP(cep) ? 'D' : ' ', 386 cep->swbuf_count, cep->rwbuf_count); 387 len = PUT_IPADDR(portid, &cep->dstaddr.ipaddr, 0); 388 cons_putchar(portid, '.'); 389 len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' '); 390 for (len = 42 - len; len -- > 0; ) 391 cons_putchar(portid, ' '); 392 if (cep->fsm_state == TCP_FSM_TIME_WAIT) 393 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state], 394 cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ); 395 else 396 cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]); 397 } 398 399 #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 400 401 for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) { 402 if (twcep->fsm_state == TCP_FSM_CLOSED) { 403 cons_printf(portid, 404 "%2dTW 0 0" 405 " - " 406 " CLOSED\n", 407 GET_TCP_TWCEPID(twcep)); 408 } 409 else { 410 cons_printf(portid, "%2dTW 0 0 ", GET_TCP_TWCEPID(twcep)); 411 len = PUT_IPADDR(portid, &twcep->dstaddr.ipaddr, 0); 412 cons_putchar(portid, '.'); 413 len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' '); 414 for (len = 42 - len; len -- > 0; ) 415 cons_putchar(portid, ' '); 416 if (twcep->fsm_state == TCP_FSM_TIME_WAIT) 417 cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state], 418 twcep->timer_2msl / TCP_SLOW_HZ); 419 else 420 cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]); 421 } 422 } 423 424 #endif /* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */ 425 426 #ifdef TCP_CFG_PASSIVE_OPEN 427 428 cons_printf(portid, 429 "TCP REP Status\n" 430 "ID Local Address CEP\n"); 431 for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) { 432 cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' '); 444 for (repid = TMIN_TCP6_REPID; repid <= tmax_tcp6_repid; repid ++) { 445 rep = GET_TCP6_REP(repid); 446 cons_printf(portid, "%2d%c ", GET_TCP6_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' '); 433 447 if (VALID_TCP_REP(rep)) { 434 448 len = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0); … … 439 453 cnt = 0; 440 454 for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) { 441 if ( cep->rep == rep) {455 if (TCP_IS_CEP_IPV6(cep) && cep->rep == rep) { 442 456 if (cnt > 0) 443 457 cons_printf(portid, ",%d", GET_TCP_CEPID(cep)); … … 452 466 cons_putchar(portid, '\n'); 453 467 } 454 455 #endif /* of #ifdef TCP_CFG_PASSIVE_OPEN */ 456 457 SIG_NET_CONS_PRINTF(); 458 FLUSH_SND_BUFF(); 459 } 460 461 #endif /* of #if defined(SUPPORT_INET6) */ 462 463 #endif /* of #ifdef SUPPORT_TCP */ 464 465 #ifdef SUPPORT_UDP 466 467 /* 468 * udp_status -- UDP の状態の出力 469 */ 468 } 469 470 #endif /* of #if TNUM_TCP6_REPID > 0 */ 471 472 #if TNUM_TCP4_REPID > 0 470 473 471 474 static void 472 udp_status (ID portid, char *line) 473 { 474 T_UDP_CEP* cep; 475 tcp4_rep_status (ID portid, char *line) 476 { 477 T_TCP_CEP* cep; 478 T_TCP4_REP* rep; 479 ID repid; 480 int_t cnt; 475 481 uint_t len; 476 482 477 WAI_NET_CONS_PRINTF();478 483 cons_printf(portid, 479 "UDP CEP Status\n" 480 "ID Local Address\n"); 481 482 for (cep = udp_cep; cep < &udp_cep[tmax_udp_ccepid]; cep ++) { 483 cons_printf(portid, "%2d%c ", GET_UDP_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' '); 484 if (VALID_UDP_CEP(cep)) { 485 len = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0); 486 cons_putchar(portid, '.'); 487 len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' '); 484 "TCP4 REP Status\n" 485 "ID Local Address CEP\n"); 486 for (repid = TMIN_TCP4_REPID; repid <= tmax_tcp4_repid; repid ++) { 487 rep = GET_TCP4_REP(repid); 488 cons_printf(portid, "%2d%c ", GET_TCP4_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' '); 489 if (VALID_TCP_REP(rep)) { 490 len = put_ipv4addr(portid, &rep->myaddr.ipaddr, 0); 491 cons_putchar(portid, ':'); 492 len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' '); 493 for (len = 21 - len; len -- > 0; ) 494 cons_putchar(portid, ' '); 495 cnt = 0; 496 for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) { 497 498 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 499 500 if (TCP_IS_CEP_IPV4(cep) && cep->rep4 == rep) { 501 502 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 503 504 if (TCP_IS_CEP_IPV4(cep) && cep->rep == rep) { 505 506 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 507 508 if (cnt > 0) 509 cons_printf(portid, ",%d", GET_TCP_CEPID(cep)); 510 else 511 cons_printf(portid, "%d", GET_TCP_CEPID(cep)); 512 cnt ++; 513 } 514 } 488 515 } 489 516 else … … 491 518 cons_putchar(portid, '\n'); 492 519 } 520 } 521 522 #endif /* of #if TNUM_TCP4_REPID > 0 */ 523 524 static void 525 tcp_status (ID portid, char *line) 526 { 527 WAI_NET_CONS_PRINTF(); 528 529 tcp_cep_status(portid, line); 530 531 #if TNUM_TCP6_REPID > 0 532 tcp6_rep_status(portid, line); 533 #endif 534 535 #if TNUM_TCP4_REPID > 0 536 tcp4_rep_status(portid, line); 537 #endif 493 538 494 539 SIG_NET_CONS_PRINTF(); … … 496 541 } 497 542 498 #endif /* of #ifdef SUPPORT_UDP */ 499 500 #ifdef SUPPORT_ETHER 501 502 #if defined(SUPPORT_INET4) 543 #endif /* of #ifdef SUPPORT_TCP */ 544 545 #ifdef SUPPORT_UDP 503 546 504 547 /* 505 * ifa_status -- ARP キャッシュ出力 506 */ 548 * udp6_status -- UDP の状態の出力 549 */ 550 551 #if TNUM_UDP6_CEPID > 0 552 553 extern const ID tmax_tcp_cepid; 507 554 508 555 static void 509 ifa_status (ID portid, char *line) 510 { 511 const T_ARP_ENTRY *cache; 512 int_t ix; 513 556 udp6_status (ID portid, char *line) 557 { 558 T_UDP6_CEP* cep; 559 ID cepid; 560 uint_t len; 561 562 cons_printf(portid, 563 "UDP6 CEP Status\n" 564 "ID Local Address\n"); 565 566 for (cepid = TMIN_UDP6_CEPID; cepid <= tmax_udp6_cepid; cepid ++) { 567 cep = GET_UDP6_CEP(cepid); 568 cons_printf(portid, "%2d%c ", GET_UDP6_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' '); 569 if (VALID_UDP_CEP(cep)) { 570 len = put_ipv6addr(portid, &cep->myaddr.ipaddr, 0); 571 cons_putchar(portid, '.'); 572 len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' '); 573 } 574 else 575 cons_printf(portid, "INVALID"); 576 cons_putchar(portid, '\n'); 577 } 578 579 SIG_NET_CONS_PRINTF(); 580 } 581 582 #endif /* of #if TNUM_UDP6_CEPID > 0 */ 583 584 /* 585 * udp4_status -- UDP の状態の出力 586 */ 587 588 #if TNUM_UDP4_CEPID > 0 589 590 static void 591 udp4_status (ID portid, char *line) 592 { 593 T_UDP4_CEP* cep; 594 ID cepid; 595 uint_t len; 596 597 cons_printf(portid, 598 "UDP4 CEP Status\n" 599 "ID Local Address\n"); 600 601 for (cepid = TMIN_UDP4_CEPID; cepid <= tmax_udp4_cepid; cepid ++) { 602 cep = GET_UDP4_CEP(cepid); 603 cons_printf(portid, "%2d%c ", GET_UDP4_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' '); 604 if (VALID_UDP_CEP(cep)) { 605 len = put_ipv4addr(portid, &cep->myaddr.ipaddr, 0); 606 cons_putchar(portid, '.'); 607 len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' '); 608 } 609 else 610 cons_printf(portid, "INVALID"); 611 cons_putchar(portid, '\n'); 612 } 613 614 SIG_NET_CONS_PRINTF(); 615 } 616 617 #endif /* of #if TNUM_UDP4_CEPID > 0 */ 618 619 static void 620 udp_status (ID portid, char *line) 621 { 514 622 WAI_NET_CONS_PRINTF(); 515 cons_printf(portid, 516 "ARP Cache\n" 517 "IX Expire IP Address MAC Address\n"); 518 519 /* expire の単位は [ms]。*/ 520 cache = arp_get_cache(); 521 for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) { 522 if (cache[ix].expire != 0) 523 cons_printf(portid, "%2d %6d %15I %M\n", 524 ix, cache[ix].expire / NET_TIMER_HZ, 525 &cache[ix].ip_addr, cache[ix].mac_addr); 526 } 623 624 #if TNUM_UDP6_CEPID > 0 625 udp6_status(portid, line); 626 #endif 627 628 #if TNUM_UDP4_CEPID > 0 629 udp4_status(portid, line); 630 #endif 527 631 528 632 SIG_NET_CONS_PRINTF(); … … 530 634 } 531 635 532 #endif /* of #if defined(SUPPORT_INET4) */ 636 #endif /* of #ifdef SUPPORT_UDP */ 637 638 #ifdef SUPPORT_ETHER 533 639 534 640 #if defined(SUPPORT_INET6) 535 641 536 642 /* 537 * ifa _status -- 近隣キャッシュ状態の出力643 * ifa6_status -- 近隣キャッシュ状態の出力 538 644 */ 539 645 … … 549 655 550 656 static void 551 ifa _status (ID portid, char *line)657 ifa6_status (ID portid, char *line) 552 658 { 553 659 const T_LLINFO_ND6 *cache; … … 565 671 for (ix = 0; ix < NUM_ND6_CACHE_ENTRY; ix ++) { 566 672 if (cache[ix].state != ND6_LLINFO_FREE) { 567 cons_printf(portid, "%2d %6 d %10s %M %I\n",673 cons_printf(portid, "%2d %6ld %10s %M %lI\n", 568 674 ix, 569 675 cache[ix].state == ND6_LLINFO_STALE || 570 (uint32_t)( cache[ix].expire - now) <= 0571 ? 0 : (cache[ix].expire - now) / SYSTIM_HZ,676 (uint32_t)((int32_t)(cache[ix].expire - now) <= 0 677 ? 0 : (int32_t)(cache[ix].expire - now) / SYSTIM_HZ), 572 678 nd_state_str[cache[ix].state], 573 679 &cache[ix].ifaddr, … … 581 687 582 688 #endif /* of #if defined(SUPPORT_INET6) */ 689 690 #if defined(SUPPORT_INET4) 691 692 /* 693 * ifa4_status -- ARP キャッシュ出力 694 */ 695 696 static void 697 ifa4_status (ID portid, char *line) 698 { 699 const T_ARP_ENTRY *cache; 700 int_t ix; 701 702 WAI_NET_CONS_PRINTF(); 703 cons_printf(portid, 704 "ARP Cache\n" 705 "IX Expire MAC Address IP Address\n"); 706 707 /* expire の単位は [ms]。*/ 708 cache = arp_get_cache(); 709 for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) { 710 if (cache[ix].expire != 0) 711 cons_printf(portid, "%2d %6d %M %hI\n", 712 ix, cache[ix].expire / NET_TIMER_HZ, 713 cache[ix].mac_addr, &cache[ix].ip_addr); 714 } 715 716 SIG_NET_CONS_PRINTF(); 717 FLUSH_SND_BUFF(); 718 } 719 720 #endif /* of #if defined(SUPPORT_INET4) */ 583 721 584 722 #endif /* of #ifdef SUPPORT_ETHER */ … … 673 811 674 812 #endif /* of #ifdef SUPPORT_ETHER */ 813 814 #if defined(SUPPORT_INET6) 815 816 cons_printf(portid, "\nIPv6\n"); 817 cons_printf(portid, "\t受信オクテット数\t%lu\n", net_count_ip6[NC_IP6_IN_OCTETS]); 818 cons_printf(portid, "\t受信データグラム数\t%lu\n", net_count_ip6[NC_IP6_IN_PACKETS]); 819 cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_PACKETS]); 820 cons_printf(portid, "\t長さエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_SHORT]); 821 cons_printf(portid, "\tバージョンエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_VER]); 822 cons_printf(portid, "\tアドレスエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_ADDR]); 823 cons_printf(portid, "\tプロトコルエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_PROTO]); 824 cons_printf(portid, "\t分割受信数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN]); 825 cons_printf(portid, "\t分割受信フラグメント数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_FRAGS]); 826 cons_printf(portid, "\t分割受信再構成成功数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_OK]); 827 cons_printf(portid, "\t分割受信破棄数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_DROP]); 828 cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]); 829 cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_TMOUT]); 830 cons_printf(portid, "\t送信オクテット数\t%lu\n", net_count_ip6[NC_IP6_OUT_OCTETS]); 831 cons_printf(portid, "\t送信データグラム数\t%lu\n", net_count_ip6[NC_IP6_OUT_PACKETS]); 832 cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n", net_count_ip6[NC_IP6_OUT_ERR_PACKETS]); 833 cons_printf(portid, "\t分割送信数\t%lu\n", net_count_ip6[NC_IP6_FRAG_OUT]); 834 cons_printf(portid, "\t分割送信フラグメント数\t%lu\n", net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]); 835 836 cons_printf(portid, "\nICMPv6\n"); 837 cons_printf(portid, "\t受信オクテット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_OCTETS]); 838 cons_printf(portid, "\t受信パケット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_PACKETS]); 839 cons_printf(portid, "\t受信エラーパケット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]); 840 cons_printf(portid, "\t受信チックサムエラー数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]); 841 cons_printf(portid, "\t送信オクテット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_OCTETS]); 842 cons_printf(portid, "\t送信パケット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_PACKETS]); 843 cons_printf(portid, "\t送信エラーパケット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]); 844 845 cons_printf(portid, "\n近隣探索\n"); 846 cons_printf(portid, "\tルータ通知受信数\t%lu\n", net_count_nd6[NC_ND6_RA_IN_PACKETS]); 847 cons_printf(portid, "\tルータ要請送信数\t%lu\n", net_count_nd6[NC_ND6_RS_OUT_PACKETS]); 848 cons_printf(portid, "\t近隣通知受信数\t%lu\n", net_count_nd6[NC_ND6_NA_IN_PACKETS]); 849 cons_printf(portid, "\t近隣通知送信数\t%lu\n", net_count_nd6[NC_ND6_NA_OUT_PACKETS]); 850 cons_printf(portid, "\t近隣要請受信数\t%lu\n", net_count_nd6[NC_ND6_NS_IN_PACKETS]); 851 cons_printf(portid, "\t近隣要請送信数\t%lu\n", net_count_nd6[NC_ND6_NS_OUT_PACKETS]); 852 cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n", net_count_nd6[NC_ND6_DAD_OUT_PACKETS]); 853 854 #else /* of #if defined(SUPPORT_INET6) */ 675 855 676 856 #if defined(SUPPORT_INET4) … … 707 887 708 888 #endif /* of #if defined(SUPPORT_INET4) */ 709 710 #if defined(SUPPORT_INET6)711 712 cons_printf(portid, "\nIPv6\n");713 cons_printf(portid, "\t受信オクテット数\t%lu\n", net_count_ip6[NC_IP6_IN_OCTETS]);714 cons_printf(portid, "\t受信データグラム数\t%lu\n", net_count_ip6[NC_IP6_IN_PACKETS]);715 cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_PACKETS]);716 cons_printf(portid, "\t長さエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_SHORT]);717 cons_printf(portid, "\tバージョンエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_VER]);718 cons_printf(portid, "\tアドレスエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_ADDR]);719 cons_printf(portid, "\tプロトコルエラー数\t%lu\n", net_count_ip6[NC_IP6_IN_ERR_PROTO]);720 cons_printf(portid, "\t分割受信数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN]);721 cons_printf(portid, "\t分割受信フラグメント数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);722 cons_printf(portid, "\t分割受信再構成成功数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_OK]);723 cons_printf(portid, "\t分割受信破棄数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_DROP]);724 cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);725 cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n", net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);726 cons_printf(portid, "\t送信オクテット数\t%lu\n", net_count_ip6[NC_IP6_OUT_OCTETS]);727 cons_printf(portid, "\t送信データグラム数\t%lu\n", net_count_ip6[NC_IP6_OUT_PACKETS]);728 cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n", net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);729 cons_printf(portid, "\t分割送信数\t%lu\n", net_count_ip6[NC_IP6_FRAG_OUT]);730 cons_printf(portid, "\t分割送信フラグメント数\t%lu\n", net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);731 732 cons_printf(portid, "\nICMPv6\n");733 cons_printf(portid, "\t受信オクテット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_OCTETS]);734 cons_printf(portid, "\t受信パケット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_PACKETS]);735 cons_printf(portid, "\t受信エラーパケット数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);736 cons_printf(portid, "\t受信チックサムエラー数\t%lu\n", net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);737 cons_printf(portid, "\t送信オクテット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_OCTETS]);738 cons_printf(portid, "\t送信パケット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_PACKETS]);739 cons_printf(portid, "\t送信エラーパケット数\t%lu\n", net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);740 741 cons_printf(portid, "\n近隣探索\n");742 cons_printf(portid, "\tルータ通知受信数\t%lu\n", net_count_nd6[NC_ND6_RA_IN_PACKETS]);743 cons_printf(portid, "\tルータ要請送信数\t%lu\n", net_count_nd6[NC_ND6_RS_OUT_PACKETS]);744 cons_printf(portid, "\t近隣通知受信数\t%lu\n", net_count_nd6[NC_ND6_NA_IN_PACKETS]);745 cons_printf(portid, "\t近隣通知送信数\t%lu\n", net_count_nd6[NC_ND6_NA_OUT_PACKETS]);746 cons_printf(portid, "\t近隣要請受信数\t%lu\n", net_count_nd6[NC_ND6_NS_IN_PACKETS]);747 cons_printf(portid, "\t近隣要請送信数\t%lu\n", net_count_nd6[NC_ND6_NS_OUT_PACKETS]);748 cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n", net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);749 889 750 890 #endif /* of #if defined(SUPPORT_INET6) */ … … 787 927 788 928 tbl = nbuf_get_tbl(); 789 cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t 割当要求数\t割当数\t割当てエラー数\n");929 cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n"); 790 930 for (ix = nbuf_get_tbl_size(); ix -- > 0; ) { 791 cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\ n",931 cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n", 792 932 tbl[ix].size, 793 933 tbl[ix].prepares, 934 tbl[ix].busies, 794 935 tbl[ix].requests, 795 936 tbl[ix].allocs, … … 833 974 for (ix = nbuf_get_tbl_size(); ix -- > 0; ) 834 975 cons_printf(portid, "\t%d", tbl[ix].size); 835 cons_p rintf(portid, "\n");976 cons_putchar(portid, '\n'); 836 977 837 978 queue = ip_get_frag_queue(); … … 846 987 cons_printf(portid, "\t%d", count); 847 988 } 848 cons_p rintf(portid, "\n");989 cons_putchar(portid, '\n'); 849 990 } 850 991 } … … 874 1015 for (ix = nbuf_get_tbl_size(); ix -- > 0; ) 875 1016 cons_printf(portid, "\t%d", tbl[ix].size); 876 cons_p rintf(portid, "\n");1017 cons_putchar(portid, '\n'); 877 1018 878 1019 queue = ip6_get_frag_queue(); … … 887 1028 cons_printf(portid, "\t%d", count); 888 1029 } 889 cons_p rintf(portid, "\n");1030 cons_putchar(portid, '\n'); 890 1031 } 891 1032 } … … 918 1059 919 1060 #ifdef TCP_CFG_SWBUF_CSAVE 920 T_IP_HDR* iph;921 1061 T_TCP_HDR* tcph; 922 1062 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */ … … 925 1065 WAI_NET_CONS_PRINTF(); 926 1066 get_tim(&now); 927 cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t% lu\n", now);1067 cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%u\n", now); 928 1068 929 1069 #if NET_COUNT_ENABLE 930 1070 931 cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t 割当要求数\t割当数\t割当てエラー数\n");1071 cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n"); 932 1072 tbl = nbuf_get_tbl(); 933 1073 for (ix = nbuf_get_tbl_size(); ix -- > 0; ) { 934 cons_printf(portid, "\t% lu\t%lu\t%lu\t%lu\t%lu\n",1074 cons_printf(portid, "\t%u\t%u\t%u\t%u\t%u\t%u\n", 935 1075 tbl[ix].size, 936 1076 tbl[ix].prepares, 1077 tbl[ix].busies, 937 1078 tbl[ix].requests, 938 1079 tbl[ix].allocs, … … 949 1090 cons_printf(portid, "%2d", GET_TCP_CEPID(cep)); 950 1091 for (nbuf = cep->reassq; nbuf != NULL; nbuf = tqhdr->next) { 951 tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_ IP_Q_HDR(nbuf)->thoff);952 cons_printf(portid, "[a:%6 d-%6d] ",1092 tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf)); 1093 cons_printf(portid, "[a:%6lu-%6lu] ", 953 1094 ntohl(tqhdr->seq) - cep->irs + tqhdr->soff, 954 1095 ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen); … … 957 1098 #ifdef TCP_CFG_RWBUF_CSAVE 958 1099 for (nbuf = cep->rwbufq; nbuf != NULL; nbuf = tqhdr->next) { 959 tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_ IP_Q_HDR(nbuf)->thoff);960 cons_printf(portid, "[r:%6 d-%6d] ",1100 tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf)); 1101 cons_printf(portid, "[r:%6lu-%6lu] ", 961 1102 ntohl(tqhdr->seq) - cep->irs + tqhdr->soff, 962 1103 ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen); … … 966 1107 #ifdef TCP_CFG_SWBUF_CSAVE 967 1108 if (cep->swbufq != NULL) { 968 iph = GET_IP_HDR(cep->swbufq);969 1109 tcph = GET_TCP_HDR(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq)); 970 cons_printf(portid, "[s:%6d-%6d] ", 1110 #if 0 1111 cons_printf(portid, "[s:%6lu-%6lu] ", 971 1112 ntohl(tcph->seq) - cep->iss, 972 ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(iph) - 973 GET_TCP_HDR_SIZE2(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq)))); 1113 ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 1114 GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq)))); 1115 #else 1116 cons_printf(portid, "[s:%6lu-%6lu,%08x,%08x] ", 1117 ntohl(tcph->seq) - cep->iss, 1118 ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 1119 GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))), 1120 ntohl(tcph->seq), cep->iss); 1121 #endif 974 1122 } 975 1123 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */ 976 1124 977 cons_p rintf(portid, "\n");1125 cons_putchar(portid, '\n'); 978 1126 } 979 1127 … … 1008 1156 } 1009 1157 1158 #ifdef USE_RESOLVER 1159 1160 /* 1161 * show_dns_soa -- DNS の SOA RDATA を表示する。 1162 */ 1163 1164 static ER_UINT 1165 show_dns_soa (ID portid, uint8_t *msg, ER_UINT length, uint_t offset) 1166 { 1167 T_RSLV_SOA soa; 1168 ER_UINT error; 1169 uint_t rn_offset; 1170 1171 if ((error = dns_analyze_soa(&soa, offset, msg, length)) < 0) 1172 return error; 1173 1174 cons_printf(portid, " mname: "); 1175 rn_offset = show_dns_domain_name(portid, msg, offset); 1176 cons_putchar(portid, '\n'); 1177 cons_printf(portid, " rname: "); 1178 show_dns_domain_name(portid, msg, rn_offset); 1179 cons_putchar(portid, '\n'); 1180 1181 cons_printf(portid, " serial: %d\n", soa.serial); 1182 cons_printf(portid, " refresh: %d\n", soa.refresh); 1183 cons_printf(portid, " retry: %d\n", soa.retry); 1184 cons_printf(portid, " expirel: %d\n", soa.expire); 1185 cons_printf(portid, " minimum: %d\n", soa.minimum); 1186 1187 return E_OK; 1188 } 1189 1190 /* 1191 * show_dns_qdsection -- DNS の Question セクションを表示する。 1192 */ 1193 1194 static ER_UINT 1195 show_dns_qdsection (ID portid, uint8_t *msg, ER_UINT length, T_RSLV_DNS_MSG *rslv) 1196 { 1197 T_RSLV_QD qd; 1198 ER_UINT offset, error; 1199 int scount; 1200 1201 cons_printf(portid, "question section: %d\n", rslv->dns_hdr.qdcount); 1202 offset = rslv->qd_offset; 1203 for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount ++) { 1204 if ((error = dns_analyze_qd(&qd, offset, msg, length)) < 0) 1205 return error; 1206 1207 cons_printf(portid, "%2d: ", scount); 1208 show_dns_domain_name(portid, msg, offset); 1209 cons_printf(portid, "\n type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class)); 1210 offset = error; 1211 } 1212 1213 return E_OK; 1214 } 1215 1216 /* 1217 * show_dns_section -- DNS の各セクションを表示する。 1218 */ 1219 1220 static ER_UINT 1221 show_dns_section (ID portid, uint8_t *msg, ER_UINT length, uint_t scount, uint_t offset, char *title) 1222 { 1223 T_RSLV_RR rr; 1224 T_IN4_ADDR in4_addr; 1225 ER_UINT error; 1226 int count, dcount, col; 1227 T_IN6_ADDR in6_addr; 1228 1229 cons_printf(portid, "%10s section: %d\n", title, scount); 1230 for (count = 1; count <= scount; count ++) { 1231 if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0) 1232 return error; 1233 1234 cons_printf(portid, "%2d: ", count); 1235 show_dns_domain_name(portid, msg, offset); 1236 cons_printf(portid, "\n type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n", 1237 dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset); 1238 1239 switch (rr.type) { 1240 case DNS_TYPE_A: 1241 memcpy((void*)&in4_addr, (void*)(msg + rr.rdata_offset), sizeof(in4_addr)); 1242 in4_addr = ntohl(in4_addr); 1243 cons_printf(portid, " IPv4 addr: %hI\n", &in4_addr); 1244 break; 1245 case DNS_TYPE_NS: 1246 cons_printf(portid, " host: "); 1247 show_dns_domain_name(portid, msg, rr.rdata_offset); 1248 cons_putchar(portid, '\n'); 1249 break; 1250 case DNS_TYPE_CNAME: 1251 cons_printf(portid, " host: "); 1252 show_dns_domain_name(portid, msg, rr.rdata_offset); 1253 cons_putchar(portid, '\n'); 1254 break; 1255 case DNS_TYPE_SOA: 1256 show_dns_soa(portid, msg, length, rr.rdata_offset); 1257 break; 1258 case DNS_TYPE_PTR: 1259 cons_printf(portid, " PTR: "); 1260 show_dns_domain_name(portid, msg, rr.rdata_offset); 1261 cons_putchar(portid, '\n'); 1262 break; 1263 case DNS_TYPE_AAAA: 1264 memcpy((void*)&in6_addr, (void*)(msg + rr.rdata_offset), sizeof(in6_addr)); 1265 cons_printf(portid, " IPv6 addr: %lI\n", &in6_addr); 1266 break; 1267 default: 1268 cons_printf(portid, " data: "); 1269 col = 32; 1270 for (dcount = 0; dcount < rr.rdlength; dcount ++) { 1271 cons_printf(portid, "%02x", *(msg + rr.rdata_offset + dcount)); 1272 if (-- col == 0) { 1273 cons_printf(portid, "\n "); 1274 col = 32; 1275 } 1276 } 1277 cons_putchar(portid, '\n'); 1278 break; 1279 } 1280 } 1281 1282 return E_OK; 1283 } 1284 /* 1285 * dns_info -- DNS 情報の表示 1286 */ 1287 1288 static void 1289 dns_info (ID portid) 1290 { 1291 #if defined(SUPPORT_INET6) 1292 T_IN6_ADDR in6_addr; 1293 #endif 1010 1294 #if defined(SUPPORT_INET4) 1011 1012 #if NUM_ROUTE_ENTRY > 0 1295 T_IN4_ADDR in4_addr; 1296 #endif 1297 1298 #if defined(SUPPORT_INET6) 1299 1300 cons_printf(portid, "domain name: %s\n", dns_in6_get_dname()); 1301 1302 #else /* of #if defined(SUPPORT_INET6) */ 1303 1304 cons_printf(portid, "domain name: %s\n", dns_in4_get_dname()); 1305 1306 #endif /* of #if defined(SUPPORT_INET6) */ 1307 1308 #if defined(SUPPORT_INET6) 1309 dns_in6_get_addr(&in6_addr); 1310 cons_printf(portid, "IPv6 DNS server: "); 1311 if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr)) 1312 cons_printf(portid, "not available.\n"); 1313 else 1314 cons_printf(portid, "%lI.\n", &in6_addr); 1315 #endif /* of #if defined(SUPPORT_INET6) */ 1316 1317 #if defined(SUPPORT_INET4) 1318 dns_in4_get_addr(&in4_addr); 1319 cons_printf(portid, "IPv4 DNS server: "); 1320 if (in4_addr == IPV4_ADDRANY) 1321 cons_printf(portid, "not available.\n"); 1322 else 1323 cons_printf(portid, "%hI.\n", &in4_addr); 1324 #endif /* of #if defined(SUPPORT_INET4) */ 1325 } 1013 1326 1014 1327 /* 1015 * routing_table_status -- 経路表の出力 1016 */ 1328 * name_lookup -- ホスト名-IP アドレス変換 1329 */ 1330 1331 const char *rcode_str[] = { 1332 "no error", 1333 "format error", 1334 "server error", 1335 "name error", 1336 "not implement", 1337 "refused", 1338 }; 1017 1339 1018 1340 static void 1019 routing_table_status (ID portid, char *line) 1020 { 1021 int_t ix; 1022 1023 if ('0' <= *(line = skip_blanks(line)) && *line <= '9') { 1024 T_IN4_ADDR target, mask, gateway; 1025 1026 ix = atoi(line); 1027 while ('0' <= *line && *line <= '9') 1028 line ++; 1029 line = GET_IPADDR(&target, skip_blanks(line)); 1030 line = GET_IPADDR(&mask, skip_blanks(line)); 1031 GET_IPADDR(&gateway, skip_blanks(line)); 1032 in4_add_route(ix, target, mask, gateway); 1033 } 1034 1341 name_lookup (ID portid, char *line) 1342 { 1343 static char hostname[DBG_LINE_SIZE + 1]; 1344 1345 T_RSLV_DNS_MSG rslv; 1346 ER_UINT length, offset; 1347 ER error; 1348 uint_t flags = 0; 1349 uint8_t *msg; 1350 1351 /* コマンドのオプションを設定する。*/ 1352 line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO)); 1353 if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) { 1354 cons_printf(portid, "DNS server not available.\n"); 1355 return; 1356 } 1357 1358 /* 照会するホスト名・IP アドレスを解析する。*/ 1359 resolv_hoststr(&flags, hostname, sizeof(hostname), line); 1360 1361 /* 正引きでも逆引きでもプロトコル上は正引きを指定する。*/ 1362 flags |= DNS_LUP_OPCODE_FORWARD; 1363 1364 /* IPv6 アドレス、または IPv4 アドレスが指定された時は、照会タイプは PTR に設定する。*/ 1365 if (((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV6) || 1366 ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV4)) 1367 flags = (flags & ~DNS_LUP_FLAGS_QTYPE_MASK) | DNS_LUP_FLAGS_QTYPE_PTR; 1368 1369 if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) { 1370 cons_printf(portid, "get buffer error: %s.\n", itron_strerror(error)); 1371 return; 1372 } 1373 1374 if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) { 1375 //cons_printf(portid, "error: %s.\n", itron_strerror(length)); 1376 goto err_ret; 1377 } 1378 1379 dly_tsk(1 * 1000); 1380 cons_printf(portid, "DNS header: flags: "); 1381 if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE | 1382 DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) { 1383 cons_printf(portid, (rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : ""); 1384 cons_printf(portid, (rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : ""); 1385 cons_printf(portid, (rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : ""); 1386 cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : ""); 1387 cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : ""); 1388 cons_printf(portid, " "); 1389 } 1390 cons_printf(portid, "opcode: "); 1391 cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW"); 1392 cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : ""); 1393 cons_printf(portid, ", rcode: %s.\n", 1394 (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED 1395 ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]); 1396 1397 if ((offset = show_dns_qdsection(portid, msg, length, &rslv)) < 0) { 1398 cons_printf(portid, "msg error: %s.\n", itron_strerror(offset)); 1399 } 1400 if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) { 1401 cons_printf(portid, "msg error: %s.\n", itron_strerror(offset)); 1402 } 1403 if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) { 1404 cons_printf(portid, "msg error: %s.\n", itron_strerror(offset)); 1405 } 1406 if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) { 1407 cons_printf(portid, "msg error: %s.\n", itron_strerror(offset)); 1408 } 1409 1410 err_ret: 1411 if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK) 1412 cons_printf(portid, "release buffer error: %s.\n", itron_strerror(error)); 1413 return; 1414 } 1415 1416 #endif /* of #ifdef USE_RESOLVER */ 1417 1418 #if defined(DHCP6_CLI_CFG) 1419 1420 /* 1421 * dhcp6c_info -- DHCPv6 クライアント情報の表示 1422 */ 1423 1424 static void 1425 dhcp6c_info (ID portid) 1426 { 1427 T_IN6_ADDR svaddr; 1428 SYSTIM bind_start; 1429 ER error; 1430 uint32_t expire, renew, rebind, deprefer; 1431 1432 if ((error = dhcp6c_get_info(&svaddr, &expire, &renew, &rebind, &deprefer, &bind_start)) == E_OK) { 1433 cons_printf(portid, " DHCPv6 server: %lI.\n", &svaddr); 1434 1435 #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS 1436 1437 cons_printf(portid, " DHCPv6 mode: stateless.\n"); 1438 1439 #elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL 1440 1441 cons_printf(portid, " DHCPv6 mode: statefull,\n"); 1442 cons_printf(portid, " Renew: %u:%02u:%02u, Deprefer: %u:%02u:%02u,\n", 1443 renew / 3600, ( renew / 60) % 60, renew % 60, 1444 deprefer / 3600, (deprefer / 60) % 60, deprefer % 60); 1445 cons_printf(portid, " Rebind: %u:%02u:%02u, Expire: %u:%02u:%02u.\n", 1446 rebind / 3600, ( rebind / 60) % 60, rebind % 60, 1447 expire / 3600, ( expire / 60) % 60, expire % 60); 1448 1449 #else /* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */ 1450 1451 #endif /* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */ 1452 1453 } 1454 else if (error == E_OBJ) 1455 cons_printf(portid, " DHCPv6 server: not available.\n"); 1456 } 1457 1458 #endif /* of #if defined(DHCP6_CLI_CFG) */ 1459 1460 #if defined(DHCP4_CLI_CFG) 1461 1462 /* 1463 * dhcp4c_info -- DHCPv4 クライアント情報の表示 1464 */ 1465 1466 static void 1467 dhcp4c_info (ID portid) 1468 { 1469 T_IN4_ADDR svaddr; 1470 SYSTIM bind_start; 1471 ER error; 1472 uint32_t expire, renew, rebind; 1473 1474 if ((error = dhcp4c_get_info(&svaddr, &expire, &renew, &rebind, &bind_start)) == E_OK) { 1475 cons_printf(portid, " DHCPv4 server: %hI,\n", &svaddr); 1476 cons_printf(portid, " Renew: %u:%02u:%02u,\n", 1477 renew / 3600, (renew / 60) % 60, renew % 60); 1478 cons_printf(portid, " Rebind: %u:%02u:%02u, Expire: %u:%02u:%02u.\n", 1479 rebind / 3600, (rebind / 60) % 60, rebind % 60, 1480 expire / 3600, (expire / 60) % 60, expire % 60); 1481 } 1482 else if (error == E_OBJ) 1483 cons_printf(portid, " DHCPv4 server: not available.\n"); 1484 } 1485 1486 #endif /* of #if defined(DHCP4_CLI_CFG) */ 1487 1488 #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) 1489 1490 /* 1491 * dhcpc -- DHCP クライアント情報の表示と制御 1492 */ 1493 1494 static void 1495 dhcpc (ID portid, char *line) 1496 { 1035 1497 WAI_NET_CONS_PRINTF(); 1036 cons_printf(portid, 1037 "Routing Table Status\n" 1038 "IX Target Mask Gateway Expire\n"); 1039 1040 for (ix = 0; ix < NUM_ROUTE_ENTRY; ix ++) { 1041 if ((routing_tbl[ix].flags & IN_RTF_DEFINED) == 0) 1042 ; 1043 else if ((routing_tbl[ix].flags & IN_RTF_REDIRECT) != 0) 1044 cons_printf(portid, "%2d %15I %15I %15I %4d\n", 1045 ix, 1046 &routing_tbl[ix].target, 1047 &routing_tbl[ix].mask, 1048 &routing_tbl[ix].gateway, 1049 &routing_tbl[ix].expire); 1050 else 1051 cons_printf(portid, "%2d %15I %15I %I\n", 1052 ix, 1053 &routing_tbl[ix].target, 1054 &routing_tbl[ix].mask, 1055 &routing_tbl[ix].gateway); 1056 1498 1499 switch (*line) { 1500 1501 #if defined(DHCP6_CLI_CFG) 1502 case '6': /* DHCPv6 の制御 */ 1503 switch (*(line + 1)) { 1504 case 'r': /* アドレス情報を解放する。*/ 1505 dhcp6c_rel_info(); 1506 break; 1507 1508 case 'n': /* アドレス情報を再取得する。*/ 1509 dhcp6c_renew_info(); 1510 break; 1511 1512 default: 1513 dhcp6c_info(portid); 1514 break; 1515 } 1516 break; 1517 #endif /* of #if defined(DHCP6_CLI_CFG) */ 1518 1519 #if defined(DHCP4_CLI_CFG) 1520 case '4': /* DHCPv4 の制御 */ 1521 switch (*(line + 1)) { 1522 case 'r': /* アドレス情報を解放する。*/ 1523 dhcp4c_rel_info(); 1524 break; 1525 1526 case 'n': /* アドレス情報を再取得する。*/ 1527 dhcp4c_renew_info(); 1528 break; 1529 1530 default: 1531 dhcp4c_info(portid); 1532 break; 1533 } 1534 break; 1535 #endif /* of #if defined(DHCP4_CLI_CFG) */ 1536 1537 default: 1538 1539 #if defined(DHCP6_CLI_CFG) 1540 dhcp6c_info(portid); 1541 #endif 1542 1543 #if defined(DHCP4_CLI_CFG) 1544 dhcp4c_info(portid); 1545 #endif 1546 break; 1057 1547 } 1058 1548 … … 1061 1551 } 1062 1552 1063 #endif /* of #if NUM_ROUTE_ENTRY > 0 */ 1064 1065 #endif /* of #if defined(SUPPORT_INET4) */ 1553 #endif /* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */ 1066 1554 1067 1555 #if defined(SUPPORT_INET6) … … 1124 1612 while (ptitle -- > 0) 1125 1613 cons_printf(portid, " "); 1126 cons_printf(portid, " % I\n", &dr[rix].addr);1614 cons_printf(portid, " %lI\n", &dr[rix].addr); 1127 1615 } 1128 1616 } … … 1188 1676 while (rtitle -- > 0) 1189 1677 cons_printf(portid, " "); 1190 cons_printf(portid, "%4d % I\n", pr[pix].prefix_len, &pr[pix].prefix);1678 cons_printf(portid, "%4d %lI\n", pr[pix].prefix_len, &pr[pix].prefix); 1191 1679 } 1192 1680 } … … 1198 1686 #endif /* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */ 1199 1687 1200 #if NUM_ ROUTE_ENTRY > 01688 #if NUM_IN6_ROUTE_ENTRY > 0 1201 1689 1202 1690 /* 1203 * routing _table_status -- 経路表の出力1691 * routing6_table_status -- 経路表(IPv6)の出力 1204 1692 */ 1205 1693 1206 1694 static void 1207 routing _table_status (ID portid, char *line)1695 routing6_table_status (ID portid, char *line) 1208 1696 { 1209 1697 SYSTIM now; … … 1212 1700 WAI_NET_CONS_PRINTF(); 1213 1701 cons_printf(portid, 1214 " Routing Table Status\n"1702 "\nRouting Table Status (IPv6)\n" 1215 1703 "IX Expire flags Prefix Target Gateway\n"); 1216 1704 1217 for (ix = 0; ix < NUM_ STATIC_ROUTE_ENTRY; ix ++) {1218 cons_printf(portid, "%2d STATIC - %6d %30 I %I\n",1705 for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++) { 1706 cons_printf(portid, "%2d STATIC - %6d %30lI %lI\n", 1219 1707 ix, 1220 routing _tbl[ix].prefix_len,1221 &routing _tbl[ix].target,1222 &routing _tbl[ix].gateway);1708 routing6_tbl[ix].prefix_len, 1709 &routing6_tbl[ix].target, 1710 &routing6_tbl[ix].gateway); 1223 1711 1224 1712 } … … 1228 1716 now /= SYSTIM_HZ; 1229 1717 1230 for ( ; ix < NUM_ ROUTE_ENTRY; ix ++)1231 if (routing _tbl[ix].flags & IN_RTF_DEFINED)1232 cons_printf(portid, "%2d %6d %02x %6d %30 I %I\n",1718 for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++) 1719 if (routing6_tbl[ix].flags & IN_RTF_DEFINED) 1720 cons_printf(portid, "%2d %6d %02x %6d %30lI %lI\n", 1233 1721 ix, 1234 (uint32_t)(routing _tbl[ix].expire - now) <= 01235 ? 0 : routing _tbl[ix].expire - now,1236 routing _tbl[ix].flags,1237 routing _tbl[ix].prefix_len,1238 &routing _tbl[ix].target,1239 &routing _tbl[ix].gateway);1722 (uint32_t)(routing6_tbl[ix].expire - now) <= 0 1723 ? 0 : routing6_tbl[ix].expire - now, 1724 routing6_tbl[ix].flags, 1725 routing6_tbl[ix].prefix_len, 1726 &routing6_tbl[ix].target, 1727 &routing6_tbl[ix].gateway); 1240 1728 1241 1729 SIG_NET_CONS_PRINTF(); … … 1243 1731 } 1244 1732 1245 #endif /* of #if NUM_ ROUTE_ENTRY > 0 */1733 #endif /* of #if NUM_IN6_ROUTE_ENTRY > 0 */ 1246 1734 1247 1735 #endif /* of #if defined(SUPPORT_INET6) */ 1248 1736 1249 #if NUM_ROUTE_ENTRY > 0 1737 #if defined(SUPPORT_INET4) 1738 1739 #if NUM_IN4_ROUTE_ENTRY > 0 1250 1740 1251 1741 /* 1252 * routing_status -- ルーティング情報 1742 * routing4_table_status -- 経路表(IPv4)の出力 1743 */ 1744 1745 static void 1746 routing4_table_status (ID portid, char *line) 1747 { 1748 int_t ix; 1749 1750 if ('0' <= *(line = skip_blanks(line)) && *line <= '9') { 1751 T_IN4_ADDR target, mask, gateway; 1752 1753 ix = atoi(line); 1754 while ('0' <= *line && *line <= '9') 1755 line ++; 1756 line = get_ipv4addr(&target, skip_blanks(line)); 1757 line = get_ipv4addr(&mask, skip_blanks(line)); 1758 get_ipv4addr(&gateway, skip_blanks(line)); 1759 in4_add_route(ix, target, mask, gateway); 1760 } 1761 1762 WAI_NET_CONS_PRINTF(); 1763 cons_printf(portid, 1764 "\nRouting Table Status (IPv4)\n" 1765 "IX Target Mask Gateway Expire\n"); 1766 1767 for (ix = 0; ix < NUM_IN4_ROUTE_ENTRY; ix ++) { 1768 if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0) 1769 ; 1770 else if ((routing4_tbl[ix].flags & IN_RTF_REDIRECT) != 0) 1771 cons_printf(portid, "%2d %15hI %15hI %15hI %4d\n", 1772 ix, 1773 &routing4_tbl[ix].target, 1774 &routing4_tbl[ix].mask, 1775 &routing4_tbl[ix].gateway, 1776 &routing4_tbl[ix].expire); 1777 else 1778 cons_printf(portid, "%2d %15hI %15hI %hI\n", 1779 ix, 1780 &routing4_tbl[ix].target, 1781 &routing4_tbl[ix].mask, 1782 &routing4_tbl[ix].gateway); 1783 1784 } 1785 1786 SIG_NET_CONS_PRINTF(); 1787 FLUSH_SND_BUFF(); 1788 } 1789 1790 #endif /* of #if NUM_IN4_ROUTE_ENTRY > 0 */ 1791 1792 #endif /* of #if defined(SUPPORT_INET4) */ 1793 1794 /* 1795 * routing_status -- 経路情報 1253 1796 */ 1254 1797 … … 1258 1801 switch (*line) { 1259 1802 1260 #if defined(SUPPORT_INET6) 1261 1262 #if NUM_ND6_DEF_RTR_ENTRY > 0 1803 #if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0 1263 1804 1264 1805 case 'l': /* ディフォルトルータ・リスト情報 */ … … 1270 1811 break; 1271 1812 1272 #endif /* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */ 1273 1274 #endif /* of #if defined(SUPPORT_INET6) */ 1275 1276 default: /* ルーティング表情報 */ 1277 routing_table_status(portid, line); 1813 #endif /* #if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0 */ 1814 1815 default: 1816 1817 /* 経路表情報 */ 1818 1819 #if defined(SUPPORT_INET6) && NUM_IN6_ROUTE_ENTRY > 0 1820 routing6_table_status(portid, line); 1821 #endif 1822 1823 #if defined(SUPPORT_INET4) && NUM_IN4_ROUTE_ENTRY > 0 1824 routing4_table_status(portid, line); 1825 #endif 1826 1278 1827 break; 1279 1280 break; 1281 } 1282 } 1283 1284 #endif /* of #if NUM_ROUTE_ENTRY > 0 */ 1828 } 1829 } 1285 1830 1286 1831 /* 1287 * network_status -- ネットワークの状態の出力1288 */ 1289 1290 staticvoid1291 network_status (ID portid, char *line)1832 * dbg_cons_network_status -- ネットワークの状態の出力 1833 */ 1834 1835 void 1836 dbg_cons_network_status (ID portid, char *line) 1292 1837 { 1293 1838 switch (*line) { … … 1296 1841 1297 1842 case 'a': /* IF アドレス情報 */ 1298 ifa_status(portid, line + 1); 1843 1844 #if defined(SUPPORT_INET6) 1845 ifa6_status(portid, line + 1); 1846 #endif 1847 #if defined(SUPPORT_INET4) 1848 ifa4_status(portid, line + 1); 1849 #endif 1850 1299 1851 break; 1300 1852 … … 1313 1865 #endif /* of #if NET_COUNT_ENABLE */ 1314 1866 1315 #if NUM_ROUTE_ENTRY > 0 1316 1317 case 'r': /* ルーティング情報 */ 1867 case 'r': /* 経路情報 */ 1318 1868 routing_status(portid, line + 1); 1319 1869 break; 1320 1870 1321 #endif /* of #if NUM_ROUTE_ENTRY > 0 */ 1871 #ifdef USE_RESOLVER 1872 1873 case 's': /* name lookup */ 1874 if (*(line = skip_blanks(line + 1)) == '\0') 1875 dns_info(portid); 1876 else 1877 name_lookup(portid, line); 1878 break; 1879 1880 #endif /* of #ifdef USE_RESOLVER */ 1322 1881 1323 1882 #ifdef SUPPORT_TCP … … 1338 1897 1339 1898 default: 1340 cons_printf(portid, "no such command: '%c%c' \n", *(line - 1), *line);1899 cons_printf(portid, "no such command: '%c%c'.\n", *(line - 1), *line); 1341 1900 SIG_NET_CONS_PRINTF(); 1342 1901 FLUSH_SND_BUFF(); … … 1345 1904 } 1346 1905 1347 #if defined(SUPPORT_INET4)1348 1349 1906 /* 1350 * ifconfig -- ネットワークインタフェースの構成情報 1351 */ 1352 1353 static void 1354 ifconfig (ID portid, char *line) 1355 { 1356 T_IFNET *ifp = IF_GET_IFNET(); 1357 T_IN4_ADDR bc; 1358 1907 * dbg_cons_ifconfig -- ネットワークインタフェースの構成情報 1908 */ 1909 1910 void 1911 dbg_cons_ifconfig (ID portid, char *line) 1912 { 1359 1913 #ifdef SUPPORT_ETHER 1360 1914 1361 if (*(line = skip_blanks(line))) { 1362 T_IN4_ADDR addr, mask; 1363 1364 GET_IPADDR(&mask, skip_blanks(GET_IPADDR(&addr, line))); 1365 in4_add_ifaddr(addr, mask); 1366 } 1367 1368 #endif /* of #ifdef SUPPORT_ETHER */ 1915 T_IF_SOFTC *ic; 1369 1916 1370 1917 WAI_NET_CONS_PRINTF(); 1371 cons_printf(portid, 1372 "Network Interface Configurations\n"); 1373 1374 #ifdef SUPPORT_ETHER 1375 1376 cons_printf(portid, 1377 "ether: %M\n", 1378 IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr); 1379 1380 #endif /* of #ifdef SUPPORT_ETHER */ 1381 1382 bc = (ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask; 1383 cons_printf(portid, 1384 "inet: %I, mask: %I, broadcast: %I\n", 1385 &ifp->in_ifaddr.addr, 1386 &ifp->in_ifaddr.mask, 1387 &bc); 1388 1918 ic = IF_ETHER_NIC_GET_SOFTC(); 1919 cons_printf(portid, "ether: %M\n", ic->ifaddr.lladdr); 1389 1920 SIG_NET_CONS_PRINTF(); 1390 1921 FLUSH_SND_BUFF(); 1391 } 1392 1393 #endif /* of #if defined(SUPPORT_INET4) */ 1394 1395 #if defined( SUPPORT_INET6)1922 1923 #endif /* of #ifdef SUPPORT_ETHER */ 1924 } 1925 1926 #if defined(NETAPP_IP6_CFG) 1396 1927 1397 1928 /* 1398 * ifconfig -- ネットワークインタフェースの構成情報1399 */ 1400 1401 staticvoid1402 ifconfig(ID portid, char *line)1929 * dbg_cons_ifconfig6 -- ネットワークインタフェース(IPv6)の構成情報 1930 */ 1931 1932 void 1933 dbg_cons_ifconfig6 (ID portid, char *line) 1403 1934 { 1404 1935 #ifdef SUPPORT_ETHER 1405 1936 1406 T_IF_SOFTC *ic;1407 1937 T_IFNET *ifp = IF_GET_IFNET(); 1408 1938 int_t ix; … … 1410 1940 1411 1941 WAI_NET_CONS_PRINTF(); 1412 ic = IF_ETHER_NIC_GET_SOFTC();1413 cons_printf(portid, "ether: %M\ninet6:\nIX Expire Preffered RTR PFX Flags IP Address\n",1414 ic->ifaddr.lladdr);1415 1942 1416 1943 /* expire と vltime の単位は [s]。*/ … … 1418 1945 now /= SYSTIM_HZ; 1419 1946 1947 cons_printf(portid, "IPv6:\nIX Expire Preffered RTR PFX Flags IP Address\n"); 1420 1948 for (ix = 0; ix < NUM_IN6_IFADDR_ENTRY; ix ++) { 1421 if (ifp->in _ifaddrs[ix].flags & IN6_IFF_DEFINED) {1949 if (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) { 1422 1950 cons_printf(portid, " %d", ix); 1423 if (ifp->in _ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)1951 if (ifp->in6_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME) 1424 1952 cons_printf(portid, " INFIN INFIN"); 1425 1953 else 1426 1954 cons_printf(portid, " %8d %9d", 1427 (uint32_t)(ifp->in _ifaddrs[ix].lifetime.expire - now) <= 01428 ? 0 : ifp->in_ifaddrs[ix].lifetime.expire - now,1429 (uint32_t)(ifp->in _ifaddrs[ix].lifetime.preferred - now) <= 01430 ? 0 : ifp->in_ifaddrs[ix].lifetime.preferred - now);1431 if (ifp->in _ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)1955 (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.expire - now) <= 0 1956 ? 0 : ifp->in6_ifaddrs[ix].lifetime.expire - now, 1957 (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.preferred - now) <= 0 1958 ? 0 : ifp->in6_ifaddrs[ix].lifetime.preferred - now); 1959 if (ifp->in6_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH) 1432 1960 cons_printf(portid, " -"); 1433 1961 else 1434 cons_printf(portid, " %3d", ifp->in _ifaddrs[ix].router_index);1435 if (ifp->in _ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)1962 cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].router_index); 1963 if (ifp->in6_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID) 1436 1964 cons_printf(portid, " -"); 1437 1965 else 1438 cons_printf(portid, " %3d", ifp->in_ifaddrs[ix].prefix_index); 1439 cons_printf(portid, " %02x %I\n", 1440 ifp->in_ifaddrs[ix].flags, 1441 &ifp->in_ifaddrs[ix].addr); 1442 } 1443 } 1966 cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].prefix_index); 1967 cons_printf(portid, " %02x %lI\n", 1968 ifp->in6_ifaddrs[ix].flags, 1969 &ifp->in6_ifaddrs[ix].addr); 1970 } 1971 } 1972 1973 #ifdef DHCP6_CLI_CFG 1974 dhcp6c_info(portid); 1975 #endif 1444 1976 1445 1977 SIG_NET_CONS_PRINTF(); … … 1449 1981 } 1450 1982 1451 #endif /* of #if defined(SUPPORT_INET6) */ 1983 #endif /* of #if defined(NETAPP_IP6_CFG) */ 1984 1985 #if defined(NETAPP_IP4_CFG) 1452 1986 1453 1987 /* 1454 * show_config -- コンフィギュレーション設定の表示 1455 */ 1456 1457 static void 1458 show_config (ID portid, char *line) 1988 * dbg_cons_ifconfig4 -- ネットワークインタフェース(IPv4)の構成情報 1989 */ 1990 1991 void 1992 dbg_cons_ifconfig4 (ID portid, char *line) 1993 { 1994 T_IFNET *ifp = IF_GET_IFNET(); 1995 T_IN4_ADDR bc; 1996 1997 #ifdef SUPPORT_ETHER 1998 1999 if (*(line = skip_blanks(line))) { 2000 T_IN4_ADDR addr, mask; 2001 2002 get_ipv4addr(&mask, skip_blanks(get_ipv4addr(&addr, line))); 2003 in4_add_ifaddr(addr, mask); 2004 } 2005 2006 #endif /* of #ifdef SUPPORT_ETHER */ 2007 2008 WAI_NET_CONS_PRINTF(); 2009 2010 bc = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask; 2011 cons_printf(portid, 2012 "IPv4: %hI, mask: %hI, broadcast: %hI\n", 2013 &ifp->in4_ifaddr.addr, 2014 &ifp->in4_ifaddr.mask, 2015 &bc); 2016 2017 #ifdef DHCP4_CLI_CFG 2018 dhcp4c_info(portid); 2019 #endif 2020 2021 SIG_NET_CONS_PRINTF(); 2022 FLUSH_SND_BUFF(); 2023 } 2024 2025 #endif /* of #if defined(NETAPP_IP4_CFG) */ 2026 2027 /* 2028 * dbg_cons_show_config -- コンフィギュレーション設定の表示 2029 */ 2030 2031 void 2032 dbg_cons_show_config (ID portid, char *line) 1459 2033 { 1460 2034 #if defined(SUPPORT_ETHER) … … 1464 2038 #endif /* of #if defined(SUPPORT_ETHER) */ 1465 2039 1466 #if defined(DHCP_CFG)1467 1468 2040 cons_printf(portid, "DHCP:\n"); 1469 1470 cons_printf(portid, " DHCP_CFG: On\n"); 1471 1472 #endif /* of #if define(DHCP_CFG) */ 2041 cons_printf(portid, " DHCP6_CLI_CFG: "); 2042 2043 #if defined(DHCP6_CLI_CFG) 2044 2045 cons_printf(portid, "On\n Mode: "); 2046 2047 #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS 2048 cons_printf(portid, "STATELESS\n"); 2049 #elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL 2050 cons_printf(portid, "STATEFULL\n"); 2051 #endif 2052 2053 #else /* of #if define(DHCP6_CLI_CFG) */ 2054 2055 cons_printf(portid, "Off\n"); 2056 2057 #endif /* of #if define(DHCP6_CLI_CFG) */ 2058 2059 cons_printf(portid, " DHCP4_CLI_CFG: "); 2060 2061 #if defined(DHCP4_CLI_CFG) 2062 cons_printf(portid, "On\n"); 2063 #else 2064 cons_printf(portid, "Off\n"); 2065 #endif 2066 2067 cons_printf(portid, "Resolver:\n"); 2068 cons_printf(portid, " USE_RESOLVER: "); 2069 2070 #if defined(USE_RESOLVER) 2071 cons_printf(portid, "On\n"); 2072 #else 2073 cons_printf(portid, "Off\n"); 2074 #endif 1473 2075 1474 2076 #if defined(SUPPORT_TCP) 1475 2077 1476 2078 cons_printf(portid, "TCP:\n"); 1477 1478 cons_printf(portid, " TCP_CFG_PASSIVE_OPEN: ");1479 #if defined(TCP_CFG_PASSIVE_OPEN)1480 cons_printf(portid, "On\n");1481 #else1482 cons_printf(portid, "Off\n");1483 #endif1484 2079 1485 2080 cons_printf(portid, " TCP_CFG_OPT_MSS: "); … … 1553 2148 #endif 1554 2149 2150 cons_printf(portid, " TCP_CFG_NON_BLOCKING_COMPAT14: "); 2151 #if defined(TCP_CFG_NON_BLOCKING_COMPAT14) 2152 cons_printf(portid, "On\n"); 2153 #else 2154 cons_printf(portid, "Off\n"); 2155 #endif 2156 1555 2157 cons_printf(portid, " TCP_CFG_EXTENTIONS: "); 1556 2158 #if defined(TCP_CFG_EXTENTIONS) 1557 2159 #if defined(USE_TCP_EXTENTIONS) 1558 2160 cons_printf(portid, "Use\n"); 1559 #if defined(SUPPORT_INET4)1560 cons_printf(portid, " NUM_VRID_TCP_REPS: %3d\n", NUM_VRID_TCP_REPS);1561 cons_printf(portid, " NUM_VRID_TCP_CEPS: %3d\n", NUM_VRID_TCP_CEPS);1562 #endif1563 2161 #if defined(SUPPORT_INET6) 1564 2162 cons_printf(portid, " NUM_VRID_TCP6_REPS: %3d\n", NUM_VRID_TCP6_REPS); 1565 2163 cons_printf(portid, " NUM_VRID_TCP6_CEPS: %3d\n", NUM_VRID_TCP6_CEPS); 1566 #endif 2164 #endif 2165 #if defined(SUPPORT_INET4) 2166 cons_printf(portid, " NUM_VRID_TCP4_REPS: %3d\n", NUM_VRID_TCP4_REPS); 2167 cons_printf(portid, " NUM_VRID_TCP4_CEPS: %3d\n", NUM_VRID_TCP4_CEPS); 2168 #endif 1567 2169 #else 1568 2170 cons_printf(portid, "On\n"); … … 1589 2191 #if defined(SUPPORT_INET4) 1590 2192 addr = TCP_CFG_TRACE_IPV4_RADDR; 1591 cons_printf(portid, " TCP_CFG_TRACE_IPV4_RADDR: % I\n", &addr);2193 cons_printf(portid, " TCP_CFG_TRACE_IPV4_RADDR: %hI\n", &addr); 1592 2194 #endif 1593 2195 cons_printf(portid, " TCP_CFG_TRACE_RPORTNO: %d\n", TCP_CFG_TRACE_RPORTNO); … … 1633 2235 #endif 1634 2236 2237 cons_printf(portid, " UDP_CFG_NON_BLOCKING_COMPAT14: "); 2238 #if defined(UDP_CFG_NON_BLOCKING_COMPAT14) 2239 cons_printf(portid, "On\n"); 2240 #else 2241 cons_printf(portid, "Off\n"); 2242 #endif 2243 1635 2244 cons_printf(portid, " UDP_CFG_EXTENTIONS: "); 1636 2245 #if defined(UDP_CFG_EXTENTIONS) … … 1640 2249 cons_printf(portid, "On\n"); 1641 2250 #endif 1642 cons_printf(portid, " NUM_VRID_UDP _CEPS: %3d\n", NUM_VRID_UDP_CEPS);2251 cons_printf(portid, " NUM_VRID_UDP4_CEPS: %3d\n", NUM_VRID_UDP4_CEPS); 1643 2252 cons_printf(portid, " NUM_VRID_UDP6_CEPS: %3d\n", NUM_VRID_UDP6_CEPS); 1644 2253 #else … … 1667 2276 #endif 1668 2277 2278 #if defined(NUM_REDIRECT_ROUTE_ENTRY) 1669 2279 #if NUM_REDIRECT_ROUTE_ENTRY > 0 1670 2280 cons_printf(portid, " TMO_IN_REDIRECT: %4d[s]\n", TMO_IN_REDIRECT / NET_TIMER_HZ); 1671 2281 #endif 1672 1673 #if defined(SUPPORT_INET4) 1674 1675 cons_printf(portid, "IPv4:\n"); 1676 1677 cons_printf(portid, " IP4_CFG_FRAGMENT: "); 1678 1679 #if defined(IP 4_CFG_FRAGMENT)2282 #endif /* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */ 2283 2284 #if defined(SUPPORT_INET6) 2285 2286 cons_printf(portid, "IPv6:\n"); 2287 2288 cons_printf(portid, " IP6_IPV4_MAPPED_ADDR: "); 2289 #if defined(IP6_CFG_IPV4_MAPPED_ADDR) 1680 2290 cons_printf(portid, "On\n"); 1681 cons_printf(portid, " NUM_IP4_FRAG_QUEUE: %4d\n", NUM_IP4_FRAG_QUEUE);1682 cons_printf(portid, " IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);1683 2291 #else 1684 2292 cons_printf(portid, "Off\n"); 1685 #endif /* of #if defined(IP4_CFG_FRAGMENT) */ 1686 1687 #if defined(SUPPORT_ETHER) 1688 addr = IPV4_ADDR_LOCAL; 1689 cons_printf(portid, " IPV4_ADDR_LOCAL: %I\n", &addr); 1690 addr = IPV4_ADDR_LOCAL_MASK; 1691 cons_printf(portid, " IPV4_ADDR_LOCAL_MASK: %I\n", &addr); 1692 addr = IPV4_ADDR_DEFAULT_GW; 1693 cons_printf(portid, " IPV4_ADDR_DEFAULT_GW: %I\n", &addr); 1694 #endif /* of #if defined(SUPPORT_ETHER) */ 2293 #endif 1695 2294 1696 2295 cons_printf(portid, " Routing Table:\n"); 1697 cons_printf(portid, " NUM_STATIC_ROUTE_ENTRY: %d\n", NUM_STATIC_ROUTE_ENTRY); 1698 cons_printf(portid, " NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY); 1699 1700 #endif /* of #if defined(SUPPORT_INET4) */ 1701 1702 #if defined(SUPPORT_INET6) 1703 1704 cons_printf(portid, "IPv6:\n"); 1705 1706 cons_printf(portid, " Routing Table:\n"); 1707 cons_printf(portid, " NUM_STATIC_ROUTE_ENTRY: %d\n", NUM_STATIC_ROUTE_ENTRY); 1708 cons_printf(portid, " NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY); 2296 cons_printf(portid, " NUM_IN6_STATIC_ROUTE_ENTRY: %d\n", NUM_IN6_STATIC_ROUTE_ENTRY); 2297 cons_printf(portid, " NUM_IN6_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN6_REDIRECT_ROUTE_ENTRY); 1709 2298 1710 2299 cons_printf(portid, "ND:\n"); … … 1730 2319 #endif /* of #if defined(SUPPORT_INET6) */ 1731 2320 2321 #if defined(SUPPORT_INET4) 2322 2323 cons_printf(portid, "IPv4:\n"); 2324 2325 cons_printf(portid, " IP4_CFG_FRAGMENT: "); 2326 2327 #if defined(IP4_CFG_FRAGMENT) 2328 cons_printf(portid, "On\n"); 2329 cons_printf(portid, " NUM_IP4_FRAG_QUEUE: %4d\n", NUM_IP4_FRAG_QUEUE); 2330 cons_printf(portid, " IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE); 2331 #else 2332 cons_printf(portid, "Off\n"); 2333 #endif /* of #if defined(IP4_CFG_FRAGMENT) */ 2334 2335 #if defined(SUPPORT_ETHER) 2336 addr = IPV4_ADDR_LOCAL; 2337 cons_printf(portid, " IPV4_ADDR_LOCAL: %hI\n", &addr); 2338 addr = IPV4_ADDR_LOCAL_MASK; 2339 cons_printf(portid, " IPV4_ADDR_LOCAL_MASK: %hI\n", &addr); 2340 addr = IPV4_ADDR_DEFAULT_GW; 2341 cons_printf(portid, " IPV4_ADDR_DEFAULT_GW: %hI\n", &addr); 2342 #endif /* of #if defined(SUPPORT_ETHER) */ 2343 2344 cons_printf(portid, " Routing Table:\n"); 2345 cons_printf(portid, " NUM_IN4_STATIC_ROUTE_ENTRY: %d\n", NUM_IN4_STATIC_ROUTE_ENTRY); 2346 cons_printf(portid, " NUM_IN4_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN4_REDIRECT_ROUTE_ENTRY); 2347 2348 #endif /* of #if defined(SUPPORT_INET4) */ 2349 1732 2350 #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER) 1733 2351 … … 1771 2389 #endif 1772 2390 2391 cons_printf(portid, " ETHER_COLLECT_ADDR: "); 2392 #if defined(ETHER_COLLECT_ADDR) 2393 cons_printf(portid, "On\n"); 2394 #else 2395 cons_printf(portid, "Off\n"); 2396 #endif 2397 1773 2398 #endif /* of #if defined(SUPPORT_ETHER) */ 1774 2399 … … 1854 2479 } 1855 2480 2481 #ifdef USE_PING 2482 2483 /* 2484 * ping コマンド 2485 */ 2486 2487 void 2488 dbg_cons_ping_comd (ID portid, char *line) 2489 { 2490 int_t tmo, size; 2491 char apip = DEFAULT_API_PROTO; 2492 2493 #if defined(SUPPORT_INET6) 2494 T_IN6_ADDR addr; 2495 #if defined(SUPPORT_INET4) 2496 T_IN4_ADDR addr4; 2497 #endif 2498 #else 2499 T_IN4_ADDR addr; 2500 #endif 2501 2502 #if defined(PING_CFG_I6RLP) 2503 2504 static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452"; 2505 static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352"; 2506 static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2"; 2507 2508 if (apip == '1') 2509 strcpy(line, i6rlp_pmtu_str1); 2510 else if (apip == '2') 2511 strcpy(line, i6rlp_pmtu_str2); 2512 else if (apip == '3') 2513 strcpy(line, i6rlp_pmtu_str3); 2514 2515 #endif /* of #ifdef PING_CFG_I6RLP */ 2516 2517 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 2518 2519 if ('0' <= *line && *line <= '9') { 2520 if (*line == '6') 2521 apip = API_PROTO_IPV6; 2522 if (*line == '4') 2523 apip = API_PROTO_IPV4; 2524 line ++; 2525 } 2526 2527 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 2528 2529 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 2530 syslog(LOG_NOTICE, "[PING] unknown host."); 2531 return; 2532 } 2533 2534 line = skip_blanks(line); 2535 if ('0' <= *line && *line <= '9') 2536 line = get_int(&tmo, line); 2537 else 2538 tmo = 3; 2539 2540 line = skip_blanks(line); 2541 if ('0' <= *line && *line <= '9') 2542 line = get_int(&size, line); 2543 else 2544 size = 64; 2545 2546 #if defined(SUPPORT_INET6) 2547 2548 #if defined(SUPPORT_INET4) 2549 2550 if (apip == API_PROTO_IPV6) { 2551 syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr)); 2552 ping6(&addr, (uint_t)tmo, (uint_t)size); 2553 } 2554 else { 2555 addr4 = ntohl(addr.s6_addr32[3]); 2556 syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr4)); 2557 ping4(&addr4, (uint_t)tmo, (uint_t)size); 2558 } 2559 2560 #else /* of #if defined(SUPPORT_INET4) */ 2561 2562 syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr)); 2563 ping6(&addr, (uint_t)tmo, (uint_t)size); 2564 2565 #endif /* of #if defined(SUPPORT_INET4) */ 2566 2567 #else /* of #if defined(SUPPORT_INET6) */ 2568 2569 2570 syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr)); 2571 ping4(&addr, (uint_t)tmo, (uint_t)size); 2572 2573 #endif /* of #if defined(SUPPORT_INET6) */ 2574 2575 } 2576 2577 #endif /* of #ifdef USE_PING */ 2578 2579 #ifdef USE_DBG_CONS_PARSER 2580 1856 2581 /* 1857 2582 * デバッグコマンド解析 1858 2583 */ 1859 2584 1860 staticvoid2585 void 1861 2586 dbg_parse (ID portid, char *line) 1862 2587 { 1863 2588 int_t cepid; 1864 ER error; 2589 ER error = E_OK; 2590 2591 #if defined(SUPPORT_UDP) && defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 2592 int_t udp_cep_ipproto; 2593 #endif 1865 2594 1866 2595 switch (*line) { … … 1870 2599 1871 2600 case 'f': /* show configurations */ 1872 show_config(portid, line + 1);2601 dbg_cons_show_config(portid, line + 1); 1873 2602 break; 1874 2603 … … 1880 2609 line ++; 1881 2610 if ((error = tcp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) { 1882 cons_printf(portid, "[TCP CAN CEP] error: %s \n", itron_strerror(error));2611 cons_printf(portid, "[TCP CAN CEP] error: %s.\n", itron_strerror(error)); 1883 2612 SIG_NET_CONS_PRINTF(); 1884 2613 FLUSH_SND_BUFF(); … … 1891 2620 1892 2621 case 'u': /* cancel UDP */ 2622 2623 #if defined(SUPPORT_INET6) 2624 2625 #if defined(SUPPORT_INET4) 2626 2627 udp_cep_ipproto = (*(line + 2) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6); 2628 cepid = atoi(line = skip_blanks(line + 3)); 2629 while ('0' <= *line && *line <= '9') 2630 line ++; 2631 2632 #if TNUM_UDP6_CEPID > 0 2633 2634 if (udp_cep_ipproto == API_PROTO_IPV6) { 2635 if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) { 2636 cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error)); 2637 SIG_NET_CONS_PRINTF(); 2638 FLUSH_SND_BUFF(); 2639 } 2640 } 2641 2642 #endif /* of #if TNUM_UDP6_CEPID > 0 */ 2643 2644 #if TNUM_UDP4_CEPID > 0 2645 2646 if (udp_cep_ipproto == API_PROTO_IPV4) { 2647 if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) { 2648 cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error)); 2649 SIG_NET_CONS_PRINTF(); 2650 FLUSH_SND_BUFF(); 2651 } 2652 } 2653 2654 #endif /* of #if TNUM_UDP4_CEPID > 0 */ 2655 2656 #else /* of #if defined(SUPPORT_INET4) */ 2657 2658 #if TNUM_UDP6_CEPID > 0 2659 1893 2660 cepid = atoi(line = skip_blanks(line + 2)); 1894 2661 while ('0' <= *line && *line <= '9') 1895 2662 line ++; 2663 1896 2664 if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) { 1897 cons_printf(portid, "[UDP CAN CEP] error: %s \n", itron_strerror(error));2665 cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error)); 1898 2666 SIG_NET_CONS_PRINTF(); 1899 2667 FLUSH_SND_BUFF(); 1900 2668 } 2669 2670 #endif /* of #if TNUM_UDP6_CEPID > 0 */ 2671 2672 #endif /* of #if defined(SUPPORT_INET4) */ 2673 2674 #else /* of #if defined(SUPPORT_INET6) */ 2675 2676 #if defined(SUPPORT_INET4) 2677 2678 #if TNUM_UDP4_CEPID > 0 2679 2680 cepid = atoi(line = skip_blanks(line + 2)); 2681 while ('0' <= *line && *line <= '9') 2682 line ++; 2683 2684 if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) { 2685 cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error)); 2686 SIG_NET_CONS_PRINTF(); 2687 FLUSH_SND_BUFF(); 2688 } 2689 2690 #endif /* of #if TNUM_UDP4_CEPID > 0 */ 2691 2692 #endif /* of #if defined(SUPPORT_INET4) */ 2693 2694 #endif /* of #if defined(SUPPORT_INET6) */ 2695 1901 2696 break; 1902 2697 … … 1906 2701 1907 2702 break; 1908 1909 #if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS)1910 2703 1911 2704 case 'd': /* discard client */ … … 1929 2722 #endif /* of #if defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */ 1930 2723 2724 #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) 2725 2726 case 'h': /* DHCP client */ 2727 dhcpc(portid, line + 2); 2728 break; 2729 2730 #endif /* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */ 2731 1931 2732 #ifdef USE_TCP_DISCARD_CLI 1932 2733 … … 1941 2742 default: 1942 2743 if ((error = psnd_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t)line)) != E_OK) { 1943 cons_printf(portid, "[TCP DISCARD CLI] error: %s \n",2744 cons_printf(portid, "[TCP DISCARD CLI] error: %s.\n", 1944 2745 itron_strerror(error)); 1945 2746 SIG_NET_CONS_PRINTF(); … … 1965 2766 default: 1966 2767 if ((error = psnd_dtq(DTQ_UDP_DISCARD_CLI, (intptr_t)line)) != E_OK) { 1967 cons_printf(portid, "[UDP DISCARD CLI] error: %s \n",2768 cons_printf(portid, "[UDP DISCARD CLI] error: %s.\n", 1968 2769 itron_strerror(error)); 1969 2770 SIG_NET_CONS_PRINTF(); … … 1981 2782 break; 1982 2783 1983 #endif /* of #if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */ 1984 1985 #if defined(USE_UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI) 2784 #if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI) 1986 2785 1987 2786 case 'e': /* echo client */ … … 2000 2799 default: 2001 2800 if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t)line)) != E_OK) { 2002 cons_printf(portid, "[TCP ECHO CLI] error: %s \n", itron_strerror(error));2801 cons_printf(portid, "[TCP ECHO CLI] error: %s.\n", itron_strerror(error)); 2003 2802 SIG_NET_CONS_PRINTF(); 2004 2803 FLUSH_SND_BUFF(); … … 2011 2810 #endif /* of #ifdef USE_TCP_ECHO_CLI */ 2012 2811 2013 #if def USE_UDP_ECHO_CLI2812 #if defined(USE_UDP_ECHO_CLI) 2014 2813 2015 2814 case 'u': /* UDP echo client */ 2016 line += 2; 2017 switch (*line) { 2815 switch (*(line + 2)) { 2018 2816 2019 2817 case 's': /* cancel UDP echo */ 2020 udp_echo_cli_valid = false; 2818 2819 #if defined(USE_UDP6_ECHO_CLI_TSK) 2820 2821 #if defined(USE_UDP4_ECHO_CLI_TSK) 2822 2823 if (*(line + 3) == '4') 2824 udp4_echo_cli_valid = false; 2825 else 2826 udp6_echo_cli_valid = false; 2827 2828 #else /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */ 2829 2830 udp6_echo_cli_valid = false; 2831 2832 #endif /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */ 2833 2834 #else /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */ 2835 2836 #if defined(USE_UDP4_CLI_TSK) 2837 2838 udp4_echo_cli_valid = false; 2839 2840 #endif /* of #if defined(USE_UDP4_CLI_TSK) */ 2841 2842 #endif /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */ 2843 2844 2021 2845 break; 2022 2846 2023 2847 default: 2024 if ((error = psnd_dtq(DTQ_UDP_ECHO_CLI, (intptr_t)line)) != E_OK) { 2025 cons_printf(portid, "[UDP ECHO CLI] error: %s\n", itron_strerror(error)); 2848 2849 line += 2; 2850 2851 #if defined(USE_UDP6_ECHO_CLI_TSK) 2852 2853 #if defined(USE_UDP4_ECHO_CLI_TSK) 2854 2855 if (*line == '4') { 2856 line ++; 2857 error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line); 2858 } 2859 else { 2860 if (*line && *line != ' ') 2861 line ++; 2862 error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line); 2863 } 2864 2865 #else /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */ 2866 2867 if (*line && *line != ' ') 2868 line ++; 2869 error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line); 2870 2871 #endif /* of #if defined(USE_UDP4_ECHO_CLI_TSK) */ 2872 2873 #else /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */ 2874 2875 if (*line && *line != ' ') 2876 line ++; 2877 error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line); 2878 2879 #endif /* of #if defined(USE_UDP6_ECHO_CLI_TSK) */ 2880 2881 if (error != E_OK) { 2882 cons_printf(portid, "[UDP ECHO CLI] error: %s.\n", itron_strerror(error)); 2026 2883 SIG_NET_CONS_PRINTF(); 2027 2884 FLUSH_SND_BUFF(); 2028 2885 } 2886 2029 2887 break; 2030 2888 … … 2032 2890 break; 2033 2891 2034 #endif /* of #if def USE_UDP_ECHO_CLI*/2892 #endif /* of #if defined(USE_UDP_ECHO_CLI) */ 2035 2893 2036 2894 } … … 2038 2896 break; 2039 2897 2040 #endif /* of #if defined(USE_ UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI) */2898 #endif /* of #if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI) */ 2041 2899 2042 2900 case 'i': 2043 2901 2044 if (*(line + 1) == 'f') 2045 ifconfig(portid, line + 2); 2902 if (*(line + 1) == 'f') { 2903 2904 dbg_cons_ifconfig (portid, line + 2); 2905 2906 #if defined(NETAPP_IP6_CFG) 2907 dbg_cons_ifconfig6(portid, line + 2); 2908 #endif 2909 2910 #if defined(NETAPP_IP4_CFG) 2911 dbg_cons_ifconfig4(portid, line + 2); 2912 #endif 2913 2914 } 2046 2915 2047 2916 #ifdef SUPPORT_PPP … … 2064 2933 2065 2934 case 'n': /* network status */ 2066 network_status(portid, line + 1);2935 dbg_cons_network_status(portid, line + 1); 2067 2936 break; 2068 2937 … … 2070 2939 2071 2940 if (*(line + 1) == 's') 2072 task_status(portid, skip_blanks(line + 2));2941 dbg_cons_task_status(portid, skip_blanks(line + 2)); 2073 2942 2074 2943 #ifdef USE_PING 2075 2944 2076 else { 2077 int_t tmo, size; 2078 T_IN_ADDR addr; 2079 2080 #ifdef PING_CFG_I6RLP 2081 static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452"; 2082 static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352"; 2083 static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2"; 2084 2085 if (*(line + 1) == '1') 2086 strcpy(line + 1, i6rlp_pmtu_str1); 2087 else if (*(line + 1) == '2') 2088 strcpy(line + 1, i6rlp_pmtu_str2); 2089 else if (*(line + 1) == '3') 2090 strcpy(line + 1, i6rlp_pmtu_str3); 2091 2092 #endif /* of #ifdef PING_CFG_I6RLP */ 2093 2094 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line + 1))); 2095 if ('0' <= *line && *line <= '9') 2096 line = get_int(&tmo, line); 2097 else 2098 tmo = 3; 2099 2100 line = skip_blanks(line + 1); 2101 if ('0' <= *line && *line <= '9') 2102 line = get_int(&size, line); 2103 else 2104 size = 64; 2105 2106 PING(&addr, (uint_t)tmo, (uint_t)size); 2107 } 2945 else 2946 dbg_cons_ping_comd(portid, line + 1); 2108 2947 2109 2948 #endif /* of #ifdef USE_PING */ … … 2113 2952 case 'r': /* release wait task */ 2114 2953 if ((error = rel_wai(atoi(skip_blanks(line + 1)))) != E_OK) { 2115 cons_printf(portid, "[REL WAI TSK] error: %s \n", itron_strerror(error));2954 cons_printf(portid, "[REL WAI TSK] error: %s.\n", itron_strerror(error)); 2116 2955 SIG_NET_CONS_PRINTF(); 2117 2956 FLUSH_SND_BUFF(); … … 2125 2964 2126 2965 case 't': /* TCP REP */ 2127 if ((error = tcp_del_rep(atoi(skip_blanks(line + 2)))) != E_OK) { 2128 cons_printf(portid, "[TCP DEL REP] error: %s\n", itron_strerror(error)); 2966 2967 error = tcp_del_rep(atoi(skip_blanks(line + 2))); 2968 if (error != E_OK) { 2969 cons_printf(portid, "[TCP DEL REP] ID: %d, error: %s.\n", 2970 atoi(skip_blanks(line + 2)), 2971 itron_strerror(error)); 2129 2972 SIG_NET_CONS_PRINTF(); 2130 2973 FLUSH_SND_BUFF(); … … 2137 2980 2138 2981 case 'u': /* UDP CEP */ 2139 if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) { 2140 cons_printf(portid, "[UDP DEL CEP] error: %s\n", itron_strerror(error)); 2982 2983 #if defined(USE_UDP6_ECHO_SRV_TSK) 2984 2985 #if defined(USE_UDP4_ECHO_SRV_TSK) 2986 2987 if (*(line + 2) == '4') { 2988 if ((error = udp_del_cep(atoi(skip_blanks(line + 3)))) != E_OK) { 2989 cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error)); 2990 SIG_NET_CONS_PRINTF(); 2991 FLUSH_SND_BUFF(); 2992 } 2993 } 2994 else { 2995 if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) { 2996 cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error)); 2997 SIG_NET_CONS_PRINTF(); 2998 FLUSH_SND_BUFF(); 2999 } 3000 } 3001 3002 #else /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3003 3004 if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) { 3005 cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error)); 2141 3006 SIG_NET_CONS_PRINTF(); 2142 3007 FLUSH_SND_BUFF(); 2143 3008 } 3009 3010 #endif /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3011 3012 #else /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */ 3013 3014 #if defined(USE_UDP4_ECHO_SRV_TSK) 3015 3016 if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) { 3017 cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error)); 3018 SIG_NET_CONS_PRINTF(); 3019 FLUSH_SND_BUFF(); 3020 } 3021 3022 #endif /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3023 3024 #endif /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */ 3025 2144 3026 break; 2145 3027 … … 2163 3045 case 'd': /* tcp discard server */ 2164 3046 if ((error = wup_tsk(TCP_DISCARD_SRV_TASK)) != E_OK) { 2165 cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s\n", itron_strerror(error));3047 //cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s.\n", itron_strerror(error)); 2166 3048 SIG_NET_CONS_PRINTF(); 2167 3049 FLUSH_SND_BUFF(); … … 2170 3052 #endif /* of #ifdef USE_TCP_DISCARD_SRV */ 2171 3053 2172 #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2)3054 #if defined(USE_TCP_ECHO_SRV1) 2173 3055 case 'e': /* tcp echo server */ 2174 if ((error = w up_tsk(TCP_ECHO_SRV_TASK)) != E_OK) {2175 cons_printf(portid, "[WUP UDP DISCARD SRV] error: %s\n", itron_strerror(error));3056 if ((error = wakeup_tcp_echo_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) { 3057 //cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error)); 2176 3058 SIG_NET_CONS_PRINTF(); 2177 3059 FLUSH_SND_BUFF(); 2178 3060 } 2179 3061 break; 2180 #endif /* of #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2) */ 3062 #endif /* of #if defined(USE_TCP_ECHO_SRV1) */ 3063 3064 #if defined(USE_TCP_ECHO_SRV2) 3065 case 'e': /* tcp echo server */ 3066 if ((error = wup_tsk(TCP_ECHO_SRV_TASK2)) != E_OK) { 3067 //cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error)); 3068 SIG_NET_CONS_PRINTF(); 3069 FLUSH_SND_BUFF(); 3070 } 3071 break; 3072 #endif /* of #if defined(USE_TCP_ECHO_SRV2) */ 2181 3073 2182 3074 #ifdef USE_WWW_SRV 2183 3075 case 'w': /* WWW server */ 2184 if ((error = w up_tsk(WWW_SRV_TASK1)) != E_OK) {2185 cons_printf(portid, "[WUP WWW SRV] error: %s\n", itron_strerror(error));3076 if ((error = wakeup_www_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) { 3077 //cons_printf(portid, "[WUP WWW SRV] error: %s.\n", itron_strerror(error)); 2186 3078 SIG_NET_CONS_PRINTF(); 2187 3079 FLUSH_SND_BUFF(); … … 2200 3092 switch (*(line + 2)) { 2201 3093 2202 #if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK) 3094 #if !defined(USE_UDP_CALL_BACK) 3095 2203 3096 case 'e': /* udp echo server */ 2204 if ((error = wup_tsk(UDP_ECHO_SRV_TASK)) != E_OK) { 2205 cons_printf(portid, "[WUP UDP ECHO SRV] error: %s\n", itron_strerror(error)); 3097 3098 #if defined(USE_UDP6_ECHO_SRV_TSK) 3099 3100 #if defined(USE_UDP4_ECHO_SRV_TSK) 3101 3102 if (*(line + 3) == '4') { 3103 if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) { 3104 cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error)); 3105 SIG_NET_CONS_PRINTF(); 3106 FLUSH_SND_BUFF(); 3107 } 3108 } 3109 else { 3110 if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) { 3111 cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error)); 3112 SIG_NET_CONS_PRINTF(); 3113 FLUSH_SND_BUFF(); 3114 } 3115 } 3116 3117 #else /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3118 3119 if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) { 3120 cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error)); 2206 3121 SIG_NET_CONS_PRINTF(); 2207 3122 FLUSH_SND_BUFF(); 2208 3123 } 3124 3125 #endif /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3126 3127 #else /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */ 3128 3129 #if defined(USE_UDP4_ECHO_SRV_TSK) 3130 3131 if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) { 3132 cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error)); 3133 SIG_NET_CONS_PRINTF(); 3134 FLUSH_SND_BUFF(); 3135 } 3136 3137 #endif /* of #if defined(USE_UDP4_ECHO_SRV_TSK) */ 3138 3139 #endif /* of #if defined(USE_UDP6_ECHO_SRV_TSK) */ 3140 2209 3141 break; 2210 #endif /* of #if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK) */ 3142 3143 #endif /* of #if !defined(USE_UDP_CALL_BACK) */ 2211 3144 2212 3145 } … … 2217 3150 default: 2218 3151 if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) { 2219 cons_printf(portid, "[WUP TSK] error: %s \n", itron_strerror(error));3152 cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error)); 2220 3153 SIG_NET_CONS_PRINTF(); 2221 3154 FLUSH_SND_BUFF(); … … 2230 3163 case 'w': /* wake up task */ 2231 3164 if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) { 2232 cons_printf(portid, "[WUP TSK] error: %s \n", itron_strerror(error));3165 cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error)); 2233 3166 SIG_NET_CONS_PRINTF(); 2234 3167 FLUSH_SND_BUFF(); … … 2242 3175 if (*line) { 2243 3176 2244 #ifdef USE_EXTRA_PARSE 2245 2246 extra_parse(line); 2247 2248 #else /* of #ifdef USE_EXTRA_PARSE */ 2249 2250 cons_printf(portid, "no such command: '%c'\n", *line); 3177 #ifdef USE_DBG_CONS_EXTRA_PARSE 3178 3179 //cons_printf(portid, "extra command: '%c'.\n", *line); 3180 dbg_cons_extra_parse(portid, line); 3181 3182 #else /* of #ifdef USE_DBG_CONS_EXTRA_PARSE */ 3183 3184 //cons_printf(portid, "command: '%c'.\n", *line); 3185 cons_printf(portid, "no such command: '%c'.\n", *line); 2251 3186 SIG_NET_CONS_PRINTF(); 2252 3187 FLUSH_SND_BUFF(); 2253 3188 2254 #endif /* of #ifdef USE_ EXTRA_PARSE */3189 #endif /* of #ifdef USE_DBG_CONS_EXTRA_PARSE */ 2255 3190 2256 3191 } … … 2258 3193 } 2259 3194 } 3195 3196 #endif /* of #ifdef USE_DBG_CONS_PARSER */ 2260 3197 2261 3198 /* … … 2268 3205 static char line[DBG_LINE_SIZE + 1]; 2269 3206 2270 uint_t len;2271 3207 ID tskid; 2272 3208 … … 2274 3210 #ifdef SUPPORT_ETHER 2275 3211 3212 #if 0 2276 3213 #if defined(SUPPORT_INET6) 2277 3214 2278 int_tlllen;3215 uint32_t lllen; 2279 3216 const uint8_t *lladdr; 2280 3217 2281 3218 #endif /* of #if defined(SUPPORT_INET6) */ 2282 2283 lcd_init(); 3219 #endif 3220 3221 lcd_initialize(0); 3222 3223 #if 0 3224 #if defined(SUPPORT_INET6) 3225 3226 dly_tsk(1 * 1000); 3227 lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr; 3228 for (lllen = ETHER_ADDR_LEN; lllen --; ) 3229 lcd_printf(LCD_PORTID, "%02x", *lladdr ++); 3230 lcd_putc(LCD_PORTID, '\n'); 3231 3232 #else /* of #if defined(SUPPORT_INET6) */ 2284 3233 2285 3234 if ((TINET_PRVER & UINT_C(0x0f)) > 0) 2286 lcd_printf( "TINET-%d.%d.%d\n",3235 lcd_printf(LCD_PORTID, "TINET-%d.%d.%d\n", 2287 3236 (TINET_PRVER >> 12) & UINT_C(0x0f), 2288 3237 (TINET_PRVER >> 4) & UINT_C(0x0f), 2289 3238 TINET_PRVER & UINT_C(0x0f)); 2290 3239 else 2291 lcd_printf( "TINET-%d.%d\n",3240 lcd_printf(LCD_PORTID, "TINET-%d.%d\n", 2292 3241 (TINET_PRVER >> 12) & UINT_C(0x0f), 2293 3242 (TINET_PRVER >> 4) & UINT_C(0x0f)); 2294 3243 2295 #if defined(SUPPORT_INET6)2296 2297 lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;2298 for (lllen = ETHER_ADDR_LEN; lllen --; )2299 lcd_printf("%02x", *lladdr ++);2300 lcd_printf("\n");2301 2302 #else /* of #if defined(SUPPORT_INET6) */2303 2304 lcd_puts(ip2str(NULL, in4_get_ifaddr(0)));2305 2306 3244 #endif /* of #if defined(SUPPORT_INET6) */ 3245 #endif 3246 3247 #if 0 3248 #if defined(SUPPORT_INET4) 3249 3250 dly_tsk(1 * 1000); 3251 lcd_puts(LCD_PORTID, ip2str(NULL, in4_get_ifaddr(0))); 3252 lcd_putc(LCD_PORTID, '\n'); 3253 3254 #endif /* of #if defined(SUPPORT_INET4) */ 3255 #endif 2307 3256 2308 3257 #endif /* of #ifdef SUPPORT_ETHER */ 2309 #e lse/* of #ifdef USE_LCD */3258 #endif /* of #ifdef USE_LCD */ 2310 3259 2311 3260 get_tid(&tskid); 2312 3261 cons_printf(CONSOLE_PORTID, "[CONSOLE:%d] started.\n", tskid); 2313 2314 #endif /* of #ifdef USE_LCD */2315 2316 3262 serial_ctl_por(CONSOLE_PORTID, 2317 3263 IOCTL_ECHO | IOCTL_CRLF | 2318 3264 IOCTL_FCSND | IOCTL_FCANY | IOCTL_FCRCV); 3265 netapp_srand (tskid); 2319 3266 while (true) { 2320 len =cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);3267 cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE); 2321 3268 dbg_parse(CONSOLE_PORTID, line); 2322 3269 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 53 53 54 54 extern void act_tasks (void); 55 extern void extra_parse (char *line); 55 extern void dbg_parse (ID portid, char *line); 56 extern void dbg_cons_extra_parse (ID portid, char *line); 57 extern void dbg_cons_task_status (ID portid, char *line); 58 extern void dbg_cons_network_status (ID portid, char *line); 59 extern void dbg_cons_ifconfig (ID portid, char *line); 60 extern void dbg_cons_ifconfig6 (ID portid, char *line); 61 extern void dbg_cons_ifconfig4 (ID portid, char *line); 62 extern void dbg_cons_show_config (ID portid, char *line); 63 extern void dbg_cons_ping_comd (ID portid, char *line); 56 64 57 65 #endif /* of #ifndef _DBG_CONS_ */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 60 60 #endif /* of #ifdef TARGET_KERNEL_JSP */ 61 61 62 #include <tinet_defs.h>63 64 #include <net/if.h>65 #include <net/if_ppp.h>66 #include <net/if_loop.h>67 #include <net/ethernet.h>68 #include <net/net.h>69 #include <net/net_timer.h>70 71 62 #include <netinet/in.h> 72 63 #include <netinet/in_itron.h> … … 109 100 #define TELNET_OPT_IAC (255) 110 101 102 #if defined(SUPPORT_INET6) 103 #define API_PROTO '6' 104 #else 105 #define API_PROTO '4' 106 #endif 107 111 108 /* 112 109 * 変数 … … 121 118 bool_t wait_accept = false; /* 接続要求待ち中 */ 122 119 120 #if defined(SUPPORT_INET6) 121 122 T_IPV6EP dst; 123 124 #else /* of #if defined(SUPPORT_INET6) */ 125 123 126 #if defined(SUPPORT_INET4) 124 127 … … 126 129 127 130 #endif /* of #if defined(SUPPORT_INET4) */ 128 129 #if defined(SUPPORT_INET6)130 131 T_IPV6EP dst;132 131 133 132 #endif /* of #if defined(SUPPORT_INET6) */ … … 156 155 get_tim(&now); 157 156 if (*(ER*)p_parblk == E_OK) { 158 syslog(LOG_NOTICE, "[NCS :%02u CBN] connected: %6lu, from: %s.%u",159 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);157 syslog(LOG_NOTICE, "[NCS%c:%02u CBN] conct: %7lu, from: %s.%u", 158 API_PROTO, cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 160 159 connected = true; 161 160 } 162 161 else 163 syslog(LOG_NOTICE, "[NCS:%02d CBN] error: %s", itron_strerror(*(ER*)p_parblk)); 162 syslog(LOG_NOTICE, "[NCS%c:%02d CBN] error: %s", 163 API_PROTO, itron_strerror(*(ER*)p_parblk)); 164 164 snd_len = snd_off = rcv_len = rcv_off = 0; 165 165 wait_accept = false; … … 193 193 if (snd_off > 0) { 194 194 if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS) 195 syslog(LOG_NOTICE, "[NCS :%02d SND] flush send error: %s",196 NET_CONS_CEPID, itron_strerror(error));195 syslog(LOG_NOTICE, "[NCS%c:%02d SND] flush send error: %s", 196 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 197 197 snd_len = snd_off = 0; 198 198 } … … 218 218 if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK) { 219 219 if (error != E_CLS) 220 syslog(LOG_NOTICE, "[NCS :%02d SND] send buff error: %s",221 NET_CONS_CEPID, itron_strerror(error));220 syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s", 221 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 222 222 syscall(sig_sem(SEM_NET_CONS_SEND)); 223 223 return; … … 226 226 if ((snd_len = tcp_get_buf(NET_CONS_CEPID, (void*)&snd_buff, TMO_FEVR)) <= 0) { 227 227 if (snd_len != E_CLS) 228 syslog(LOG_NOTICE, "[NCS :%02d SND] get buff error: %s",229 NET_CONS_CEPID, itron_strerror(snd_len));228 syslog(LOG_NOTICE, "[NCS%c:%02d SND] get buff error: %s", 229 API_PROTO, NET_CONS_CEPID, itron_strerror(snd_len)); 230 230 syscall(sig_sem(SEM_NET_CONS_SEND)); 231 231 return; … … 253 253 if ((error = tcp_rel_buf(NET_CONS_CEPID, rcv_len)) != E_OK) { 254 254 if (error != E_CLS) 255 syslog(LOG_NOTICE, "[NCS :%02d RCV] release buff error: %s",256 NET_CONS_CEPID, itron_strerror(error));255 syslog(LOG_NOTICE, "[NCS%c:%02d RCV] release buff error: %s", 256 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 257 257 discon_net_cons(); 258 258 return EOF; … … 264 264 else if (rcv_len < 0) { 265 265 if (rcv_len != E_CLS) 266 syslog(LOG_NOTICE, "[NCS :%02d RCV] recieve buff error: %s",267 NET_CONS_CEPID, itron_strerror(rcv_len));266 syslog(LOG_NOTICE, "[NCS%c:%02d RCV] recieve buff error: %s", 267 API_PROTO, NET_CONS_CEPID, itron_strerror(rcv_len)); 268 268 discon_net_cons(); 269 269 return EOF; … … 284 284 { 285 285 T_SERIAL_RPOR rpor; 286 int_t ch , req;286 int_t ch; 287 287 char uch; 288 288 ER error; … … 292 292 error = TCP_ACP_CEP(NET_CONS_CEPID, NET_CONS_REPID, &dst, TMO_NBLK); 293 293 #if 0 294 syslog(LOG_NOTICE, "[NCS:%02d ACP] status: %s",NET_CONS_CEPID, itron_strerror(error)); 294 syslog(LOG_NOTICE, "[NCS%c:%02d ACP] status: %s", 295 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 295 296 #endif 296 297 if (error != E_WBLK) … … 307 308 case TELNET_OPT_DO: 308 309 case TELNET_OPT_DONT: 309 req =cons_getchar_raw();310 cons_getchar_raw(); 310 311 break; 311 312 case TELNET_OPT_SB: … … 354 355 if (snd_off > 0) { 355 356 if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS) 356 syslog(LOG_NOTICE, "[NCS :%02d SND] send buff error: %s",357 NET_CONS_CEPID, itron_strerror(error));357 syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s", 358 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 358 359 } 359 360 if ((error = tcp_sht_cep(NET_CONS_CEPID)) != E_OK) 360 syslog(LOG_NOTICE, "[NCS :%02d SHT] shutdown error: %s",361 NET_CONS_CEPID, itron_strerror(error));361 syslog(LOG_NOTICE, "[NCS%c:%02d SHT] shutdown error: %s", 362 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 362 363 if ((error = tcp_cls_cep(NET_CONS_CEPID, TMO_FEVR)) != E_OK) 363 syslog(LOG_NOTICE, "[NCS :%02d CLS] close error: %s",364 NET_CONS_CEPID, itron_strerror(error));364 syslog(LOG_NOTICE, "[NCS%c:%02d CLS] close error: %s", 365 API_PROTO, NET_CONS_CEPID, itron_strerror(error)); 365 366 connected = false; 366 367 syscall(sig_sem(SEM_NET_CONS_SEND)); 367 368 get_tim(&now); 368 syslog(LOG_NOTICE, "[NCS :%02u SND] disconnected:%5lu, from: %s.%u",369 NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);369 syslog(LOG_NOTICE, "[NCS%c:%02u SND] discn: %7lu, from: %s.%u", 370 API_PROTO, NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 370 371 } 371 372 return error; … … 499 500 case 'M': 500 501 str = va_arg(ap, char*); 501 put_macaddr(CONSOLE_PORTID, str, width);502 put_macaddr(CONSOLE_PORTID, (uint8_t *)str, width); 502 503 break; 503 504 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 39 39 */ 40 40 41 #if defined(SUPPORT_INET6) 42 43 #define PUT_IPADDR(p,a,w) put_ipv6addr(p,a,w) 44 45 #else /* of #if defined(SUPPORT_INET6) */ 46 41 47 #if defined(SUPPORT_INET4) 48 42 49 #define PUT_IPADDR(p,a,w) put_ipv4addr(p,a,w) 43 #endif44 50 45 # if defined(SUPPORT_INET6)46 #define PUT_IPADDR(p,a,w) put_ipv6addr(p,a,w) 47 #endif 51 #endif /* of #if defined(SUPPORT_INET4) */ 52 53 #endif /* of #if defined(SUPPORT_INET6) */ 48 54 49 55 /* … … 52 58 53 59 #ifndef CONSOLE_PORTID 60 #define CONSOLE_PORTID LOGTASK_PORTID 61 #endif 54 62 55 #define CONSOLE_PORTID LOGTASK_PORTID 63 /* 64 * コンソールに用いる LCD ポート番号 65 */ 56 66 57 # endif /* of #ifndef CONSOLE_PORTID */67 #define LCD_PORTID 0 58 68 59 69 /* … … 80 90 extern int_t put_macaddr (ID portid, uint8_t *mac, int_t width); 81 91 82 #if defined(SUPPORT_INET4)92 #ifdef T_IN4_ADDR_DEFINED 83 93 extern int_t put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width); 84 94 #endif 85 86 #if defined(SUPPORT_INET6) 95 #ifdef T_IN6_ADDR_DEFINED 87 96 extern int_t put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width); 88 97 #endif -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 44 44 #include <sil.h> 45 45 #include <syssvc/serial.h> 46 #include <syssvc/logtask.h> 47 #include <t_syslog.h> 46 48 #include "kernel_cfg.h" 47 49 #include "tinet_cfg.h" … … 62 64 63 65 #include <net/net.h> 66 #include <net/net_endian.h> 64 67 65 68 #include <netinet/in.h> … … 68 71 #include <netapp/netapp.h> 69 72 #include <netapp/netapp_var.h> 73 #include <netapp/resolver.h> 70 74 71 75 #ifdef USE_NETAPP_SUBR 76 77 /* 78 * IPv6 と IPv4 で引数が異なる関数のコンパイル 79 */ 80 81 #if defined(SUPPORT_INET6) 82 83 #ifdef USE_TCP_EXTENTIONS 84 85 const ID vrid_tcp6_cep[] = 86 { 87 #if NUM_VRID_TCP6_CEPS >= 1 88 TCP6_RSV_CEPID1, 89 #endif 90 #if NUM_VRID_TCP6_CEPS >= 2 91 TCP6_RSV_CEPID2, 92 #endif 93 #if NUM_VRID_TCP6_CEPS >= 3 94 TCP6_RSV_CEPID3, 95 #endif 96 #if NUM_VRID_TCP6_CEPS >= 4 97 TCP6_RSV_CEPID4, 98 #endif 99 }; 100 101 const ID vrid_tcp6_rep[] = 102 { 103 #if NUM_VRID_TCP6_REPS >= 1 104 TCP6_RSV_REPID1, 105 #endif 106 #if NUM_VRID_TCP6_REPS >= 2 107 TCP6_RSV_REPID2, 108 #endif 109 }; 110 111 ID tskid_tcp6_cep[NUM_VRID_TCP6_CEPS]; 112 ID tskid_tcp6_rep[NUM_VRID_TCP6_REPS]; 113 114 #endif /* #ifdef USE_TCP_EXTENTIONS */ 115 116 #ifdef USE_UDP_EXTENTIONS 117 118 const ID vrid_udp6_cep[] = 119 { 120 #if NUM_VRID_UDP6_CEPS >= 1 121 UDP6_RSV_CEPID1, 122 #endif 123 #if NUM_VRID_UDP6_CEPS >= 2 124 UDP6_RSV_CEPID2, 125 #endif 126 }; 127 128 ID tskid_udp6_cep[NUM_VRID_UDP6_CEPS]; 129 130 #endif /* #ifdef USE_UDP_EXTENTIONS */ 131 132 #undef TCP_CRE_REP 133 #undef UDP_CRE_CEP 134 #undef UDP_DEL_CEP 135 #undef TCP_IS_CEPID 136 #undef ALLOC_TCP_REP 137 #undef ALLOC_TCP_CEP 138 #undef ALLOC_UDP_CEP 139 #undef FREE_TCP_REP 140 #undef FREE_TCP_CEP 141 #undef FREE_UDP_CEP 142 #undef T_TCPN_CREP 143 #undef T_UDPN_CCEP 144 #undef NUM_VRID_TCP_CEPS 145 #undef NUM_VRID_TCP_REPS 146 #undef NUM_VRID_UDP_CEPS 147 #undef VRID_TCP_CEP 148 #undef VRID_UDP_CEP 149 #undef VRID_TCP_REP 150 #undef TSKID_TCP_CEP 151 #undef TSKID_TCP_REP 152 #undef TSKID_UDP_CEP 153 #undef API_IPPROTO 154 155 #define TCP_CRE_REP tcp6_cre_rep 156 #define UDP_CRE_CEP udp6_cre_cep 157 #define UDP_DEL_CEP udp6_del_cep 158 159 #define TCP_IS_CEPID tcp6_is_cepid 160 #define ALLOC_TCP_REP alloc_tcp6_rep 161 #define ALLOC_TCP_CEP alloc_tcp6_cep 162 #define ALLOC_UDP_CEP alloc_udp6_cep 163 #define FREE_TCP_REP free_tcp6_rep 164 #define FREE_TCP_CEP free_tcp6_cep 165 #define FREE_UDP_CEP free_udp6_cep 166 #define T_TCPN_CREP T_TCP6_CREP 167 #define T_UDPN_CCEP T_UDP6_CCEP 168 #define NUM_VRID_TCP_CEPS NUM_VRID_TCP6_CEPS 169 #define NUM_VRID_TCP_REPS NUM_VRID_TCP6_REPS 170 #define NUM_VRID_UDP_CEPS NUM_VRID_UDP6_CEPS 171 #define VRID_TCP_CEP vrid_tcp6_cep 172 #define VRID_TCP_REP vrid_tcp6_rep 173 #define VRID_UDP_CEP vrid_udp6_cep 174 #define TSKID_TCP_CEP tskid_tcp6_cep 175 #define TSKID_TCP_REP tskid_tcp6_rep 176 #define TSKID_UDP_CEP tskid_udp6_cep 177 #define API_IPPROTO API_PROTO_IPV6 178 179 #include <netapp/netappn_subr.c> 180 181 #endif /* of #if defined(SUPPORT_INET6) */ 182 183 #if defined(SUPPORT_INET4) 184 185 #ifdef USE_TCP_EXTENTIONS 186 187 const ID vrid_tcp4_cep[] = 188 { 189 #if NUM_VRID_TCP4_CEPS >= 1 190 TCP4_RSV_CEPID1, 191 #endif 192 #if NUM_VRID_TCP4_CEPS >= 2 193 TCP4_RSV_CEPID2, 194 #endif 195 #if NUM_VRID_TCP4_CEPS >= 3 196 TCP4_RSV_CEPID3, 197 #endif 198 #if NUM_VRID_TCP4_CEPS >= 4 199 TCP4_RSV_CEPID4, 200 #endif 201 }; 202 203 const ID vrid_tcp4_rep[] = 204 { 205 #if NUM_VRID_TCP4_REPS >= 1 206 TCP4_RSV_REPID1, 207 #endif 208 #if NUM_VRID_TCP4_REPS >= 2 209 TCP4_RSV_REPID2, 210 #endif 211 }; 212 213 ID tskid_tcp4_cep[NUM_VRID_TCP4_CEPS]; 214 ID tskid_tcp4_rep[NUM_VRID_TCP4_REPS]; 215 216 #endif /* #ifdef USE_TCP_EXTENTIONS */ 217 218 #ifdef USE_UDP_EXTENTIONS 219 220 const ID vrid_udp4_cep[] = 221 { 222 #if NUM_VRID_UDP4_CEPS >= 1 223 UDP4_RSV_CEPID1, 224 #endif 225 #if NUM_VRID_UDP4_CEPS >= 2 226 UDP4_RSV_CEPID2, 227 #endif 228 }; 229 230 ID tskid_udp4_cep[NUM_VRID_UDP4_CEPS]; 231 232 #endif /* #ifdef USE_UDP_EXTENTIONS */ 233 234 #undef TCP_CRE_REP 235 #undef UDP_CRE_CEP 236 #undef UDP_DEL_CEP 237 #undef TCP_IS_CEPID 238 #undef ALLOC_TCP_REP 239 #undef ALLOC_TCP_CEP 240 #undef ALLOC_UDP_CEP 241 #undef FREE_TCP_REP 242 #undef FREE_TCP_CEP 243 #undef FREE_UDP_CEP 244 #undef T_TCPN_CREP 245 #undef T_UDPN_CCEP 246 #undef NUM_VRID_TCP_CEPS 247 #undef NUM_VRID_TCP_REPS 248 #undef NUM_VRID_UDP_CEPS 249 #undef VRID_TCP_CEP 250 #undef VRID_TCP_REP 251 #undef VRID_UDP_CEP 252 #undef TSKID_TCP_CEP 253 #undef TSKID_TCP_REP 254 #undef TSKID_UDP_CEP 255 #undef API_IPPROTO 256 257 #define TCP_CRE_REP tcp_cre_rep 258 #define UDP_CRE_CEP udp_cre_cep 259 #define UDP_DEL_CEP udp_del_cep 260 #define TCP_IS_CEPID tcp4_is_cepid 261 #define ALLOC_TCP_REP alloc_tcp4_rep 262 #define ALLOC_TCP_CEP alloc_tcp4_cep 263 #define ALLOC_UDP_CEP alloc_udp4_cep 264 #define FREE_TCP_REP free_tcp4_rep 265 #define FREE_TCP_CEP free_tcp4_cep 266 #define FREE_UDP_CEP free_udp4_cep 267 #define T_TCPN_CREP T_TCP_CREP 268 #define T_UDPN_CCEP T_UDP_CCEP 269 #define NUM_VRID_TCP_CEPS NUM_VRID_TCP4_CEPS 270 #define NUM_VRID_TCP_REPS NUM_VRID_TCP4_REPS 271 #define NUM_VRID_UDP_CEPS NUM_VRID_UDP4_CEPS 272 #define VRID_TCP_CEP vrid_tcp4_cep 273 #define VRID_TCP_REP vrid_tcp4_rep 274 #define VRID_UDP_CEP vrid_udp4_cep 275 #define TSKID_TCP_CEP tskid_tcp4_cep 276 #define TSKID_TCP_REP tskid_tcp4_rep 277 #define TSKID_UDP_CEP tskid_udp4_cep 278 #define API_IPPROTO API_PROTO_IPV4 279 280 #include <netapp/netappn_subr.c> 281 282 #endif /* of #if defined(SUPPORT_INET4) */ 283 284 #undef TCP_CRE_REP 285 #undef ALLOC_TCPN_REP 286 #undef ALLOC_TCPN_CEP 287 #undef ALLOC_UDPN_CEP 288 #undef FREE_TCPN_REP 289 #undef FREE_TCPN_CEP 290 #undef FREE_UDPN_CEP 291 #undef T_TCPN_CREP 292 #undef NUM_VRID_TCP_REPS 293 #undef NUM_VRID_UDP_CEPS 294 #undef VRID_TCP_CEP 295 #undef VRID_TCP_REP 296 #undef VRID_UDP_CEP 297 #undef TSKID_TCP_CEP 298 #undef TSKID_TCP_REP 299 #undef TSKID_UDP_CEP 300 301 /* 302 * 変数 303 */ 304 305 static uint32_t rand_next = ULONG_C(1); 306 307 #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 308 309 const T_IN6_ADDR in6_addr_unspecified = 310 IPV6_ADDR_UNSPECIFIED_INIT; 311 312 #endif /* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 72 313 73 314 /* … … 83 324 const char radhex[] = "0123456789abcdef"; 84 325 const char radHEX[] = "0123456789ABCDEF"; 326 327 /* 328 * netapp_rand -- 乱数を返す。 329 */ 330 331 uint32_t 332 netapp_rand (void) 333 { 334 rand_next = (rand_next * 99991 + 12345) & ULONG_C(0x7fffffff); 335 return rand_next; 336 } 337 338 /* 339 * srand -- 乱数を初期化する。 340 */ 341 342 void 343 netapp_srand (uint32_t seed) 344 { 345 SYSTIM now; 346 347 syscall(get_tim(&now)); 348 rand_next += now + seed; 349 } 85 350 86 351 #ifndef USE_NET_CONS … … 160 425 return pchars; 161 426 } 162 163 #if defined(SUPPORT_INET4)164 427 165 428 /* … … 186 449 } 187 450 188 #define PUT_IPADDR(p,a,w) put_ipv4addr(p,a,w)189 190 #endif /* of #if defined(SUPPORT_INET4) */191 192 #if defined(SUPPORT_INET6)193 194 451 /* 195 452 * ipv6addr -- IPv6 アドレス出力 … … 199 456 put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width) 200 457 { 201 int_t len = 0, ix ;458 int_t len = 0, ix, len6; 202 459 bool_t omit = false, zero = false; 203 460 204 if (addr == NULL ) {461 if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) { 205 462 cons_putchar(portid, '0'); 206 463 cons_putchar(portid, ':'); … … 210 467 } 211 468 else { 212 for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) { 469 if (in6_is_addr_ipv4mapped(addr)) 470 len6 = sizeof(T_IN6_ADDR) / 2 - 2; 471 else 472 len6 = sizeof(T_IN6_ADDR) / 2; 473 for (ix = 0; ix < len6; ix ++) { 213 474 if (omit) { 214 475 len += cons_putnumber(portid, ntohs(addr->s6_addr16[ix]), 16, radhex, 0, false, ' '); … … 234 495 } 235 496 497 if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) { 498 T_IN4_ADDR ip4addr; 499 500 ip4addr = ntohl(addr->s6_addr32[3]); 501 len += put_ipv4addr(portid, &ip4addr, 0); 502 } 503 236 504 for ( ; len < width; len ++) 237 505 cons_putchar(portid, ' '); … … 239 507 return len; 240 508 } 241 242 #define PUT_IPADDR(p,a,w) put_ipv6addr(p,a,w)243 244 #endif /* of #if defined(SUPPORT_INET6) */245 509 246 510 /* … … 275 539 long_t val; 276 540 char padchar, *str; 277 int_t ch, width, longflag, left; 278 279 #if defined(SUPPORT_INET4) 541 int_t ch, width, longflag, shortflag, left; 280 542 T_IN4_ADDR *addr; 281 #endif /* of #if defined(SUPPORT_INET4) */282 543 283 544 va_start(ap, fmt); … … 288 549 } 289 550 290 width = longflag = 0;551 width = longflag = shortflag = 0; 291 552 padchar = ' '; 292 553 293 if ( ch== '-') { /* 左詰め */554 if (*fmt == '-') { /* 左詰め */ 294 555 fmt ++; 295 556 left = -1; … … 310 571 while (ch == 'l') { /* long (long) の指定 */ 311 572 longflag ++; 573 ch = *fmt ++; 574 } 575 576 while (ch == 'h') { /* short の指定 */ 577 shortflag ++; 312 578 ch = *fmt ++; 313 579 } … … 358 624 case 'I': 359 625 626 if (longflag) { 627 str = va_arg(ap, char*); 628 put_ipv6addr(portid, (T_IN6_ADDR *)str, width); 629 } 630 else if (shortflag) { 631 addr = va_arg(ap, T_IN4_ADDR *); 632 put_ipv4addr(portid, addr, width); 633 } 634 else { 635 636 #if defined(SUPPORT_INET6) 637 638 str = va_arg(ap, char*); 639 put_ipv6addr(portid, (T_IN6_ADDR *)str, width); 640 641 #else /* of #if defined(SUPPORT_INET6) */ 642 360 643 #if defined(SUPPORT_INET4) 361 644 362 addr = va_arg(ap, T_IN4_ADDR *);363 put_ipv4addr(portid, addr, width);645 addr = va_arg(ap, T_IN4_ADDR *); 646 put_ipv4addr(portid, addr, width); 364 647 365 648 #endif /* of #if defined(SUPPORT_INET4) */ 366 649 367 #if defined(SUPPORT_INET6)368 369 str = va_arg(ap, char*);370 put_ipv6addr(portid, (T_IN6_ADDR *)str, width);371 372 650 #endif /* of #if defined(SUPPORT_INET6) */ 373 651 652 } 374 653 break; 375 654 376 655 case 'M': 377 656 str = va_arg(ap, char*); 378 put_macaddr(portid, str, width);657 put_macaddr(portid, (uint8_t *)str, width); 379 658 break; 380 659 … … 396 675 397 676 /* 677 * host2msg16 -- 16ビットの値を、バイトオーダーを調整してメッセージに書き込む。 678 */ 679 680 void 681 host2msg16 (void *msg, uint16_t host_data) 682 { 683 uint16_t msg_data; 684 685 msg_data = htons(host_data); 686 memcpy(msg, &msg_data, sizeof(msg_data)); 687 } 688 689 /* 690 * host2msg32 -- 32ビットの値を、バイトオーダーを調整してメッセージに書き込む。 691 */ 692 693 void 694 host2msg32 (void *msg, uint32_t host_data) 695 { 696 uint32_t msg_data; 697 698 msg_data = htonl(host_data); 699 memcpy(msg, &msg_data, sizeof(msg_data)); 700 } 701 702 /* 703 * msg2host16 -- 16ビットの値を、バイトオーダーを調整してメッセージから読み出す。 704 */ 705 706 uint16_t 707 msg2host16 (void *msg) 708 { 709 uint16_t host_data; 710 711 memcpy(&host_data, msg, sizeof(host_data)); 712 return htons(host_data); 713 } 714 715 /* 716 * msg2host32 -- 32ビットの値を、バイトオーダーを調整してメッセージから読み出す。 717 */ 718 719 uint32_t 720 msg2host32 (void *msg) 721 { 722 uint32_t host_data; 723 724 memcpy(&host_data, msg, sizeof(host_data)); 725 return htonl(host_data); 726 } 727 728 /* 398 729 * skip_blanks -- 空白と TAB をスキップする。 399 730 */ … … 416 747 int_t oct; 417 748 418 *addr = 0;749 *addr = IPV4_ADDRANY; 419 750 while ('0' <= *line && *line <= '9') { 420 751 oct = 0; … … 425 756 line ++; 426 757 } 758 #if 1 759 return *addr == IPV4_ADDRANY ? NULL : line; 760 #else 427 761 return line; 428 } 429 430 #if defined(SUPPORT_INET6) 762 #endif 763 } 764 765 #if defined(SUPPORT_INET6) || defined(USE_RESOLVER) 431 766 432 767 /* … … 438 773 { 439 774 int_t word, ix = 0, omit = 0, six; 775 char *ipv4line; 440 776 441 777 memset(addr, 0, sizeof(T_IN6_ADDR)); 442 while (ix < 8 && 443 (('0' <= *line && *line <= '9') || 444 ('a' <= *line && *line <= 'f') || 445 ('A' <= *line && *line <= 'F'))) { 446 word = 0; 447 while (('0' <= *line && *line <= '9') || 448 ('a' <= *line && *line <= 'f') || 449 ('A' <= *line && *line <= 'F')) { 450 if ('0' <= *line && *line <= '9') 451 word = (word << 4) + (*line ++) - '0'; 452 else if ('a' <= *line && *line <= 'f') 453 word = (word << 4) + (*line ++) - 'a' + 10; 454 else if ('A' <= *line && *line <= 'F') 455 word = (word << 4) + (*line ++) - 'A' + 10; 456 } 457 addr->s6_addr16[ix ++] = htons(word); 458 if (*line == ':') { 459 line ++; 778 779 /* 780 * IPv4 アドレス(数字.)を検出したら IPv4 アドレスとして入力し、 781 * IPv4 射影アドレスに変換する。 782 */ 783 for (ipv4line = line; '0' <= *ipv4line && *ipv4line <= '9'; ipv4line ++) 784 ; 785 if (*ipv4line == '.') { 786 T_IN4_ADDR ipv4addr; 787 788 line = get_ipv4addr(&ipv4addr, line); 789 in6_make_ipv4mapped (addr, ipv4addr); 790 } 791 else { 792 while (ix < 8 && 793 (('0' <= *line && *line <= '9') || 794 ('a' <= *line && *line <= 'f') || 795 ('A' <= *line && *line <= 'F'))) { 796 word = 0; 797 while (('0' <= *line && *line <= '9') || 798 ('a' <= *line && *line <= 'f') || 799 ('A' <= *line && *line <= 'F')) { 800 if ('0' <= *line && *line <= '9') 801 word = (word << 4) + (*line ++) - '0'; 802 else if ('a' <= *line && *line <= 'f') 803 word = (word << 4) + (*line ++) - 'a' + 10; 804 else if ('A' <= *line && *line <= 'F') 805 word = (word << 4) + (*line ++) - 'A' + 10; 806 } 807 addr->s6_addr16[ix ++] = htons(word); 460 808 if (*line == ':') { 461 omit = ix;462 809 line ++; 463 } 464 } 465 } 466 if (omit > 0) { 467 six = 7; 468 while (ix > omit) { 469 addr->s6_addr16[six --] = addr->s6_addr16[-- ix]; 470 addr->s6_addr16[ ix ] = 0; 810 if (*line == ':') { 811 omit = ix; 812 line ++; 813 } 814 } 815 } 816 if (omit > 0) { 817 six = 7; 818 while (ix > omit) { 819 addr->s6_addr16[six --] = addr->s6_addr16[-- ix]; 820 addr->s6_addr16[ ix ] = 0; 821 } 471 822 } 472 823 } … … 474 825 } 475 826 476 #endif /* of #if defined(SUPPORT_INET6) */827 #endif /* of #if defined(SUPPORT_INET6) || defined(USE_RESOLVER) */ 477 828 478 829 /* … … 559 910 } 560 911 561 #ifdef USE_TCP_EXTENTIONS 562 563 const ID vrid_tcp_rep[] = 564 { 565 #if NUM_VRID_TCP_REPS >= 1 566 TCP_RSV_REPID1, 567 #endif 568 #if NUM_VRID_TCP_REPS >= 2 569 TCP_RSV_REPID2, 570 #endif 571 }; 572 573 const ID vrid_tcp_cep[] = 574 { 575 #if NUM_VRID_TCP_CEPS >= 1 576 TCP_RSV_CEPID1, 577 #endif 578 #if NUM_VRID_TCP_CEPS >= 2 579 TCP_RSV_CEPID2, 580 #endif 581 #if NUM_VRID_TCP_CEPS >= 3 582 TCP_RSV_CEPID3, 583 #endif 584 #if NUM_VRID_TCP_CEPS >= 4 585 TCP_RSV_CEPID4, 586 #endif 587 }; 588 589 ID tskid_tcp_rep[NUM_VRID_TCP_REPS]; 590 ID tskid_tcp_cep[NUM_VRID_TCP_CEPS]; 591 592 /* 593 * alloc_tcp_rep -- TCP 受付口を獲得する。 594 */ 595 596 ER 597 alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep) 598 { 599 int_t ix; 600 601 *repid = TCP_REP_NONE; 602 syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK)); 603 for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) { 604 if (tskid_tcp_rep[ix] == TSK_NONE) { 605 *repid = vrid_tcp_rep[ix]; 606 tskid_tcp_rep[ix] = tskid; 912 #ifdef USE_RESOLVER 913 914 /* 915 * dns_strtype -- DNS の type の文字列を返す。 916 */ 917 918 const char * 919 dns_strtype (uint_t type) 920 { 921 switch (type) { 922 case DNS_TYPE_A: 923 return "A"; 924 break; 925 case DNS_TYPE_NS: 926 return "NS"; 927 break; 928 case DNS_TYPE_CNAME: 929 return "CNAME"; 930 break; 931 case DNS_TYPE_SOA: 932 return "SOA"; 933 break; 934 case DNS_TYPE_PTR: 935 return "PTR"; 936 break; 937 case DNS_TYPE_AAAA: 938 return "AAAA"; 939 break; 940 default: 941 return "unknown type"; 942 break; 943 } 944 } 945 946 /* 947 * dns_strclass -- DNS の class を表示する。 948 */ 949 950 const char * 951 dns_strclass (uint_t class) 952 { 953 switch (class) { 954 case DNS_CLASS_IN: 955 return "IN"; 956 break; 957 default: 958 return "unknown class"; 959 break; 960 } 961 } 962 963 /* 964 * resolv_hoststr -- 文字列のFQDN・ホスト名・IPv6/IPv4 アドレスを解析する。 965 */ 966 967 #define IS_HOSTCH_DIGIT(c) (('0'<=(c)&&(c)<='9')) 968 #define IS_HOSTCH_XDIGIT(c) (IS_HOSTCH_DIGIT(c)||('a'<=(c)&&(c)<='f')||('A'<=(c)&&(c)<='F')) 969 #define IS_HOSTCH_ALPHA(c) (('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='z')) 970 #define IS_HOSTCH_ALNUM(c) (IS_HOSTCH_ALPHA(c)||IS_HOSTCH_DIGIT(c)) 971 #define IS_HOSTCH_IPV6ADDR(c) (IS_HOSTCH_XDIGIT(c)||(c)==':') 972 #define IS_HOSTCH_IPV4ADDR(c) (IS_HOSTCH_DIGIT(c)||(c)=='.') 973 #define IS_HOSTCH_IPADDR(c) (IS_HOSTCH_XDIGIT(c)||(c)==':'||(c)=='.') 974 #define IS_HOSTCH_NAME_FIRST(c) (IS_HOSTCH_ALPHA(c)) 975 #define IS_HOSTCH_NAME(c) (IS_HOSTCH_ALNUM(c)||(c)=='-'||(c)=='.') 976 #define IS_HOSTCH_BLANK(c) ((c)=='\0'||(c)==' '||(c)=='\t') 977 978 char * 979 resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line) 980 { 981 char *h, *p; 982 983 h = hostname; 984 p = line = skip_blanks(line); 985 986 if (IS_HOSTCH_IPADDR(*p)) { 987 while (IS_HOSTCH_DIGIT(*p)) { 988 if (h - hostname > name_size) 989 return NULL; 990 *h ++ = *p ++; 991 } 992 if (p > line && *p == '.') { 993 while (IS_HOSTCH_IPV4ADDR(*p)) { 994 if (h - hostname > name_size) 995 return NULL; 996 *h ++ = *p ++; 997 } 998 if (IS_HOSTCH_BLANK(*p)) { 999 *flags |= HOSTSTR_IPV4; 1000 *h = '\0'; 1001 return p; 1002 } 1003 } 1004 else if (IS_HOSTCH_IPADDR(*p)) { 1005 while (IS_HOSTCH_IPADDR(*p)) { 1006 if (h - hostname > name_size) 1007 return NULL; 1008 *h ++ = *p ++; 1009 } 1010 if (IS_HOSTCH_BLANK(*p)) { 1011 *flags |= HOSTSTR_IPV6; 1012 *h = '\0'; 1013 return p; 1014 } 1015 } 1016 h = hostname; 1017 p = line; 1018 } 1019 1020 if (IS_HOSTCH_NAME_FIRST(*p)) { 1021 *flags |= HOSTSTR_HOSTNAME; 1022 while (IS_HOSTCH_NAME(*p)) { 1023 if (h - hostname > name_size) 1024 return NULL; 1025 if (*p == '.') 1026 *flags |= HOSTSTR_FQDN; 1027 *h ++ = *p ++; 1028 } 1029 } 1030 else 1031 *flags |= HOSTSTR_OTHER; 1032 1033 *h = '\0'; 1034 return p; 1035 } 1036 1037 /* 1038 * show_dns_domain_name -- DNS のドメイン名を表示する。 1039 */ 1040 1041 uint_t 1042 show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset) 1043 { 1044 uint8_t *ptr; 1045 uint_t c; 1046 1047 ptr = hdr + offset; 1048 while (*ptr) { 1049 if ((*ptr & DNS_MSG_COMP_MARK) == DNS_MSG_COMP_MARK) { 1050 show_dns_domain_name(portid, hdr, (*ptr & ~DNS_MSG_COMP_MARK) << 8 | *(ptr + 1)); 1051 ptr += 2; 607 1052 break; 608 1053 } 609 } 610 syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK)); 611 612 if (*repid == TCP_REP_NONE) 613 return E_NOEXS; 1054 else { 1055 for (c = 1; c <= *ptr; c++) 1056 cons_printf(portid, "%c", *(ptr + c)); 1057 ptr += *ptr + 1; 1058 if (*ptr) 1059 cons_printf(portid, "."); 1060 } 1061 } 1062 return ptr - hdr; 1063 } 1064 1065 /* 1066 * resolv_options -- アドレス解決のオプション解析 1067 */ 1068 1069 char * 1070 resolv_options (uint_t *flags, char *line, char apip) 1071 { 1072 #if defined(SUPPORT_INET6) 1073 T_IN6_ADDR in6_addr; 1074 #endif 1075 1076 #if defined(SUPPORT_INET4) 1077 T_IN4_ADDR in4_addr; 1078 #endif 1079 1080 line = skip_blanks(line); 1081 1082 #if defined(SUPPORT_INET6) 1083 1084 #if defined(SUPPORT_INET4) 1085 1086 *flags |= DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4; 1087 if (apip == API_PROTO_IPV4) 1088 *flags |= DNS_LUP_FLAGS_QTYPE_A; 614 1089 else 615 return TCP_CRE_REP(*repid, crep); 616 } 617 618 /* 619 * free_tcp_rep -- TCP 受付口を解放する。 620 */ 621 622 ER 623 free_tcp_rep (ID repid, bool_t call_tcp_del_rep) 624 { 625 int_t ix; 626 627 syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK)); 628 for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) { 629 if (repid == vrid_tcp_rep[ix]) { 630 tskid_tcp_rep[ix] = TSK_NONE; 631 break; 632 } 633 } 634 syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK)); 635 636 if (call_tcp_del_rep) 637 return tcp_del_rep(repid); 638 else 639 return E_OK; 640 } 641 642 /* 643 * alloc_tcp_cep -- TCP 通信端点を獲得する。 644 */ 645 646 ER 647 alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep) 648 { 649 int_t ix; 650 651 *cepid = TCP_CEP_NONE; 652 syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK)); 653 for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) { 654 if (tskid_tcp_cep[ix] == TSK_NONE) { 655 *cepid = vrid_tcp_cep[ix]; 656 tskid_tcp_cep[ix] = tskid; 657 break; 658 } 659 } 660 syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK)); 661 662 if (*cepid == TCP_CEP_NONE) 663 return E_NOEXS; 664 else 665 return tcp_cre_cep(*cepid, ccep); 666 } 667 668 /* 669 * free_tcp_cep -- TCP 通信端点を解放する。 670 */ 671 672 ER 673 free_tcp_cep (ID cepid) 674 { 675 int_t ix; 676 677 syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK)); 678 for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) { 679 if (cepid == vrid_tcp_cep[ix]) { 680 tskid_tcp_cep[ix] = TSK_NONE; 681 break; 682 } 683 } 684 syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK)); 685 686 return tcp_del_cep(cepid); 687 } 688 689 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 690 691 #ifdef USE_UDP_EXTENTIONS 692 693 const ID vrid_udp_cep[] = 694 { 695 #if NUM_VRID_UDP_CEPS >= 1 696 UDP_RSV_CEPID1, 697 #endif 698 #if NUM_VRID_UDP_CEPS >= 2 699 UDP_RSV_CEPID2, 700 #endif 701 }; 702 703 ID tskid_udp_cep[NUM_VRID_UDP_CEPS]; 704 705 /* 706 * alloc_udp_cep -- UDP 通信端点を獲得する。 707 */ 708 709 ER 710 alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep) 711 { 712 int_t ix; 713 714 *cepid = UDP_CEP_NONE; 715 syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK)); 716 for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) { 717 if (tskid_udp_cep[ix] == TSK_NONE) { 718 *cepid = vrid_udp_cep[ix]; 719 tskid_udp_cep[ix] = tskid; 720 break; 721 } 722 } 723 syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK)); 724 725 if (*cepid == UDP_CEP_NONE) 726 return E_NOEXS; 727 else 728 return UDP_CRE_CEP(*cepid, ccep); 729 } 730 731 /* 732 * free_udp_cep -- UDP 通信端点を解放する。 733 */ 734 735 ER 736 free_udp_cep (ID cepid, bool_t call_udp_del_cep) 737 { 738 int_t ix; 739 740 syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK)); 741 for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) { 742 if (cepid == vrid_udp_cep[ix]) { 743 tskid_udp_cep[ix] = TSK_NONE; 744 break; 745 } 746 } 747 syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK)); 748 749 if (call_udp_del_cep) 750 return udp_del_cep(cepid); 751 else 752 return E_OK; 753 } 754 755 #endif /* of #ifdef USE_UDP_EXTENTIONS */ 1090 *flags |= DNS_LUP_FLAGS_QTYPE_AAAA; 1091 1092 if (*line == '-') { 1093 line ++; 1094 if (*line == '6') { 1095 line ++; 1096 *flags &= ~DNS_LUP_FLAGS_PROTO_IPV4; 1097 } 1098 else if (*line == '4') { 1099 line ++; 1100 *flags &= ~DNS_LUP_FLAGS_PROTO_IPV6; 1101 } 1102 if (*line == 'Q' || *line == 'q') { 1103 *flags &= ~DNS_LUP_FLAGS_QTYPE_A; 1104 line ++; 1105 } 1106 else if (*line == 'A' || *line == 'a') { 1107 *flags &= ~DNS_LUP_FLAGS_QTYPE_AAAA; 1108 line ++; 1109 } 1110 while (*line && !(*line == ' ' || *line == '\t')) 1111 line ++; 1112 } 1113 1114 #else /* of #if defined(SUPPORT_INET4) */ 1115 1116 *flags = DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_QTYPE_AAAA; 1117 if (*line == '-') { 1118 line ++; 1119 while (*line && !(*line == ' ' || *line == '\t')) 1120 line ++; 1121 } 1122 1123 #endif /* of #if defined(SUPPORT_INET4) */ 1124 1125 #else /* of #if defined(SUPPORT_INET6) */ 1126 1127 #if defined(SUPPORT_INET4) 1128 1129 *flags = DNS_LUP_FLAGS_PROTO_IPV4 | DNS_LUP_FLAGS_QTYPE_A; 1130 if (*line == '-') { 1131 line ++; 1132 while (*line && !(*line == ' ' || *line == '\t')) 1133 line ++; 1134 } 1135 1136 #endif /* of #if defined(SUPPORT_INET4) */ 1137 1138 #endif /* of #if defined(SUPPORT_INET6) */ 1139 1140 #if defined(SUPPORT_INET6) 1141 1142 if (*flags | DNS_LUP_FLAGS_PROTO_IPV6) { 1143 /* 1144 * IPv6 で DNS サーバに照会することが指定されても、 1145 * サーバの IPv6 アドレスが未定義の時は、指定を外す。 1146 */ 1147 dns_in6_get_addr(&in6_addr); 1148 if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr)) 1149 *flags &= ~DNS_LUP_FLAGS_PROTO_IPV6; 1150 } 1151 1152 #endif /* of #if defined(SUPPORT_INET6) */ 1153 1154 #if defined(SUPPORT_INET4) 1155 1156 if (*flags | DNS_LUP_FLAGS_PROTO_IPV4) { 1157 /* 1158 * IPv4 で DNS サーバに照会することが指定されても、 1159 * サーバの IPv4 アドレスが未定義の時は、指定を外す。 1160 */ 1161 dns_in4_get_addr(&in4_addr); 1162 if (in4_addr == IPV4_ADDRANY) 1163 *flags &= ~DNS_LUP_FLAGS_PROTO_IPV4; 1164 } 1165 1166 #endif /* of #if defined(SUPPORT_INET4) */ 1167 1168 return line; 1169 } 1170 1171 #endif /* of #ifdef USE_RESOLVER */ 1172 1173 /* 1174 * lookup_ipaddr -- ホスト名・リテラルのIPアドレスをIP アドレスに変換する。 1175 */ 1176 1177 char * 1178 lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip) 1179 { 1180 1181 #ifdef USE_RESOLVER 1182 1183 static char hostname[DBG_LINE_SIZE + 1]; 1184 1185 ER_UINT error; 1186 uint_t flags = 0; 1187 char *last; 1188 1189 line = skip_blanks(resolv_options(&flags, line, apip)); 1190 if ((last = resolv_hoststr(&flags, hostname, sizeof(hostname), line)) == NULL) { 1191 cons_printf(CONSOLE_PORTID, "unknown host: %s.\n", hostname); 1192 return NULL; 1193 } 1194 1195 switch (flags & DNS_LUP_FLAGS_NAME_MASK) { 1196 case DNS_LUP_FLAGS_NAME_IPV4: 1197 case DNS_LUP_FLAGS_NAME_IPV6: 1198 line = GET_IPADDR(addr, line); /* IP Address by Literal */ 1199 break; 1200 1201 case DNS_LUP_FLAGS_NAME_HOST: 1202 case DNS_LUP_FLAGS_NAME_FQDN: 1203 line = last; 1204 if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) { 1205 cons_printf(CONSOLE_PORTID, "DNS server not available.\n"); 1206 return NULL; 1207 } 1208 1209 flags |= DNS_LUP_OPCODE_FORWARD; 1210 if ((error = dns_host_addr(flags, hostname, addr)) != E_OK) { 1211 cons_printf(CONSOLE_PORTID, "error: %s.\n", itron_strerror(error)); 1212 return NULL; 1213 } 1214 break; 1215 1216 } 1217 1218 return line; 1219 1220 #else /* of #ifdef USE_RESOLVER */ 1221 1222 return GET_IPADDR(addr, skip_blanks(line)); /* IP Address by Literal */ 1223 1224 #endif /* of #ifdef USE_RESOLVER */ 1225 1226 } 756 1227 757 1228 #endif /* of #ifdef USE_NETAPP_SUBR */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_var.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 36 36 37 37 /* 38 * マクロ定義 39 */ 40 41 #if defined(SUPPORT_INET4) 42 #define T_IPEP T_IPV4EP 38 * TOPPERS/JSP カーネル、システム時刻 (SYSTIM) の周波数 39 */ 40 41 #define SYSTIM_HZ ULONG_C(1000000) /* [us] */ 42 43 /* 44 * IPv6/IPv4 に関する定義 45 */ 46 47 /* 48 * 指定されたマクロに対するサンプルアプリケーション内部のマクロの定義 49 * 50 * SUPPORT_INET6 . . ON ON ON ON 51 * SUPPORT_INET4 ON ON . . ON ON 52 * API_CFG_IP4MAPPED_ADDR . ON . ON . ON 53 * ---------------------- ---------------------- 54 * NETAPP_IP6_CFG . . ON ON ON ON 55 * NETAPP_IP4_CFG ON ON . ON ON ON 56 * 57 */ 58 59 #if defined(SUPPORT_INET6) 60 61 #define NETAPP_IP6_CFG 62 63 #endif /* #if defined(SUPPORT_INET6) */ 64 65 #if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)) 66 #define NETAPP_IP4_CFG 43 67 #endif 44 68 45 #if defined(SUPPORT_INET6) 46 #define T_IPEP T_IPV6EP 69 /* 70 * IPv4 と IPv6 をコンパイル時に選択するためのマクロ 71 */ 72 73 #define DBG_LINE_SIZE 63 74 75 #if defined(SUPPORT_INET6) 76 77 #define T_IN_ADDR T_IN6_ADDR 78 #define T_IPEP T_IPV6EP 79 #define IP_ADDRANY IPV6_ADDRANY 80 #define T_TCPN_CREP T_TCP6_CREP 81 82 #else /* of #if defined(SUPPORT_INET6) */ 83 84 #define T_IN_ADDR T_IN4_ADDR 85 #define T_IPEP T_IPV4EP 86 #define IP_ADDRANY IPV4_ADDRANY 87 #define T_TCPN_CREP T_TCP_CREP 88 89 #endif /* of #if defined(SUPPORT_INET6) */ 90 91 /* 92 * API IPプロトコルの指定 93 */ 94 95 #if defined(SUPPORT_INET6) 96 #define DEFAULT_API_PROTO API_PROTO_IPV6 97 #else 98 #define DEFAULT_API_PROTO API_PROTO_IPV4 47 99 #endif 100 101 /* 102 * resolv_hoststr が返す flags の値の定義 103 * 104 * 注意: 105 * 106 * dns.h で定義されている DNS_OPCODE、 107 * resolver.h で定義されている DNS_LUP_FLAGS と重ならない事。 108 */ 109 110 #define HOSTSTR_OTHER 0x0000U 111 #define HOSTSTR_IPV4 DNS_LUP_FLAGS_NAME_IPV4 112 #define HOSTSTR_IPV6 DNS_LUP_FLAGS_NAME_IPV6 113 #define HOSTSTR_HOSTNAME DNS_LUP_FLAGS_NAME_HOST 114 #define HOSTSTR_FQDN DNS_LUP_FLAGS_NAME_FQDN 115 116 /* 117 * 定数の定義 118 */ 119 120 #define DBG_LINE_SIZE 63 121 122 #if defined(SUPPORT_INET6) 123 124 #define NUM_VRID_TCP_CEPS NUM_VRID_TCP6_CEPS 125 126 #else /* of #if defined(SUPPORT_INET6) */ 127 128 #define NUM_VRID_TCP_CEPS NUM_VRID_TCP4_CEPS 129 130 #endif /* of #if defined(SUPPORT_INET6) */ 131 132 /* 133 * 関数シミュレーションマクロ 134 */ 135 136 /* メッセージからの読出し */ 137 138 #define MSG2HOST16(p) (msg2host16((void*)&(p))) 139 #define MSG2HOST32(p) (msg2host32((void*)&(p))) 140 141 /* メッセージへの書込み */ 142 143 #define HOST2MSG16(p,v) (host2msg16((void*)&(p),(v))) 144 #define HOST2MSG32(p,v) (host2msg32((void*)&(p),(v))) 48 145 49 146 /* … … 80 177 extern const char *in_strtfn (FN fncd); 81 178 extern const char *itron_strerror (ER ercd); 179 extern const char *dns_strtype (uint_t type); 180 extern const char *dns_strclass (uint_t class); 82 181 extern ER net_syslog(uint_t prio, const char *format, ...) throw(); 83 182 extern ER net_serial_ctl_por(ID portid, uint_t ioctl) throw(); … … 85 184 extern ER discon_net_cons (void); 86 185 extern void wup_net_cons (void); 87 extern ER alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep); 88 extern ER free_tcp_rep (ID repid, bool_t call_tcp_del_rep); 89 extern ER alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep); 90 extern ER free_tcp_cep (ID cepid); 91 extern ER alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep); 92 extern ER free_udp_cep (ID cepid, bool_t call_udp_del_cep); 186 extern bool_t tcp6_is_cepid (ID cepid); 187 extern ER alloc_tcp6_rep (ID *repid, ID tskid, T_TCP6_CREP *crep); 188 extern ER alloc_tcp6_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep); 189 extern ER alloc_udp6_cep (ID *cepid, ID tskid, T_UDP6_CCEP *ccep); 190 extern ER free_tcp6_rep (ID repid, bool_t call_tcp_del_rep); 191 extern ER free_tcp6_cep (ID cepid); 192 extern ER free_udp6_cep (ID cepid, bool_t call_udp_del_cep); 193 extern bool_t tcp4_is_cepid (ID cepid); 194 extern ER alloc_tcp4_rep (ID *repid, ID tskid, T_TCP_CREP *crep); 195 extern ER alloc_tcp4_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep); 196 extern ER alloc_udp4_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep); 197 extern ER free_tcp4_rep (ID repid, bool_t call_tcp_del_rep); 198 extern ER free_tcp4_cep (ID cepid); 199 extern ER free_udp4_cep (ID cepid, bool_t call_udp_del_cep); 200 extern void ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len); 201 extern void ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len); 202 extern char *get_ipv6addr (T_IN6_ADDR *addr, char *line); 203 extern char *get_ipv4addr (T_IN4_ADDR *addr, char *line); 204 extern char *resolv_options (uint_t *flags, char *line, char apip); 205 extern char *resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line); 206 extern char *lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip); 207 extern uint_t show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset); 208 extern void host2msg16 (void *msg, uint16_t host_data); 209 extern void host2msg32 (void *msg, uint32_t host_data); 210 extern uint16_t msg2host16 (void *msg); 211 extern uint32_t msg2host32 (void *msg); 212 extern uint32_t netapp_rand (void); 213 extern void netapp_srand (uint32_t seed); 214 215 #if defined(SUPPORT_INET6) 216 217 #define TCP_CRE_REP(i,r) tcp6_cre_rep(i,r) 218 #define TCP_CRE_CEP(i,c) tcp6_cre_cep(i,c) 219 #define UDP_CRE_CEP(i,c) udp6_cre_cep(i,c) 220 #define TCP_ACP_CEP(c,r,d,t) tcp6_acp_cep(c,r,d,t) 221 #define TCP_CON_CEP(c,m,d,t) tcp6_con_cep(c,m,d,t) 222 223 #define UDP_SND_DAT(c,d,b,l,t) udp6_snd_dat(c,d,b,l,t) 224 #define UDP_RCV_DAT(c,d,b,l,t) udp6_rcv_dat(c,d,b,l,t) 225 226 #define TCP_IS_CEPID(i) tcp6_is_cepid(i) 227 #define ALLOC_TCP_REP(i,t,r) alloc_tcp6_rep(i,t,r) 228 #define ALLOC_TCP_CEP(i,t,c) alloc_tcp6_cep(i,t,c) 229 #define ALLOC_UDP_CEP(i,t,c) alloc_udp6_cep(i,t,c) 230 #define FREE_TCP_REP(i,r) free_tcp6_rep(i,r) 231 #define FREE_TCP_CEP(i) free_tcp6_cep(i) 232 #define FREE_UDP_CEP(i,c) free_udp6_cep(i,c) 233 234 #define IP2STR(s,a) ipv62str(s,a) 235 #define GET_IPADDR(a,l) get_ipv6addr(a,l) 236 #define PING(a,t,l) ping6(a,t,l) 237 238 #else /* of #if defined(SUPPORT_INET6) */ 93 239 94 240 #if defined(SUPPORT_INET4) … … 103 249 #define UDP_RCV_DAT(c,d,b,l,t) udp_rcv_dat(c,d,b,l,t) 104 250 251 #define TCP_IS_CEPID(i) tcp4_is_cepid(i) 252 #define ALLOC_TCP_REP(i,t,r) alloc_tcp4_rep(i,t,r) 253 #define ALLOC_TCP_CEP(i,t,c) alloc_tcp4_cep(i,t,c) 254 #define ALLOC_UDP_CEP(i,t,c) alloc_udp4_cep(i,t,c) 255 #define FREE_TCP_REP(i,r) free_tcp4_rep(i,r) 256 #define FREE_TCP_CEP(i) free_tcp4_cep(i) 257 #define FREE_UDP_CEP(i,c) free_udp4_cep(i,c) 258 105 259 #define IP2STR(s,a) ip2str(s,a) 106 107 260 #define GET_IPADDR(a,l) get_ipv4addr(a,l) 108 261 #define PING(a,t,l) ping4(a,t,l) 109 262 110 extern void ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);111 extern char *get_ipv4addr (T_IN4_ADDR *addr, char *line);112 113 263 #endif /* of #if defined(SUPPORT_INET4) */ 114 264 115 #if defined(SUPPORT_INET6)116 117 #define TCP_CRE_REP(i,r) tcp6_cre_rep(i,r)118 #define TCP_CRE_CEP(i,c) tcp6_cre_cep(i,c)119 #define UDP_CRE_CEP(i,c) udp6_cre_cep(i,c)120 #define TCP_ACP_CEP(c,r,d,t) tcp6_acp_cep(c,r,d,t)121 #define TCP_CON_CEP(c,m,d,t) tcp6_con_cep(c,m,d,t)122 123 #define UDP_SND_DAT(c,d,b,l,t) udp6_snd_dat(c,d,b,l,t)124 #define UDP_RCV_DAT(c,d,b,l,t) udp6_rcv_dat(c,d,b,l,t)125 126 #define IP2STR(s,a) ipv62str(s,a)127 128 #define GET_IPADDR(a,l) get_ipv6addr(a,l)129 #define PING(a,t,l) ping6(a,t,l)130 131 extern void ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);132 extern char *get_ipv6addr (T_IN6_ADDR *addr, char *line);133 134 265 #endif /* of #if defined(SUPPORT_INET6) */ 135 266 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 61 61 #include <net/ppp_ipcp.h> 62 62 #include <net/net.h> 63 #include <net/net_endian.h> 63 64 #include <net/net_buf.h> 64 65 #include <net/net_timer.h> … … 74 75 #ifdef USE_PING 75 76 77 #if defined(SUPPORT_INET4) 78 76 79 /* 77 80 * 変数 78 81 */ 79 82 80 static uint16_t icmp_id = 0; 83 #if 0 81 84 static uint16_t curr_icmp_id; 82 85 static uint16_t curr_icmp_len; 86 #endif 87 88 static uint16_t icmp_id = 0; 83 89 static SYSTIM icmp_start_time; 84 90 … … 90 96 icmp_reply_timeout (void *arg) 91 97 { 92 syslog(LOG_NOTICE, "[PING ] request timeout.");98 syslog(LOG_NOTICE, "[PING4] request timeout."); 93 99 } 94 100 … … 100 106 icmp_echo_reply (T_NET_BUF *input, uint_t ihoff) 101 107 { 102 SYSTIM time; 108 SYSTIM time; 109 T_IN4_ADDR addr; 103 110 104 111 syscall(get_tim(&time)); 112 addr = ntohl(GET_IP4_HDR(input)->src); 105 113 untimeout(icmp_reply_timeout, NULL); 106 syslog(LOG_NOTICE, "[PING] reply, %d [ms].", 107 (time - icmp_start_time) * 1000 / SYSTIM_HZ); 114 syslog(LOG_NOTICE, "[PING4] reply: %5ld [ms] from: %s", 115 (time - icmp_start_time) * 1000 / SYSTIM_HZ, 116 ip2str(NULL, &addr)); 108 117 } 109 118 … … 143 152 144 153 /* 応答チェック用の変数を設定する。*/ 154 #if 0 145 155 curr_icmp_id = icmp_id ++; 146 156 curr_icmp_len = len; 157 #endif 147 158 148 159 NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1); … … 157 168 } 158 169 170 #endif /* of #if defined(SUPPORT_INET4) */ 171 159 172 #endif /* of #ifdef USE_PING */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping6.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 61 61 #include <net/ppp_ipcp.h> 62 62 #include <net/net.h> 63 #include <net/net_endian.h> 63 64 #include <net/net_buf.h> 64 65 #include <net/net_timer.h> … … 67 68 #include <netinet/in.h> 68 69 #include <netinet/in_var.h> 70 #include <netinet/ip.h> 71 #include <netinet/ip_var.h> 72 #include <netinet/ip_icmp.h> 69 73 70 #include <netinet6/in6.h>71 #include <netinet6/in6_var.h>72 74 #include <netinet6/nd6.h> 73 75 74 #include <netinet/ip6.h> 75 #include <netinet6/ip6_var.h> 76 #include <netinet/icmp6.h> 77 78 #include <net/if6_var.h> 76 #include <net/if_var.h> 79 77 80 78 #ifdef USE_PING 79 80 #if defined(SUPPORT_INET6) 81 81 82 82 /* … … 84 84 */ 85 85 86 static uint16_t send_icmp6_id = 0; 86 #if 0 87 87 static uint16_t curr_icmp6_id; 88 88 static uint16_t curr_icmp6_size; 89 #endif 90 91 static uint16_t send_icmp6_id = 0; 89 92 static uint16_t reply_count; 90 93 static SYSTIM icmp6_start_time; … … 108 111 icmp6_echo_reply (T_NET_BUF *input, uint_t ihoff) 109 112 { 110 T_IP6_HDR *ip6h; 111 SYSTIM time; 113 SYSTIM time; 112 114 113 115 syscall(get_tim(&time)); 114 ip6h = GET_IP6_HDR(input); 115 116 syslog(LOG_NOTICE, "[PING6] reply: %5d [ms] from: %s", 116 untimeout(icmp6_reply_timeout, NULL); 117 syslog(LOG_NOTICE, "[PING6] reply: %5ld [ms] from: %s", 117 118 (time - icmp6_start_time) * 1000 / SYSTIM_HZ, 118 ipv62str(NULL, & ip6h->src));119 ipv62str(NULL, &GET_IP6_HDR(input)->src)); 119 120 reply_count ++; 120 121 } … … 169 170 170 171 /* 応答チェック用の変数を設定する。*/ 172 reply_count = 0; 173 174 #if 0 171 175 curr_icmp6_id = send_icmp6_id ++; 172 176 curr_icmp6_size = size; 177 #endif 173 178 174 reply_count = 0; 175 179 #if 0 176 180 syslog(LOG_NOTICE, "[PING6] send: TMO:%d, SIZE:%d, to: %s, from %s", 177 181 tmo, size, 178 182 ipv62str(NULL, addr), ipv62str(NULL, &ia->addr)); 183 #endif 179 184 180 185 /* 送信後、現在の時間を記憶し、タイムアウトを設定する。*/ … … 188 193 } 189 194 195 #endif /* of #if defined(SUPPORT_INET6) */ 196 190 197 #endif /* of #ifdef USE_PING */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 58 58 #endif /* of #ifdef TARGET_KERNEL_JSP */ 59 59 60 #include <tinet_defs.h>61 #include <tinet_config.h>62 63 #include <net/if.h>64 #include <net/if_ppp.h>65 #include <net/if_loop.h>66 #include <net/ethernet.h>67 #include <net/net.h>68 #include <net/net_var.h>69 #include <net/net_timer.h>70 71 60 #include <netinet/in.h> 72 61 #include <netinet/in_itron.h> 73 #include <netinet/ip.h>74 #include <netinet/ip6.h>75 #include <netinet/tcp.h>76 62 77 63 #include <netapp/netapp.h> 78 64 #include <netapp/netapp_var.h> 79 #include <netapp/ discard.h>65 #include <netapp/tcp_discard_cli.h> 80 66 81 67 #ifdef USE_TCP_DISCARD_CLI … … 88 74 89 75 /*#define SHOW_RCV_RANGE*/ 76 77 /* 送信間隔 */ 78 79 #ifdef TOPPERS_S810_CLG3_85 80 81 #define START_DLY (10*SYSTIM_HZ) 82 #define SND_ITV (5*SYSTIM_HZ) 83 #define SLP_ITV (30*SYSTIM_HZ) 84 85 #else /* of #ifdef TOPPERS_S810_CLG3_85 */ 86 87 #define START_DLY (10*SYSTIM_HZ) 88 #define SND_ITV (5*SYSTIM_HZ) 89 #define SLP_ITV (60*SYSTIM_HZ) 90 91 #endif /* of #ifdef TOPPERS_S810_CLG3_85 */ 92 93 /* 自動実行 */ 94 95 #if defined(TCP_DISCARD_CLI_AUTO_RUN_STR) 96 #else 97 #if 0 98 #if defined(SUPPORT_INET6) 99 #define TCP_DISCARD_CLI_AUTO_RUN_STR "fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0" 100 #else 101 #define TCP_DISCARD_CLI_AUTO_RUN_STR "172.25.129.142 - 0" 102 #endif 103 #endif 104 #endif 90 105 91 106 /* … … 143 158 case TFN_TCP_CLS_CEP: 144 159 if (nblk_error < 0) 145 syslog(LOG_NOTICE, "[TDC :%02dCBN] close error: %s", cepid, itron_strerror(nblk_error));160 syslog(LOG_NOTICE, "[TDCn:%02u CBN] close error: %s", cepid, itron_strerror(nblk_error)); 146 161 syscall(sig_sem(SEM_TCP_DISCARD_CLI_NBLK_READY)); 147 162 break; … … 162 177 */ 163 178 164 static void179 static ER 165 180 send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno) 166 181 { … … 183 198 184 199 if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) { 185 syslog(LOG_NOTICE, "[TDC :%02dSND] connect error: %s", cepid, itron_strerror(error));186 return ;200 syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error)); 201 return error; 187 202 } 188 203 … … 191 206 192 207 if (nblk_error != E_OK) 193 syslog(LOG_NOTICE, "[TDC :%02dSND] connect error: %s", cepid, itron_strerror(nblk_error));208 syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(nblk_error)); 194 209 else { 195 210 get_tim(&time); 196 syslog(LOG_NOTICE, "[TDC :%02d SND] connecting: %6ld, to: %s.%d",211 syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to: %s.%d", 197 212 cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno); 198 213 … … 202 217 while (soff < SND_BUF_SIZE) { 203 218 if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) { 204 syslog(LOG_NOTICE, "[TDC :%02dSND] send error: %s",219 syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s", 205 220 cepid, itron_strerror(slen)); 206 221 goto cls_ret; … … 211 226 212 227 #ifdef SHOW_RCV_RANGE 213 syslog(LOG_NOTICE, "[TDC :%02d SND] snd: %2d, len: %4d, off: %4d",228 syslog(LOG_NOTICE, "[TDCn:%02u SND] send: %7lu, len: %4u, off: %4u", 214 229 cepid, scount, (uint16_t)slen, soff); 215 230 #endif /* of #ifdef SHOW_RCV_RANGE */ 216 231 217 syscall(dly_tsk(500 + net _rand() % SYSTIM_HZ));232 syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ)); 218 233 } 219 234 } … … 221 236 cls_ret: 222 237 get_tim(&time); 223 syslog(LOG_NOTICE, "[TDC :%02d SND] finished: %6ld, snd: %4d, len: %ld",238 syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu", 224 239 cepid, time / SYSTIM_HZ, scount, total); 225 240 226 241 if ((error = tcp_sht_cep(cepid)) < 0) 227 syslog(LOG_NOTICE, "[TDC :%02dSND] shutdown error: %s", cepid, itron_strerror(error));242 syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error)); 228 243 229 244 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) 230 syslog(LOG_NOTICE, "[TDC :%02dSND] close error: %s", cepid, itron_strerror(error));245 syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error)); 231 246 232 247 /* 開放が完了するまで待つ。*/ 233 248 syscall(wai_sem(SEM_TCP_DISCARD_CLI_NBLK_READY)); 234 249 } 250 251 return E_OK; 235 252 } 236 253 … … 241 258 */ 242 259 243 static void260 static ER 244 261 send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno) 245 262 { … … 266 283 267 284 if ((error = TCP_CON_CEP(cepid, &src, &dst, 60 * 1000)) != E_OK) { 268 syslog(LOG_NOTICE, "[TDC :%02dSND] connect error: %s", cepid, itron_strerror(error));269 return ;285 syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error)); 286 return error; 270 287 } 271 288 272 289 get_tim(&time); 273 syslog(LOG_NOTICE, "[TDC :%02d SND] connecting: %6ld, to: %s.%d",290 syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to: %s.%d", 274 291 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 275 292 … … 279 296 while (soff < SND_BUF_SIZE) { 280 297 if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) { 281 syslog(LOG_NOTICE, "[TDC :%02dSND] send error: %s", cepid, itron_strerror(slen));298 syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s", cepid, itron_strerror(slen)); 282 299 goto cls_ret; 283 300 } … … 287 304 288 305 #ifdef SHOW_RCV_RANGE 289 syslog(LOG_NOTICE, "[TDC :%02d SND] snd: %3d, len: %4d, off: %4d",306 syslog(LOG_NOTICE, "[TDCn:%02u SND] send: %7lu, len: %4u, off: %4u", 290 307 cepid, scount, (uint16_t)slen, soff); 291 308 #endif /* of #ifdef SHOW_RCV_RANGE */ 292 309 293 syscall(dly_tsk(500 + net _rand() % SYSTIM_HZ));310 syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ)); 294 311 } 295 312 } … … 297 314 cls_ret: 298 315 get_tim(&time); 299 syslog(LOG_NOTICE, "[TDC :%02d SND] finished: %6ld, snd: %4d, len: %ld",316 syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu", 300 317 cepid, time / SYSTIM_HZ, scount, total); 301 318 302 319 if ((error = tcp_sht_cep(cepid)) < 0) 303 syslog(LOG_NOTICE, "[TDC :%02dSND] shutdown error: %s", cepid, itron_strerror(error));320 syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error)); 304 321 305 322 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) < 0) 306 syslog(LOG_NOTICE, "[TDC:%02d SND] close error: %s", cepid, itron_strerror(error)); 323 syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error)); 324 325 return E_OK; 307 326 } 308 327 309 328 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 329 330 /* 331 * getcomd -- コマンドを得る。 332 */ 333 334 #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR 335 336 static char * 337 getcomd (ID cepid, bool_t retry) 338 { 339 ER error; 340 char *line = NULL; 341 static char auto_run_str[] = TCP_DISCARD_CLI_AUTO_RUN_STR; 342 static int_t count = 0; 343 344 if (retry || (count == 0)) { 345 line = auto_run_str; 346 dly_tsk(3 * 1000); 347 } 348 else { 349 while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) { 350 syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error)); 351 dly_tsk(SLP_ITV); 352 } 353 } 354 355 count ++; 356 return line; 357 } 358 359 #else /* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */ 360 361 static char * 362 getcomd (ID cepid, bool_t retry) 363 { 364 ER error; 365 char *line = NULL; 366 367 while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) { 368 syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error)); 369 dly_tsk(SLP_ITV); 370 } 371 return line; 372 } 373 374 #endif /* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */ 310 375 311 376 void 312 377 tcp_discard_cli_task (intptr_t exinf) 313 378 { 379 ID tskid, cepid; 314 380 T_IN_ADDR addr; 315 ID tskid, cepid; 316 int_t rep; 317 uint32_t count; 381 ER error; 382 uint8_t *line; 383 int_t rep, count; 384 bool_t retry = false; 318 385 uint16_t portno; 319 uint8_t *line;386 char apip; 320 387 321 388 #ifdef USE_TCP_EXTENTIONS 322 389 323 ER error;324 390 T_TCP_CCEP ccep; 325 391 326 392 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 327 393 394 #ifdef TCP_ECHO_CLI_AUTO_RUN_STR 395 dly_tsk(START_DLY); 396 #endif 328 397 get_tid(&tskid); 329 syslog(LOG_NOTICE, "[TCP DISCARD CLI:%d,%d] started.", tskid, (ID)exinf); 398 399 #if defined(SUPPORT_INET6) 400 apip = API_PROTO_IPV6; 401 #if defined(SUPPORT_INET4) 402 syslog(LOG_NOTICE, "[TCPn DISCARD CLI:%d,%d] started.", tskid, (ID)exinf); 403 #else 404 syslog(LOG_NOTICE, "[TCP6 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf); 405 #endif 406 #else 407 apip = API_PROTO_IPV4; 408 syslog(LOG_NOTICE, "[TCP4 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf); 409 #endif 410 330 411 while (true) { 331 if (rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line) == E_OK) { 332 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line))); /* IP Address */ 333 334 if ('0' <= *line && *line <= '9') { /* Port No */ 335 line = get_int(&rep, line); 336 portno = (uint16_t)rep; 412 line = skip_blanks(getcomd((ID)exinf, retry)); 413 414 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 415 syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], unknown host.", 416 (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ); 417 dly_tsk(SLP_ITV); 418 syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", (ID)exinf); 419 retry = true; 420 continue; 421 } 422 else 423 retry = false; 424 425 line = skip_blanks(line); 426 if ('0' <= *line && *line <= '9') { /* Port No */ 427 line = get_int(&rep, line); 428 portno = (uint16_t)rep; 429 } 430 else { 431 line ++; 432 portno = DISCARD_SRV_PORTNO; 433 } 434 435 line = skip_blanks(line); 436 if ('0' <= *line && *line <= '9') /* Repeat */ 437 line = get_int(&rep, line); 438 else 439 rep = 1; 440 441 #ifdef USE_TCP_EXTENTIONS 442 443 ccep.cepatr = 0; 444 ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE; 445 ccep.rbufsz = 0; 446 ccep.rbuf = NADR; 447 448 #ifdef TCP_CFG_SWBUF_CSAVE 449 ccep.sbuf = NADR; 450 #else 451 ccep.sbuf = tcp_discard_cli_swbuf; 452 #endif 453 #ifdef USE_TCP_NON_BLOCKING 454 ccep.callback = (FP)callback_nblk_tcp_discard_cli; 455 #else 456 ccep.callback = NULL; 457 #endif 458 459 if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) { 460 syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP create error: %s", cepid, itron_strerror(error)); 461 continue; 462 } 463 464 #else /* of #ifdef USE_TCP_EXTENTIONS */ 465 466 cepid = (ID)exinf; 467 468 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 469 470 tcp_discard_cli_valid = true; 471 count = 0; 472 while (rep == 0 || count < rep) { 473 if (!tcp_discard_cli_valid) { 474 syslog(LOG_NOTICE, "[TDCn:%02u TSK] canceled.", cepid); 475 break; 476 } 477 478 count ++; 479 if (rep == 0) { 480 syslog(LOG_NOTICE, "[TDCn:%02u TSK] start: repeat: %d", cepid, count); 481 error = send_tcp_discard(cepid, &addr, portno); 482 syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh: repeat: %d", cepid, count); 337 483 } 338 484 else { 339 line ++; 340 portno = DISCARD_SRV_PORTNO; 341 } 342 343 line = skip_blanks(line); 344 if ('0' <= *line && *line <= '9') /* Repeat */ 345 line = get_int(&rep, line); 346 else 347 rep = 1; 485 syslog(LOG_NOTICE, "[TDCn:%02u TSK] start: repeat: %d/%d", cepid, count, rep); 486 error = send_tcp_discard(cepid, &addr, portno); 487 syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh: repeat: %d/%d", cepid, count, rep); 488 } 489 490 if (error != E_OK) { 491 syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], error: %s", 492 cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error)); 493 tslp_tsk(SLP_ITV); 494 syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", cepid); 495 } 496 497 #if defined(SND_ITV) 498 #if SND_ITV > 0 499 if (count < rep) { 500 uint_t itv; 501 502 itv = SND_ITV; 503 syslog(LOG_NOTICE, "[TDCn:%02u TSK] interval: %d[s].", cepid, itv / SYSTIM_HZ); 504 syscall(dly_tsk(SND_ITV)); 505 } 506 #endif 507 #endif 508 } 348 509 349 510 #ifdef USE_TCP_EXTENTIONS 350 511 351 ccep.cepatr = 0; 352 ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE; 353 ccep.rbufsz = 0; 354 ccep.rbuf = NADR; 355 356 #ifdef TCP_CFG_SWBUF_CSAVE 357 ccep.sbuf = NADR; 358 #else 359 ccep.sbuf = tcp_discard_cli_swbuf; 360 #endif 361 #ifdef USE_TCP_NON_BLOCKING 362 ccep.callback = (FP)callback_nblk_tcp_discard_cli; 363 #else 364 ccep.callback = NULL; 365 #endif 366 367 if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) { 368 syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error)); 369 continue; 370 } 371 372 #else /* of #ifdef USE_TCP_EXTENTIONS */ 373 374 cepid = (ID)exinf; 512 if ((error = FREE_TCP_CEP(cepid)) != E_OK) 513 syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP delete error: %s", cepid, itron_strerror(error)); 375 514 376 515 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 377 516 378 tcp_discard_cli_valid = true;379 for (count = rep; count -- > 0; ) {380 if (!tcp_discard_cli_valid) {381 syslog(LOG_NOTICE, "[TDC:%02d TSK] canceled.", (ID)exinf);382 break;383 }384 syslog(LOG_NOTICE, "[TDC:%02d TSK] start: repeat: %d/%d",385 (ID)exinf, rep - count, rep);386 send_tcp_discard(cepid, &addr, portno);387 syslog(LOG_NOTICE, "[TDC:%02d TSK] finished: repeat: %d/%d",388 (ID)exinf, rep - count, rep);389 syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));390 }391 392 #ifdef USE_TCP_EXTENTIONS393 394 if ((error = free_tcp_cep(cepid)) != E_OK)395 syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));396 397 #endif /* of #ifdef USE_TCP_EXTENTIONS */398 399 }400 517 } 401 518 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 58 58 #endif /* of #ifdef TARGET_KERNEL_JSP */ 59 59 60 #include <tinet_defs.h>61 #include <tinet_config.h>62 63 #include <net/if.h>64 #include <net/if_ppp.h>65 #include <net/if_loop.h>66 #include <net/ethernet.h>67 #include <net/net.h>68 #include <net/net_timer.h>69 70 60 #include <netinet/in.h> 71 61 #include <netinet/in_itron.h> 72 #include <netinet/ip.h>73 #include <netinet/ip6.h>74 #include <netinet/tcp.h>75 62 76 63 #include <netapp/netapp.h> 77 64 #include <netapp/netapp_var.h> 78 #include <netapp/ discard.h>65 #include <netapp/tcp_discard_srv.h> 79 66 80 67 #ifdef USE_TCP_DISCARD_SRV … … 121 108 122 109 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 123 syslog(LOG_NOTICE, "[TDS :%02dACP] accept error: %s", cepid, itron_strerror(error));110 syslog(LOG_NOTICE, "[TDSn:%02u ACP] accept error: %s", cepid, itron_strerror(error)); 124 111 return error; 125 112 } 126 113 127 114 #ifdef USE_TCP_EXTENTIONS 128 if ((error = free_tcp_rep(repid, true)) != E_OK) {129 syslog(LOG_NOTICE, "[TDS :%02dDEL] REP delete error: %s", cepid, itron_strerror(error));115 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 116 syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 130 117 return error; 131 118 } … … 134 121 count = total = 0; 135 122 get_tim(&time); 136 syslog(LOG_NOTICE, "[TDS :%02d RCV] connected: %6ld, from: %s.%d",123 syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d", 137 124 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 138 125 while ((rlen = tcp_rcv_buf(cepid, (void*)&buf, TMO_FEVR)) > 0) { … … 140 127 141 128 #ifdef SHOW_RCV_RANGE 142 syslog(LOG_NOTICE, "[TDS :%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",129 syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x", 143 130 cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1)); 144 131 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 150 137 151 138 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK) { 152 syslog(LOG_NOTICE, "[TDS :%02dRCV] rel buf error: %s",139 syslog(LOG_NOTICE, "[TDSn:%02u RCV] rel buf error: %s", 153 140 cepid, itron_strerror(error)); 154 141 rlen = 0; … … 159 146 160 147 if (rlen != 0) 161 syslog(LOG_NOTICE, "[TDS :%02dRCV] recv buf error: %s", cepid, itron_strerror(rlen));148 syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv buf error: %s", cepid, itron_strerror(rlen)); 162 149 163 150 if ((error = tcp_sht_cep(cepid)) != E_OK) 164 syslog(LOG_NOTICE, "[TDS :%02dRCV] shutdown error: %s", cepid, itron_strerror(error));151 syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error)); 165 152 166 153 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK) 167 syslog(LOG_NOTICE, "[TDS :%02dRCV] close error: %s", cepid, itron_strerror(error));154 syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error)); 168 155 169 156 get_tim(&time); 170 syslog(LOG_NOTICE, "[TDS :%02d RCV] finished: %6ld, rcv: %4d, len: %ld",157 syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu", 171 158 cepid, time / SYSTIM_HZ, count, total); 172 159 … … 190 177 191 178 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 192 syslog(LOG_NOTICE, "[TDS :%02dRCV] accept error: %s", cepid, itron_strerror(error));179 syslog(LOG_NOTICE, "[TDSn:%02u RCV] accept error: %s", cepid, itron_strerror(error)); 193 180 return error; 194 181 } 195 182 196 183 #ifdef USE_TCP_EXTENTIONS 197 if ((error = free_tcp_rep(repid, true)) != E_OK) {198 syslog(LOG_NOTICE, "[TDS :%02dDEL] REP delete error: %s", cepid, itron_strerror(error));184 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 185 syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 199 186 return error; 200 187 } … … 203 190 count = total = 0; 204 191 get_tim(&time); 205 syslog(LOG_NOTICE, "[TDS :%02d RCV] connected: %6ld, from: %s.%d",192 syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d", 206 193 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 207 194 while ((rlen = tcp_rcv_dat(cepid, buf, BUF_SIZE - 1, TMO_FEVR)) > 0) { … … 209 196 210 197 #ifdef SHOW_RCV_RANGE 211 syslog(LOG_NOTICE, "[TDS :%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",198 syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x", 212 199 cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1)); 213 200 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 216 203 } 217 204 if (rlen != 0) 218 syslog(LOG_NOTICE, "[TDS :%02dRCV] recv error: %s", cepid, itron_strerror(rlen));205 syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv error: %s", cepid, itron_strerror(rlen)); 219 206 220 207 if ((error = tcp_sht_cep(cepid)) != E_OK) 221 syslog(LOG_NOTICE, "[TDS :%02dRCV] shutdown error: %s", cepid, itron_strerror(error));208 syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error)); 222 209 223 210 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK) 224 syslog(LOG_NOTICE, "[TDS :%02dRCV] close error: %s", cepid, itron_strerror(error));211 syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error)); 225 212 226 213 get_tim(&time); 227 syslog(LOG_NOTICE, "[TDS :%02d RCV] finished: %6ld, rcv: %4d, len: %ld",214 syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu", 228 215 cepid, time / SYSTIM_HZ, count, total); 229 216 … … 243 230 { 244 231 ID tskid; 245 T_TCP _CREP crep;232 T_TCPN_CREP crep; 246 233 247 234 get_tid(&tskid); … … 250 237 crep.myaddr.portno = UINT_C(9); 251 238 239 #if defined(SUPPORT_INET6) 240 241 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 242 243 #else /* #if defined(SUPPORT_INET6) */ 244 252 245 #if defined(SUPPORT_INET4) 253 246 crep.myaddr.ipaddr = IPV4_ADDRANY; 254 247 #endif 255 248 256 #if defined(SUPPORT_INET6) 257 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 258 #endif 259 260 return alloc_tcp_rep(repid, tskid, &crep); 249 #endif /* #if defined(SUPPORT_INET6) */ 250 251 return ALLOC_TCP_REP(repid, tskid, &crep); 261 252 } 262 253 … … 285 276 #endif 286 277 287 return alloc_tcp_cep(cepid, tskid, &ccep);278 return ALLOC_TCP_CEP(cepid, tskid, &ccep); 288 279 } 289 280 … … 299 290 300 291 syscall(get_tid(&tskid)); 301 syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid); 292 293 #if defined(SUPPORT_INET6) 294 #if defined(SUPPORT_INET4) 295 syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d] started.", tskid); 296 #else 297 syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d] started.", tskid); 298 #endif 299 #else 300 syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d] started.", tskid); 301 #endif 302 302 303 while (true) { 303 304 304 305 syscall(slp_tsk()); 305 306 if ((error = get_tcp_cep (&cepid)) != E_OK) { 306 syslog(LOG_NOTICE, "[TDS :00 EXT] CEP create error: %s", itron_strerror(error));307 syslog(LOG_NOTICE, "[TDSn:00 EXT] CEP create error: %s", itron_strerror(error)); 307 308 continue; 308 309 } … … 311 312 312 313 if ((error = get_tcp_rep (&repid)) != E_OK) { 313 syslog(LOG_NOTICE, "[TDS :00 EXT] REP create error: %s", itron_strerror(error));314 syslog(LOG_NOTICE, "[TDSn:00 EXT] REP create error: %s", itron_strerror(error)); 314 315 break; 315 316 } 316 317 else if ((error = tcp_discard_srv(cepid, repid)) != E_OK) { 317 error = free_tcp_rep(repid, error != E_DLT);318 error = FREE_TCP_REP(repid, error != E_DLT); 318 319 break; 319 320 } 320 321 } 321 322 322 if ((error = free_tcp_cep(cepid)) != E_OK)323 syslog(LOG_NOTICE, "[TDS :%02dEXT] CEP delete error: %s", cepid, itron_strerror(error));323 if ((error = FREE_TCP_CEP(cepid)) != E_OK) 324 syslog(LOG_NOTICE, "[TDSn:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error)); 324 325 325 326 } … … 334 335 335 336 get_tid(&tskid); 336 syslog(LOG_NOTICE, "[TCP DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 337 338 #if defined(SUPPORT_INET6) 339 #if defined(SUPPORT_INET4) 340 syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 341 #else 342 syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 343 #endif 344 #else 345 syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf); 346 #endif 347 337 348 while (true) { 338 349 while (tcp_discard_srv((ID)exinf, TCP_DISCARD_SRV_REPID) == E_OK) -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 50 50 #include <t_syslog.h> 51 51 #include "kernel_cfg.h" 52 #include "tinet_cfg.h" 52 53 53 54 #endif /* of #ifdef TARGET_KERNEL_ASP */ … … 57 58 #include <t_services.h> 58 59 #include "kernel_id.h" 60 #include "tinet_id.h" 59 61 60 62 #endif /* of #ifdef TARGET_KERNEL_JSP */ 61 62 #include <tinet_defs.h>63 #include <tinet_config.h>64 65 #include <net/if.h>66 #include <net/if_ppp.h>67 #include <net/if_loop.h>68 #include <net/net.h>69 #include <net/ethernet.h>70 #include <net/net_var.h>71 #include <net/net_timer.h>72 63 73 64 #include <netinet/in.h> 74 65 #include <netinet/in_itron.h> 75 #include <netinet/ip.h>76 #include <netinet/ip6.h>77 #include <netinet/tcp.h>78 66 79 67 #include <netapp/netapp.h> 80 68 #include <netapp/netapp_var.h> 81 #include <netapp/ echo.h>69 #include <netapp/tcp_echo_cli.h> 82 70 83 71 #ifdef USE_TCP_ECHO_CLI … … 96 84 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 97 85 98 /* 表示 */99 100 //#define SHOW_RCV_RANGE101 102 /* タイムアウト */103 104 #define CON_TMO TMO_FEVR105 //#define CON_TMO (60*SYSTIM_HZ)106 //#define CLS_TMO TMO_FEVR /* Close Wait は標準で 60秒 */107 #define CLS_TMO (70*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*10)108 //#define RCV_TMO TMO_FEVR109 #define RCV_TMO (40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20)110 //#define SND_TMO TMO_FEVR111 #define SND_TMO (30*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*30)112 113 86 /* 送信間隔 */ 114 87 115 //#define SND_DLY ULONG_C(500) 116 #define SND_ITV (5*SYSTM_HZ) 88 #ifdef TOPPERS_S810_CLG3_85 89 90 //#define SND_DLY (500) 91 #define START_DLY (10*SYSTIM_HZ) 92 #define SND_ITV (5*SYSTIM_HZ) 93 #define SLP_ITV (30*SYSTIM_HZ) 94 95 #else /* of #ifdef TOPPERS_S810_CLG3_85 */ 96 97 //#define SND_DLY (500) 98 #define START_DLY (10*SYSTIM_HZ) 99 #define SND_ITV (5*SYSTIM_HZ) 117 100 #define SLP_ITV (60*SYSTIM_HZ) 118 101 102 #endif /* of #ifdef TOPPERS_S810_CLG3_85 */ 103 119 104 /* 自動実行 */ 120 105 106 #if defined(TCP_ECHO_CLI_AUTO_RUN_STR) 107 #else 121 108 #if 0 122 109 #if defined(SUPPORT_INET6) 123 #define AUTO_RUN_STR "fe80::211:2fff:fe8a:e8c0- 0"124 #else 125 #define AUTO_RUN_STR "172.25.193.140 - 0"126 #endif 127 #endif 128 129 /* 130 * バッファサイズの定義 131 */ 132 133 # define NUM_ECHO 20134 #define NUM_REP_PAT 20135 # define PAT_BEGIN ' '136 # define PAT_END '~'137 #define SND_BUF_SIZE ((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)138 # define RCV_BUF_SIZE (SND_BUF_SIZE*15/10)110 #define TCP_ECHO_CLI_AUTO_RUN_STR "fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0" 111 #else 112 #define TCP_ECHO_CLI_AUTO_RUN_STR "172.25.129.140 - 0" 113 #endif 114 #endif 115 #endif 116 117 #if defined(SUPPORT_INET6) 118 #if defined(SUPPORT_INET4) 119 #define API_PROTO 'n' 120 #else 121 #define API_PROTO '6' 122 #endif 123 #else 124 #define API_PROTO '4' 125 #endif 139 126 140 127 /* … … 142 129 */ 143 130 144 bool_t tcp_echo_cli_valid; 131 bool_t tcp_echo_cli_valid; 132 uint_t tcp_echo_cli_scount; 145 133 146 134 /* TCP 送受信ウィンドバッファ */ … … 154 142 #endif 155 143 156 /*157 * 変数158 */159 160 static uint_t scount;161 static uint_t rcount;162 163 144 #ifdef USE_TCP_NON_BLOCKING 164 145 165 static T_IPEP nblk_src = { 166 IP_ADDRANY, 167 TCP_PORTANY, 168 }; 169 static T_IPEP nblk_dst; 170 static ER_UINT nblk_error; 146 /* 147 * 全域変数 148 */ 149 150 ER_UINT tcp_echo_cli_nblk_error; 171 151 172 152 /* … … 179 159 ER error = E_OK; 180 160 181 nblk_error = *(ER*)p_parblk;161 tcp_echo_cli_nblk_error = *(ER*)p_parblk; 182 162 183 163 switch (fncd) { … … 188 168 189 169 case TFN_TCP_RCV_BUF: 190 if (nblk_error < 0) 191 syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv buf error: %s", cepid, itron_strerror(nblk_error)); 170 if (tcp_echo_cli_nblk_error < 0) 171 syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s", 172 API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error)); 192 173 syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY)); 193 174 break; 194 175 195 176 case TFN_TCP_CLS_CEP: 196 if (nblk_error < 0) 197 syslog(LOG_NOTICE, "[TEC:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error)); 177 if (tcp_echo_cli_nblk_error < 0) 178 syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s", 179 API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error)); 198 180 syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY)); 199 181 break; 200 182 201 183 case TFN_TCP_RCV_DAT: 202 if (nblk_error < 0) 203 syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv dat error: %s", cepid, itron_strerror(nblk_error)); 184 if (tcp_echo_cli_nblk_error < 0) 185 syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s", 186 API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error)); 204 187 syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY)); 205 188 break; 206 189 207 190 case TFN_TCP_SND_OOB: 208 if (nblk_error > 0) 209 syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg: %4d", cepid, nblk_error); 191 if (tcp_echo_cli_nblk_error > 0) 192 syslog(LOG_NOTICE, "[TEC%c:%02u CBN] snd urg: %4u", 193 API_PROTO, cepid, tcp_echo_cli_nblk_error); 210 194 else 211 syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg error: %s", cepid, itron_strerror(nblk_error)); 195 syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s", 196 API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error)); 212 197 break; 213 198 … … 222 207 } 223 208 224 /*225 * send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。226 */227 228 static ER229 send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)230 {231 static char smsg[SND_BUF_SIZE];232 233 ER_UINT slen;234 ER error;235 SYSTIM time;236 uint32_t total;237 uint16_t soff, echo, rep;238 char *p, pat;239 240 #ifdef SND_URG_DATA_SIZE241 int_t urg = SND_URG_COUNT;242 #endif243 244 nblk_dst.ipaddr = *ipaddr;245 nblk_dst.portno = portno;246 247 p = smsg;248 for (rep = NUM_REP_PAT; rep -- > 0; )249 for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)250 *p ++ = pat;251 252 if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {253 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));254 return error;255 }256 257 /* 接続が完了するまで待つ。*/258 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));259 260 if (nblk_error != E_OK)261 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(nblk_error));262 else {263 get_tim(&time);264 syslog(LOG_NOTICE, "[TEC:%02d SND] connecting: %6lu, to: %s.%u",265 cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);266 267 if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {268 syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));269 goto cls_ret;270 }271 272 scount = total = 0;273 for (echo = NUM_ECHO; echo -- > 0; ) {274 soff = 0;275 while (soff < SND_BUF_SIZE) {276 if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {277 syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s",278 cepid, itron_strerror(slen));279 goto cls_ret;280 }281 soff += (uint16_t)slen;282 total += slen;283 scount ++;284 #ifdef SHOW_RCV_RANGE285 syslog(LOG_NOTICE, "[TEC:%02d SND] send cnt: %2d, len: %4d, off: %4d",286 cepid, scount, (uint16_t)slen, soff);287 #endif /* of #ifdef SHOW_RCV_RANGE */288 289 #ifdef SND_URG_DATA_SIZE290 if (urg) {291 if (urg == 1) {292 if ((error = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, TMO_NBLK)) != E_WBLK)293 syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",294 cepid, itron_strerror(error));295 }296 urg --;297 }298 #endif /* of #ifdef SND_URG_DATA_SIZE */299 300 #if SND_DLY > 0301 syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));302 #endif303 }304 }305 306 cls_ret:307 if ((error = tcp_sht_cep(cepid)) < 0)308 syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));309 310 /* 受信が完了するまで待つ。*/311 syscall(slp_tsk());312 }313 314 return error;315 }316 317 /*318 * TCP ECHO クライアント受信タスク319 */320 321 #ifdef USE_COPYSAVE_API322 323 void324 tcp_echo_cli_rcv_task (intptr_t exinf)325 {326 ID tskid, cepid;327 ER error;328 SYSTIM time;329 uint32_t total;330 uint16_t roff, rlen;331 char *rmsg, head, tail;332 333 get_tid(&tskid);334 syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK,CS) RCV:%d] started.", tskid);335 while (true) {336 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {337 syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",338 cepid, itron_strerror(error));339 }340 else {341 roff = rcount = total = 0;342 while (true) {343 if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {344 syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s", cepid, itron_strerror(error));345 break;346 }347 348 /* 受信バッファの獲得が完了するまで待つ。*/349 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));350 if (nblk_error < 0)351 break;352 353 rlen = nblk_error;354 head = *rmsg;355 tail = *(rmsg + rlen - 1);356 if (rlen > 0) {357 roff += rlen;358 total += rlen;359 rcount ++;360 #ifdef SHOW_RCV_RANGE361 syslog(LOG_NOTICE, "[TEC:%02d RCV] "362 "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",363 cepid, rcount, rlen, roff, head, tail);364 #endif /* of #ifdef SHOW_RCV_RANGE */365 }366 else367 break;368 369 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)370 syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s",371 cepid, itron_strerror(error));372 }373 374 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)375 syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));376 377 /* 切断が完了するまで待つ。*/378 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));379 380 get_tim(&time);381 syslog(LOG_NOTICE, "[TEC:%02u RCV] finished: %6lu, snd: %4u, rcv: %4u, len: %u",382 cepid, time / SYSTIM_HZ, scount, rcount, total);383 }384 385 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));386 }387 }388 389 #else /* of #ifdef USE_COPYSAVE_API */390 391 void392 tcp_echo_cli_rcv_task (intptr_t exinf)393 {394 static char rmsg[RCV_BUF_SIZE];395 396 ID tskid, cepid;397 ER error;398 SYSTIM time;399 uint32_t total;400 uint16_t roff, rlen;401 char head, tail;402 403 get_tid(&tskid);404 syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK) RCV:%d] started.", tskid);405 while (true) {406 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {407 syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",408 cepid, itron_strerror(error));409 }410 else {411 roff = rcount = total = 0;412 while (true) {413 if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {414 syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv error: %s", cepid, itron_strerror(error));415 break;416 }417 418 /* 受信が完了するまで待つ。*/419 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));420 if (nblk_error < 0)421 break;422 423 rlen = nblk_error;424 head = *rmsg;425 tail = *(rmsg + rlen - 1);426 rcount ++;427 if (rlen > 0) {428 roff += rlen;429 total += rlen;430 #ifdef SHOW_RCV_RANGE431 syslog(LOG_NOTICE, "[TEC:%02d RCV] "432 "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",433 cepid, rcount, rlen, roff, head, tail);434 #endif /* of #ifdef SHOW_RCV_RANGE */435 }436 else437 break;438 }439 440 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)441 syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));442 443 /* 切断が完了するまで待つ。*/444 syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));445 446 get_tim(&time);447 syslog(LOG_NOTICE, "[TEC:%02u RCV] finished: %6lu, snd: %4u, rcv: %4u, len: %u",448 cepid, time / SYSTIM_HZ, scount, rcount, total);449 }450 451 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));452 }453 }454 455 #endif /* of #ifdef USE_COPYSAVE_API */456 457 #else /* of #ifdef USE_TCP_NON_BLOCKING */458 459 /*460 * send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。461 */462 463 static ER464 send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)465 {466 static char smsg[SND_BUF_SIZE];467 static T_IPEP src = {468 IP_ADDRANY,469 TCP_PORTANY,470 };471 472 T_IPEP dst;473 ER_UINT slen;474 ER error;475 SYSTIM time;476 uint32_t total;477 uint16_t soff, echo, rep;478 char pat, *p;479 480 #ifdef SND_URG_DATA_SIZE481 int_t urg = SND_URG_COUNT;482 #endif483 484 dst.ipaddr = *ipaddr;485 dst.portno = portno;486 487 p = smsg;488 for (rep = NUM_REP_PAT; rep -- > 0; )489 for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)490 *p ++ = pat;491 492 if ((error = TCP_CON_CEP(cepid, &src, &dst, CON_TMO)) != E_OK) {493 syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));494 return error;495 }496 497 get_tim(&time);498 syslog(LOG_NOTICE, "[TEC:%02u SND] connecting: %6lu, to: %s.%u",499 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);500 501 if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {502 syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));503 goto cls_ret;504 }505 506 scount = total = 0;507 for (echo = NUM_ECHO; echo -- > 0; ) {508 soff = 0;509 while (soff < SND_BUF_SIZE) {510 if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {511 syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s", cepid, itron_strerror(slen));512 goto cls_ret;513 }514 soff += (uint16_t)slen;515 total += slen;516 scount ++;517 #ifdef SHOW_RCV_RANGE518 syslog(LOG_NOTICE, "[TEC:%02d SND] send count: %3d, len: %4d, offset: %4d",519 cepid, scount, (uint16_t)slen, soff);520 #endif /* of #ifdef SHOW_RCV_RANGE */521 522 #ifdef SND_URG_DATA_SIZE523 if (urg > 0) {524 if (urg == 1) {525 if ((slen = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, SND_TMO)) >= 0)526 syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg: %4d",527 cepid, (uint16_6)slen);528 else529 syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",530 cepid, itron_strerror(slen));531 }532 urg --;533 }534 #endif /* of #ifdef SND_URG_DATA_SIZE */535 536 #if SND_DLY > 0537 syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));538 #endif539 }540 }541 542 cls_ret:543 if ((error = tcp_sht_cep(cepid)) < 0)544 syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));545 546 /* 受信が完了するまで待つ。*/547 syscall(slp_tsk());548 549 return error;550 }551 552 /*553 * TCP ECHO クライアント受信タスク554 */555 556 #ifdef USE_COPYSAVE_API557 558 void559 tcp_echo_cli_rcv_task (intptr_t exinf)560 {561 ID tskid, cepid;562 ER_UINT rlen;563 ER error;564 SYSTIM time;565 uint32_t total;566 uint16_t roff;567 char *rmsg;568 569 get_tid(&tskid);570 syslog(LOG_NOTICE, "[TCP ECHO CLI (CS) RCV:%d] started.", tskid);571 while (true) {572 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {573 syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",574 cepid, itron_strerror(error));575 }576 else {577 roff = rcount = total = 0;578 while (true) {579 if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, RCV_TMO)) < 0) {580 syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s",581 cepid, itron_strerror(rlen));582 break;583 }584 else if (rlen > 0) {585 roff += (uint16_t)rlen;586 total += rlen;587 rcount ++;588 #ifdef SHOW_RCV_RANGE589 syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",590 cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));591 #endif /* of #ifdef SHOW_RCV_RANGE */592 }593 else594 break;595 if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)596 syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s", cepid, itron_strerror(error));597 }598 599 if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)600 syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));601 602 get_tim(&time);603 syslog(LOG_NOTICE, "[TEC:%02u RCV] finished: %6lu, snd: %4u, rcv: %4u, len: %u",604 cepid, time / SYSTIM_HZ, scount, rcount, total);605 }606 607 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));608 }609 }610 611 #else /* of #ifdef USE_COPYSAVE_API */612 613 void614 tcp_echo_cli_rcv_task (intptr_t exinf)615 {616 static char rmsg[RCV_BUF_SIZE];617 618 ID tskid, cepid;619 ER_UINT rlen;620 ER error;621 SYSTIM time;622 uint32_t total;623 uint16_t roff;624 625 get_tid(&tskid);626 syslog(LOG_NOTICE, "[TCP ECHO CLI RCV:%d] started.", tskid);627 while (true) {628 if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {629 syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",630 cepid, itron_strerror(error));631 }632 else {633 roff = rcount = total = 0;634 while (true) {635 if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), RCV_TMO)) < 0) {636 syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv dat error: %s", cepid, itron_strerror(rlen));637 tcp_can_cep(cepid, TFN_TCP_ALL);638 break;639 }640 else if (rlen > 0) {641 roff += (uint16_t)rlen;642 total += rlen;643 rcount ++;644 #ifdef SHOW_RCV_RANGE645 syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",646 cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));647 #endif /* of #ifdef SHOW_RCV_RANGE */648 }649 else650 break;651 }652 653 if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)654 syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));655 656 get_tim(&time);657 syslog(LOG_NOTICE, "[TEC:%02u RCV] received: %6lu, snd: %4u, rcv: %4u, len: %u",658 cepid, time / SYSTIM_HZ, scount, rcount, total);659 }660 661 syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));662 }663 }664 665 #endif /* of #ifdef USE_COPYSAVE_API */666 667 209 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 668 210 … … 671 213 */ 672 214 673 #ifdef AUTO_RUN_STR215 #ifdef TCP_ECHO_CLI_AUTO_RUN_STR 674 216 675 217 static char * 676 getcomd (ID cepid )218 getcomd (ID cepid, bool_t retry, char *apip) 677 219 { 678 220 ER error; 679 221 char *line = NULL; 680 static char auto_run_str[] = AUTO_RUN_STR;222 static char auto_run_str[] = TCP_ECHO_CLI_AUTO_RUN_STR; 681 223 static int_t count = 0; 682 224 683 if ( count == 0) {225 if (retry || (count == 0)) { 684 226 line = auto_run_str; 685 227 dly_tsk(3 * 1000); … … 687 229 else { 688 230 while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) { 689 syslog(LOG_NOTICE, "[TEC :%02d TSK] error: %s", cepid, itron_strerror(error));231 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error)); 690 232 dly_tsk(SLP_ITV); 691 233 } … … 696 238 } 697 239 698 #else /* of #ifdef AUTO_RUN_STR */240 #else /* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */ 699 241 700 242 static char * 701 getcomd (ID cepid )243 getcomd (ID cepid, bool_t retry, char *apip) 702 244 { 703 245 ER error; … … 705 247 706 248 while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) { 707 syslog(LOG_NOTICE, "[TEC :%02d TSK] error: %s", cepid, itron_strerror(error));249 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error)); 708 250 dly_tsk(SLP_ITV); 709 251 } 252 253 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) 254 255 if (*line == '6') { 256 line ++; 257 *apip = API_PROTO_IPV6; 258 } 259 else if (*line == '4') { 260 line ++; 261 *apip = API_PROTO_IPV4; 262 } 263 else { 264 *apip= DEFAULT_API_PROTO; 265 if (*line && *line != ' ') 266 line ++; 267 } 268 269 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 270 271 *apip= DEFAULT_API_PROTO; 272 if (*line && *line != ' ') 273 line ++; 274 275 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 276 710 277 return line; 711 278 } 712 279 713 #endif /* of #ifdef AUTO_RUN_STR */280 #endif /* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */ 714 281 715 282 /* 716 283 * TCP ECHO クライアント送信タスク 717 284 */ 285 286 /* 287 * IP アドレスの指定 288 */ 289 290 #define ADDR_IPVn 'n' 291 #define ADDR_IPV6 '6' 292 #define ADDR_IPV4 '4' 718 293 719 294 void … … 723 298 ER error; 724 299 T_IN_ADDR addr; 300 char *line; 301 int_t rep, count; 302 bool_t retry = false; 725 303 uint16_t portno; 726 int_t rep, count; 727 char *line; 304 char apip; 728 305 729 306 #ifdef USE_TCP_EXTENTIONS … … 733 310 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 734 311 312 #ifdef TCP_ECHO_CLI_AUTO_RUN_STR 313 dly_tsk(START_DLY); 314 #endif 735 315 get_tid(&tskid); 736 syslog(LOG_NOTICE, "[TCP ECHO CLI SND:%d,%d] started.", tskid, (ID)exinf);316 syslog(LOG_NOTICE, "[TCP%c ECHO CLI SND:%d,%d] started.", DEFAULT_API_PROTO, tskid, (ID)exinf); 737 317 while (true) { 738 line = getcomd((ID)exinf); 739 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line))); /* IP Address */ 740 741 if ('0' <= *line && *line <= '9') { /* Port No */ 318 line = skip_blanks(getcomd((ID)exinf, retry, &apip)); 319 320 #if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR) 321 322 if (apip == API_PROTO_IPV4) { 323 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf); 324 retry = true; 325 continue; 326 } 327 328 #endif /* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR) */ 329 330 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 331 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], unknown host.", 332 API_PROTO, (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ); 333 dly_tsk(SLP_ITV); 334 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", API_PROTO, (ID)exinf); 335 retry = true; 336 continue; 337 } 338 else 339 retry = false; 340 341 #if defined(SUPPORT_INET6) 342 343 #if defined(USE_TCP4_ECHO_CLI) 344 345 #else /* of #if defined(USE_TCP4_ECHO_CLI) */ 346 347 if (in6_is_addr_ipv4mapped(&addr)) 348 apip = API_PROTO_IPV4; 349 else 350 apip = API_PROTO_IPV6; 351 352 #endif /* of #if defined(USE_TCP4_ECHO_CLI) */ 353 354 #else /* of #if defined(SUPPORT_INET6) */ 355 356 if (apip == API_PROTO_IPV6) { 357 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf); 358 retry = true; 359 continue; 360 } 361 362 #endif /* of #if defined(SUPPORT_INET6) */ 363 364 line = skip_blanks(line); 365 if ('0' <= *line && *line <= '9') { /* Port No */ 742 366 line = get_int(&rep, line); 743 367 portno = (uint16_t)rep; … … 749 373 750 374 line = skip_blanks(line); 751 if ('0' <= *line && *line <= '9') 375 if ('0' <= *line && *line <= '9') /* Repeat */ 752 376 line = get_int(&rep, line); 753 else 377 else { 378 line ++; 754 379 rep = 1; 380 } 755 381 756 382 #ifdef USE_TCP_EXTENTIONS … … 776 402 #endif 777 403 778 if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) { 779 syslog(LOG_NOTICE, "[TEC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error)); 404 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) 405 406 if (apip == API_PROTO_IPV6) { 407 if ((error = alloc_tcp6_cep(&cepid, tskid, &ccep)) != E_OK) { 408 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error)); 409 continue; 410 } 411 } 412 else { 413 if ((error = alloc_tcp4_cep(&cepid, tskid, &ccep)) != E_OK) { 414 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error)); 415 continue; 416 } 417 } 418 419 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 420 421 if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) { 422 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error)); 780 423 continue; 781 424 } 782 425 426 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 427 783 428 #else /* of #ifdef USE_TCP_EXTENTIONS */ 784 429 430 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) 431 432 if (apip == API_PROTO_IPV6) 433 cepid = (ID)exinf; 434 else 435 cepid = TCP4_ECHO_CLI_CEPID; 436 437 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 438 785 439 cepid = (ID)exinf; 440 441 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */ 786 442 787 443 #endif /* of #ifdef USE_TCP_EXTENTIONS */ … … 791 447 while (rep == 0 || count < rep) { 792 448 if (!tcp_echo_cli_valid) { 793 syslog(LOG_NOTICE, "[TEC :%02d TSK] canceled.", cepid);449 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] canceled.", apip, cepid); 794 450 break; 795 451 } … … 797 453 count ++; 798 454 if (rep == 0) { 799 syslog(LOG_NOTICE, "[TEC :%02d TSK] start: repeat: %d", cepid, count);800 error = send_tcp_echo(cepid, &addr, portno);801 syslog(LOG_NOTICE, "[TEC :%02d TSK] finished: repeat: %d", cepid, count);455 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start: repeat: %d", apip, cepid, count); 456 error = tcp_echo_cli_snd(cepid, &addr, portno, apip); 457 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh: repeat: %d", apip, cepid, count); 802 458 } 803 459 else { 804 syslog(LOG_NOTICE, "[TEC :%02d TSK] start: repeat: %d/%d", cepid, count, rep);805 error = send_tcp_echo(cepid, &addr, portno);806 syslog(LOG_NOTICE, "[TEC :%02d TSK] finished: repeat: %d/%d", cepid, count, rep);460 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start: repeat: %d/%d", apip, cepid, count, rep); 461 error = tcp_echo_cli_snd(cepid, &addr, portno, apip); 462 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh: repeat: %d/%d", apip, cepid, count, rep); 807 463 } 808 464 809 465 if (error != E_OK) { 810 syslog(LOG_NOTICE, "[TEC :%02d TSK] sleep %d[ms], error: %s",811 cepid, SLP_ITV, itron_strerror(error));466 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], error: %s", 467 apip, cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error)); 812 468 tslp_tsk(SLP_ITV); 813 syslog(LOG_NOTICE, "[TEC :%02d TSK] resume.", cepid);469 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", apip, cepid); 814 470 } 815 471 816 472 #if defined(SND_ITV) 817 473 #if SND_ITV > 0 818 if (count > 0) {474 if (count < rep) { 819 475 uint_t itv; 820 476 821 477 itv = SND_ITV; 822 syslog(LOG_NOTICE, "[TEC :%02d TSK] interval: %d[ms].", cepid, itv);478 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] interval: %d[s].", apip, cepid, itv / SYSTIM_HZ); 823 479 syscall(dly_tsk(SND_ITV)); 824 480 } … … 829 485 #ifdef USE_TCP_EXTENTIONS 830 486 831 if ((error = free_tcp_cep(cepid)) != E_OK)832 syslog(LOG_NOTICE, "[TEC :%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));487 if ((error = FREE_TCP_CEP(cepid)) != E_OK) 488 syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error)); 833 489 834 490 #endif /* of #ifdef USE_TCP_EXTENTIONS */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 62 62 #endif /* of #ifdef TARGET_KERNEL_JSP */ 63 63 64 #include <tinet_defs.h>65 #include <tinet_config.h>66 67 #include <net/if.h>68 #include <net/if_ppp.h>69 #include <net/if_loop.h>70 #include <net/ethernet.h>71 #include <net/net.h>72 #include <net/net_timer.h>73 74 64 #include <netinet/in.h> 75 65 #include <netinet/in_itron.h> 76 #include <netinet/ip.h>77 #include <netinet/ip6.h>78 #include <netinet/tcp.h>79 66 80 67 #include <netapp/netapp.h> 81 68 #include <netapp/netapp_var.h> 82 #include <netapp/echo.h> 69 #include <netapp/tcp_echo_srv1.h> 70 #include <netapp/tcp_echo_srv1_var.h> 71 72 #if defined(_NET_CFG_BYTE_ORDER) 73 #error "net/net.h included." 74 #endif 83 75 84 76 #ifdef USE_TCP_ECHO_SRV1 … … 100 92 */ 101 93 94 #ifdef TOPPERS_S810_CLG3_85 95 96 #define CLS_TMO TMO_FEVR /* Close Wait は標準で 60秒 */ 97 //#define RCV_TMO TMO_FEVR 98 #define RCV_TMO (30*SYSTIM_HZ) 99 //#define SND_TMO TMO_FEVR 100 #define SND_TMO (30*SYSTIM_HZ) 101 102 #else /* of #ifdef TOPPERS_S810_CLG3_85 */ 103 102 104 //#define CLS_TMO TMO_FEVR /* Close Wait は標準で 60秒 */ 103 #define CLS_TMO (70*SYSTIM_HZ+(net _rand()%SYSTIM_HZ)*10)105 #define CLS_TMO (70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10) 104 106 //#define RCV_TMO TMO_FEVR 105 #define RCV_TMO (30*SYSTIM_HZ+(net _rand()%SYSTIM_HZ)*30)107 #define RCV_TMO (30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30) 106 108 //#define SND_TMO TMO_FEVR 107 #define SND_TMO (40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20) 109 #define SND_TMO (40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20) 110 111 #endif /* of #ifdef TOPPERS_S810_CLG3_85 */ 108 112 109 113 /* … … 121 125 #endif 122 126 127 #ifndef USE_TCP_NON_BLOCKING 128 123 129 /* 124 130 * 変数 125 131 */ 126 132 127 /* 128 * 注意: 129 * 130 * BUF_SIZE は TCP の 131 * 送信ウインドウバッファサイズ + 受信ウインドウバッファサイズの 132 * 3/2 倍以上の大きさがなければ、デッドロックする可能性がある。 133 */ 134 135 #define BUF_SIZE ((TCP_ECHO_SRV_SWBUF_SIZE + \ 136 TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2) 137 138 static T_IPEP dst; /* 接続相手 */ 139 140 #ifdef USE_TCP_NON_BLOCKING 141 142 static char buffer[BUF_SIZE]; 143 static ER nblk_error = E_OK; 144 static ER_UINT nblk_slen = 0; 145 static ER_UINT nblk_rlen = 0; 146 147 #else /* of #ifdef USE_TCP_NON_BLOCKING */ 148 149 #ifdef USE_COPYSAVE_API 150 151 #else /* of #ifdef USE_COPYSAVE_API */ 152 153 static char buffer[BUF_SIZE]; 154 155 #endif /* of #ifdef USE_COPYSAVE_API */ 156 157 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 158 159 #ifdef USE_TCP_NON_BLOCKING 160 161 /* 162 * ノンブロッキングコールのコールバック関数 163 */ 164 165 ER 166 callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk) 133 #ifdef USE_TCP_EXTENTIONS 134 135 T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[NUM_TCP_ECHO_SRV_TASKS]; 136 137 #else /* of #ifdef USE_TCP_EXTENTIONS */ 138 139 T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = { 140 141 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) 142 143 { TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID }, 144 145 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */ 146 147 { TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID }, 148 149 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */ 150 151 #if NUM_TCP_ECHO_SRV_TASKS >= 2 152 { TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID }, 153 #endif 154 #if NUM_TCP_ECHO_SRV_TASKS >= 3 155 { TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID }, 156 #endif 157 #if NUM_TCP_ECHO_SRV_TASKS >= 4 158 { TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID }, 159 #endif 160 #if NUM_TCP_ECHO_SRV_TASKS >= 5 161 { TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID }, 162 #endif 163 #if NUM_TCP_ECHO_SRV_TASKS >= 6 164 { TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID }, 165 #endif 166 #if NUM_TCP_ECHO_SRV_TASKS >= 7 167 { TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID }, 168 #endif 169 #if NUM_TCP_ECHO_SRV_TASKS >= 8 170 { TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID }, 171 #endif 172 173 }; 174 175 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 176 177 /* 178 * tcp_passive_open -- 受動オープンを実行する。 179 * 180 * USE_TCP_NON_BLOCKING OFF 181 */ 182 183 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 184 185 static ER 186 tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip) 167 187 { 168 ER error = E_OK; 169 170 switch (fncd) { 171 172 case TFN_TCP_ACP_CEP: 173 nblk_error = *(ER*)p_parblk; 174 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 175 break; 176 177 case TFN_TCP_RCV_DAT: 178 if ((nblk_rlen = *(ER*)p_parblk) < 0) 179 syslog(LOG_NOTICE, "[TES:%02d CBN] recv error: %s", cepid, itron_strerror(nblk_rlen)); 180 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 181 break; 182 183 case TFN_TCP_SND_DAT: 184 if ((nblk_slen = *(ER*)p_parblk) < 0) 185 syslog(LOG_NOTICE, "[TES:%02d CBN] send error: %s", cepid, itron_strerror(nblk_slen)); 186 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 187 break; 188 189 case TFN_TCP_CLS_CEP: 190 if ((nblk_error = *(ER*)p_parblk) < 0) 191 syslog(LOG_NOTICE, "[TES:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error)); 192 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 193 break; 194 195 case TFN_TCP_RCV_BUF: 196 if ((nblk_rlen = *(ER*)p_parblk) < 0) 197 syslog(LOG_NOTICE, "[TES:%02d CBN] rbuf error: %s", cepid, itron_strerror(nblk_rlen)); 198 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 199 break; 200 201 case TFN_TCP_GET_BUF: 202 if ((nblk_slen = *(ER*)p_parblk) < 0) 203 syslog(LOG_NOTICE, "[TES:%02d CBN] sbuf error: %s", cepid, itron_strerror(nblk_slen)); 204 syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 205 break; 188 ER error = E_OK; 189 190 #if TNUM_TCP4_REPID > 0 191 T_IPV4EP dst4; 192 #endif 193 194 if (apip == API_PROTO_IPV6) { 195 196 #if TNUM_TCP6_REPID > 0 197 198 /* 受付口は IPv6 */ 199 if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 200 return error; 206 201 207 202 #ifdef USE_TCP_EXTENTIONS 208 209 case TEV_TCP_RCV_OOB: 210 if ((nblk_rlen = *(ER*)p_parblk) < 0) 211 syslog(LOG_NOTICE, "[TES:%02d OOB] callback error: %s", cepid, itron_strerror(nblk_rlen)); 212 else if (nblk_rlen > 0) { 213 char ch; 214 215 if ((nblk_rlen = tcp_rcv_oob(cepid, &ch, sizeof(ch))) > 0) 216 syslog(LOG_NOTICE, "[TES:%02d OOB] recv oob: 0x%02x", cepid, ch); 217 else if (nblk_rlen < 0) 218 syslog(LOG_NOTICE, "[TES:%02d OOB] recv error: %s", cepid, itron_strerror(nblk_rlen)); 219 } 220 break; 221 203 if ((error = free_tcp6_rep(info->repid, true)) != E_OK) 204 return error; 222 205 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 223 206 224 case TFN_TCP_CON_CEP: 225 case TFN_TCP_SND_OOB: 226 default: 227 error = E_PAR; 228 break; 229 } 207 #endif /* of #if TNUM_TCP6_REPID > 0 */ 208 209 } 210 else { 211 212 #if TNUM_TCP4_REPID > 0 213 214 /* 受付口は IPv4 */ 215 if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK) 216 return error; 217 in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr); 218 info->dst.portno = dst4.portno; 219 220 #ifdef USE_TCP_EXTENTIONS 221 if ((error = free_tcp4_rep(info->repid, true)) != E_OK) 222 return error; 223 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 224 225 #endif /* of #if TNUM_TCP4_REPID > 0 */ 226 227 } 228 230 229 return error; 231 230 } 232 231 232 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 233 234 /* 235 * tcp_passive_open -- 受動オープンを実行する。 236 * 237 * USE_TCP_NON_BLOCKING OFF 238 */ 239 240 static ER 241 tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip) 242 { 243 ER error = E_OK; 244 245 if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 246 return error; 247 248 #ifdef USE_TCP_EXTENTIONS 249 if ((error = FREE_TCP_REP(info->repid, true)) != E_OK) 250 return error; 251 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 252 253 return error; 254 } 255 256 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 257 233 258 #ifdef USE_COPYSAVE_API 234 259 235 static ER 236 tcp_echo_srv (ID cepid, ID repid) 260 /* 261 * tcp_echo_srv -- TCP エコーサーバ 262 * 263 * USE_TCP_NON_BLOCKING OFF 264 * USE_COPYSAVE_API ON 265 */ 266 267 ER 268 tcp_echo_srv (uint_t six, char apip) 237 269 { 238 ER error; 270 ER error = E_OK; 271 ER_UINT rblen, sblen; 239 272 SYSTIM now; 240 273 uint32_t total; 241 uint16_t rblen, sblen, rlen, slen, soff, scount, rcount; 242 char *rbuf, *sbuf, head, tail; 243 244 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) { 245 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error)); 274 uint16_t rlen, slen, soff, scount, rcount; 275 char *rbuf, *sbuf; 276 277 #ifdef SHOW_RCV_RANGE 278 char head, tail; 279 #endif 280 281 if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) { 282 syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s", 283 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 246 284 return error; 247 285 } 248 286 249 /* 相手から接続されるまで待つ。*/ 250 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 251 252 if (nblk_error == E_OK) { 253 syscall(get_tim(&now)); 254 syslog(LOG_NOTICE, "[TES:%02d ACP] connected: %6lu, from: %s.%u", 255 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 256 } 287 syscall(get_tim(&now)); 288 289 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 290 291 if (apip == API_PROTO_IPV6) 292 syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u", 293 tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 294 ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr), 295 tcp_echo_srv_info[six].dst.portno); 257 296 else { 258 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error)); 259 return nblk_error; 260 } 261 262 #ifdef USE_TCP_EXTENTIONS 263 if ((error = free_tcp_rep(repid, true)) != E_OK) 264 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error)); 265 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 266 267 rlen = scount = rcount = total = 0; 297 T_IN4_ADDR addr; 298 299 addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]); 300 syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u", 301 tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 302 ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno); 303 } 304 305 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 306 307 syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u", 308 apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 309 IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr), 310 tcp_echo_srv_info[six].dst.portno); 311 312 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 313 314 scount = rcount = total = 0; 268 315 while (true) { 269 if ((error = tcp_rcv_buf(cepid, (void**)&rbuf, TMO_NBLK)) != E_WBLK) { 270 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", cepid, itron_strerror(error)); 316 if ((rblen = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, RCV_TMO)) <= 0) { 317 if (rblen != E_OK) 318 syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s", 319 apip, tcp_echo_srv_info[six].cepid, itron_strerror(rblen)); 271 320 break; 272 321 } 273 322 274 /* 受信するまで待つ。*/ 275 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 276 277 if (nblk_rlen < 0) { /* エラー */ 278 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", 279 cepid, itron_strerror(nblk_rlen)); 280 break; 281 } 282 else if (nblk_rlen == 0) /* 受信終了 */ 283 break; 284 285 rblen = nblk_rlen; 286 287 /* バッファの残りにより、受信長を調整する。*/ 288 if (rblen > BUF_SIZE - rlen) 289 rblen = BUF_SIZE - rlen; 290 total += rblen; 291 rlen = rblen; 292 323 rcount ++; 324 325 #ifdef SHOW_RCV_RANGE 293 326 head = *rbuf; 294 327 tail = *(rbuf + rblen - 1); 295 rcount ++; 296 297 #ifdef SHOW_RCV_RANGE 298 syslog(LOG_NOTICE, "[TES:%02d RCV] " 299 "rcount: %4d, len: %4d, data %02x -> %02x", 300 cepid, rcount, rblen, head, tail); 328 329 //syslog(LOG_NOTICE, "[TES%c:%02u RCV] len: %7lu", 330 // apip, tcp_echo_srv_info[six].cepid, (uint16_t)rblen); 331 syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %7lu, len: %6lu, data %02x -> %02x", 332 apip, tcp_echo_srv_info[six].cepid, rcount, (uint16_t)rblen, head, tail); 301 333 #endif /* of #ifdef SHOW_RCV_RANGE */ 302 334 303 memcpy(buffer, rbuf, rblen); 304 305 if ((error = tcp_rel_buf(cepid, rlen)) < 0) { 306 syslog(LOG_NOTICE, "[TES:%02d REL] error: %s", 307 cepid, itron_strerror(error)); 308 break; 309 } 310 335 rlen = (uint16_t)rblen; 336 total += rblen; 311 337 soff = 0; 312 338 while (rlen > 0) { 313 339 314 if (( error = tcp_get_buf(cepid, (void**)&sbuf, TMO_NBLK)) != E_WBLK) {315 syslog(LOG_NOTICE, "[TES :%02dGET] error: %s",316 cepid, itron_strerror(error));340 if ((sblen = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, SND_TMO)) < 0) { 341 syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s", 342 apip, tcp_echo_srv_info[six].cepid, itron_strerror(sblen)); 317 343 goto err_fin; 318 344 } 319 345 320 /* 送信バッファの獲得が完了するまで待つ。*/ 321 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 322 323 if (nblk_slen < 0) { 324 syslog(LOG_NOTICE, "[TES:%02d GET] error: %s", 325 cepid, itron_strerror(nblk_slen)); 326 goto err_fin; 327 } 328 329 sblen = nblk_slen; 346 //syslog(LOG_NOTICE, "[TES%c:%02u SND] len: %7lu", 347 // apip, tcp_echo_srv_info[six].cepid, (uint16_t)sblen); 330 348 scount ++; 331 slen = sblen < rlen ? sblen : rlen; 332 memcpy(sbuf, buffer + soff, slen); 333 334 if ((error = tcp_snd_buf(cepid, slen)) != E_OK) { 335 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s", 336 cepid, itron_strerror(error)); 349 slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen; 350 memcpy(sbuf, rbuf + soff, slen); 351 if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) { 352 syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s", 353 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 337 354 goto err_fin; 338 355 } 339 356 #ifdef SHOW_RCV_RANGE 340 syslog(LOG_NOTICE, "[TES :%02d SND] scount: %4d, len: %4d",341 cepid, scount, slen);357 syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u", 358 apip, tcp_echo_srv_info[six].cepid, scount, slen); 342 359 #endif /* of #ifdef SHOW_RCV_RANGE */ 343 360 … … 345 362 soff += slen; 346 363 } 364 365 if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rblen)) < 0) { 366 syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s", 367 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 368 break; 369 } 347 370 } 348 371 err_fin: 349 372 350 373 #ifdef USE_TCP_SHT_CEP 351 if ((error = tcp_sht_cep(cepid)) != E_OK) 352 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error)); 374 if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK) 375 syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s", 376 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 353 377 #endif /* of #ifdef USE_TCP_SHT_CEP */ 354 378 355 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) 356 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error)); 357 358 /* 開放が完了するまで待つ。*/ 359 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 379 if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, CLS_TMO)) != E_OK) 380 syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s", 381 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 360 382 361 383 syscall(get_tim(&now)); 362 syslog(LOG_NOTICE, "[TES:%02d FIN] finished: %6lu, snd: %4u, rcv: %4u, len: %lu", 363 cepid, now / SYSTIM_HZ, scount, rcount, total); 364 365 return error == E_WBLK ? E_OK : error; 384 #if 1 385 syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu", 386 apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total); 387 #else 388 syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu, error: %s", 389 apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total, itron_strerror(error)); 390 #endif 391 392 return error; 366 393 } 367 394 368 395 #else /* of #ifdef USE_COPYSAVE_API */ 369 396 370 static ER 371 tcp_echo_srv (ID cepid, ID repid) 397 /* 398 * tcp_echo_srv -- TCP エコーサーバ 399 * 400 * USE_TCP_NON_BLOCKING OFF 401 * USE_COPYSAVE_API OFF 402 */ 403 404 ER 405 tcp_echo_srv (uint_t six, char apip) 372 406 { 407 ID cepid; 408 ER error = E_OK; 409 ER_UINT rlen, slen; 373 410 SYSTIM now; 374 ER error;375 411 uint32_t total; 376 uint16_t rlen, slen,soff, scount, rcount;377 char head, tail; 378 379 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {380 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s",cepid, itron_strerror(error));412 uint16_t soff, scount, rcount; 413 414 if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) { 415 syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s", 416 apip, tcp_echo_srv_info[six].cepid, itron_strerror(error)); 381 417 return error; 382 418 } 383 384 /* 相手から接続されるまで待つ。*/ 385 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 386 387 if (nblk_error == E_OK) { 388 syscall(get_tim(&now)); 389 syslog(LOG_NOTICE, "[TES:%02d ACP] connected: %6lu, from: %s.%u", 390 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 391 } 392 else { 393 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error)); 394 return nblk_error; 395 } 396 397 #ifdef USE_TCP_EXTENTIONS 398 if ((error = free_tcp_rep(repid, true)) != E_OK) 399 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error)); 400 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 401 419 420 syscall(get_tim(&now)); 421 422 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 423 424 if (apip == API_PROTO_IPV6) 425 syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u", 426 tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 427 ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr), 428 tcp_echo_srv_info[six].dst.portno); 429 else { 430 T_IN4_ADDR addr; 431 432 addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]); 433 syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u", 434 tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 435 ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno); 436 } 437 438 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 439 440 syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u", 441 apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, 442 IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr), 443 tcp_echo_srv_info[six].dst.portno); 444 445 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 446 447 cepid = tcp_echo_srv_info[six].cepid; 402 448 scount = rcount = total = 0; 403 449 while (true) { 404 if ((error = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) { 405 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", 406 cepid, itron_strerror(error)); 450 if ((rlen = tcp_rcv_dat(cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) { 451 if (rlen != E_OK) 452 syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s", 453 apip, cepid, itron_strerror(rlen)); 407 454 break; 408 455 } 409 456 410 /* 受信完了まで待つ。*/411 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));412 413 if (nblk_rlen < 0) {414 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",415 cepid, itron_strerror(nblk_rlen));416 break;417 }418 else if (nblk_rlen == 0)419 break;420 421 rlen = nblk_rlen;422 head = *buffer;423 tail = *(buffer + rlen - 1);424 457 rcount ++; 425 426 458 #ifdef SHOW_RCV_RANGE 427 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x", 428 cepid, rcount, rlen, head, tail); 459 syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x", 460 apip, cepid, rcount, 461 (uint16_t)rlen, * tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer, 462 *(tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer + rlen - 1)); 429 463 #endif /* of #ifdef SHOW_RCV_RANGE */ 430 464 … … 433 467 while (rlen > 0) { 434 468 scount ++; 435 if (( error = tcp_snd_dat(cepid, &buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {436 syslog(LOG_NOTICE, "[TES :%02dSND] error: %s",437 cepid, itron_strerror(error));469 if ((slen = tcp_snd_dat(cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, SND_TMO)) < 0) { 470 syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s", 471 apip, cepid, itron_strerror(slen)); 438 472 goto err_fin; 439 473 } 440 441 /* 送信完了まで待つ。*/442 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));443 444 if (nblk_slen < 0) {445 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",446 cepid, itron_strerror(nblk_slen));447 goto err_fin;448 }449 450 slen = nblk_slen;451 452 474 #ifdef SHOW_RCV_RANGE 453 syslog(LOG_NOTICE, "[TES :%02d SND] scount: %4d, len: %4d",454 cepid, scount,slen);475 syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u", 476 apip, cepid, scount, (uint16_t)slen); 455 477 #endif /* of #ifdef SHOW_RCV_RANGE */ 456 478 … … 463 485 #ifdef USE_TCP_SHT_CEP 464 486 if ((error = tcp_sht_cep(cepid)) != E_OK) 465 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error)); 487 syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s", 488 apip, cepid, itron_strerror(error)); 466 489 #endif /* of #ifdef USE_TCP_SHT_CEP */ 467 490 468 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) 469 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error)); 470 471 /* 開放が完了するまで待つ。*/ 472 syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY)); 491 if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK) 492 syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s", 493 apip, cepid, itron_strerror(error)); 473 494 474 495 syscall(get_tim(&now)); 475 syslog(LOG_NOTICE, "[TES:%02d FIN] finished: %6lu, snd: %4u, rcv: %4u, len: %lu", 476 cepid, now / SYSTIM_HZ, scount, rcount, total); 477 478 return error == E_WBLK ? E_OK : error; 479 } 480 481 #endif /* of #ifdef USE_COPYSAVE_API */ 482 483 #else /* of #ifdef USE_TCP_NON_BLOCKING */ 484 485 #ifdef USE_COPYSAVE_API 486 487 static ER 488 tcp_echo_srv (ID cepid, ID repid) 489 { 490 ER_UINT rblen, sblen; 491 SYSTIM now; 492 ER error; 493 uint32_t total; 494 uint16_t rlen, slen, soff, scount, rcount; 495 char *rbuf, *sbuf, head, tail; 496 497 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 498 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error)); 499 return error; 500 } 501 502 #ifdef USE_TCP_EXTENTIONS 503 if ((error = free_tcp_rep(repid, true)) != E_OK) 504 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error)); 505 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 506 507 scount = rcount = total = 0; 508 syscall(get_tim(&now)); 509 syslog(LOG_NOTICE, "[TES:%02d ACP] connected: %6lu, from: %s.%u", 510 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 511 while (true) { 512 if ((rblen = tcp_rcv_buf(cepid, (void**)&rbuf, RCV_TMO)) <= 0) { 513 if (rblen != E_OK) 514 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", 515 cepid, itron_strerror(rblen)); 516 break; 517 } 518 519 head = *rbuf; 520 tail = *(rbuf + rblen - 1); 521 rcount ++; 522 523 //syslog(LOG_NOTICE, "[TES:%02d RCV] len: %4d", cepid, (uint16_t)rblen); 524 #ifdef SHOW_RCV_RANGE 525 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x", 526 cepid, rcount, (uint16_t)rblen, head, tail); 527 #endif /* of #ifdef SHOW_RCV_RANGE */ 528 529 rlen = (uint16_t)rblen; 530 total += rblen; 531 soff = 0; 532 while (rlen > 0) { 533 534 if ((sblen = tcp_get_buf(cepid, (void**)&sbuf, SND_TMO)) < 0) { 535 syslog(LOG_NOTICE, "[TES:%02d GET] error: %s", 536 cepid, itron_strerror(sblen)); 537 goto err_fin; 538 } 539 540 //syslog(LOG_NOTICE, "[TES:%02d SND] len: %4d", cepid, (uint16_t)sblen); 541 scount ++; 542 slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen; 543 memcpy(sbuf, rbuf + soff, slen); 544 if ((error = tcp_snd_buf(cepid, slen)) != E_OK) { 545 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s", 546 cepid, itron_strerror(error)); 547 goto err_fin; 548 } 549 #ifdef SHOW_RCV_RANGE 550 syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, slen); 551 #endif /* of #ifdef SHOW_RCV_RANGE */ 552 553 rlen -= slen; 554 soff += slen; 555 } 556 557 if ((error = tcp_rel_buf(cepid, rblen)) < 0) { 558 syslog(LOG_NOTICE, "[TES:%02d REL] error: %s", cepid, itron_strerror(error)); 559 break; 560 } 561 } 562 err_fin: 563 564 #ifdef USE_TCP_SHT_CEP 565 if ((error = tcp_sht_cep(cepid)) != E_OK) 566 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error)); 567 #endif /* of #ifdef USE_TCP_SHT_CEP */ 568 569 if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK) 570 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error)); 571 572 syscall(get_tim(&now)); 573 syslog(LOG_NOTICE, "[TES:%02d FIN] finished: %6lu, snd: %4u, rcv: %4u, len: %lu", 574 cepid, now / SYSTIM_HZ, scount, rcount, total); 496 syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu", 497 apip, cepid, now / SYSTIM_HZ, total); 575 498 576 499 return error; 577 500 } 578 501 579 #else /* of #ifdef USE_COPYSAVE_API */580 581 /*582 * tcp_echo_srv -- TCP エコーサーバ583 */584 585 static ER586 tcp_echo_srv (ID cepid, ID repid)587 {588 ER_UINT rlen, slen;589 ER error = E_OK;590 SYSTIM now;591 uint32_t total;592 uint16_t soff, scount, rcount;593 594 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {595 syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));596 return error;597 }598 599 #ifdef USE_TCP_EXTENTIONS600 if ((error = free_tcp_rep(repid, true)) != E_OK)601 syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));602 #endif /* of #ifdef USE_TCP_EXTENTIONS */603 604 scount = rcount = total = 0;605 syscall(get_tim(&now));606 syslog(LOG_NOTICE, "[TES:%02d ACP] connected: %6lu, from: %s.%u",607 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);608 while (true) {609 if ((rlen = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {610 if (rlen != E_OK)611 syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",612 cepid, itron_strerror(rlen));613 break;614 }615 616 rcount ++;617 #ifdef SHOW_RCV_RANGE618 syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",619 cepid, rcount, (uint16_t)rlen, *buffer, *(buffer + rlen - 1));620 #endif /* of #ifdef SHOW_RCV_RANGE */621 622 total += rlen;623 soff = 0;624 while (rlen > 0) {625 scount ++;626 if ((slen = tcp_snd_dat(cepid, &buffer[soff], rlen, SND_TMO)) < 0) {627 syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",628 cepid, itron_strerror(slen));629 goto err_fin;630 }631 #ifdef SHOW_RCV_RANGE632 syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, (uint16_t)slen);633 #endif /* of #ifdef SHOW_RCV_RANGE */634 635 rlen -= slen;636 soff += slen;637 }638 }639 err_fin:640 641 #ifdef USE_TCP_SHT_CEP642 if ((error = tcp_sht_cep(cepid)) != E_OK)643 syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));644 #endif /* of #ifdef USE_TCP_SHT_CEP */645 646 if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)647 syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));648 649 syscall(get_tim(&now));650 syslog(LOG_NOTICE, "[TES:%02d FIN] finished: %6lu, snd: %4u, rcv: %4u, len: %lu",651 cepid, now / SYSTIM_HZ, scount, rcount, total);652 653 return error;654 }655 656 502 #endif /* of #ifdef USE_COPYSAVE_API */ 657 503 658 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 659 660 #ifdef USE_TCP_EXTENTIONS 661 662 /* 663 * get_tcp_rep -- TCP 受付口を獲得する。 664 */ 665 666 static ER 667 get_tcp_rep (ID *repid) 668 { 669 ID tskid; 670 T_TCP_CREP crep; 671 672 get_tid(&tskid); 673 674 crep.repatr = UINT_C(0); 675 crep.myaddr.portno = UINT_C(7); 676 677 #if defined(SUPPORT_INET4) 678 crep.myaddr.ipaddr = IPV4_ADDRANY; 679 #endif 680 681 #if defined(SUPPORT_INET6) 682 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 683 #endif 684 685 return alloc_tcp_rep(repid, tskid, &crep); 686 } 687 688 /* 689 * get_tcp_cep -- TCP 通信端点とを獲得する。 690 */ 691 692 static ER 693 get_tcp_cep (ID *cepid) 694 { 695 ID tskid; 696 T_TCP_CCEP ccep; 697 698 get_tid(&tskid); 699 700 ccep.cepatr = UINT_C(0); 701 ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE; 702 ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE; 703 704 #ifdef TCP_CFG_SWBUF_CSAVE 705 ccep.sbuf = NADR; 706 #else 707 ccep.sbuf = tcp_echo_srv_swbuf; 708 #endif 709 #ifdef TCP_CFG_RWBUF_CSAVE 710 ccep.rbuf = NADR; 711 #else 712 ccep.rbuf = tcp_echo_srv_rwbuf; 713 #endif 714 #ifdef USE_TCP_NON_BLOCKING 715 ccep.callback = (FP)callback_nblk_tcp_echo_srv; 716 #else 717 ccep.callback = NULL; 718 #endif 719 720 return alloc_tcp_cep(cepid, tskid, &ccep); 721 } 722 723 /* 724 * tcp_echo_srv_task -- TCP エコーサーバタスク 725 */ 726 727 void 728 tcp_echo_srv_task (intptr_t exinf) 729 { 730 ID tskid, cepid, repid; 731 ER error = E_OK; 732 733 syscall(get_tid(&tskid)); 734 syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid); 735 while (true) { 736 737 syscall(slp_tsk()); 738 if ((error = get_tcp_cep (&cepid)) != E_OK) { 739 syslog(LOG_NOTICE, "[TES:00 EXT] CEP create error: %s", itron_strerror(error)); 740 continue; 741 } 742 743 while (true) { 744 745 if ((error = get_tcp_rep (&repid)) != E_OK) { 746 syslog(LOG_NOTICE, "[TES:00 EXT] REP create error: %s", itron_strerror(error)); 747 break; 748 } 749 else if ((error = tcp_echo_srv(cepid, repid)) != E_OK) { 750 error = free_tcp_rep(repid, error != E_DLT); 751 break; 752 } 753 } 754 755 if ((error = free_tcp_cep(cepid)) != E_OK) 756 syslog(LOG_NOTICE, "[TES:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error)); 757 758 } 759 } 760 761 #else /* of #ifdef USE_TCP_EXTENTIONS */ 504 #endif /* of #ifndef USE_TCP_NON_BLOCKING */ 505 506 #ifndef USE_TCP_EXTENTIONS 762 507 763 508 /* … … 768 513 tcp_echo_srv_task(intptr_t exinf) 769 514 { 770 ID tskid ;515 ID tskid, cepid; 771 516 ER error; 517 uint_t six; 518 char apip; 519 520 six = INDEX_SRV_INFO((ID)exinf); 521 522 #if defined(SUPPORT_INET6) 523 524 #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) 525 526 if (six >= NUM_TCP4_ECHO_SRV_TASKS) 527 apip = API_PROTO_IPV6; 528 else 529 apip = API_PROTO_IPV4; 530 531 #else /* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */ 532 533 apip = API_PROTO_IPV6; 534 535 #endif /* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */ 536 537 #else /* of #if defined(SUPPORT_INET6) */ 538 539 apip = API_PROTO_IPV4; 540 541 #endif /* of #if defined(SUPPORT_INET6) */ 772 542 773 543 syscall(get_tid(&tskid)); 774 syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] started.", tskid, (ID)exinf); 544 cepid = tcp_echo_srv_info[six].cepid; 545 syslog(LOG_NOTICE, "[TCP%c ECHO SRV:%d,%d] started.", apip, tskid, cepid); 546 775 547 while (true) { 776 while ((error = tcp_echo_srv( (ID)exinf, TCP_ECHO_SRV_REPID)) == E_OK)548 while ((error = tcp_echo_srv(six, apip)) == E_OK) 777 549 ; 778 syslog(LOG_NOTICE, "[TES:%02d] goto sleep 60[s], error: %s", (ID)exinf, itron_strerror(error)); 779 tslp_tsk(60 * 1000); 550 syslog(LOG_NOTICE, "[TES%c:%02u TSK] sleep 60[s], error: %s", apip, cepid, itron_strerror(error)); 551 tslp_tsk(60 * 1000 * 1000); 552 syslog(LOG_NOTICE, "[TES%c:%02u TSK] resume.", apip, cepid); 780 553 } 781 554 } 782 555 783 #endif /* of #if def USE_TCP_EXTENTIONS */556 #endif /* of #ifndef USE_TCP_EXTENTIONS */ 784 557 785 558 #endif /* of #ifdef USE_TCP_ECHO_SRV1 */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 41 41 /* タスク */ 42 42 43 #ifdef USE_TCP_EXTENTIONS 44 45 CRE_TSK(TCP_ECHO_SRV_TASK, { 43 CRE_TSK(TCP_ECHO_SRV_TASK1, { 46 44 TA_HLNG | TA_ACT, 47 0,45 1, 48 46 tcp_echo_srv_task, 49 47 TCP_ECHO_SRV_MAIN_PRIORITY, … … 52 50 }); 53 51 54 #else /* of #ifdef USE_TCP_EXTENTIONS */55 56 CRE_TSK(TCP_ECHO_SRV_TASK, {57 TA_HLNG | TA_ACT,58 TCP_ECHO_SRV_CEPID1,59 tcp_echo_srv_task,60 TCP_ECHO_SRV_MAIN_PRIORITY,61 TCP_ECHO_SRV_STACK_SIZE,62 NULL63 });64 65 #endif /* of #ifdef USE_TCP_EXTENTIONS */66 67 52 #if NUM_TCP_ECHO_SRV_TASKS >= 2 68 53 69 54 CRE_TSK(TCP_ECHO_SRV_TASK2, { 70 55 TA_HLNG | TA_ACT, 71 TCP_ECHO_SRV_CEPID2,56 2, 72 57 tcp_echo_srv_task, 73 58 TCP_ECHO_SRV_MAIN_PRIORITY, … … 82 67 CRE_TSK(TCP_ECHO_SRV_TASK3, { 83 68 TA_HLNG | TA_ACT, 84 TCP_ECHO_SRV_CEPID3,69 3, 85 70 tcp_echo_srv_task, 86 71 TCP_ECHO_SRV_MAIN_PRIORITY, … … 95 80 CRE_TSK(TCP_ECHO_SRV_TASK4, { 96 81 TA_HLNG | TA_ACT, 97 TCP_ECHO_SRV_CEPID4,82 4, 98 83 tcp_echo_srv_task, 99 84 TCP_ECHO_SRV_MAIN_PRIORITY, … … 108 93 CRE_TSK(TCP_ECHO_SRV_TASK5, { 109 94 TA_HLNG | TA_ACT, 110 TCP_ECHO_SRV_CEPID5,95 5, 111 96 tcp_echo_srv_task, 112 97 TCP_ECHO_SRV_MAIN_PRIORITY, … … 121 106 CRE_TSK(TCP_ECHO_SRV_TASK6, { 122 107 TA_HLNG | TA_ACT, 123 TCP_ECHO_SRV_CEPID6,108 6, 124 109 tcp_echo_srv_task, 125 110 TCP_ECHO_SRV_MAIN_PRIORITY, … … 134 119 CRE_TSK(TCP_ECHO_SRV_TASK7, { 135 120 TA_HLNG | TA_ACT, 136 TCP_ECHO_SRV_CEPID7,121 7, 137 122 tcp_echo_srv_task, 138 123 TCP_ECHO_SRV_MAIN_PRIORITY, … … 147 132 CRE_TSK(TCP_ECHO_SRV_TASK8, { 148 133 TA_HLNG | TA_ACT, 149 TCP_ECHO_SRV_CEPID8,134 8, 150 135 tcp_echo_srv_task, 151 136 TCP_ECHO_SRV_MAIN_PRIORITY, … … 160 145 #ifdef USE_TCP_NON_BLOCKING 161 146 162 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY, { TA_TPRI, 0, 1 }); 147 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY1, { TA_TPRI, 0, 1 }); 148 149 #if NUM_TCP_ECHO_SRV_TASKS >= 2 150 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY2, { TA_TPRI, 0, 1 }); 151 #endif 152 #if NUM_TCP_ECHO_SRV_TASKS >= 3 153 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY3, { TA_TPRI, 0, 1 }); 154 #endif 155 #if NUM_TCP_ECHO_SRV_TASKS >= 4 156 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY4, { TA_TPRI, 0, 1 }); 157 #endif 158 #if NUM_TCP_ECHO_SRV_TASKS >= 5 159 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY5, { TA_TPRI, 0, 1 }); 160 #endif 161 #if NUM_TCP_ECHO_SRV_TASKS >= 6 162 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY6, { TA_TPRI, 0, 1 }); 163 #endif 164 #if NUM_TCP_ECHO_SRV_TASKS >= 7 165 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY7, { TA_TPRI, 0, 1 }); 166 #endif 167 #if NUM_TCP_ECHO_SRV_TASKS >= 8 168 CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY8, { TA_TPRI, 0, 1 }); 169 #endif 163 170 164 171 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 70 70 #include <netinet/in_itron.h> 71 71 #include <netinet/ip.h> 72 #include <netinet/ip6.h>73 72 #include <netinet/tcp.h> 74 73 75 74 #include <netapp/netapp.h> 76 75 #include <netapp/netapp_var.h> 77 #include <netapp/ echo.h>76 #include <netapp/tcp_echo_srv2.h> 78 77 79 78 #ifdef USE_TCP_ECHO_SRV2 … … 161 160 snd_error = 1; 162 161 ena_rcv = true; 163 syslog(LOG_NOTICE, "[TES:%02 d CBN] connected: %6ld, from: %s.%d",162 syslog(LOG_NOTICE, "[TES:%02u CBN] connect: %6lu, from: %s.%d", 164 163 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 165 164 } 166 165 else 167 syslog(LOG_NOTICE, "[TES:%02 dCBN] accept error: %s\n", cepid, itron_strerror(rcv_error));166 syslog(LOG_NOTICE, "[TES:%02u CBN] accept error: %s\n", cepid, itron_strerror(rcv_error)); 168 167 169 168 syscall(sig_sem(SEM_TCP_ECHO_SRV_RCV_READY)); … … 176 175 tail = *(sptr + slen - 1); 177 176 #ifdef SHOW_RCV_RANGE 178 syslog(LOG_NOTICE, "[TES:%02 d CBN] send len: %4d, data %02x -> %02x",177 syslog(LOG_NOTICE, "[TES:%02u CBN] send len: %4u, data %02x -> %02x", 179 178 cepid, (uint16_t)slen, head, tail); 180 179 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 205 204 } 206 205 else { 207 syslog(LOG_NOTICE, "[TES:%02 dCBN] send error = %s", cepid, itron_strerror(snd_error));206 syslog(LOG_NOTICE, "[TES:%02u CBN] send error = %s", cepid, itron_strerror(snd_error)); 208 207 sig_sem(SEM_TCP_ECHO_SRV_SND_READY); 209 208 } … … 216 215 tail = *(rptr + rlen - 1); 217 216 #ifdef SHOW_RCV_RANGE 218 syslog(LOG_NOTICE, "[TES:%02 d CBN] recv len: %4d, data %02x -> %02x",217 syslog(LOG_NOTICE, "[TES:%02u CBN] recv len: %4u, data %02x -> %02x", 219 218 cepid, (uint16_t)rlen, head, tail); 220 219 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 246 245 else { 247 246 if (rlen < 0) 248 syslog(LOG_NOTICE, "[TES:%02 dCBN] recv error = %s", cepid, itron_strerror(rcv_error));247 syslog(LOG_NOTICE, "[TES:%02u CBN] recv error = %s", cepid, itron_strerror(rcv_error)); 249 248 sig_sem(SEM_TCP_ECHO_SRV_RCV_READY); 250 249 } … … 254 253 snd_error = *(ER*)p_parblk; 255 254 if (snd_error != E_OK) 256 syslog(LOG_NOTICE, "[TES:%02 dCBN] close error = %s", cepid, itron_strerror(snd_error));257 258 syslog(LOG_NOTICE, "[TES:%02 d CBN] finished: %6ld, snd: %4d, rcv: %4d, len: %ld",255 syslog(LOG_NOTICE, "[TES:%02u CBN] close error = %s", cepid, itron_strerror(snd_error)); 256 257 syslog(LOG_NOTICE, "[TES:%02u CBN] finish: %6lu, snd: %4u, rcv: %4u, len: %ld", 259 258 cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total); 260 259 … … 283 282 284 283 if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) { 285 syslog(LOG_NOTICE, "[TES:%02 dRCV] sync error: %s", cepid, itron_strerror(error));284 syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error)); 286 285 return error; 287 286 } 288 287 289 288 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) { 290 syslog(LOG_NOTICE, "[TES:%02 dACP] accept error = %s", cepid, itron_strerror(error));289 syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error)); 291 290 return error; 292 291 } … … 300 299 301 300 #ifdef USE_TCP_EXTENTIONS 302 if ((error = free_tcp_rep(repid, true)) != E_OK) {303 syslog(LOG_NOTICE, "[TES:%02 dDEL] REP delete error: %s", cepid, itron_strerror(error));301 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 302 syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 304 303 return error; 305 304 } … … 318 317 /* 受信する。*/ 319 318 if ((error = tcp_rcv_dat(cepid, rptr, blen, TMO_NBLK)) != E_WBLK) { 320 syslog(LOG_NOTICE, "[TES:%02 dRCV] recv error = %s", cepid, itron_strerror(error));319 syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s", cepid, itron_strerror(error)); 321 320 break; 322 321 } … … 359 358 while (true) { 360 359 if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) { 361 syslog(LOG_NOTICE, "[TES:%02 dSND] sync error: %s",360 syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s", 362 361 cepid, itron_strerror(error)); 363 362 continue; … … 387 386 /* 送信する。*/ 388 387 if ((error = tcp_snd_dat(cepid, sptr, blen, TMO_NBLK)) != E_WBLK) { 389 syslog(LOG_NOTICE, "[TES:%02 dSND] send error = %s", cepid, itron_strerror(error));388 syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(error)); 390 389 break; 391 390 } … … 398 397 #ifdef USE_TCP_SHT_CEP 399 398 if ((error = tcp_sht_cep(cepid)) != E_OK) 400 syslog(LOG_NOTICE, "[TES:%02 dSND] shutdown error = %s", cepid, itron_strerror(error));399 syslog(LOG_NOTICE, "[TES:%02u SND] shutdown error = %s", cepid, itron_strerror(error)); 401 400 #endif /* of #ifdef USE_TCP_SHT_CEP */ 402 401 403 402 if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) { 404 syslog(LOG_NOTICE, "[TES:%02 dSND] close error = %s", cepid, itron_strerror(error));403 syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error)); 405 404 } 406 405 … … 426 425 427 426 if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) { 428 syslog(LOG_NOTICE, "[TES:%02 dRCV] sync error: %s", cepid, itron_strerror(error));427 syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error)); 429 428 return error; 430 429 } 431 430 432 431 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) { 433 syslog(LOG_NOTICE, "[TES:%02 dACP] accept error = %s", cepid, itron_strerror(error));432 syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error)); 434 433 return error; 435 434 } 436 435 437 436 #ifdef USE_TCP_EXTENTIONS 438 if ((error = free_tcp_rep(repid, true)) != E_OK) {439 syslog(LOG_NOTICE, "[TES:%02 dDEL] REP delete error: %s", cepid, itron_strerror(error));437 if ((error = FREE_TCP_REP(repid, true)) != E_OK) { 438 syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error)); 440 439 return error; 441 440 } … … 443 442 444 443 syscall(get_tim(&now)); 445 syslog(LOG_NOTICE, "[TES:%02 d ACP] connected: %6ld, from: %s.%d",444 syslog(LOG_NOTICE, "[TES:%02u ACP] connect: %6lu, from: %s.%d", 446 445 cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 447 446 sptr = rptr = buffer; … … 461 460 if ((rlen = tcp_rcv_dat(cepid, rptr, blen, TMO_FEVR)) <= 0) { 462 461 if (rlen < 0) 463 syslog(LOG_NOTICE, "[TES:%02 dRCV] recv error = %s",462 syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s", 464 463 cepid, itron_strerror(rlen)); 465 464 break; … … 468 467 tail = *(rptr + rlen - 1); 469 468 #ifdef SHOW_RCV_RANGE 470 syslog(LOG_NOTICE, "[TES:%02 d RCV] len: %4d, data %02x -> %02x",469 syslog(LOG_NOTICE, "[TES:%02u RCV] len: %4u, data %02x -> %02x", 471 470 cepid, (uint16_t)rlen, head, tail); 472 471 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 531 530 while (true) { 532 531 if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) { 533 syslog(LOG_NOTICE, "[TES:%02 dSND] sync error: %s",532 syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s", 534 533 cepid, itron_strerror(error)); 535 534 continue; … … 554 553 555 554 if ((slen = tcp_snd_dat(cepid, sptr, blen, TMO_FEVR)) <= 0) { 556 syslog(LOG_NOTICE, "[TES:%02 dSND] send error = %s", cepid, itron_strerror(slen));555 syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(slen)); 557 556 break; 558 557 } … … 561 560 tail = *(sptr + slen - 1); 562 561 #ifdef SHOW_RCV_RANGE 563 syslog(LOG_NOTICE, "[TES:%02 d SND] len: %4d, data %02x -> %02x",562 syslog(LOG_NOTICE, "[TES:%02u SND] len: %4u, data %02x -> %02x", 564 563 cepid, (uint16_t)slen, head, tail); 565 564 #endif /* of #ifdef SHOW_RCV_RANGE */ … … 602 601 #ifdef USE_TCP_SHT_CEP 603 602 if ((error = tcp_sht_cep(cepid)) != E_OK) 604 syslog(LOG_NOTICE, "[TES:%02 dSND] shtudown error = %s", cepid, itron_strerror(error));603 syslog(LOG_NOTICE, "[TES:%02u SND] shtudown error = %s", cepid, itron_strerror(error)); 605 604 #endif /* of #ifdef USE_TCP_SHT_CEP */ 606 605 607 606 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK) 608 syslog(LOG_NOTICE, "[TES:%02 dSND] close error = %s", cepid, itron_strerror(error));607 syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error)); 609 608 610 609 get_tim(&now); 611 syslog(LOG_NOTICE, "[TES:%02 d SND] finished: %6ld, snd: %4d, rcv: %4d, len: %ld",610 syslog(LOG_NOTICE, "[TES:%02u SND] finish: %6lu, snd: %4u, rcv: %4u, len: %ld", 612 611 cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total); 613 612 … … 646 645 #endif 647 646 648 return alloc_tcp_rep(repid, tskid, &crep);647 return ALLOC_TCP_REP(repid, tskid, &crep); 649 648 } 650 649 … … 681 680 #endif 682 681 683 return alloc_tcp_cep(cepid, tskid, &ccep);682 return ALLOC_TCP_CEP(cepid, tskid, &ccep); 684 683 } 685 684 … … 711 710 } 712 711 else if ((error = tcp_echo_srv_rcv(cepid, repid)) != E_OK) { 713 error = free_tcp_rep(repid, error != E_DLT);712 error = FREE_TCP_REP(repid, error != E_DLT); 714 713 break; 715 714 } … … 717 716 718 717 if ((error = free_tcp_cep(cepid)) != E_OK) 719 syslog(LOG_NOTICE, "[TES:%02 dEXT] CEP delete error: %s", cepid, itron_strerror(error));718 syslog(LOG_NOTICE, "[TES:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error)); 720 719 721 720 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dbg_cons.cfg
r321 r331 2 2 * TINET (UDP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 43 43 /* TCP 受付口 */ 44 44 45 #ifdef SUPPORT_INET6 46 47 #if NUM_VRID_TCP6_REPS >= 1 48 VRID_TCP6_REP (TCP6_RSV_REPID1); 49 #endif 50 51 #if NUM_VRID_TCP6_REPS >= 2 52 VRID_TCP6_REP (TCP6_RSV_REPID2); 53 #endif 54 55 #endif /* of #ifdef SUPPORT_INET6 */ 56 45 57 #ifdef SUPPORT_INET4 46 58 47 #if NUM_VRID_TCP _REPS >= 148 VRID_TCP_REP (TCP _RSV_REPID1);59 #if NUM_VRID_TCP4_REPS >= 1 60 VRID_TCP_REP (TCP4_RSV_REPID1); 49 61 #endif 50 62 51 #if NUM_VRID_TCP _REPS >= 252 VRID_TCP_REP (TCP _RSV_REPID2);63 #if NUM_VRID_TCP4_REPS >= 2 64 VRID_TCP_REP (TCP4_RSV_REPID2); 53 65 #endif 54 66 55 67 #endif /* of #ifdef SUPPORT_INET4 */ 56 68 69 /* TCP 通信端点 */ 70 57 71 #ifdef SUPPORT_INET6 58 72 59 #if NUM_VRID_TCP _REPS >= 160 VRID_TCP6_ REP (TCP_RSV_REPID1);73 #if NUM_VRID_TCP6_CEPS >= 1 74 VRID_TCP6_CEP (TCP6_RSV_CEPID1); 61 75 #endif 62 76 63 #if NUM_VRID_TCP_REPS >= 2 64 VRID_TCP6_REP (TCP_RSV_REPID2); 77 #if NUM_VRID_TCP6_CEPS >= 2 78 VRID_TCP6_CEP (TCP6_RSV_CEPID2); 79 #endif 80 81 #if NUM_VRID_TCP6_CEPS >= 3 82 VRID_TCP6_CEP (TCP6_RSV_CEPID3); 83 #endif 84 85 #if NUM_VRID_TCP6_CEPS >= 4 86 VRID_TCP6_CEP (TCP6_RSV_CEPID4); 65 87 #endif 66 88 67 89 #endif /* of #ifdef SUPPORT_INET6 */ 68 90 69 /* TCP 通信端点 */70 71 91 #ifdef SUPPORT_INET4 72 92 73 #if NUM_VRID_TCP _CEPS >= 174 VRID_TCP_CEP (TCP _RSV_CEPID1);93 #if NUM_VRID_TCP4_CEPS >= 1 94 VRID_TCP_CEP (TCP4_RSV_CEPID1); 75 95 #endif 76 96 77 #if NUM_VRID_TCP _CEPS >= 278 VRID_TCP_CEP (TCP _RSV_CEPID2);97 #if NUM_VRID_TCP4_CEPS >= 2 98 VRID_TCP_CEP (TCP4_RSV_CEPID2); 79 99 #endif 80 100 81 #if NUM_VRID_TCP _CEPS >= 382 VRID_TCP_CEP (TCP _RSV_CEPID3);101 #if NUM_VRID_TCP4_CEPS >= 3 102 VRID_TCP_CEP (TCP4_RSV_CEPID3); 83 103 #endif 84 104 85 #if NUM_VRID_TCP _CEPS >= 486 VRID_TCP_CEP (TCP _RSV_CEPID4);105 #if NUM_VRID_TCP4_CEPS >= 4 106 VRID_TCP_CEP (TCP4_RSV_CEPID4); 87 107 #endif 88 108 89 109 #endif /* of #ifdef SUPPORT_INET4 */ 90 91 #ifdef SUPPORT_INET692 93 #if NUM_VRID_TCP_CEPS >= 194 VRID_TCP6_CEP (TCP_RSV_CEPID1);95 #endif96 97 #if NUM_VRID_TCP_CEPS >= 298 VRID_TCP6_CEP (TCP_RSV_CEPID2);99 #endif100 101 #if NUM_VRID_TCP_CEPS >= 3102 VRID_TCP6_CEP (TCP_RSV_CEPID3);103 #endif104 105 #if NUM_VRID_TCP_CEPS >= 4106 VRID_TCP6_CEP (TCP_RSV_CEPID4);107 #endif108 109 #endif /* of #ifdef SUPPORT_INET6 */110 110 111 111 #endif /* of #ifdef USE_TCP_EXTENTIONS */ … … 115 115 /* UDP 通信端点 */ 116 116 117 #ifdef SUPPORT_INET6 118 119 #if NUM_VRID_UDP6_CEPS >= 1 120 VRID_UDP6_CEP (UDP6_RSV_CEPID1); 121 #endif 122 123 #if NUM_VRID_UDP6_CEPS >= 2 124 VRID_UDP6_CEP (UDP6_RSV_CEPID2); 125 #endif 126 127 #endif /* of #ifdef SUPPORT_INET6 */ 128 117 129 #ifdef SUPPORT_INET4 118 130 119 #if NUM_VRID_UDP _CEPS >= 1120 VRID_UDP_CEP (UDP _RSV_CEPID1);131 #if NUM_VRID_UDP4_CEPS >= 1 132 VRID_UDP_CEP (UDP4_RSV_CEPID1); 121 133 #endif 122 134 123 #if NUM_VRID_UDP _CEPS >= 2124 VRID_UDP_CEP (UDP _RSV_CEPID2);135 #if NUM_VRID_UDP4_CEPS >= 2 136 VRID_UDP_CEP (UDP4_RSV_CEPID2); 125 137 #endif 126 138 127 139 #endif /* of #ifdef SUPPORT_INET4 */ 128 140 129 #ifdef SUPPORT_INET6130 131 #if NUM_VRID_UDP_CEPS >= 1132 VRID_UDP6_CEP (UDP_RSV_CEPID1);133 #endif134 135 #if NUM_VRID_UDP_CEPS >= 2136 VRID_UDP6_CEP (UDP_RSV_CEPID2);137 #endif138 139 #endif /* of #ifdef SUPPORT_INET6 */140 141 141 #endif /* of #ifdef USE_UDP_EXTENTIONS */ 142 142 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_net_cons.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 41 41 /* TCP 受付口 */ 42 42 43 #ifdef SUPPORT_INET6 44 45 TCP6_CRE_REP (NET_CONS_REPID, { 46 0, 47 { IPV6_ADDRANY, 23 } 48 } ); 49 50 #else /* of #ifdef SUPPORT_INET6 */ 51 43 52 #ifdef SUPPORT_INET4 44 53 … … 50 59 #endif /* of #ifdef SUPPORT_INET4 */ 51 60 52 #ifdef SUPPORT_INET653 54 TCP6_CRE_REP (NET_CONS_REPID, {55 0,56 { IPV6_ADDRANY, 23 }57 } );58 59 61 #endif /* of #ifdef SUPPORT_INET6 */ 60 62 61 63 /* TCP 通信端点 */ 64 65 #ifdef SUPPORT_INET6 66 67 #ifdef TCP_CFG_SWBUF_CSAVE 68 69 TCP6_CRE_CEP (NET_CONS_CEPID, { 70 0, 71 NADR, 72 NET_CONS_SWBUF_SIZE, 73 NADR, 74 NET_CONS_RWBUF_SIZE, 75 callback_nblk_net_cons 76 } ); 77 78 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE */ 79 80 TCP6_CRE_CEP (NET_CONS_CEPID, { 81 0, 82 net_cons_swbuf, 83 NET_CONS_SWBUF_SIZE, 84 net_cons_rwbuf, 85 NET_CONS_RWBUF_SIZE, 86 callback_nblk_net_cons 87 } ); 88 89 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */ 90 91 #else /* of #ifdef SUPPORT_INET6 */ 62 92 63 93 #ifdef SUPPORT_INET4 … … 89 119 #endif /* of #ifdef SUPPORT_INET4 */ 90 120 91 #ifdef SUPPORT_INET692 93 #ifdef TCP_CFG_SWBUF_CSAVE94 95 TCP6_CRE_CEP (NET_CONS_CEPID, {96 0,97 NADR,98 NET_CONS_SWBUF_SIZE,99 NADR,100 NET_CONS_RWBUF_SIZE,101 callback_nblk_net_cons102 } );103 104 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE */105 106 TCP6_CRE_CEP (NET_CONS_CEPID, {107 0,108 net_cons_swbuf,109 NET_CONS_SWBUF_SIZE,110 net_cons_rwbuf,111 NET_CONS_RWBUF_SIZE,112 callback_nblk_net_cons113 } );114 115 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */116 117 121 #endif /* of #ifdef SUPPORT_INET6 */ 118 122 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_cli.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 43 43 /* TCP 通信端点 */ 44 44 45 #ifdef SUPPORT_INET6 46 47 #ifdef USE_TCP_NON_BLOCKING 48 49 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY 50 51 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 52 TA_NULL, 53 NADR, 54 TCP_DISCARD_CLI_SWBUF_SIZE, 55 NADR, 56 0, 57 callback_nblk_tcp_discard_cli 58 } ); 59 60 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */ 61 62 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 63 TA_NULL, 64 tcp_discard_cli_swbuf, 65 TCP_DISCARD_CLI_SWBUF_SIZE, 66 NADR, 67 0, 68 callback_nblk_tcp_discard_cli 69 } ); 70 71 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */ 72 73 #else /* of #ifdef USE_TCP_NON_BLOCKING */ 74 75 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY 76 77 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 78 TA_NULL, 79 NADR, 80 TCP_DISCARD_CLI_SWBUF_SIZE, 81 NADR, 82 0, 83 NULL 84 } ); 85 86 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */ 87 88 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 89 TA_NULL, 90 tcp_discard_cli_swbuf, 91 TCP_DISCARD_CLI_SWBUF_SIZE, 92 NADR, 93 0, 94 NULL 95 } ); 96 97 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */ 98 99 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 100 101 #else /* of #ifdef SUPPORT_INET6 */ 102 45 103 #ifdef SUPPORT_INET4 46 104 … … 50 108 51 109 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 52 0,110 TA_NULL, 53 111 NADR, 54 112 TCP_DISCARD_CLI_SWBUF_SIZE, … … 61 119 62 120 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 63 0,121 TA_NULL, 64 122 tcp_discard_cli_swbuf, 65 123 TCP_DISCARD_CLI_SWBUF_SIZE, … … 76 134 77 135 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 78 0,136 TA_NULL, 79 137 NADR, 80 138 TCP_DISCARD_CLI_SWBUF_SIZE, … … 87 145 88 146 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, { 89 0,147 TA_NULL, 90 148 tcp_discard_cli_swbuf, 91 149 TCP_DISCARD_CLI_SWBUF_SIZE, … … 101 159 #endif /* of #ifdef SUPPORT_INET4 */ 102 160 103 #ifdef SUPPORT_INET6104 105 #ifdef USE_TCP_NON_BLOCKING106 107 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY108 109 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {110 0,111 NADR,112 TCP_DISCARD_CLI_SWBUF_SIZE,113 NADR,114 0,115 callback_nblk_tcp_discard_cli116 } );117 118 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */119 120 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {121 0,122 tcp_discard_cli_swbuf,123 TCP_DISCARD_CLI_SWBUF_SIZE,124 NADR,125 0,126 callback_nblk_tcp_discard_cli127 } );128 129 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */130 131 #else /* of #ifdef USE_TCP_NON_BLOCKING */132 133 #ifdef TCP_CFG_SWBUF_CSAVE_ONLY134 135 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {136 0,137 NADR,138 TCP_DISCARD_CLI_SWBUF_SIZE,139 NADR,140 0,141 NULL142 } );143 144 #else /* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */145 146 TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {147 0,148 tcp_discard_cli_swbuf,149 TCP_DISCARD_CLI_SWBUF_SIZE,150 NADR,151 0,152 NULL153 } );154 155 #endif /* of #ifdef TCP_CFG_SWBUF_CSAVE */156 157 #endif /* of #ifdef USE_TCP_NON_BLOCKING */158 159 161 #endif /* of #ifdef SUPPORT_INET6 */ 160 162 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_srv.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 42 42 /* TCP 受付口 */ 43 43 44 #ifdef SUPPORT_INET6 45 46 TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, { 47 TA_NULL, 48 { IPV6_ADDRANY, 9 } 49 } ); 50 51 #else /* of #ifdef SUPPORT_INET6 */ 52 44 53 #ifdef SUPPORT_INET4 45 54 46 55 TCP_CRE_REP (TCP_DISCARD_SRV_REPID, { 47 0,56 TA_NULL, 48 57 { IPV4_ADDRANY, 9 } 49 58 } ); … … 51 60 #endif /* of #ifdef SUPPORT_INET4 */ 52 61 53 #ifdef SUPPORT_INET654 55 TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {56 0,57 { IPV6_ADDRANY, 9 }58 } );59 60 62 #endif /* of #ifdef SUPPORT_INET6 */ 61 63 62 64 /* TCP 通信端点 */ 65 66 #ifdef SUPPORT_INET6 67 68 #ifdef TCP_CFG_RWBUF_CSAVE_ONLY 69 70 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, { 71 TA_NULL, 72 NADR, 73 0, 74 NADR, 75 TCP_DISCARD_SRV_RWBUF_SIZE, 76 NULL 77 } ); 78 79 #else /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */ 80 81 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, { 82 TA_NULL, 83 NADR, 84 0, 85 tcp_discard_srv_rwbuf, 86 TCP_DISCARD_SRV_RWBUF_SIZE, 87 NULL 88 } ); 89 90 #endif /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */ 91 92 #else /* of #ifdef SUPPORT_INET6 */ 63 93 64 94 #ifdef SUPPORT_INET4 … … 67 97 68 98 TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, { 69 0,99 TA_NULL, 70 100 NADR, 71 101 0, … … 78 108 79 109 TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, { 80 0,110 TA_NULL, 81 111 NADR, 82 112 0, … … 90 120 #endif /* of #ifdef SUPPORT_INET4 */ 91 121 92 #ifdef SUPPORT_INET693 94 #ifdef TCP_CFG_RWBUF_CSAVE_ONLY95 96 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {97 0,98 NADR,99 0,100 NADR,101 TCP_DISCARD_SRV_RWBUF_SIZE,102 NULL103 } );104 105 #else /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */106 107 TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {108 0,109 NADR,110 0,111 tcp_discard_srv_rwbuf,112 TCP_DISCARD_SRV_RWBUF_SIZE,113 NULL114 } );115 116 #endif /* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */117 118 122 #endif /* of #ifdef SUPPORT_INET6 */ 119 123 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_cli.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 43 43 /* TCP 通信端点 */ 44 44 45 #ifdef SUPPORT_INET6 46 47 #ifdef USE_TCP_NON_BLOCKING 48 49 #if defined(TCP_CFG_SWBUF_CSAVE) 50 51 #if defined(TCP_CFG_RWBUF_CSAVE) 52 53 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 54 0, 55 NADR, 56 TCP_ECHO_CLI_SWBUF_SIZE, 57 NADR, 58 TCP_ECHO_CLI_RWBUF_SIZE, 59 callback_nblk_tcp_echo_cli 60 } ); 61 62 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 63 64 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 65 0, 66 NADR, 67 TCP_ECHO_CLI_SWBUF_SIZE, 68 tcp_echo_cli_rwbuf, 69 TCP_ECHO_CLI_RWBUF_SIZE, 70 callback_nblk_tcp_echo_cli 71 } ); 72 73 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 74 75 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 76 77 #if defined(TCP_CFG_RWBUF_CSAVE) 78 79 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 80 0, 81 tcp_echo_cli_swbuf, 82 TCP_ECHO_CLI_SWBUF_SIZE, 83 NADR, 84 TCP_ECHO_CLI_RWBUF_SIZE, 85 callback_nblk_tcp_echo_cli 86 } ); 87 88 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 89 90 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 91 0, 92 tcp_echo_cli_swbuf, 93 TCP_ECHO_CLI_SWBUF_SIZE, 94 tcp_echo_cli_rwbuf, 95 TCP_ECHO_CLI_RWBUF_SIZE, 96 callback_nblk_tcp_echo_cli 97 } ); 98 99 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 100 101 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 102 103 #else /* of #ifdef USE_TCP_NON_BLOCKING */ 104 105 #if defined(TCP_CFG_SWBUF_CSAVE) 106 107 #if defined(TCP_CFG_RWBUF_CSAVE) 108 109 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 110 0, 111 NADR, 112 TCP_ECHO_CLI_SWBUF_SIZE, 113 NADR, 114 TCP_ECHO_CLI_RWBUF_SIZE, 115 NULL 116 } ); 117 118 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 119 120 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 121 0, 122 NADR, 123 TCP_ECHO_CLI_SWBUF_SIZE, 124 tcp_echo_cli_rwbuf, 125 TCP_ECHO_CLI_RWBUF_SIZE, 126 NULL 127 } ); 128 129 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 130 131 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 132 133 #if defined(TCP_CFG_RWBUF_CSAVE) 134 135 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 136 0, 137 tcp_echo_cli_swbuf, 138 TCP_ECHO_CLI_SWBUF_SIZE, 139 NADR, 140 TCP_ECHO_CLI_RWBUF_SIZE, 141 NULL 142 } ); 143 144 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 145 146 TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, { 147 0, 148 tcp_echo_cli_swbuf, 149 TCP_ECHO_CLI_SWBUF_SIZE, 150 tcp_echo_cli_rwbuf, 151 TCP_ECHO_CLI_RWBUF_SIZE, 152 NULL 153 } ); 154 155 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 156 157 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 158 159 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 160 45 161 #ifdef SUPPORT_INET4 46 162 163 #ifdef USE_TCP4_ECHO_CLI 164 47 165 #ifdef USE_TCP_NON_BLOCKING 48 166 … … 51 169 #if defined(TCP_CFG_RWBUF_CSAVE) 52 170 53 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {54 0, 55 NADR, 56 TCP_ECHO_CLI_SWBUF_SIZE, 57 NADR, 58 TCP_ECHO_CLI_RWBUF_SIZE, 59 callback_nblk_tcp_echo_cli 60 } ); 61 62 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 63 64 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {65 0, 66 NADR, 67 TCP_ECHO_CLI_SWBUF_SIZE, 68 tcp_echo_cli_rwbuf, 69 TCP_ECHO_CLI_RWBUF_SIZE, 70 callback_nblk_tcp_echo_cli 71 } ); 72 73 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 74 75 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 76 77 #if defined(TCP_CFG_RWBUF_CSAVE) 78 79 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {80 0, 81 tcp_echo_cli_swbuf, 82 TCP_ECHO_CLI_SWBUF_SIZE, 83 NADR, 84 TCP_ECHO_CLI_RWBUF_SIZE, 85 callback_nblk_tcp_echo_cli 86 } ); 87 88 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 89 90 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {171 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 172 0, 173 NADR, 174 TCP_ECHO_CLI_SWBUF_SIZE, 175 NADR, 176 TCP_ECHO_CLI_RWBUF_SIZE, 177 callback_nblk_tcp_echo_cli 178 } ); 179 180 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 181 182 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 183 0, 184 NADR, 185 TCP_ECHO_CLI_SWBUF_SIZE, 186 tcp_echo_cli_rwbuf, 187 TCP_ECHO_CLI_RWBUF_SIZE, 188 callback_nblk_tcp_echo_cli 189 } ); 190 191 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 192 193 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 194 195 #if defined(TCP_CFG_RWBUF_CSAVE) 196 197 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 198 0, 199 tcp_echo_cli_swbuf, 200 TCP_ECHO_CLI_SWBUF_SIZE, 201 NADR, 202 TCP_ECHO_CLI_RWBUF_SIZE, 203 callback_nblk_tcp_echo_cli 204 } ); 205 206 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 207 208 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 91 209 0, 92 210 tcp_echo_cli_swbuf, … … 107 225 #if defined(TCP_CFG_RWBUF_CSAVE) 108 226 109 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {110 0, 111 NADR, 112 TCP_ECHO_CLI_SWBUF_SIZE, 113 NADR, 114 TCP_ECHO_CLI_RWBUF_SIZE, 115 NULL 116 } ); 117 118 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 119 120 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {121 0, 122 NADR, 123 TCP_ECHO_CLI_SWBUF_SIZE, 124 tcp_echo_cli_rwbuf, 125 TCP_ECHO_CLI_RWBUF_SIZE, 126 NULL 127 } ); 128 129 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 130 131 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 132 133 #if defined(TCP_CFG_RWBUF_CSAVE) 134 135 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {136 0, 137 tcp_echo_cli_swbuf, 138 TCP_ECHO_CLI_SWBUF_SIZE, 139 NADR, 140 TCP_ECHO_CLI_RWBUF_SIZE, 141 NULL 142 } ); 143 144 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 145 146 TCP_CRE_CEP (TCP _ECHO_CLI_CEPID, {227 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 228 0, 229 NADR, 230 TCP_ECHO_CLI_SWBUF_SIZE, 231 NADR, 232 TCP_ECHO_CLI_RWBUF_SIZE, 233 NULL 234 } ); 235 236 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 237 238 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 239 0, 240 NADR, 241 TCP_ECHO_CLI_SWBUF_SIZE, 242 tcp_echo_cli_rwbuf, 243 TCP_ECHO_CLI_RWBUF_SIZE, 244 NULL 245 } ); 246 247 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 248 249 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 250 251 #if defined(TCP_CFG_RWBUF_CSAVE) 252 253 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 254 0, 255 tcp_echo_cli_swbuf, 256 TCP_ECHO_CLI_SWBUF_SIZE, 257 NADR, 258 TCP_ECHO_CLI_RWBUF_SIZE, 259 NULL 260 } ); 261 262 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 263 264 TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, { 147 265 0, 148 266 tcp_echo_cli_swbuf, … … 159 277 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 160 278 279 #endif /* of #ifdef USE_TCP4_ECHO_CLI */ 280 161 281 #endif /* of #ifdef SUPPORT_INET4 */ 162 282 163 #ifdef SUPPORT_INET6 283 #else /* of #ifdef SUPPORT_INET6 */ 284 285 #ifdef SUPPORT_INET4 164 286 165 287 #ifdef USE_TCP_NON_BLOCKING … … 169 291 #if defined(TCP_CFG_RWBUF_CSAVE) 170 292 171 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {172 0, 173 NADR, 174 TCP_ECHO_CLI_SWBUF_SIZE, 175 NADR, 176 TCP_ECHO_CLI_RWBUF_SIZE, 177 callback_nblk_tcp_echo_cli 178 } ); 179 180 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 181 182 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {183 0, 184 NADR, 185 TCP_ECHO_CLI_SWBUF_SIZE, 186 tcp_echo_cli_rwbuf, 187 TCP_ECHO_CLI_RWBUF_SIZE, 188 callback_nblk_tcp_echo_cli 189 } ); 190 191 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 192 193 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 194 195 #if defined(TCP_CFG_RWBUF_CSAVE) 196 197 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {198 0, 199 tcp_echo_cli_swbuf, 200 TCP_ECHO_CLI_SWBUF_SIZE, 201 NADR, 202 TCP_ECHO_CLI_RWBUF_SIZE, 203 callback_nblk_tcp_echo_cli 204 } ); 205 206 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 207 208 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {293 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 294 0, 295 NADR, 296 TCP_ECHO_CLI_SWBUF_SIZE, 297 NADR, 298 TCP_ECHO_CLI_RWBUF_SIZE, 299 callback_nblk_tcp_echo_cli 300 } ); 301 302 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 303 304 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 305 0, 306 NADR, 307 TCP_ECHO_CLI_SWBUF_SIZE, 308 tcp_echo_cli_rwbuf, 309 TCP_ECHO_CLI_RWBUF_SIZE, 310 callback_nblk_tcp_echo_cli 311 } ); 312 313 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 314 315 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 316 317 #if defined(TCP_CFG_RWBUF_CSAVE) 318 319 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 320 0, 321 tcp_echo_cli_swbuf, 322 TCP_ECHO_CLI_SWBUF_SIZE, 323 NADR, 324 TCP_ECHO_CLI_RWBUF_SIZE, 325 callback_nblk_tcp_echo_cli 326 } ); 327 328 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 329 330 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 209 331 0, 210 332 tcp_echo_cli_swbuf, … … 225 347 #if defined(TCP_CFG_RWBUF_CSAVE) 226 348 227 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {228 0, 229 NADR, 230 TCP_ECHO_CLI_SWBUF_SIZE, 231 NADR, 232 TCP_ECHO_CLI_RWBUF_SIZE, 233 NULL 234 } ); 235 236 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 237 238 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {239 0, 240 NADR, 241 TCP_ECHO_CLI_SWBUF_SIZE, 242 tcp_echo_cli_rwbuf, 243 TCP_ECHO_CLI_RWBUF_SIZE, 244 NULL 245 } ); 246 247 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 248 249 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 250 251 #if defined(TCP_CFG_RWBUF_CSAVE) 252 253 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {254 0, 255 tcp_echo_cli_swbuf, 256 TCP_ECHO_CLI_SWBUF_SIZE, 257 NADR, 258 TCP_ECHO_CLI_RWBUF_SIZE, 259 NULL 260 } ); 261 262 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 263 264 TCP 6_CRE_CEP (TCP_ECHO_CLI_CEPID, {349 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 350 0, 351 NADR, 352 TCP_ECHO_CLI_SWBUF_SIZE, 353 NADR, 354 TCP_ECHO_CLI_RWBUF_SIZE, 355 NULL 356 } ); 357 358 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 359 360 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 361 0, 362 NADR, 363 TCP_ECHO_CLI_SWBUF_SIZE, 364 tcp_echo_cli_rwbuf, 365 TCP_ECHO_CLI_RWBUF_SIZE, 366 NULL 367 } ); 368 369 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 370 371 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 372 373 #if defined(TCP_CFG_RWBUF_CSAVE) 374 375 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 376 0, 377 tcp_echo_cli_swbuf, 378 TCP_ECHO_CLI_SWBUF_SIZE, 379 NADR, 380 TCP_ECHO_CLI_RWBUF_SIZE, 381 NULL 382 } ); 383 384 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 385 386 TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, { 265 387 0, 266 388 tcp_echo_cli_swbuf, … … 277 399 #endif /* of #ifdef USE_TCP_NON_BLOCKING */ 278 400 401 #endif /* of #ifdef SUPPORT_INET4 */ 402 279 403 #endif /* of #ifdef SUPPORT_INET6 */ 280 404 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_discard_cli.cfg
r321 r331 2 2 * TINET (UDP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 43 43 /* UDP 通信端点 */ 44 44 45 #ifdef SUPPORT_INET6 46 47 UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, { 48 0, 49 { IPV6_ADDRANY, UDP_PORTANY }, 50 NULL 51 } ); 52 53 #else /* of #ifdef SUPPORT_INET6 */ 54 45 55 #ifdef SUPPORT_INET4 46 56 … … 53 63 #endif /* of #ifdef SUPPORT_INET4 */ 54 64 55 #ifdef SUPPORT_INET656 57 UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, {58 0,59 { IPV6_ADDRANY, UDP_PORTANY },60 NULL61 } );62 63 65 #endif /* of #ifdef SUPPORT_INET6 */ 64 66 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_wwws.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 34 34 /* 35 35 * WWW サーバの TCP/IP コンフィギュレーションファイル 36 * 37 * SUPPORT_INET6 38 * SUPPORT_INET4 39 * USE_TCP_NON_BLOCKING: OFF 40 * USE_TCP_EXTENTIONS: OFF 41 * TCP 受付口 42 * TCP 通信端点 43 * 36 44 */ 37 45 38 #ifdef USE_WWW_SRV 39 40 #ifndef USE_TCP_EXTENTIONS 41 42 /* TCP 受付口 */ 43 44 #ifdef SUPPORT_INET4 46 #if defined(USE_WWW_SRV) 47 48 /* 49 * TCP 受付口 50 */ 51 52 #if defined(USE_TCP_EXTENTIONS) 53 54 #else /* of #if defined(USE_TCP_EXTENTIONS) */ 55 56 #if defined(SUPPORT_INET6) 57 58 TCP6_CRE_REP (WWW_SRV_REPID, { 59 0, 60 { IPV6_ADDRANY, 80 } 61 } ); 62 63 #if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 64 65 TCP_CRE_REP (WWW4_SRV_REPID, { 66 0, 67 { IPV4_ADDRANY, 80 } 68 } ); 69 70 #endif /* of #if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 71 72 #else /* of #if defined(SUPPORT_INET6 */ 73 74 #if defined(SUPPORT_INET4) 45 75 46 76 TCP_CRE_REP (WWW_SRV_REPID, { … … 49 79 } ); 50 80 51 #endif /* of #ifdef SUPPORT_INET4 */ 52 53 #ifdef SUPPORT_INET6 54 55 TCP6_CRE_REP (WWW_SRV_REPID, { 56 0, 57 { IPV6_ADDRANY, 80 } 58 } ); 59 60 #endif /* of #ifdef SUPPORT_INET6 */ 61 62 /* TCP 通信端点 */ 63 64 #ifdef SUPPORT_INET4 81 #endif /* of #if defined(SUPPORT_INET4 */ 82 83 #endif /* of #if defined(SUPPORT_INET6 */ 84 85 #endif /* of #if defined(USE_TCP_EXTENTIONS */ 86 87 /* 88 * TCP 通信端点 89 * 90 * 定義する TCP 通信端点(WWW?_CEPID1)の選択 91 * 92 * INET6 INET4 USE_TCP4 TCP6_CRE_CEP TCP_CRE_CEP 93 * ○ ○ ○ × WWW4 94 * ○ ○ × WWW × 95 * ○ × ○ WWW × 96 * ○ × × WWW × 97 * × ○ ○ × WWW 98 * × ○ × × WWW 99 * × × ○ × × 100 * × × × × × 101 * 102 */ 103 104 #if defined(USE_TCP_EXTENTIONS) 105 106 #else /* of #if defined(USE_TCP_EXTENTIONS */ 107 108 #if defined(SUPPORT_INET6) 109 110 #if defined(SUPPORT_INET4) 111 112 #if defined(USE_WWW4_SRV) 113 114 #if defined(TCP_CFG_SWBUF_CSAVE) 115 116 #if defined(TCP_CFG_RWBUF_CSAVE) 117 118 TCP_CRE_CEP (WWW4_SRV_CEPID1, { 119 0, 120 NADR, 121 WWW_SRV_SWBUF_SIZE, 122 NADR, 123 WWW_SRV_RWBUF_SIZE, 124 NULL 125 } ); 126 127 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 128 129 TCP_CRE_CEP (WWW4_SRV_CEPID1, { 130 0, 131 NADR, 132 WWW_SRV_SWBUF_SIZE, 133 www_srv_rwbuf[0], 134 WWW_SRV_RWBUF_SIZE, 135 NULL 136 } ); 137 138 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 139 140 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 141 142 #if defined(TCP_CFG_RWBUF_CSAVE) 143 144 TCP_CRE_CEP (WWW4_SRV_CEPID1, { 145 0, 146 www_srv_swbuf[0], 147 WWW_SRV_SWBUF_SIZE, 148 NADR, 149 WWW_SRV_RWBUF_SIZE, 150 NULL 151 } ); 152 153 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 154 155 TCP_CRE_CEP (WWW4_SRV_CEPID1, { 156 0, 157 www_srv_swbuf[0], 158 WWW_SRV_SWBUF_SIZE, 159 www_srv_rwbuf[0], 160 WWW_SRV_RWBUF_SIZE, 161 NULL 162 } ); 163 164 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 165 166 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 167 168 #else /* of #if defined(USE_WWW4_SRV) */ 169 170 #if defined(TCP_CFG_SWBUF_CSAVE) 171 172 #if defined(TCP_CFG_RWBUF_CSAVE) 173 174 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 175 0, 176 NADR, 177 WWW_SRV_SWBUF_SIZE, 178 NADR, 179 WWW_SRV_RWBUF_SIZE, 180 NULL 181 } ); 182 183 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 184 185 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 186 0, 187 NADR, 188 WWW_SRV_SWBUF_SIZE, 189 www_srv_rwbuf[0], 190 WWW_SRV_RWBUF_SIZE, 191 NULL 192 } ); 193 194 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 195 196 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 197 198 #if defined(TCP_CFG_RWBUF_CSAVE) 199 200 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 201 0, 202 www_srv_swbuf[0], 203 WWW_SRV_SWBUF_SIZE, 204 NADR, 205 WWW_SRV_RWBUF_SIZE, 206 NULL 207 } ); 208 209 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 210 211 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 212 0, 213 www_srv_swbuf[0], 214 WWW_SRV_SWBUF_SIZE, 215 www_srv_rwbuf[0], 216 WWW_SRV_RWBUF_SIZE, 217 NULL 218 } ); 219 220 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 221 222 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 223 224 #endif /* of #if defined(USE_WWW4_SRV) */ 225 226 #else /* of #if defined(SUPPORT_INET4 */ 227 228 #if defined(TCP_CFG_SWBUF_CSAVE) 229 230 #if defined(TCP_CFG_RWBUF_CSAVE) 231 232 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 233 0, 234 NADR, 235 WWW_SRV_SWBUF_SIZE, 236 NADR, 237 WWW_SRV_RWBUF_SIZE, 238 NULL 239 } ); 240 241 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 242 243 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 244 0, 245 NADR, 246 WWW_SRV_SWBUF_SIZE, 247 www_srv_rwbuf[0], 248 WWW_SRV_RWBUF_SIZE, 249 NULL 250 } ); 251 252 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 253 254 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 255 256 #if defined(TCP_CFG_RWBUF_CSAVE) 257 258 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 259 0, 260 www_srv_swbuf[0], 261 WWW_SRV_SWBUF_SIZE, 262 NADR, 263 WWW_SRV_RWBUF_SIZE, 264 NULL 265 } ); 266 267 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 268 269 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 270 0, 271 www_srv_swbuf[0], 272 WWW_SRV_SWBUF_SIZE, 273 www_srv_rwbuf[0], 274 WWW_SRV_RWBUF_SIZE, 275 NULL 276 } ); 277 278 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 279 280 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 281 282 #endif /* of #if defined(SUPPORT_INET4 */ 283 284 #if NUM_WWW_SRV_TASKS >= 2 285 286 #if defined(TCP_CFG_SWBUF_CSAVE) 287 288 #if defined(TCP_CFG_RWBUF_CSAVE) 289 290 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 291 0, 292 NADR, 293 WWW_SRV_SWBUF_SIZE, 294 NADR, 295 WWW_SRV_RWBUF_SIZE, 296 NULL 297 } ); 298 299 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 300 301 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 302 0, 303 NADR, 304 WWW_SRV_SWBUF_SIZE, 305 www_srv_rwbuf[1], 306 WWW_SRV_RWBUF_SIZE, 307 NULL 308 } ); 309 310 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 311 312 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 313 314 #if defined(TCP_CFG_RWBUF_CSAVE) 315 316 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 317 0, 318 www_srv_swbuf[1], 319 WWW_SRV_SWBUF_SIZE, 320 NADR, 321 WWW_SRV_RWBUF_SIZE, 322 NULL 323 } ); 324 325 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 326 327 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 328 0, 329 www_srv_swbuf[1], 330 WWW_SRV_SWBUF_SIZE, 331 www_srv_rwbuf[1], 332 WWW_SRV_RWBUF_SIZE, 333 NULL 334 } ); 335 336 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 337 338 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 339 340 #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */ 341 342 #elif defined(SUPPORT_INET4) /* of #if defined(SUPPORT_INET6) */ 65 343 66 344 #if defined(TCP_CFG_SWBUF_CSAVE) … … 176 454 #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */ 177 455 178 #endif /* of #ifdef SUPPORT_INET4 */ 179 180 #ifdef SUPPORT_INET6 181 182 #if defined(TCP_CFG_SWBUF_CSAVE) 183 184 #if defined(TCP_CFG_RWBUF_CSAVE) 185 186 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 187 0, 188 NADR, 189 WWW_SRV_SWBUF_SIZE, 190 NADR, 191 WWW_SRV_RWBUF_SIZE, 192 NULL 193 } ); 194 195 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 196 197 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 198 0, 199 NADR, 200 WWW_SRV_SWBUF_SIZE, 201 www_srv_rwbuf[0], 202 WWW_SRV_RWBUF_SIZE, 203 NULL 204 } ); 205 206 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 207 208 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 209 210 #if defined(TCP_CFG_RWBUF_CSAVE) 211 212 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 213 0, 214 www_srv_swbuf[0], 215 WWW_SRV_SWBUF_SIZE, 216 NADR, 217 WWW_SRV_RWBUF_SIZE, 218 NULL 219 } ); 220 221 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 222 223 TCP6_CRE_CEP (WWW_SRV_CEPID1, { 224 0, 225 www_srv_swbuf[0], 226 WWW_SRV_SWBUF_SIZE, 227 www_srv_rwbuf[0], 228 WWW_SRV_RWBUF_SIZE, 229 NULL 230 } ); 231 232 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 233 234 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 235 236 #if NUM_WWW_SRV_TASKS >= 2 237 238 #if defined(TCP_CFG_SWBUF_CSAVE) 239 240 #if defined(TCP_CFG_RWBUF_CSAVE) 241 242 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 243 0, 244 NADR, 245 WWW_SRV_SWBUF_SIZE, 246 NADR, 247 WWW_SRV_RWBUF_SIZE, 248 NULL 249 } ); 250 251 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 252 253 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 254 0, 255 NADR, 256 WWW_SRV_SWBUF_SIZE, 257 www_srv_rwbuf[1], 258 WWW_SRV_RWBUF_SIZE, 259 NULL 260 } ); 261 262 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 263 264 #else /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 265 266 #if defined(TCP_CFG_RWBUF_CSAVE) 267 268 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 269 0, 270 www_srv_swbuf[1], 271 WWW_SRV_SWBUF_SIZE, 272 NADR, 273 WWW_SRV_RWBUF_SIZE, 274 NULL 275 } ); 276 277 #else /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 278 279 TCP6_CRE_CEP (WWW_SRV_CEPID2, { 280 0, 281 www_srv_swbuf[1], 282 WWW_SRV_SWBUF_SIZE, 283 www_srv_rwbuf[1], 284 WWW_SRV_RWBUF_SIZE, 285 NULL 286 } ); 287 288 #endif /* of #if defined(TCP_CFG_RWBUF_CSAVE) */ 289 290 #endif /* of #if defined(TCP_CFG_SWBUF_CSAVE) */ 291 292 #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */ 293 294 #endif /* of #ifdef SUPPORT_INET6 */ 295 296 #endif /* of #ifndef USE_TCP_EXTENTIONS */ 297 298 #endif /* of #ifdef USE_WWW_SRV */ 456 #endif /* of #if defined(SUPPORT_INET6) */ 457 458 #endif /* of #if defined(USE_TCP_EXTENTIONS) */ 459 460 #endif /* of #if defined(USE_WWW_SRV) */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 56 56 #endif /* of #ifdef TARGET_KERNEL_JSP */ 57 57 58 #include <tinet_defs.h>59 #include <tinet_config.h>60 61 #include <net/if.h>62 #include <net/if_ppp.h>63 #include <net/if_loop.h>64 #include <net/ethernet.h>65 #include <net/net.h>66 #include <net/net_var.h>67 #include <net/net_timer.h>68 69 58 #include <netinet/in.h> 59 #include <netinet/in_itron.h> 70 60 #include <netinet/ip.h> 71 #include <netinet/ip6.h>72 61 #include <netinet/udp.h> 73 #include <netinet/udp_var.h>74 #include <netinet/in_itron.h>75 62 76 63 #include <netapp/netapp.h> 77 64 #include <netapp/netapp_var.h> 78 #include <netapp/ discard.h>65 #include <netapp/udp_discard_cli.h> 79 66 80 67 #ifdef USE_UDP_DISCARD_CLI … … 90 77 #define PAT_BEGIN ' ' 91 78 #define PAT_END '~' 79 80 #if defined(SUPPORT_INET6) 81 #define API_PROTO '6' 82 #else 83 #define API_PROTO '4' 84 #endif 92 85 93 86 /* … … 104 97 send_udp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno) 105 98 { 106 static char smsg[IF_MTU - IP_UDP_HDR_SIZE]; 99 #if defined(SUPPORT_INET6) 100 static char smsg[IPV6_MMTU - (IP6_HDR_SIZE + UDP_HDR_SIZE)]; 101 #else 102 static char smsg[IP4_MSS - (IP4_HDR_SIZE + UDP_HDR_SIZE)]; 103 #endif 107 104 108 105 T_IPEP dst; … … 117 114 118 115 p = smsg; 119 for (slen = IF_MTU - IP_UDP_HDR_SIZE; slen > 0; )116 for (slen = sizeof(smsg); slen > 0; ) 120 117 for (pat = PAT_BEGIN; slen > 0 && pat <= PAT_END; pat ++, slen --) 121 118 *p ++ = pat; 122 119 123 120 get_tim(&time); 124 syslog(LOG_NOTICE, "[UDC :%02d SND] sending: %6ld, to: %s.%d",125 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);121 syslog(LOG_NOTICE, "[UDC%c:%02u SND] send: %7lu, to: %s.%d", 122 API_PROTO, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno); 126 123 127 124 scount = total = 0; 128 125 udp_discard_cli_valid = true; 129 for (slen = IF_MTU - IP_UDP_HDR_SIZE; udp_discard_cli_valid && slen > 0; slen --) {126 for (slen = sizeof(smsg); udp_discard_cli_valid && slen > 0; slen --) { 130 127 scount ++; 131 128 if ((len = UDP_SND_DAT(cepid, &dst, smsg, slen, TMO_FEVR)) < 0) { 132 syslog(LOG_NOTICE, "[UDC :%02d SND] send error: %s", cepid, itron_strerror(len));129 syslog(LOG_NOTICE, "[UDC%c:%02u SND] error: %s", API_PROTO, cepid, itron_strerror(len)); 133 130 return len; 134 131 } 135 132 else 136 syslog(LOG_NOTICE, "[UDC :%02d SND] send: %4d, %4d", cepid, scount, slen);133 syslog(LOG_NOTICE, "[UDC%c:%02u SND] send: %7lu, %4u", API_PROTO, cepid, scount, slen); 137 134 total += len; 138 dly_tsk(10 * SYSTIM_HZ + net _rand() % (10 * SYSTIM_HZ));135 dly_tsk(10 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ)); 139 136 } 140 137 141 138 get_tim(&time); 142 syslog(LOG_NOTICE, "[UDC :%02d SND] finished: %6ld, snd: %4d, len: %ld",143 cepid, time / SYSTIM_HZ, scount, total);139 syslog(LOG_NOTICE, "[UDC%c:%02u SND] finsh: %7lu, snd: %4u, len: %ld", 140 API_PROTO, cepid, time / SYSTIM_HZ, scount, total); 144 141 return E_OK; 145 142 } … … 158 155 int_t no; 159 156 uint16_t portno; 157 char apip; 160 158 161 159 #ifdef USE_UDP_EXTENTIONS 162 160 161 #if defined(SUPPORT_INET6) 162 T_UDP6_CCEP ccep; 163 #else 163 164 T_UDP_CCEP ccep; 165 #endif 164 166 165 167 #endif /* of #ifdef USE_UDP_EXTENTIONS */ 168 169 #if defined(SUPPORT_INET6) 170 apip = API_PROTO_IPV6; 171 #else 172 apip = API_PROTO_IPV4; 173 #endif 166 174 167 175 get_tid(&tskid); … … 171 179 line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line))); /* IP Address */ 172 180 181 if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) { 182 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] unknown host.", (ID)exinf); 183 continue; 184 } 185 173 186 if ('0' <= *line && *line <= '9') { /* Port No */ 174 187 line = get_int(&no, line); … … 186 199 ccep.myaddr.portno = UDP_PORTANY; 187 200 201 #if defined(SUPPORT_INET6) 202 203 memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 204 205 #else /* #if defined(SUPPORT_INET6) */ 206 188 207 #if defined(SUPPORT_INET4) 189 208 ccep.myaddr.ipaddr = IPV4_ADDRANY; 190 209 #endif 191 210 192 #if defined(SUPPORT_INET6) 193 memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 194 #endif 195 196 if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) { 197 syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error)); 211 #endif /* #if defined(SUPPORT_INET6) */ 212 213 if ((error = ALLOC_UDP_CEP(&cepid, tskid, &ccep)) != E_OK) { 214 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP create error: %s", API_PROTO, cepid, itron_strerror(error)); 198 215 continue; 199 216 } … … 206 223 207 224 if ((error = send_udp_discard(cepid, &addr, portno)) != E_OK) 208 syslog(LOG_NOTICE, "[UDC :%02d TSK] error: %s", cepid, itron_strerror(error));225 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error)); 209 226 210 227 #ifdef USE_UDP_EXTENTIONS 211 228 212 if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)213 syslog(LOG_NOTICE, "[UDC :%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));229 if ((error = FREE_UDP_CEP(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK) 230 syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP delete error: %s", API_PROTO, cepid, itron_strerror(error)); 214 231 215 232 #endif /* of #ifdef USE_UDP_EXTENTIONS */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 75 75 #include <net/ethernet.h> 76 76 #include <net/net.h> 77 #include <net/net_endian.h> 77 78 #include <net/net_buf.h> 78 #include <net/net_timer.h>79 79 #include <net/net_count.h> 80 80 81 81 #include <netinet/in.h> 82 82 #include <netinet/in_itron.h> 83 #include <netinet/ip.h> 84 #include <netinet/ip6.h> 85 #include <netinet/tcp.h> 86 83 84 #include <netapp/netapp.h> 87 85 #include <netapp/netapp_var.h> 88 86 #include <netapp/wwws.h> … … 118 116 #endif /* of #if NET_COUNT_ENABLE */ 119 117 118 #ifdef USE_TCP_EXTENTIONS 119 120 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 121 122 #if NUM_WWW_SRV_TASKS >= 2 /* 2 を超える個数は想定していない。 */ 123 124 #define WWW4_SRV_TASK WWW_SRV_TASK1 125 #define WWW6_SRV_TASK WWW_SRV_TASK2 126 127 #else /* of #if NUM_WWW_SRV_TASKS >= 2 */ 128 129 #define WWW4_SRV_TASK WWW_SRV_TASK1 130 #define WWW6_SRV_TASK WWW_SRV_TASK1 131 132 #endif /* of #if NUM_WWW_SRV_TASKS >= 2 */ 133 134 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 135 136 #define WWW4_SRV_TASK WWW_SRV_TASK1 137 #define WWW6_SRV_TASK WWW_SRV_TASK1 138 139 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 140 141 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 142 143 120 144 /* 121 145 * 全域変数 … … 161 185 #define ST_NOT_FOUND 1 162 186 187 /* 188 * 接続相手の情報構造体 189 */ 190 191 #ifdef NUM_WWW4_SRV_TASKS 192 #undef NUM_WWW4_SRV_TASKS 193 #endif 194 #define NUM_WWW4_SRV_TASKS 1 195 196 typedef struct t_www_srv_info { 197 ID cepid; /* 通信端点 ID */ 198 ID repid; /* 受付口 ID */ 199 T_IPEP dst; /* 接続相手アドレス情報 */ 200 } T_WWW_SRV_INFO; 201 202 #define INDEX_SRV_INFO(id) ((id)-1) 203 204 #ifdef USE_TCP_EXTENTIONS 205 206 static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS]; 207 /* 2 を超える個数は想定していない。 */ 208 209 #else /* of #ifdef USE_TCP_EXTENTIONS */ 210 211 static T_WWW_SRV_INFO www_srv_info[] = { 212 213 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 214 215 { WWW4_SRV_CEPID1, WWW4_SRV_REPID }, 216 217 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 218 219 { WWW_SRV_CEPID1, WWW_SRV_REPID }, 220 221 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 222 223 #if NUM_WWW_SRV_TASKS >= 2 /* 2 を超える個数は想定していない。 */ 224 { WWW_SRV_CEPID2, WWW_SRV_REPID }, 225 #endif 226 227 }; 228 229 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 230 163 231 #ifdef USE_COPYSAVE_API 164 232 … … 180 248 if (srbuf->rbuf.index >= srbuf->rbuf.len) { 181 249 if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK) 182 syslog(LOG_WARNING, "[WWW :%02d] tcp_rel_buf error: %s",250 syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s", 183 251 cepid, itron_strerror(error)); 184 252 srbuf->rbuf.index = 0; 185 253 if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) { 186 254 if (len < 0) 187 syslog(LOG_WARNING, "[WWW :%02d] tcp_rcv_buf error: %s",255 syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s", 188 256 cepid, itron_strerror(len)); 189 257 srbuf->rbuf.len = 0; … … 228 296 if (srbuf->sbuf.index >= srbuf->sbuf.len) 229 297 if ((error = flush_sbuf(cepid, srbuf)) != E_OK) { 230 syslog(LOG_WARNING, "[WWW :%02d] tcp_snd_daterror: %s", cepid, itron_strerror(error));298 syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error)); 231 299 return 0; 232 300 } … … 234 302 if (srbuf->sbuf.len == 0) { 235 303 if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) { 236 syslog(LOG_WARNING, "[WWW :%02d] tcp_get_buferror: %s", cepid, itron_strerror(srbuf->sbuf.len));304 syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len)); 237 305 return 0; 238 306 } … … 272 340 if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) { 273 341 if (len < 0) { 274 syslog(LOG_WARNING, "[WWW :%02d] tcp_rcv_daterror: %s",342 syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s", 275 343 cepid, itron_strerror(len)); 276 344 } … … 321 389 if (srbuf->sbuf.index >= srbuf->sbuf.len) 322 390 if ((error = flush_sbuf(cepid, srbuf)) != E_OK) { 323 syslog(LOG_WARNING, "[WWW :%02d] tcp_snd_daterror: %s", cepid, itron_strerror(error));391 syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error)); 324 392 return 0; 325 393 } … … 476 544 int_t ix; 477 545 478 for (ix = NUM_FILES; ix -- > 0; ) 546 for (ix = NUM_FILES; ix -- > 0; ) { 479 547 if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) { 548 //syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]); 480 549 return (*file[ix].func)(cepid, srbuf); 481 550 } 551 } 482 552 put_status(cepid, srbuf, ST_NOT_FOUND); 483 553 return E_NOEXS; … … 494 564 ER error = E_OK; 495 565 int_t blen = 0; 496 uint16_t len;497 566 498 567 if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) { 499 syslog(LOG_CRIT, "[WWW :%02d] get line error: %s.",568 syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.", 500 569 cepid, itron_strerror(error)); 501 570 return error; 502 571 } 503 572 504 if ( (len = get_line(cepid, method, srbuf)) == 0) {573 if (get_line(cepid, method, srbuf) == 0) { 505 574 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 506 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",575 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 507 576 cepid, itron_strerror(error)); 508 577 return error; … … 510 579 511 580 if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) { 512 syslog(LOG_CRIT, "[WWW :%02d] get line buffer error: %s.",581 syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.", 513 582 cepid, itron_strerror(error)); 514 583 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 515 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",584 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 516 585 cepid, itron_strerror(error)); 517 586 return error; 518 587 } 519 588 520 while ( (len = get_line(cepid, line, srbuf)) > 0) { /* ヘッダをスキップする。*/589 while (get_line(cepid, line, srbuf) > 0) { /* ヘッダをスキップする。*/ 521 590 split_fields(line, ": "); 522 591 if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0) 523 592 blen = atoi(&line->buf[line->off[1]]); 524 593 } 525 while (blen > 0 && (len = get_line(cepid, line, srbuf)) > 0) {594 while (blen > 0 && get_line(cepid, line, srbuf) > 0) { 526 595 /* エンティティ・ボディをスキップする。*/ 527 596 blen -= line->len; … … 529 598 530 599 if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK) 531 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",600 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 532 601 cepid, itron_strerror(error)); 533 602 … … 539 608 540 609 if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK) 541 syslog(LOG_WARNING, "[WWW :%02d] release line buffer error: %s.",610 syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.", 542 611 cepid, itron_strerror(error)); 543 612 … … 567 636 568 637 #ifdef TARGET_KERNEL_ASP 569 "ASP Kernel Release 1.3 (patchlevel = 2)for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"638 "ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n" 570 639 #endif 571 640 572 641 #ifdef TARGET_KERNEL_JSP 573 "JSP Kernel Release 1.4 (patchlevel = 3)for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"642 "JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n" 574 643 #endif 575 644 576 645 "TINET TCP/IP プロトコルスタックによりサービスしています。<br><hr>\r\n" 646 647 #if NET_COUNT_ENABLE 648 577 649 "<ul><li type=\"square\"><a href=\"stat.html\">ネットワーク統計情報</a></ul><hr>\r\n" 650 651 #else /* of #if NET_COUNT_ENABLE */ 652 653 "<ul><li type=\"square\">ネットワーク統計情報</ul><hr>\r\n" 654 655 #endif /* of #if NET_COUNT_ENABLE */ 656 578 657 "FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n" 579 658 "The Regents of the University of California. All rights reserved.<br><br>\r\n" … … 629 708 len += put_str(cepid, srbuf, response); 630 709 get_tim(&finish); 631 syslog(LOG_NOTICE, "[WWW :%02u] send:index.html, len: %4u, time: %lu [ms]",710 syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]", 632 711 cepid, len, (finish - start) * 1000 / SYSTIM_HZ); 633 712 return E_OK; … … 1530 1609 1531 1610 get_tim(&finish); 1532 syslog(LOG_NOTICE, "[WWW :%02u] send:stat.html, len: %4u, time: %lu [ms]",1611 syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html, len: %4u, time: %lu [ms]", 1533 1612 cepid, len, (finish - start) * 1000 / SYSTIM_HZ); 1534 1613 return E_OK; … … 1537 1616 #endif /* of #if NET_COUNT_ENABLE */ 1538 1617 1539 /*1540 * WWW サーバ1541 */1542 1543 static ER1544 www_srv (ID cepid, ID repid)1545 {1546 #if defined(SUPPORT_INET4)1547 1548 T_IPV4EP dst;1549 1550 #endif /* of #if defined(SUPPORT_INET4) */1551 1552 #if defined(SUPPORT_INET6)1553 1554 T_IPV6EP dst;1555 1556 #endif /* of #if defined(SUPPORT_INET6) */1557 1558 T_WWW_RWBUF *srbuf;1559 ER error;1560 SYSTIM time;1561 1562 if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {1563 syslog(LOG_WARNING, "[WWW:%02d] accept error: %s", cepid, itron_strerror(error));1564 return error;1565 }1566 1567 get_tim(&time);1568 syslog(LOG_NOTICE, "[WWW:%02u] connected: %6lu, from: %s.%u",1569 cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);1570 1571 if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {1572 syslog(LOG_CRIT, "[WWW:%02d] get buffer error: %s.", cepid, itron_strerror(error));1573 srbuf = NULL;1574 }1575 else {1576 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;1577 1578 #ifdef USE_COPYSAVE_API1579 1580 srbuf->sbuf.len = 0;1581 1582 #else /* of #ifdef USE_COPYSAVE_API */1583 1584 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);1585 1586 #endif /* of #ifdef USE_COPYSAVE_API */1587 1588 if ((error = parse_request(cepid, srbuf)) != E_OK)1589 syslog(LOG_WARNING, "[WWW:%02d] parse request error: %s",1590 cepid, itron_strerror(error));1591 }1592 1593 if ((error = tcp_sht_cep(cepid)) != E_OK)1594 syslog(LOG_WARNING, "[WWW:%02d] shutdown error: %s", cepid, itron_strerror(error));1595 1596 if (srbuf != NULL) {1597 while (get_char(cepid, srbuf) != EOF)1598 ;1599 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)1600 syslog(LOG_WARNING, "[WWW:%02d] release buffer error: %s.",1601 cepid, itron_strerror(error));1602 }1603 1604 if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)1605 syslog(LOG_WARNING, "[WWW:%02d] close error: %s", cepid, itron_strerror(error));1606 1607 get_tim(&time);1608 syslog(LOG_NOTICE, "[WWW:%02u] finished: %6lu", cepid, time / SYSTIM_HZ);1609 1610 return error;1611 }1612 1613 1618 #ifdef USE_TCP_EXTENTIONS 1614 1619 … … 1616 1621 * get_tcp_rep -- TCP 受付口を獲得する。 1617 1622 */ 1623 1624 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1618 1625 1619 1626 static ER … … 1621 1628 { 1622 1629 ID tskid; 1623 T_TCP_CREP crep; 1630 T_TCP6_CREP crep6; 1631 T_TCP_CREP crep4; 1632 1633 get_tid(&tskid); 1634 if (tskid == WWW4_SRV_TASK) { 1635 crep4.repatr = UINT_C(0); 1636 crep4.myaddr.portno = UINT_C(80); 1637 crep4.myaddr.ipaddr = IPV4_ADDRANY; 1638 return alloc_tcp4_rep(repid, tskid, &crep4); 1639 } 1640 else { 1641 crep6.repatr = UINT_C(0); 1642 crep6.myaddr.portno = UINT_C(80); 1643 memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1644 return alloc_tcp6_rep(repid, tskid, &crep6); 1645 } 1646 } 1647 1648 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1649 1650 static ER 1651 get_tcp_rep (ID *repid) 1652 { 1653 ID tskid; 1654 T_TCPN_CREP crep; 1624 1655 1625 1656 get_tid(&tskid); … … 1627 1658 crep.repatr = UINT_C(0); 1628 1659 crep.myaddr.portno = UINT_C(80); 1660 1661 #if defined(SUPPORT_INET6) 1662 1663 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1664 1665 #else /* #if defined(SUPPORT_INET6) */ 1629 1666 1630 1667 #if defined(SUPPORT_INET4) … … 1632 1669 #endif 1633 1670 1634 #if defined(SUPPORT_INET6) 1635 memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR)); 1636 #endif 1637 1638 1639 return alloc_tcp_rep(repid, tskid, &crep); 1640 } 1641 1642 /* 1643 * get_tcp_cep -- TCP 通信端点とを獲得する。 1671 #endif /* #if defined(SUPPORT_INET6) */ 1672 1673 return ALLOC_TCP_REP(repid, tskid, &crep); 1674 } 1675 1676 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1677 1678 /* 1679 * get_tcp_cep -- TCP 通信端点を獲得する。 1644 1680 */ 1645 1681 … … 1668 1704 #endif 1669 1705 1670 return alloc_tcp_cep(cepid, tskid, &ccep); 1671 } 1706 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1707 1708 if (tskid == WWW4_SRV_TASK) 1709 return alloc_tcp4_cep(cepid, tskid, &ccep); 1710 else 1711 return alloc_tcp6_cep(cepid, tskid, &ccep); 1712 1713 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1714 1715 return ALLOC_TCP_CEP(cepid, tskid, &ccep); 1716 1717 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1718 1719 } 1720 1721 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1722 1723 /* 1724 * tcp_passive_open -- 受動オープンを実行する。 1725 * 1726 * USE_TCP_NON_BLOCKING OFF 1727 */ 1728 1729 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1730 1731 static ER 1732 tcp_passive_open (T_WWW_SRV_INFO *info, char apip) 1733 { 1734 ER error = E_OK; 1735 T_IPV4EP dst4; 1736 1737 if (apip == API_PROTO_IPV6) { 1738 /* 受付口は IPv6 */ 1739 if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 1740 return error; 1741 1742 #ifdef USE_TCP_EXTENTIONS 1743 if ((error = free_tcp6_rep(info->repid, true)) != E_OK) 1744 return error; 1745 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1746 1747 } 1748 else { 1749 /* 受付口は IPv4 */ 1750 if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK) 1751 return error; 1752 in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr); 1753 info->dst.portno = dst4.portno; 1754 1755 #ifdef USE_TCP_EXTENTIONS 1756 if ((error = free_tcp4_rep(info->repid, true)) != E_OK) 1757 return error; 1758 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1759 } 1760 1761 return error; 1762 } 1763 1764 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1765 1766 static ER 1767 tcp_passive_open (T_WWW_SRV_INFO *info, char apip) 1768 { 1769 ER error = E_OK; 1770 1771 if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK) 1772 return error; 1773 1774 #ifdef USE_TCP_EXTENTIONS 1775 if ((error = FREE_TCP_REP(info->repid, true)) != E_OK) 1776 return error; 1777 #endif /* of #ifdef USE_TCP_EXTENTIONS */ 1778 1779 return error; 1780 } 1781 1782 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1783 1784 /* 1785 * WWW サーバ 1786 */ 1787 1788 static ER 1789 www_srv (uint_t six, char apip) 1790 { 1791 T_WWW_RWBUF *srbuf; 1792 ER error; 1793 SYSTIM now; 1794 1795 if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK) 1796 return error; 1797 1798 syscall(get_tim(&now)); 1799 1800 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 1801 1802 if (apip == API_PROTO_IPV6) 1803 syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct: %6lu,from: %s.%u", 1804 www_srv_info[six].cepid, now / SYSTIM_HZ, 1805 ipv62str(NULL, &www_srv_info[six].dst.ipaddr), 1806 www_srv_info[six].dst.portno); 1807 else 1808 syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct: %6lu,from: %s.%u", 1809 www_srv_info[six].cepid, now / SYSTIM_HZ, 1810 ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]), 1811 www_srv_info[six].dst.portno); 1812 1813 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1814 1815 syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct: %6lu,from: %s.%u", 1816 www_srv_info[six].cepid, now / SYSTIM_HZ, 1817 IP2STR(NULL, &www_srv_info[six].dst.ipaddr), 1818 www_srv_info[six].dst.portno); 1819 1820 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1821 1822 if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) { 1823 syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.", 1824 www_srv_info[six].cepid, itron_strerror(error)); 1825 srbuf = NULL; 1826 } 1827 else { 1828 srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0; 1829 1830 #ifdef USE_COPYSAVE_API 1831 1832 srbuf->sbuf.len = 0; 1833 1834 #else /* of #ifdef USE_COPYSAVE_API */ 1835 1836 srbuf->sbuf.len = sizeof(srbuf->sbuf.buf); 1837 1838 #endif /* of #ifdef USE_COPYSAVE_API */ 1839 1840 if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK) 1841 syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s", 1842 www_srv_info[six].cepid, itron_strerror(error)); 1843 } 1844 1845 if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK) 1846 syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s", 1847 www_srv_info[six].cepid, itron_strerror(error)); 1848 1849 if (srbuf != NULL) { 1850 while (get_char(www_srv_info[six].cepid, srbuf) != EOF) 1851 ; 1852 if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK) 1853 syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.", 1854 www_srv_info[six].cepid, itron_strerror(error)); 1855 } 1856 1857 if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK) 1858 syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s", 1859 www_srv_info[six].cepid, itron_strerror(error)); 1860 1861 get_tim(&now); 1862 syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh: %6lu", 1863 www_srv_info[six].cepid, now / SYSTIM_HZ); 1864 1865 return error; 1866 } 1867 1868 #ifdef USE_TCP_EXTENTIONS 1672 1869 1673 1870 /* … … 1678 1875 www_srv_task(intptr_t exinf) 1679 1876 { 1680 ID tskid , cepid, repid;1877 ID tskid; 1681 1878 ER error = E_OK; 1879 uint_t six; 1880 char apip; 1682 1881 1683 1882 syscall(get_tid(&tskid)); 1684 syslog(LOG_NOTICE, "[WWW:%d] started.", tskid); 1883 six = INDEX_SRV_INFO((ID)exinf); 1884 1885 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 1886 1887 if (six >= NUM_WWW4_SRV_TASKS) 1888 apip = API_PROTO_IPV6; 1889 else 1890 apip = API_PROTO_IPV4; 1891 1892 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1893 1894 apip = API_PROTO_IPVn; 1895 1896 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 1897 1898 syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid); 1685 1899 while (true) { 1686 1900 1687 1901 syscall(slp_tsk()); 1688 if ((error = get_tcp_cep (&cepid)) != E_OK) { 1689 syslog(LOG_NOTICE, "[WWW:00 EXT] CEP create error: %s", itron_strerror(error)); 1902 if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) { 1903 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s", 1904 apip, www_srv_info[six].cepid, itron_strerror(error)); 1690 1905 continue; 1691 1906 } 1692 1907 1693 if ((error = get_tcp_rep (&repid)) != E_OK) { 1694 syslog(LOG_NOTICE, "[WWW:00 EXT] REP create error: %s", itron_strerror(error)); 1695 free_tcp_cep(cepid); 1696 continue; 1697 } 1698 1699 while (true) 1700 if ((error = www_srv(cepid, repid)) != E_OK) { 1701 error = free_tcp_rep(repid, error != E_DLT); 1908 while (true) { 1909 1910 if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) { 1911 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s", 1912 apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error)); 1702 1913 break; 1703 1914 } 1704 1705 if ((error = free_tcp_cep(cepid)) != E_OK) 1706 syslog(LOG_NOTICE, "[WWW:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error)); 1707 1708 } 1915 else if ((error = www_srv(six, apip)) != E_OK) { 1916 1917 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1918 1919 if (tskid == WWW4_SRV_TASK) 1920 error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT); 1921 else 1922 error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT); 1923 1924 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1925 1926 error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT); 1927 1928 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1929 1930 if (error != E_OK) { 1931 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s", 1932 apip, www_srv_info[six].cepid, 1933 www_srv_info[six].repid, itron_strerror(error)); 1934 1935 } 1936 break; 1937 } 1938 } 1939 1940 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) 1941 1942 if (tskid == WWW4_SRV_TASK) { 1943 if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK) 1944 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1945 apip, www_srv_info[six].cepid, itron_strerror(error)); 1946 } 1947 else { 1948 if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK) 1949 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1950 apip, www_srv_info[six].cepid, itron_strerror(error)); 1951 } 1952 1953 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1954 1955 if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK) 1956 syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s", 1957 apip, www_srv_info[six].cepid, itron_strerror(error)); 1958 1959 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */ 1960 1961 } 1962 } 1963 1964 /* 1965 * wakeup_www_srv -- WWW サーバタスクの休止解除 1966 */ 1967 1968 ER 1969 wakeup_www_srv (char apip) 1970 { 1971 ID taskid; 1972 1973 if (apip == API_PROTO_IPV6) 1974 taskid = WWW6_SRV_TASK; 1975 else 1976 taskid = WWW4_SRV_TASK; 1977 syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid); 1978 return wup_tsk(taskid); 1709 1979 } 1710 1980 … … 1718 1988 www_srv_task(intptr_t exinf) 1719 1989 { 1720 ID tskid; 1990 ID tskid, cepid; 1991 uint_t six; 1992 char apip; 1721 1993 1722 1994 get_tim(&srv_start); 1723 1995 get_tid(&tskid); 1724 syslog(LOG_NOTICE, "[WWW:%d,%d] started.", tskid, (int_t)exinf); 1996 six = INDEX_SRV_INFO((ID)exinf); 1997 cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid; 1998 1999 #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) 2000 2001 if (six >= NUM_WWW4_SRV_TASKS) 2002 apip = API_PROTO_IPV6; 2003 else 2004 apip = API_PROTO_IPV4; 2005 2006 #else /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 2007 2008 apip = API_PROTO_IPVn; 2009 2010 #endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */ 2011 2012 syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid); 2013 1725 2014 while (true) { 1726 while (www_srv( (int_t)exinf, WWW_SRV_REPID) == E_OK)2015 while (www_srv(six, apip) == E_OK) 1727 2016 ; 1728 2017 } -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 40 40 /* タスク */ 41 41 42 #ifdef USE_TCP_EXTENTIONS43 44 42 CRE_TSK(WWW_SRV_TASK1, { 45 43 TA_HLNG | TA_ACT, 46 0,44 1, 47 45 www_srv_task, 48 46 WWW_SRV_MAIN_PRIORITY, … … 51 49 }); 52 50 53 #else /* of #ifdef USE_TCP_EXTENTIONS */54 55 CRE_TSK(WWW_SRV_TASK1, {56 TA_HLNG | TA_ACT,57 WWW_SRV_CEPID1,58 www_srv_task,59 WWW_SRV_MAIN_PRIORITY,60 WWW_SRV_STACK_SIZE,61 NULL62 });63 64 #endif /* of #ifdef USE_TCP_EXTENTIONS */65 66 51 #if NUM_WWW_SRV_TASKS >= 2 67 52 68 53 CRE_TSK(WWW_SRV_TASK2, { 69 54 TA_HLNG | TA_ACT, 70 WWW_SRV_CEPID2,55 2, 71 56 www_srv_task, 72 57 WWW_SRV_MAIN_PRIORITY, -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.h
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 39 39 */ 40 40 41 #include <tinet_defs.h>42 43 #include <net/if.h>44 #include <net/if_ppp.h>45 #include <net/if_loop.h>46 #include <net/ethernet.h>47 48 #include <netinet6/in6.h>49 #include <netinet/ip.h>50 #include <netinet/ip6.h>51 #include <netinet/tcp.h>52 53 41 #ifdef TOPPERS_S810_CLG3_85 54 42 #define WWW_SRV_STACK_SIZE 768 /* タスクのスタックサイズ */ … … 62 50 */ 63 51 64 #if defined( NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 052 #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) 65 53 66 #define WWW_SRV_SWBUF_SIZE ((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1) 67 68 #else /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */ 69 70 #if defined(SUPPORT_INET4) 71 #define WWW_SRV_SWBUF_SIZE (TCP_MSS) 54 #if defined(SUPPORT_INET6) 55 #define WWW_SRV_SWBUF_SIZE (1024) 56 #elif defined(SUPPORT_INET4) 57 #define WWW_SRV_SWBUF_SIZE (512) 72 58 #endif 73 59 74 #if defined(SUPPORT_INET6) 75 #define WWW_SRV_SWBUF_SIZE (TCP6_MSS) 76 #endif 60 #else /* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */ 77 61 78 # endif /* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */62 #define WWW_SRV_SWBUF_SIZE (2048) 79 63 80 #if defined(SUPPORT_INET4) 81 #define WWW_SRV_RWBUF_SIZE (TCP_MSS) 82 #endif 64 #endif /* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */ 83 65 84 66 #if defined(SUPPORT_INET6) 85 #define WWW_SRV_RWBUF_SIZE (TCP6_MSS) 67 #define WWW_SRV_RWBUF_SIZE (1024) 68 #elif defined(SUPPORT_INET4) 69 #define WWW_SRV_RWBUF_SIZE (512) 86 70 #endif 87 71 … … 89 73 #define WWW_LINE_SIZE 80 90 74 #define WWW_NUM_FIELDS 4 75 76 /* 77 * タスク数 78 */ 91 79 92 80 #ifndef _MACRO_ONLY … … 128 116 129 117 /* 130 * TCP 送受信バッファ118 * 変数 131 119 */ 120 121 /* TCP 送受信ウィンドバッファ */ 122 123 #ifdef NUM_WWW_SRV_TASKS 132 124 133 125 extern uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE]; 134 126 extern uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE]; 135 127 128 #endif /* of #ifdef NUM_WWW_SRV_TASKS */ 129 130 /* 131 * 関数 132 */ 133 134 extern ER wakeup_www_srv (char apip); 135 136 136 #endif /* of #ifndef _MACRO_ONLY */ 137 137 -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_asp.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 * … … 42 42 INCLUDE("netapp/wwws.cfg"); 43 43 44 #ifdef USE_WWW_SRV 45 44 46 /* 45 47 * 固定メモリプール … … 65 67 NULL 66 68 }); 69 70 #endif /* of #ifdef USE_WWW_SRV */ -
EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_jsp.cfg
r321 r331 2 2 * TINET (TCP/IP Protocol Stack) 3 3 * 4 * Copyright (C) 2001-20 09by Dep. of Computer Science and Engineering4 * Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering 5 5 * Tomakomai National College of Technology, JAPAN 6 6 *
Note:
See TracChangeset
for help on using the changeset viewer.