Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -58,23 +58,10 @@
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
 
-#include <tinet_defs.h>
-#include <tinet_config.h>
-
-#include <net/if.h>
-#include <net/if_ppp.h>
-#include <net/if_loop.h>
-#include <net/ethernet.h>
-#include <net/net.h>
-#include <net/net_timer.h>
-
 #include <netinet/in.h>
 #include <netinet/in_itron.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/tcp.h>
 
 #include <netapp/netapp.h>
 #include <netapp/netapp_var.h>
-#include <netapp/discard.h>
+#include <netapp/tcp_discard_srv.h>
 
 #ifdef USE_TCP_DISCARD_SRV
@@ -121,11 +108,11 @@
 
 	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_NOTICE, "[TDS:%02d ACP] accept error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u ACP] accept error: %s", cepid, itron_strerror(error));
 		return error;
 		}
 
 #ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK) {
-		syslog(LOG_NOTICE, "[TDS:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
 		return error;
 		}
@@ -134,5 +121,5 @@
 	count = total = 0;
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDS:%02d RCV] connected:  %6ld, from: %s.%d",
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
 	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 	while ((rlen = tcp_rcv_buf(cepid, (void*)&buf, TMO_FEVR)) > 0) {
@@ -140,5 +127,5 @@
 
 #ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
 		       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -150,5 +137,5 @@
 
 		if ((error = tcp_rel_buf(cepid, rlen)) != E_OK) {
-			syslog(LOG_NOTICE, "[TDS:%02d RCV] rel buf error: %s",
+			syslog(LOG_NOTICE, "[TDSn:%02u RCV] rel buf error: %s",
 			                    cepid, itron_strerror(error));
 			rlen = 0;
@@ -159,14 +146,14 @@
 
 	if (rlen != 0)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] recv buf error: %s", cepid, itron_strerror(rlen));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv buf error: %s", cepid, itron_strerror(rlen));
 
 	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] shutdown error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
 
 	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] close error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
 
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDS:%02d RCV] finished:   %6ld,            rcv: %4d, len: %ld",
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
 	                   cepid, time / SYSTIM_HZ, count, total);
 
@@ -190,11 +177,11 @@
 
 	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] accept error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] accept error: %s", cepid, itron_strerror(error));
 		return error;
 		}
 
 #ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK) {
-		syslog(LOG_NOTICE, "[TDS:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
 		return error;
 		}
@@ -203,5 +190,5 @@
 	count = total = 0;
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDS:%02d RCV] connected:  %6ld, from: %s.%d",
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
 	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 	while ((rlen = tcp_rcv_dat(cepid, buf, BUF_SIZE - 1, TMO_FEVR)) > 0) {
@@ -209,5 +196,5 @@
 
 #ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] count: %4d, len: %4d, data: %02x -> %02x",
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
 		       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -216,14 +203,14 @@
 		}
 	if (rlen != 0)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] recv error: %s", cepid, itron_strerror(rlen));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv error: %s", cepid, itron_strerror(rlen));
 
 	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] shutdown error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
 
 	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
-		syslog(LOG_NOTICE, "[TDS:%02d RCV] close error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
 
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDS:%02d RCV] finished:   %6ld,            rcv: %4d, len: %ld",
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
 	                   cepid, time / SYSTIM_HZ, count, total);
 
@@ -243,5 +230,5 @@
 {
 	ID		tskid;
-	T_TCP_CREP	crep;
+	T_TCPN_CREP	crep;
 
 	get_tid(&tskid);
@@ -250,13 +237,17 @@
 	crep.myaddr.portno = UINT_C(9);
 
+#if defined(SUPPORT_INET6)
+
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
 #if defined(SUPPORT_INET4)
 	crep.myaddr.ipaddr = IPV4_ADDRANY;
 #endif
 
-#if defined(SUPPORT_INET6)
-	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
-#endif
-
-	return alloc_tcp_rep(repid, tskid, &crep);
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
 	}
 
@@ -285,5 +276,5 @@
 #endif
 
-	return alloc_tcp_cep(cepid, tskid, &ccep);
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
 	}
 
@@ -299,10 +290,20 @@
 
 	syscall(get_tid(&tskid));
-	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid);
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d] started.", tskid);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d] started.", tskid);
+#endif
+#else
+	syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d] started.", tskid);
+#endif
+
 	while (true) {
 
 		syscall(slp_tsk());
 		if ((error = get_tcp_cep (&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TDS:00 EXT] CEP create error: %s", itron_strerror(error));
+			syslog(LOG_NOTICE, "[TDSn:00 EXT] CEP create error: %s", itron_strerror(error));
 			continue;
 			}
@@ -311,15 +312,15 @@
 
 			if ((error = get_tcp_rep (&repid)) != E_OK) {
-				syslog(LOG_NOTICE, "[TDS:00 EXT] REP create error: %s", itron_strerror(error));
+				syslog(LOG_NOTICE, "[TDSn:00 EXT] REP create error: %s", itron_strerror(error));
 				break;
 				}
 			else if ((error = tcp_discard_srv(cepid, repid)) != E_OK) {
-				error = free_tcp_rep(repid, error != E_DLT);
+				error = FREE_TCP_REP(repid, error != E_DLT);
 				break;
 				}
 			}
 
-		if ((error = free_tcp_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TDS:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TDSn:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
 
 		}
@@ -334,5 +335,15 @@
 
 	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#endif
+#else
+	syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#endif
+
 	while (true) {
 		while (tcp_discard_srv((ID)exinf, TCP_DISCARD_SRV_REPID) == E_OK)
