Index: EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.config
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.config	(revision 321)
+++ 	(revision )
@@ -1,179 +1,0 @@
-#
-#   TINET (TCP/IP Protocol Stack)
-#  
-#   Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
-#                    Tomakomai National College of Technology, JAPAN
-# 
-#   上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
-#   によって公表されている GNU General Public License の Version 2 に記
-#   述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
-#   を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
-#   利用と呼ぶ）することを無償で許諾する．
-#   (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
-#       権表示，この利用条件および下記の無保証規定が，そのままの形でソー
-#       スコード中に含まれていること．
-#   (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
-#       用できる形で再配布する場合には，再配布に伴うドキュメント（利用
-#       者マニュアルなど）に，上記の著作権表示，この利用条件および下記
-#       の無保証規定を掲載すること．
-#   (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
-#       用できない形で再配布する場合には，次の条件を満たすこと．
-#     (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
-#         作権表示，この利用条件および下記の無保証規定を掲載すること．
-#   (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
-#       害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
-# 
-#   本ソフトウェアは，無保証で提供されているものである．上記著作権者お
-#   よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
-#   含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
-#   接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
-#  
-#   @(#) $Id$
-#
-
-#
-#  「ソースファイルのディレクトリの定義」の後に追加する。
-#
-
-#
-#  TINET ソースファイルのディレクトリの定義
-#
-TINET_ROOT = $(SRCDIR)/tinet
-
-#
-#  TINET 1.1 との互換性のための定義
-#
-ifndef SUPPORT_INET4
-	ifndef SUPPORT_INET6
-		SUPPORT_INET4 = true
-	endif
-endif
-
-#
-#  ネットワークサービスに関する定義
-#
-TINET_DIR = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet
-
-TINET_COBJS := $(TINET_COBJS) \
-	       net_buf.o net_count.o net_subr.o net_timer.o \
-               in_subr.o tinet_cfg.o route_cfg.o
-
-ifeq ($(SUPPORT_INET4),true)
-
-	TINET_COBJS := $(TINET_COBJS) \
-	               ip_input.o ip_output.o ip_icmp.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
-
-endif
-
-ifeq ($(SUPPORT_INET6),true)
-
-	TINET_DIR := $(TINET_DIR):$(TINET_ROOT)/netinet6
-	TINET_COBJS := $(TINET_COBJS) \
-	               in6.o in6_ifattach.o nd6_rtr.o \
-	               in6_subr.o ip6_input.o icmp6.o \
-	               dest6.o route6.o frag6.o \
-	               ah_input.o esp_input.o \
-	               nd6.o nd6_nbr.o ip6_output.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
-
-endif
-
-ifeq ($(NET_IF),loop)
-
-	TINET_COBJS := $(TINET_COBJS) if_loop.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_LOOP
-
-endif
-
-ifeq ($(NET_IF),ppp)
-
-	TINET_COBJS := $(TINET_COBJS) \
-	               ppp.o ppp_hdlc.o ppp_lcp.o ppp_fsm.o \
-	               ppp_auth.o ppp_ipcp.o ppp_upap.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_PPP
-
-ifeq ($(PPP_CFG_MODEM),true)
-
-	TINET_COBJS := $(TINET_COBJS) ppp_modem.o 
-	TINET_CDEFS := $(TINET_CDEFS) -DPPP_CFG_MODEM
-
-endif
-
-endif
-
-ifeq ($(NET_IF),ether)
-
-	#  ターゲット依存の定義のインクルード
-
-	ifdef TOOL
-	    ifdef SYS
-	        -include $(SRCDIR)/config/$(CPU)-$(TOOL)/$(SYS)/Makefile.tinet
-	    endif
-	else
-	    ifdef SYS
-	        -include $(SRCDIR)/config/$(CPU)/$(SYS)/Makefile.tinet
-	    endif
-	endif
-
-	TINET_COBJS := $(TINET_COBJS) if.o ethernet.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_ETHER
-
-	ifeq ($(SUPPORT_INET4),true)
-
-		TINET_COBJS := $(TINET_COBJS) if_ether.o
-
-	endif
-
-	ifeq ($(SUPPORT_INET6),true)
-
-		TINET_COBJS := $(TINET_COBJS) if6_ether.o 
-
-	endif
-
-	include $(TINET_ROOT)/netdev/$(NET_DEV)/Makefile.tinet
-
-endif
-
-ifeq ($(SUPPORT_TCP),true)
-
-	TINET_COBJS := $(TINET_COBJS) \
-	               tcp_input.o tcp_output.o tcp_usrreq.o \
-	               tcp_subr.o tcp_timer.o tcp_subr_ncs.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_TCP
-
-endif
-
-ifeq ($(SUPPORT_UDP),true)
-
-	TINET_COBJS := $(TINET_COBJS) \
-	               udp_input.o udp_usrreq.o udp_output.o
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_UDP
-
-endif
-
-#
-#  共通コンパイルオプションの定義への追加
-#
-CDEFS := $(CDEFS) $(TINET_CDEFS)
-INCLUDES := $(INCLUDES) -I$(TINET_ROOT)
-
-#
-#  アプリケーションプログラムに関する定義への追加
-#
-TINET_UTASK_CFG = tinet_$(UNAME).cfg
-
-#
-#  システムサービスに関する定義への追加
-#
-STASK_DIR := $(STASK_DIR):$(TINET_DIR)
-STASK_COBJS := $(STASK_COBJS) $(TINET_COBJS)
-STASK_LIBS := $(STASK_LIBS) -lc
-
-#
-#  TINET コンフィギュレーションファイルの生成
-#
-tinet:
-	$(CC) -E $(INCLUDES) $(CDEFS) -x c-header $(TINET_UTASK_CFG) > tmpfile9
-	$(TINET_ROOT)/cfg/tinet_cfg -s tmpfile9
-	rm -f tmpfile9
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet	(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
 #   Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
@@ -63,34 +63,52 @@
 
 #
+#  TINET 1.7 以降は、ネットワーク層の指定を変更した。
+#
+
+ifeq ($(SUPPORT_INET6),true)
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
+endif
+
+ifeq ($(SUPPORT_INET4),true)
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
+endif
+
+ifeq ($API_CFG_IP4MAPPED_ADDR,true)
+	TINET_CDEFS := $(TINET_CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
+endif
+
+ifeq ($(SUPPORT_IGMP),true)
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_IGMP
+endif
+
+#
 #  ネットワークサービスに関する定義
 #
-TINET_DIR = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet
-
+
+#  汎用通信機能
+
+TINET_DIRS = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet:$(TINET_ROOT)/netinet6
 TINET_COBJS := $(TINET_COBJS) \
-	       net_buf.o net_count.o net_subr.o net_timer.o \
-               in_subr.o tinet_cfg.o route_cfg.o
-
-ifeq ($(SUPPORT_INET4),true)
-
-	TINET_COBJS := $(TINET_COBJS) \
-	               ip_input.o ip_output.o ip_icmp.o
-	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/ip.cfg
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
-
-endif
-
-ifeq ($(SUPPORT_INET6),true)
-
-	TINET_DIR := $(TINET_DIR):$(TINET_ROOT)/netinet6
-	TINET_COBJS := $(TINET_COBJS) \
-	               in6.o in6_ifattach.o nd6_rtr.o \
-	               in6_subr.o ip6_input.o icmp6.o \
-	               dest6.o route6.o frag6.o \
-	               ah_input.o esp_input.o \
-	               nd6.o nd6_nbr.o ip6_output.o scope6.o
-	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet6/ip6.cfg
-	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
-
-endif
+               net_buf.o net_count.o net_subr.o net_timer.o if.o \
+               in_subr.o route_cfg.o
+TINET_CFG_COBJS := $(TINET_CFG_COBJS) tinet_cfg.o
+
+#  IPv6
+
+TINET_COBJS := $(TINET_COBJS) \
+               in6.o in6_ifattach.o nd6_rtr.o \
+               in6_subr.o ip6_input.o icmp6.o \
+               dest6.o route6.o frag6.o \
+               ah_input.o esp_input.o \
+               nd6.o nd6_nbr.o ip6_output.o scope6.o
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet6/ip6.cfg
+
+#  IPv4
+
+TINET_COBJS := $(TINET_COBJS) \
+               ip_input.o ip_output.o ip_icmp.o ip_igmp.o in4_subr.o
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/ip.cfg
+
+#  loop back
 
 ifeq ($(NET_IF),loop)
@@ -102,11 +120,19 @@
 endif
 
+#  ppp
+
 ifeq ($(NET_IF),ppp)
 
 	TINET_COBJS := $(TINET_COBJS) \
 	               ppp.o ppp_hdlc.o ppp_lcp.o ppp_fsm.o \
-	               ppp_auth.o ppp_ipcp.o ppp_upap.o
+	               ppp_auth.o ppp_upap.o
 	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/ppp.cfg
 	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_PPP
+
+#  IPv6用 cp
+	TINET_COBJS := $(TINET_COBJS) ppp_ipv6cp.o
+
+#  IPv4用 cp
+	TINET_COBJS := $(TINET_COBJS) ppp_ipcp.o
 
 ifeq ($(PPP_CFG_MODEM),true)
@@ -143,27 +169,18 @@
 endif
 
+#  ethernet
+
 ifeq ($(NET_IF),ether)
 
-	TINET_COBJS := $(TINET_COBJS) if.o ethernet.o
-	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/ethernet.cfg
+	TINET_COBJS := $(TINET_COBJS) ethernet.o if6_ether.o if_ether.o
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) \
+	                    $(TINET_ROOT)/net/ethernet.cfg \
+	                    $(TINET_ROOT)/netinet/if_ether.cfg
 	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_ETHER
-
-	ifeq ($(SUPPORT_INET4),true)
-
-		TINET_COBJS := $(TINET_COBJS) if_ether.o
-		TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/if_ether.cfg
-
-	endif
-
-	ifeq ($(SUPPORT_INET6),true)
-
-		TINET_COBJS := $(TINET_COBJS) if6_ether.o 
-
-	endif
-
-
 	include $(TINET_ROOT)/netdev/$(NET_DEV)/Makefile.tinet
 
 endif
+
+#  TCP
 
 ifeq ($(SUPPORT_TCP),true)
@@ -177,4 +194,6 @@
 endif
 
+#  UDP
+
 ifeq ($(SUPPORT_UDP),true)
 
@@ -193,13 +212,9 @@
 
 	ifeq ($(SUPPORT_TCP),true)
-
 		TINET_COBJS := $(TINET_COBJS) tcp_usrreq.o 
-
 	endif
 
 	ifeq ($(SUPPORT_UDP),true)
-
-		TINET_COBJS := $(TINET_COBJS) udp_usrreq.o
-
+		TINET_COBJS := $(TINET_COBJS) udp_usrreq.o udp_usrreq_nblk.o
 	endif
 
@@ -207,13 +222,9 @@
 
 	ifeq ($(SUPPORT_TCP),true)
-
 		TINET_LCSRCS := $(TINET_LCSRCS) tcp_usrreq.c 
-
 	endif
 
 	ifeq ($(SUPPORT_UDP),true)
-
-		TINET_LCSRCS := $(TINET_LCSRCS) udp_usrreq.c
-
+		TINET_LCSRCS := $(TINET_LCSRCS) udp_usrreq.c udp_usrreq_nblk.c
 	endif
 
@@ -248,8 +259,13 @@
 		tcp_set_opt.o tcp_get_opt.o
 
-udp_usrreq = 	udp_can_snd.o udp_can_rcv.o udp_can_cep.o \
-		udp_cre_cep.o udp_del_cep.o \
-		udp_snd_dat.o udp_rcv_dat.o udp_send_data.o \
-		udp_set_opt.o udp_get_opt.o
+udp_usrreq = 	udp_can_cep.o udp_send_data.o \
+		udp_can_snd.o udp_can_rcv.o \
+		udp_snd_dat.o udp_rcv_dat.o \
+		udp_set_opt.o udp_get_opt.o \
+		udp_cre_cep.o udp_del_cep.o
+
+udp_usrreq_nblk = \
+		udp_can_snd_nblk.o udp_can_rcv_nblk.o \
+		udp_snd_dat_nblk.o udp_rcv_dat_nblk.o
 
 #
@@ -257,6 +273,7 @@
 #  オブジェクトファイルの依存関係の定義
 #
-$(tcp_usrreq) $(tcp_usrreq:.o=.s) $(tcp_usrreq:.o=.d): tcp_usrreq.c
-$(udp_usrreq) $(udp_usrreq:.o=.s) $(udp_usrreq:.o=.d): udp_usrreq.c udp_usrreq_nblk.c
+$(tcp_usrreq) $(tcp_usrreq:.o=.s) $(tcp_usrreq:.o=.d): tcp_usrreq.c tcpn_usrreq.c
+$(udp_usrreq) $(udp_usrreq:.o=.s) $(udp_usrreq:.o=.d): udp_usrreq.c udpn_usrreq.c
+$(udp_usrreq_nblk) $(udp_usrreq_nblk:.o=.s) $(udp_usrreq_nblk:.o=.d): udp_usrreq_nblk.c
 
 #
@@ -271,6 +288,5 @@
 ifeq ($(TARGET_KERNEL),ASP)
 
-TINET_CFG = $(APPLDIR)/tinet_$(APPLNAME).cfg
-TINET_CFG_OUT = tinet_cfg.c tinet_cfg.h
+TINET_CFG_OUT = tinet_cfg.c tinet_cfg.h tinet_kern.cfg
 TINET_KERNEL_CFG :=	$(TINET_KERNEL_CFG) \
 			$(TINET_ROOT)/tinet_asp.cfg $(TINET_ROOT)/net/net_asp.cfg 
@@ -305,5 +321,5 @@
 ifeq ($(TARGET_KERNEL),ASP)
 
-	SYSSVC_DIRS := $(SYSSVC_DIRS):$(TINET_DIR)
+	SYSSVC_DIRS := $(SYSSVC_DIRS):$(TINET_DIRS)
 	SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
 	SYSSVC_COBJS := $(SYSSVC_COBJS) $(TINET_COBJS)
@@ -311,4 +327,6 @@
 	SYSSVC_LIBS := $(SYSSVC_LIBS) $(LIBTINET) -lc
 
+	CFG_COBJS := $(CFG_COBJS) $(TINET_CFG_COBJS)
+
 	CLEAN_FILES := $(CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
 
@@ -319,5 +337,5 @@
 	MTASK_CFG := $(MTASK_CFG) $(TINET_CFG)
 	MTASK_KERNEL_CFG := $(MTASK_KERNEL_CFG) $(TINET_KERNEL_CFG)
-	MTASK_DIR := $(MTASK_DIR):$(TINET_DIR)
+	MTASK_DIR := $(MTASK_DIRS):$(TINET_DIRS)
 	MTASK_LCSRCS := $(MTASK_LCSRCS) $(TINET_LCSRCS)
 	MTASK_ASMOBJS := $(MTASK_ASMOBJS)
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ether_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ether_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ether_var.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.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
  *
@@ -63,4 +63,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -71,9 +72,9 @@
 #include <netinet/in_var.h>
 #include <netinet/if_ether.h>
+
 #include <netinet6/if6_ether.h>
 #include <netinet6/nd6.h>
 
 #include <net/if_var.h>
-#include <net/if6_var.h>
 
 #ifdef SUPPORT_ETHER
@@ -83,5 +84,5 @@
  */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 const uint8_t ether_broad_cast_addr[ETHER_ADDR_LEN] = {
@@ -90,5 +91,5 @@
 	};
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
 
 /*
@@ -98,32 +99,9 @@
 /* ネットワークインタフェース構造体 */
 
-#if defined(SUPPORT_INET4)
-
-static T_IFNET ether_ifnet = {
-	NULL,			/* ネットワークインタフェースのソフトウェア情報	*/
-	{
-		IPV4_ADDR_LOCAL,	/* IPv4 アドレス		*/
-		IPV4_ADDR_LOCAL_MASK,	/* サブネットマスク		*/
-		},
-	};
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-static T_IFNET ether_ifnet = {
-	NULL,			/* ネットワークインタフェースのソフトウェア情報	*/
-	{0},			/* IPv6 アドレス情報				*/
-	{0},			/* マルチキャスト IPv6 アドレス			*/
-	0,				/* フラグ					*/
-	};
-
-#endif	/* of #if defined(SUPPORT_INET6) */
+static T_IFNET ether_ifnet;
 
 #ifdef SUPPORT_MIB
 
-/*
- *  SNMP の 管理情報ベース (MIB)
- */
+/*  SNMP の 管理情報ベース (MIB) */
 
 T_IF_STATS if_stats;
@@ -158,4 +136,32 @@
 
 /*
+ *  ether_srand -- 乱数を初期値を返す。
+ */
+
+uint32_t
+ether_srand (void)
+{
+	T_IF_SOFTC	*ic;
+	uint32_t	rval;
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	rval  = (ic->ifaddr.lladdr[2] << 24)
+	      + (ic->ifaddr.lladdr[3] << 16)
+	      + (ic->ifaddr.lladdr[4] <<  8)
+	      + (ic->ifaddr.lladdr[5]      );
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+
+	rval += (ether_collect_addr.lladdr[2] << 24)
+	      + (ether_collect_addr.lladdr[3] << 16)
+	      + (ether_collect_addr.lladdr[4] <<  8)
+	      + (ether_collect_addr.lladdr[5]      );
+
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+	return rval;
+	}
+
+/*
  *  ether_get_ifnet -- ネットワークインタフェース構造体を返す。
  */
@@ -167,5 +173,5 @@
 	}
 
-#if defined(SUPPORT_INET6)
+#if defined(_IP6_CFG)
 
 /*
@@ -174,5 +180,5 @@
 
 ER
-ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr)
+ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr)
 {
 	/* マルチキャストアドレスかチェックする。*/
@@ -186,5 +192,5 @@
 	}
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 /**
@@ -203,4 +209,11 @@
       }
 #endif /* LWIP_ARP */
+
+#if LWIP_IGMP
+      /* resend IGMP memberships */
+      if (ether->_flags & IF_FLAG_IGMP) {
+        igmp_report_groups(ether);
+      }
+#endif /* LWIP_IGMP */
     }
     if (ether->link_callback) {
@@ -262,5 +275,5 @@
 
 ER
-ether_output (T_NET_BUF *output, void *dst, T_IF_ADDR *gw, TMO tmout)
+ether_output (T_NET_BUF *output, const void *dst, T_IF_ADDR *gw, TMO tmout)
 {
 	T_IF_SOFTC	*ic;
@@ -275,5 +288,5 @@
 	switch(ntohs(eth->type)) {
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 	case ETHER_TYPE_IP:		/* IPv4	*/
@@ -292,11 +305,11 @@
 		break;
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
 
 	case ETHER_TYPE_IPV6:		/* IPv6	*/
-		error = nd6_storelladdr((T_ETHER_ADDR*)GET_ETHER_HDR(output)->dhost,
-		                        (T_IN6_ADDR*)dst, gw);
+		error = nd6_storelladdr((T_ETHER_ADDR*)eth->dhost,
+		                        (const T_IN6_ADDR*)dst, gw);
 		if (error == E_OK)
 			error = ether_raw_output(output, tmout);
@@ -311,5 +324,5 @@
 		break;
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 	default:
@@ -398,7 +411,17 @@
 	ID		tskid;
 	uint16_t	proto;
+	uint8_t		rcount = 0;
 
 	/* ネットワークインタフェース管理を初期化する。*/
 	ifinit();
+
+	/* イーサネットネットワークインタフェース管理を初期化する。*/
+
+#if defined(_IP4_CFG)
+
+	ether_ifnet.in4_ifaddr.addr = IPV4_ADDR_LOCAL;		/* IPv4 アドレス		*/
+	ether_ifnet.in4_ifaddr.mask = IPV4_ADDR_LOCAL_MASK;	/* サブネットマスク		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
 
 	/* NIC を初期化する。*/
@@ -418,17 +441,20 @@
 	                   tskid, mac2str(NULL, ic->ifaddr.lladdr));
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 	/* ARP を初期化する。*/
 	arp_init();
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
 
 	ether_ifnet.ic = ic;
+
+	/* 乱数生成を初期化する。*/
+	net_srand(0);
 
 	while (true) {
 		syscall(wai_sem(ic->semid_rxb_ready));
 		if ((input = IF_ETHER_NIC_READ(ic)) != NULL) {
-			NET_COUNT_ETHER(net_count_ether.in_octets, input->len);
+			NET_COUNT_ETHER(net_count_ether.in_octets,  input->len);
 			NET_COUNT_MIB(if_stats.ifInOctets, input->len + 8);
 			NET_COUNT_ETHER(net_count_ether.in_packets, 1);
@@ -436,4 +462,17 @@
 			proto = ntohs(eth->type);
 
+			/* 乱数生成を初期化する。*/
+			if (rcount == 0) {
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+				memcpy(ether_collect_addr.lladdr, eth->shost, 
+				sizeof(ether_collect_addr.lladdr));
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+				net_srand(0);
+				}
+			rcount ++;
+
+
 #ifdef SUPPORT_MIB
 			if ((*eth->dhost & ETHER_MCAST_ADDR) == 0) {
@@ -445,5 +484,5 @@
 #endif	/* of #ifdef SUPPORT_MIB */
 
-#if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL)
+#if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL)
 
 			if ((*eth->dhost & ETHER_MCAST_ADDR) && *eth->dhost != 0xff) {
@@ -464,9 +503,9 @@
 				}
 
-#endif	/* of #if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) */
+#endif	/* of #if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL) */
 
 			switch(proto) {
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 			case ETHER_TYPE_IP:		/* IP	*/
@@ -478,7 +517,7 @@
 				break;
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
 
 			case ETHER_TYPE_IPV6:		/* IPv6	*/
@@ -486,5 +525,5 @@
 				break;
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 			default:
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h	(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
  *
@@ -98,4 +98,38 @@
 #endif	/* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
 
+#if defined(__RX)
+
+#pragma pack
+typedef struct t_ether_header {
+
+#if IF_ETHER_NIC_HDR_ALIGN != 0
+
+	uint8_t		align[IF_ETHER_NIC_HDR_ALIGN];	/* アライン調整 */
+
+#endif	/* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
+
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	type;
+	} T_ETHER_HDR;
+#pragma packoption
+
+#elif defined(TOPPERS_S810_CLG3_85)	/* of #if defined(__RX) */
+
+typedef struct t_ether_header {
+
+#if IF_ETHER_NIC_HDR_ALIGN != 0
+
+	uint8_t		align[IF_ETHER_NIC_HDR_ALIGN];	/* アライン調整 */
+
+#endif	/* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
+
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	type;
+	} T_ETHER_HDR;
+
+#else	/* of #if defined(__RX) */
+
 typedef struct t_ether_header {
 
@@ -111,4 +145,6 @@
 	} __attribute__((packed, aligned(2)))T_ETHER_HDR;
 
+#endif	/* of #if defined(__RX) */
+
 #define GET_ETHER_HDR(nbuf)		((T_ETHER_HDR*)((nbuf)->buf))
 
@@ -140,4 +176,5 @@
 #define IF_HDR_ALIGN		2			/* ヘッダのアライン単位				*/
 #define IF_MTU			1500			/* インタフェースの MTU				*/
+#define IF_MIN_LEN		ETHER_MIN_LEN		/* インターフェースフレームの最短長		*/
 
 #define IF_OUTPUT(o,d,g,t)	ether_output(o,d,g,t)	/* インタフェースの出力関数			*/
@@ -148,9 +185,10 @@
 							/* ソフトウェア情報から MAC アドレスを取り出す	*/
 #define IF_GET_IFNET()		ether_get_ifnet()	/* ネットワークインタフェース構造体を返す。		*/
-#define IF_TYPE			IFT_ETHER		/* インターフェースの型				*/
+#define IF_TYPE			IFT_ETHER		/* インタフェースの型				*/
+#define IF_SRAND()		ether_srand()	/* インタフェースの乱数初期値			*/
 
 /* IPv4 関係 */
 
-#define IF_PROTO_IP		ETHER_TYPE_IP		/* インタフェースの IP プロトコル指定		*/
+#define IF_PROTO_IP		ETHER_TYPE_IP		/* インタフェースの IPv4 プロトコル指定		*/
 #define IF_PROTO_ARP		ETHER_TYPE_ARP		/* インタフェースの ARP プロトコル指定		*/
 
@@ -160,5 +198,5 @@
 #define IF_MADDR_INIT		{ { { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 } } }
 							/* インタフェースのマルチキャストアドレス配列の初期化	*/
-#define IF_PROTO_IPV6		ETHER_TYPE_IPV6		/* インタフェースの IP プロトコル指定			*/
+#define IF_PROTO_IPV6		ETHER_TYPE_IPV6		/* インタフェースの IPv6 プロトコル指定			*/
 #define IF_ADDMULTI(s)		IF_ETHER_NIC_ADDMULTI(s)
 							/* マルチキャストアドレスの登録				*/
@@ -215,13 +253,13 @@
 	T_IF_ADDR		ifaddr;			/* ネットワークインタフェースのアドレス	*/
 	uint16_t		timer;			/* 送信タイムアウト			*/
-	T_IF_ETHER_NIC_SOFTC	*sc;	/* ディバイス依存のソフトウェア情報	*/
+	T_IF_ETHER_NIC_SOFTC	*sc;			/* ディバイス依存のソフトウェア情報	*/
 	ID			semid_txb_ready;	/* 送信セマフォ				*/
 	ID			semid_rxb_ready;	/* 受信セマフォ				*/
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 	T_IF_ADDR 	maddrs[MAX_IF_MADDR_CNT];	/* マルチキャストアドレスリスト	*/
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifdef _IP6_CFG */
 	};
 
@@ -231,5 +269,19 @@
 #define IF_FLAG_LINK_UP			0x10U
 
-#ifdef SUPPORT_INET6
+/*
+ *  変数
+ */
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+
+T_ETHER_ADDR ether_collect_addr;
+
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+/*
+ *  関数
+ */
+
+#ifdef _IP6_CFG
 
 /* 前方参照 */
@@ -243,19 +295,12 @@
 #endif	/* of #ifndef T_IN6_ADDR_DEFINED */
 
-/*
- *  関数
- */
-
-extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, T_IN6_ADDR *maddr);
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-/*
- *  関数
- */
+extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr);
+
+#endif	/* of #ifdef _IP6_CFG */
 
 extern T_IFNET *ether_get_ifnet (void);
-extern ER ether_output (T_NET_BUF *data, void *dst, T_IF_ADDR *gw, TMO tmout);
+extern ER ether_output (T_NET_BUF *data, const void *dst, T_IF_ADDR *gw, TMO tmout);
 extern ER ether_raw_output (T_NET_BUF *data, TMO tmout);
+extern uint32_t ether_srand (void);
 
 /** Function prototype for netif status- or link-callback functions. */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.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
  *
@@ -86,13 +86,19 @@
 
 #include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
 #include <net/ethernet.h>
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
 #include <netinet6/in6_var.h>
 
-#include <net/if6_var.h>
+#include <net/if_var.h>
 
 #ifdef SUPPORT_ETHER
@@ -133,5 +139,7 @@
 	}
 
-#ifdef SUPPORT_INET6
+#endif /* of #ifdef SUPPORT_ETHER */
+
+#ifdef _IP6_CFG
 
 /*
@@ -142,4 +150,6 @@
 if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type)
 {
+#if MAX_IF_MADDR_CNT > 0
+
 	T_IF_ADDR	llmaddr;
 	ER		error = E_OK;
@@ -152,5 +162,5 @@
 
 		/* IPv6 マルチキャストアドレスを登録する。*/
-		ifp->in_maddrs[ix] = *(T_IN6_ADDR*)maddr;
+		ifp->in6_maddrs[ix] = *(T_IN6_ADDR*)maddr;
 
 		/* インタフェースのアドレスに変換し、登録する。*/
@@ -162,7 +172,11 @@
 
 	return IF_ADDMULTI(ifp->ic);
+
+#else	/* of #if MAX_IF_MADDR_CNT > 0 */
+
+	return E_OK;
+
+#endif	/* of #if MAX_IF_MADDR_CNT > 0 */
 	}
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#endif /* of #ifdef SUPPORT_ETHER */
+#endif	/* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if6_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if6_var.h	(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
  *
@@ -68,18 +68,51 @@
 #define _IF6_VAR_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  ネットワークインタフェース構造体
  */
 
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
 struct t_ifnet {
 	T_IF_SOFTC	*ic;		/* ネットワークインタフェースのソフトウェア情報	*/
-	T_IN6_IFADDR 	in_ifaddrs[NUM_IN6_IFADDR_ENTRY];
+	T_IN6_IFADDR 	in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
 					/* IPv6 アドレス情報				*/
-	T_IN6_ADDR	in_maddrs [MAX_IN6_MADDR_CNT];
+	T_IN6_ADDR	in6_maddrs [MAX_IN6_MADDR_CNT];
 					/* マルチキャスト IPv6 アドレス			*/
+	T_IN4_IFADDR 	in4_ifaddr;	/* IPv4 アドレス情報				*/
+	ether_status_callback_fn link_callback;
 	uint8_t		flags;		/* フラグ					*/
 	};
+
+#else	/* of #if defined(_IP4_CFG) */
+
+struct t_ifnet {
+	T_IF_SOFTC	*ic;		/* ネットワークインタフェースのソフトウェア情報	*/
+	T_IN6_IFADDR 	in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
+					/* IPv6 アドレス情報				*/
+	T_IN6_ADDR	in6_maddrs [MAX_IN6_MADDR_CNT];
+					/* マルチキャスト IPv6 アドレス			*/
+	ether_status_callback_fn link_callback;
+	uint8_t		flags;		/* フラグ					*/
+	};
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+struct t_ifnet {
+	T_IF_SOFTC	*ic;		/* ネットワークインタフェースのソフトウェア情報	*/
+	T_IN4_IFADDR 	in4_ifaddr;	/* IPv4 アドレス情報				*/
+	ether_status_callback_fn link_callback;
+	uint8_t		flags;		/* フラグ					*/
+	};
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
 
 #ifndef T_IFNET_DEFINED
@@ -90,4 +123,6 @@
 
 #endif	/* of #ifndef T_IFNET_DEFINED */
+
+#if defined(_IP6_CFG)
 
 /*
@@ -103,5 +138,5 @@
 extern ER if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #if defined(_IP6_CFG) */
 
 #endif	/* of #ifndef _IF6_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_llc.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_llc.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_llc.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.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
  *
@@ -91,4 +91,5 @@
 #include <net/if_loop.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -98,11 +99,8 @@
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/tcp.h>
 #include <netinet/udp.h>
 
 #include <net/if_var.h>
-#include <net/if6_var.h>
 
 #ifdef SUPPORT_LOOP
@@ -124,5 +122,13 @@
 /* ネットワークインタフェース構造体 */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP6_CFG)
+
+static T_IFNET loop_ifnet = {
+	NULL,			/* ネットワークインタフェースのソフトウェア情報	*/
+	{},			/* IPv6 アドレス情報				*/
+	{},			/* マルチキャスト IPv6 アドレス			*/
+	};
+
+#elif defined(_IP4_CFG)	/* of #if defined(_IP6_CFG) */
 
 static T_IFNET loop_ifnet = {
@@ -134,15 +140,5 @@
 	};
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-static T_IFNET loop_ifnet = {
-	NULL,			/* ネットワークインタフェースのソフトウェア情報	*/
-	{},			/* IPv6 アドレス情報				*/
-	{},			/* マルチキャスト IPv6 アドレス			*/
-	};
-
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 /*
@@ -213,5 +209,5 @@
 			NET_COUNT_LOOP(net_count_loop.in_packets, 1);
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 			/* IPv4 入力関数を呼び出す */
@@ -219,7 +215,7 @@
 				ip_input(input);
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
 
 			/* IPv6 入力関数を呼び出す */
@@ -227,5 +223,5 @@
 				ip6_input(input);
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 			}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_loop.h	(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
  *
@@ -91,4 +91,5 @@
 #define IF_SET_PROTO(b,p)				/* インタフェースのプロトコル設定関数	*/
 #define IF_GET_IFNET()		loop_get_ifnet()	/* ネットワークインタフェース構造体を返す。		*/
+#define IF_SRAND()		(0)			/* インターフェースの乱数初期値			*/
 
 /* IPv4 関係 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_ppp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_ppp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_ppp.h	(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
  *
@@ -59,18 +59,40 @@
 
 /*
+ *  PPP アドレスの定義（ダミー）
+ */
+
+typedef struct t_ppp_addr {
+	uint8_t		lladdr[0];
+	} T_PPP_ADDR;
+
+/*
  *  インタフェースの選択マクロ
  */
 
-#define T_IF_HDR		T_PPP_HDR	/* インタフェースのヘッダ			*/
-#define IF_HDR_ALIGN		2		/* ヘッダのアライン単位			*/
-#define IF_MTU			DEF_PPP_MTU	/* インタフェースの MTU			*/
-						/* インタフェースの IPv4 アドレス		*/
-#define IF_PROTO_IP		PPP_IP		/* インタフェースの IP プロトコル指定	*/
+#define T_IF_HDR		T_PPP_HDR		/* インタフェースのヘッダ		*/
+#define T_IF_ADDR		T_PPP_ADDR		/* インタフェースのアドレス			*/
+#define IF_HDR_ALIGN		2			/* ヘッダのアライン単位			*/
+#define IF_MTU			DEF_PPP_MTU		/* インタフェースの MTU			*/
 
 #define IF_OUTPUT(o,d,g,t)	ppp_output(o,t)		/* インタフェースの出力関数		*/
 #define IF_RAW_OUTPUT(o,t)	ppp_output(o,t)		/* インタフェースの出力関数、アドレス解決無し*/
+#define IF_SET_PROTO(b,p)	(*GET_PPP_HDR(b) = htons(p))
 							/* インタフェースのプロトコル設定関数	*/
-#define IF_SET_PROTO(b,p)	(*GET_PPP_HDR(b) = htons(p))
-#define IF_GET_IFNET()		ppp_get_ifnet()		/* ネットワークインタフェース構造体を返す。		*/
+#define IF_SOFTC_TO_IFADDR(s)	((T_IF_ADDR*)(s)->ifaddr.lladdr)
+							/* ソフトウェア情報から PPP アドレスを取り出す	*/
+#define IF_GET_IFNET()		ppp_get_ifnet()		/* ネットワークインタフェース構造体を返す。*/
+#define IF_SRAND()		(0)			/* インターフェースの乱数初期値			*/
+
+/* IPv4 関係 */
+
+#define IF_PROTO_IP		PPP_IP			/* インタフェースの IPv4 プロトコル指定	*/
+
+/* IPv6 関係 */
+
+#define MAX_IF_MADDR_CNT	0			/* インタフェースのマルチキャストアドレス配列の最大サイズ*/
+#define IF_PROTO_IPV6		PPP_IPV6		/* インタフェースの IPv6 プロトコル指定	*/
+#define IF_IN6_NEED_CACHE(i)	(false)			/* 近隣探索キャッシュを使用する。	*/
+#define IF_IN6_IFID(i,a)	get_rand_ifid(i,a)	/* インタフェース識別子の設定		*/
+#define IF_IN6_RESOLVE_MULTICAST(i,m)	{}		/* インタフェースのマルチキャストアドレスへの変換		*/
 
 /*
@@ -120,5 +142,7 @@
  */
 
-struct t_if_softc { };
+struct t_if_softc {
+	T_IF_ADDR	ifaddr;		/* ネットワークインタフェースのアドレス	*/
+	};
 
 /*
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_types.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_types.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_types.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_var.h	(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
  *
@@ -68,26 +68,5 @@
 #define _IF_VAR_H_
 
-#if defined(SUPPORT_INET4)
-
-/*
- *  ネットワークインタフェース構造体
- */
-
-struct t_ifnet {
-	T_IF_SOFTC	*ic;		/* ネットワークインタフェースのソフトウェア情報	*/
-	T_IN4_IFADDR 	in_ifaddr;	/* IPv4 アドレス情報				*/
-	ether_status_callback_fn link_callback;
-	uint8_t		flags;		/* フラグ					*/
-	};
-
-#ifndef T_IFNET_DEFINED
-
-typedef struct t_ifnet T_IFNET;
-
-#define T_IFNET_DEFINED
-
-#endif	/* of #ifndef T_IFNET_DEFINED */
-
-#endif	/* of #if defined(SUPPORT_INET4) */
+#include <net/if6_var.h>
 
 #ifdef SUPPORT_MIB
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.cfg	(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
  *
@@ -41,5 +41,5 @@
 
 CRE_TSK(NET_TIMER_TASK, {
-		TA_NULL,
+		TA_HLNG,
 		0,
 		net_timer_task,
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net.h	(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
  *
@@ -69,124 +69,4 @@
 
 /*
- *  バイトオーダの定義
- */
-
-#define _NET_CFG_LITTLE_ENDIAN	1234
-#define _NET_CFG_BIG_ENDIAN	4321
-
-#ifdef TARGET_KERNEL_ASP
-
-#if defined(SIL_ENDIAN_LITTLE)
-
-#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
-
-#elif defined(SIL_ENDIAN_BIG)
-
-#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
-
-#else	/* of #if defined(SIL_ENDIAN_BIG) */
-
-#error "SIL_ENDIAN expected."
-
-#endif	/* of #if defined(SIL_ENDIAN_BIG) */
-
-#endif	/* of #ifdef TARGET_KERNEL_ASP */
-
-#ifdef TARGET_KERNEL_JSP
-
-#if SIL_ENDIAN == SIL_ENDIAN_LITTLE
-
-#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
-
-#elif SIL_ENDIAN == SIL_ENDIAN_BIG	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
-
-#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
-
-#else	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
-
-#error "SIL_ENDIAN expected."
-
-#endif	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
-
-#endif	/* of #ifdef TARGET_KERNEL_JSP */
-
-/*
- *  バイトオーダ変換の定義
- */
-
-#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
-
-#define ntohs(n)		((uint16_t)n)
-#define htons(h)		((uint16_t)h)
-#define ntohl(n)		((uint32_t)n)
-#define htonl(h)		((uint32_t)h)
-
-#define NTOHS(n)
-#define HTONS(h)
-#define NTOHL(n)
-#define HTONL(h)
-
-/*
- *  注意: IPヘッダ以降は、4 バイト境界にアラインされている事を
- *        前提としているが、4 バイト境界でアクセスする
- *        プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン
- *        されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。
- */
-
-#define ntoahl(h,n)		memcpy((uint8_t*)&(h),(n),4)
-#define ahtonl(n,h)		memcpy((n),(uint8_t*)&(h),4)
-
-#define nahcmpl(n,h)		memcmp((n),(uint8_t*)&(h),4)
-
-#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
-
-#ifndef NET_REV_ENDIAN_HWORD
-
-#define NET_REV_ENDIAN_HWORD(d)	((uint16_t)((((uint16_t)(d)&0xff)<<8)|(((uint16_t)(d)>>8)&0xff)))
-
-#endif	/* of #ifndef NET_REV_ENDIAN_HWORD */
-
-#ifndef NET_REV_ENDIAN_WORD
-
-#define NET_REV_ENDIAN_WORD(d)	((uint32_t)((((uint32_t)(d)&0xff)<<24)|(((uint32_t)(d)&0xff00)<<8)| \
-				            (((uint32_t)(d)>>8)&0xff00)|(((uint32_t)(d)>>24)&0xff)))
-
-#endif	/* of #ifndef NET_REV_ENDIAN_WORD */
-
-#define ntohs(n)		NET_REV_ENDIAN_HWORD(n)
-#define htons(h)		NET_REV_ENDIAN_HWORD(h)
-#define ntohl(n)		NET_REV_ENDIAN_WORD(n)
-#define htonl(h)		NET_REV_ENDIAN_WORD(h)
-
-#define NTOHS(n)		((n)=NET_REV_ENDIAN_HWORD(n))
-#define HTONS(h)		((h)=NET_REV_ENDIAN_HWORD(h))
-#define NTOHL(n)		((n)=NET_REV_ENDIAN_WORD(n))
-#define HTONL(h)		((h)=NET_REV_ENDIAN_WORD(h))
-
-/*
- *  注意: IPヘッダ以降は、4 バイト境界にアラインされている事を
- *        前提としているが、4 バイト境界でアクセスする
- *        プロセッサで、ネットワーク側のデータが、4 バイト境界にアライン
- *        されていない場合は、ntoahl、ahtonl、nahcmpl を使用すること。
- */
-
-#ifndef _MACRO_ONLY
-
-extern void rev_memcpy_word (uint8_t *dst, uint8_t *src);
-extern int  rev_memcmp_word (uint8_t *data1, uint8_t *data2);
-
-#endif	/* of #ifndef _MACRO_ONLY */
-
-#define ntoahl(h,n)		rev_memcpy_word((uint8_t*)&(h),(n))
-#define ahtonl(n,h)		rev_memcpy_word((n),(uint8_t*)&(h))
-#define nahcmpl(n,h)		rev_memcmp_word((n),(uint8_t*)&(h))
-
-#else	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
-
-#error "_NET_CFG_BYTE_ORDER expected."
-
-#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
-
-/*
  *  プロトコルを識別するフラグに関する定義
  *
@@ -199,8 +79,9 @@
 #define PROTO_FLG_PPP_LCP	ULONG_C(0x00000008)	/* ppp_lcp.c	*/
 #define PROTO_FLG_PPP_IPCP	ULONG_C(0x00000010)	/* ppp_ipcp.c	*/
-#define PROTO_FLG_PPP_CCP	ULONG_C(0x00000020)	/* ppp_ccp.c	*/
-#define PROTO_FLG_PPP_PAP	ULONG_C(0x00000040)	/* ppp_upap.c	*/
-#define PROTO_FLG_PPP_MODEM	ULONG_C(0x00000080)	/* ppp_modem.c	*/
-#define PROTO_FLG_PPP		ULONG_C(0x00000100)	/* ppp.c	*/
+#define PROTO_FLG_PPP_IPV6CP	ULONG_C(0x00000020)	/* ppp_ipv6cp.c	*/
+#define PROTO_FLG_PPP_CCP	ULONG_C(0x00000040)	/* ppp_ccp.c	*/
+#define PROTO_FLG_PPP_PAP	ULONG_C(0x00000080)	/* ppp_upap.c	*/
+#define PROTO_FLG_PPP_MODEM	ULONG_C(0x00000100)	/* ppp_modem.c	*/
+#define PROTO_FLG_PPP		ULONG_C(0x00000200)	/* ppp.c	*/
 
 #define PROTO_FLG_ETHER_NIC	ULONG_C(0x00000001)	/* if_??.c	*/
@@ -216,4 +97,5 @@
 #define PROTO_FLG_IP4		ULONG_C(0x00010000)	/* ip_*.c	*/
 #define PROTO_FLG_ICMP4		ULONG_C(0x00040000)	/* ip_icmp.c	*/
+#define PROTO_FLG_IGMP		ULONG_C(0x00080000)	/* ip_igmp.c	*/
 
 #define PROTO_FLG_IP6		ULONG_C(0x00100000)	/* ip6_*.c	*/
@@ -236,4 +118,15 @@
 #define AT_INET6		UINT_C(0x20)		/* IPv6 アドレス	*/
 
+/*
+ *  IPv4 UDPオプションの定義
+ */
+
+#define IP_MULTICAST_IF    32
+#define IP_MULTICAST_TTL   33
+#define IP_MULTICAST_LOOP  34
+#define IP_ADD_MEMBERSHIP  35
+#define IP_DROP_MEMBERSHIP 36
+#define IP_MSFILTER        41
+
 #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg	(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
  *
@@ -50,5 +50,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_CSEG,
-		sizeof(T_NET_BUF_CSEG)
+		sizeof(T_NET_BUF_CSEG),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
@@ -57,5 +59,7 @@
 CRE_MPF(MPF_NET_BUF_64, {
 		TA_TFIFO, NUM_MPF_NET_BUF_64,
-		sizeof(T_NET_BUF_64)
+		sizeof(T_NET_BUF_64),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
@@ -65,5 +69,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_128,
-		sizeof(T_NET_BUF_128)
+		sizeof(T_NET_BUF_128),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
@@ -73,5 +79,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_256,
-		sizeof(T_NET_BUF_256)
+		sizeof(T_NET_BUF_256),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */
@@ -81,5 +89,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_512,
-		sizeof(T_NET_BUF_512)
+		sizeof(T_NET_BUF_512),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */
@@ -89,5 +99,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_IP_MSS,
-		sizeof(T_NET_BUF_IP_MSS)
+		sizeof(T_NET_BUF_IP_MSS),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */
@@ -97,5 +109,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_1024,
-		sizeof(T_NET_BUF_1024)
+		sizeof(T_NET_BUF_1024),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */
@@ -105,5 +119,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_IPV6_MMTU,
-		sizeof(T_NET_BUF_IPV6_MMTU)
+		sizeof(T_NET_BUF_IPV6_MMTU),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */
@@ -113,22 +129,33 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF_IF_PDU,
-		sizeof(T_NET_BUF_IF_PDU)
+		sizeof(T_NET_BUF_IF_PDU),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
 
+#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_REASSM,
+		sizeof(T_NET_BUF6_REASSM),
+		NULL,
+		NULL
+		});
+
+#else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
 CRE_MPF(MPF_NET_BUF_REASSM, {
 		TA_TFIFO,
 		NUM_MPF_NET_BUF4_REASSM,
-		sizeof(T_NET_BUF4_REASSM)
+		sizeof(T_NET_BUF4_REASSM),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
 
-#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
-CRE_MPF(MPF_NET_BUF_REASSM, {
-		TA_TFIFO,
-		NUM_MPF_NET_BUF6_REASSM,
-		sizeof(T_NET_BUF6_REASSM)
-		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
 
@@ -137,5 +164,7 @@
 		TA_TFIFO,
 		NUM_MPF_NET_BUF6_65536,
-		sizeof(T_NET_BUF6_65536)
+		sizeof(T_NET_BUF6_65536),
+		NULL,
+		NULL
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.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
  *
@@ -57,4 +57,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -62,11 +63,7 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 
@@ -98,4 +95,5 @@
 
 #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
 	{
 		MPF_NET_BUF_REASSM,
@@ -109,7 +107,9 @@
 
 		},
-#endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#else	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
 
 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
 	{
 		MPF_NET_BUF_REASSM,
@@ -123,5 +123,8 @@
 
 		},
+
 #endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
 
 #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
@@ -223,5 +226,5 @@
 #endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
@@ -239,5 +242,5 @@
 #endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
 
 #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
@@ -308,5 +311,9 @@
 			(*buf)->len   = (uint16_t)minlen;
 			(*buf)->flags = 0;
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
 			NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
+			net_buf_table[ix].busies ++;
+#endif
 			return error;
 			}
@@ -316,5 +323,6 @@
 		}
 
-	syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, minlen);
+	syslog(LOG_WARNING, "[BUF] busy, up   index:%d,%d[%4d], len:%4d.",
+	                    (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
 	*buf = NULL;
 	NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
@@ -346,5 +354,9 @@
 			(*buf)->len   = net_buf_table[ix].size;
 			(*buf)->flags = 0;
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
 			NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
+			net_buf_table[ix].busies ++;
+#endif
 			return error;
 			}
@@ -354,5 +366,6 @@
 		}
 
-	syslog(LOG_WARNING, "[NET BUF] busy, index=%d, len=%4d.", (uint16_t)req_ix, maxlen);
+	syslog(LOG_WARNING, "[BUF] busy, down index:%d,%d[%4d], len:%4d.",
+	                    (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
 	*buf = NULL;
 	NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
@@ -380,4 +393,6 @@
 		}
 
+#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
+
 	/* TCP で予約したネットワークバッファを取り出す。*/
 	if ((nbatr & NBA_RESERVE_TCP) != 0) {
@@ -386,4 +401,6 @@
 			}
 		}
+
+#endif	/* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
 
 	if ((nbatr & NBA_SEARCH_DESCENT) != 0)
@@ -423,11 +440,20 @@
 	else {
 
+#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
+
 		/* TCP で、ネットワークバッファを予約する。*/
 		if (TCP_PUSH_RES_NBUF(buf) == NULL)
 			return E_OK;
 
+#endif	/* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
+
 		/* 固定メモリプールに返す。*/
-		if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK)
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+		net_buf_table[buf->idix].busies --;
+#endif
+		if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
 			syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
+			}
 		}
 	return error;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h	(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
  *
@@ -61,5 +61,5 @@
 	uint8_t		halign[4 - IF_HDR_ALIGN];
 #endif
-	uint8_t		buf[4];	/* バッファ本体		*/
+	uint8_t		buf[IF_MIN_LEN];	/* バッファ本体 */
 	};
 
@@ -71,4 +71,5 @@
 
 #endif	/* of #ifndef T_NET_BUF_DEFINED */
+
 /*
  *  64 オクテット
@@ -159,4 +160,6 @@
  *  ネットワークインタフェースの最大 PDU サイズ
  */
+
+#if defined(IF_PDU_SIZE)
 
 typedef struct t_net_buf_if_pdu {
@@ -177,4 +180,6 @@
 	} T_NET_BUF_IF_PDU;
 
+#endif	/* of #if defined(IF_PDU_SIZE) */
+
 /*
  *  ネットワークバッファ表
@@ -189,4 +194,5 @@
 
 	ulong_t		prepares;
+	ulong_t		busies;
 	ulong_t		requests;
 	ulong_t		allocs;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.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
  *
@@ -120,4 +120,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_count.h>
 
@@ -142,4 +143,11 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
 
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
+
+T_NET_COUNT_VAL	net_count_ppp_ipv6cp_in_octets;
+T_NET_COUNT_VAL	net_count_ppp_ipv6cp_in_packets;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
 #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP
 
@@ -190,5 +198,5 @@
 #endif	/* of #ifdef SUPPORT_ETHER */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 #if NET_COUNT_ENABLE & PROTO_FLG_ARP
@@ -210,7 +218,13 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+#if NET_COUNT_ENABLE & PROTO_FLG_IGMP
+
+T_NET_COUNT	net_count_igmp;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
 
 #if NET_COUNT_ENABLE & PROTO_FLG_IP6
@@ -232,5 +246,5 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 #ifdef SUPPORT_TCP
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.h	(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
  *
@@ -155,4 +155,23 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
 
+/* PPP IPV6CP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
+
+#define NET_COUNT_PPP_IPV6CP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
+#define NET_COUNT_PPP_IPV6CP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
 /* PPP IPCP */
 
@@ -302,5 +321,5 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 /* ARP */
@@ -380,7 +399,25 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
 
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+/* IGMP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_IGMP
+
+#define NET_COUNT_IGMP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_igmp;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */
+
+#define NET_COUNT_IGMP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
 
 /* IPv6 */
@@ -472,5 +509,5 @@
 #endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(_IP6_CFG) */
 
 #ifdef SUPPORT_TCP
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_endian.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_endian.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_endian.h	(revision 331)
@@ -0,0 +1,209 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _NET_ENDIAN_H_
+#define _NET_ENDIAN_H_
+
+/*
+ *  ãã¤ããªã¼ãã®å®ç¾©
+ */
+
+#define _NET_CFG_LITTLE_ENDIAN	1234
+#define _NET_CFG_BIG_ENDIAN	4321
+
+#ifdef TARGET_KERNEL_ASP
+
+#if defined(SIL_ENDIAN_LITTLE)
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
+
+#elif defined(SIL_ENDIAN_BIG)
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
+
+#else	/* of #if defined(SIL_ENDIAN_BIG) */
+
+#error "SIL_ENDIAN expected."
+
+#endif	/* of #if defined(SIL_ENDIAN_BIG) */
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#if SIL_ENDIAN == SIL_ENDIAN_LITTLE
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
+
+#elif SIL_ENDIAN == SIL_ENDIAN_BIG	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
+
+#else	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#error "SIL_ENDIAN expected."
+
+#endif	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+/*
+ *  ãã¤ããªã¼ãå¤æã®å®ç¾©
+ */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define ntohs(n)		((uint16_t)n)
+#define htons(h)		((uint16_t)h)
+#define ntohl(n)		((uint32_t)n)
+#define htonl(h)		((uint32_t)h)
+
+#define NTOHS(n)
+#define HTONS(h)
+#define NTOHL(n)
+#define HTONL(h)
+
+/*
+ *  æ³¨æ: IPãããä»¥éã¯ã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã¦ããäºã
+ *        åæã¨ãã¦ãããã4 ãã¤ãå¢çã§ã¢ã¯ã»ã¹ãã
+ *        ãã­ã»ããµã§ããããã¯ã¼ã¯å´ã®ãã¼ã¿ãã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³
+ *        ããã¦ããªãå ´åã¯ãntoahlãahtonlãnahcmpl ãä½¿ç¨ãããã¨ã
+ */
+
+#define ntoahs(h,n)		memcpy((void*)&(h),(n),sizeof(uint16_t))
+#define ahtons(n,h)		memcpy((n),(void*)&(h),sizeof(uint16_t))
+#define ntoahl(h,n)		memcpy((void*)&(h),(n),sizeof(uint32_t))
+#define ahtonl(n,h)		memcpy((n),(void*)&(h),sizeof(uint32_t))
+
+#define nahcmpl(n,h)		memcmp((n),(void*)&(h),sizeof(uint32_t))
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#ifndef NET_REV_ENDIAN_HWORD
+
+#define NET_REV_ENDIAN_HWORD(d)	((uint16_t)((((uint16_t)(d)&0xff)<<8)|(((uint16_t)(d)>>8)&0xff)))
+
+#endif	/* of #ifndef NET_REV_ENDIAN_HWORD */
+
+#ifndef NET_REV_ENDIAN_WORD
+
+#define NET_REV_ENDIAN_WORD(d)	((uint32_t)((((uint32_t)(d)&0xff)<<24)|(((uint32_t)(d)&0xff00)<<8)| \
+				            (((uint32_t)(d)>>8)&0xff00)|(((uint32_t)(d)>>24)&0xff)))
+
+#endif	/* of #ifndef NET_REV_ENDIAN_WORD */
+
+#define ntohs(n)		NET_REV_ENDIAN_HWORD(n)
+#define htons(h)		NET_REV_ENDIAN_HWORD(h)
+#define ntohl(n)		NET_REV_ENDIAN_WORD(n)
+#define htonl(h)		NET_REV_ENDIAN_WORD(h)
+
+#define NTOHS(n)		((n)=NET_REV_ENDIAN_HWORD(n))
+#define HTONS(h)		((h)=NET_REV_ENDIAN_HWORD(h))
+#define NTOHL(n)		((n)=NET_REV_ENDIAN_WORD(n))
+#define HTONL(h)		((h)=NET_REV_ENDIAN_WORD(h))
+
+/*
+ *  æ³¨æ: IPãããä»¥éã¯ã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã¦ããäºã
+ *        åæã¨ãã¦ãããã4 ãã¤ãå¢çã§ã¢ã¯ã»ã¹ãã
+ *        ãã­ã»ããµã§ããããã¯ã¼ã¯å´ã®ãã¼ã¿ãã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³
+ *        ããã¦ããªãå ´åã¯ãntoahlãahtonlãnahcmpl ãä½¿ç¨ãããã¨ã
+ */
+
+#ifndef _MACRO_ONLY
+
+extern void rev_memcpy_word  (void *dst, void *src);
+extern void rev_memcpy_hword (void *dst, void *src);
+
+extern int  rev_memcmp_word (void *data1, void *data2);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#define ntoahs(h,n)		rev_memcpy_hword((void*)&(h),(n))
+#define ahtons(n,h)		rev_memcpy_hword((n),(void*)&(h))
+#define ntoahl(h,n)		rev_memcpy_word((void*)&(h),(n))
+#define ahtonl(n,h)		rev_memcpy_word((n),(void*)&(h))
+
+#define nahcmpl(n,h)		rev_memcmp_word((n),(void*)&(h))
+
+#else	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#error "_NET_CFG_BYTE_ORDER expected."
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifndef _NET_ENDIAN_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_jsp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_jsp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_jsp.cfg	(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
  *
@@ -127,5 +127,17 @@
 #endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
 
+#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_REASSM,
+		sizeof(T_NET_BUF6_REASSM),
+		NULL
+		});
+
+#else	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
 #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
 CRE_MPF(MPF_NET_BUF_REASSM, {
 		TA_TFIFO,
@@ -134,13 +146,7 @@
 		NULL
 		});
+
 #endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
 
-#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
-CRE_MPF(MPF_NET_BUF_REASSM, {
-		TA_TFIFO,
-		NUM_MPF_NET_BUF6_REASSM,
-		sizeof(T_NET_BUF6_REASSM),
-		NULL
-		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h	(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
  *
@@ -41,4 +41,13 @@
 /* net/ethernet.c */
 
+#define ether_input_task	_tinet_ether_input_task
+#define ether_get_ifnet		_tinet_ether_get_ifnet
+#define ether_in6_resolve_multicast	\
+				_tinet_ether_in6_resolve_multicast
+#define ether_srand		_tinet_ether_srand
+#define ether_output		_tinet_ether_output
+#define	ether_raw_output	_tinet_ether_raw_output
+#define ether_output_task	_tinet_ether_output_task
+
 #define ether_broad_cast_addr	_tinet_ether_broad_cast_addr
 #define ether_ipv4_addr_local	_tinet_ether_ipv4_addr_local
@@ -46,13 +55,6 @@
 				_tinet_ether_ipv4_addr_local_mask
 
-#define ether_raw_output	_tinet_ether_raw_output
-#define ether_output		_tinet_ether_output
 #define ether_in6_ifaddr	_tinet_ether_in6_ifaddr
 #define ether_in6_ifaddr_list	_tinet_ether_in6_ifaddr_list
-#define ether_in6_resolve_multicast	\
-				_tinet_ether_in6_resolve_multicast
-#define ether_input_task	_tinet_ether_input_task
-#define ether_get_ifnet		_tinet_ether_get_ifnet
-#define ether_output_task	_tinet_ether_output_task
 
 /* net/if.c */
@@ -93,5 +95,6 @@
 /* route_cfg.c */
 
-#define routing_tbl		_tinet_routing_tbl
+#define routing6_tbl		_tinet_routing6_tbl
+#define routing4_tbl		_tinet_routing4_tbl
 
 #ifdef SUPPORT_PPP
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_subr.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
  *
@@ -88,5 +88,10 @@
 #include <tinet_config.h>
 
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 
 /*
@@ -103,5 +108,5 @@
 net_rand (void)
 {
-	next = (next * 1103515245 + 12345) % (ULONG_C(0x7fffffff) + 1);
+	next = (next * 99991 + 12345) & ULONG_C(0x7fffffff);
 	return next;
 	}
@@ -114,5 +119,8 @@
 net_srand (uint32_t seed)
 {
-	next += seed;
+	SYSTIM now;
+
+	syscall(get_tim(&now));
+	next += now + seed + IF_SRAND();
 	}
 
@@ -186,5 +194,5 @@
 
 /*
- *  rev_memcpy_word -- 反転メモリコピー（4 バイト）
+ *  rev_memcpy_hword -- 反転メモリコピー（2 バイト）
  *
  *    バイト単位にアクセスする事により、
@@ -193,14 +201,12 @@
 
 void
-rev_memcpy_word (uint8_t *dst, uint8_t *src)
-{
-	*(dst    ) = *(src + 3);
-	*(dst + 1) = *(src + 2);
-	*(dst + 2) = *(src + 1);
-	*(dst + 3) = *(src    );
-	}
-
-/*
- *  rev_memcmp_word -- 反転メモリ比較（4 バイト）
+rev_memcpy_hword (void *dst, void *src)
+{
+	*((uint8_t*)dst    ) = *((uint8_t*)src + 1);
+	*((uint8_t*)dst + 1) = *((uint8_t*)src    );
+	}
+
+/*
+ *  rev_memcpy_word -- 反転メモリコピー（4 バイト）
  *
  *    バイト単位にアクセスする事により、
@@ -208,11 +214,27 @@
  */
 
+void
+rev_memcpy_word (void *dst, void *src)
+{
+	*((uint8_t*)dst    ) = *((uint8_t*)src + 3);
+	*((uint8_t*)dst + 1) = *((uint8_t*)src + 2);
+	*((uint8_t*)dst + 2) = *((uint8_t*)src + 1);
+	*((uint8_t*)dst + 3) = *((uint8_t*)src    );
+	}
+
+/*
+ *  rev_memcmp_word -- 反転メモリ比較（4 バイト）
+ *
+ *    バイト単位にアクセスする事により、
+ *    境界へのアラインの問題を解決する。
+ */
+
 int_t
-rev_memcmp_word (uint8_t *data1, uint8_t *data2)
+rev_memcmp_word (void *data1, void *data2)
 {
 	int_t	ix, diff;
 
-	for (ix = 4; ix -- > 0; ) {
-		diff = *(data1 + ix) -  *(data2 + (3 - ix));
+	for (ix = sizeof(uint32_t); ix -- > 0; ) {
+		diff = *((uint8_t*)data1 + ix) -  *((uint8_t*)data2 + (3 - ix));
 		if (diff != 0)
 			return diff;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.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
  *
@@ -90,13 +90,12 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
 
 #include <netinet/in.h>
+#include <netinet/in_var.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/tcp_timer.h>
 
 /*
@@ -162,5 +161,5 @@
 "\n"
 "TINET %d.%d.%d (" __DATE__ ", " __TIME__ ")\n"
-"Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering\n"
+"Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering\n"
 "                    Tomakomai National College of Technology, JAPAN\n";
 
@@ -181,5 +180,12 @@
 
 	/* IP を初期化する。*/
-	IP_INIT();
+
+#if defined(_IP6_CFG)
+	ip6_init();
+#endif
+
+#if defined(_IP4_CFG)
+	ip_init();
+#endif
 
 #ifdef SUPPORT_TCP
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_timer.h	(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
  *
@@ -74,5 +74,5 @@
  */
 
-#define SYSTIM_HZ		ULONG_C(1000*1000)	/* [ms]					*/
+#define SYSTIM_HZ		ULONG_C(1000000)	/* [us]					*/
 
 /*
@@ -80,9 +80,9 @@
  */
 
-#define NET_TIMER_CYCLE		ULONG_C(100)	/* [ms]、fast timeout 使用時の動作周期	*/
+#define NET_TIMER_CYCLE		ULONG_C(100000)	/* [us]、fast timeout 使用時の動作周期	*/
 						/* タイマの周波数			*/
 #define NET_TIMER_HZ		(SYSTIM_HZ/NET_TIMER_CYCLE)
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 #define NUM_NET_CALLOUT		12		/* タイムアウト呼出し数、10 以上	*/
 #else
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_var.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.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
  *
@@ -81,4 +81,6 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -89,4 +91,5 @@
 #include <net/ppp_fsm.h>
 #include <net/ppp_lcp.h>
+#include <net/ppp_ipv6cp.h>
 #include <net/ppp_ipcp.h>
 #include <net/ppp_ccp.h>
@@ -108,17 +111,24 @@
 T_PPP_PROTENT *protocols[] = {
 	&lcp_protent,
+
+#ifdef _IP6_CFG
+	&ipv6cp_protent,
+#endif	/* of #ifdef _IP6_CFG */
+
+#ifdef _IP4_CFG
 	&ipcp_protent,
+#endif	/* of #ifdef _IP4_CFG */
 
 #ifdef SUPPORT_CCP
 	&ccp_protent,
-#endif	/* #ifdef SUPPORT_CCP */
+#endif	/* of #ifdef SUPPORT_CCP */
 
 #ifdef LCP_CFG_PAP
 	&pap_protent,
-#endif	/* #ifdef LCP_CFG_PAP */
+#endif	/* of #ifdef LCP_CFG_PAP */
 
 #ifdef LCP_CFG_CHAP
 	&chap_protent,
-#endif	/* #ifdef LCP_CFG_CHAP */
+#endif	/* of #ifdef LCP_CFG_CHAP */
 
 	NULL
@@ -223,7 +233,21 @@
 #endif	/* of #ifdef PPP_CFG_MODEM */
 
+#ifdef _IP6_CFG
+	/* IPV6CP の接続完了まで待つ。*/
+	if ((error = wait_ipv6cp()) != E_OK)
+		goto buf_ret;
+#endif	/* of #ifdef _IP6_CFG */
+
+#ifdef _IP4_CFG
 	/* IPCP の接続完了まで待つ。*/
 	if ((error = wait_ipcp()) != E_OK)
 		goto buf_ret;
+#endif	/* of #ifdef _IP4_CFG */
+
+#ifdef _IP4_CFG
+	/* IPCP の接続完了まで待つ。*/
+	if ((error = wait_ipcp()) != E_OK)
+		goto buf_ret;
+#endif	/* of #ifdef _IP4_CFG */
 
 #ifdef PPP_IDLE_TIMEOUT
@@ -290,4 +314,5 @@
 	ID		tskid;
 	int_t		ix;
+	uint8_t		rcount = 0;
 
 	/* ポートを初期設定する */
@@ -321,4 +346,7 @@
 	/* PPP 出力タスクを起動する */
 	syscall(act_tsk(PPP_OUTPUT_TASK));
+
+	/* 乱数生成を初期化する。*/
+	net_srand(0);
 
 	while (true) {
@@ -328,5 +356,10 @@
 			if (input->len > 0) {
 
-	#ifdef PPP_IDLE_TIMEOUT
+				/* 乱数生成を初期化する。*/
+				if (rcount == 0)
+					net_srand(input->len);
+				rcount ++;
+
+#ifdef PPP_IDLE_TIMEOUT
 				wai_sem(SEM_IDLE_TIMEOUT);
 				if (idle && ntohs(*GET_PPP_HDR(input)) != PPP_LCP) {
@@ -335,5 +368,5 @@
 					}
 				sig_sem(SEM_IDLE_TIMEOUT);
-	#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
 
 				parse_input(input);
@@ -342,5 +375,5 @@
 				syscall(rel_net_buf(input));
 
-	#ifdef PPP_IDLE_TIMEOUT
+#ifdef PPP_IDLE_TIMEOUT
 			wai_sem(SEM_IDLE_TIMEOUT);
 			if (!idle && ppp_phase == PPP_PHASE_NETWORK) {
@@ -353,5 +386,5 @@
 				}
 			sig_sem(SEM_IDLE_TIMEOUT);
-	#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
 
 			}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.cfg	(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
  *
@@ -56,11 +56,18 @@
 	});
 
-CRE_DTQ(DTQ_PPP_OUTPUT,  { TA_TFIFO, NUM_DTQ_PPP_OUTPUT,  NULL });
+CRE_DTQ(DTQ_PPP_OUTPUT,   { TA_TFIFO, NUM_DTQ_PPP_OUTPUT,  NULL });
 
-CRE_SEM(SEM_MODEM_READY, { TA_TPRI, 0, 1 });
-CRE_SEM(SEM_IPCP_READY,  { TA_TPRI, 0, 1 });
+CRE_SEM(SEM_MODEM_READY,  { TA_TPRI, 0, 1 });
+
+#if defined(_IP6_CFG)
+CRE_SEM(SEM_IPV6CP_READY, { TA_TPRI, 0, 1 });
+#endif
+
+#if defined(_IP4_CFG)
+CRE_SEM(SEM_IPCP_READY,   { TA_TPRI, 0, 1 });
+#endif
 
 #ifdef PPP_IDLE_TIMEOUT
-CRE_SEM(SEM_IDLE_TIMEOUT,{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_IDLE_TIMEOUT, { TA_TPRI, 1, 1 });
 #endif	/* of #ifdef PPP_IDLE_TIMEOUT */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp.h	(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
  *
@@ -74,13 +74,15 @@
  */
 
-#define PPP_IP		UINT_C(0x0021)		/* IP   */
+#define PPP_IP		UINT_C(0x0021)		/* IPv4		*/
+#define PPP_IPV6	UINT_C(0x0057)		/* IPv6		*/
 
-#define PPP_IPCP	UINT_C(0x8021)		/* IPCP */
-#define PPP_CCP		UINT_C(0x80fd)		/* CCP */
+#define PPP_IPCP	UINT_C(0x8021)		/* IPCP		*/
+#define PPP_IPV6CP	UINT_C(0x8057)		/* IPV6CP	*/
+#define PPP_CCP		UINT_C(0x80fd)		/* CCP		*/
 
-#define PPP_LCP		UINT_C(0xc021)		/* LCP  */
-#define PPP_PAP		UINT_C(0xc023)		/* PAP  */
-#define PPP_LQR		UINT_C(0xc025)		/* LQR  */
-#define PPP_CHAP	UINT_C(0xc223)		/* CHAP */
+#define PPP_LCP		UINT_C(0xc021)		/* LCP		*/
+#define PPP_PAP		UINT_C(0xc023)		/* PAP		*/
+#define PPP_LQR		UINT_C(0xc025)		/* LQR		*/
+#define PPP_CHAP	UINT_C(0xc223)		/* CHAP		*/
 
 #define GET_PPP_HDR(nbuf)	((T_PPP_HDR*)((nbuf)->buf))
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.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
  *
@@ -100,4 +100,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/ppp.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_auth.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.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
  *
@@ -93,5 +93,4 @@
 #include <net/if_ppp.h>
 #include <net/net_buf.h>
-#include <net/net_debug.h>
 #include <net/net_count.h>
 #include <net/ppp.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ccp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.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
  *
@@ -86,4 +86,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_timer.h>
 #include <net/net_buf.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_fsm.h	(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
  *
@@ -96,5 +96,5 @@
 	int8_t		retrans;	/* Configure-Request または、		*/
 					/* Terminate-Request の再送回数		*/
-	} __attribute__((packed, aligned(2)))T_PPP_FSM;
+	} T_PPP_FSM;
 
 #define T_PPP_FSM_DEFINED
@@ -124,5 +124,5 @@
 					/* 不明な CP を受信したときの処理	*/
 	bool_t  (*extcode)(T_PPP_FSM *, uint8_t, uint8_t, T_NET_BUF *);
-	} __attribute__((packed, aligned(2)))T_PPP_FSM_CALLBACKS;
+	} T_PPP_FSM_CALLBACKS;
 
 /*
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.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
  *
@@ -65,4 +65,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_hdlc.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.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
  *
@@ -89,4 +89,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -102,6 +103,6 @@
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
 #include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
 #include <netinet/udp_var.h>
 
@@ -149,5 +150,5 @@
 	NULL,
 	{
-		IPV4_ADDR_LOCAL,		/* IP アドレス			*/
+		IPV4_ADDR_LOCAL,		/* IPv4 アドレス			*/
 		UINT_C(0),			/* サブネットマスク		*/
 		},
@@ -157,5 +158,5 @@
 	NULL,
 	{
-		IPV4_ADDR_REMOTE,		/* IP アドレス			*/
+		IPV4_ADDR_REMOTE,		/* IPv4 アドレス			*/
 		UINT_C(0),			/* サブネットマスク		*/
 		}
@@ -200,5 +201,5 @@
 	ipcp_open,			/* オープンする			*/
 	ipcp_close,			/* クローズする			*/
-	ip_input,			/* データ入力、IP 入力		*/
+	ip_input,			/* データ入力、IPv4 入力	*/
 	};
 
@@ -307,5 +308,5 @@
 	int_t cilen = 0;
 
-	cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* IP アドレス */
+	cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* IPv4 アドレス */
 
 	return cilen;
@@ -323,8 +324,8 @@
 	buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
 
-	/* IP アドレスオプションを追加する。 */
+	/* IPv4 アドレスオプションを追加する。 */
 	*buf ++ = IPCP_CIT_ADDR;
 	*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
-	ahtonl(buf, ipcp_local_neg_cfg.in_ifaddr.addr);
+	ahtonl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr);
 	buf += sizeof(uint32_t);
 	}
@@ -355,5 +356,5 @@
 	    *buf ++ != IPCP_CIT_ADDR			||
 	    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
-	    nahcmpl(buf, ipcp_local_neg_cfg.in_ifaddr.addr))
+	    nahcmpl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr))
 		return false;
 	buf += sizeof(uint32_t);
@@ -390,5 +391,5 @@
 		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
 		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
-		new_cfg.in_ifaddr.addr = cilong;
+		new_cfg.in4_ifaddr.addr = cilong;
 		}
 
@@ -438,5 +439,5 @@
 		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
 		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
-		new_cfg.in_ifaddr.addr = 0;
+		new_cfg.in4_ifaddr.addr = 0;
 		}
 
@@ -499,5 +500,5 @@
 		switch (type) {
 
-		case IPCP_CIT_ADDR:	/* IP アドレス */
+		case IPCP_CIT_ADDR:	/* IPv4 アドレス */
 
 		 	/* CI 長が、ヘッダ + 4 オクテットでなければエラー */
@@ -506,20 +507,20 @@
 			else {
 				ntoahl(addr, ap);
-				if (addr != ipcp_remote_neg_cfg.in_ifaddr.addr &&
-				    (addr == 0 || ipcp_remote_neg_cfg.in_ifaddr.addr != 0)) {
+				if (addr != ipcp_remote_neg_cfg.in4_ifaddr.addr &&
+				    (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr != 0)) {
 					*np ++ = IPCP_CIT_ADDR;
 					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
-					ahtonl(np, ipcp_remote_neg_cfg.in_ifaddr.addr);
+					ahtonl(np, ipcp_remote_neg_cfg.in4_ifaddr.addr);
 					np  += sizeof(uint32_t);
 					code = PPP_CONFNAK;
 					}
 #if 1	/* 要確認 */
-				else if (addr == 0 && ipcp_remote_neg_cfg.in_ifaddr.addr == 0)
+				else if (addr == 0 && ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
 #else
-				else if (addr == 0 || ipcp_remote_neg_cfg.in_ifaddr.addr == 0)
+				else if (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
 #endif
 					code = PPP_CONFREJ;
 				else
-					ipcp_remote_neg_cfg.in_ifaddr.addr = addr;
+					ipcp_remote_neg_cfg.in4_ifaddr.addr = addr;
 				}
 			break;
@@ -582,7 +583,7 @@
 	/*
 	 *  サブネットマスクと
-	 *  ローカル・ブロードキャスト IP アドレスを設定する。
+	 *  ローカル・ブロードキャスト IPv4 アドレスを設定する。
 	 */
-	ipcp_local_ack_cfg.in_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in_ifaddr.addr);
+	ipcp_local_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in4_ifaddr.addr);
 
 	/* 相手の構成情報の初期設定 */
@@ -591,13 +592,13 @@
 	/*
 	 *  サブネットマスクと
-	 *  ローカル・ブロードキャスト IP アドレスを設定する。
+	 *  ローカル・ブロードキャスト IPv4 アドレスを設定する。
 	 */
-	ipcp_remote_ack_cfg.in_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in_ifaddr.addr);
+	ipcp_remote_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in4_ifaddr.addr);
 
 	sig_sem(SEM_IPCP_READY);
 
-	syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IP Addr: %s, Remote IP Addr: %s.",
-	                   ip2str(NULL, &ipcp_local_neg_cfg.in_ifaddr.addr),
-	                   ip2str(NULL, &ipcp_remote_neg_cfg.in_ifaddr.addr));
+	syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IPv4 Addr: %s, Remote IPv4 Addr: %s.",
+	                   ip2str(NULL, &ipcp_local_neg_cfg.in4_ifaddr.addr),
+	                   ip2str(NULL, &ipcp_remote_neg_cfg.in4_ifaddr.addr));
 	}
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipcp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.c	(revision 331)
@@ -0,0 +1,713 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipv6cp.c - PPP IP Control Protocol.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	PPP IP Control Protocol (IPV6CP) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipv6cp.c,v 1.90.2.4 2000/08/19 09:30:03 brian Exp $
+ *
+ *	TODO:
+ *		o Support IPADDRS properly
+ *		o Validate the length in IpcpDecodeConfig
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_ipv6cp.h>
+#include <net/ppp_modem.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+static void ipv6cp_init (void);
+static void ipv6cp_input (T_NET_BUF *input);
+static void ipv6cp_protrej (void);
+static void ipv6cp_lowerup (void);
+static void ipv6cp_lowerdown (void);
+static void ipv6cp_open (void);
+static void ipv6cp_close (void);
+
+/*
+ * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢
+ */
+
+static void  ipv6cp_resetci(T_PPP_FSM *fsm);	/* èªæ§ææ
+å ±ããªã»ããããã	*/
+static int_t ipv6cp_cilen	(T_PPP_FSM *fsm);	/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+static void  ipv6cp_addci	(T_PPP_FSM *fsm, T_NET_BUF *output);
+						/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+static bool_t  ipv6cp_ackci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipv6cp_nakci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipv6cp_rejci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+static int_t ipv6cp_reqci	(T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output);
+						/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+static void ipv6cp_up	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+static void ipv6cp_down	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+static void ipv6cp_finished(T_PPP_FSM *fsm);	/* ä¸ä½å±¤ãçµäºããã		*/
+
+/*
+ *  å¤æ°
+ */
+
+static T_IFNET ipv6cp_local_def_cfg = {		/* èªæ§ææ
+å ±ã®è¦å®å¤		*/
+	NULL,					/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{},					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	{},					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	0,					/* ãã©ã°					*/
+	};
+
+static T_IFNET ipv6cp_remote_def_cfg = {	/* ç¸æã®æ§ææ
+å ±ã®è¦å®å¤	*/
+	NULL,					/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{},					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	{},					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	0,					/* ãã©ã°					*/
+	};
+
+static T_IFNET ipv6cp_local_neg_cfg;		/* ãã´ä¸­ã®èªæ§ææ
+å ±		*/
+
+static T_IFNET ipv6cp_remote_neg_cfg;		/* ãã´ä¸­ã®ç¸æã®æ§ææ
+å ±		*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_FSM_CALLBACKS ipv6cp_callbacks = {
+	ipv6cp_resetci,			/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	ipv6cp_cilen,			/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	ipv6cp_addci,			/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	ipv6cp_ackci,			/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_nakci,			/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_rejci,			/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_reqci,			/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	ipv6cp_up,			/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+	ipv6cp_down,			/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+	NULL,				/* ä¸ä½å±¤ãéå§ããã		*/
+	ipv6cp_finished,			/* ä¸ä½å±¤ãçµäºããã		*/
+	NULL,				/* åéããã			*/
+	NULL,				/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	};
+
+T_PPP_FSM ipv6cp_fsm = {
+	&ipv6cp_callbacks,		/* ã³ã¼ã«ããã¯é¢æ°		*/
+	PPP_IPV6CP,			/* ãã­ãã³ã«			*/
+	};
+
+T_PPP_PROTENT ipv6cp_protent = {
+	PPP_IPV6CP,
+	ipv6cp_init,			/* åæå			*/
+	ipv6cp_input,			/* å
+¥å				*/
+	ipv6cp_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	ipv6cp_lowerup,			/* ä¸ä½å±¤ãèµ·åãã		*/
+	ipv6cp_lowerdown,		/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	ipv6cp_open,			/* ãªã¼ãã³ãã			*/
+	ipv6cp_close,			/* ã¯ã­ã¼ãºãã			*/
+	ip6_input,			/* ãã¼ã¿å
+¥åãIPv6 å
+¥å	*/
+	};
+
+T_IFNET ipv6cp_local_ack_cfg;		/* ç¸æã«è¨±å¯ãããã®èªæ§ææ
+å ±	*/
+T_IFNET ipv6cp_remote_ack_cfg;		/* ç¸æã«è¨±å¯ããæ§ææ
+å ±	*/
+
+/*
+ *  ppp_get_ifnet -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã
+ */
+
+T_IFNET *
+ppp_get_ifnet (void)
+{
+	return &ipv6cp_local_ack_cfg;
+	}
+
+/*
+ *  wait_ipv6cp -- IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã
+ *
+ *	æ»ãå¤: æ¥ç¶ã«å¤±æããã E_OBJ ãè¿ãã
+ */
+
+ER
+wait_ipv6cp (void)
+{
+#ifdef PPP_CFG_MODEM
+	ER error;
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+	if (ipv6cp_fsm.state <= PPP_FSM_STOPPED) {
+
+#ifdef PPP_CFG_MODEM
+
+		/* ã¢ãã ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		if ((error = wait_modem()) != E_OK)
+			return error;
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+		/*
+		 * ååãªã¼ãã³ããç¸æããã®æ¥ç¶å¾
+ã¡ãªã LCP ãä¸åº¦ã¯ã­ã¼ãºãã
+		 * è½åãªã¼ãã³ç¶æ
+ã§ãåãªã¼ãã³ããã
+		 */
+		lcp_close();
+		lcp_open(PPP_OPEN_ACTIVE);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+		}
+
+	if (ipv6cp_fsm.state != PPP_FSM_OPENED) {
+		/* IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		wai_sem(SEM_IPV6CP_READY);
+		if (ipv6cp_fsm.state != PPP_FSM_OPENED)
+			return E_OBJ;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  ipv6cp_init -- IPV6CP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+ipv6cp_init (void)
+{
+	fsm_init(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_input -- IPV6CP å
+¥å
+ */
+
+static void
+ipv6cp_input (T_NET_BUF *input)
+{
+	NET_COUNT_PPP_IPV6CP(net_count_ppp_ipv6cp_in_octets,  input->len);
+	NET_COUNT_PPP_IPV6CP(net_count_ppp_ipv6cp_in_packets, 1);
+	fsm_input(&ipv6cp_fsm, input);
+	}
+
+/*
+ *  ipv6cp_resetci -- IPV6CPã®æ§ææ
+å ±ããªã»ããããã
+ */
+
+static void
+ipv6cp_resetci (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_local_neg_cfg = ipv6cp_local_def_cfg;
+	memset((void*)&ipv6cp_local_ack_cfg, 0, sizeof(T_IFNET));
+
+	/* ç¸æã®æ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_remote_neg_cfg = ipv6cp_remote_def_cfg;
+	memset((void*)&ipv6cp_remote_ack_cfg, 0, sizeof(T_IFNET));
+	}
+
+/*
+ *  ipv6cp_cilen -- æ§ææ
+å ±ã®é·ããè¿ãã
+ */
+
+static int_t
+ipv6cp_cilen (T_PPP_FSM *fsm)
+{
+	int_t cilen = 0;
+
+	cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* IPv6 ã¢ãã¬ã¹ */
+
+	return cilen;
+	}
+
+/*
+ *  ipv6cp_addci -- IPV6CPã®æ§ææ
+å ±ãè¿½å ããã
+ */
+
+static void
+ipv6cp_addci (T_PPP_FSM *fsm, T_NET_BUF *output)
+{
+	uint8_t *buf;
+
+	buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/* IPv6 ã¢ãã¬ã¹ãªãã·ã§ã³ãè¿½å ããã */
+	*buf ++ = IPV6CP_CIT_ADDR;
+	*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+	ahtonl(buf, ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr);
+	buf += sizeof(uint32_t);
+	}
+
+/*
+ *  ipv6cp_ackci -- ACK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	true  ACK ã¯æ­£å¸¸
+ *		false ACK ã¯ç°å¸¸
+ */
+
+static bool_t
+ipv6cp_ackci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	/*
+	 *  æ§ææ
+å ±ã¯éä¿¡ããé ã«å®å
+¨ã«ä¸è´ããªããã°ãªããªãã
+	 *  å¾ã£ã¦ãipv6cp_addci ã§ä½æããé ã«è§£æããã
+	 */
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	||
+	    *buf ++ != IPV6CP_CIT_ADDR			||
+	    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
+	    nahcmpl(buf, ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr))
+		return false;
+	buf += sizeof(uint32_t);
+	len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+
+	return true;
+	}
+
+/*
+ *  ipv6cp_nakci -- NAK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  NAK ã¯æ­£å¸¸
+ *		0  NAK ã¯ç°å¸¸
+ */
+
+static int_t
+ipv6cp_nakci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint32_t	addr;
+	uint16_t	len;
+	uint8_t		*buf, cilen;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipv6cp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(addr)		&&
+	    * buf      == IPV6CP_CIT_ADDR			&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(addr)) {
+		memcpy(&new_cfg.in6_ifaddrs[0].addr, buf + 2, sizeof(addr));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(addr);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(addr);
+		}
+
+	/* å¾ã¯ç¡è¦ããã*/
+	while (len > sizeof(T_PPP_CI_HDR)) {
+		cilen = *(buf + 1);
+		if (len < cilen)
+			return 0;
+		buf += cilen;
+		len -= cilen;
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipv6cp_local_neg_cfg = new_cfg;
+               		
+	return 1;
+	}
+
+/*
+ *  ipv6cp_rejci -- REJ ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  REJ ã¯æ­£å¸¸
+ *		0  REJ ã¯ç°å¸¸
+ */
+
+static int_t
+ipv6cp_rejci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipv6cp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr)	&&
+	    * buf      == IPV6CP_CIT_ADDR					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr)) {
+		memcpy(&new_cfg.in6_ifaddrs[0].addr, &in6_addr_unspecified,
+		 sizeof(new_cfg.in6_ifaddrs[0].addr));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr);
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipv6cp_local_neg_cfg = new_cfg;
+
+	return 1;
+	}
+
+/*
+ *  ipv6cp_reqci -- ç¸æã®æ§ææ
+å ±ãè§£æããã
+ */
+
+static int_t
+ipv6cp_reqci (T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output)
+{
+	T_IN6_ADDR	addr;
+	uint16_t	code, final, len, cilen;
+	uint8_t		*np, *rp, *ap, *cp, type = 0;
+
+	rp = ap = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+				/* rp: REJãap: ACK ãã CI ã®ãã¤ã³ã¿	*/
+				/* æå¦ããå ´åã¯ãå¼æ° buf ã«ä¸æ¸ãããã	*/
+	len   = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	np    = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	final = PPP_CONFACK;	/* æçµçã«éä¿¡ããã³ã¼ã */
+	while (len > 0) {
+		code = PPP_CONFACK;
+		cp   = ap;	/* cp: ç¾å¨å¦çä¸­ã® CI	*/
+
+		if (len < sizeof(T_PPP_CI_HDR)) {
+
+			/* æ®ãã CI ãããããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPV6CP] bad CI len: %d.", len);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+
+		type  = *ap ++;	/* CI ã®å		*/
+		cilen = *ap ++;	/* CI ã®é·ã		*/
+		if (len < cilen) {
+
+			/* æ®ãã CI é·ããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPV6CP] bad CI len: %d.", cilen);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+		len -= sizeof(T_PPP_CI_HDR);
+
+		/* CI ã®åã«ããåå²ããã*/
+		switch (type) {
+
+		case IPV6CP_CIT_ADDR:	/* IPv6 ã¢ãã¬ã¹ */
+
+		 	/* CI é·ããããã + 4 ãªã¯ãããã§ãªããã°ã¨ã©ã¼ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(addr))
+				code = PPP_CONFREJ;
+			else {
+				memcpy((uint8_t*)&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr, ap,
+				           sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+				if (!IN6_ARE_ADDR_EQUAL(&addr, &ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr) &&
+				    (IN6_IS_ADDR_UNSPECIFIED(&addr) ||
+				     IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr))) {
+					memcpy(np, (uint8_t*)&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr,
+					               sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+					*np ++ = IPV6CP_CIT_ADDR;
+					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+					np    += sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr);
+					code = PPP_CONFNAK;
+					}
+#if 1	/* è¦ç¢ºèª */
+				else if (IN6_IS_ADDR_UNSPECIFIED(&addr) &&
+				         IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0]))
+#else
+				else if (IN6_IS_ADDR_UNSPECIFIED(&addr) ||
+				         IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0]))
+#endif
+					code = PPP_CONFREJ;
+				else
+					ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr = addr;
+				}
+			break;
+
+		default:
+			syslog(LOG_INFO, "[PPP/IPV6CP] unexp opt: %d.", type);
+			code = PPP_CONFREJ;
+			break;
+			}
+endswitch:
+
+		if (code == PPP_CONFNAK) {
+			/* CI ã®åã Magic Number ã®å ´åãé¤ãã¦ãNAK ã®åæ°ã	*/
+			/* æå¤§å¤ MAX_PPP_FAILURES  ãè¶
+ãããæå¦ããã	*/
+			if (fsm->failures >= MAX_PPP_FAILURES)
+				code = PPP_CONFREJ;
+			else if (final != PPP_CONFREJ)
+				final = PPP_CONFNAK;
+			}
+
+		/* ãã® CI ãæå¦ãã */
+		if (code == PPP_CONFREJ) {
+			if (rp < cp)		/* åã«è©°ããã*/
+				memcpy(rp, cp, cilen);
+			rp += cilen;
+			final = PPP_CONFREJ;
+			}
+
+		ap   += cilen - sizeof(T_PPP_CI_HDR);
+		len  -= cilen - sizeof(T_PPP_CI_HDR);
+		}
+
+	/* æçµçãªé·ããèª¿æ´ããã*/
+	switch (final) {
+	case PPP_CONFNAK:
+		output->len = np - output->buf;
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		break;
+	case PPP_CONFREJ:
+		memcpy(output->buf, input->buf, output->len = rp - input->buf);
+		break;
+	case PPP_CONFACK:
+		memcpy(output->buf, input->buf, input->len);
+		break;
+		}
+
+	return final;
+	}
+
+/*
+ *  ipv6cp_up -- ãªã³ã¯æ¥ç¶ãç¢ºç«ããã
+ */
+
+static void
+ipv6cp_up (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_local_ack_cfg = ipv6cp_local_neg_cfg;
+
+	sig_sem(SEM_IPV6CP_READY);
+
+	syslog(LOG_NOTICE, "[PPP/IPV6CP] up, Local IPv6 Addr: %s, Remote IPv6 Addr: %s.",
+	                   ipv62str(NULL, &ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr),
+	                   ipv62str(NULL, &ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+	}
+
+/*
+ *  ipv6cp_down -- ãªã³ã¯æ¥ç¶ãè§£æ¾ããã
+ */
+
+static void
+ipv6cp_down (T_PPP_FSM *fsm)
+{
+	sig_sem(SEM_IPV6CP_READY);
+	syslog(LOG_NOTICE, "[PPP/IPV6CP] down.");
+	}
+
+/*
+ *  ipv6cp_finished -- ä¸ä½å±¤ãçµäºããã
+ */
+
+static void
+ipv6cp_finished (T_PPP_FSM *fsm)
+{
+	}
+
+/*
+ *  ipv6cp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+ipv6cp_protrej (void)
+{
+	fsm_lowerdown(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_lowerup -- IPV6CP ä¸ä½å±¤ãèµ·åããã
+ */
+
+static void
+ipv6cp_lowerup (void)
+{
+	fsm_lowerup(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_lowerdown -- IPV6CP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+static void
+ipv6cp_lowerdown (void)
+{
+	fsm_lowerdown(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_open -- IPV6CP ã®ãªã¼ãã³
+ */
+
+static void
+ipv6cp_open (void)
+{
+	fsm_open(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_close -- IPV6CP ã®ã¯ã­ã¼ãº
+ */
+
+static void
+ipv6cp_close (void)
+{
+	fsm_close(&ipv6cp_fsm);
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_ipv6cp.h	(revision 331)
@@ -0,0 +1,143 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipv6cp.h - IP Control Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/ipv6cp.h,v 1.9.2.1 1999/08/29 15:47:01 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipv6cp.h,v 1.30.2.2 2000/06/15 17:08:28 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_IPV6CP_H_
+#define _PPP_IPV6CP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  IPV6CP ã®æ§ææ
+å ± (CI)
+ */
+
+/*
+ *  CI ã®å
+ */
+
+#define IPV6CP_CIT_ADDRS		UINT_C(1)	/* IP ã¢ãã¬ã¹ (å»æ£)	*/
+#define IPV6CP_CIT_COMP_TYPE	UINT_C(2)	/* å§ç¸®æ¹å¼		*/
+#define IPV6CP_CIT_ADDR		UINT_C(3)	/* IP ã¢ãã¬ã¹		*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef T_PPP_FSM_DEFINED
+extern T_PPP_FSM	ipv6cp_fsm;
+#endif	/* of #ifdef T_PPP_FSM_DEFINED */
+
+#ifdef T_PPP_PROTENT_DEFINED
+extern T_PPP_PROTENT	ipv6cp_protent;
+#endif	/* of #ifdef T_PPP_PROTENT_DEFINED */
+
+extern T_IFNET	ipv6cp_local_ack_cfg;
+extern T_IFNET	ipv6cp_remote_ack_cfg;
+
+/*
+ *  é¢æ°
+ */
+
+extern ER wait_ipv6cp (void);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_IPV6CP_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.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
  *
@@ -86,4 +86,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_lcp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.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
  *
@@ -47,4 +47,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_modem.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.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
  *
@@ -87,4 +87,5 @@
 #include <net/if_ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_upap.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ppp_var.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/route.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/route.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/route.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/tinet.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/tinet.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/tinet.h	(revision 331)
@@ -0,0 +1,59 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_H_
+#define _TINET_H_
+
+#if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
+
+/*
+ *  TINET ç¬èªé¢æ°
+ */
+
+extern char *mac2str (char *buf, uint8_t *macaddr);
+
+#endif /* #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY) */
+
+#endif	/* of #ifndef _TINET_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp	(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
 # 
@@ -50,11 +50,25 @@
 
 TINET_ROOT = $(SRCDIR)/tinet
-NETAPP_DIR = $(TINET_ROOT)/netapp
+NETAPP_DIRS = $(TINET_ROOT)/netapp
 NETAPP_COBJS := $(NETAPP_COBJS) netapp_subr.o
 
+ifeq ($(USE_LCD),true)
+
+	NETAPP_COBJS := $(NETAPP_COBJS) lcd.o
+
+ifeq ($(TARGET_KERNEL),ASP)
+	NETAPP_COBJS := $(NETAPP_COBJS) target_lcd.o sc1602.o
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+	NETAPP_COBJS := $(NETAPP_COBJS) hw_lcd.o sc1602.o
+endif
+
+endif
+
 #  トランスポート層の選択
 
-SUPPORT_TCP = false
-SUPPORT_UDP = false
+#SUPPORT_TCP = false
+#SUPPORT_UDP = false
 
 # 
@@ -62,37 +76,87 @@
 # 
 
+ifeq ($(USE_WWW4_SRV),true)
+	USE_WWW_SRV = true
+	CDEFS := $(CDEFS) -DUSE_WWW4_SRV
+endif
+
 ifeq ($(USE_WWW_SRV),true)
-	SUPPORT_TCP = true
-	TCP_CFG_PASSIVE_OPEN = true
+
+	SUPPORT_TCP = true
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_WWW_SRV
 	NETAPP_COBJS := $(NETAPP_COBJS) wwws.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/wwws.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/wwws.cfg
+
+endif
+
+ifeq ($(USE_TCP4_ECHO_SRV),true)
+	TCP_ECHO_SRV = tcp_echo_srv1
+	CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_SRV
 endif
 
 ifeq ($(TCP_ECHO_SRV),tcp_echo_srv1)		# 送受信タスク同一型
-	SUPPORT_TCP = true
-	TCP_CFG_PASSIVE_OPEN = true
+
+	SUPPORT_TCP = true
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV1
 	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv1.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv1.cfg
+
+	ifeq ($(USE_TCP_NON_BLOCKING),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_nblk.o
+	endif
+
+	ifeq ($(USE_TCP_EXTENTIONS),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_ext.o
+	endif
+
 endif
 
 ifeq ($(TCP_ECHO_SRV),tcp_echo_srv2)		# 送受信タスク分離型
 	SUPPORT_TCP = true
-	TCP_CFG_PASSIVE_OPEN = true
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV2
 	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv2.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_srv2.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv2.cfg
+endif
+
+ifeq ($(USE_UDP4_ECHO_SRV),true)
+	USE_UDP_ECHO_SRV = true
 endif
 
 ifeq ($(USE_UDP_ECHO_SRV),true)
-	SUPPORT_UDP = true
-	USE_NETAPP_SUBR = true
+
 	CDEFS := $(CDEFS) -DUSE_UDP_ECHO_SRV
-	NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_srv.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_srv.cfg
+
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		USE_NETAPP_SUBR = true
+		CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_SRV_TSK
+		NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_srv.o
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_srv.cfg
+
+		ifeq ($(SUPPORT_INET4),true)
+			ifeq ($(USE_UDP4_ECHO_SRV),true)
+				CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
+				NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
+				NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
+			endif
+		endif
+	else
+		ifeq ($(SUPPORT_INET4),true)
+			SUPPORT_UDP = true
+			USE_NETAPP_SUBR = true
+			CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
+			NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
+			NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
+		endif
+	endif
+endif
+
+
+ifeq ($(USE_TCP4_ECHO_CLI),true)
+	USE_TCP_ECHO_CLI = true
+	CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_CLI
 endif
 
@@ -101,23 +165,48 @@
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_CLI
-	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_echo_cli.cfg
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o tcp_echo_cli_snd.o tcp_echo_cli_rcv.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_cli.cfg
+endif
+
+ifeq ($(USE_UDP4_ECHO_CLI),true)
+	USE_UDP_ECHO_CLI = true
 endif
 
 ifeq ($(USE_UDP_ECHO_CLI),true)
-	SUPPORT_UDP = true
-	USE_NETAPP_SUBR = true
+
 	CDEFS := $(CDEFS) -DUSE_UDP_ECHO_CLI
-	NETAPP_COBJS := $(NETAPP_COBJS) udp_echo_cli.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_echo_cli.cfg
+
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		USE_NETAPP_SUBR = true
+		CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_CLI_TSK
+		NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg
+	
+		ifeq ($(SUPPORT_INET4),true)
+			ifeq ($(USE_UDP4_ECHO_CLI),true)
+				CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
+				NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
+				NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
+			endif
+		endif
+        else
+		ifeq ($(SUPPORT_INET4),true)
+			SUPPORT_UDP = true
+			USE_NETAPP_SUBR = true
+			CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
+			NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
+			NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
+		endif
+
+	endif
 endif
 
 ifeq ($(USE_TCP_DISCARD_SRV),true)
 	SUPPORT_TCP = true
-	TCP_CFG_PASSIVE_OPEN = true
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_SRV
 	NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_srv.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_discard_srv.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_srv.cfg
 endif
 
@@ -127,5 +216,5 @@
 	CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_CLI
 	NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_cli.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/tcp_discard_cli.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_cli.cfg
 endif
 
@@ -135,5 +224,5 @@
 	CDEFS := $(CDEFS) -DUSE_UDP_DISCARD_CLI
 	NETAPP_COBJS := $(NETAPP_COBJS) udp_discard_cli.o
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/udp_discard_cli.cfg
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp_discard_cli.cfg
 endif
 
@@ -141,37 +230,61 @@
 	ifeq ($(TCP_CFG_NON_BLOCKING),true)
 		SUPPORT_TCP = true
-		TCP_CFG_PASSIVE_OPEN = true
 		USE_DBG_CONS = true
 		USE_NETAPP_SUBR = true
 		CDEFS := $(CDEFS) -DUSE_NET_CONS
 		NETAPP_COBJS := $(NETAPP_COBJS) net_cons.o
-		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/net_cons.cfg
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/net_cons.cfg
 	endif
 endif
 
 ifeq ($(USE_DBG_CONS),true)
-
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_DBG_CONS
 	NETAPP_COBJS := $(NETAPP_COBJS) dbg_cons.o 
-	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIR)/dbg_cons.cfg
-
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/dbg_cons.cfg
+	ifeq ($(USE_DBG_CONS_PARSER),true)
+		CDEFS := $(CDEFS) -DUSE_DBG_CONS_PARSER
+	endif
+	ifeq ($(USE_DBG_CONS_EXTRA_PARSE),true)
+		CDEFS := $(CDEFS) -DUSE_DBG_CONS_EXTRA_PARSE
+	endif
 endif
 
 ifeq ($(USE_PING),true)
-
 	USE_NETAPP_SUBR = true
 	CDEFS := $(CDEFS) -DUSE_PING
-
 	ifeq ($(SUPPORT_INET4),true)
-
 		NETAPP_COBJS := $(NETAPP_COBJS) ping.o
 	endif
-
 	ifeq ($(SUPPORT_INET6),true)
-
 		NETAPP_COBJS := $(NETAPP_COBJS) ping6.o
 	endif
-
+endif
+
+ifeq ($(USE_RESOLVER),true)
+	SUPPORT_UDP = true
+	CDEFS := $(CDEFS) -DUSE_RESOLVER
+	NETAPP_COBJS := $(NETAPP_COBJS) resolver.o 
+
+endif
+
+ifeq ($(USE_DHCP6_CLI),true)
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		UDP_CFG_NON_BLOCKING = true
+		USE_UDP_NON_BLOCKING = true
+		CDEFS := $(CDEFS) -DDHCP6_CLI_CFG
+		NETAPP_COBJS := $(NETAPP_COBJS) dhcp6_cli.o 
+	endif
+endif
+
+ifeq ($(USE_DHCP4_CLI),true)
+	ifeq ($(SUPPORT_INET4),true)
+		SUPPORT_UDP = true
+		UDP_CFG_NON_BLOCKING = true
+		USE_UDP_NON_BLOCKING = true
+		CDEFS := $(CDEFS) -DDHCP4_CLI_CFG
+		NETAPP_COBJS := $(NETAPP_COBJS) dhcp4_cli.o 
+	endif
 endif
 
@@ -180,10 +293,10 @@
 endif
 
+ifeq ($(API_CFG_IP4MAPPED_ADDR),true)
+	CDEFS := $(CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
+endif
+
 ifeq ($(USE_COPYSAVE_API),true)
 	CDEFS := $(CDEFS) -DUSE_COPYSAVE_API
-endif
-
-ifndef TCP_CFG_PASSIVE_OPEN
-	CDEFS := $(CDEFS) -DUNDEF_TCP_CFG_PASSIVE_OPEN
 endif
 
@@ -241,4 +354,8 @@
 endif
 
+ifeq ($(USE_LCD),true)
+	CDEFS := $(CDEFS) -DUSE_LCD
+endif
+
 #
 #  アプリケーションプログラムに関する定義への追加
@@ -247,5 +364,5 @@
 ifeq ($(TARGET_KERNEL),ASP)
 
-	APPLDIR := $(APPLDIR) $(NETAPP_DIR)
+	APPLDIR := $(APPLDIR) $(NETAPP_DIRS)
 	APPL_COBJS := $(APPL_COBJS) $(NETAPP_COBJS)
 	APPL_CFLAGS := $(APPL_CFLAGS) -fno-strict-aliasing
@@ -255,5 +372,5 @@
 ifeq ($(TARGET_KERNEL),JSP)
 
-	UTASK_DIR := $(UTASK_DIR):$(NETAPP_DIR)
+	UTASK_DIRS := $(UTASK_DIRS):$(NETAPP_DIRS)
 	UTASK_COBJS := $(UTASK_COBJS) $(NETAPP_COBJS)
 	UTASK_CFLAGS := $(UTASK_CFLAGS) -fno-strict-aliasing
@@ -261,4 +378,20 @@
 endif
 
+ifeq ($(USE_LCD),true)
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+	APPLDIR := $(APPLDIR) $(SRCDIR)/pdic/sc1602
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+	UTASK_DIRS := $(UTASK_DIRS):$(SRCDIR)/pdic/sc1602
+
+endif
+
+endif
+
 #
 #  TINET コンフィギュレーションファイルの定義への追加
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.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
  *
@@ -37,4 +37,5 @@
 
 #include <stdlib.h>
+#include <string.h>
 
 #ifdef TARGET_KERNEL_ASP
@@ -44,7 +45,8 @@
 #include <syssvc/serial.h>
 #include <syssvc/logtask.h>
-#include "kernel_cfg.h"
 #include "kernel/kernel_impl.h"
 #include "kernel/task.h"
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -55,4 +57,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #include "../kernel/jsp_kernel.h"
@@ -69,4 +72,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -83,36 +87,38 @@
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
 #include <netinet/if_ether.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
+#include <netinet/tcp_timer.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 
+#include <netinet6/nd6.h>
+
 #include <net/if_var.h>
-#include <net/if6_var.h>
 
 #include <netapp/netapp.h>
 #include <netapp/netapp_var.h>
-#include <netapp/echo.h>
-#include <netapp/discard.h>
+#include <netapp/wwws.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv2.h>
+#include <netapp/tcp_echo_cli.h>
+#include <netapp/tcp_discard_cli.h>
+#include <netapp/udp6_echo_srv.h>
+#include <netapp/udp4_echo_srv.h>
+#include <netapp/udp6_echo_cli.h>
+#include <netapp/udp4_echo_cli.h>
+#include <netapp/udp_discard_cli.h>
+#include <netapp/resolver.h>
 #include <netapp/dbg_cons.h>
-
-#ifdef USE_LCD
-
-#include "sc1602/lcd.h"
-
-#endif	/* of #ifdef USE_LCD */
+#include <netapp/dhcp6_cli.h>
+#include <netapp/dhcp4_cli.h>
+#include "lcd.h"
 
 #ifdef USE_DBG_CONS
 
-#define DBG_LINE_SIZE	63
-
 /*
- *  task_status -- タスクの状態の出力
+ *  dbg_cons_task_status -- タスクの状態の出力
  */
 
@@ -127,6 +133,6 @@
 	};
 
-static void
-task_status (ID portid, char *line)
+void
+dbg_cons_task_status (ID portid, char *line)
 {
 	TCB	*tcb;
@@ -149,5 +155,5 @@
 			st >>= 1;
 			}
-		cons_printf(portid, "\n");
+		cons_putchar(portid, '\n');
 		}
 
@@ -176,8 +182,138 @@
 	};
 
+#if defined(SUPPORT_INET6)
+
+static void
+tcp_cep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	int		len;
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	T_TCP_TWCEP*	twcep;
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	cons_printf(portid,
+	            "TCP CEP Status\n"
+	            "ID  Snd-Q Rcv-Q Foreign Address                               State\n");
+
+	for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
+		if (!VALID_TCP_CEP(cep)) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " INVALID\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " CLOSED\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_LISTEN) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " LISTEN\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else {
+			cons_printf(portid,
+			            "%2d%c%c %5d %5d ",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4',
+			            cep->swbuf_count, cep->rwbuf_count);
+
 #if defined(SUPPORT_INET4)
 
+			if (TCP_IS_CEP_IPV4(cep)) {
+				T_IN4_ADDR	addr;
+
+				addr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+				len  = put_ipv4addr(portid, &addr, 0);
+				}
+			else
+				len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 44 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (cep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
+				                    cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
+			}
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
+		if (twcep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2dTW     0     0"
+			            " -                                            "
+			            " CLOSED\n",
+			            GET_TCP_TWCEPID(twcep));
+			}
+		else {
+			cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
+
+#if defined(SUPPORT_INET4)
+
+			if (TCP_IS_CEP_IPV4(twcep)) {
+				T_IN4_ADDR	addr;
+
+				addr = ntohl(twcep->dstaddr.ipaddr.s6_addr32[3]);
+				len  = put_ipv4addr(portid, &addr, 0);
+				}
+			else
+				len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 44 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
+				                    twcep->timer_2msl / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
+			}
+		}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
 static void
-tcp_status (ID portid, char *line)
+tcp_cep_status (ID portid, char *line)
 {
 	T_TCP_CEP*	cep;
@@ -190,12 +326,4 @@
 #endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
 
-#ifdef TCP_CFG_PASSIVE_OPEN
-
-	T_TCP_REP*	rep;
-	int_t		cnt;
-
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
-
-	WAI_NET_CONS_PRINTF();
 	cons_printf(portid,
 	            "TCP CEP Status\n"
@@ -205,25 +333,28 @@
 		if (!VALID_TCP_CEP(cep)) {
 			cons_printf(portid,
-			            "%2d%c     0     0"
+			            "%2d%c%c     0     0"
 			            " -                    "
 			            " -                    "
 			            " INVALID\n",
 			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
 			}
 		else if (cep->fsm_state == TCP_FSM_CLOSED) {
 			cons_printf(portid,
-			            "%2d%c     0     0"
+			            "%2d%c%c     0     0"
 			            " -                    "
 			            " -                    "
 			            " CLOSED\n",
 			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
 			}
 		else if (cep->fsm_state == TCP_FSM_LISTEN) {
 			cons_printf(portid,
-			            "%2d%c     0     0 ",
+			            "%2d%c%c     0     0 ",
 			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
 			len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
 			cons_putchar(portid, ':');
@@ -263,5 +394,5 @@
 		if (twcep->fsm_state == TCP_FSM_CLOSED) {
 			cons_printf(portid,
-			            "%2dTW    0     0"
+			            "%2dTW     0     0"
 			            " -                    "
 			            " -                    "
@@ -270,5 +401,5 @@
 			}
 		else {
-			cons_printf(portid, "%2dTW    0     0 ", GET_TCP_TWCEPID(twcep));
+			cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
 			len  = PUT_IPADDR(portid, &twcep->myaddr.ipaddr, 0);
 			cons_putchar(portid, ':');
@@ -291,144 +422,27 @@
 #endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
 
-#ifdef TCP_CFG_PASSIVE_OPEN
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if TNUM_TCP6_REPID > 0
+
+static void
+tcp6_rep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	T_TCP6_REP*	rep;
+	ID		repid;
+	int_t		cnt;
+	uint_t		len;
 
 	cons_printf(portid,
-	            "TCP REP Status\n"
+	            "TCP6 REP Status\n"
 	            "ID  Local Address         CEP\n");
-	for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) {
-		cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
-		if (VALID_TCP_REP(rep)) {
-			len  = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0);
-			cons_putchar(portid, ':');
-			len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
-			for (len = 21 - len; len -- > 0; )
-				cons_putchar(portid, ' ');
-			cnt = 0;
-			for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
-				if (cep->rep == rep) {
-					if (cnt > 0)
-						cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
-					else
-						cons_printf(portid, "%d", GET_TCP_CEPID(cep));
-					cnt ++;
-					}
-				}
-			}
-		else
-			cons_printf(portid, "INVALID");
-		cons_putchar(portid, '\n');
-		}
-
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
-
-	SIG_NET_CONS_PRINTF();
-	FLUSH_SND_BUFF();
-	}
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-static void
-tcp_status (ID portid, char *line)
-{
-	T_TCP_CEP*	cep;
-	uint_t		len;
-
-#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
-
-	T_TCP_TWCEP*	twcep;
-
-#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
-
-#ifdef TCP_CFG_PASSIVE_OPEN
-
-	T_TCP_REP*	rep;
-	int_t		cnt;
-
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
-
-	WAI_NET_CONS_PRINTF();
-	cons_printf(portid,
-	            "TCP CEP Status\n"
-	            "ID  Snd-Q Rcv-Q Foreign Address                             State\n");
-
-	for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
-		if (!VALID_TCP_CEP(cep)) {
-			cons_printf(portid,
-			            "%2d%c     0     0"
-			            " -                                          "
-			            " INVALID\n",
-			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
-			}
-		else if (cep->fsm_state == TCP_FSM_CLOSED) {
-			cons_printf(portid,
-			            "%2d%c     0     0"
-			            " -                                          "
-			            " CLOSED\n",
-			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
-			}
-		else if (cep->fsm_state == TCP_FSM_LISTEN) {
-			cons_printf(portid,
-			            "%2d%c     0     0"
-			            " -                                          "
-			            " LISTEN\n",
-			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ');
-			}
-		else {
-			cons_printf(portid,
-			            "%2d%c %5d %5d ",
-			            GET_TCP_CEPID(cep),
-			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ',
-			            cep->swbuf_count, cep->rwbuf_count);
-			len  = PUT_IPADDR(portid, &cep->dstaddr.ipaddr, 0);
-			cons_putchar(portid, '.');
-			len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
-			for (len = 42 - len; len -- > 0; )
-				cons_putchar(portid, ' ');
-			if (cep->fsm_state == TCP_FSM_TIME_WAIT)
-				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
-				                    cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
-			else
-				cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
-			}
-
-#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
-
-	for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
-		if (twcep->fsm_state == TCP_FSM_CLOSED) {
-			cons_printf(portid,
-			            "%2dTW    0     0"
-			            " -                                          "
-			            " CLOSED\n",
-			            GET_TCP_TWCEPID(twcep));
-			}
-		else {
-			cons_printf(portid, "%2dTW    0     0 ", GET_TCP_TWCEPID(twcep));
-			len  = PUT_IPADDR(portid, &twcep->dstaddr.ipaddr, 0);
-			cons_putchar(portid, '.');
-			len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
-			for (len = 42 - len; len -- > 0; )
-				cons_putchar(portid, ' ');
-			if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
-				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
-				                    twcep->timer_2msl / TCP_SLOW_HZ);
-			else
-				cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
-			}
-		}
-
-#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
-
-#ifdef TCP_CFG_PASSIVE_OPEN
-
-	cons_printf(portid,
-	            "TCP REP Status\n"
-	            "ID  Local Address         CEP\n");
-	for (rep = tcp_rep; rep < &tcp_rep[tmax_tcp_repid]; rep ++) {
-		cons_printf(portid, "%2d%c ", GET_TCP_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
+	for (repid = TMIN_TCP6_REPID; repid <= tmax_tcp6_repid; repid ++) {
+		rep = GET_TCP6_REP(repid);
+		cons_printf(portid, "%2d%c ", GET_TCP6_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
 		if (VALID_TCP_REP(rep)) {
 			len  = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0);
@@ -439,5 +453,5 @@
 			cnt = 0;
 			for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
-				if (cep->rep == rep) {
+				if (TCP_IS_CEP_IPV6(cep) && cep->rep == rep) {
 					if (cnt > 0)
 						cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
@@ -452,38 +466,51 @@
 		cons_putchar(portid, '\n');
 		}
-
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
-
-	SIG_NET_CONS_PRINTF();
-	FLUSH_SND_BUFF();
-	}
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-#endif	/* of #ifdef SUPPORT_TCP */
-
-#ifdef SUPPORT_UDP
-
-/*
- *  udp_status -- UDP の状態の出力
- */
+	}
+
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+
+#if TNUM_TCP4_REPID > 0
 
 static void
-udp_status (ID portid, char *line)
-{
-	T_UDP_CEP*	cep;
+tcp4_rep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	T_TCP4_REP*	rep;
+	ID		repid;
+	int_t		cnt;
 	uint_t		len;
 
-	WAI_NET_CONS_PRINTF();
 	cons_printf(portid,
-	            "UDP CEP Status\n"
-	            "ID  Local Address\n");
-
-	for (cep = udp_cep; cep < &udp_cep[tmax_udp_ccepid]; cep ++) {
-		cons_printf(portid, "%2d%c ", GET_UDP_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
-		if (VALID_UDP_CEP(cep)) {
-			len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
-			cons_putchar(portid, '.');
-			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+	            "TCP4 REP Status\n"
+	            "ID  Local Address         CEP\n");
+	for (repid = TMIN_TCP4_REPID; repid <= tmax_tcp4_repid; repid ++) {
+		rep = GET_TCP4_REP(repid);
+		cons_printf(portid, "%2d%c ", GET_TCP4_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
+		if (VALID_TCP_REP(rep)) {
+			len  = put_ipv4addr(portid, &rep->myaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 21 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			cnt = 0;
+			for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (TCP_IS_CEP_IPV4(cep) && cep->rep4 == rep) {
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (TCP_IS_CEP_IPV4(cep) && cep->rep == rep) {
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+					if (cnt > 0)
+						cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
+					else
+						cons_printf(portid, "%d", GET_TCP_CEPID(cep));
+					cnt ++;
+					}
+				}
 			}
 		else
@@ -491,4 +518,22 @@
 		cons_putchar(portid, '\n');
 		}
+	}
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+
+static void
+tcp_status (ID portid, char *line)
+{
+	WAI_NET_CONS_PRINTF();
+
+	tcp_cep_status(portid, line);
+
+#if TNUM_TCP6_REPID > 0
+	tcp6_rep_status(portid, line);
+#endif
+
+#if TNUM_TCP4_REPID > 0
+	tcp4_rep_status(portid, line);
+#endif
 
 	SIG_NET_CONS_PRINTF();
@@ -496,33 +541,92 @@
 	}
 
-#endif	/* of #ifdef SUPPORT_UDP */
-
-#ifdef SUPPORT_ETHER
-
-#if defined(SUPPORT_INET4)
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
 
 /*
- *  ifa_status -- ARP キャッシュ出力
- */
+ *  udp6_status -- UDP の状態の出力
+ */
+
+#if TNUM_UDP6_CEPID > 0
+
+extern const ID tmax_tcp_cepid;
 
 static void
-ifa_status (ID portid, char *line)
-{
-	const T_ARP_ENTRY	*cache;
-	int_t			ix;
-
+udp6_status (ID portid, char *line)
+{
+	T_UDP6_CEP*	cep;
+	ID		cepid;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "UDP6 CEP Status\n"
+	            "ID  Local Address\n");
+
+	for (cepid = TMIN_UDP6_CEPID; cepid <= tmax_udp6_cepid; cepid ++) {
+		cep = GET_UDP6_CEP(cepid);
+		cons_printf(portid, "%2d%c ", GET_UDP6_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
+		if (VALID_UDP_CEP(cep)) {
+			len  = put_ipv6addr(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+
+	SIG_NET_CONS_PRINTF();
+	}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+/*
+ *  udp4_status -- UDP の状態の出力
+ */
+
+#if TNUM_UDP4_CEPID > 0
+
+static void
+udp4_status (ID portid, char *line)
+{
+	T_UDP4_CEP*	cep;
+	ID		cepid;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "UDP4 CEP Status\n"
+	            "ID  Local Address\n");
+
+	for (cepid = TMIN_UDP4_CEPID; cepid <= tmax_udp4_cepid; cepid ++) {
+		cep = GET_UDP4_CEP(cepid);
+		cons_printf(portid, "%2d%c ", GET_UDP4_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
+		if (VALID_UDP_CEP(cep)) {
+			len  = put_ipv4addr(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+
+	SIG_NET_CONS_PRINTF();
+	}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+static void
+udp_status (ID portid, char *line)
+{
 	WAI_NET_CONS_PRINTF();
-	cons_printf(portid,
-	            "ARP Cache\n"
-	            "IX Expire IP Address      MAC Address\n");
-
-	/* expire の単位は [ms]。*/
-	cache = arp_get_cache();
-	for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
-		if (cache[ix].expire != 0)
-			cons_printf(portid, "%2d %6d %15I %M\n",
-			                    ix, cache[ix].expire / NET_TIMER_HZ,
-			                    &cache[ix].ip_addr, cache[ix].mac_addr);
-		}
+
+#if TNUM_UDP6_CEPID > 0
+	udp6_status(portid, line);
+#endif
+
+#if TNUM_UDP4_CEPID > 0
+	udp4_status(portid, line);
+#endif
 
 	SIG_NET_CONS_PRINTF();
@@ -530,10 +634,12 @@
 	}
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #ifdef SUPPORT_UDP */
+
+#ifdef SUPPORT_ETHER
 
 #if defined(SUPPORT_INET6)
 
 /*
- * ifa_status -- 近隣キャッシュ状態の出力
+ * ifa6_status -- 近隣キャッシュ状態の出力
  */
 
@@ -549,5 +655,5 @@
 
 static void
-ifa_status (ID portid, char *line)
+ifa6_status (ID portid, char *line)
 {
 	const T_LLINFO_ND6	*cache;
@@ -565,9 +671,9 @@
 	for (ix = 0; ix < NUM_ND6_CACHE_ENTRY; ix ++) {
 		if (cache[ix].state != ND6_LLINFO_FREE) {
-			cons_printf(portid, "%2d %6d %10s %M %I\n",
+			cons_printf(portid, "%2d %6ld %10s %M %lI\n",
 			            ix, 
 			            cache[ix].state == ND6_LLINFO_STALE ||
-			            (uint32_t)(cache[ix].expire - now) <= 0
-			                ? 0 : (cache[ix].expire - now) / SYSTIM_HZ,
+			            (uint32_t)((int32_t)(cache[ix].expire - now) <= 0
+			                 ? 0 : (int32_t)(cache[ix].expire - now) / SYSTIM_HZ),
 			            nd_state_str[cache[ix].state],
 			            &cache[ix].ifaddr,
@@ -581,4 +687,36 @@
 
 #endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  ifa4_status -- ARP キャッシュ出力
+ */
+
+static void
+ifa4_status (ID portid, char *line)
+{
+	const T_ARP_ENTRY	*cache;
+	int_t			ix;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "ARP Cache\n"
+	            "IX Expire MAC Address       IP Address\n");
+
+	/* expire の単位は [ms]。*/
+	cache = arp_get_cache();
+	for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
+		if (cache[ix].expire != 0)
+			cons_printf(portid, "%2d %6d %M %hI\n",
+			                    ix, cache[ix].expire / NET_TIMER_HZ,
+			                    cache[ix].mac_addr, &cache[ix].ip_addr);
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
 
 #endif	/* of #ifdef SUPPORT_ETHER */
@@ -673,4 +811,46 @@
 
 #endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "\nIPv6\n");
+	cons_printf(portid, "\t受信オクテット数\t%lu\n",		net_count_ip6[NC_IP6_IN_OCTETS]);
+	cons_printf(portid, "\t受信データグラム数\t%lu\n",		net_count_ip6[NC_IP6_IN_PACKETS]);
+	cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n",	net_count_ip6[NC_IP6_IN_ERR_PACKETS]);
+	cons_printf(portid, "\t長さエラー数\t%lu\n",			net_count_ip6[NC_IP6_IN_ERR_SHORT]);
+	cons_printf(portid, "\tバージョンエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_VER]);
+	cons_printf(portid, "\tアドレスエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_ADDR]);
+	cons_printf(portid, "\tプロトコルエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_PROTO]);
+	cons_printf(portid, "\t分割受信数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN]);
+	cons_printf(portid, "\t分割受信フラグメント数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);
+	cons_printf(portid, "\t分割受信再構成成功数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_OK]);
+	cons_printf(portid, "\t分割受信破棄数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN_DROP]);
+	cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n",	net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);
+	cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);
+	cons_printf(portid, "\t送信オクテット数\t%lu\n",		net_count_ip6[NC_IP6_OUT_OCTETS]);
+	cons_printf(portid, "\t送信データグラム数\t%lu\n",		net_count_ip6[NC_IP6_OUT_PACKETS]);
+	cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n",	net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);
+	cons_printf(portid, "\t分割送信数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_OUT]);
+	cons_printf(portid, "\t分割送信フラグメント数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);
+
+	cons_printf(portid, "\nICMPv6\n");
+	cons_printf(portid, "\t受信オクテット数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_OCTETS]);
+	cons_printf(portid, "\t受信パケット数\t%lu\n",			net_count_icmp6[NC_ICMP6_IN_PACKETS]);
+	cons_printf(portid, "\t受信エラーパケット数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);
+	cons_printf(portid, "\t受信チックサムエラー数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);
+	cons_printf(portid, "\t送信オクテット数\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_OCTETS]);
+	cons_printf(portid, "\t送信パケット数\t%lu\n",			net_count_icmp6[NC_ICMP6_OUT_PACKETS]);
+	cons_printf(portid, "\t送信エラーパケット数\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);
+
+	cons_printf(portid, "\n近隣探索\n");
+	cons_printf(portid, "\tルータ通知受信数\t%lu\n",		net_count_nd6[NC_ND6_RA_IN_PACKETS]);
+	cons_printf(portid, "\tルータ要請送信数\t%lu\n",		net_count_nd6[NC_ND6_RS_OUT_PACKETS]);
+	cons_printf(portid, "\t近隣通知受信数\t%lu\n",			net_count_nd6[NC_ND6_NA_IN_PACKETS]);
+	cons_printf(portid, "\t近隣通知送信数\t%lu\n",			net_count_nd6[NC_ND6_NA_OUT_PACKETS]);
+	cons_printf(portid, "\t近隣要請受信数\t%lu\n",			net_count_nd6[NC_ND6_NS_IN_PACKETS]);
+	cons_printf(portid, "\t近隣要請送信数\t%lu\n",			net_count_nd6[NC_ND6_NS_OUT_PACKETS]);
+	cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n",		net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);
+
+#else	/* of #if defined(SUPPORT_INET6) */
 
 #if defined(SUPPORT_INET4)
@@ -707,44 +887,4 @@
 
 #endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-	cons_printf(portid, "\nIPv6\n");
-	cons_printf(portid, "\t受信オクテット数\t%lu\n",		net_count_ip6[NC_IP6_IN_OCTETS]);
-	cons_printf(portid, "\t受信データグラム数\t%lu\n",		net_count_ip6[NC_IP6_IN_PACKETS]);
-	cons_printf(portid, "\t受信エラーデータグラム数\t%lu\n",	net_count_ip6[NC_IP6_IN_ERR_PACKETS]);
-	cons_printf(portid, "\t長さエラー数\t%lu\n",			net_count_ip6[NC_IP6_IN_ERR_SHORT]);
-	cons_printf(portid, "\tバージョンエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_VER]);
-	cons_printf(portid, "\tアドレスエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_ADDR]);
-	cons_printf(portid, "\tプロトコルエラー数\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_PROTO]);
-	cons_printf(portid, "\t分割受信数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN]);
-	cons_printf(portid, "\t分割受信フラグメント数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);
-	cons_printf(portid, "\t分割受信再構成成功数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_OK]);
-	cons_printf(portid, "\t分割受信破棄数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN_DROP]);
-	cons_printf(portid, "\t分割受信バッファり当て失敗数\t%lu\n",	net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);
-	cons_printf(portid, "\t分割受信タイムアウト数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);
-	cons_printf(portid, "\t送信オクテット数\t%lu\n",		net_count_ip6[NC_IP6_OUT_OCTETS]);
-	cons_printf(portid, "\t送信データグラム数\t%lu\n",		net_count_ip6[NC_IP6_OUT_PACKETS]);
-	cons_printf(portid, "\t送信エラーデータグラム数\t%lu\n",	net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);
-	cons_printf(portid, "\t分割送信数\t%lu\n",			net_count_ip6[NC_IP6_FRAG_OUT]);
-	cons_printf(portid, "\t分割送信フラグメント数\t%lu\n",		net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);
-
-	cons_printf(portid, "\nICMPv6\n");
-	cons_printf(portid, "\t受信オクテット数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_OCTETS]);
-	cons_printf(portid, "\t受信パケット数\t%lu\n",			net_count_icmp6[NC_ICMP6_IN_PACKETS]);
-	cons_printf(portid, "\t受信エラーパケット数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);
-	cons_printf(portid, "\t受信チックサムエラー数\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);
-	cons_printf(portid, "\t送信オクテット数\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_OCTETS]);
-	cons_printf(portid, "\t送信パケット数\t%lu\n",			net_count_icmp6[NC_ICMP6_OUT_PACKETS]);
-	cons_printf(portid, "\t送信エラーパケット数\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);
-
-	cons_printf(portid, "\n近隣探索\n");
-	cons_printf(portid, "\tルータ通知受信数\t%lu\n",		net_count_nd6[NC_ND6_RA_IN_PACKETS]);
-	cons_printf(portid, "\tルータ要請送信数\t%lu\n",		net_count_nd6[NC_ND6_RS_OUT_PACKETS]);
-	cons_printf(portid, "\t近隣通知受信数\t%lu\n",			net_count_nd6[NC_ND6_NA_IN_PACKETS]);
-	cons_printf(portid, "\t近隣通知送信数\t%lu\n",			net_count_nd6[NC_ND6_NA_OUT_PACKETS]);
-	cons_printf(portid, "\t近隣要請受信数\t%lu\n",			net_count_nd6[NC_ND6_NS_IN_PACKETS]);
-	cons_printf(portid, "\t近隣要請送信数\t%lu\n",			net_count_nd6[NC_ND6_NS_OUT_PACKETS]);
-	cons_printf(portid, "\t重複アドレス検出送信数\t%lu\n",		net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);
 
 #endif	/* of #if defined(SUPPORT_INET6) */
@@ -787,9 +927,10 @@
 
 	tbl = nbuf_get_tbl();
-	cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t割当要求数\t割当数\t割当てエラー数\n");
+	cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n");
 	for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
-		cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\n",
+		cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
 		                    tbl[ix].size,
 		                    tbl[ix].prepares,
+		                    tbl[ix].busies,
 		                    tbl[ix].requests,
 		                    tbl[ix].allocs,
@@ -833,5 +974,5 @@
 	for (ix = nbuf_get_tbl_size(); ix -- > 0; )
 		cons_printf(portid, "\t%d", tbl[ix].size);
-	cons_printf(portid, "\n");
+	cons_putchar(portid, '\n');
 
 	queue = ip_get_frag_queue();
@@ -846,5 +987,5 @@
 				cons_printf(portid, "\t%d", count);
 				}
-			cons_printf(portid, "\n");
+			cons_putchar(portid, '\n');
 			}
 		}
@@ -874,5 +1015,5 @@
 	for (ix = nbuf_get_tbl_size(); ix -- > 0; )
 		cons_printf(portid, "\t%d", tbl[ix].size);
-	cons_printf(portid, "\n");
+	cons_putchar(portid, '\n');
 
 	queue = ip6_get_frag_queue();
@@ -887,5 +1028,5 @@
 				cons_printf(portid, "\t%d", count);
 				}
-			cons_printf(portid, "\n");
+			cons_putchar(portid, '\n');
 			}
 		}
@@ -918,5 +1059,4 @@
 
 #ifdef TCP_CFG_SWBUF_CSAVE
-	T_IP_HDR*		iph;
 	T_TCP_HDR*		tcph;
 #endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
@@ -925,14 +1065,15 @@
 	WAI_NET_CONS_PRINTF();
 	get_tim(&now);
-	cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%lu\n", now);
+	cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%u\n", now);
 
 #if NET_COUNT_ENABLE
 
-	cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t割当要求数\t割当数\t割当てエラー数\n");
+	cons_printf(portid, "\nネットワークバッファ\n\tサイズ\t用意数\t使用中数\t割当要求数\t割当数\t割当てエラー数\n");
 	tbl = nbuf_get_tbl();
 	for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
-		cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\n",
+		cons_printf(portid, "\t%u\t%u\t%u\t%u\t%u\t%u\n",
 		                    tbl[ix].size,
 		                    tbl[ix].prepares,
+		                    tbl[ix].busies,
 		                    tbl[ix].requests,
 		                    tbl[ix].allocs,
@@ -949,6 +1090,6 @@
 		cons_printf(portid, "%2d", GET_TCP_CEPID(cep));
 		for (nbuf = cep->reassq; nbuf != NULL; nbuf = tqhdr->next) {
-			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_IP_Q_HDR(nbuf)->thoff);
-			cons_printf(portid, "[a:%6d-%6d] ",
+			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
+			cons_printf(portid, "[a:%6lu-%6lu] ",
 			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
 			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
@@ -957,6 +1098,6 @@
 #ifdef TCP_CFG_RWBUF_CSAVE
 		for (nbuf = cep->rwbufq; nbuf != NULL; nbuf = tqhdr->next) {
-			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_IP_Q_HDR(nbuf)->thoff);
-			cons_printf(portid, "[r:%6d-%6d] ",
+			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
+			cons_printf(portid, "[r:%6lu-%6lu] ",
 			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
 			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
@@ -966,14 +1107,21 @@
 #ifdef TCP_CFG_SWBUF_CSAVE
 		if (cep->swbufq != NULL) {
-			iph  = GET_IP_HDR(cep->swbufq);
 			tcph = GET_TCP_HDR(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq));
-			cons_printf(portid, "[s:%6d-%6d] ",
+#if 0
+			cons_printf(portid, "[s:%6lu-%6lu] ",
 			            ntohl(tcph->seq) - cep->iss,
-			            ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(iph) - 
-			                                           GET_TCP_HDR_SIZE2(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))));
+			            ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 
+			                                           GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))));
+#else
+			cons_printf(portid, "[s:%6lu-%6lu,%08x,%08x] ",
+			            ntohl(tcph->seq) - cep->iss,
+			            ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 
+			                                           GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))),
+			            ntohl(tcph->seq), cep->iss);
+#endif
 			}
 #endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
 
-		cons_printf(portid, "\n");
+		cons_putchar(portid, '\n');
 		}
 
@@ -1008,51 +1156,393 @@
 	}
 
+#ifdef USE_RESOLVER
+
+/*
+ *  show_dns_soa -- DNS の SOA RDATA を表示する。
+ */
+
+static ER_UINT
+show_dns_soa (ID portid, uint8_t *msg, ER_UINT length, uint_t offset)
+{
+	T_RSLV_SOA	soa;
+	ER_UINT		error;
+	uint_t		rn_offset;
+
+	if ((error = dns_analyze_soa(&soa, offset, msg, length)) < 0)
+		return error;
+
+	cons_printf(portid, "    mname:   ");
+	rn_offset = show_dns_domain_name(portid, msg, offset);
+	cons_putchar(portid, '\n');
+	cons_printf(portid, "    rname:   ");
+	show_dns_domain_name(portid, msg, rn_offset);
+	cons_putchar(portid, '\n');
+
+	cons_printf(portid, "    serial:  %d\n", soa.serial);
+	cons_printf(portid, "    refresh: %d\n", soa.refresh);
+	cons_printf(portid, "    retry:   %d\n", soa.retry);
+	cons_printf(portid, "    expirel: %d\n", soa.expire);
+	cons_printf(portid, "    minimum: %d\n", soa.minimum);
+
+	return E_OK;
+	}
+
+/*
+ *  show_dns_qdsection -- DNS の Question セクションを表示する。
+ */
+
+static ER_UINT
+show_dns_qdsection (ID portid, uint8_t *msg, ER_UINT length, T_RSLV_DNS_MSG *rslv)
+{
+	T_RSLV_QD	qd;
+	ER_UINT		offset, error;
+	int		scount;
+
+	cons_printf(portid, "question   section: %d\n", rslv->dns_hdr.qdcount);
+	offset = rslv->qd_offset;
+	for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount ++) {
+		if ((error = dns_analyze_qd(&qd, offset, msg, length)) < 0)
+			return error;
+
+		cons_printf(portid, "%2d: ", scount);
+		show_dns_domain_name(portid, msg, offset);
+		cons_printf(portid, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
+		offset = error;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  show_dns_section -- DNS の各セクションを表示する。
+ */
+
+static ER_UINT
+show_dns_section (ID portid, uint8_t *msg, ER_UINT length, uint_t scount, uint_t offset, char *title)
+{
+	T_RSLV_RR	rr;
+	T_IN4_ADDR	in4_addr;
+	ER_UINT		error;
+	int		count, dcount, col;
+	T_IN6_ADDR	in6_addr;
+
+	cons_printf(portid, "%10s section: %d\n", title, scount);
+	for (count = 1; count <= scount; count ++) {
+		if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
+			return error;
+
+		cons_printf(portid, "%2d: ", count);
+		show_dns_domain_name(portid, msg, offset);
+		cons_printf(portid, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
+		            dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
+
+		switch (rr.type) {
+		case DNS_TYPE_A:
+			memcpy((void*)&in4_addr, (void*)(msg + rr.rdata_offset), sizeof(in4_addr));
+			in4_addr = ntohl(in4_addr);
+			cons_printf(portid, "    IPv4 addr: %hI\n", &in4_addr);
+			break;
+		case DNS_TYPE_NS:
+			cons_printf(portid, "    host: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_CNAME:
+			cons_printf(portid, "    host: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_SOA:
+			show_dns_soa(portid, msg, length, rr.rdata_offset);
+			break;
+		case DNS_TYPE_PTR:
+			cons_printf(portid, "     PTR: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_AAAA:
+			memcpy((void*)&in6_addr, (void*)(msg + rr.rdata_offset), sizeof(in6_addr));
+			cons_printf(portid, "    IPv6 addr: %lI\n", &in6_addr);
+			break;
+		default:
+			cons_printf(portid, "    data: ");
+			col = 32;
+			for (dcount = 0; dcount < rr.rdlength; dcount ++) {
+				cons_printf(portid, "%02x", *(msg + rr.rdata_offset + dcount));
+				if (-- col == 0) {
+					cons_printf(portid, "\n          ");
+					col = 32;
+					}
+				}
+			cons_putchar(portid, '\n');
+			break;
+			}
+		}
+
+	return E_OK;
+	}
+/*
+ *  dns_info -- DNS 情報の表示
+ */
+
+static void
+dns_info (ID portid)
+{
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	in6_addr;
+#endif
 #if defined(SUPPORT_INET4)
-
-#if NUM_ROUTE_ENTRY > 0
+	T_IN4_ADDR	in4_addr;
+#endif
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "domain name:     %s\n", dns_in6_get_dname());
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+	cons_printf(portid, "domain name:     %s\n", dns_in4_get_dname());
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET6)
+	dns_in6_get_addr(&in6_addr);
+	cons_printf(portid, "IPv6 DNS server: ");
+	if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
+		cons_printf(portid, "not available.\n");
+	else
+		cons_printf(portid, "%lI.\n", &in6_addr);
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+	dns_in4_get_addr(&in4_addr);
+	cons_printf(portid, "IPv4 DNS server: ");
+	if (in4_addr == IPV4_ADDRANY)
+		cons_printf(portid, "not available.\n");
+	else
+		cons_printf(portid, "%hI.\n", &in4_addr);
+#endif	/* of #if defined(SUPPORT_INET4) */
+	}
 
 /*
- *  routing_table_status -- 経路表の出力
- */
+ *  name_lookup -- ホスト名－IP アドレス変換
+ */
+
+const char *rcode_str[] = {
+	"no error",
+	"format error",
+	"server error",
+	"name error",
+	"not implement",
+	"refused",
+	};
 
 static void
-routing_table_status (ID portid, char *line)
-{
-	int_t	ix;
-
-	if ('0' <= *(line = skip_blanks(line)) && *line <= '9') {
-		T_IN4_ADDR	target, mask, gateway;
-
-		ix = atoi(line);
-		while ('0' <= *line && *line <= '9')
-			line ++;
-		line = GET_IPADDR(&target,  skip_blanks(line));
-		line = GET_IPADDR(&mask,    skip_blanks(line));
-		       GET_IPADDR(&gateway, skip_blanks(line));
-		in4_add_route(ix, target, mask, gateway);
-		}
-
+name_lookup (ID portid, char *line)
+{
+	static char hostname[DBG_LINE_SIZE + 1];
+
+	T_RSLV_DNS_MSG	rslv;
+	ER_UINT		length, offset;
+	ER		error;
+	uint_t		flags = 0;
+	uint8_t 	*msg;
+
+	/* コマンドのオプションを設定する。*/
+	line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
+	if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
+		cons_printf(portid, "DNS server not available.\n");
+		return;
+		}
+
+	/* 照会するホスト名・IP アドレスを解析する。*/
+	resolv_hoststr(&flags, hostname, sizeof(hostname), line);
+
+	/* 正引きでも逆引きでもプロトコル上は正引きを指定する。*/
+	flags |= DNS_LUP_OPCODE_FORWARD;
+
+	/* IPv6 アドレス、または IPv4 アドレスが指定された時は、照会タイプは PTR に設定する。*/
+	if (((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV6) ||
+	    ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV4))
+		flags = (flags & ~DNS_LUP_FLAGS_QTYPE_MASK) | DNS_LUP_FLAGS_QTYPE_PTR;
+
+	if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
+		cons_printf(portid, "get buffer error: %s.\n", itron_strerror(error));
+		return;
+		}
+
+	if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
+		//cons_printf(portid, "error: %s.\n", itron_strerror(length));
+		goto err_ret;
+		}
+
+	dly_tsk(1 * 1000);
+	cons_printf(portid, "DNS header: flags: ");
+	if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE     |
+	                         DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_QR_RESPONSE)         ? "QR," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_AUTHORITATIVE)       ? "AA," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_TRUN_CATION)         ? "TC," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED)   ? "RD," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
+		cons_printf(portid, " ");
+		}
+	cons_printf(portid, "opcode: ");
+	cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE)      ? "RV"  : "FW");
+	cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_STATUS)       ? ",ST" : "");
+	cons_printf(portid, ", rcode: %s.\n",
+	            (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
+	            	? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
+
+	if ((offset = show_dns_qdsection(portid, msg, length, &rslv)) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+
+err_ret:
+	if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
+		cons_printf(portid, "release buffer error: %s.\n", itron_strerror(error));
+	return;
+	}
+
+#endif	 /* of #ifdef USE_RESOLVER */
+
+#if defined(DHCP6_CLI_CFG)
+
+/*
+ *  dhcp6c_info -- DHCPv6 クライアント情報の表示
+ */
+
+static void
+dhcp6c_info (ID portid)
+{
+	T_IN6_ADDR	svaddr;
+	SYSTIM		bind_start;
+	ER		error;
+	uint32_t	expire, renew, rebind, deprefer;
+
+	if ((error = dhcp6c_get_info(&svaddr, &expire, &renew, &rebind, &deprefer, &bind_start)) == E_OK) {
+		cons_printf(portid, "      DHCPv6 server: %lI.\n", &svaddr);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	
+		cons_printf(portid, "      DHCPv6 mode:   stateless.\n");
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		cons_printf(portid, "      DHCPv6 mode:   statefull,\n");
+		cons_printf(portid, "        Renew:       %u:%02u:%02u, Deprefer: %u:%02u:%02u,\n",
+		                       renew / 3600, (   renew / 60) % 60,    renew % 60,
+		                    deprefer / 3600, (deprefer / 60) % 60, deprefer % 60);
+		cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
+		                      rebind / 3600, (  rebind / 60) % 60,   rebind % 60,
+		                      expire / 3600, (  expire / 60) % 60,   expire % 60);
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+		}
+	else if (error == E_OBJ)
+		cons_printf(portid, "      DHCPv6 server: not available.\n");
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#if defined(DHCP4_CLI_CFG)
+
+/*
+ *  dhcp4c_info -- DHCPv4 クライアント情報の表示
+ */
+
+static void
+dhcp4c_info (ID portid)
+{
+	T_IN4_ADDR	svaddr;
+	SYSTIM		bind_start;
+	ER		error;
+	uint32_t	expire, renew, rebind;
+
+	if ((error = dhcp4c_get_info(&svaddr, &expire, &renew, &rebind, &bind_start)) == E_OK) {
+		cons_printf(portid, "      DHCPv4 server: %hI,\n", &svaddr);
+		cons_printf(portid, "        Renew:       %u:%02u:%02u,\n", 
+		                      renew  / 3600, (renew  / 60) % 60, renew % 60);
+		cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
+		                      rebind / 3600, (rebind / 60) % 60, rebind % 60,
+		                      expire / 3600, (expire / 60) % 60, expire % 60);
+		}
+	else if (error == E_OBJ)
+		cons_printf(portid, "      DHCPv4 server: not available.\n");
+	}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG) */
+
+#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
+
+/*
+ *  dhcpc -- DHCP クライアント情報の表示と制御
+ */
+
+static void
+dhcpc (ID portid, char *line)
+{
 	WAI_NET_CONS_PRINTF();
-	cons_printf(portid,
-	            "Routing Table Status\n"
-	            "IX Target          Mask            Gateway         Expire\n");
-
-	for (ix = 0; ix < NUM_ROUTE_ENTRY; ix ++) {
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) == 0)
-			;
-		else if ((routing_tbl[ix].flags & IN_RTF_REDIRECT) != 0)
-			cons_printf(portid, "%2d %15I %15I %15I %4d\n",
-			            ix,
-			            &routing_tbl[ix].target,
-			            &routing_tbl[ix].mask,
-			            &routing_tbl[ix].gateway,
-			            &routing_tbl[ix].expire);
-		else
-			cons_printf(portid, "%2d %15I %15I %I\n",
-			            ix,
-			            &routing_tbl[ix].target,
-			            &routing_tbl[ix].mask,
-			            &routing_tbl[ix].gateway);
-		            
+
+	switch (*line) {
+
+#if defined(DHCP6_CLI_CFG)
+	case '6':			/* DHCPv6 の制御 */
+		switch (*(line + 1)) {
+		case 'r':		/* アドレス情報を解放する。*/
+			dhcp6c_rel_info();
+			break;
+
+		case 'n':		/* アドレス情報を再取得する。*/
+			dhcp6c_renew_info();
+			break;
+
+		default:
+			dhcp6c_info(portid);
+			break;
+			}
+		break;
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#if defined(DHCP4_CLI_CFG)
+	case '4':		/* DHCPv4 の制御 */
+		switch (*(line + 1)) {
+		case 'r':		/* アドレス情報を解放する。*/
+			dhcp4c_rel_info();
+			break;
+
+		case 'n':		/* アドレス情報を再取得する。*/
+			dhcp4c_renew_info();
+			break;
+
+		default:
+			dhcp4c_info(portid);
+			break;
+			}
+		break;
+#endif	/* of #if defined(DHCP4_CLI_CFG) */
+
+	default:
+
+#if defined(DHCP6_CLI_CFG)
+		dhcp6c_info(portid);
+#endif
+
+#if defined(DHCP4_CLI_CFG)
+		dhcp4c_info(portid);
+#endif
+		break;
 		}
 
@@ -1061,7 +1551,5 @@
 	}
 
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
-
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
 
 #if defined(SUPPORT_INET6)
@@ -1124,5 +1612,5 @@
 			while (ptitle -- > 0)
 				cons_printf(portid, " ");
-			cons_printf(portid, " %I\n",  &dr[rix].addr);
+			cons_printf(portid, " %lI\n",  &dr[rix].addr);
 			}
 		}
@@ -1188,5 +1676,5 @@
 			while (rtitle -- > 0)
 				cons_printf(portid, " ");
-			cons_printf(portid, "%4d %I\n",  pr[pix].prefix_len, &pr[pix].prefix);
+			cons_printf(portid, "%4d %lI\n",  pr[pix].prefix_len, &pr[pix].prefix);
 			}
 		}
@@ -1198,12 +1686,12 @@
 #endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
 
-#if NUM_ROUTE_ENTRY > 0
+#if NUM_IN6_ROUTE_ENTRY > 0
 
 /*
- *  routing_table_status -- 経路表の出力
+ *  routing6_table_status -- 経路表（IPv6）の出力
  */
 
 static void
-routing_table_status (ID portid, char *line)
+routing6_table_status (ID portid, char *line)
 {
 	SYSTIM	now;
@@ -1212,13 +1700,13 @@
 	WAI_NET_CONS_PRINTF();
 	cons_printf(portid,
-	            "Routing Table Status\n"
+	            "\nRouting Table Status (IPv6)\n"
 	            "IX Expire flags Prefix Target                         Gateway\n");
 
-	for (ix = 0; ix < NUM_STATIC_ROUTE_ENTRY; ix ++) {
-		cons_printf(portid, "%2d STATIC     - %6d %30I %I\n",
+	for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++) {
+		cons_printf(portid, "%2d STATIC     - %6d %30lI %lI\n",
 		            ix,
-		             routing_tbl[ix].prefix_len,
-		            &routing_tbl[ix].target,
-		            &routing_tbl[ix].gateway);
+		             routing6_tbl[ix].prefix_len,
+		            &routing6_tbl[ix].target,
+		            &routing6_tbl[ix].gateway);
 		            
 		}
@@ -1228,14 +1716,14 @@
 	now /= SYSTIM_HZ;
 
-	for ( ; ix < NUM_ROUTE_ENTRY; ix ++)
-		if (routing_tbl[ix].flags & IN_RTF_DEFINED)
-			cons_printf(portid, "%2d %6d    %02x %6d %30I %I\n",
+	for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		if (routing6_tbl[ix].flags & IN_RTF_DEFINED)
+			cons_printf(portid, "%2d %6d    %02x %6d %30lI %lI\n",
 			            ix,
-			            (uint32_t)(routing_tbl[ix].expire - now) <= 0
-			                ? 0 : routing_tbl[ix].expire - now,
-			             routing_tbl[ix].flags,
-			             routing_tbl[ix].prefix_len,
-			            &routing_tbl[ix].target,
-			            &routing_tbl[ix].gateway);
+			            (uint32_t)(routing6_tbl[ix].expire - now) <= 0
+			                ? 0 : routing6_tbl[ix].expire - now,
+			             routing6_tbl[ix].flags,
+			             routing6_tbl[ix].prefix_len,
+			            &routing6_tbl[ix].target,
+			            &routing6_tbl[ix].gateway);
 
 	SIG_NET_CONS_PRINTF();
@@ -1243,12 +1731,67 @@
 	}
 
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
 
 #endif	/* of #if defined(SUPPORT_INET6) */
 
-#if NUM_ROUTE_ENTRY > 0
+#if defined(SUPPORT_INET4)
+
+#if NUM_IN4_ROUTE_ENTRY > 0
 
 /*
- *  routing_status -- ルーティング情報
+ *  routing4_table_status -- 経路表（IPv4）の出力
+ */
+
+static void
+routing4_table_status (ID portid, char *line)
+{
+	int_t	ix;
+
+	if ('0' <= *(line = skip_blanks(line)) && *line <= '9') {
+		T_IN4_ADDR	target, mask, gateway;
+
+		ix = atoi(line);
+		while ('0' <= *line && *line <= '9')
+			line ++;
+		line = get_ipv4addr(&target,  skip_blanks(line));
+		line = get_ipv4addr(&mask,    skip_blanks(line));
+		       get_ipv4addr(&gateway, skip_blanks(line));
+		in4_add_route(ix, target, mask, gateway);
+		}
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "\nRouting Table Status (IPv4)\n"
+	            "IX Target          Mask            Gateway         Expire\n");
+
+	for (ix = 0; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0)
+			;
+		else if ((routing4_tbl[ix].flags & IN_RTF_REDIRECT) != 0)
+			cons_printf(portid, "%2d %15hI %15hI %15hI %4d\n",
+			            ix,
+			            &routing4_tbl[ix].target,
+			            &routing4_tbl[ix].mask,
+			            &routing4_tbl[ix].gateway,
+			            &routing4_tbl[ix].expire);
+		else
+			cons_printf(portid, "%2d %15hI %15hI %hI\n",
+			            ix,
+			            &routing4_tbl[ix].target,
+			            &routing4_tbl[ix].mask,
+			            &routing4_tbl[ix].gateway);
+		            
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if NUM_IN4_ROUTE_ENTRY > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  routing_status -- 経路情報
  */
 
@@ -1258,7 +1801,5 @@
 	switch (*line) {
 
-#if defined(SUPPORT_INET6)
-
-#if NUM_ND6_DEF_RTR_ENTRY > 0
+#if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0
 
 	case 'l':		/* ディフォルトルータ・リスト情報 */
@@ -1270,24 +1811,28 @@
 		break;
 
-#endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-	default:		/* ルーティング表情報 */
-		routing_table_status(portid, line);
+#endif	/* #if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+	default:
+
+		/* 経路表情報 */
+
+#if defined(SUPPORT_INET6) && NUM_IN6_ROUTE_ENTRY > 0
+		routing6_table_status(portid, line);
+#endif
+
+#if defined(SUPPORT_INET4) && NUM_IN4_ROUTE_ENTRY > 0
+		routing4_table_status(portid, line);
+#endif
+
 		break;
-
-		break;
-		}
-	}
-
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+		}
+	}
 
 /*
- *  network_status -- ネットワークの状態の出力
- */
-
-static void
-network_status (ID portid, char *line)
+ *  dbg_cons_network_status -- ネットワークの状態の出力
+ */
+
+void
+dbg_cons_network_status (ID portid, char *line)
 {
 	switch (*line) {
@@ -1296,5 +1841,12 @@
 
 	case 'a':		/* IF アドレス情報 */
-		ifa_status(portid, line + 1);
+
+#if defined(SUPPORT_INET6)
+		ifa6_status(portid, line + 1);
+#endif
+#if defined(SUPPORT_INET4)
+		ifa4_status(portid, line + 1);
+#endif
+
 		break;
 
@@ -1313,11 +1865,18 @@
 #endif	/* of #if NET_COUNT_ENABLE */
 
-#if NUM_ROUTE_ENTRY > 0
-
-	case 'r':		/* ルーティング情報 */
+	case 'r':		/* 経路情報 */
 		routing_status(portid, line + 1);
 		break;
 
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+#ifdef USE_RESOLVER
+
+	case 's':		/* name lookup */
+		if (*(line = skip_blanks(line + 1)) == '\0')
+			dns_info(portid);
+		else
+			name_lookup(portid, line);
+		break;
+
+#endif	 /* of #ifdef USE_RESOLVER */
 
 #ifdef SUPPORT_TCP
@@ -1338,5 +1897,5 @@
 
 	default:
-		cons_printf(portid, "no such command: '%c%c'\n", *(line - 1), *line);
+		cons_printf(portid, "no such command: '%c%c'.\n", *(line - 1), *line);
 		SIG_NET_CONS_PRINTF();
 		FLUSH_SND_BUFF();
@@ -1345,64 +1904,35 @@
 	}
 
-#if defined(SUPPORT_INET4)
-
 /*
- *  ifconfig -- ネットワークインタフェースの構成情報
- */
-
-static void
-ifconfig (ID portid, char *line)
-{
-	T_IFNET		*ifp = IF_GET_IFNET();
-	T_IN4_ADDR	bc;
-
+ *  dbg_cons_ifconfig -- ネットワークインタフェースの構成情報
+ */
+
+void
+dbg_cons_ifconfig (ID portid, char *line)
+{
 #ifdef SUPPORT_ETHER
 
-	if (*(line = skip_blanks(line))) {
-		T_IN4_ADDR	addr, mask;
-
-		GET_IPADDR(&mask, skip_blanks(GET_IPADDR(&addr, line)));
-		in4_add_ifaddr(addr, mask);
-		}
-
-#endif	/* of #ifdef SUPPORT_ETHER */
+	T_IF_SOFTC	*ic;
 
 	WAI_NET_CONS_PRINTF();
-	cons_printf(portid,
-	            "Network Interface Configurations\n");
-
-#ifdef SUPPORT_ETHER
-
-	cons_printf(portid,
-	            "ether: %M\n",
-	            IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr);
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
-	bc = (ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask;
-	cons_printf(portid,
-	            "inet:  %I, mask: %I, broadcast: %I\n",
-	            &ifp->in_ifaddr.addr,
-	            &ifp->in_ifaddr.mask,
-	            &bc);
-
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	cons_printf(portid, "ether: %M\n", ic->ifaddr.lladdr);
 	SIG_NET_CONS_PRINTF();
 	FLUSH_SND_BUFF();
-	}
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+	}
+
+#if defined(NETAPP_IP6_CFG)
 
 /*
- *  ifconfig -- ネットワークインタフェースの構成情報
- */
-
-static void
-ifconfig (ID portid, char *line)
+ *  dbg_cons_ifconfig6 -- ネットワークインタフェース（IPv6）の構成情報
+ */
+
+void
+dbg_cons_ifconfig6 (ID portid, char *line)
 {
 #ifdef SUPPORT_ETHER
 
-	T_IF_SOFTC	*ic;
 	T_IFNET		*ifp = IF_GET_IFNET();
 	int_t		ix;
@@ -1410,7 +1940,4 @@
 
 	WAI_NET_CONS_PRINTF();
-	ic = IF_ETHER_NIC_GET_SOFTC();
-	cons_printf(portid, "ether: %M\ninet6:\nIX   Expire Preffered RTR PFX Flags IP Address\n",
-	                    ic->ifaddr.lladdr);
 
 	/* expire と vltime の単位は [s]。*/
@@ -1418,28 +1945,33 @@
 	now /= SYSTIM_HZ;
 
+	cons_printf(portid, "IPv6:\nIX   Expire Preffered RTR PFX Flags IP Address\n");
 	for (ix = 0; ix < NUM_IN6_IFADDR_ENTRY; ix ++) {
-		if (ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) {
+		if (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) {
 			cons_printf(portid, " %d", ix);
-			if (ifp->in_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)
+			if (ifp->in6_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)
 				cons_printf(portid, "    INFIN     INFIN");
 			else
 				cons_printf(portid, " %8d %9d",
-				                    (uint32_t)(ifp->in_ifaddrs[ix].lifetime.expire - now) <= 0 
-				                        ? 0 : ifp->in_ifaddrs[ix].lifetime.expire - now,
-				                    (uint32_t)(ifp->in_ifaddrs[ix].lifetime.preferred - now) <= 0
-				                        ? 0 : ifp->in_ifaddrs[ix].lifetime.preferred - now);
-			if (ifp->in_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)
+				                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.expire - now) <= 0 
+				                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.expire - now,
+				                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.preferred - now) <= 0
+				                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.preferred - now);
+			if (ifp->in6_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)
 				cons_printf(portid, "   -");
 			else
-				cons_printf(portid, " %3d", ifp->in_ifaddrs[ix].router_index);
-			if (ifp->in_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)
+				cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].router_index);
+			if (ifp->in6_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)
 				cons_printf(portid, "   -");
 			else
-				cons_printf(portid, " %3d", ifp->in_ifaddrs[ix].prefix_index);
-			cons_printf(portid, "    %02x %I\n",
-			                    ifp->in_ifaddrs[ix].flags,
-			                    &ifp->in_ifaddrs[ix].addr);
-			}
-		}
+				cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].prefix_index);
+			cons_printf(portid, "    %02x %lI\n",
+			                     ifp->in6_ifaddrs[ix].flags,
+			                    &ifp->in6_ifaddrs[ix].addr);
+			}
+		}
+
+#ifdef DHCP6_CLI_CFG
+	dhcp6c_info(portid);
+#endif
 
 	SIG_NET_CONS_PRINTF();
@@ -1449,12 +1981,54 @@
 	}
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(NETAPP_IP6_CFG) */
+
+#if defined(NETAPP_IP4_CFG)
 
 /*
- *  show_config -- コンフィギュレーション設定の表示
- */
-
-static void
-show_config (ID portid, char *line)
+ *  dbg_cons_ifconfig4 -- ネットワークインタフェース（IPv4）の構成情報
+ */
+
+void
+dbg_cons_ifconfig4 (ID portid, char *line)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN4_ADDR	bc;
+
+#ifdef SUPPORT_ETHER
+
+	if (*(line = skip_blanks(line))) {
+		T_IN4_ADDR	addr, mask;
+
+		get_ipv4addr(&mask, skip_blanks(get_ipv4addr(&addr, line)));
+		in4_add_ifaddr(addr, mask);
+		}
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	WAI_NET_CONS_PRINTF();
+
+	bc = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
+	cons_printf(portid,
+	            "IPv4: %hI, mask: %hI, broadcast: %hI\n",
+	            &ifp->in4_ifaddr.addr,
+	            &ifp->in4_ifaddr.mask,
+	            &bc);
+
+#ifdef DHCP4_CLI_CFG
+	dhcp4c_info(portid);
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(NETAPP_IP4_CFG) */
+
+/*
+ *  dbg_cons_show_config -- コンフィギュレーション設定の表示
+ */
+
+void
+dbg_cons_show_config (ID portid, char *line)
 {
 #if defined(SUPPORT_ETHER)
@@ -1464,22 +2038,43 @@
 #endif	/* of #if defined(SUPPORT_ETHER) */
 
-#if defined(DHCP_CFG)
-
 	cons_printf(portid, "DHCP:\n");
-
-	cons_printf(portid, "  DHCP_CFG: On\n");
-
-#endif	/* of #if define(DHCP_CFG) */
+	cons_printf(portid, "  DHCP6_CLI_CFG: ");
+
+#if defined(DHCP6_CLI_CFG)
+
+	cons_printf(portid, "On\n           Mode: ");
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	cons_printf(portid, "STATELESS\n");
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+	cons_printf(portid, "STATEFULL\n");
+#endif
+
+#else	/* of #if define(DHCP6_CLI_CFG) */
+
+	cons_printf(portid, "Off\n");
+
+#endif	/* of #if define(DHCP6_CLI_CFG) */
+
+	cons_printf(portid, "  DHCP4_CLI_CFG: ");
+
+#if defined(DHCP4_CLI_CFG)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "Resolver:\n");
+	cons_printf(portid, "  USE_RESOLVER: ");
+
+#if defined(USE_RESOLVER)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
 
 #if defined(SUPPORT_TCP)
 
 	cons_printf(portid, "TCP:\n");
-
-	cons_printf(portid, "  TCP_CFG_PASSIVE_OPEN: ");
-#if defined(TCP_CFG_PASSIVE_OPEN)
-	cons_printf(portid, "On\n");
-#else
-	cons_printf(portid, "Off\n");
-#endif
 
 	cons_printf(portid, "  TCP_CFG_OPT_MSS:      ");
@@ -1553,16 +2148,23 @@
 #endif
 
+	cons_printf(portid, "  TCP_CFG_NON_BLOCKING_COMPAT14: ");
+#if defined(TCP_CFG_NON_BLOCKING_COMPAT14)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
 	cons_printf(portid, "  TCP_CFG_EXTENTIONS:   ");
 #if defined(TCP_CFG_EXTENTIONS)
 #if defined(USE_TCP_EXTENTIONS)
 	cons_printf(portid, "Use\n");
-#if defined(SUPPORT_INET4)
-	cons_printf(portid, "  NUM_VRID_TCP_REPS:    %3d\n", NUM_VRID_TCP_REPS);
-	cons_printf(portid, "  NUM_VRID_TCP_CEPS:    %3d\n", NUM_VRID_TCP_CEPS);
-#endif	
 #if defined(SUPPORT_INET6)
 	cons_printf(portid, "  NUM_VRID_TCP6_REPS:   %3d\n", NUM_VRID_TCP6_REPS);
 	cons_printf(portid, "  NUM_VRID_TCP6_CEPS:   %3d\n", NUM_VRID_TCP6_CEPS);
-#endif	
+#endif
+#if defined(SUPPORT_INET4)
+	cons_printf(portid, "  NUM_VRID_TCP4_REPS:   %3d\n", NUM_VRID_TCP4_REPS);
+	cons_printf(portid, "  NUM_VRID_TCP4_CEPS:   %3d\n", NUM_VRID_TCP4_CEPS);
+#endif
 #else
 	cons_printf(portid, "On\n");
@@ -1589,5 +2191,5 @@
 #if defined(SUPPORT_INET4)
 	addr = TCP_CFG_TRACE_IPV4_RADDR;
-	cons_printf(portid, "                            TCP_CFG_TRACE_IPV4_RADDR: %I\n", &addr);
+	cons_printf(portid, "                            TCP_CFG_TRACE_IPV4_RADDR: %hI\n", &addr);
 #endif
 	cons_printf(portid, "                            TCP_CFG_TRACE_RPORTNO:    %d\n", TCP_CFG_TRACE_RPORTNO);
@@ -1633,4 +2235,11 @@
 #endif
 
+	cons_printf(portid, "  UDP_CFG_NON_BLOCKING_COMPAT14: ");
+#if defined(UDP_CFG_NON_BLOCKING_COMPAT14)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
 	cons_printf(portid, "  UDP_CFG_EXTENTIONS:   ");
 #if defined(UDP_CFG_EXTENTIONS)
@@ -1640,5 +2249,5 @@
 	cons_printf(portid, "On\n");
 #endif
-	cons_printf(portid, "  NUM_VRID_UDP_CEPS:    %3d\n", NUM_VRID_UDP_CEPS);
+	cons_printf(portid, "  NUM_VRID_UDP4_CEPS:   %3d\n", NUM_VRID_UDP4_CEPS);
 	cons_printf(portid, "  NUM_VRID_UDP6_CEPS:   %3d\n", NUM_VRID_UDP6_CEPS);
 #else
@@ -1667,44 +2276,24 @@
 #endif
 
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
 #if NUM_REDIRECT_ROUTE_ENTRY > 0
 	cons_printf(portid, "  TMO_IN_REDIRECT: %4d[s]\n", TMO_IN_REDIRECT / NET_TIMER_HZ);
 #endif
-
-#if defined(SUPPORT_INET4)
-
-	cons_printf(portid, "IPv4:\n");
-
-	cons_printf(portid, "  IP4_CFG_FRAGMENT: ");
-
-#if defined(IP4_CFG_FRAGMENT)
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "IPv6:\n");
+
+	cons_printf(portid, "  IP6_IPV4_MAPPED_ADDR:   ");
+#if defined(IP6_CFG_IPV4_MAPPED_ADDR)
 	cons_printf(portid, "On\n");
-	cons_printf(portid, "    NUM_IP4_FRAG_QUEUE:       %4d\n", NUM_IP4_FRAG_QUEUE);
-	cons_printf(portid, "    IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);
 #else
 	cons_printf(portid, "Off\n");
-#endif	/* of #if defined(IP4_CFG_FRAGMENT) */
-
-#if defined(SUPPORT_ETHER)
-	addr = IPV4_ADDR_LOCAL;
-	cons_printf(portid, "  IPV4_ADDR_LOCAL:      %I\n", &addr);
-	addr = IPV4_ADDR_LOCAL_MASK;
-	cons_printf(portid, "  IPV4_ADDR_LOCAL_MASK: %I\n", &addr);
-	addr = IPV4_ADDR_DEFAULT_GW;
-	cons_printf(portid, "  IPV4_ADDR_DEFAULT_GW: %I\n", &addr);
-#endif	/* of #if defined(SUPPORT_ETHER) */
+#endif
 
 	cons_printf(portid, "  Routing Table:\n");
-	cons_printf(portid, "    NUM_STATIC_ROUTE_ENTRY:   %d\n", NUM_STATIC_ROUTE_ENTRY);
-	cons_printf(portid, "    NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY);
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-	cons_printf(portid, "IPv6:\n");
-
-	cons_printf(portid, "  Routing Table:\n");
-	cons_printf(portid, "    NUM_STATIC_ROUTE_ENTRY:   %d\n", NUM_STATIC_ROUTE_ENTRY);
-	cons_printf(portid, "    NUM_REDIRECT_ROUTE_ENTRY: %d\n", NUM_REDIRECT_ROUTE_ENTRY);
+	cons_printf(portid, "    NUM_IN6_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN6_STATIC_ROUTE_ENTRY);
+	cons_printf(portid, "    NUM_IN6_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN6_REDIRECT_ROUTE_ENTRY);
 
 	cons_printf(portid, "ND:\n");
@@ -1730,4 +2319,33 @@
 #endif	/* of #if defined(SUPPORT_INET6) */
 
+#if defined(SUPPORT_INET4)
+
+	cons_printf(portid, "IPv4:\n");
+
+	cons_printf(portid, "  IP4_CFG_FRAGMENT: ");
+
+#if defined(IP4_CFG_FRAGMENT)
+	cons_printf(portid, "On\n");
+	cons_printf(portid, "    NUM_IP4_FRAG_QUEUE:       %4d\n", NUM_IP4_FRAG_QUEUE);
+	cons_printf(portid, "    IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);
+#else
+	cons_printf(portid, "Off\n");
+#endif	/* of #if defined(IP4_CFG_FRAGMENT) */
+
+#if defined(SUPPORT_ETHER)
+	addr = IPV4_ADDR_LOCAL;
+	cons_printf(portid, "  IPV4_ADDR_LOCAL:      %hI\n", &addr);
+	addr = IPV4_ADDR_LOCAL_MASK;
+	cons_printf(portid, "  IPV4_ADDR_LOCAL_MASK: %hI\n", &addr);
+	addr = IPV4_ADDR_DEFAULT_GW;
+	cons_printf(portid, "  IPV4_ADDR_DEFAULT_GW: %hI\n", &addr);
+#endif	/* of #if defined(SUPPORT_ETHER) */
+
+	cons_printf(portid, "  Routing Table:\n");
+	cons_printf(portid, "    NUM_IN4_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN4_STATIC_ROUTE_ENTRY);
+	cons_printf(portid, "    NUM_IN4_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN4_REDIRECT_ROUTE_ENTRY);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
 #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER)
 
@@ -1771,4 +2389,11 @@
 #endif
 
+	cons_printf(portid, "  ETHER_COLLECT_ADDR:      ");
+#if defined(ETHER_COLLECT_ADDR)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
 #endif	/* of #if defined(SUPPORT_ETHER) */
 
@@ -1854,13 +2479,117 @@
 	}
 
+#ifdef USE_PING
+
+/*
+ *  ping コマンド
+ */
+
+void
+dbg_cons_ping_comd (ID portid, char *line)
+{
+	int_t	tmo, size;
+	char	apip = DEFAULT_API_PROTO;
+
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	addr;
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	addr4;
+#endif
+#else
+	T_IN4_ADDR	addr;
+#endif
+
+#if defined(PING_CFG_I6RLP)
+
+	static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452";
+	static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352";
+	static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2";
+
+	if      (apip == '1')
+		strcpy(line, i6rlp_pmtu_str1);
+	else if (apip == '2')
+		strcpy(line, i6rlp_pmtu_str2);
+	else if (apip == '3')
+		strcpy(line, i6rlp_pmtu_str3);
+
+#endif	/* of #ifdef PING_CFG_I6RLP */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if ('0' <= *line && *line <= '9') {
+		if (*line == '6')
+			apip = API_PROTO_IPV6;
+		if (*line == '4')
+			apip = API_PROTO_IPV4;
+		line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+		syslog(LOG_NOTICE, "[PING] unknown host.");
+		return;
+		}
+
+	line = skip_blanks(line);
+	if ('0' <= *line && *line <= '9')
+		line = get_int(&tmo, line);
+	else
+		tmo = 3;
+
+	line = skip_blanks(line);
+	if ('0' <= *line && *line <= '9')
+		line = get_int(&size, line);
+	else
+		size = 64;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6) {
+		syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
+		ping6(&addr, (uint_t)tmo, (uint_t)size);
+		}
+	else {
+		addr4 = ntohl(addr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr4));
+		ping4(&addr4, (uint_t)tmo, (uint_t)size);
+		}
+
+#else /* of #if defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
+	ping6(&addr, (uint_t)tmo, (uint_t)size);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+
+	syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr));
+	ping4(&addr, (uint_t)tmo, (uint_t)size);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	}
+
+#endif	/* of #ifdef USE_PING */
+
+#ifdef USE_DBG_CONS_PARSER
+
 /*
  *  デバッグコマンド解析
  */
 
-static void
+void
 dbg_parse (ID portid, char *line)
 {
 	int_t	cepid;
-	ER	error;
+	ER	error = E_OK;
+
+#if defined(SUPPORT_UDP) && defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	int_t	udp_cep_ipproto;
+#endif
 
 	switch (*line) {
@@ -1870,5 +2599,5 @@
 
 		case 'f':	/* show configurations */
-			show_config(portid, line + 1);
+			dbg_cons_show_config(portid, line + 1);
 			break;
 
@@ -1880,5 +2609,5 @@
 				line ++;
 			if ((error = tcp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
-				cons_printf(portid, "[TCP CAN CEP] error: %s\n", itron_strerror(error));
+				cons_printf(portid, "[TCP CAN CEP] error: %s.\n", itron_strerror(error));
 				SIG_NET_CONS_PRINTF();
 				FLUSH_SND_BUFF();
@@ -1891,12 +2620,78 @@
 
 		case 'u':	/* cancel UDP */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+			udp_cep_ipproto = (*(line + 2) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6);
+			cepid = atoi(line = skip_blanks(line + 3));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+
+#if TNUM_UDP6_CEPID > 0
+
+			if (udp_cep_ipproto == API_PROTO_IPV6) {
+				if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+					cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+#if TNUM_UDP4_CEPID > 0
+
+			if (udp_cep_ipproto == API_PROTO_IPV4) {
+				if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+					cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if TNUM_UDP6_CEPID > 0
+
 			cepid = atoi(line = skip_blanks(line + 2));
 			while ('0' <= *line && *line <= '9')
 				line ++;
+
 			if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
-				cons_printf(portid, "[UDP CAN CEP] error: %s\n", itron_strerror(error));
+				cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
 				SIG_NET_CONS_PRINTF();
 				FLUSH_SND_BUFF();
 				}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if TNUM_UDP4_CEPID > 0
+
+			cepid = atoi(line = skip_blanks(line + 2));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+
+			if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+				cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
 			break;
 
@@ -1906,6 +2701,4 @@
 
 		break;
-
-#if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS)
 
 	case 'd':	/* discard client */
@@ -1929,4 +2722,12 @@
 #endif	/* of #if defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */
 
+#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
+
+		case 'h':		/* DHCP client */
+			dhcpc(portid, line + 2);
+			break;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
+
 #ifdef USE_TCP_DISCARD_CLI
 
@@ -1941,5 +2742,5 @@
 			default:
 				if ((error = psnd_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
-					cons_printf(portid, "[TCP DISCARD CLI] error: %s\n",
+					cons_printf(portid, "[TCP DISCARD CLI] error: %s.\n",
 					       itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
@@ -1965,5 +2766,5 @@
 			default:
 				if ((error = psnd_dtq(DTQ_UDP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
-					cons_printf(portid, "[UDP DISCARD CLI] error: %s\n",
+					cons_printf(portid, "[UDP DISCARD CLI] error: %s.\n",
 					       itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
@@ -1981,7 +2782,5 @@
 		break;
 
-#endif	/* of #if defined(USE_UDP_DISCARD_CLI) || defined(USE_TCP_DISCARD_CLI) || defined(SUPPORT_PPP) || defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */
-
-#if defined(USE_UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI)
+#if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI)
 
 	case 'e':	/* echo client */
@@ -2000,5 +2799,5 @@
 			default:
 				if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t)line)) != E_OK) {
-					cons_printf(portid, "[TCP ECHO CLI] error: %s\n", itron_strerror(error));
+					cons_printf(portid, "[TCP ECHO CLI] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
@@ -2011,20 +2810,79 @@
 #endif	/* of #ifdef USE_TCP_ECHO_CLI */
 
-#ifdef USE_UDP_ECHO_CLI
+#if defined(USE_UDP_ECHO_CLI)
 
 		case 'u':	/* UDP echo client */
-			line += 2;
-			switch (*line) {
+			switch (*(line + 2)) {
 
 			case 's':	/* cancel UDP echo */
-				udp_echo_cli_valid = false;
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+				if (*(line + 3) == '4')
+					udp4_echo_cli_valid = false;
+				else
+					udp6_echo_cli_valid = false;
+
+#else	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+				udp6_echo_cli_valid = false;
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+#if defined(USE_UDP4_CLI_TSK)
+
+				udp4_echo_cli_valid = false;
+
+#endif	/* of #if defined(USE_UDP4_CLI_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+
 				break;
 
 			default:
-				if ((error = psnd_dtq(DTQ_UDP_ECHO_CLI, (intptr_t)line)) != E_OK) {
-					cons_printf(portid, "[UDP ECHO CLI] error: %s\n", itron_strerror(error));
+
+				line += 2;
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+				if (*line == '4') {
+					line ++;
+					error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
+					}
+				else {
+					if (*line && *line != ' ')
+						line ++;
+					error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
+					}
+
+#else	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+				if (*line && *line != ' ')
+					line ++;
+				error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+				if (*line && *line != ' ')
+					line ++;
+				error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+				if (error != E_OK) {
+					cons_printf(portid, "[UDP ECHO CLI] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
 					}
+
 				break;
 
@@ -2032,5 +2890,5 @@
 			break;
 
-#endif	/* of #ifdef USE_UDP_ECHO_CLI */
+#endif	/* of #if defined(USE_UDP_ECHO_CLI) */
 
 			}
@@ -2038,10 +2896,21 @@
 		break;
 
-#endif	/* of #if defined(USE_UDP_ECHO_CLI) || defined(USE_TCP_ECHO_CLI) */
+#endif	/* of #if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI) */
 
 	case 'i':
 
-		if (*(line + 1) == 'f')
-			ifconfig(portid, line + 2);
+		if (*(line + 1) == 'f') {
+
+			dbg_cons_ifconfig (portid, line + 2);
+
+#if defined(NETAPP_IP6_CFG)
+			dbg_cons_ifconfig6(portid, line + 2);
+#endif
+
+#if defined(NETAPP_IP4_CFG)
+			dbg_cons_ifconfig4(portid, line + 2);
+#endif
+
+			}
 
 #ifdef SUPPORT_PPP
@@ -2064,5 +2933,5 @@
 
 	case 'n':		/* network status */
-		network_status(portid, line + 1);
+		dbg_cons_network_status(portid, line + 1);
 		break;
 
@@ -2070,40 +2939,10 @@
 
 		if (*(line + 1) == 's')
-			task_status(portid, skip_blanks(line + 2));
+			dbg_cons_task_status(portid, skip_blanks(line + 2));
 
 #ifdef USE_PING
 
-		else {
-			int_t		tmo, size;
-			T_IN_ADDR	addr;
-
-#ifdef PING_CFG_I6RLP
-			static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452";
-			static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352";
-			static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2";
-
-			if      (*(line + 1) == '1')
-				strcpy(line + 1, i6rlp_pmtu_str1);
-			else if (*(line + 1) == '2')
-				strcpy(line + 1, i6rlp_pmtu_str2);
-			else if (*(line + 1) == '3')
-				strcpy(line + 1, i6rlp_pmtu_str3);
-
-#endif	/* of #ifdef PING_CFG_I6RLP */
-
-			line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line + 1)));
-			if ('0' <= *line && *line <= '9')
-				line = get_int(&tmo, line);
-			else
-				tmo = 3;
-
-			line = skip_blanks(line + 1);
-			if ('0' <= *line && *line <= '9')
-				line = get_int(&size, line);
-			else
-				size = 64;
-
-			PING(&addr, (uint_t)tmo, (uint_t)size);
-			}
+		else
+			dbg_cons_ping_comd(portid, line + 1);
 
 #endif	/* of #ifdef USE_PING */
@@ -2113,5 +2952,5 @@
 	case 'r':		/* release wait task */
 		if ((error = rel_wai(atoi(skip_blanks(line + 1)))) != E_OK) {
-			cons_printf(portid, "[REL WAI TSK] error: %s\n", itron_strerror(error));
+			cons_printf(portid, "[REL WAI TSK] error: %s.\n", itron_strerror(error));
 			SIG_NET_CONS_PRINTF();
 			FLUSH_SND_BUFF();
@@ -2125,6 +2964,10 @@
 
 		case 't':		/* TCP REP */
-			if ((error = tcp_del_rep(atoi(skip_blanks(line + 2)))) != E_OK) {
-				cons_printf(portid, "[TCP DEL REP] error: %s\n", itron_strerror(error));
+	
+			error = tcp_del_rep(atoi(skip_blanks(line + 2)));
+			if (error != E_OK) {
+				cons_printf(portid, "[TCP DEL REP] ID: %d, error: %s.\n", 
+				                    atoi(skip_blanks(line + 2)),
+				                    itron_strerror(error));
 				SIG_NET_CONS_PRINTF();
 				FLUSH_SND_BUFF();
@@ -2137,9 +2980,48 @@
 
 		case 'u':		/* UDP CEP */
-			if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
-				cons_printf(portid, "[UDP DEL CEP] error: %s\n", itron_strerror(error));
+
+#if defined(USE_UDP6_ECHO_SRV_TSK)
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+			if (*(line + 2) == '4') {
+				if ((error = udp_del_cep(atoi(skip_blanks(line + 3)))) != E_OK) {
+					cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+			else {
+				if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+					cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#else	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+			if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+				cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
 				SIG_NET_CONS_PRINTF();
 				FLUSH_SND_BUFF();
 				}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+			if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+				cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
 			break;
 
@@ -2163,5 +3045,5 @@
 			case 'd':		/* tcp discard server */
 				if ((error = wup_tsk(TCP_DISCARD_SRV_TASK)) != E_OK) {
-					cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s\n", itron_strerror(error));
+					//cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
@@ -2170,18 +3052,28 @@
 #endif	/* of #ifdef USE_TCP_DISCARD_SRV */
 
-#if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2)
+#if defined(USE_TCP_ECHO_SRV1)
 			case 'e':		/* tcp echo server */
-				if ((error = wup_tsk(TCP_ECHO_SRV_TASK)) != E_OK) {
-					cons_printf(portid, "[WUP UDP DISCARD SRV] error: %s\n", itron_strerror(error));
+				if ((error = wakeup_tcp_echo_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
+					//cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
 					}
 				break;
-#endif	/* of #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2) */
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
+
+#if defined(USE_TCP_ECHO_SRV2)
+			case 'e':		/* tcp echo server */
+				if ((error = wup_tsk(TCP_ECHO_SRV_TASK2)) != E_OK) {
+					//cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+#endif	/* of #if defined(USE_TCP_ECHO_SRV2) */
 
 #ifdef USE_WWW_SRV
 			case 'w':		/* WWW server */
-				if ((error = wup_tsk(WWW_SRV_TASK1)) != E_OK) {
-					cons_printf(portid, "[WUP WWW SRV] error: %s\n", itron_strerror(error));
+				if ((error = wakeup_www_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
+					//cons_printf(portid, "[WUP WWW SRV] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
@@ -2200,13 +3092,54 @@
 			switch (*(line + 2)) {
 
-#if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK)
+#if !defined(USE_UDP_CALL_BACK)
+
 			case 'e':		/* udp echo server */
-				if ((error = wup_tsk(UDP_ECHO_SRV_TASK)) != E_OK) {
-					cons_printf(portid, "[WUP UDP ECHO SRV] error: %s\n", itron_strerror(error));
+
+#if defined(USE_UDP6_ECHO_SRV_TSK)
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+				if (*(line + 3) == '4') {
+					if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
+						cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
+						SIG_NET_CONS_PRINTF();
+						FLUSH_SND_BUFF();
+						}
+					}
+				else {
+					if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
+						cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
+						SIG_NET_CONS_PRINTF();
+						FLUSH_SND_BUFF();
+						}
+					}
+
+#else	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+				if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
+					cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
 					SIG_NET_CONS_PRINTF();
 					FLUSH_SND_BUFF();
 					}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+				if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
+					cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
 				break;
-#endif	/* of #if defined(USE_UDP_ECHO_SRV) && !defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if !defined(USE_UDP_CALL_BACK) */
 
 				}
@@ -2217,5 +3150,5 @@
 		default:
 			if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
-				cons_printf(portid, "[WUP TSK] error: %s\n", itron_strerror(error));
+				cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
 				SIG_NET_CONS_PRINTF();
 				FLUSH_SND_BUFF();
@@ -2230,5 +3163,5 @@
 	case 'w':		/* wake up task */
 		if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
-			cons_printf(portid, "[WUP TSK] error: %s\n", itron_strerror(error));
+			cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
 			SIG_NET_CONS_PRINTF();
 			FLUSH_SND_BUFF();
@@ -2242,15 +3175,17 @@
 		if (*line) {
 
-#ifdef USE_EXTRA_PARSE
-
-			extra_parse(line);
-
-#else	/* of #ifdef USE_EXTRA_PARSE */
-
-			cons_printf(portid, "no such command: '%c'\n", *line);
+#ifdef USE_DBG_CONS_EXTRA_PARSE
+
+			//cons_printf(portid, "extra command: '%c'.\n", *line);
+			dbg_cons_extra_parse(portid, line);
+
+#else	/* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
+
+			//cons_printf(portid, "command: '%c'.\n", *line);
+			cons_printf(portid, "no such command: '%c'.\n", *line);
 			SIG_NET_CONS_PRINTF();
 			FLUSH_SND_BUFF();
 
-#endif	/* of #ifdef USE_EXTRA_PARSE */
+#endif	/* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
 
 			}
@@ -2258,4 +3193,6 @@
 		}
 	}
+
+#endif	/* of #ifdef USE_DBG_CONS_PARSER */
 
 /*
@@ -2268,5 +3205,4 @@
 	static char line[DBG_LINE_SIZE + 1];
 
-	uint_t	len;
 	ID	tskid;
 
@@ -2274,49 +3210,60 @@
 #ifdef SUPPORT_ETHER
 
+#if 0
 #if defined(SUPPORT_INET6)
 
-	int_t		lllen;
+	uint32_t	lllen;
 	const uint8_t	*lladdr;
 
 #endif	/* of #if defined(SUPPORT_INET6) */
-
-	lcd_init();
+#endif
+
+	lcd_initialize(0);
+
+#if 0
+#if defined(SUPPORT_INET6)
+
+	dly_tsk(1 * 1000);
+	lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;
+	for (lllen = ETHER_ADDR_LEN; lllen --; )
+		lcd_printf(LCD_PORTID, "%02x", *lladdr ++);
+	lcd_putc(LCD_PORTID, '\n');
+
+#else	/* of #if defined(SUPPORT_INET6) */
 
 	if ((TINET_PRVER & UINT_C(0x0f)) > 0)
-		lcd_printf("TINET-%d.%d.%d\n",
+		lcd_printf(LCD_PORTID, "TINET-%d.%d.%d\n",
 		       (TINET_PRVER   >> 12) & UINT_C(0x0f),
 		       (TINET_PRVER   >>  4) & UINT_C(0x0f),
 		        TINET_PRVER          & UINT_C(0x0f));
 	else
-		lcd_printf("TINET-%d.%d\n",
+		lcd_printf(LCD_PORTID, "TINET-%d.%d\n",
 		       (TINET_PRVER   >> 12) & UINT_C(0x0f),
 		       (TINET_PRVER   >>  4) & UINT_C(0x0f));
 
-#if defined(SUPPORT_INET6)
-
-	lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;
-	for (lllen = ETHER_ADDR_LEN; lllen --; )
-		lcd_printf("%02x", *lladdr ++);
-	lcd_printf("\n");
-
-#else	/* of #if defined(SUPPORT_INET6) */
-
-	lcd_puts(ip2str(NULL, in4_get_ifaddr(0)));
-
 #endif	/* of #if defined(SUPPORT_INET6) */
+#endif
+
+#if 0
+#if defined(SUPPORT_INET4)
+
+	dly_tsk(1 * 1000);
+	lcd_puts(LCD_PORTID, ip2str(NULL, in4_get_ifaddr(0)));
+	lcd_putc(LCD_PORTID, '\n');
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+#endif
 
 #endif	/* of #ifdef SUPPORT_ETHER */
-#else	/* of #ifdef USE_LCD */
+#endif	/* of #ifdef USE_LCD */
 
 	get_tid(&tskid);
 	cons_printf(CONSOLE_PORTID, "[CONSOLE:%d] started.\n", tskid);
-
-#endif	/* of #ifdef USE_LCD */
-
 	serial_ctl_por(CONSOLE_PORTID,
 	               IOCTL_ECHO  | IOCTL_CRLF  |
 	               IOCTL_FCSND | IOCTL_FCANY | IOCTL_FCRCV);
+	netapp_srand (tskid);
 	while (true) {
-		len = cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);
+		cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);
 		dbg_parse(CONSOLE_PORTID, line);
 		}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.h	(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
  *
@@ -53,5 +53,13 @@
 
 extern void act_tasks (void);
-extern void extra_parse (char *line);
+extern void dbg_parse (ID portid, char *line);
+extern void dbg_cons_extra_parse (ID portid, char *line);
+extern void dbg_cons_task_status (ID portid, char *line);
+extern void dbg_cons_network_status (ID portid, char *line);
+extern void dbg_cons_ifconfig (ID portid, char *line);
+extern void dbg_cons_ifconfig6 (ID portid, char *line);
+extern void dbg_cons_ifconfig4 (ID portid, char *line);
+extern void dbg_cons_show_config (ID portid, char *line);
+extern void dbg_cons_ping_comd (ID portid, char *line);
 
 #endif	/* of #ifndef _DBG_CONS_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h	(revision 331)
@@ -0,0 +1,387 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_H
+#define DHCP4_H
+
+/*
+ *  DHCP ã«é¢ããå®ç¾©
+ *
+ *    RFC2131
+ */
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸ã®å®æ°ã®å®ç¾©
+ */
+
+#define DHCP4_CHADDR_LEN	16
+#define DHCP4_SNAME_LEN		64
+#define DHCP4_FILE_LEN		128
+#define DHCP4_DFLT_OPT_LEN	312
+#define DHCP4_UDP_MSG_LENGTH	(sizeof(uint32_t)*7+DHCP4_CHADDR_LEN	\
+				 +DHCP4_SNAME_LEN+DHCP4_FILE_LEN+DHCP4_DFLT_OPT_LEN)
+#define DHCP4_SNAME_OFFSET	(sizeof(uint32_t)*7+DHCP4_CHADDR_LEN)
+#define DHCP4_FILE_OFFSET	(DHCP4_SNAME_OFFSET+DHCP4_SNAME_LEN)
+#define DHCP4_OPTION_OFFSET	(DHCP4_FILE_OFFSET+DHCP4_FILE_LEN)
+#define DHCP4_TIME_INFINITY	UINT_C(0xffffffff)
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸
+ */
+
+typedef struct dhcp4_msg {
+	uint8_t		op;			/* packet type			*/
+	uint8_t		htype;			/* hardware address type	*/
+	uint8_t		hlen;			/* hardware address length	*/
+	uint8_t		hops;			/* gateway hops			*/
+	uint32_t	xid;			/* transaction ID		*/
+	uint16_t	secs;			/* seconds since boot began	*/
+	uint16_t	flags;
+	uint32_t	ciaddr;			/* client IP address		*/
+	uint32_t	yiaddr;			/* your   IP address		*/
+	uint32_t	siaddr;			/* server IP address		*/
+	uint32_t	giaddr;			/* relay agent IP address	*/
+	uint8_t		chaddr [DHCP4_CHADDR_LEN];	/* client hardware address	*/
+	uint8_t		sname  [DHCP4_SNAME_LEN];	/* server host name		*/
+	uint8_t		file   [DHCP4_FILE_LEN];		/* boot file name		*/
+	uint8_t		options[DHCP4_DFLT_OPT_LEN];	/* optional parameters field	*/
+	} T_DHCP4_MSG;
+
+/* packet type ã®å®ç¾© */
+
+#define DHCP4_REQUEST		UINT_C(1)
+#define DHCP4_REPLY		UINT_C(2)
+
+/* hardware address type ã®å®ç¾© */
+
+#define DHCP4_HWA_TYPE_ETHER	UINT_C(1)
+#define DHCP4_HWA_TYPE_IEEE802	UINT_C(6)
+
+/*
+ *  DHCP ãªãã·ã§ã³
+ *
+ *    RFC1533
+ */
+
+/*
+ *  ãªãã·ã§ã³ã®ç©´åã
+ */
+#define DHCP4_OPT_PAD		UINT_C(0)
+
+/*
+ *  ãµãããããã¹ã¯
+ *
+ *     code   len   subnet mask
+ *   +------+-----+-----+-----+-----+-----+
+ *   |   1  |  4  |  m1 |  m2 |  m3 |  m4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_SUBNET_MASK	UINT_C(1)
+
+/*
+ *  ã«ã¼ã¿
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |   3  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_ROUTER		UINT_C(3)
+
+/*
+ *  DNS ãµã¼ã
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |   6  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_DNS_SERVER	UINT_C(6)
+
+/*
+ *  ãã¹ãå
+ *
+ *     code   len   host name
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  12  |  n  |  h1 |  h2 |  h3 |  h4 | ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_HOST_NAME	UINT_C(12)
+
+/*
+ *  ãã¡ã¤ã³å
+ *
+ *     code   len   domain name
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  15  |  n  |  d1 |  d2 |  d3 |  d4 | ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_DOMAIN_NAME	UINT_C(15)
+
+/*
+ *  ã«ã¼ã¿æ¢ç´¢
+ *
+ *     code   len  value
+ *   +------+-----+-----+
+ *   |  31  |  1  | 0/1 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_RTR_DISOVERY	UINT_C(31)
+
+/*
+ *  éççµè·¯
+ *
+ *     code   len   destination #1          router #1
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |  33  |  n  |  d1 |  d2 |  d3 |  d4 |  r1 |  r2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_STATIC_ROUTE	UINT_C(33)
+
+/*
+ *  ãã³ãã¼åºææ
+å ±
+ *
+ *     code   len   vendor-specific informations
+ *   +------+-----+-----+-----+-----+---
+ *   |  43  |  n  |  i1 |  i2 |  i3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_VENDOR_INFO	UINT_C(43)
+
+/*
+ *  NetBIOS over TCP/IP ãã¼ã ãµã¼ã
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |  44  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_NETBIOS_NS	UINT_C(44)
+
+/*
+ *  NetBIOS over TCP/IP ãã¼ãã¿ã¤ã
+ *
+ *     code   len   type
+ *   +------+-----+-----+
+ *   |  46  |  1  | type|
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_NETBIOS_NODE	UINT_C(46)
+
+/*
+ *  NetBIOS over TCP/IP ã¹ã³ã¼ã
+ *
+ *     code   len   NetBIOS scope
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  44  |  n  |  s1 |  s2 |  s3 |  s4 |  ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_NETBIOS_SCOPE	UINT_C(47)
+
+/*
+ *  ç¹å®ã® IPv4 ã¢ãã¬ã¹è¦æ±
+ *
+ *     code   len   IPv4 address
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  50  |  4  |  a1 |  a2 |  a3 |  a4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_REQ_IPV4	UINT_C(50)
+
+/*
+ *  ãªã¼ã¹æé
+ *
+ *     code   len   lease time
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  51  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_LEASE_TIME	UINT_C(51)
+
+/*
+ *  ãªãã·ã§ã³ãªã¼ãã¼ã­ã¼ã
+ *
+ *     code   len  value
+ *   +------+-----+-----+
+ *   |  52  |  1  | 1-3 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_OPT_OVERLOAD	UINT_C(52)
+
+/* value ã®å®ç¾© */
+
+#define DHCP4_OPTOL_FILE	UINT_C(0x01)
+#define DHCP4_OPTOL_SNAME	UINT_C(0x02)
+#define DHCP4_OPTOL_BOTH	UINT_C(0x03)
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸ã¿ã¤ã
+ *
+ *     code   len   type
+ *   +------+-----+-----+
+ *   |  53  |  1  | 1-7 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_MSG_TYPE	UINT_C(53)
+
+/* type ã®å®ç¾© */
+
+#define DHCP4_MTYPE_BOOTP	UINT_C(0)
+#define DHCP4_MTYPE_DISCOVER	UINT_C(1)
+#define DHCP4_MTYPE_OFFER	UINT_C(2)
+#define DHCP4_MTYPE_REQUEST	UINT_C(3)
+#define DHCP4_MTYPE_DECLINE	UINT_C(4)
+#define DHCP4_MTYPE_ACK		UINT_C(5)
+#define DHCP4_MTYPE_NAK		UINT_C(6)
+#define DHCP4_MTYPE_RELEASE	UINT_C(7)
+#define DHCP4_MTYPE_INFOMATION	UINT_C(8)
+
+/*
+ *  ãµã¼ã ID
+ *
+ *     code   len   IPv4 address
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  54  |  4  |  a1 |  a2 |  a3 |  a4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_SERVER_ID	UINT_C(54)
+
+/*
+ *  è¦æ±ãã©ã¡ã¼ã¿ãªã¹ã
+ *
+ *     code   len   option code
+ *   +------+-----+-----+-----+-----+---
+ *   |  55  |  n  |  c1 |  c2 |  c3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_REQ_PARAM	UINT_C(55)
+
+/*
+ *  Renewal (T1) æé
+ *
+ *     code   len   T1 interval
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  58  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_RENEWAL_T1	UINT_C(58)
+
+/*
+ *  Rebinding (T2) æé
+ *
+ *     code   len   T2 interval
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  59  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_REBINDING_T2	UINT_C(59)
+
+/*
+ *  ãã³ãã¼ã¯ã©ã¹ IDï¼RFC2132ï¼
+ *
+ *     code   len   vendor class ID
+ *   +------+-----+-----+-----+-----+---
+ *   |  60  |  n  |  i1 |  i2 |  i3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_VCLASS_ID	UINT_C(60)
+
+/*
+ *  ã¯ã©ã¤ã¢ã³ã ID
+ *
+ *     code   len   type  client ID
+ *   +------+-----+-----+-----+-----+---
+ *   |  61  |  n  | type|  i1 |  i2 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ *   type       : ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹ã¿ã¤ã
+ *   i1, i2, ...: éå¸¸ MAC ã¢ãã¬ã¹
+ */
+#define DHCP4_OPT_CLIENT_ID	UINT_C(61)
+
+/*
+ *  ã¯ã©ã¹ãªãéççµè·¯ï¼RFC3442ï¼
+ *
+ *     code   len   destination #1     router #1
+ *   +------+-----+-----+------+-----+-----+-----+-----+---
+ *   |  121 |  n  |  d1 |  ... |  dN |  r1 |  r2 |  r3 | ...
+ *   +------+-----+-----+------+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_CLASSLESS_RTE	UINT_C(121)
+
+/*
+ *  ãªãã·ã§ã³ã®çµäº
+ */
+#define DHCP4_OPT_END		UINT_C(255)
+
+/*
+ *  magic çªå·ï¼RFC1048ï¼
+ */
+
+#define DHCP4_RFC1048_MAGIC	{ UINT_C(99), UINT_C(130), UINT_C(83), UINT_C(99), }
+#define DHCP4_MAGIC_LEN		4
+
+/*
+ *  UDP ãã¼ãçªå·
+ */
+
+#ifndef DHCP4_SRV_CFG_PORTNO
+#define DHCP4_SRV_CFG_PORTNO	67	/* server	*/
+#endif
+
+#ifndef DHCP4_CLI_CFG_PORTNO
+#define DHCP4_CLI_CFG_PORTNO	68	/* client	*/
+#endif
+
+#endif	/* of #ifndef DHCP4_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c	(revision 331)
@@ -0,0 +1,2131 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The Internet Software Consortium nor the names
+ *    of its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/if_ether.h>
+
+#include <net/if_var.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/dhcp4_cli.h>
+#include <netapp/dhcp4_cli_var.h>
+#include <netapp/resolver.h>
+#include "lcd.h"
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/*
+ *  å¤æ°
+ */
+
+static T_DHCP4_CLI_CONTEXT	context;			/* ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ã	*/
+static uint8_t	magicno[DHCP4_MAGIC_LEN] = DHCP4_RFC1048_MAGIC;	/* magic çªå·ï¼RFC1048ï¼*/
+
+/* å¿
+é ãªãã·ã§ã³ãªã¹ã */
+#ifdef DHCP4_CLI_CFG_REQUIRED_OLIST
+static uint8_t	required_plist[] = DHCP4_CLI_CFG_REQUIRED_OLIST;
+#endif
+
+/* è¦æ±ãªãã·ã§ã³ãªã¹ã */
+#ifdef DHCP4_CLI_CFG_REQUEST_OLIST
+static uint8_t	request_plist[] = DHCP4_CLI_CFG_REQUEST_OLIST;
+#endif
+
+/*
+ *  dhcp4_cksum -- ãã§ãã¯ãµã ã®è¨ç®é¢æ°
+ */
+
+static uint32_t
+dhcp4_cksum (void *data, uint_t len /*ãªã¯ãããåä½*/)
+{
+	uint32_t carry, sum = 0;
+
+	for ( ; len > 0; len -= 2) {
+		sum += (*(uint8_t*)data << 8) + *((uint8_t*)data + 1);
+		data = (uint8_t*)data + 2;
+		}
+
+	while (sum >= 0x00010000) {
+		carry = sum >> 16;
+		sum   = (sum & 0xffff) + carry;
+		}
+
+	return sum;
+	}
+
+/*
+ *  create_xid -- ãã©ã³ã¶ã¯ã·ã§ã³ ID ãçæããã
+ */
+
+static uint32_t
+create_xid (void)
+{
+	T_IF_SOFTC	*ic;
+	SYSTIM		time;
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	get_tim(&time);
+	return (dhcp4_cksum((void*)&ic->ifaddr.lladdr, ETHER_ADDR_LEN) << 16)
+	      + dhcp4_cksum((void*)&time, sizeof(time));
+	}
+
+/*
+ *  find_option_sub -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° size ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ */
+
+static uint8_t *
+find_option_sub (T_DHCP4_CLI_MSG *msg, uint_t off, uint_t len, 
+                                      uint_t tag, uint_t size, bool_t overload)
+{
+	uint8_t	*opt, *tmp;
+
+	opt = (uint8_t*)&msg->msg + off;
+	while (opt < (uint8_t*)&msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE) {
+				tmp = find_option_sub(msg, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, tag, len, false);
+				if (tmp != NULL)
+					return tmp;
+				}
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME) {
+				tmp = find_option_sub(msg, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, tag, len, false);
+				if (tmp != NULL)
+					return tmp;
+				}
+			opt += *(opt + 1) + 2;
+			}
+		else if (*opt == tag && (size == 0 || *(opt + 1) == size))
+			return opt;
+		else
+			opt += *(opt + 1) + 2;
+		}
+	return NULL;
+	}
+
+/*
+ *  find_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° size ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ */
+
+static uint8_t *
+find_option (T_DHCP4_CLI_MSG *msg, uint_t tag, uint_t size)
+{
+	return find_option_sub(msg, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	                       msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN),
+	                       tag, size, true);
+	}
+
+/*
+ *  is_equal_sid -- ã¡ãã»ã¼ã¸å
+ã® SERVER ID ãæ¯è¼ããã
+ */
+
+static bool_t
+is_equal_sid (T_DHCP4_CLI_MSG *msg1, T_DHCP4_CLI_MSG *msg2)
+{
+	uint8_t	*opt1, *opt2;
+
+	if ((opt1 = find_option(msg1, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return false;
+	if ((opt2 = find_option(msg2, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return false;
+
+	return msg2host32(opt1) == msg2host32(opt2);
+	}
+
+/*
+ *  timer_value -- ã¡ãã»ã¼ã¸ããæéæ
+å ±ãåãåºãã
+ */
+
+static uint32_t
+timer_value (T_DHCP4_CLI_MSG *msg, uint_t tag, uint32_t def_value)
+{
+	uint8_t 	*opt;
+	uint32_t	seconds;
+
+	if ((opt = find_option(msg, tag, sizeof(uint32_t))) == NULL)
+		return def_value;
+	else {
+
+		/* ãµã¼ãããã®ãªã¼ã¹æéã¯[s]ã*/
+		seconds = msg2host32(opt + 2);
+
+		/* ã³ã³ãã­ã¹ãå
+ã®ãªã¼ã¹æéã¯ SYSTIM_HZã*/
+		if (seconds == DHCP4_TIME_INFINITY)
+			return DHCP4_TIME_INFINITY;
+		else if (seconds > SYSTIM2SEC(DHCP4_TIME_INFINITY))
+			return DHCP4_TIME_INFINITY;
+		else
+			return SEC2SYSTIM(seconds);
+		}
+	}
+
+/*
+ *  rel_addr -- IPv4 ã¢ãã¬ã¹ããµãããããã¹ã¯ãéççµè·¯è¡¨ãè§£æ¾ããã
+ */
+
+static void
+rel_addr (void)
+{
+	ER	error;
+	uint_t	count = 0;
+
+	if ((error = in4_add_ifaddr(IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, IPv4 addr: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(0, IPV4_ADDRANY, IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(1, IPV4_ADDRANY, IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(2, 0xffffffff, 0xffffffff, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if (count == 0) {
+		syslog(LOG_NOTICE, "[DHCP4C] release IPv4 addr.");
+
+#if 0
+#ifdef USE_LCD
+		dly_tsk(1 * 1000);
+		lcd_puts(LCD_PORTID, "0.0.0.0\n");
+#endif	/* of #ifdef USE_LCD */
+#endif
+
+		}
+	}
+
+/*
+ *  rel_options -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã
+ */
+
+static void
+rel_options (T_DHCP4_CLI_CONTEXT *ct, uint_t off, uint_t len, bool_t overload)
+{
+#if defined(USE_RESOLVER)
+	T_IN4_ADDR	addr;
+#endif
+
+	uint8_t	*opt;
+
+	opt = (uint8_t*)&ct->act_msg->msg + off;
+	while (opt < (uint8_t*)&ct->act_msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE)
+				rel_options(ct, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, false);
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME)
+				rel_options(ct, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, false);
+			opt += *(opt + 1) + 2;
+			}
+		else {
+
+			switch (*opt) {
+
+#if defined(USE_RESOLVER)
+
+			case DHCP4_OPT_DNS_SERVER:
+				addr = IPV4_ADDRANY;
+				dns_in4_set_addr(&addr);
+				break;
+
+			case DHCP4_OPT_HOST_NAME:
+				break;
+
+			case DHCP4_OPT_DOMAIN_NAME:
+				dns_in4_set_dname("", 0);
+				break;
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_DNS_SERVER:
+			case DHCP4_OPT_HOST_NAME:
+			case DHCP4_OPT_DOMAIN_NAME:
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_SUBNET_MASK:
+			case DHCP4_OPT_ROUTER:
+			case DHCP4_OPT_LEASE_TIME:
+			case DHCP4_OPT_RENEWAL_T1:
+			case DHCP4_OPT_REBINDING_T2:
+				break;
+
+			default:
+				break;
+				}
+
+			opt += *(opt + 1) + 2;
+			}
+		}
+	}
+
+/*
+ *  rel_lease -- ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã
+ */
+
+static void
+rel_lease (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãç¡ããã°ä½ãããªãã*/
+	if (ct->act_msg == NULL)
+		return;
+
+	/* ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã*/
+	rel_options(ct, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	              ct->act_msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN), true);
+	rel_addr();
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+	syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)ct->act_msg));
+	ct->act_msg = NULL;
+	}
+
+/*
+ *  set_addr -- IPv4 ã¢ãã¬ã¹ããµãããããã¹ã¯ãéççµè·¯è¡¨ãè¨­å®ããã
+ */
+
+static void
+set_addr (T_DHCP4_CLI_CONTEXT *ct, uint8_t *mopt, uint8_t *ropt)
+{
+	ER		error;
+	T_IN4_ADDR	addr, mask, router, net_addr;
+
+	addr     = ntohl(ct->act_msg->msg.yiaddr);
+	mask     = msg2host32(mopt + 2);
+	net_addr = addr & mask;
+	router   = msg2host32(ropt + 2);
+	
+	if ((error = in4_add_ifaddr(addr, mask)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set IPv4 addr: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(0, IPV4_ADDRANY, IPV4_ADDRANY, router)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(1, net_addr, mask, IPV4_ADDRANY)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(2, 0xffffffff, 0xffffffff, IPV4_ADDRANY)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if (error == E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] set IPv4 addr: %s.", ip2str(NULL, &addr));
+
+#ifdef USE_LCD
+		dly_tsk(1 * 1000);
+		lcd_puts(LCD_PORTID, ip2str(NULL, &addr));
+		lcd_putc(LCD_PORTID, '\n');
+#endif	/* of #ifdef USE_LCD */
+	if (ct->set_addr_callback != NULL)
+		ct->set_addr_callback();
+
+		}
+	}
+
+/*
+ *  set_options -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã
+ */
+
+static void
+set_options (T_DHCP4_CLI_CONTEXT *ct, uint_t off, uint_t len, bool_t overload)
+{
+#if defined(USE_RESOLVER)
+	T_IN4_ADDR	addr;
+#endif
+
+	uint8_t	*opt, *mopt = NULL, *ropt = NULL;
+
+	opt = (uint8_t*)&ct->act_msg->msg + off;
+	while (opt < (uint8_t*)&ct->act_msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE)
+				set_options(ct, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, false);
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME)
+				set_options(ct, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, false);
+			opt += *(opt + 1) + 2;
+			}
+		else {
+
+			switch (*opt) {
+			case DHCP4_OPT_SUBNET_MASK:
+				mopt = opt;
+				break;
+
+			case DHCP4_OPT_ROUTER:
+				ropt = opt;
+				break;
+
+#if defined(USE_RESOLVER)
+
+			case DHCP4_OPT_DNS_SERVER:
+				addr = msg2host32(opt + 2);
+				dns_in4_set_addr(&addr);
+				break;
+
+			case DHCP4_OPT_HOST_NAME:
+				break;
+
+			case DHCP4_OPT_DOMAIN_NAME:
+				dns_in4_set_dname(opt + 2, *(opt + 1));
+				break;
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_DNS_SERVER:
+			case DHCP4_OPT_HOST_NAME:
+			case DHCP4_OPT_DOMAIN_NAME:
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_LEASE_TIME:
+			case DHCP4_OPT_RENEWAL_T1:
+			case DHCP4_OPT_REBINDING_T2:
+				break;
+
+			default:
+				break;
+				}
+
+			opt += *(opt + 1) + 2;
+			}
+		}
+	if (!(mopt == NULL || ropt == NULL))
+		set_addr(ct, mopt, ropt);
+	}
+
+/*
+ *  set_lease -- ãªã¼ã¹ãããæ
+å ±ãè¨­å®ããã
+ */
+
+static void
+set_lease (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã*/
+	set_options(ct, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	              ct->act_msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN), true);
+	}
+
+/*
+ *  validate_duplicate -- æå®ããã IPv4 ã¢ãã¬ã¹ãä½¿ããã¦ããªããæ¤è¨¼ããã
+ *
+ *    ä½¿ããã¦ããªãæã¯ true ãè¿ãã
+ */
+
+static bool_t
+validate_duplicate (T_DHCP4_CLI_MSG *msg)
+{
+	T_IN4_ADDR	yiaddr;
+
+	/* æå®ããã IPv4 ã¢ãã¬ã¹ã ADDR ANY ãªãä½¿ããã¦ããªãã¨å¤æ­ããã*/
+	yiaddr = ntohl(msg->msg.yiaddr);
+	if (yiaddr == IPV4_ADDRANY)
+		return true;
+
+	/* ARP ã­ã£ãã·ã¥ã«ããã°ä½¿ããã¦ããã¨å¤æ­ããã*/
+	if (arp_lookup(yiaddr, false) != NULL)
+		return false;
+
+	/*
+	 *  ARP è¦æ±ãåºåãã¦ TMO_DHCP4C_ARP_WAIT å¾
+ã¡ã
+	 *  ARP ã­ã£ãã·ã¥ã«ãªããã°ä½¿ããã¦ããªãã¨å¤æ­ããã
+	 */
+	arp_request(&IF_ETHER_NIC_GET_SOFTC()->ifaddr, yiaddr);
+	dly_tsk(TMO_DHCP4C_ARP_WAIT);
+	return arp_lookup(yiaddr, false) == NULL;
+	}
+
+/*
+ *  validate_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_rcv_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *msg)
+{
+	uint8_t 	*opt;
+
+	/* packet type ã DHCP4_REPLY ã§ãããã¨ãç¢ºèªããã*/
+	if (!(msg->msg.op == DHCP4_REPLY))
+		return false;
+
+	/* ã¡ãã»ã¼ã¸ã¿ã¤ããªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_option(msg, DHCP4_OPT_MSG_TYPE, 1)) == NULL)
+		return E_PAR;
+
+	/* ã¡ãã»ã¼ã¸ã®ã¿ã¤ããä¸è´ãã¦ãããã¨ãæ¤è¨¼ããã*/
+	msg->type = *(opt + 2);
+	switch (ct->fsm) {
+
+	case DHCP4_FSM_SELECT:
+		if (!(msg->type == DHCP4_MTYPE_OFFER))
+			return E_PAR;
+		break;
+
+	case DHCP4_FSM_REQUEST:
+	case DHCP4_FSM_REBOOT:
+	case DHCP4_FSM_RENEW:
+	case DHCP4_FSM_REBIND:
+	case DHCP4_FSM_REL_INFO:
+		if (!((msg->type == DHCP4_MTYPE_ACK) || (msg->type == DHCP4_MTYPE_NAK)))
+			return E_PAR;
+		break;
+
+	case DHCP4_FSM_INIT:
+	case DHCP4_FSM_BOUND:
+	case DHCP4_FSM_INIT_REBOOT:
+		return E_PAR;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP4C] error, unknown state: %d.", ct->fsm);
+		return E_PAR;
+		break;
+		}
+
+	/* ãã¸ãã¯çªå·ãæ¤è¨¼ããã*/
+	if (memcmp((uint8_t*)&msg->msg.options, magicno, DHCP4_MAGIC_LEN))
+		return E_PAR;
+
+	/* ãã©ã³ã¶ã¯ã·ã§ã³ ID ãç°ãªã£ã¦ããã°ã¨ã©ã¼ */
+	if (ntohl(msg->msg.xid) != ct->xid)
+		return E_PAR;
+
+	/* ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹é·ã 6ï¼MAC ã¢ãã¬ã¹é·ï¼ã§ãªããã°ã¨ã©ã¼ */
+	if (msg->msg.hlen != ETHER_ADDR_LEN)
+		return E_PAR;
+
+	/* ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹ãç°ãªã£ã¦ããã°ã¨ã©ã¼ */
+	if (memcmp(&msg->msg.chaddr, &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr)))
+		return E_PAR;
+
+	/*
+	 *  ã¡ãã»ã¼ã¸ã¿ã¤ãã OFFER ã®å ´åã¯ã
+	 *  ARP ãä½¿ç¨ãã¦ãæå®ããã IPv4 ã¢ãã¬ã¹ãä½¿ããã¦ããªããæ¤è¨¼ããã
+	 *  ä½¿ããã¦ããæã¯ãä»ã® IPv4 ã¢ãã¬ã¹ã®æä¾ãå¾
+ã¤ã
+	 */
+	if (msg->type == DHCP4_MTYPE_OFFER) {
+		if (!validate_duplicate(msg))
+			return E_PAR;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  eval_prefer -- åä¿¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_prefer (T_DHCP4_CLI_MSG *msg)
+{
+	int	ix;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (msg == NULL)
+		return;
+
+	/* æå®ããã IPv4 ã¢ãã¬ã¹ã ADDR ANY ãªãæ¨å¥¨åº¦ã 0ã«è¨­å®ããã*/
+	if (ntohl(msg->msg.yiaddr) == IPV4_ADDRANY)
+		msg->prefer = 0;
+	else
+		msg->prefer = DHCP4_CLI_CFG_PREFER_ADDR;
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		if (find_option(msg, request_plist[ix], 0) != NULL)
+			msg->prefer ++;
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		if (find_option(msg, required_plist[ix], 0) == NULL)
+			msg->prefer = 0;
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+	}
+
+/*
+ *  eval_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãè©ä¾¡ããã
+ */
+
+static ER
+eval_rcv_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*evl, *msg;
+
+	/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	if (ct->val_lst == NULL) {
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* æ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãããè©ä¾¡ã¡ãã»ã¼ã¸ãåãåºãã*/
+	evl         = ct->val_lst;
+	ct->val_lst = ct->val_lst->next;
+	evl->next   = NULL;
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if (validate_rcv_msg(ct, evl) != E_OK) {
+
+		/* ã¨ã©ã¼ãçºçããè©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		goto rcv_ret;
+		}
+
+	/* åä¿¡ããã¡ãã»ã¼ã¸ã NAK ã®æã®å¦ç */
+	if (evl->type == DHCP4_MTYPE_NAK) {
+
+		/* ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* å
+é¨ã¨ã©ã¼ãè¨­å®ãã¦çµäºããã*/
+		return E_PAR;
+		}
+
+	/* REL_INFO ç¶æ
+ã®æã®å¦ç */
+	//cons_printf(CONSOLE_PORTID, "evl_rcv_msg3[s=%d]\n", ct->fsm);
+	if (ct->fsm == DHCP4_FSM_REL_INFO) {
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã*/
+	eval_prefer(evl);
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããç©ºãªãè©ä¾¡ã¡ãã»ã¼ã¸ãç§»ãã¦çµäºããã*/
+	if (ct->prf_lst == NULL) {
+		ct->max_prefer = evl->prefer;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã¨æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ãæ¯è¼ããã*/
+	if (evl->prefer > ct->max_prefer) {
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããé«ããã°ã
+		 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		ct->max_prefer = evl->prefer;
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		if (ct->rcv_lst == NULL)
+			ct->rcv_lst = ct->prf_lst;
+		else {
+			for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+				;
+			msg->next = ct->prf_lst;
+			}
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	else if (evl->prefer == ct->max_prefer) {
+		for (msg = ct->prf_lst; msg != NULL; msg = msg->next) {
+			if (is_equal_sid(evl, msg)) {
+
+				/*
+				 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«åã DHCP4_OPT_SERVER_ID ã®ã¡ãã»ã¼ã¸ãããã°ã
+				 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+				 */
+				goto rcv_ret;
+				}
+			}
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+	
+	/*else */
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããä½ããã°ã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+
+rcv_ret:
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	evl->next   = ct->rcv_lst;
+	ct->rcv_lst = evl;
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+	return E_OK;
+	}
+
+/*
+ *  select_msg -- æ¨å¥¨ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static T_DHCP4_CLI_MSG*
+select_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG		*msg, *select;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	if (ct->prf_lst == NULL) {
+		/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return NULL;
+		}
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã*/
+	select = ct->prf_lst;
+	ct->prf_lst  = ct->prf_lst->next;
+	select->next = NULL;
+
+	/* é¸æãããªãã£ãæ¤è¨¼ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->rcv_lst == NULL)
+		ct->rcv_lst = ct->prf_lst;
+	else {
+		for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+			;
+		msg->next = ct->prf_lst;
+		}
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+	return select;
+	}
+
+/*
+ *  select_ack -- ACK ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ *
+ *    åãå
+¥ãããã¨ãå¯è½ã®æã¯ true ãè¿ãã
+ */
+
+static bool_t
+select_ack (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*msg;
+
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ããã°ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->act_msg != NULL) {
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		ct->act_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->act_msg;
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		}
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ã«è¨­å®ããã*/
+	ct->act_msg = msg;
+	return true;
+	}
+
+/*
+ *  select_offer -- OFFER ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ *
+ *    åãå
+¥ãããã¨ãå¯è½ã®æã¯ true ãè¿ãã
+ */
+
+static bool_t
+select_offer (T_DHCP4_CLI_CONTEXT *ct)
+{
+	return (ct->off_msg = select_msg(ct)) != NULL;
+	}
+
+/*
+ *  cancel_all_timers -- å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã
+ */
+
+static void
+cancel_all_timers (T_DHCP4_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; )
+		ct->timers[ix] = 0;
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+
+/*
+ *  start_select -- DISCOVER ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_select (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* éä¿¡ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->snd_start);
+
+	/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_RCV_OFFER] = SYSTIM2TIMER(TMO_DHCP4C_OFFER);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã«ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* éä¿¡ééããªã»ããããã*/
+	ct->interval = 0;
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_SELECT;
+
+	/* DISCOVER ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_DISC;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  start_bound -- BOUND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_bound (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹ãããæ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* ãªã¼ã¹ã®æå¹æéãè¨­å®ããã*/
+	ct->expire = timer_value(ct->act_msg, DHCP4_OPT_LEASE_TIME, TMO_DHCP4C_DEF_LEASE);
+
+	/* ãªã¼ã¹æéã TMO_DHCP4C_MIN_LEASE ä»¥ä¸ã®æã¯ãTMO_DHCP4C_MIN_LEASE ã«è¨­å®ããã*/
+	if (ct->expire < TMO_DHCP4C_MIN_LEASE)
+		ct->expire = TMO_DHCP4C_MIN_LEASE;
+
+	/* RENEW ç¶æ
+ã¾ã§ã®æéãè¨­å®ããã*/
+	ct->renew = timer_value(ct->act_msg, DHCP4_OPT_RENEWAL_T1, ct->expire / 2);
+
+	/* REBIND ç¶æ
+ã¾ã§ã®æéãè¨­å®ããã*/
+	ct->rebind = timer_value(ct->act_msg, DHCP4_OPT_REBINDING_T2, ct->renew + ct->renew / 2 + ct->renew / 4);
+
+	/* EXPIREãRENEWãREBIND ã¿ã¤ãã¼ãè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_EXPIRE] = SYSTIM2TIMER(ct->expire);		/* EXPIRE      ã¾ã§ã®æé */
+	ct->timers[DHCP4C_TIMER_REBIND] = SYSTIM2TIMER(ct->rebind);		/* REBINDï¼T2ï¼ã¾ã§ã®æé */
+	ct->timers[DHCP4C_TIMER_RENEW]  = SYSTIM2TIMER(ct->renew);		/* RENEW ï¼T1ï¼ã¾ã§ã®æé */
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_BOUND;
+
+	/* BIND ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->bind_start);
+	}
+
+/*
+ *  start_send_request -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ãæå®ãããç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_send_request (T_DHCP4_CLI_CONTEXT *ct, uint_t fsm)
+{
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	/* éä¿¡ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->snd_start);
+
+	/* é·ç§»ããç¶æ
+ã RENEW ä»¥å¤ã§ã¯ ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	if (fsm != DHCP4_FSM_RENEW) { 
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_ACK] = SYSTIM2TIMER(TMO_DHCP4C_ACK);
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		}
+
+	/*
+	 *  é·ç§»ããç¶æ
+ã RENEW ã§ã
+	 *  SERVER ID ãªãã·ã§ã³ãããã°ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããéä¿¡ããã
+	 */
+	if ((fsm == DHCP4_FSM_RENEW) &&
+	    (find_option(ct->act_msg, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR)) !=  NULL))
+		ct->dst.ipaddr = (ifp->in4_ifaddr.addr &  ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
+	else
+		ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* éä¿¡ééããªã»ããããã*/
+	ct->interval = 0;
+
+	/* æå®ãããç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = fsm;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REQ;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv4 ã® RFC2131 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP4_FSM_SLEEP;
+		return;
+		}
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã«ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REL;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  setup_dhcp_com_msg -- DHCP ã¡ãã»ã¼ã¸ã®å
+±éé¨åãä½æããã
+ */
+
+static uint8_t *
+setup_dhcp_com_msg (T_DHCP4_CLI_CONTEXT *ct, uint_t op, uint_t type)
+{
+	uint8_t	*option;
+
+	memset((void*)&ct->snd_msg->msg, sizeof(ct->snd_msg->msg), 0);
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg);
+
+	/* ãããé¨ãè¨­å®ããã*/
+	ct->snd_msg->msg.op = op;
+	ct->snd_msg->msg.htype = DHCP4_HWA_TYPE_ETHER;
+	ct->snd_msg->msg.hlen = ETHER_ADDR_LEN;
+	HOST2MSG32(ct->snd_msg->msg.xid, ct->xid);
+
+	/* MAC ã¢ãã¬ã¹ãè¨­å®ããã*/
+	memcpy(&ct->snd_msg->msg.chaddr, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+
+	/*
+	 *  ãªãã·ã§ã³é¨ãè¨­å®ããã
+	 */
+
+	/* RFC1048 ã«å®ç¾©ããã¦ãããã¸ãã¯çªå·ãè¨­å®ããã*/
+	memcpy(&ct->snd_msg->msg.options, magicno, DHCP4_MAGIC_LEN);
+	option = ct->snd_msg->msg.options + DHCP4_MAGIC_LEN;
+
+	/* DHCP ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	*(option ++) = DHCP4_OPT_MSG_TYPE;
+	*(option ++) = 1;
+	*(option ++) = type;
+
+	return option;
+	}
+
+/*
+ *  setup_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_release_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *ref)
+{
+	uint8_t *opt, *ref_opt;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ããªããã°ã¨ã©ã¼ */
+	if (ref == NULL)
+		return E_PAR;
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_RELEASE)) == NULL)
+		return E_PAR;
+
+	/*
+	 *  ãµã¼ã IDï¼server-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if ((ref_opt = find_option(ref, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return E_PAR;
+	*(opt ++) = *(ref_opt ++);
+	*(opt ++) = *(ref_opt ++);
+	memcpy(opt, ref_opt, *(ref_opt - 1));
+	opt += *(ref_opt - 1);
+
+	/* 
+	 *  ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/*
+	 *  ã¯ã©ã¤ã¢ã³ã IP ã¢ãã¬ã¹ï¼ciaddrï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	HOST2MSG32(ct->snd_msg->msg.ciaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+
+/*
+ *  setup_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_request_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *ref)
+{
+	uint8_t *opt, *ref_opt;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+	uint_t	len = 0;
+#endif
+
+	/* åç
+§ããã¡ãã»ã¼ã¸ããªããã°ã¨ã©ã¼ */
+	if (ref == NULL)
+		return E_PAR;
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_REQUEST)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¿½å ã®ãªãã·ã§ã³ãè¨­å®ããã*/
+
+	*opt  = DHCP4_OPT_REQ_PARAM;
+	 opt += 2;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(required_plist) > 0) {
+		memcpy(opt, required_plist, sizeof(required_plist));
+		opt += sizeof(required_plist);
+		len += sizeof(required_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(request_plist) > 0) {
+		memcpy(opt, request_plist, sizeof(request_plist));
+		opt += sizeof(request_plist);
+		len += sizeof(request_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	*(opt - len - 1) = len;
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	/*
+	 *  ãµã¼ã IDï¼server-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if (ct->fsm == DHCP4_FSM_REQUEST) {
+		if ((ref_opt = find_option(ref, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+			return E_PAR;
+		*(opt ++) = *(ref_opt ++);
+		*(opt ++) = *(ref_opt ++);
+		memcpy(opt, ref_opt, *(ref_opt - 1));
+		opt += *(ref_opt - 1);
+		}
+
+	/*
+	 *  è¦æ± IP ã¢ãã¬ã¹ï¼requested-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 *  RFC2131 ã§ã¯ãDHCP4_FSM_RENEW ã®æ MUST NOT ã«ãªã£ã¦ãããã
+	 *  MUST ã®ããã§ããã
+	 */
+	*(opt ++) = DHCP4_OPT_REQ_IPV4;
+	*(opt ++) = sizeof(ref->msg.yiaddr);
+	if (ct->fsm == DHCP4_FSM_REQUEST || ct->fsm == DHCP4_FSM_INIT_REBOOT ||
+	    ct->fsm == DHCP4_FSM_RENEW   || ct->fsm == DHCP4_FSM_REBIND)
+	 	/* åç
+§ã¡ãã»ã¼ã¸ã¨åã IP ã¢ãã¬ã¹ï¼requested-ipï¼ãè¦æ±ããã*/
+		memcpy(opt, (uint8_t*)&ref->msg.yiaddr, sizeof(ref->msg.yiaddr));
+	else
+		host2msg32(opt, IPV4_ADDRANY);
+	opt += sizeof(ref->msg.yiaddr);
+
+	/* 
+	 *  ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/*
+	 *  ã¯ã©ã¤ã¢ã³ã IP ã¢ãã¬ã¹ï¼ciaddrï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if (ct->fsm == DHCP4_FSM_RENEW || ct->fsm == DHCP4_FSM_REBIND)
+		HOST2MSG32(ct->snd_msg->msg.ciaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+	else
+		HOST2MSG32(ct->snd_msg->msg.ciaddr, IPV4_ADDRANY);
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+/*
+ *  setup_discover_msg -- DISCOVER ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_discover_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	uint8_t *opt;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+	uint_t	len = 0;
+#endif
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_DISCOVER)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¿½å ã®ãªãã·ã§ã³ãè¨­å®ããã*/
+
+	*opt  = DHCP4_OPT_REQ_PARAM;
+	 opt += 2;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(required_plist) > 0) {
+		memcpy(opt, required_plist, sizeof(required_plist));
+		opt += sizeof(required_plist);
+		len += sizeof(required_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(request_plist) > 0) {
+		memcpy(opt, request_plist, sizeof(request_plist));
+		opt += sizeof(request_plist);
+		len += sizeof(request_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	*(opt - len - 1) = len;
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	/* æ¢ã«ã¢ãã¬ã¹æ
+å ±ããªã¼ã¹ããã¦ããã°ãåã IP ã¢ãã¬ã¹ãè¦æ±ããã*/
+	if (ct->act_msg != NULL) {
+		*(opt ++) = DHCP4_OPT_REQ_IPV4;
+		*(opt ++) = sizeof(ct->act_msg->msg.yiaddr);
+		memcpy(opt, (uint8_t*)&ct->act_msg->msg.yiaddr, sizeof(ct->act_msg->msg.yiaddr));
+		opt += sizeof(ct->act_msg->msg.yiaddr);
+		}
+
+	/* ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+/*
+ *  ack_msg_timeout -- ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+ack_msg_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ACK ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_ack(ct)) {
+
+		/* REQUEST ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_SND_REQ] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/*
+		 *  ç¶æ
+ã REQUEST ã®æã¯ã
+		 *  OFFER ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+		if (ct->fsm == DHCP4_FSM_REQUEST && ct->off_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->off_msg;
+			syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg = NULL;
+			}
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+	else {
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		ct->error = E_TMOUT;
+		}
+	}
+
+/*
+ *  send_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_request_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*ref;
+	ER		error;
+	SYSTIM		time;
+	RELTIM		interval;
+	uint16_t	secs;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* ACK ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_ack(ct)) {
+
+		/* ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_ACK] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/*
+		 *  ç¶æ
+ã REQUEST ã®æã¯ã
+		 *  OFFER ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+		if (ct->fsm == DHCP4_FSM_REQUEST && ct->off_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->off_msg;
+			syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg = NULL;
+			}
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		ref = ct->off_msg;
+	else
+		ref = ct->act_msg;
+	if ((error = setup_request_msg(ct, ref)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup request message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ãéå§ãã¦ããã®æéãå¾ãã*/
+	get_tim(&time);
+	interval = time - ct->snd_start;
+
+	/*
+	 * éä¿¡ãéå§ãã¦ããã®æéï¼ç§ï¼ãã¡ãã»ã¼ã¸ã«è¨­å®ããã
+	 * æå¤§å¤ã¯ 65535ã
+	 */
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		secs = ct->secs;
+	else {
+		if (SYSTIM2SEC(interval) < 65536)
+			secs = SYSTIM2SEC(interval);
+		else
+			secs = 65535;
+		}
+	HOST2MSG16(ct->snd_msg->msg.secs, secs);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send request message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ééãè¨­å®ããã*/
+	if (ct->interval == 0)
+		/* æªè¨­å® */
+		ct->interval = TMO_DHCP4C_INIT_INTVL;
+	else
+		/* ããã¯ãªãã¢ã«ã´ãªãºã ã§ 2åã«ããï¼ä¹±æ°ä½¿ç¨ï¼éä¿¡ééãå ç®ããã*/
+		ct->interval += (netapp_rand() >> 2) % (ct->interval << 1);
+	
+	/* éä¿¡å¨æã®å¶éå¤ãè¶
+ããªãããã«ããã*/
+	if (ct->interval > TMO_DHCP4C_MAX_BACKOFF)
+		ct->interval = (TMO_DHCP4C_MAX_BACKOFF >> 1) + ((netapp_rand() >> 2) % TMO_DHCP4C_MAX_BACKOFF);
+
+	/* ãªã¼ã¹æéã®ã¿ã¤ã ã¢ã¦ããå
+éãã */
+	if (ct->fsm != DHCP4_FSM_REQUEST &&
+	    TIMEC_GT(ct->interval + time, ct->expire + ct->bind_start))
+		ct->interval = ct->expire + ct->bind_start - time + SYSTIM_HZ;
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_SND_REQ] = SYSTIM2TIMER(ct->interval);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+/*
+ *  send_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_release_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER		error;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_release_msg(ct, ct->act_msg)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup release message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send release message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* ã¡ãã»ã¼ã¸éä¿¡å¾
+ã¡ãè¡ãã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_READY));
+
+	/* SLEEP ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_SLEEP;
+	}
+
+/*
+ *  offer_msg_timeout -- OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+offer_msg_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* OFFER ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãREQUEST ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_offer(ct)) {
+
+		/* DISCOVER ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_SND_DISC] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
+ã«é·ç§»ããã*/
+		start_send_request(ct, DHCP4_FSM_REQUEST);
+		}
+	else
+		ct->error = E_TMOUT;
+	}
+
+/*
+ *  send_discover_msg -- DISCOVERã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_discover_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER	error;
+	SYSTIM	time;
+	RELTIM	interval;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* OFFER ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãREQUEST ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_offer(ct)) {
+
+		/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_OFFER] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
+ã«é·ç§»ããã*/
+		start_send_request(ct, DHCP4_FSM_REQUEST);
+		return;
+		}
+
+	/* DISCOVER ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_discover_msg(ct)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup discover message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ãéå§ãã¦ããã®æéãå¾ãã*/
+	get_tim(&time);
+	interval = time - ct->snd_start;
+
+	/*
+	 * éä¿¡ãéå§ãã¦ããã®æéï¼ç§ï¼ãã¡ãã»ã¼ã¸ã«è¨­å®ããã
+	 * æå¤§å¤ã¯ 65535ã
+	 */
+	if (SYSTIM2SEC(interval) < 65536)
+		ct->secs = SYSTIM2SEC(interval);
+	else
+		ct->secs = 65535;
+	HOST2MSG16(ct->snd_msg->msg.secs, ct->secs);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send discover message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ééãè¨­å®ããã*/
+	if (ct->interval == 0)
+		/* æªè¨­å® */
+		ct->interval = TMO_DHCP4C_INIT_INTVL;
+	else
+		/* ããã¯ãªãã¢ã«ã´ãªãºã ã§ 2åã«ããï¼ä¹±æ°ä½¿ç¨ï¼éä¿¡ééãå ç®ããã*/
+		ct->interval += (netapp_rand() >> 2) % (ct->interval << 1);
+	
+	/* éä¿¡å¨æã®å¶éå¤ãè¶
+ããªãããã«ããã*/
+	if (ct->interval > TMO_DHCP4C_MAX_BACKOFF)
+		ct->interval = (TMO_DHCP4C_MAX_BACKOFF >> 1) + ((netapp_rand() >> 2) % TMO_DHCP4C_MAX_BACKOFF);
+
+	/* OFFER ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¶
+ããªãããã«èª¿æ´ããã*/
+	if (TIMEC_GT(time + ct->interval, ct->snd_start + TMO_DHCP4C_OFFER))
+		ct->interval = (TMO_DHCP4C_INIT_INTVL + TMO_DHCP4C_OFFER) - time + 1;
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_SND_DISC] = SYSTIM2TIMER(ct->interval);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+/*
+ *  dhcpc_timer -- TIMER ç®¡ç
+ */
+
+static void
+dhcpc_timer (T_DHCP4_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; ) {
+		if (ct->timers[ix] != 0) {
+			ct->timers[ix] --;
+			if (ct->timers[ix] == 0) {
+				ct->flags = (ct->flags & ~DHCP4C_FLAG_TMOUT_MASK) | DHCP4C_FLAG_TMOUT_TIMER | ix;
+				syscall(sig_sem(SEM_DHCP4_CLI_READY));
+				}
+			}
+		}
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããã*/
+	timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ);
+	}
+
+/*
+ *  expire_timeout -- EXPIRE ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+expire_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	//ER	error;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* ç¶æ
+ã REQUEST ã®æã¯ä½ãããªãã*/
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		return;
+
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	ct->error = E_TMOUT;
+	}
+
+/*
+ *  rebind_timeout -- REBIND ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+rebind_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REBIND ç¶æ
+ã«é·ç§»ããã*/
+	start_send_request(ct, DHCP4_FSM_REBIND);
+	}
+
+/*
+ *  renew_timeout -- RENEW ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+renew_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ RENEW ç¶æ
+ã«é·ç§»ããã*/
+	start_send_request(ct, DHCP4_FSM_RENEW);
+	}
+
+/*
+ *  dispatch_timeout -- ã¿ã¤ã ã¢ã¦ãããæã®å¦ç
+ */
+
+static ER
+dispatch_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	switch (ct->flags & DHCP4C_FLAG_TMOUT_TIMER_MASK) {
+
+	case DHCP4C_TIMER_SND_DISC:
+		send_discover_msg(ct);
+		break;
+
+	case DHCP4C_TIMER_SND_REQ:
+		send_request_msg(ct);
+		break;
+
+	case DHCP4C_TIMER_RCV_OFFER:
+		offer_msg_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_RCV_ACK:
+		ack_msg_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_RENEW:
+		renew_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_REBIND:
+		rebind_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_EXPIRE:
+		expire_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_SND_REL:
+		send_release_msg(ct);
+		break;
+
+	default:
+		break;
+		}
+
+	return ct->error;
+	}
+
+/*
+ *  dispatch_event -- ã¤ãã³ãæ¯ã®å¦ç
+ */
+
+static ER
+dispatch_event (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER	error = E_OK;
+
+	while (ct->fsm != DHCP4_FSM_SLEEP && error == E_OK) {
+
+		/* ã¡ãã»ã¼ã¸ã®åä¿¡ã¨ã¿ã¤ã ã¢ã¦ããå¾
+ã¤ã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_READY));
+
+		if (ct->flags & DHCP4C_FLAG_RCV_MSG) {
+			while (ct->val_lst != NULL) {
+				error = eval_rcv_msg(ct);
+				}
+			ct->flags &= ~DHCP4C_FLAG_RCV_MSG;
+			}
+		if (ct->flags & DHCP4C_FLAG_TMOUT_MASK)
+			error = dispatch_timeout(ct);
+
+		if (ct->error != E_OK)
+			error = ct->error;
+		}
+
+	return error;
+	}
+
+/*
+ *  init_context -- DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã
+ */
+
+static void
+init_context (T_DHCP4_CLI_CONTEXT *ct, ID cepid)
+{
+  	memset(ct, 0, sizeof(*ct));
+	ct->cepid	= cepid;
+	ct->sc		= IF_ETHER_NIC_GET_SOFTC();
+	ct->dst.portno	= DHCP4_SRV_CFG_PORTNO;
+	ct->dst.ipaddr	= IPV4_ADDRANY;
+	ct->set_addr_callback = DHCP4_CLI_SET_ADDR_CALLBACK;
+	}
+
+/*
+ *  rel_cli_msg -- ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã
+ */
+
+static void
+rel_cli_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*ptr, *cell;
+
+	for (ptr = ct->rcv_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->val_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->prf_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	if (ct->snd_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)ct->snd_msg));
+	ct->rcv_lst = ct->prf_lst = ct->val_lst = ct->snd_msg = NULL;
+	}
+
+/*
+ *  init_cli_msg -- åã¡ãã»ã¼ã¸æ§é ä½ãåæåããã
+ */
+
+static ER
+init_cli_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*cell;
+	ER		error;
+	int		count;
+
+	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	if ((error = tget_mpf(MPF_DHCP4_CLI_MSG, (void*)&ct->snd_msg, TMO_DHCP4C_MPF_GET)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, tget_mpf() for send: %s.", itron_strerror(error));
+		return error;
+		}
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãããå ´åã¯ã
+	 *  ç²å¾ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã®æ§é ä½ã 1æ¸ããã
+	 */
+	if (ct->act_msg == NULL)
+		count = NUM_DHCP4_MSG_LIST;
+	else
+		count = NUM_DHCP4_MSG_LIST - 1;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	while (count --> 0) {
+		if ((error = tget_mpf(MPF_DHCP4_CLI_MSG, (void*)&cell, TMO_DHCP4C_MPF_GET)) != E_OK) {
+			syslog(LOG_NOTICE, "[DHCP4C] error, tget_mpf() for receive: %s.", itron_strerror(error));
+			break;
+			}
+		cell->next  = ct->rcv_lst;
+		ct->rcv_lst = cell;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  dhcp4c_renew_info -- ãããã¯ã¼ã¯æ
+å ±ãååå¾ããã
+ */
+
+ER
+dhcp4c_renew_info (void)
+{
+	if (context.fsm == DHCP4_FSM_BOUND) {
+
+		/* REL_INFO ç¶æ
+ã«é·ç§»ããå¾ã« SLEEP ãè§£é¤ããããã«è¨­å®ããã*/
+		context.flags |= DHCP4C_FLAG_RENEW;
+		start_rel_info(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP4_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP4_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+	}
+
+/*
+ *  dhcp4c_rel_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè§£æ¾ããã
+ */
+
+ER
+dhcp4c_rel_info (void)
+{
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	start_rel_info(&context);
+	return E_OK;
+	}
+
+/*
+ *  dhcp4c_get_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè¿ãã
+ */
+
+ER
+dhcp4c_get_info (T_IN4_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                   uint32_t *rebind, SYSTIM *bind_start)
+{
+	if (addr  == NULL || expire == NULL || 
+	    renew == NULL || rebind == NULL || bind_start == NULL)
+		return E_PAR;
+	else if (context.act_msg == NULL)
+		return E_OBJ;
+	else {
+		*addr		= context.act_msg->srv.ipaddr;
+		*expire		= context.timers[DHCP4C_TIMER_EXPIRE];
+		*renew		= context.timers[DHCP4C_TIMER_RENEW];
+		*rebind		= context.timers[DHCP4C_TIMER_REBIND];
+		*bind_start	= context.bind_start;
+		return E_OK;
+		}
+	}
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_dhcp4_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	T_DHCP4_CLI_MSG	*msg;
+	ER_UINT		len;
+
+	len = *(ER_UINT*)p_parblk;
+	if (len < 0 && len != E_RLWAI) {
+		/* E_RLWAI ä»¥å¤ã§ã0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ãæå³ãã¦ããã*/
+		syslog(LOG_NOTICE, "[DHCPC(CBR)] error: %s, fncd: %s", itron_strerror(len), in_strtfn(fncd));
+		}
+	else {
+		if (fncd == TEV_UDP_RCV_DAT) {
+
+			/* åä¿¡ã¡ãã»ã¼ã¸ãªã¹ããç©ºã®æã¯ãåä¿¡ããªãã§ãã¼ã¿ã°ã©ã ãæ¨ã¦ãã*/
+			if (context.rcv_lst == NULL) 
+				syslog(LOG_NOTICE, "[DHCP4C(CBR)] receive buffer all busy.");
+			else {
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã¡ãã»ã¼ã¸æ§é ä½ãæºåããã*/
+				syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+				msg = context.rcv_lst;
+				context.rcv_lst = context.rcv_lst->next;
+				syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã*/
+				len = udp_rcv_dat(context.cepid, &msg->srv, &msg->msg, sizeof(msg->msg), TMO_POL);
+
+				syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+				msg->len = len;
+				if (len >= 0) {
+					/* åä¿¡ããã¡ãã»ã¼ã¸ãæ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã*/
+					msg->next = context.val_lst;
+					context.val_lst = msg;
+					context.flags |= DHCP4C_FLAG_RCV_MSG;
+					}
+				else {
+					/* ã¡ãã»ã¼ã¸æ§é ä½ãåä¿¡ã¡ãã»ã¼ã¸ãªã¹ãã«æ»ãã*/
+					context.error = len;
+					msg->next = context.rcv_lst;
+					context.rcv_lst = msg;
+					}
+				syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+				}
+			}
+		syscall(sig_sem(SEM_DHCP4_CLI_READY));
+		}
+	return E_OK;
+	}
+
+/*
+ *  dhcp4_cli_task -- DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+void
+dhcp4_cli_task (intptr_t exinf)
+{
+	T_DHCP4_CLI_CONTEXT	*ct;
+	ID			tskid;
+	ER			error;
+
+	dly_tsk(1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[DHCP4C:%d,%d] started.", tskid, (ID)exinf);
+	dly_tsk(500);
+	ct = &context;
+
+	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
+	init_context(ct, (ID)exinf);
+
+	while (true) {
+
+		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP4C_TIMER_HZ);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+		if ((error = init_cli_msg(ct)) == E_OK) {
+
+			/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+			start_select(ct);
+
+			/* ã¡ã¤ã³ã«ã¼ã */
+			error = dispatch_event(ct);
+			}
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)dhcpc_timer, ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg (ct);
+
+		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
+		if (!(ct->flags & DHCP4C_FLAG_RENEW)) {
+
+			/* ä¼æ­¢ããã*/
+			if (error == E_OK)
+				syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
+			else {
+				syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(error));
+				ct->fsm = DHCP4_FSM_SLEEP;
+				}
+			slp_tsk();
+			}
+		ct->flags = 0;
+		ct->error = E_OK;
+		}
+	}
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.cfg	(revision 331)
@@ -0,0 +1,74 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(DHCP4_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP4_DHCP_CLI_CEPID,
+	dhcp4_cli_task,
+	DHCP4_CLI_MAIN_PRIORITY,
+	DHCP4_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
+
+/* ã»ããã© */
+
+#ifdef DHCP4_CLI_CFG
+
+CRE_SEM(SEM_DHCP4_CLI_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_DHCP4_CLI_TIMER,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_DHCP4_CLI_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h	(revision 331)
@@ -0,0 +1,285 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The Internet Software Consortium nor the names
+ *    of its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_CLI_H
+#define DHCP4_CLI_H
+
+#include <netapp/dhcp4.h>
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®ã¹ã¿ãã¯ãµã¤ãº
+ */
+
+#define DHCP4_CLI_STACK_SIZE		1024		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®åªå
+åº¦
+ */
+
+#define DHCP4_CLI_MAIN_PRIORITY		5		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* æ¨å¥¨åº¦ã®å®ç¾© */
+#define DHCP4_CLI_CFG_PREFER_ADDR	100		/* ã¢ãã¬ã¹ã®æ¨å¥¨åº¦	*/
+
+/* DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸ã®åä¿¡ãªã¹ããµã¤ãºï¼2ä»¥ä¸æå®ãããã¨ï¼ */
+#define NUM_DHCP4_MSG_LIST		3
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½æ°ãå¤æ´ç¦æ­¢ã
+ *  +1 ã¯éä¿¡ç¨
+ */
+#define NUM_MPF_DHCP4_CLI_MSG		(NUM_DHCP4_MSG_LIST+1)
+
+/* 
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³
+ */
+
+/* DHCP å¿
+é ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP4_CLI_CFG_REQUIRED_OLIST
+
+#define DHCP4_CLI_CFG_REQUIRED_OLIST {	\
+	DHCP4_OPT_SUBNET_MASK,		\
+	DHCP4_OPT_ROUTER,		\
+}
+
+#endif	/* of #ifndef DHCP4_CLI_CFG_REQUIRED_OLIST */
+
+/* DHCP è¦æ±ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP4_CLI_CFG_REQUEST_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP4_CLI_CFG_REQUEST_OLIST {	\
+	DHCP4_OPT_DNS_SERVER,		\
+	DHCP4_OPT_DOMAIN_NAME,		\
+}
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP4_CLI_CFG_REQUEST_OLIST */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå¤
+ */
+
+/* åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_OFFER	ULONG_C(120*1000)	/* OFFER ã¡ãã»ã¼ã¸	*/
+#define TMO_DHCP4C_ACK		ULONG_C(60*1000)	/* ACK/NAK ã¡ãã»ã¼ã¸	*/
+
+/* ãªã¼ã¹æéã®æ¢å®å¤	*/
+#define TMO_DHCP4C_DEF_LEASE	ULONG_C(12*60*60*1000)	/* æ¨æºæé	*/
+#define TMO_DHCP4C_MIN_LEASE	ULONG_C(60*1000)	/* æå°æé	*/
+
+/* ã¡ãã»ã¼ã¸ã®éä¿¡å¨æ	*/
+#define TMO_DHCP4C_INIT_INTVL	ULONG_C(3*1000)		/* åæå¤	*/
+#define TMO_DHCP4C_MAX_BACKOFF	ULONG_C(15*1000)	/* å¶éå¤	*/
+
+/* DHCP ãµã¼ãã¸ã® UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_UDP_SND	ULONG_C(1000000)		/* [us] */
+
+/* ã¡ãã»ã¼ã¸æ§é ä½ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_MPF_GET	ULONG_C(1000000)		/* [us] */
+
+/* ARP è¦æ±ãéä¿¡ãã¦ããã®å¾
+ã¡æé	*/
+#define TMO_DHCP4C_ARP_WAIT	ULONG_C(1000000)		/* [us] */
+
+/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ããã®å¾
+ã¡æé	*/
+#define TMO_DHCP4C_SND_REL_WAIT	ULONG_C(1000000)	/* [us] */
+
+/* DHCP ã§ã¢ãã¬ã¹ãæ´æ°ãããæã«å¼ã³åºãã³ã¼ã«ããã¯é¢æ° */
+#ifndef DHCP4_CLI_SET_ADDR_CALLBACK
+#define DHCP4_CLI_SET_ADDR_CALLBACK NULL
+#endif
+
+#ifndef _MACRO_ONLY
+
+#ifdef T_IPV4EP_DEFINED
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½
+ */
+
+typedef struct dhcp4_cli_msg {
+	/* 4ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã*/
+	T_DHCP4_MSG		msg;		/* DHCP ã¡ãã»ã¼ã¸æ§é ä½	*/
+	struct dhcp4_cli_msg	*next;		/* ãªã¹ãã®æ¬¡ã®ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IPV4EP		srv;		/* ãµã¼ãã®IPv4ã¢ãã¬ã¹/ãã¼ãçªå· */
+	uint16_t		len;		/* msg ã®æå¹é·			*/
+	uint16_t		prefer;		/* msg ã®æ¨å¥¨åº¦			*/
+	uint8_t			type;		/* ã¡ãã»ã¼ã¸ã¿ã¤ã		*/
+	} T_DHCP4_CLI_MSG;
+
+#endif	/*of #ifdef T_IPV4EP_DEFINED */
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+extern ER callback_nblk_dhcp4_cli (ID cepid, FN fncd, void *p_parblk);
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	dhcp4_cli_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+#ifdef T_IN4_ADDR_DEFINED
+
+extern ER dhcp4c_rel_info (void);
+extern ER dhcp4c_renew_info (void);
+extern ER dhcp4c_get_info (T_IN4_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                             uint32_t *rebind, SYSTIM *bind_start);
+
+#endif	/* of #ifdef T_IN4_ADDR_DEFINED */
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef DHCP4_CLI_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_asp.cfg	(revision 331)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+INCLUDE("netapp/dhcp4_cli.cfg");
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP4_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP4_CLI_MSG,
+	sizeof(T_DHCP4_CLI_MSG),
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_jsp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_jsp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_jsp.cfg	(revision 331)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+#include "netapp/dhcp4_cli.cfg"
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP4_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP4_CLI_MSG,
+	sizeof(T_DHCP4_CLI_MSG),
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h	(revision 331)
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The Internet Software Consortium nor the names
+ *    of its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * This software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_CLI_VAR_H
+#define DHCP4_CLI_VAR_H
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½
+ */
+
+/* TIMER ã®å®ç¾© */
+
+#define DHCP4C_TIMER_SND_DISC	0
+#define DHCP4C_TIMER_SND_REQ	1
+#define DHCP4C_TIMER_SND_REL	2
+#define DHCP4C_TIMER_RCV_OFFER	3
+#define DHCP4C_TIMER_RCV_ACK	4
+#define DHCP4C_TIMER_RENEW	5
+#define DHCP4C_TIMER_REBIND	6
+#define DHCP4C_TIMER_EXPIRE	7
+#define NUM_DHCP4C_TIMERS	8
+
+#define DHCP4C_TIMER_HZ		1
+
+typedef struct dhcp4_cli_context {
+	T_DHCP4_CLI_MSG	*rcv_lst;	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*val_lst;	/* æ¤è¨¼ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*prf_lst;	/* æ¨å¥¨ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*snd_msg;	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½			*/
+	T_DHCP4_CLI_MSG	*off_msg;	/* éç¥ããããªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_DHCP4_CLI_MSG	*act_msg;	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IF_SOFTC	*sc;		/* IF ã®ã½ããã¦ã§ã¢æ
+å ±		*/
+	T_IPV4EP	dst;		/* éä¿¡å
+ã®IPã¢ãã¬ã¹/ãã¼ãçªå·	*/
+	SYSTIM		snd_start;	/* éä¿¡ãéå§ããæé			*/
+	SYSTIM		bind_start;	/* BINDãéå§ããæé			*/
+	SYSTIM		expire;		/* ãªã¼ã¹ã®æå¹æéï¼msï¼		*/
+	SYSTIM		renew;		/* RENEWï¼T1ï¼ã¾ã§ã®æéï¼msï¼	*/
+	SYSTIM		rebind;		/* REBINDï¼T2ï¼ã¾ã§ã®æéï¼msï¼	*/
+	SYSTIM		timers[NUM_DHCP4C_TIMERS];	
+					/* ã¿ã¤ãã¼é
+å			*/
+	RELTIM		interval;	/* éä¿¡éé			*/
+	ER_UINT		error;		/* ã¨ã©ã¼ã»ãã¼ã¿é·		*/
+	ID		cepid;		/* CEP ID			*/
+	uint32_t	xid;		/* ãã©ã³ã¶ã¯ã·ã§ã³ ID		*/
+	uint16_t	flags;		/* åç¨®ãã©ã°			*/
+	uint16_t	max_prefer;	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦	*/
+	uint16_t	secs;		/* seconds since boot began	*/
+	uint8_t		fsm;		/* ç¾å¨ã®ç¶æ
+			*/
+	void (* set_addr_callback)();	/* ã¢ãã¬ã¹è¨­å®æã®ã³ã¼ã«ããã¯ */
+	} T_DHCP4_CLI_CONTEXT;
+
+/* fsmï¼ç¶æ
+é·ç§»ï¼ã®å®ç¾© */
+
+#define DHCP4_FSM_INIT		1
+#define DHCP4_FSM_SELECT	2
+#define DHCP4_FSM_REQUEST	3
+#define DHCP4_FSM_BOUND		4
+#define DHCP4_FSM_RENEW		5
+#define DHCP4_FSM_REBIND	6
+#define DHCP4_FSM_INIT_REBOOT	7
+#define DHCP4_FSM_REBOOT	8
+#define DHCP4_FSM_REL_INFO	11	/* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
+#define DHCP4_FSM_SLEEP		12	/* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
+
+/* flag ã®å®ç¾© */
+
+#define DHCP4C_FLAG_TMOUT_SND_DISC	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_DISC)
+#define DHCP4C_FLAG_TMOUT_SND_REQ	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REQ)
+#define DHCP4C_FLAG_TMOUT_SND_REL	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REL)
+#define DHCP4C_FLAG_TMOUT_RCV_OFFER	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_OFFER)
+#define DHCP4C_FLAG_TMOUT_RCV_ACK	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_ACK)
+#define DHCP4C_FLAG_TMOUT_EXPIRE	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_EXPIRE)
+#define DHCP4C_FLAG_TMOUT_RENEW		(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RENEW)
+#define DHCP4C_FLAG_TMOUT_REBIND	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_REBIND)
+#define DHCP4C_FLAG_TMOUT_TIMER		UINT_C(0x0010)
+#define DHCP4C_FLAG_TMOUT_TIMER_MASK	UINT_C(0x000f)
+#define DHCP4C_FLAG_TMOUT_MASK		UINT_C(0x001f)
+
+#define DHCP4C_FLAG_RCV_MSG		UINT_C(0x0200)
+#define DHCP4C_FLAG_RENEW		UINT_C(0x0400)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* ã¿ã¤ã ã¢ã¦ãã®è¨ç® */
+
+#define DHCP4C_TMOC(t)		(((t)-1000)+dhcp_rand()%2000)
+
+/* æéæ¯è¼ */
+
+#define TIMEC_GT(a,b)		((int32_t)((a)-(b))>0)
+#define TIMEC_GE(a,b)		((int32_t)((a)-(b))>=0)
+
+/* æéå®æ°ã®å¤æ */
+
+#define SYSTIM2TIMER(t)		(((t)<SYSTIM_HZ/DHCP4C_TIMER_HZ)?(DHCP4C_TIMER_HZ):((t)*DHCP4C_TIMER_HZ)/SYSTIM_HZ)
+#define SYSTIM2SEC(t)		(((t)<SYSTIM_HZ)?1:((t)/SYSTIM_HZ))
+#define SEC2TIMER(t)		((t)*DHCP4C_TIMER_HZ)
+#define SEC2SYSTIM(t)		((t)*SYSTIM_HZ)
+
+#endif	/* of #ifndef DHCP4_CLI_VAR_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6.h	(revision 331)
@@ -0,0 +1,345 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_H
+#define DHCP6_H
+
+/*
+ *  DHCPv6 ã«é¢ããå®ç¾©
+ *
+ *    RFC3315
+ */
+
+/*
+ *  DHCPv6 ã¡ãã»ã¼ã¸ã®å®æ°ã®å®ç¾©
+ */
+
+#define DHCP6_XID_LEN		3
+#define DHCP6_OPTION_LEN	(512-(1+DHCP6_XID_LEN))
+
+/*
+ *  DHCPv6 ã¡ãã»ã¼ã¸
+ */
+
+typedef struct dhcp6_msg_hdr {
+	uint8_t	type;				/* message type		*/
+	uint8_t	xid[DHCP6_XID_LEN];		/* transaction ID	*/
+	} T_DHCP6_MSG_HDR;
+
+typedef struct dhcp6_msg {
+	T_DHCP6_MSG_HDR	hdr;
+	uint8_t		options[DHCP6_OPTION_LEN];	/* options	*/
+	} T_DHCP6_MSG;
+
+/* message type ã®å®ç¾© */
+
+#define DHCP6_SOLICIT		UINT_C(1)
+#define DHCP6_ADVERTISE		UINT_C(2)
+#define DHCP6_REQUEST		UINT_C(3)
+#define DHCP6_CONFIRM		UINT_C(4)
+#define DHCP6_RENEW		UINT_C(5)
+#define DHCP6_REBIND		UINT_C(6)
+#define DHCP6_REPLY		UINT_C(7)
+#define DHCP6_RELEASE		UINT_C(8)
+#define DHCP6_DECLINE		UINT_C(9)
+#define DHCP6_RECONFIGURE	UINT_C(10)
+#define DHCP6_INFO_REQ		UINT_C(11)
+#define DHCP6_RELAY_FORW	UINT_C(12)
+#define DHCP6_RELAY_REPL	UINT_C(13)
+
+/*
+ *  DHCPv6 ãªãã·ã§ã³
+ */
+
+#define DHCP6_OPT_CLIENTID	UINT_C(1)
+#define DHCP6_OPT_SERVERID	UINT_C(2)
+#define DHCP6_OPT_IA_NA		UINT_C(3)
+#define DHCP6_OPT_IA_TA		UINT_C(4)
+#define DHCP6_OPT_IAADDR	UINT_C(5)
+#define DHCP6_OPT_ORO		UINT_C(6)
+#define DHCP6_OPT_PREFERENCE	UINT_C(7)
+#define DHCP6_OPT_UNICAST	UINT_C(12)
+#define DHCP6_OPT_STATUS_CODE	UINT_C(13)
+#define DHCP6_OPT_RAPID_COMMIT	UINT_C(14)
+#define DHCP6_OPT_NAME_SERVERS	UINT_C(23)
+#define DHCP6_OPT_DOMAIN_SEARCH	UINT_C(24)
+#define DHCP6_OPT_IA_PD		UINT_C(25)
+
+/* hardware address type ã®å®ç¾© */
+
+#define DHCP6_HWA_TYPE_ETHER	UINT_C(1)
+#define DHCP6_HWA_TYPE_IEEE802	UINT_C(6)
+
+/* STATUS CODE ã®å®ç¾© */
+
+#define DHCP6_STAT_SUCCESS	UINT_C(0)
+#define DHCP6_STAT_UNSPECIFID	UINT_C(1)
+#define DHCP6_STAT_NO_AVAIL	UINT_C(2)
+#define DHCP6_STAT_NO_BINDING	UINT_C(3)
+#define DHCP6_STAT_NO_ONLINK	UINT_C(4)
+#define DHCP6_STAT_USE_MCAST	UINT_C(5)
+
+/* æéå®æ°[s]ã®å®ç¾© */
+
+#define DHCP6_MAX_TIME		UINT_C(0xffffffff)
+
+/*
+ *  ãªãã·ã§ã³ã®ãããé¨ã®å®ç¾©
+ */
+
+/* ãªãã·ã§ã³ã®å
+±éé¨ */
+
+typedef struct dhcp6_option {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPTION;
+
+/* ãªãã·ã§ã³ã®å
+±éé¨ */
+
+/* CLIENTID ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_clientid {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_CLIENTID;
+
+/* SERVERID ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_serverid {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_SERVERID;
+
+/* IA_NA/IA_PD ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_ia_na_pd {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint32_t	iaid;		/* IA ID		*/
+	uint32_t	renew;		/* renew  timeout (T1)	*/
+	uint32_t	rebind;		/* rebind timeout (T2)	*/
+	} T_DHCP6_OPT_IA_NA_PD;
+
+/* IA_TA ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_ia_ta {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint32_t	iaid;		/* IA ID		*/
+	} T_DHCP6_OPT_IA_TA;
+
+/* IAADDR ãªãã·ã§ã³ */
+
+#ifdef T_IN6_ADDR_DEFINED
+
+typedef struct dhcp6_opt_iaaddr {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addr;		/* IPv6 address		*/
+	uint32_t	prefer;		/* preferred lifetime	*/
+	uint32_t	valid;		/* valid     lifetime	*/
+	} T_DHCP6_OPT_IAADDR;
+
+#endif	/* of #ifdef T_IN6_ADDR_DEFINED */
+
+/* ORO ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_oro {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_ORO;
+
+/* PREFERENCE ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_preference {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint8_t		prefer;		/* preference value	*/
+	} T_DHCP6_OPT_PREFERENCE;
+
+/* UNICAST ãªãã·ã§ã³ */
+
+#ifdef T_IN6_ADDR_DEFINED
+
+typedef struct dhcp6_opt_unicast {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addr;		/* IPv6 address for server*/
+	} T_DHCP6_OPT_UNICAST;
+
+#endif	/* of #ifdef T_IN6_ADDR_DEFINED */
+
+/* STATUS CODE ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_status_code {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint16_t	status;		/* status code		*/
+	} T_DHCP6_OPT_STATUS_CODE;
+
+/* NAME SERVERS ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_name_servers {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addrs[1];	/* IPv6 address		*/
+	} T_DHCP6_OPT_NAME_SERVERS;
+
+/* DOMAIN SEARCH ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_domain_search {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint8_t		name[1];	/* domain search	*/
+	} T_DHCP6_OPT_DOMAIN_SEARCH;
+
+/*
+ *  DHCPv6 ã¿ã¤ãã³ã°å®æ°ãRFC3315 5.5 åç
+§ã
+ *  ãã®ä»ã®ã¿ã¤ãã³ã°å®æ°ã¯ dhcp6_cli.h åç
+§
+ */
+
+#ifdef SYSTIM_HZ
+
+#define TMO_SOL_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_SOL_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_SOL_MAX_RT		(120*SYSTIM_HZ)	/* 120[s] 	*/
+#define TMO_REQ_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_REQ_MAX_RT		(30*SYSTIM_HZ)	/*  30[s] 	*/
+#define TMO_REQ_MAX_RC		10		/* åéä¿¡åæ°	*/
+#define TMO_CNF_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_CNF_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_CNF_MAX_RT		(4*SYSTIM_HZ)	/*   4[s] 	*/
+#define TMO_CNF_MAX_RD		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REN_TIMEOUT		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REN_MAX_RT		(600*SYSTIM_HZ)	/* 600[s] 	*/
+#define TMO_REB_TIMEOUT		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REB_MAX_RT		(600*SYSTIM_HZ)	/* 600[s] 	*/
+#define TMO_INF_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_INF_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_INF_MAX_RT		(120*SYSTIM_HZ)	/* 120[s] 	*/
+#define TMO_REL_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_REL_MAX_RC		5		/* åéä¿¡åæ°	*/
+#define TMO_DEC_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_DEC_MAX_RC		5		/* åéä¿¡åæ°	*/
+#define TMO_REC_TIMEOUT		(2*SYSTIM_HZ)	/*   2[s] 	*/
+#define TMO_REC_MAX_RC		8		/* åéä¿¡åæ°	*/
+
+#endif	/* of #ifdef SYSTIM_HZ */
+
+/*
+ *  DUID -- DHCP Unique ID
+ */
+
+/* DUID_LLT æ§é ä½ */
+
+typedef struct dhcp6_duid_llt_hdr {
+	uint16_t	code;		/* DUID code		*/
+	uint16_t	type;		/* hardware type	*/
+	uint32_t	time;		/* time			*/
+	} T_DHCP6_DUID_LLT_HDR;
+
+/* DUID_LL æ§é ä½ */
+
+typedef struct dhcp6_duid_ll_hdr {
+	uint16_t	code;		/* DUID code		*/
+	uint16_t	type;		/* hardware type	*/
+	} T_DHCP6_DUID_LL_HDR;
+
+/* DUID ã¿ã¤ããRFC3315 9åç
+§ã*/
+
+#define DUID_LLT		1
+#define DUID_EN			2
+#define DUID_LL			3
+
+/*
+ *  DUID æéã®èª¿æ´
+ *  DUID æéã®éå§ã¯ 2001/1/1
+ */
+
+#define DUID_TIME_EPOCH		0
+
+/* ãªã¬ã¼è»¢éã®æå¤§ãããæ° */
+
+#define HOP_COUNT_LIMIT		32
+
+/*
+ *  IPv6 ã¢ãã¬ã¹
+ */
+
+#define IPV6_ADDR_ALL_DHCP_RELAY_SERVERS_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x02) }}}
+
+#define IPV6_ADDR_ALL_DHCP_SERVERS_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x05), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x03) }}}
+
+/*
+ *  UDP ãã¼ãçªå·
+ */
+
+#ifndef DHCP6_SRV_CFG_PORTNO
+#define DHCP6_SRV_CFG_PORTNO	547	/* server	*/
+#endif
+
+#ifndef DHCP6_CLI_CFG_PORTNO
+#define DHCP6_CLI_CFG_PORTNO	546	/* client	*/
+#endif
+
+#endif	/* of #ifndef DHCP6_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.c	(revision 331)
@@ -0,0 +1,3338 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+
+#include <net/if_var.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/dhcp6_cli.h>
+#include <netapp/dhcp6_cli_var.h>
+#include <netapp/resolver.h>
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/*
+ *  DHCP åä½ã¢ã¼ã
+ *
+ *    #define DHCP6_CLI_CFG_MODE ã§æå®ããã
+ *
+ */
+
+#if !defined(DHCP6_CLI_CFG_MODE)
+#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_MODE_DEFAULT
+#endif
+
+/*
+ *  å¤æ°
+ */
+
+static const T_IN6_ADDR in6_addr_all_DHCP_relay_servers =
+	IPV6_ADDR_ALL_DHCP_RELAY_SERVERS_INIT;			/* ãªã¬ã¼ã»ãµã¼ãã® IPv6 ã¢ãã¬ã¹	*/
+static T_DHCP6_CLI_CONTEXT	context;			/* ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ã	*/
+
+#ifdef DHCP6_CLI_CFG_REQUIRED_OLIST
+static uint8_t	required_plist[] = DHCP6_CLI_CFG_REQUIRED_OLIST;	/* å¿
+é ãªãã·ã§ã³ãªã¹ã		*/
+#endif
+
+#ifdef DHCP6_CLI_CFG_REQUEST_OLIST
+static uint8_t	request_plist[] = DHCP6_CLI_CFG_REQUEST_OLIST;		/* è¦æ±ãªãã·ã§ã³ãªã¹ã		*/
+#endif
+
+/*
+ *  dhcp6_rand -- RFC3315 ã«è¦å®ãããä¹±æ°ãçºçããã
+ */
+
+static int32_t
+dhcp6_rand (SYSTIM base)
+{
+	SYSTIM 		range, split;
+	uint32_t	rval;
+
+	split = (base - 1) / 10;
+	if (split == 0)
+		return 0;
+	range = (split * 2) + 10;
+	rval = netapp_rand() % range - split;
+
+	return rval;
+	}
+
+/*
+ *  init_duid -- ã¯ã©ã¤ã¢ã³ãã® DUID ãè¨­å®ããã
+ */
+
+static void
+init_duid (T_DHCP6_CLI_CONTEXT *ct)
+{
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	/* åä½ã¢ã¼ãã« STATELESS ãæå®ãããæã¯ LL å½¢å¼ã«ããã*/
+
+	T_DHCP6_DUID_LL_HDR	*ll;
+
+	ll = (T_DHCP6_DUID_LL_HDR*)&ct->duid[0];
+	HOST2MSG16(ll->code, DUID_LL);
+	HOST2MSG16(ll->type, DHCP6_HWA_TYPE_ETHER);
+	memcpy(&ct->duid[sizeof(*ll)], &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr));
+	ct->duid_len = sizeof(*ll) + sizeof(ct->sc->ifaddr.lladdr);	/* DIUD é·ãè¨é²ããã*/
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	/*
+	 *    åä½ã¢ã¼ãã« DHCP6_CLI_CFG_STATEFULL ãæå®ãããæã¯ LLT å½¢å¼ã«ããã
+	 *    time ã¡ã³ãã¼ã«ã¯ç¾å¨ã®æé[s]ãè¨­å®ããã
+	 *    æ³¨æ: æ«å®çã« get_tim() ã®å¤ãä½¿ãããè¦æ¤è¨
+	 */
+
+	T_DHCP6_DUID_LLT_HDR	*llt;
+	SYSTIM			time;
+
+	get_tim(&time);
+	time = SYSTIM2SEC(time) - DUID_TIME_EPOCH;
+	llt = (T_DHCP6_DUID_LLT_HDR*)&ct->duid[0];
+	HOST2MSG16(llt->code, DUID_LLT);
+	HOST2MSG16(llt->type, DHCP6_HWA_TYPE_ETHER);
+	HOST2MSG32(llt->time, time);
+	memcpy(&ct->duid[sizeof(*llt)], &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr));
+	ct->duid_len = sizeof(*llt) + sizeof(ct->sc->ifaddr.lladdr);	/* DIUD é·ãè¨é²ããã*/
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	}
+
+/*
+ *  cancel_all_timers -- å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã
+ */
+
+static void
+cancel_all_timers (T_DHCP6_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	for (ix = NUM_DHCP6C_TIMERS; ix -- > 0; )
+		ct->timers[ix] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+	}
+
+/*
+ *  dhcpc_timer -- TIMER ç®¡ç
+ */
+
+static void
+dhcpc_timer (T_DHCP6_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	for (ix = NUM_DHCP6C_TIMERS; ix -- > 0; ) {
+		if (ct->timers[ix] != 0) {
+			ct->timers[ix] --;
+			if (ct->timers[ix] == 0) {
+				ct->flags = (ct->flags & ~DHCP6C_FLAG_TMOUT_MASK) | DHCP6C_FLAG_TMOUT_TIMER | ix;
+				syscall(sig_sem(SEM_DHCP6_CLI_READY));
+				}
+			}
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããã*/
+	timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP6C_TIMER_HZ);
+	}
+
+/*
+ *  find_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° len ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ *          å¼æ° len ã«ã¯ãªãã·ã§ã³å
+¨ä½ã®ãµã¤ãºãæå®ãããã¨ã
+ */
+
+static uint8_t *
+find_option (uint8_t *msg, uint_t msg_len, uint_t code, uint_t len)
+{
+	T_DHCP6_OPTION	*hdr;
+	uint8_t		*last;
+
+	last = msg + msg_len;
+	while (msg < last) {
+		hdr = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(hdr->code) == code && (len == 0 || (MSG2HOST16(hdr->len) + sizeof(*hdr)) == len))
+			return msg;
+		else
+			msg += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	return NULL;
+	}
+
+/*
+ *  find_msg_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° len ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ *          å¼æ° len ã«ã¯ãªãã·ã§ã³å
+¨ä½ã®ãµã¤ãºãæå®ãããã¨ã
+ */
+
+static uint8_t *
+find_msg_option (T_DHCP6_CLI_MSG *cli_msg, uint_t code, uint_t len)
+{
+	return find_option(cli_msg->msg.options, cli_msg->len, code, len);
+	}
+
+/*
+ *  is_equal_sid -- ã¡ãã»ã¼ã¸å
+ã® SERVER ID ãæ¯è¼ããã
+ */
+
+static bool_t
+is_equal_sid (T_DHCP6_CLI_MSG *msg1, T_DHCP6_CLI_MSG *msg2)
+{
+	T_DHCP6_OPT_SERVERID	*sid1;
+	T_DHCP6_OPT_SERVERID	*sid2;
+
+	if ((sid1 = (T_DHCP6_OPT_SERVERID*)find_msg_option(msg1, DHCP6_OPT_SERVERID, 0)) == NULL)
+		return false;
+	if ((sid2 = (T_DHCP6_OPT_SERVERID*)find_msg_option(msg2, DHCP6_OPT_SERVERID, 0)) == NULL)
+		return false;
+	if (MSG2HOST16(sid1->len) != MSG2HOST16(sid2->len))
+		return false;
+
+	return memcmp((uint8_t*)sid1 + sizeof(*sid1),
+	              (uint8_t*)sid2 + sizeof(*sid2), MSG2HOST16(sid1->len)) == 0;
+	}
+
+/*
+ *  validate_iaaddrs -- ã¢ãã¬ã¹æ
+å ±ï¼IAADDRï¼ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_iaaddrs (uint8_t *opt, uint_t len)
+{
+	T_DHCP6_OPT_IAADDR	*iaa;
+
+	/* ãªãã·ã§ã³ã IAADDR ã§ãããã¨ãæ¤è¨¼ããã*/
+	iaa = (T_DHCP6_OPT_IAADDR*)opt;
+	if (MSG2HOST16(iaa->code) != DHCP6_OPT_IAADDR)
+		return E_PAR;
+
+	while (len > 0) {
+		/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+		if (len < sizeof(*iaa))
+			return E_PAR;
+
+		/* ãªãã·ã§ã³é·ã T_DHCP6_OPT_IAADDR ã®ãµã¤ãºã¨ä¸è´ãã¦ããªããã°ã¨ã©ã¼ */
+		iaa = (T_DHCP6_OPT_IAADDR*)opt;
+		if ((MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) < (sizeof(*iaa) - sizeof(T_DHCP6_OPTION)))
+			return E_PAR;
+
+		/*
+		 *  perferred-lifetime ã¨ valid-lifetime ã®å¤ãçç¾ãã¦ããã¨ãã¯ã¨ã©ã¼
+		 *  ãRFC3315 (22.6) åç
+§ã
+		 */
+		if (MSG2HOST32(iaa->prefer) > MSG2HOST32(iaa->valid))
+			return E_PAR;
+
+		len -= (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(T_DHCP6_OPTION);
+		opt += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(T_DHCP6_OPTION);
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  validate_ia_na_pd -- IA_NA/IA_PD ãªãã·ã§ã³ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_ia_na_pd (T_DHCP6_CLI_MSG *msg, uint16_t code)
+{
+	T_DHCP6_OPT_IA_NA_PD	*na;
+	uint8_t			*opt;
+
+	/* IA_NA/IA_PD ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_msg_option(msg, code, 0)) == NULL)
+		return E_OK;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	na = (T_DHCP6_OPT_IA_NA_PD*)opt;
+	if (!(msg->len >= (opt - (uint8_t*)&msg->msg) + sizeof(*na) &&
+	                         (MSG2HOST16(na->len) & ~DHCP6C_IAA_FLAG_MASK) >= sizeof(*na)))
+		return E_PAR;
+
+	/*
+	 *  T1 ã¨ T2 ã®å¤ãçç¾ãã¦ããæãã¾ãã¯ã¢ãã¬ã¹æ
+å ±ãèª¤ã£ã¦ããæã¯ã¨ã©ã¼
+	 *  ãRFC3315 (22.4) åç
+§ã
+	 */
+	if (MSG2HOST32(na->renew) > 0 && MSG2HOST32(na->rebind) > 0 &&
+	    MSG2HOST32(na->renew) >      MSG2HOST32(na->rebind))
+		return E_PAR;
+
+	if (validate_iaaddrs(opt + sizeof(*na), (MSG2HOST16(na->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*na) - sizeof(T_DHCP6_OPTION))) != E_OK)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  validate_ia_ta -- IA_TA ãªãã·ã§ã³ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_ia_ta (T_DHCP6_CLI_MSG *msg)
+{
+	T_DHCP6_OPT_IA_TA	*ta;
+	uint8_t			*opt;
+
+	/* IA_TA ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_IA_TA, 0)) == NULL)
+		return E_OK;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	ta = (T_DHCP6_OPT_IA_TA	*)opt;
+	if (!(msg->len >= (opt - (uint8_t*)&msg->msg) + sizeof(*ta) &&
+	                         (MSG2HOST16(ta->len) & ~DHCP6C_IAA_FLAG_MASK) >= sizeof(*ta)))
+		return E_PAR;
+
+	/*
+	 *  ã¢ãã¬ã¹æ
+å ±ãèª¤ã£ã¦ããæã¯ã¨ã©ã¼ãRFC3315 (22.4) åç
+§ã
+	 */
+	if (validate_iaaddrs(opt + sizeof(*ta), (MSG2HOST16(ta->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*ta) - sizeof(T_DHCP6_OPTION))) != E_OK)
+		return E_PAR;
+
+	return E_OK;
+	}
+/*
+ *  classify_reply -- å¿ç­ã¡ãã»ã¼ã¸ãåé¡ããã
+ */
+
+static ER
+classify_reply (T_DHCP6_CLI_MSG *msg)
+{
+	ER	error;
+
+	/* IA_NA ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_na_pd(msg, DHCP6_OPT_IA_NA)) != E_OK)
+		return error;
+
+	/* IA_TA ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_ta(msg)) != E_OK)
+		return error;
+
+	/* IA_PD ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_na_pd(msg, DHCP6_OPT_IA_PD)) != E_OK)
+		return error;
+
+	/* ãµã¼ã DUID ããããã¨ãæ¤è¨¼ããã*/
+	if (find_msg_option(msg, DHCP6_OPT_SERVERID, 0) == NULL)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  validate_reply -- å¿ç­ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_reply (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *msg)
+{
+	T_DHCP6_OPT_CLIENTID	*cid;
+	uint8_t			*opt;
+
+	/* ãµã¼ã DUID ããããã¨ãæ¤è¨¼ããã*/
+	if (find_msg_option(msg, DHCP6_OPT_SERVERID, 0) == NULL)
+		return E_PAR;
+
+	/* ã¯ã©ã¤ã¢ã³ã DUID ããããèªåã®ã¯ã©ã¤ã¢ã³ã DUID ã¨åããã¨ãæ¤è¨¼ããã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_CLIENTID, 0)) == NULL)
+		return E_PAR;
+
+	cid = (T_DHCP6_OPT_CLIENTID*)opt;
+	if (MSG2HOST16(cid->len) != ct->duid_len)
+		return E_PAR;
+	if (memcmp(opt + sizeof(*cid), ct->duid, ct->duid_len) != 0)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  get_status_code -- STATUS ãªãã·ã§ã³ã®çµæã³ã¼ããç²å¾ããã
+ */
+
+static ER_UINT
+get_status_code (uint8_t *msg, uint_t msg_len)
+{
+	T_DHCP6_OPT_STATUS_CODE	*status;
+	uint8_t			*opt;
+
+	/* STATUS ãªãã·ã§ã³ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_option(msg, msg_len, DHCP6_OPT_STATUS_CODE, 0)) == NULL)
+		return DHCP6_STAT_SUCCESS;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	status = (T_DHCP6_OPT_STATUS_CODE*)opt;
+	if (msg_len < sizeof(*status))
+		return E_PAR;
+	if (MSG2HOST16(status->len) < sizeof(*status) - sizeof(T_DHCP6_OPTION))
+		return E_PAR;
+
+	return MSG2HOST16(status->status);
+	}
+
+/*
+ *  get_msg_status_code -- STATUS ãªãã·ã§ã³ã®çµæã³ã¼ããç²å¾ããã
+ */
+
+static ER_UINT
+get_msg_status_code (T_DHCP6_CLI_MSG *cli_msg, uint_t *code)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IA_TA	*ta;
+	ER_UINT			status;
+	uint8_t			*msg, *last;
+
+	*code = 0;
+	cli_msg->status = DHCP6_CLI_STAT_UNDEFINED;
+	if ((status = get_status_code(cli_msg->msg.options, cli_msg->len)) == DHCP6_STAT_SUCCESS) {
+
+		msg = cli_msg->msg.options;
+		last = msg + (cli_msg->len - sizeof(T_DHCP6_MSG_HDR));
+		while (msg < last) {
+
+			opt = (T_DHCP6_OPTION*)msg;
+			status = get_status_code(msg + sizeof(*opt), MSG2HOST16(opt->len));
+			if (status != DHCP6_STAT_SUCCESS) {
+				*code = MSG2HOST16(opt->code);
+				break;
+				}
+
+			if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+				ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+				status = get_status_code(msg + sizeof(*opt), MSG2HOST16(ia->len));
+				if (status != DHCP6_STAT_SUCCESS) {
+					*code = MSG2HOST16(((T_DHCP6_OPTION*)((uint8_t*)opt + sizeof(*opt)))->code);
+					break;
+					}
+				}
+
+			else if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_TA) {
+
+				ta = (T_DHCP6_OPT_IA_TA*)opt;
+				status = get_status_code(msg + sizeof(*opt), MSG2HOST16(ta->len));
+				if (status != DHCP6_STAT_SUCCESS) {
+					*code = MSG2HOST16(((T_DHCP6_OPTION*)((uint8_t*)opt + sizeof(*opt)))->code);
+					break;
+					}
+				}
+
+			msg += MSG2HOST16(opt->len) + sizeof(*opt);
+			}
+		cli_msg->status = status;
+		}
+	
+	return status;
+	}
+
+/*
+ *  validate_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_rcv_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *msg)
+{
+	ER	error;
+	uint_t	code;
+
+	/* ã¡ãã»ã¼ã¸ã®ã¿ã¤ããä¸è´ãã¦ãããã¨ãæ¤è¨¼ããã*/
+	switch (ct->fsm) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6_FSM_SELECT:
+		if (msg->msg.hdr.type != DHCP6_REPLY)
+			return E_PAR;
+		break;
+	case DHCP6_FSM_INFORMED:
+		return E_PAR;
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6_FSM_INIT:
+		if (msg->msg.hdr.type != DHCP6_ADVERTISE)
+			return E_PAR;
+		break;
+
+	case DHCP6_FSM_SELECT:
+	case DHCP6_FSM_RENEW:
+	case DHCP6_FSM_REBIND:
+	case DHCP6_FSM_REL_INFO:
+		if (msg->msg.hdr.type != DHCP6_REPLY)
+			return E_PAR;
+		break;
+
+	case DHCP6_FSM_BOUND:
+		return E_PAR;
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] error, unknown state: %d.", ct->fsm);
+		return E_PAR;
+		break;
+		}
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if ((error = validate_reply(ct, msg)) != E_OK)
+		return error;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ãåé¡ããã*/
+	if ((error = classify_reply(msg)) != E_OK)
+		return error;
+
+	/* åä¿¡ããã¡ãã»ã¼ã¸å
+ã® STATUS CODE ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	error = get_msg_status_code(msg, &code);
+	if (error != E_OK)
+		return error > 0 ? E_PAR : error;
+
+	return E_OK;
+	}
+
+/*
+ *  eval_ia_prefer -- IA_NA/IA_TA/IA_PD ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_ia_prefer (T_DHCP6_CLI_MSG *cli_msg)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IA_TA	*ta;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (cli_msg == NULL)
+		return;
+
+	msg = cli_msg->msg.options;
+	last = msg + (cli_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+		opt = (T_DHCP6_OPTION*)msg;
+
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			aoff  = sizeof(*ia);
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			while (aoff < asize) {
+				cli_msg->prefer += DHCP6_CLI_CFG_PREFER_IAADDR;
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+			cli_msg->prefer = (cli_msg->prefer + DHCP6_CLI_CFG_PREFER_IA) | DHCP6_ClI_MSG_PREFER_ADDR;
+			}
+
+		else if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_TA) {
+
+			ta = (T_DHCP6_OPT_IA_TA*)opt;
+			aoff  = sizeof(*ta);
+			asize = MSG2HOST16(ta->len) + sizeof(*opt);
+			while (aoff < asize) {
+				cli_msg->prefer += DHCP6_CLI_CFG_PREFER_IAADDR;
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+			cli_msg->prefer = (cli_msg->prefer + DHCP6_CLI_CFG_PREFER_IA) | DHCP6_ClI_MSG_PREFER_ADDR;
+			}
+
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	}
+
+/*
+ *  eval_prefer -- åä¿¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_prefer (T_DHCP6_CLI_MSG *msg)
+{
+	uint8_t			*opt;
+	int			ix;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (msg == NULL)
+		return;
+
+	/* PREFERENCE ãªãã·ã§ã³ãè©ä¾¡ããã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_PREFERENCE, sizeof(T_DHCP6_OPT_PREFERENCE))) != NULL)
+		msg->prefer = MSG2HOST16(((T_DHCP6_OPT_PREFERENCE*)opt)->prefer) | DHCP6_ClI_MSG_PREFER_OPTION;
+	else
+		msg->prefer = 1;
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		if (find_msg_option(msg, required_plist[ix], 0) == NULL)
+			msg->prefer = 0;
+		}
+	msg->prefer |= DHCP6_ClI_MSG_PREFER_REQUIRED;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		if (find_msg_option(msg, request_plist[ix], 0) != NULL)
+			msg->prefer = (msg->prefer + 1) | DHCP6_ClI_MSG_PREFER_REQUEST;
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+	}
+
+/*
+ *  eval_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãè©ä¾¡ããã
+ */
+
+static ER
+eval_rcv_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*evl, *msg;
+	SYSTIM		time;
+
+	/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->val_lst == NULL) {
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* æ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãããè©ä¾¡ã¡ãã»ã¼ã¸ãåãåºãã*/
+	evl         = ct->val_lst;
+	ct->val_lst = ct->val_lst->next;
+	evl->next   = NULL;
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	/* åä¿¡æéãè¨­å®ããã*/
+	get_tim(&time);
+	evl->rcv_time = time;
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if (validate_rcv_msg(ct, evl) != E_OK) {
+
+		/* ã¨ã©ã¼ãçºçããè©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		goto rcv_ret;
+		}
+
+	/* REL_INFO ç¶æ
+ã®æã®å¦ç */
+	if (ct->fsm == DHCP6_FSM_REL_INFO) {
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		if (evl->status == DHCP6_STAT_SUCCESS) {
+			/*
+			 *  STATUS CODE ã DHCP6_STAT_SUCCESS ãªãã
+			 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«è¨­å®ãã¦çµäºããã
+			 */
+			evl->next   = ct->prf_lst;
+			ct->prf_lst = evl;
+			}
+		else {
+			/* è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã¦çµäºããã*/
+			evl->next   = ct->rcv_lst;
+			ct->rcv_lst = evl;
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã*/
+	eval_prefer(evl);
+	eval_ia_prefer(evl);
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããç©ºãªãè©ä¾¡ã¡ãã»ã¼ã¸ãç§»ãã¦çµäºããã*/
+	if (ct->prf_lst == NULL) {
+		ct->max_prefer = evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã¨æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ãæ¯è¼ããã*/
+	if ((evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) > ct->max_prefer) {
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããé«ããã°ã
+		 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		ct->max_prefer = evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK;
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		if (ct->rcv_lst == NULL)
+			ct->rcv_lst = ct->prf_lst;
+		else {
+			for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+				;
+			msg->next = ct->prf_lst;
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	else if ((evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) == ct->max_prefer) {
+		for (msg = ct->prf_lst; msg != NULL; msg = msg->next) {
+			if (is_equal_sid(evl, msg)) {
+
+				/*
+				 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«åã DHCP6_OPT_SERVERID ã®ã¡ãã»ã¼ã¸ãããã°ã
+				 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+				 */
+				goto rcv_ret;
+				}
+			}
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+	
+	/*else */
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããä½ããã°ã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+
+rcv_ret:
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	evl->next   = ct->rcv_lst;
+	ct->rcv_lst = evl;
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	return E_OK;
+	}
+
+/*
+ *  select_msg -- æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static T_DHCP6_CLI_MSG*
+select_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg, *select;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->prf_lst == NULL) {
+		/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+	select = ct->prf_lst;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	if ((select->prefer & DHCP6_ClI_MSG_PREFER_REQUIRED) == 0) {
+		/* å¿
+é ãªãã·ã§ã³ãç¡ããã°é¸æããªãã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	if (((select->prefer & DHCP6_ClI_MSG_PREFER_REQUIRED) == 0) ||
+	    ((select->prefer & DHCP6_ClI_MSG_PREFER_ADDR)     == 0)) {
+		/* å¿
+é ãªãã·ã§ã³ã¨ã¢ãã¬ã¹ãç¡ããã°é¸æããªãã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã*/
+	ct->prf_lst  = ct->prf_lst->next;
+	select->next = NULL;
+
+	/* é¸æãããªãã£ãæ¤è¨¼ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->rcv_lst == NULL)
+		ct->rcv_lst = ct->prf_lst;
+	else {
+		for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+			;
+		msg->next = ct->prf_lst;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	return select;
+	}
+
+/*
+ *  advance_retrans -- åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã
+ */
+
+static void
+advance_retrans (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/*
+	 *  åéä¿¡ééï¼RTï¼ãæ´æ°ããã
+	 *  åéä¿¡æ¯ã«ç´ 2åãããã
+	 *  æå¤§éä¿¡ééï¼MRTï¼ãè¶
+ããªãããã«ããã
+	 */
+	ct->RT += ct->RT + dhcp6_rand(ct->RT);
+	if ((ct->MRT != 0) && (ct->RT > ct->MRT))
+		ct->RT = ct->MRT + dhcp6_rand(ct->MRT);
+
+	/* åéä¿¡åæ°ãæ´æ°ããã*/
+	ct->txcount ++;
+	}
+
+/*
+ *  init_retrans -- åéä¿¡åæ°ããã©ã³ã¶ã¯ã·ã§ã³ IDããã®ä»ãè¨­å®ããã
+ */
+
+static void
+init_retrans (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* éä¿¡åæ°ããªã»ããããã*/
+	ct->txcount = 0;
+
+	/* åéä¿¡ééãè¨­å®ããã*/
+	ct->RT = ct->IRT + dhcp6_rand(ct->IRT);
+
+	/* ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	ct->xid = netapp_rand() % 0x00ffffff;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦ããªã»ããããã*/
+	ct->max_prefer = 0;
+	}
+
+/*
+ *  setup_msg_header -- ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã
+ */
+
+static uint8_t *
+setup_msg_header (T_DHCP6_CLI_CONTEXT *ct, uint_t type)
+{
+	memset((void*)&ct->snd_msg->msg, sizeof(ct->snd_msg->msg), 0);
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg);
+
+	/* ãããé¨ãè¨­å®ããã*/
+	ct->snd_msg->msg.hdr.type   = type;
+	ct->snd_msg->msg.hdr.xid[0] = (ct->xid >> 16) & 0xff;
+	ct->snd_msg->msg.hdr.xid[1] = (ct->xid >>  8) & 0xff;
+	ct->snd_msg->msg.hdr.xid[2] =  ct->xid        & 0xff;
+
+	return (uint8_t*)&ct->snd_msg->msg + sizeof(ct->snd_msg->msg.hdr);
+	}
+
+/*
+ *  common_options -- æ¨æºãªãã·ã§ã³ãè¿½å ããã
+ */
+
+static uint8_t *
+common_options (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t type, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_CLIENTID	*cid;
+	T_DHCP6_OPT_SERVERID	*sid;
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+	T_DHCP6_OPT_ORO		*oro;
+#endif
+
+	uint8_t			*opt;
+	uint_t			opt_len;
+	int_t			ix;
+
+#if defined(DHCP6_CLI_CFG_RAPID_COMMIT)
+
+	/* Rapid-commit ã®æå® */
+	if (type == DHCP6_SOLICIT)
+		;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_RAPID_COMMIT) */
+
+	/* ã¯ã©ã¤ã¢ã³ã DUID ãè¿½å ããã*/
+	cid = (T_DHCP6_OPT_CLIENTID*)msg;
+	HOST2MSG16(cid->code, DHCP6_OPT_CLIENTID);
+	HOST2MSG16(cid->len,  ct->duid_len);
+	memcpy(msg + sizeof(T_DHCP6_OPT_CLIENTID), ct->duid, ct->duid_len);
+	msg += ct->duid_len + sizeof(T_DHCP6_OPT_CLIENTID);
+
+	/* ãµã¼ã DUID ãè¿½å ããã*/
+	if (lease == NULL) {
+		if (!(type == DHCP6_SOLICIT || type == DHCP6_INFO_REQ))
+			return NULL;
+		}
+	else if (!(type == DHCP6_CONFIRM || type == DHCP6_REBIND)) {
+		if ((opt = find_msg_option(lease, DHCP6_OPT_SERVERID, 0)) != NULL) {
+			sid = (T_DHCP6_OPT_SERVERID*)opt;
+			opt_len = MSG2HOST16(sid->len);
+			memcpy(msg, opt, opt_len + sizeof(*sid));
+			msg += opt_len + sizeof(*sid);
+			}
+		}
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* å¿
+é ã»è¦æ±ãªãã·ã§ã³ãè¿½å ããã*/
+	oro = (T_DHCP6_OPT_ORO*)msg;
+	HOST2MSG16(oro->code, DHCP6_OPT_ORO);
+	HOST2MSG16(oro->len, 0);
+	msg += sizeof(oro->code) + sizeof(oro->len);
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãè¿½å ããã*/
+	HOST2MSG16(oro->len, MSG2HOST16(oro->len) + sizeof(required_plist) * 2);
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		host2msg16(msg, required_plist[ix]);
+		msg += sizeof(uint16_t);
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãè¿½å ããã*/
+	HOST2MSG16(oro->len, MSG2HOST16(oro->len) + sizeof(request_plist) * 2);
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		host2msg16(msg, request_plist[ix]);
+		msg += sizeof(uint16_t);
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+
+	return msg;
+	}
+
+/*
+ *  rel_lease -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã
+ */
+
+static void
+rel_lease (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION			*hdr;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	T_DHCP6_OPT_IA_NA_PD		*ia;
+	T_DHCP6_OPT_IAADDR		*iaa;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+	uint8_t		*opt, *last;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãç¡ããã°ä½ãããªãã*/
+	if (ct->act_msg == NULL)
+		return;
+
+	opt  = ct->act_msg->msg.options;
+	last = opt + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (opt < last) {
+		hdr = (T_DHCP6_OPTION*)opt;
+		switch (MSG2HOST16(hdr->code)) {
+
+		case DHCP6_OPT_NAME_SERVERS:
+			dns_in6_set_addr(NULL);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			syslog(LOG_NOTICE, "[DHCP6C] release DNS server addr.");
+#endif
+			break;
+
+		case DHCP6_OPT_DOMAIN_SEARCH:
+			dns_in6_set_dname(NULL, 0);
+			break;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		case DHCP6_OPT_IA_NA:
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			if (MSG2HOST16(ia->len) > sizeof(*iaa)) {
+				iaa = (T_DHCP6_OPT_IAADDR*)(opt + sizeof(*ia));
+				in6_del_ifaddr(&iaa->addr);
+				}
+			break;
+
+		case DHCP6_OPT_IA_TA:
+			break;
+
+		case DHCP6_OPT_IA_PD:
+			break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+		default:
+			break;
+			}
+		opt += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	}
+
+/*
+ *  set_lease -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã
+ */
+
+static void
+set_lease (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION			*hdr;
+	T_DHCP6_OPT_NAME_SERVERS	*ns;
+	T_DHCP6_OPT_DOMAIN_SEARCH	*ds;
+	const uint8_t			*dname;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	T_DHCP6_OPT_IA_NA_PD		*ia;
+	T_DHCP6_OPT_IAADDR		*iaa;
+	SYSTIM				time, delay;
+	ER				error;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+	uint8_t		*opt, *last;
+
+	opt  = ct->act_msg->msg.options;
+	last = opt + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (opt < last) {
+		hdr = (T_DHCP6_OPTION*)opt;
+		switch (MSG2HOST16(hdr->code)) {
+
+		case DHCP6_OPT_NAME_SERVERS:
+			ns = (T_DHCP6_OPT_NAME_SERVERS*)opt;
+			dns_in6_set_addr(&ns->addrs[0]);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			syslog(LOG_NOTICE, "[DHCP6C] set DNS server addr: %s.", ipv62str(NULL, &ns->addrs[0]));
+#endif
+			break;
+
+		case DHCP6_OPT_DOMAIN_SEARCH:
+			ds = (T_DHCP6_OPT_DOMAIN_SEARCH*)opt;
+			dname = dns_in6_set_dname(ds->name, MSG2HOST16(ds->len));
+			break;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		case DHCP6_OPT_IA_NA:
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			if (MSG2HOST16(ia->len) > sizeof(*iaa)) {
+				get_tim(&time);
+				delay = time - ct->act_msg->rcv_time;
+				iaa = (T_DHCP6_OPT_IAADDR*)(opt + sizeof(*ia));
+				error = in6_upd_ifaddr(&iaa->addr, 64, MSG2HOST32(iaa->valid)  - SYSTIM2SEC(delay),
+				                                       MSG2HOST32(iaa->prefer) - SYSTIM2SEC(delay));
+				if (error == E_OK)
+					syslog(LOG_NOTICE, "[DHCP6C] set IPv6 addr: %s.", ipv62str(NULL, &iaa->addr));
+				else
+					syslog(LOG_NOTICE, "[DHCP6C] set IPv6 addr, error: %s.", itron_strerror(error));
+				}
+			break;
+
+		case DHCP6_OPT_IA_TA:
+			break;
+
+		case DHCP6_OPT_IA_PD:
+			break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+		default:
+			break;
+			}
+		opt += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	}
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+/*
+ *  start_req_info -- INFO-REQUEST ãéå§ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_req_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.5) åç
+§ã*/
+	ct->IRT = TMO_INF_TIMEOUT;
+	ct->MRT = TMO_INF_MAX_RT;
+	ct->MRC = 0;
+
+	/* DHCP6_CLI_CFG_ONE_TRYãæå®ããã¦ããªããã°æ¨æºã¿ã¤ã ã¢ã¦ãã¾ã§åéããã*/
+#if defined(DHCP6_CLI_CFG_ONE_TRY)
+	ct->MRD = 0;
+#else
+	ct->MRD = TMO_DHCP6C_NORMAL;
+#endif
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/*
+	 *  INFO-REQUEST ã¡ãã»ã¼ã¸éä¿¡é
+å»¶æéãè¨­å®ããã
+	 *  ãã ããTMO_INF_MAX_DELAY ã 1[s]ãªã®ã§ãdly_tsk()ãä½¿ç¨ããã
+	 */
+	dly_tsk(netapp_rand() % TMO_INF_MAX_DELAY);
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SELECT;
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_IREQ;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_informed -- INFORMED ç¶æ
+ã«é·ç§»ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_informed (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ãªã¼ã¹æ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* INFORMED ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_INFORMED;
+
+	//ct->flags |= DHCP6C_FLAG_STAY_STATE;
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* SLEEP ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SLEEP;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  select_info_reply -- æé©ãª REPLY (INFO-REQUEST ã¸ã®å¿ç­) ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_info_reply (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg;
+
+	/* æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã*/
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+	
+	ct->act_msg = msg;
+	return true;
+	}
+
+/*
+ *  setup_info_req_msg -- INFO-REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_info_req_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, DHCP6_INFO_REQ)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, DHCP6_INFO_REQ, NULL)) == NULL)
+		return E_PAR;
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+	return E_OK;
+	}
+
+/*
+ *  send_info_req_msg -- INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_info_req_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (select_info_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* INFORMED ç¶æ
+ã«é·ç§»ããã*/
+		start_informed(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_info_req_msg(ct)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup request message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send info-request message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_IREQ] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+/*
+ *  select_reply -- æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_reply (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg;
+
+	/* æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã*/
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+
+	if (ct->adv_msg != NULL) {
+		eval_prefer(ct->adv_msg);
+		eval_ia_prefer(ct->adv_msg);
+		}
+
+	/*
+	 *  æé©ãª REPLY ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã ADVERTISE ã¡ãã»ã¼ã¸æ¨å¥¨åº¦ã®
+	 *  1/2 ä»¥ä¸ã®æã¯åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+	 */
+	if ((ct->adv_msg != NULL) && (ct->max_prefer < (ct->adv_msg->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) / 2)) {
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		msg->next = ct->rcv_lst;
+		ct->rcv_lst = msg;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		}
+	else {
+
+		/*
+		 *  ct->act_msg ã«ããæå¹ãªå
+ REPLY ã¡ãã»ã¼ã¸ã
+		 *  åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã¦ã
+		 *  æé©ãª REPLY ã¡ãã»ã¼ã¸ã act ã«ç§»ãã
+		 */
+		if (ct->act_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+			ct->act_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->act_msg;
+			syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+			}
+		ct->act_msg = msg;
+		}
+
+	return ct->act_msg != NULL;
+	}
+
+/*
+ *  select_adv -- æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_adv (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ã adv ã«ç§»ãã*/
+	if ((ct->adv_msg = select_msg(ct)) != NULL) {
+
+		/*
+		 *  æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ã®ãµã¼ãã® IPv6 ã¢ãã¬ã¹ã
+		 *  æ¬¡ããéä¿¡ããã¢ãã¬ã¹ã«è¨­å®ããã
+		 */
+		ct->dst = ct->adv_msg->srv;
+		return true;
+		}
+	else
+		return false;
+	}
+
+/*
+ *  eval_expire -- æ¨å¥¨æå¹æéã¨æå¹æéãæ±ºå®ããã
+ */
+
+static void
+eval_expire (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint32_t	depref, expire,
+			high, low, renew, rebind,
+			tval, iaa_high, iaa_low;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize, addrs;
+
+	/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RENEW]  = 0;
+	ct->timers[DHCP6C_TIMER_REBIND] = 0;
+	ct->timers[DHCP6C_TIMER_DEPREF] = 0;
+	ct->timers[DHCP6C_TIMER_EXPIRE] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+	
+	addrs = high = expire = 0;
+	low = renew = rebind = depref = DHCP6_MAX_TIME;
+
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	get_tim(&time);
+	while (msg < last) {
+		opt = (T_DHCP6_OPTION*)msg;
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæå¹æéãæ´æ°ããã*/
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			//dump_msg_option("evl_expire1", msg);
+			iaa_high = 0;
+			iaa_low  = DHCP6_MAX_TIME;
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			aoff  = sizeof(*ia);
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			while (aoff < asize) {
+
+				/* æç­ã®æ¨å¥¨æå¹æéãæ´æ°ããã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				//dump_msg_option("evl_depref1", (uint8_t*)iaa);
+				if (!(MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_DEPREFERD)) {
+					if (MSG2HOST32(iaa->prefer) == DHCP6_MAX_TIME)
+						tval = DHCP6_MAX_TIME;
+					else
+						tval = MSG2HOST32(iaa->prefer) + SYSTIM2SEC(ct->act_msg->rcv_time);
+					if (tval < depref)
+						depref = tval;
+					}
+
+				/* IAADDR ã®æå¹æéãæ´æ°ããã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if (!(MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_EXPIRED)) {
+					if (MSG2HOST32(iaa->valid) == DHCP6_MAX_TIME)
+						tval = DHCP6_MAX_TIME;
+					else
+						tval = MSG2HOST32(iaa->valid) + SYSTIM2SEC(ct->act_msg->rcv_time);
+					tval -= SYSTIM2SEC(ct->act_msg->rcv_time);
+					if (tval > iaa_high)
+						iaa_high = tval;
+					if (tval < iaa_low)
+						iaa_low  = tval;
+					addrs ++;
+					}
+
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+
+			/* iaa_low ã¨ iaa_high/2 ã®æé·ã®æ¹ãæå¹æéã¨ãã¦é¸æããã*/
+			if (iaa_low <= (iaa_high / 2))
+				expire = iaa_high;
+			else
+				expire = iaa_low;
+
+			/* expire ã æå¤§å¤ï¼ç¡å¶éï¼ã 1 ä»¥ä¸ãªãæ¢å®å¤ã«è¨­å®ããã*/
+			if ((expire == DHCP6_MAX_TIME) || (expire <= 1))
+				expire  = SYSTIM2SEC(TMO_DHCP6C_REQ_LEASE) / 2;
+			else
+				expire /= 2;
+
+			/* renew ãæ±ºå®ããã*/
+			if (MSG2HOST32(ia->renew) == 0)
+				tval = expire + SYSTIM2SEC(ct->act_msg->rcv_time);
+			else if (MSG2HOST32(ia->renew) == DHCP6_MAX_TIME)
+				tval = DHCP6_MAX_TIME;
+			else
+				tval = MSG2HOST32(ia->renew) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (tval < renew)
+				renew = tval;
+
+			/* rebind ãæ±ºå®ããã*/
+			if (MSG2HOST32(ia->rebind) == 0)
+				tval = (expire + expire / 2) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			else if (MSG2HOST32(ia->rebind) == DHCP6_MAX_TIME)
+				tval = DHCP6_MAX_TIME;
+			else
+				tval = MSG2HOST32(ia->rebind) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (tval < rebind)
+				rebind = tval;
+
+			/* æç­æå¹æéã¨æé·æå¹æéãæ´æ°ããã*/
+			iaa_low  += SYSTIM2SEC(ct->act_msg->rcv_time);
+			iaa_high += SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (iaa_low < low)
+				low = iaa_low;
+			if (iaa_high > high)
+				high = iaa_high;
+			}
+
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	/* ã¢ãã¬ã¹ãéããã¦ããªããã°ãSLEEP ç¶æ
+ã«é·ç§»ããã*/
+	if (addrs == 0) {
+		ct->fsm    = DHCP6_FSM_SLEEP;
+		}
+
+	/* ç¶æ
+ã«ä¾å­ããå¦ç */
+	switch (ct->fsm) {
+
+	case DHCP6_FSM_BOUND:
+
+		/* RENEW ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+		if ((rebind > SYSTIM2SEC(time)) && (renew < rebind)) {
+			ct->next_MRD = SEC2SYSTIM(rebind) - time;
+			syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+			ct->timers[DHCP6C_TIMER_RENEW] = SEC2TIMER(renew) - SYSTIM2TIMER(time);
+			syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+			break;
+			}
+		/* break; */	/* ä¸ã«æããã*/
+
+	case DHCP6_FSM_RENEW:
+
+		/* REBIND ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+		ct->MRD = SEC2SYSTIM(rebind);
+		if (rebind != DHCP6_MAX_TIME) {
+			ct->next_MRD = SEC2SYSTIM(high) - time;
+			syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+			ct->timers[DHCP6C_TIMER_REBIND] = SEC2TIMER(rebind) - SYSTIM2TIMER(time);
+			syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+			}
+		break;
+
+	case DHCP6_FSM_REBIND:
+
+		ct->next_MRD = (SEC2TIMER(high) - time) - time;
+		break;
+
+	default:
+		break;
+		}
+
+	/* DEPREF ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+	if (depref != DHCP6_MAX_TIME) {
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_DEPREF] = SEC2TIMER(depref) - SYSTIM2TIMER(time);
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+		}
+
+	/* EXPIRE ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+	if (low != DHCP6_MAX_TIME) {
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_EXPIRE] = SEC2TIMER(low) - SYSTIM2TIMER(time);
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+		}
+	}
+
+/*
+ *  start_init -- INIT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_init (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (17.1.2) åç
+§ã*/
+	ct->IRT = TMO_SOL_TIMEOUT;
+	ct->MRT = TMO_SOL_MAX_RT;
+	ct->MRC = 0;
+
+	/* DHCP6_CLI_CFG_ONE_TRYãæå®ããã¦ããªããã°æ¨æºã¿ã¤ã ã¢ã¦ãã¾ã§åéããã*/
+#if defined(DHCP6_CLI_CFG_ONE_TRY)
+	ct->MRD = 0;
+#else
+	ct->MRD = TMO_DHCP6C_NORMAL;
+#endif
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* RFC3315 (17.1.2) ã®è¦å®ã«å¾ã£ã¦ã¿ã¤ã ã¢ã¦ããèª¿æ´ããã*/
+	if (ct->RT <= ct->IRT)
+		ct->RT = ct->IRT + (ct->IRT - ct->RT);
+	if (ct->RT <= ct->IRT)
+		ct->RT = ct->IRT + SEC2SYSTIM(1);
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_ADV] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/*
+	 *  SOLICIT ã¡ãã»ã¼ã¸éä¿¡é
+å»¶æéãè¨­å®ããã
+	 *  ãã ããTMO_SOL_MAX_DELAY ã 1[s]ãªã®ã§ãdly_tsk()ãä½¿ç¨ããã
+	 */
+	dly_tsk(netapp_rand() % TMO_SOL_MAX_DELAY);
+
+	/* INIT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_INIT;
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_SOL;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_select -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_select (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãª ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã° SLEEP ç¶æ
+ã«é·ç§»ããã*/
+	if (ct->adv_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.1) åç
+§ã*/
+	ct->IRT = TMO_REQ_TIMEOUT;
+	ct->MRT = TMO_REQ_MAX_RT;
+	ct->MRC = TMO_REQ_MAX_RC;
+	ct->MRD = 0;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SELECT;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REQ;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_bound -- BOUND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_bound (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL)
+		ct->fsm = DHCP6_FSM_SLEEP;
+
+	/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm    = DHCP6_FSM_BOUND;
+
+	/* ãªã¼ã¹æ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* æå¹æéãæ±ºå®ããã*/
+	eval_expire(ct);
+
+	}
+/*
+ *  start_renew -- RENEW ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_renew (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.3) åç
+§ã*/
+	ct->IRT = TMO_REN_TIMEOUT;
+	ct->MRT = TMO_REN_MAX_RT;
+	ct->MRC = 0;
+	ct->MRD = ct->next_MRD;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REFRESH ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	ct->refresh_type = DHCP6_RENEW;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_RENEW;
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REF;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_rebind -- REBIND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_rebind (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.4) åç
+§ã*/
+	ct->IRT = TMO_REB_TIMEOUT;
+	ct->MRT = TMO_REB_MAX_RT;
+	ct->MRC = 0;
+	ct->MRD = ct->next_MRD;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REFRESH ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	ct->refresh_type = DHCP6_REBIND;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+
+	/* REBIND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_REBIND;
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REF;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.1) åç
+§ã*/
+	ct->IRT = TMO_REL_TIMEOUT;
+	ct->MRT = 0;
+	ct->MRC = TMO_REL_MAX_RC;
+	ct->MRD = 0;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_REL_INFO;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REL;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+/*
+ *  solicit_ia_option -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã
+ */
+
+static void
+solicit_ia_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IA_TA	*ia;
+	uint_t			off, len;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	ia = (T_DHCP6_OPT_IA_TA*)msg;
+	HOST2MSG16(ia->code, code);
+
+	/* IAID ãè¨­å®ããã*/
+	if (sizeof(ct->sc->ifaddr.lladdr) > sizeof(uint32_t)) {
+		off = sizeof(ct->sc->ifaddr.lladdr) - 4;
+		len = 4;
+		}
+	else {
+		off = 0;
+		len = sizeof(ct->sc->ifaddr.lladdr);
+		}
+	memcpy((uint8_t*)&ia->iaid, ((uint8_t*)ct->sc->ifaddr.lladdr) + off, len);
+	}
+
+/*
+ *  solicit_iaaddr_option -- SOLICIT ã¡ãã»ã¼ã¸ã® IAADDR ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+static uint_t
+solicit_iaaddr_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IAADDR	*iaa;
+	uint32_t		t1, t2;
+	uint8_t			*opt;
+	uint_t			len;
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_NA/IA_TA/IA_PDï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	if ((ct->act_msg == NULL) || (opt = find_msg_option(ct->act_msg, code, 0)) == NULL)
+		return 0;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	iaa = (T_DHCP6_OPT_IAADDR*)msg;
+	HOST2MSG16(iaa->code, DHCP6_OPT_IAADDR);
+
+	/* IAADDR ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(iaa->len, sizeof(*iaa) - sizeof(T_DHCP6_OPTION));
+
+	/* ã¢ãã¬ã¹ãè¨­å®ããã*/
+	len = code == DHCP6_OPT_IA_TA ? sizeof(T_DHCP6_OPT_IA_TA)
+	                              : sizeof(T_DHCP6_OPT_IA_NA_PD);
+	memcpy(&iaa->addr, opt + sizeof(T_DHCP6_OPTION) + len, sizeof(iaa->addr));
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	t1 = TMO_DHCP6C_REQ_LEASE / 2;
+	t2 = t1 + (t1 / 2);
+	HOST2MSG32(iaa->prefer, t1);
+	HOST2MSG32(iaa->valid,  t2);
+
+	return sizeof(*iaa);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  solicit_ia_na_pd -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_NA/IA_PD ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+solicit_ia_na_pd (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	uint32_t		t1, t2;
+	uint_t			len;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	solicit_ia_option(ct, msg, code);
+	ia = (T_DHCP6_OPT_IA_NA_PD*)msg;
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	t1 = TMO_DHCP6C_REQ_LEASE / 2;
+	t2 = t1 + (t1 / 2);
+	HOST2MSG32(ia->renew,  SYSTIM2SEC(t1));
+	HOST2MSG32(ia->rebind, SYSTIM2SEC(t2));
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_NA/IA_PDï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	msg += sizeof(*ia);
+	len  = solicit_iaaddr_option(ct, msg, code);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(ia->len, (sizeof(*ia) + len) - sizeof(T_DHCP6_OPTION));
+
+	return msg + len;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  solicit_ia_ta -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_TA ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+static uint8_t *
+solicit_ia_ta (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg)
+{
+	T_DHCP6_OPT_IA_TA	*ia;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	solicit_ia_option(ct, msg, DHCP6_OPT_IA_TA);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	ia = (T_DHCP6_OPT_IA_TA*)msg;
+	HOST2MSG16(ia->len, sizeof(*ia) - sizeof(T_DHCP6_OPTION));
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_TAï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	msg += sizeof(*ia);
+	return msg + solicit_iaaddr_option(ct, msg, code);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_TA) */
+
+/*
+ *  setup_solicit_msg -- SOLICIT ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_solicit_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease)
+{
+	uint8_t	*head, *msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((head = setup_msg_header(ct, DHCP6_SOLICIT)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, head, DHCP6_SOLICIT, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = solicit_ia_na_pd(ct, msg, DHCP6_OPT_IA_NA);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+	/* IA_TA ãè¿½å ããã*/
+	msg = solicit_ia_ta(ct, msg);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = solicit_ia_na_pd(ct, msg, DHCP6_OPT_IA_PD);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+	return E_OK;
+	}
+
+/*
+ *  send_solicit_msg -- SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_solicit_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	ct->error = E_OK;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãSELECT ç¶æ
+ã«é·ç§»ããã*/
+	if (select_adv(ct)) {
+
+		/* ADVERTISE ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_ADV] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+ 		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã*/
+ 		start_select(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_solicit_msg(ct, NULL)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup solicit message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send solicit message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_SOL] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  request_ia_option -- REQUEST ã¡ãã»ã¼ã¸ã® IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+request_ia_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code, uint8_t *lease)
+{
+	T_DHCP6_OPT_IA_NA_PD	*dst, *src;
+
+	dst = (T_DHCP6_OPT_IA_NA_PD*)msg;
+	src = (T_DHCP6_OPT_IA_NA_PD*)lease;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	HOST2MSG16(dst->code, code);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(dst->len, sizeof(*dst) - (sizeof(dst->code) + sizeof(dst->len)));
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ãã IA ID ãã³ãã¼ããã*/
+	memcpy(&dst->iaid, &src->iaid, sizeof(src->iaid));
+
+	return msg + sizeof(uint16_t) * 2 + sizeof(uint32_t);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  request_ia_na_pd -- REQUEST ã¡ãã»ã¼ã¸ã® IA_NA/IA_PD ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+request_ia_na_pd (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t msg_type, uint_t opt_code, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_IA_NA_PD	*dia,  *sia;
+	T_DHCP6_OPT_IAADDR	*diaa, *siaa;
+	uint8_t			*opt;
+	uint32_t		t1, t2;
+	uint_t			ix, nsiaa;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã«æå®ããããªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_msg_option(lease, opt_code, 0)) == NULL)
+		return msg;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	dia = (T_DHCP6_OPT_IA_NA_PD*)msg;
+	sia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+	msg = request_ia_option(ct, msg, opt_code, opt);
+
+	/* T1ãT2 ãæ±ºå®ããã*/
+	switch (msg_type) {
+	case DHCP6_REQUEST:
+	case DHCP6_RENEW:
+	case DHCP6_REBIND:
+		t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+		t2 = t1 + (t1 / 2);
+		break;
+
+	case DHCP6_CONFIRM:
+	case DHCP6_RELEASE:
+	case DHCP6_DECLINE:
+		t1 = t2 = 0;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] unkown msg_type in setup IA_NA/IA_PD for request message: %d.", msg_type);
+		return NULL;
+		break;
+		}
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	HOST2MSG32(dia->renew,  t1);
+	HOST2MSG32(dia->rebind, t2);
+	msg += sizeof(dia->renew) + sizeof(dia->rebind);
+
+	/* IAADDR ãªãã·ã§ã³ãè¨­å®ããã*/
+	nsiaa = ((MSG2HOST16(sia->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*sia) - (sizeof(sia->code) + sizeof(sia->len)))) / sizeof(*siaa);
+
+	for (ix = 0; ix <nsiaa; ix++) {
+		diaa = (T_DHCP6_OPT_IAADDR*)(msg + sizeof(*diaa) * ix);
+		siaa = (T_DHCP6_OPT_IAADDR*)((opt + sizeof(*sia)) + sizeof(*siaa) * ix);
+
+		/* ã¢ãã¬ã¹ã®æå¹æéãåãã¦ããã°ã¹ã­ããããã*/
+		if (MSG2HOST16(siaa->len) & DHCP6C_IAA_FLAG_EXPIRED)
+			continue;
+
+		/* ã³ã¼ãã¨é·ããè¨­å®ããã*/
+		memcpy(&diaa->code, &siaa->code, sizeof(siaa->code));
+		HOST2MSG16(diaa->len, MSG2HOST16(siaa->len) & ~DHCP6C_IAA_FLAG_MASK);
+		msg += sizeof(dia->code) + sizeof(dia->len);
+
+		/* IPv6 ã¢ãã¬ã¹ãã³ãã¼ããã*/
+		memcpy(&diaa->addr, &siaa->addr, sizeof(siaa->addr));
+		msg += sizeof(diaa->addr);
+
+		/* T1ãT2 ãæ±ºå®ããã*/
+		switch (msg_type) {
+		case DHCP6_REQUEST:
+		case DHCP6_RENEW:
+		case DHCP6_REBIND:
+			t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+			t2 = t1 + 300;
+			break;
+
+		case DHCP6_CONFIRM:
+		case DHCP6_RELEASE:
+		case DHCP6_DECLINE:
+			t1 = t2 = 0;
+			break;
+
+		default:
+			syslog(LOG_NOTICE, "[DHCP6C] unknown msg_type in setup IA_NA/IA_PD for request: %d.", msg_type);
+			return NULL;
+			break;
+			}
+
+		/* T1ãT2 ãè¨­å®ããã*/
+		HOST2MSG32(diaa->prefer, t1);
+		HOST2MSG32(diaa->valid,  t2);
+		msg += sizeof(diaa->prefer) + sizeof(diaa->valid);
+
+		/* IAADDR ã«ä»å ãªãã·ã§ã³ãè¿½å ãããå
+éããã*/
+		}
+
+	HOST2MSG16(((T_DHCP6_OPTION*)dia)->len, 
+	MSG2HOST16(((T_DHCP6_OPTION*)dia)->len) + (msg - (uint8_t*)dia) - sizeof(*dia));
+	return msg;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  request_ia_ta -- REQUEST ã¡ãã»ã¼ã¸ã® IA_TA ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+static uint8_t *
+request_ia_ta (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t msg_type, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_IA_TA	*dia,  *sia;
+	T_DHCP6_OPT_IAADDR	*diaa, *siaa;
+	uint8_t			*opt;
+	uint32_t		t1, t2;
+	uint_t			ix, nsiaa;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã« IA_TA ãªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_msg_option(lease, DHCP6_OPT_IA_TA, 0)) == NULL)
+		return msg;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	dia = (T_DHCP6_OPT_IA_TA*)msg;
+	sia = (T_DHCP6_OPT_IA_TA*)opt;
+	msg = request_ia_option(ct, msg, DHCP6_OPT_IA_TA, opt);
+
+	/* IAADDR ãªãã·ã§ã³ãè¨­å®ããã*/
+	nsiaa = ((MSG2HOST16(sia->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*sia) - (sizeof(sia->code) + sizeof(sia->len)))) / sizeof(*siaa);
+
+	for (ix = 0; ix <nsiaa; ix++) {
+		diaa = (T_DHCP6_OPT_IAADDR*)(msg + sizeof(*diaa) * ix);
+		siaa = (T_DHCP6_OPT_IAADDR*)((opt + sizeof(*sia)) + sizeof(*siaa) * ix);
+
+		/* ã¢ãã¬ã¹ã®æå¹æéãåãã¦ããã°ã¹ã­ããããã*/
+		if (MSG2HOST16(siaa->len) & DHCP6C_IAA_FLAG_EXPIRED)
+			continue;
+
+		/* ã³ã¼ãã¨é·ããè¨­å®ããã*/
+		memcpy(diaa->code, siaa->code, sizeof(siaa->code));
+		diaa->len  = HOST2MSG16(MSG2HOST16(siaa->len) & ~DHCP6C_IAA_FLAG_MASK);
+		msg += sizeof(dia->code) + sizeof(dia->len);
+
+		/* IPv6 ã¢ãã¬ã¹ãã³ãã¼ããã*/
+		memcpy(diaa->addr, siaa->addr, sizeof(siaa->addr));
+		msg += sizeof(diaa->addr);
+
+		/* T1ãT2 ãæ±ºå®ããã*/
+		switch (msg_type) {
+		case DHCP6_REQUEST:
+		case DHCP6_RENEW:
+		case DHCP6_REBIND:
+			t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+			t2 = t1 + 300;
+			break;
+
+		case DHCP6_CONFIRM:
+		case DHCP6_RELEASE:
+		case DHCP6_DECLINE:
+			t1 = t2 = 0;
+			break;
+
+		default:
+			syslog(LOG_NOTICE, "[DHCP6C] unknown msg_type in setup IA_TA for request message: %d.", msg_type);
+			return NULL;
+			break;
+			}
+
+		/* T1ãT2 ãè¨­å®ããã*/
+		HOST2MSG32(diaa->prefer, t1);
+		HOST2MSG32(diaa->valid,  t2);
+		msg += sizeof(diaa->prefer) + sizeof(diaa->valid);
+
+		/* IAADDR ã«ä»å ãªãã·ã§ã³ãè¿½å ãããå
+éããã*/
+		}
+
+	return msg;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_TA) */
+
+/*
+ *  setup_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_request_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease, uint_t type)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, type)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, type, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_NA, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+	/* IA_TA ãè¿½å ããã*/
+	msg = request_ia_ta(ct, msg, type, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_PD, lease);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+	return E_OK;
+	}
+
+/*
+ *  send_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_request_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	ct->error = E_OK;
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ã¨ã©ã¼ */
+	if (ct->adv_msg == NULL) {
+		ct->error  = E_OBJ;
+		return;
+		}
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	 	/* ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		ct->adv_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->adv_msg;
+		ct->adv_msg = NULL;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_request_msg(ct, ct->adv_msg, DHCP6_REQUEST)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup request message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send request message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REQ] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  send_refresh_msg -- REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_refresh_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPT_UNICAST	*uc;
+	ER			error;
+	uint8_t			*opt;
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ããªããã°ã¨ã©ã¼ */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL)
+		ct->error = E_OBJ;
+
+	/* REFRESH ã¿ã¤ãã RENEW ã¾ãã¯ REBIND ã§ãªããã°ã¨ã©ã¼ */
+	if (!((ct->refresh_type == DHCP6_RENEW) || (ct->refresh_type == DHCP6_REBIND)))
+		ct->error = E_PAR;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		eval_expire(ct);
+		return;
+		}
+
+	/*
+	 *  ãµã¼ããã UNICAST ãªãã·ã§ã³ãåä¿¡ããã¨ãã¯
+	 *  æå®ããã¢ãã¬ã¹ãéä¿¡å
+ã¢ãã¬ã¹ã«è¨­å®ããã
+	 */
+	if ((opt = find_msg_option(ct->act_msg, DHCP6_OPT_UNICAST, sizeof(T_DHCP6_OPT_UNICAST))) != NULL) {
+		uc = (T_DHCP6_OPT_UNICAST*)opt;
+		ct->dst.ipaddr = uc->addr;
+		}
+
+	/* REFRESH (REQUEST) ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_request_msg(ct, ct->act_msg, ct->refresh_type)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup refresh message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send refresh message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REF] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  setup_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_release_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease, uint_t type)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, type)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, type, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_NA, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_PD, lease);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+	return E_OK;
+	}
+
+/*
+ *  send_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_release_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	/* æå¹ãª REPLY ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ã¨ã©ã¼ */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL)
+		ct->error = E_OBJ;
+
+	/* æå¹ãª REPLY ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãSLEEP ç¶æ
+ã«é·ç§»ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->prf_lst != NULL) {
+
+		/* åéä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		if (ct->act_msg != NULL) {
+			syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->act_msg));
+			ct->act_msg = NULL;
+			}
+
+		/* SLEEP ç¶æ
+ã«é·ç§»ããã*/
+		ct->fsm    = DHCP6_FSM_SLEEP;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_release_msg(ct, ct->act_msg, DHCP6_RELEASE)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup release message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send release message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REL] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  advertise_msg_timeout -- ADVERTISE ã¡ãã»ã¼ã¸ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+advertise_msg_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* SOLICIT ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_SOL] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	if (select_adv(ct)) {
+		/*
+		 *  ADVERTISE ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ã
+ 		 *  REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ 		 */
+ 		start_select(ct);
+		}
+	else
+		ct->error  = E_TMOUT;
+	}
+
+/*
+ *  renew_timeout -- RENEW ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+renew_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	start_renew(ct);
+	}
+
+/*
+ *  rebind_timeout -- REBIND ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+rebind_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* REBIND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	start_rebind(ct);
+	}
+
+/*
+ *  depref_timeout -- DEPREF ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+depref_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize;
+
+	/* æå¹ãªãªã¼ã¹ãç¡ããã°å¦ççµäº */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL) {
+		return;
+		}
+
+	get_tim(&time);
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæ¨å¥¨æå¹æéãç¢ºèªããã*/
+		opt = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			for (aoff  = sizeof(*ia); aoff < asize;
+				                  aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa)) {
+
+				/* ãã§ã«æ¨å¥¨æå¹æéãçµéãã¦ããã°å¦çããªãã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if ((MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_DEPREFERD))
+					continue;
+
+				/* æ¨å¥¨æå¹æéçµéãã¦ããã° FLAG ãè¨­å®ããã*/
+				if (TIMEC_GE(time, ct->act_msg->rcv_time + MSG2HOST32(iaa->prefer))) {
+					HOST2MSG16(iaa->len, MSG2HOST16(iaa->len) | DHCP6C_IAA_FLAG_DEPREFERD);
+					if (MSG2HOST16(ia->code) == DHCP6_OPT_IA_NA)
+						syslog(LOG_NOTICE, "[DHCP6C] address depreferd: %s.", ipv62str(NULL, &iaa->addr));
+					else
+						syslog(LOG_NOTICE, "[DHCP6C] prefix  depreferd: %s.", ipv62str(NULL, &iaa->addr));
+
+					/*ãDNS ã®å¦çãå¿
+è¦ã*/
+					}
+				}
+			}
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	eval_expire(ct);
+	}
+
+/*
+ *  expire_timeout -- EXPIRE ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+expire_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize, addrs = 0;
+
+	/* æå¹ãªãªã¼ã¹ãç¡ããã°å¦ççµäº */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL) {
+		return;
+		}
+
+	get_tim(&time);
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæå¹æéãç¢ºèªããã*/
+		opt = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			for (aoff  = sizeof(*ia); aoff < asize;
+				                  aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa)) {
+
+				/* ãã§ã«æå¹æéãçµéãã¦ããã°å¦çããªãã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if ((MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_EXPIRED))
+					continue;
+
+				/* æå¹æéçµéãã¦ããã° FLAG ãè¨­å®ããã*/
+				if (TIMEC_GE(time, ct->act_msg->rcv_time + MSG2HOST32(iaa->valid))) {
+					HOST2MSG16(iaa->len, MSG2HOST16(iaa->len) | DHCP6C_IAA_FLAG_EXPIRED);
+					if (MSG2HOST16(ia->code) == DHCP6_OPT_IA_NA)
+						syslog(LOG_NOTICE, "[DHCP6C] address expired: %s.", ipv62str(NULL, &iaa->addr));
+					else
+						syslog(LOG_NOTICE, "[DHCP6C] prefix  expired: %s.", ipv62str(NULL, &iaa->addr));
+
+					/*ãDNS ã®å¦çãå¿
+è¦ã*/
+					continue;
+					}
+				addrs ++;
+				}
+			}
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	/* æå¹ãªã¢ãã¬ã¹ãå
+¨ã¦ç¡ããªã£ãæã¯ INIT ç¶æ
+ã«é·ç§»ããã*/
+	if (addrs == 0) {
+
+	 	/* ACTIVE ãªã¼ã¹ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		syslog(LOG_NOTICE, "[DHCP6C] all address expired.");
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		ct->act_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->act_msg;
+		ct->act_msg = NULL;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* INIT ç¶æ
+ã«é·ç§»ããã*/
+		start_init(ct);
+		return;
+		}
+
+	eval_expire(ct);
+	}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+/*
+ *  reply_msg_timeout -- REPLY ã¡ãã»ã¼ã¸ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+reply_msg_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* SOLICIT ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REQ] = 0;
+	ct->timers[DHCP6C_TIMER_SND_REF] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	/* STATELES ã¢ã¼ãã§ã¯SLEEP ã«é·ç§»ããã*/
+	ct->error = E_TMOUT;
+	ct->fsm   = DHCP6_FSM_SLEEP;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	/* RENEW ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		}
+	else if (ct->fsm == DHCP6_FSM_RENEW || ct->fsm == DHCP6_FSM_REBIND)
+		eval_expire(ct);
+	else {
+		/* SLEEP ã«é·ç§»ããã*/
+		ct->error = E_TMOUT;
+		ct->fsm   = DHCP6_FSM_SLEEP;
+		}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+	}
+
+/*
+ *  dispatch_timeout -- ã¿ã¤ã ã¢ã¦ãããæã®å¦ç
+ */
+
+static ER
+dispatch_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+
+	switch (ct->flags & DHCP6C_FLAG_TMOUT_TIMER_MASK) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6C_TIMER_SND_IREQ:
+		send_info_req_msg(ct);
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6C_TIMER_SND_SOL:
+		send_solicit_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REQ:
+		send_request_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REF:
+		send_refresh_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REL:
+		send_release_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_RCV_ADV:
+		advertise_msg_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_RENEW:
+		renew_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_REBIND:
+		rebind_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_DEPREF:
+		depref_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_EXPIRE:
+		expire_timeout(ct);
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+	case DHCP6C_TIMER_RCV_REPLY:
+		reply_msg_timeout(ct);
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] error, unknown timeout: %d.", ct->flags & DHCP6C_FLAG_TMOUT_TIMER_MASK);
+		break;
+		}
+
+	return ct->error;
+	}
+
+/*
+ *  dispatch_event -- ã¤ãã³ãæ¯ã®å¦ç
+ */
+
+static ER
+dispatch_event (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error = E_OK;
+
+	while (ct->fsm != DHCP6_FSM_SLEEP && error == E_OK) {
+
+		/* ã¡ãã»ã¼ã¸ã®éåä¿¡ã¨ã¿ã¤ã ã¢ã¦ããå¾
+ã¤ã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_READY));
+
+		if (ct->flags & DHCP6C_FLAG_RCV_MSG) {
+			while (ct->val_lst != NULL) {
+				error = eval_rcv_msg(ct);
+				}
+			ct->flags &= ~DHCP6C_FLAG_RCV_MSG;
+			}
+
+		if (ct->flags & DHCP6C_FLAG_TMOUT_MASK)
+			error = dispatch_timeout(ct);
+
+		if (ct->error != E_OK)
+			error = ct->error;
+		}
+
+	return error;
+	}
+
+/*
+ *  init_context -- DHCPv6 ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã
+ */
+
+static void
+init_context (T_DHCP6_CLI_CONTEXT *ct, ID cepid)
+{
+  	memset(ct, 0, sizeof(*ct));
+	ct->cepid	= cepid;
+	ct->sc		= IF_ETHER_NIC_GET_SOFTC();
+	ct->dst.portno	= DHCP6_SRV_CFG_PORTNO;
+	}
+
+/*
+ *  rel_cli_msg -- ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã
+ */
+
+static void
+rel_cli_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*ptr, *cell;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	for (ptr = ct->rcv_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->val_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->prf_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	if (ct->snd_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->snd_msg));
+	if (ct->adv_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->adv_msg));
+	ct->rcv_lst = ct->prf_lst = ct->val_lst = ct->snd_msg = ct->adv_msg = NULL;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	/* ã¹ãã¼ãã¬ã¹ã®æã¯æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+	if (ct->act_msg != NULL) {
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->act_msg));
+		ct->act_msg = NULL;
+		}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	}
+
+/*
+ *  init_cli_msg -- åã¡ãã»ã¼ã¸æ§é ä½ãåæåããã
+ */
+
+static ER
+init_cli_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*cell;
+	ER		error;
+	int		count;
+
+	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	if ((error = tget_mpf(MPF_DHCP6_CLI_MSG, (void*)&ct->snd_msg, TMO_DHCP6C_MPF_GET)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, tget_mpf() for send: %s.", itron_strerror(error));
+		return error;
+		}
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãããå ´åã¯ã
+	 *  ç²å¾ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã®æ§é ä½ã 1æ¸ããã
+	 */
+	if (ct->act_msg == NULL)
+		count = NUM_DHCP6_CLI_MSG_LIST;
+	else
+		count = NUM_DHCP6_CLI_MSG_LIST - 1;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	while (count --> 0) {
+		if ((error = tget_mpf(MPF_DHCP6_CLI_MSG, (void*)&cell, TMO_DHCP6C_MPF_GET)) != E_OK) {
+			syslog(LOG_NOTICE, "[DHCP6C] error, tget_mpf() for receive: %s.", itron_strerror(error));
+			break;
+			}
+		cell->next  = ct->rcv_lst;
+		ct->rcv_lst = cell;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	return E_OK;
+	}
+
+/*
+ *  dhcp6c_renew_info -- ãããã¯ã¼ã¯æ
+å ±ãååå¾ããã
+ */
+
+ER
+dhcp6c_renew_info (void)
+{
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	if (context.fsm == DHCP6_FSM_INFORMED) {
+
+		/* REL_INFO ç¶æ
+ã«é·ç§»ããå¾ã« SLEEP ãè§£é¤ããããã«è¨­å®ããã*/
+		context.flags |= DHCP6C_FLAG_RENEW;
+		start_rel_info(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP6_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP6_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	if (context.fsm == DHCP6_FSM_BOUND) {
+
+		/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+		start_renew(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP6_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP6_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	}
+
+/*
+ *  dhcp6c_rel_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè§£æ¾ããã
+ */
+
+ER
+dhcp6c_rel_info (void)
+{
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	start_rel_info(&context);
+	return E_OK;
+	}
+
+/*
+ *  dhcp6c_get_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè¿ãã
+ */
+
+ER
+dhcp6c_get_info (T_IN6_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                   uint32_t *rebind, uint32_t *deprefer, SYSTIM *bind_start)
+{
+	if (addr   == NULL || expire ==   NULL || renew == NULL || 
+	    rebind == NULL || deprefer == NULL || bind_start == NULL)
+		return E_PAR;
+	else if (context.act_msg == NULL)
+		return E_OBJ;
+	else {
+		//            context.timers[DHCP6C_TIMER_EXPIRE],
+		//            context.timers[DHCP6C_TIMER_RENEW],
+		//            context.timers[DHCP6C_TIMER_REBIND],
+		//            context.timers[DHCP6C_TIMER_DEPREF]);
+
+		*addr = context.act_msg->srv.ipaddr;
+		*expire		= context.timers[DHCP6C_TIMER_EXPIRE];
+		*renew		= context.timers[DHCP6C_TIMER_RENEW];
+		*rebind		= context.timers[DHCP6C_TIMER_REBIND];
+		*deprefer	= context.timers[DHCP6C_TIMER_DEPREF];
+		*bind_start	= context.act_msg->rcv_time;
+		return E_OK;
+		}
+	}
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_dhcp6_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	T_DHCP6_CLI_MSG	*msg;
+	ER_UINT		len;
+
+	len = *(ER_UINT*)p_parblk;
+	if (len < 0 && len != E_RLWAI) {
+		/* E_RLWAI ä»¥å¤ã§ã0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[DHCP6C(CBR)] error: %s, fncd: %s.", itron_strerror(len), in_strtfn(fncd));
+		}
+	else {
+		if (fncd == TEV_UDP_RCV_DAT) {
+
+			/* åä¿¡ã¡ãã»ã¼ã¸ãªã¹ããç©ºã®æã¯ãåä¿¡ããªãã§ãã¼ã¿ã°ã©ã ãæ¨ã¦ãã*/
+			if (context.rcv_lst == NULL) 
+				syslog(LOG_NOTICE, "[DHCP6C(CBR)] receive buffer all busy.");
+			else {
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã¡ãã»ã¼ã¸æ§é ä½ãæºåããã*/
+				syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+				msg = context.rcv_lst;
+				context.rcv_lst = context.rcv_lst->next;
+				syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã*/
+				len = UDP_RCV_DAT(context.cepid, &msg->srv, &msg->msg, sizeof(msg->msg), TMO_POL);
+
+				syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+				msg->len = len;
+				if (len >= 0) {
+					/* åä¿¡ããã¡ãã»ã¼ã¸ãæ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã*/
+					msg->next = context.val_lst;
+					context.val_lst = msg;
+					context.flags |= DHCP6C_FLAG_RCV_MSG;
+					}
+				else {
+					/* ã¡ãã»ã¼ã¸æ§é ä½ãåä¿¡ã¡ãã»ã¼ã¸ãªã¹ãã«æ»ãã*/
+					context.error = len;
+					msg->next = context.rcv_lst;
+					context.rcv_lst = msg;
+					}
+				syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+				}
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_READY));
+		}
+	return E_OK;
+	}
+/*
+ *  dhcp6_cli_task -- DHCPv6 ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+void
+dhcp6_cli_task (intptr_t exinf)
+{
+	T_DHCP6_CLI_CONTEXT	*ct;
+	ID			tskid;
+	ER			error;
+
+	dly_tsk(1000);
+	get_tid(&tskid);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	syslog(LOG_NOTICE, "[DHCP6C:%d] started in stateless.", tskid);
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+	syslog(LOG_NOTICE, "[DHCP6C:%d] started in statefull.", tskid);
+#else
+#endif
+
+	dly_tsk(500);
+	ct = &context;
+
+	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
+	init_context(ct, (ID)exinf);
+
+	while (true) {
+
+		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP6C_TIMER_HZ);
+
+		/* ã¯ã©ã¤ã¢ã³ã DUID ãè¨­å®ããã*/
+		init_duid(ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+		if ((error = init_cli_msg(ct))  == E_OK) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			start_req_info(ct);
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+			start_init(ct);
+#else
+#endif
+
+			/* ã¡ã¤ã³ã«ã¼ã */
+			error = dispatch_event(ct);
+			}
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)dhcpc_timer, ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg(ct);
+
+		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
+		if (!(ct->flags & DHCP6C_FLAG_RENEW)) {
+
+			/* ä¼æ­¢ããã*/
+			if (error == E_OK)
+				syslog(LOG_NOTICE, "[DHCP6C] lease released, go to sleep.");
+			else {
+				syslog(LOG_NOTICE, "[DHCP6C] server not available, go to sleep, error: %s.", itron_strerror(error));
+				ct->fsm = DHCP6_FSM_SLEEP;
+				}
+			slp_tsk();
+			}
+		ct->flags = 0;
+		ct->error = E_OK;
+		}
+	}
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.cfg	(revision 331)
@@ -0,0 +1,70 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(DHCP6_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP6_DHCP_CLI_CEPID,
+	dhcp6_cli_task,
+	DHCP6_CLI_MAIN_PRIORITY,
+	DHCP6_CLI_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_DHCP6_CLI_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_DHCP6_CLI_TIMER,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_DHCP6_CLI_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli.h	(revision 331)
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_CLI_H
+#define DHCP6_CLI_H
+
+#ifdef DHCP6_CLI_CFG
+
+#include <netinet/in.h>
+#include <netapp/dhcp6.h>
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®ã¹ã¿ãã¯ãµã¤ãº
+ */
+
+#define DHCP6_CLI_STACK_SIZE		1024		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®åªå
+åº¦
+ */
+
+#define DHCP6_CLI_MAIN_PRIORITY		5		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* 
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³
+ */
+
+/*
+ *  DHCPv6 åä½ã¢ã¼ã
+ *
+ *    #define DHCP6_CLI_CFG_MODE ã§æå®ããã
+ *    æå®ããã¦ããªããã°ãã¹ãã¼ãã¬ã¹ã«è¨­å®ããã
+ *
+ */
+
+#define DHCP6_CLI_CFG_STATELESS		0	/* ã¹ãã¼ãã¬ã¹ã«è¨­å®ããã		*/
+#define DHCP6_CLI_CFG_STATEFULL		1	/* ã¹ãã¼ããã«ã«è¨­å®ããã		*/
+#define DHCP6_CLI_CFG_RA		2	/* RA ã® M/O ãããã«ããè¨­å®ããã	*/
+#define DHCP6_CLI_CFG_MODE_DEFAULT	DHCP6_CLI_CFG_STATELESS
+
+/* IA ã®è¨­å® */
+#define DHCP6_CLI_CFG_IA_NA		1
+//#define DHCP6_CLI_CFG_IA_TA		1
+//#define DHCP6_CLI_CFG_IA_PD		1
+
+/* Rapid-commit ã®æå® */
+//#define DHCP6_CLI_CFG_RAPID_COMMIT	1
+
+/* æ¨å¥¨åº¦ã®å®ç¾© */
+#define DHCP6_CLI_CFG_PREFER_IA		50	/* IA_NA/TA/PD å½ããã®æ¨å¥¨åº¦	*/
+#define DHCP6_CLI_CFG_PREFER_IAADDR	100	/* ã¢ãã¬ã¹å½ããã®æ¨å¥¨åº¦	*/
+
+/* DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸ã®åä¿¡ãªã¹ããµã¤ãºï¼2ä»¥ä¸æå®ãããã¨ï¼ */
+#define NUM_DHCP6_CLI_MSG_LIST		3
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½æ°ãå¤æ´ç¦æ­¢ã
+ *  +1 ã¯éä¿¡ç¨
+ */
+#define NUM_MPF_DHCP6_CLI_MSG		(NUM_DHCP6_CLI_MSG_LIST+1)
+
+/* DHCP å¿
+é ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP6_CLI_CFG_REQUIRED_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP6_CLI_CFG_REQUIRED_OLIST {	\
+	DHCP6_OPT_NAME_SERVERS,		\
+	}
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP6_CLI_CFG_REQUIRED_OLIST */
+
+/* DHCP è¦æ±ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP6_CLI_CFG_REQUEST_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP6_CLI_CFG_REQUEST_OLIST {	\
+	DHCP6_OPT_DOMAIN_SEARCH,	\
+	}
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP6_CLI_CFG_REQUEST_OLIST */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå®æ°
+ *  RFC3315 ã«è¦å®ãããã¿ã¤ãã³ã°å®æ°ã¯ dhcp6.h åç
+§
+ */
+
+/* æ¨æºã¡ãã»ã¼ã¸ã®åéä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_NORMAL	ULONG_C(60*1000)
+
+/* æ¨æºè¦æ±ãªã¼ã¹æé			*/
+#define TMO_DHCP6C_REQ_LEASE	ULONG_C(7200*1000)
+
+/* ã¡ãã»ã¼ã¸æ§é ä½ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_MPF_GET	ULONG_C(1000)
+
+/* ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_RCV_DAT	ULONG_C(1000)
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½
+ */
+
+typedef struct dhcp6_cli_msg {
+	/* 4ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã*/
+	T_DHCP6_MSG		msg;		/* DHCPv6 ã¡ãã»ã¼ã¸æ§é ä½	*/
+	struct dhcp6_cli_msg	*next;		/* ãªã¹ãã®æ¬¡ã®ã¡ãã»ã¼ã¸æ§é ä½	*/
+	SYSTIM			rcv_time;	/* åä¿¡ããæé			*/
+	T_IPV6EP		srv;		/* ãµã¼ãã®IPv6ã¢ãã¬ã¹/ãã¼ãçªå· */
+	uint16_t		len;		/* msg ã®æå¹é·			*/
+	uint16_t		prefer;		/* msg ã®æ¨å¥¨åº¦			*/
+	uint16_t		status;		/* STATUS CODE ãªãã·ã§ã³ã® status */
+	} T_DHCP6_CLI_MSG;
+
+/* prefer ã®ãã©ã° */
+
+#define DHCP6_ClI_MSG_PREFER_ADDR	UINT_C(0x8000)	/* ã¢ãã¬ã¹æ
+å ±ãã		*/
+#define DHCP6_ClI_MSG_PREFER_REQUIRED	UINT_C(0x4000)	/* å¿
+é ãªãã·ã§ã³ãã		*/
+#define DHCP6_ClI_MSG_PREFER_REQUEST	UINT_C(0x2000)	/* è¦æ±ãªãã·ã§ã³ãã		*/
+#define DHCP6_ClI_MSG_PREFER_OPTION	UINT_C(0x1000)	/* PREFER ãªãã·ã§ã³ãã	*/
+#define DHCP6_ClI_MSG_PREFER_FLAG_MASK	UINT_C(0xf000)
+#define DHCP6_ClI_MSG_PREFER_VALUE_MASK	(~(DHCP6_ClI_MSG_PREFER_FLAG_MASK))
+
+/*
+ *  STATUS CODE ãªãã·ã§ã³ãç¡ãæã®å¤
+ */
+
+#define DHCP6_CLI_STAT_UNDEFINED	(-1)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+extern ER callback_nblk_dhcp6_cli (ID cepid, FN fncd, void *p_parblk);
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	dhcp6_cli_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER dhcp6c_rel_info (void);
+extern ER dhcp6c_renew_info (void);
+extern ER dhcp6c_get_info (T_IN6_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                             uint32_t *rebind, uint32_t *deprefer, SYSTIM *bind_start);
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
+
+#endif	/* of #ifndef DHCP6_CLI_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_asp.cfg	(revision 331)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+INCLUDE("netapp/dhcp6_cli.cfg");
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP6_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP6_CLI_MSG,
+	sizeof(T_DHCP6_CLI_MSG),
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_jsp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_jsp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_jsp.cfg	(revision 331)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+#include "netapp/dhcp6_cli.cfg"
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP6_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP6_CLI_MSG,
+	sizeof(T_DHCP6_CLI_MSG),
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp6_cli_var.h	(revision 331)
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_CLI_VAR_H
+#define DHCP6_CLI_VAR_H
+
+#ifdef DHCP6_CLI_CFG
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½
+ */
+
+/* TIMER ã®å®ç¾© */
+
+#define DHCP6C_TIMER_SND_SOL	0
+#define DHCP6C_TIMER_SND_REQ	1
+#define DHCP6C_TIMER_SND_REL	2
+#define DHCP6C_TIMER_RCV_ADV	3
+#define DHCP6C_TIMER_RCV_REPLY	4
+#define DHCP6C_TIMER_RENEW	5
+#define DHCP6C_TIMER_REBIND	6
+#define DHCP6C_TIMER_EXPIRE	7
+#define DHCP6C_TIMER_DEPREF	8
+#define DHCP6C_TIMER_SND_REF	9
+#define DHCP6C_TIMER_SND_IREQ	10
+#define NUM_DHCP6C_TIMERS	11
+
+#define DHCP6C_TIMER_HZ		1
+
+/* å®æ°ã®å®ç¾© */
+
+#define MAX_DUID_LEN		(ETHER_ADDR_LEN+8)
+
+typedef struct dhcp6_cli_context {
+	T_DHCP6_CLI_MSG		*rcv_lst;	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*val_lst;	/* æ¤è¨¼ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*prf_lst;	/* æ¨å¥¨ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*snd_msg;	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½			*/
+	T_DHCP6_CLI_MSG		*adv_msg;	/* éç¥ããããªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_DHCP6_CLI_MSG		*act_msg;	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IF_SOFTC		*sc;		/* IF ã®ã½ããã¦ã§ã¢æ
+å ±		*/
+	T_IPV6EP		dst;		/* éä¿¡å
+ã®IPã¢ãã¬ã¹/ãã¼ãçªå·	*/
+	SYSTIM			RT;		/* åéä¿¡éé				*/
+	SYSTIM			IRT;		/* åæåéä¿¡éé			*/
+	SYSTIM			MRT;		/* æå¤§åéä¿¡éé			*/
+	SYSTIM			MRD;		/* æå¤§åéä¿¡ç¶ç¶æé			*/
+	SYSTIM			next_MRD;	/* æ¬¡ã®æå¤§åéä¿¡ç¶ç¶æé		*/
+	SYSTIM			timers[NUM_DHCP6C_TIMERS];	
+						/* ã¿ã¤ãã¼é
+å			*/
+	ER_UINT			error;		/* ã¨ã©ã¼ã»ãã¼ã¿é·		*/
+	ID			cepid;		/* CEP ID			*/
+	uint32_t		xid;		/* ãã©ã³ã¶ã¯ã·ã§ã³ ID		*/
+	uint16_t		flags;		/* åç¨®ãã©ã°			*/
+	uint16_t		max_prefer;	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦	*/
+	uint8_t			duid[MAX_DUID_LEN];	
+						/* client DHCP Unique ID	*/
+	uint8_t			duid_len;	/* client DUID é·		*/
+	uint8_t			fsm;		/* ç¾å¨ã®ç¶æ
+			*/
+	uint8_t			MRC;		/* æå¤§åéä¿¡åæ°		*/
+	uint8_t			txcount;	/* åéä¿¡åæ°			*/
+	uint8_t			refresh_type;	/* REFRESH ã®ã¡ãã»ã¼ã¸ã¿ã¤ã	*/
+	} T_DHCP6_CLI_CONTEXT;
+
+/* fsmï¼ç¶æ
+é·ç§»ï¼ã®å®ç¾© */
+
+#define DHCP6_FSM_INIT		1
+#define DHCP6_FSM_SELECT	2
+#define DHCP6_FSM_BOUND		4
+#define DHCP6_FSM_RENEW		5
+#define DHCP6_FSM_REBIND	6
+#define DHCP6_FSM_REQ_INFO	9	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_INFORMED	10	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_REL_INFO	11	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_SLEEP		12	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+
+/* flag ã®å®ç¾© */
+
+#define DHCP6C_FLAG_TMOUT_SND_SOL	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_SOL)
+#define DHCP6C_FLAG_TMOUT_SND_REQ	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REQ)
+#define DHCP6C_FLAG_TMOUT_SND_REL	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REL)
+#define DHCP6C_FLAG_TMOUT_RCV_ADV	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RCV_ADV)
+#define DHCP6C_FLAG_TMOUT_RCV_REPLY	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RCV_REPLY)
+#define DHCP6C_FLAG_TMOUT_RENEW		(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RENEW)
+#define DHCP6C_FLAG_TMOUT_REBIND	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_REBIND)
+#define DHCP6C_FLAG_TMOUT_EXPIRE	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_EXPIRE)
+#define DHCP6C_FLAG_TMOUT_DEPREF	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_DEPREF)
+#define DHCP6C_FLAG_TMOUT_SND_REF	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REF)
+#define DHCP6C_FLAG_TMOUT_SND_IREQ	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_IREQ)
+#define DHCP6C_FLAG_TMOUT_TIMER		UINT_C(0x0010)
+#define DHCP6C_FLAG_TMOUT_TIMER_MASK	UINT_C(0x000f)
+#define DHCP6C_FLAG_TMOUT_MASK		UINT_C(0x001f)
+
+#define DHCP6C_FLAG_RCV_MSG		UINT_C(0x0200)
+#define DHCP6C_FLAG_RENEW		UINT_C(0x0400)
+
+/* IAADDR æ§é ä½ã® FLAG ã®å®ç¾©ï¼len ã«å¤éåããï¼*/
+
+#define DHCP6C_IAA_FLAG_EXPIRED		UINT_C(0x8000)
+#define DHCP6C_IAA_FLAG_DEPREFERD	UINT_C(0x4000)
+#define DHCP6C_IAA_FLAG_MASK		UINT_C(0xc000)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* æéæ¯è¼ */
+
+#define TIMEC_GT(a,b)		((int32_t)((a)-(b))>0)
+#define TIMEC_GE(a,b)		((int32_t)((a)-(b))>=0)
+
+/* æéå®æ°ã®å¤æ */
+
+#define SYSTIM2TIMER(t)		(((t)<SYSTIM_HZ/DHCP6C_TIMER_HZ)?(DHCP6C_TIMER_HZ):((t)*DHCP6C_TIMER_HZ)/SYSTIM_HZ)
+#define SYSTIM2SEC(t)		(((t)<SYSTIM_HZ)?1:((t)/SYSTIM_HZ))
+#define SEC2TIMER(t)		((t)*DHCP6C_TIMER_HZ)
+#define SEC2SYSTIM(t)		((t)*SYSTIM_HZ)
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
+
+#endif	/* of #ifndef DHCP6_CLI_VAR_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/discard.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/discard.h	(revision 321)
+++ 	(revision )
@@ -1,110 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-#ifndef _DISCARD_H_
-#define _DISCARD_H_
-
-/* 
- *  DISCARD サーバ・クライアントのスタックサイズ
- */
-
-#define TCP_DISCARD_SRV_STACK_SIZE	1024		/* TCP DISCARD サーバタスクのスタックサイズ */
-#define TCP_DISCARD_CLI_STACK_SIZE	1024		/* TCP DISCARD クライアントタスクのスタックサイズ */
-#define UDP_DISCARD_CLI_STACK_SIZE	1024		/* UDP DISCARD クライアントタスクのスタックサイズ */
-
-/* 
- *  DISCARD サーバ・クライアントの優先度
- */
-
-#define TCP_DISCARD_SRV_MAIN_PRIORITY	5	/* TCP DISCARD サーバタスクの優先度 */
-#define TCP_DISCARD_CLI_MAIN_PRIORITY	5	/* TCP DISCARD クライアントタスクの優先度 */
-#define UDP_DISCARD_CLI_MAIN_PRIORITY	5	/* UDP DISCARD クライアントタスクの優先度 */
-
-/*
- *  TCP 送受信ウインドバッファサイズ
- */
-
-#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
-
-#define TCP_DISCARD_CLI_SWBUF_SIZE	((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
-#define TCP_DISCARD_SRV_RWBUF_SIZE	((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
-
-#else	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
-
-#if defined(SUPPORT_INET4)
-
-#define TCP_DISCARD_CLI_SWBUF_SIZE	(TCP_MSS)
-#define TCP_DISCARD_SRV_RWBUF_SIZE	(TCP_MSS)
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-#define TCP_DISCARD_CLI_SWBUF_SIZE	(TCP6_MSS)
-#define TCP_DISCARD_SRV_RWBUF_SIZE	(TCP6_MSS)
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
-
-/*
- *  変数
- */
-
-extern bool_t	tcp_discard_cli_valid;
-extern bool_t	udp_discard_cli_valid;
-
-/* TCP 送受信バッファ */
-
-extern uint8_t tcp_discard_cli_swbuf[];
-extern uint8_t tcp_discard_cli_rwbuf[];
-
-extern uint8_t tcp_discard_srv_swbuf[];
-extern uint8_t tcp_discard_srv_rwbuf[];
-
-/*
- *  タスク
- */
-
-extern void tcp_discard_srv_task(intptr_t exinf);
-extern void tcp_discard_cli_task(intptr_t exinf);
-
-extern void udp_discard_cli_task(intptr_t exinf);
-
-/*
- *  関数
- */
-
-extern ER callback_nblk_tcp_discard_cli (ID cepid, FN fncd, void *p_parblk);
-
-#endif	/* of #ifndef _DISCARD_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dns.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dns.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dns.h	(revision 331)
@@ -0,0 +1,294 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DNS_H
+#define DNS_H
+
+/*
+ *  DNS ã¡ãã»ã¼ã¸ã«é¢ããå®ç¾©
+ *
+ *    RFC1034ãRFC1035ãRFC1886ãRFC2136ã
+ *    RFC2671ãRFC2845ãRFC2930ãRFC3596
+ *
+ *  DNS ã¡ãã»ã¼ã¸
+ *
+ *  +---------------------+
+ *  |       Header        |
+ *  +---------------------+
+ *  |      Question       | Question section å½¢å¼
+ *  +---------------------+
+ *  |       Answer        | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *  |     Authority       | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *  |     Additional      | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *
+ *  DNS ããã
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                      ID                       |
+ *  +--+-----------+--+--+--+--+--------+-----------+
+ *  |QR|   Opcode  |AA|TC|RD|RA|    Z   |   RCODE   |
+ *  +--+--------+--+--+--+--+--+--------+-----------+
+ *  |                    QDCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ANCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    NSCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ARCOUNT                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct dns_hdr {
+	uint16_t	id;		/* ID */
+	uint16_t	code;	/* QR:		1
+				   Opcode:	4
+				   AA:		1
+				   TC:		1
+				   RD:		1
+				   RA:		1
+				   Z:		3
+				   RCODE:	4
+				   */
+	uint16_t	qdcount;	/* question   section */
+	uint16_t	ancount;	/* answer     section */
+	uint16_t	nscount;	/* authority  section */
+	uint16_t	arcount;	/* additional section */
+	} T_DNS_HDR;
+
+/*
+ *  code ã®å®ç¾©
+ */
+
+/* QR ã®å®ç¾© */
+
+#define DNS_QR_QUERY		0x0000U
+#define DNS_QR_RESPONSE		0x8000U
+
+/* Opcode ã®å®ç¾© */
+
+#define DNS_OPCODE_MASK		0x7800U
+#define DNS_OPCODE_FORWARD	0x0000U
+#define DNS_OPCODE_REVERSE	0x0800U
+#define DNS_OPCODE_STATUS	0x1000U
+
+/* AA ã®å®ç¾© */
+
+#define DNS_AUTHORITATIVE	0x0400U
+
+/* TC ã®å®ç¾© */
+
+#define DNS_TRUN_CATION		0x0200U
+
+/* RD ã®å®ç¾© */
+
+#define DNS_RECURSION_DESIRED	0x0100U
+
+/* RA ã®å®ç¾© */
+
+#define DNS_RECURSION_AVAILABLE	0x0080U
+
+/* RCODE ã®å®ç¾© */
+
+#define DNS_RCODE_MASK		0x000fU
+#define DNS_RCODE_NO_ERROR	0x0000U
+#define DNS_RCODE_FORMAT_ERROR	0x0001U
+#define DNS_RCODE_SERVER_ERROR	0x0002U
+#define DNS_RCODE_NAME_ERROR	0x0003U
+#define DNS_RCODE_NOT_IMPLEMENT	0x0004U
+#define DNS_RCODE_REFUSED	0x0005U
+
+/*
+ * DNS TYPE ã®å®ç¾©
+ */
+
+#define DNS_TYPE_A		(uint16_t)1U
+#define DNS_TYPE_NS		(uint16_t)2U
+#define DNS_TYPE_CNAME		(uint16_t)5U
+#define DNS_TYPE_SOA		(uint16_t)6U
+#define DNS_TYPE_PTR		(uint16_t)12U
+#define DNS_TYPE_AAAA		(uint16_t)28U
+
+/*
+ * DNS CLASS ã®å®ç¾©
+ */
+
+#define DNS_CLASS_IN		(uint16_t)1U
+
+/*
+ *  RR (Resouce Record) å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                      NAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                      TYPE                     |
+ *  +-----------------------------------------------+
+ *  |                      CLASS                    |
+ *  +-----------------------------------------------+
+ *  |                       TTL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    RDLENGTH                   |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RDATA                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ */
+
+typedef struct dns_rr {
+					/* NAME			*/
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	uint32_t	ttl;		/* TTL			*/
+	uint16_t	rdlength;	/* RDATA length		*/
+					/* RDATA		*/
+	} T_DNS_RR;
+
+#define T_DNS_RR_SIZE	(sizeof(uint16_t)*3+sizeof(uint32_t))
+
+/*
+ *  Question section å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     QNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                     QTYPE                     |
+ *  +-----------------------------------------------+
+ *  |                     QCLASS                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct dns_qd {
+					/* QNAME		*/
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	} T_DNS_QD;
+
+#define T_DNS_QD_SIZE	(sizeof(uint16_t)*2)
+
+/*
+ *  SOA RDATA å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     MNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                    SERIAL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    REFRESH                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                     RETRY                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    EXPIRE                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    MINIMUM                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ */
+
+typedef struct dns_soa {
+					/* MNAME		*/
+					/* RNAME		*/
+	uint32_t	serial;		/* SERIAL		*/
+	uint32_t	refresh;	/* REFRESH		*/
+	uint32_t	retry;		/* RETRY		*/
+	uint32_t	expire;		/* EXPIRE		*/
+	uint32_t	minimum;	/* MINIMUM		*/
+	} T_DNS_SOA;
+
+#define T_DNS_SOA_SIZE	(sizeof(uint32_t)*5)
+
+/*
+ *  DNS ã®å®æ°ã®å®ç¾©
+ */
+
+#define DNS_LABEL_LENGTH	63
+#define DNS_NAME_LENGTH		255
+#define DNS_UDP_MSG_LENGTH	512
+
+#define DNS_MSG_COMP_MARK	0xc0
+
+#endif	/* of #ifndef DNS_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/echo.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/echo.h	(revision 321)
+++ 	(revision )
@@ -1,157 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-#ifndef _ECHO_H_
-#define _ECHO_H_
-
-/* 
- *  ECHO クライアント・サーバのスタックサイズ
- */
-
-#define TCP_ECHO_SRV_STACK_SIZE		1024		/* TCP ECHO サーバタスクのスタックサイズ		*/
-
-#ifdef TOPPERS_S810_CLG3_85
-#define TCP_ECHO_CLI_RCV_STACK_SIZE	512		/* TCP ECHO クライアント受信タスクのスタックサイズ	*/
-#define TCP_ECHO_CLI_SND_STACK_SIZE	512		/* TCP ECHO クライアント送信タスクのスタックサイズ	*/
-#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
-#define TCP_ECHO_CLI_RCV_STACK_SIZE	1024		/* TCP ECHO クライアント受信タスクのスタックサイズ	*/
-#define TCP_ECHO_CLI_SND_STACK_SIZE	1024		/* TCP ECHO クライアント送信タスクのスタックサイズ	*/
-#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
-
-#define UDP_ECHO_SRV_STACK_SIZE		1024		/* UDP ECHO サーバタスクのスタックサイズ		*/
-#define UDP_ECHO_CLI_STACK_SIZE		1024		/* UDP ECHO クライアントタスクのスタックサイズ	*/
-
-/* 
- *  ECHO クライアント・サーバの優先度
- */
-
-#define TCP_ECHO_SRV_MAIN_PRIORITY	5		/* TCP ECHO サーバタスクの優先度			*/
-#define TCP_ECHO_CLI_RCV_MAIN_PRIORITY	5		/* TCP ECHO クライアント受信タスクの優先度		*/
-#define TCP_ECHO_CLI_SND_MAIN_PRIORITY	5		/* TCP ECHO クライアント送信タスクの優先度		*/
-
-#define UDP_ECHO_SRV_MAIN_PRIORITY	5		/* UDP ECHO サーバタスクの優先度			*/
-#define UDP_ECHO_CLI_MAIN_PRIORITY	5		/* UDP ECHO クライアントタスクの優先度		*/
-
-/*
- *  TCP 送受信ウインドバッファサイズ
- */
-
-#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
-
-#define TCP_ECHO_CLI_SWBUF_SIZE		((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
-#define TCP_ECHO_CLI_RWBUF_SIZE		((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
-
-#define TCP_ECHO_SRV_SWBUF_SIZE		((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*2)
-#define TCP_ECHO_SRV_RWBUF_SIZE		((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*2)
-
-#else	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
-
-#if defined(SUPPORT_INET4)
-
-#define TCP_ECHO_CLI_SWBUF_SIZE		(TCP_MSS)
-#define TCP_ECHO_CLI_RWBUF_SIZE		(TCP_MSS)
-
-#define TCP_ECHO_SRV_SWBUF_SIZE		(TCP_MSS)
-#define TCP_ECHO_SRV_RWBUF_SIZE		(TCP_MSS)
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-#define TCP_ECHO_CLI_SWBUF_SIZE		(TCP6_MSS)
-#define TCP_ECHO_CLI_RWBUF_SIZE		(TCP6_MSS)
-
-#define TCP_ECHO_SRV_SWBUF_SIZE		(TCP6_MSS)
-#define TCP_ECHO_SRV_RWBUF_SIZE		(TCP6_MSS)
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
-
-/*
- *  タスク数
- */
-
-#if !(defined(USE_TCP_ECHO_SRV1) && !defined(USE_TCP_NON_BLOCKING) && defined(USE_COPYSAVE_API))
-
-#undef  NUM_TCP_ECHO_SRV_TASKS
-#define NUM_TCP_ECHO_SRV_TASKS		1
-
-#endif	/* of #if !(defined(USE_TCP_ECHO_SRV1) && !defined(USE_TCP_NON_BLOCKING) && defined(USE_COPYSAVE_API)) */
-
-/*
- *  変数
- */
-
-extern bool_t	tcp_echo_cli_valid;
-extern bool_t	udp_echo_cli_valid;
-
-/* TCP 送受信バッファ */
-
-extern uint8_t tcp_echo_cli_swbuf[];
-extern uint8_t tcp_echo_cli_rwbuf[];
-
-#ifdef _TCP_H_
-
-extern uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
-extern uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
-
-#endif	/* of #ifdef _TCP_H_ */
-
-/*
- *  タスク
- */
-
-extern void	tcp_echo_srv_task(intptr_t exinf);
-extern void	tcp_echo_srv_rcv_task(intptr_t exinf);
-extern void	tcp_echo_srv_snd_task(intptr_t exinf);
-extern void	tcp_echo_cli_rcv_task(intptr_t exinf);
-extern void	tcp_echo_cli_snd_task(intptr_t exinf);
-
-extern void	udp_echo_srv_task(intptr_t exinf);
-extern void	udp_echo_cli_task(intptr_t exinf);
-
-/*
- *  関数
- */
-
-extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
-extern ER callback_nblk_tcp_echo_cli (ID cepid, FN fncd, void *p_parblk);
-
-extern ER callback_udp_echo_srv (ID cepid, FN fncd, void *p_parblk);
-extern ER callback_udp_echo_cli (ID cepid, FN fncd, void *p_parblk);
-
-extern ER callback_nblk_udp_echo_srv (ID cepid, FN fncd, void *p_parblk);
-extern ER callback_nblk_udp_echo_cli (ID cepid, FN fncd, void *p_parblk);
-
-#endif	/* of #ifndef _ECHO_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.c	(revision 331)
@@ -0,0 +1,495 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <sil.h>
+#include "target_syssvc.h"
+#include "target_lcd.h"
+#include <kernel.h>
+#include <t_syslog.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "hw_lcd.h"
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/lcd.h>
+
+/*
+ *  å±æå¤æ°ã®å®ç¾©
+ */
+
+static bool_t newline = false;
+static int_t col = 0;
+static int8_t line[LCD_COLUMN_SIZE + 1] = { "                " };
+
+/*
+ *  lcd_cls -- LCD è¡¨ç¤ºã¯ãªã¢
+ */
+
+void
+lcd_cls (void)
+{
+	target_lcd_cls();
+	col = 0;
+	newline = false;
+	}
+
+/*
+ *  lcd_newline -- LCD ã®è¡¨ç¤ºãæ¹è¡ããã
+ */
+
+static void
+lcd_newline (void)
+{
+	target_lcd_newline(line, col);
+	col = 0;
+	newline = false;
+	}
+
+/*
+ *  lcd_initialize -- LCD åæå
+ */
+
+void
+lcd_initialize (intptr_t exinf)
+{
+	target_lcd_initialize();
+	lcd_cls();
+	}
+
+/*
+ *  lcd_putc -- LCD åºå
+ */
+
+void
+lcd_putc (ID portid, int8_t data)
+{
+	if (data == '\n')
+		newline = true;
+	else {
+		if (newline)
+			lcd_newline();
+		target_lcd_data_putc(data);
+		line[col ++] = data;
+		if (col >= LCD_COLUMN_SIZE)
+			newline = true;
+		}
+	}
+
+/*
+ *  lcd_puts -- LCD ã¸ã®æå­åã®åºå
+ */
+
+void
+lcd_puts (ID portid, const char *str)
+{
+	while (*str != '\0')
+		lcd_putc(portid, *str ++);
+	}
+
+/*
+ *  LCD ã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+
+/*
+ *  æ°å¤å¤æã®ããã®å¤æè¡¨
+ */
+
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  ãã£ã¨ãé·ãæ´æ°å (LONGEST) ã¨ç¬¦å·ãªãæ´æ°å (ULONGEST)
+ */
+
+#ifdef _int64_
+
+typedef _int64_			LONGEST;
+typedef unsigned _int64_	ULONGEST;
+
+#else	/* of #ifdef _int64_ */
+
+#ifdef _int32_
+
+typedef _int32_			LONGEST;
+typedef unsigned _int32_	ULONGEST;
+
+#else	/* of #ifdef _int32_ */
+
+typedef int_t			LONGEST;
+typedef uint_t			ULONGEST;
+
+#endif	/* of #ifdef _int32_ */
+
+#endif	/* of #ifdef _int64_ */
+
+/*
+ *  convert -- lcd_printf ã®æ°å¤å¤æ
+ */
+
+static int_t
+convert (ID portid, ULONGEST val, int_t radix,
+         const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+	bool_t	left;
+
+	if (width < 0) {
+		width = -width;
+		left = true;
+		}
+	else
+		left = false;
+
+	ix = 0;
+	do {
+		digits[ix ++] = radchar[val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	pad = ix;
+	if (!left)	/* å³è©°ã */
+		for ( ; pad < width; pad ++)
+			lcd_putc(portid, padchar);
+
+	while (ix -- > 0)
+		lcd_putc(portid, digits[ix]);
+
+	if (left)	/* å·¦è©°ã */
+		for ( ; pad < width; pad ++)
+			lcd_putc(portid, padchar);
+
+	return pchars;
+	}
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  ipv4addr -- IPv4 ã¢ãã¬ã¹åºå
+ */
+
+static void
+put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width)
+{
+	int_t len = 3;	/* 3 ã¯ '.' ã®æå­æ° */
+
+	len += convert(portid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+
+	for ( ; len < width; len ++)
+		lcd_putc(portid, ' ');
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  ipv6addr -- IPv6 ã¢ãã¬ã¹åºå
+ */
+
+static void
+put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width)
+{
+	int_t	len = 0, ix;
+	bool_t	omit = false, zero = false;
+
+	if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) {
+		lcd_putc(portid, ':');
+		lcd_putc(portid, ':');
+		}
+	else {
+		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+			if (omit) {
+				if (ix < 7) {
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				}
+			else if (ix > 0 && ix < 7 && addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				if (ix < 7) {
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				}
+			}
+
+		for ( ; len < width; len ++)
+			lcd_putc(portid, ' ');
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  macaddr -- MAC ã¢ãã¬ã¹åºå
+ */
+
+static void
+macaddr (ID portid, uint8_t *mac, int_t width)
+{
+	int_t oct, len;
+
+	for (oct = 5; oct -- > 0; ) {
+		convert(portid, *mac ++, 16, radhex, 2, false, '0'); 
+		lcd_putc(portid, ':');
+		}
+	convert(portid, *mac, 16, radhex, 2, false, '0'); 
+
+	for (len = 17; len < width; len ++)
+		lcd_putc(portid, ' ');
+	}
+
+/*
+ *  å¼æ°ãåãåºãããã®ãã¯ã­
+ */
+
+#ifdef _int32_
+
+#define GET_ARG(ap,lf)	 (lf ? va_arg(ap, _int32_) : va_arg(ap, int_t))
+
+#else	/* of #ifdef _int32_ */
+
+#define GET_ARG(ap,lf)	(va_arg(ap, int_t))
+
+#endif	/* of #ifdef _int32_ */
+
+/*
+ *  lcd_printf -- ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºå
+ */
+
+void
+lcd_printf (ID portid, const char *fmt, ...)
+{
+	va_list	ap;
+	LONGEST	val;
+	char	padchar, *str;
+	int_t	ch, width, longflag, shortflag, left;
+
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	*addr;
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+	va_start(ap, fmt);
+	while ((ch = *fmt ++) != '\0') {
+		if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+			lcd_putc(portid, (char)ch);
+			continue;
+			}
+
+		width = longflag = shortflag = 0;
+		padchar = ' ';
+
+		if (ch == '-') {		/* å·¦è©°ã */
+			fmt ++;
+			left = -1;
+			}
+		else
+			left = 1;
+
+		if ((ch = *fmt ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+			padchar = '0';
+			ch = *fmt ++;
+			}
+
+		while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+			width = width * 10 + ch - '0';
+			ch = *fmt ++;
+			}
+
+		while (ch == 'l') {		/* long (long) ã®æå® */
+			longflag ++;
+			ch = *fmt ++;
+			}
+
+		while (ch == 'h') {		/* short ã®æå® */
+			shortflag ++;
+			ch = *fmt ++;
+			}
+
+		switch (ch) {
+		case 'd':
+			val = GET_ARG(ap, longflag);
+			if (val >= 0)
+				convert(portid, val, 10, radhex, width * left, false, padchar);
+			else
+				convert(portid, -val, 10, radhex, width * left, true, padchar);
+			break;
+
+		case 'u':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 10, radhex, width * left, false, padchar);
+			break;
+
+		case 'x':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 16, radhex, width * left, false, padchar);
+			break;
+
+		case 'X':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 16, radHEX, width * left, false, padchar);
+			break;
+
+		case 'c':
+			ch = va_arg(ap, int_t);
+			lcd_putc(portid, (char)ch);
+			break;
+
+		case 's':
+			str = va_arg(ap, char*);
+			while ((ch = *str ++) != '\0')
+				lcd_putc(portid, (char)ch);
+			break;
+
+		case 'I':
+
+			if (longflag) {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				}
+			else if (shortflag) {
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+				}
+			else {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				}
+			break;
+
+		case 'M':
+			str = va_arg(ap, char*);
+			macaddr(portid, str, width);
+			break;
+
+		case '%':
+			lcd_putc(portid, '%');
+			break;
+
+		case '0':
+			fmt --;
+			break;
+
+		default:
+			break;
+			}
+
+		}
+	va_end(ap);
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/lcd.h	(revision 331)
@@ -0,0 +1,78 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  æ±ç¨ LCD ãã©ã¤ã
+ */
+
+#ifndef LCD_H
+#define LCD_H
+
+/*
+ *  lcd_cls -- LCD è¡¨ç¤ºã¯ãªã¢
+ */
+extern void lcd_cls (void);
+
+/*
+ *  lcd_initialize -- LCD åæå
+ */
+extern void lcd_initialize (intptr_t exinf);
+
+/*
+ *  lcd_putc -- LCD åºå
+ */
+extern void lcd_putc (ID portid, int8_t data);
+
+/*
+ *  lcd_puts -- LCD ã¸ã®æå­åã®åºå
+ */
+extern void lcd_puts (ID portid, const char *str);
+
+/*
+ *  LCD ã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+extern void lcd_printf (ID portid, const char *fmt, ...);
+
+#endif	/* of #ifndef LCD_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.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
  *
@@ -60,13 +60,4 @@
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
 
-#include <tinet_defs.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>
@@ -109,4 +100,10 @@
 #define TELNET_OPT_IAC		(255)
 
+#if defined(SUPPORT_INET6)
+#define API_PROTO		'6'
+#else
+#define API_PROTO		'4'
+#endif
+
 /*
  *  変数
@@ -121,4 +118,10 @@
 bool_t	wait_accept	= false;	/* 接続要求待ち中	*/
 
+#if defined(SUPPORT_INET6)
+
+T_IPV6EP	dst;
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
 #if defined(SUPPORT_INET4)
 
@@ -126,8 +129,4 @@
 
 #endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-T_IPV6EP	dst;
 
 #endif	/* of #if defined(SUPPORT_INET6) */
@@ -156,10 +155,11 @@
 		get_tim(&now);
 		if (*(ER*)p_parblk == E_OK) {
-			syslog(LOG_NOTICE, "[NCS:%02u CBN] connected:  %6lu, from: %s.%u",
-			                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+			syslog(LOG_NOTICE, "[NCS%c:%02u CBN] conct: %7lu, from: %s.%u",
+			                   API_PROTO, cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 			connected = true;
 			}
 		else
-			syslog(LOG_NOTICE, "[NCS:%02d CBN] error: %s", itron_strerror(*(ER*)p_parblk));
+			syslog(LOG_NOTICE, "[NCS%c:%02d CBN] error: %s",
+			                   API_PROTO, itron_strerror(*(ER*)p_parblk));
 		snd_len = snd_off = rcv_len = rcv_off = 0;
 		wait_accept = false;
@@ -193,6 +193,6 @@
 		if (snd_off > 0) {
 			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
-				syslog(LOG_NOTICE, "[NCS:%02d SND] flush send error: %s",
-				                   NET_CONS_CEPID, itron_strerror(error));
+				syslog(LOG_NOTICE, "[NCS%c:%02d SND] flush send error: %s",
+				                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 			snd_len = snd_off = 0;
 			}
@@ -218,6 +218,6 @@
 			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK) {
 				if (error != E_CLS)
-					syslog(LOG_NOTICE, "[NCS:%02d SND] send buff error: %s",
-					                   NET_CONS_CEPID, itron_strerror(error));
+					syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 				syscall(sig_sem(SEM_NET_CONS_SEND));
 				return;
@@ -226,6 +226,6 @@
 			if ((snd_len = tcp_get_buf(NET_CONS_CEPID, (void*)&snd_buff, TMO_FEVR)) <= 0) {
 				if (snd_len != E_CLS)
-					syslog(LOG_NOTICE, "[NCS:%02d SND] get buff error: %s",
-					                   NET_CONS_CEPID, itron_strerror(snd_len));
+					syslog(LOG_NOTICE, "[NCS%c:%02d SND] get buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(snd_len));
 				syscall(sig_sem(SEM_NET_CONS_SEND));
 				return;
@@ -253,6 +253,6 @@
 			if ((error = tcp_rel_buf(NET_CONS_CEPID, rcv_len)) != E_OK) {
 				if (error != E_CLS)
-					syslog(LOG_NOTICE, "[NCS:%02d RCV] release buff error: %s",
-					                   NET_CONS_CEPID, itron_strerror(error));
+					syslog(LOG_NOTICE, "[NCS%c:%02d RCV] release buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 				discon_net_cons();
 				return EOF;
@@ -264,6 +264,6 @@
 			else if (rcv_len < 0) {
 				if (rcv_len != E_CLS)
-					syslog(LOG_NOTICE, "[NCS:%02d RCV] recieve buff error: %s",
-					                   NET_CONS_CEPID, itron_strerror(rcv_len));
+					syslog(LOG_NOTICE, "[NCS%c:%02d RCV] recieve buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(rcv_len));
 				discon_net_cons();
 				return EOF;
@@ -284,5 +284,5 @@
 {
 	T_SERIAL_RPOR	rpor;
-	int_t		ch, req;
+	int_t		ch;
 	char		uch;
 	ER		error;
@@ -292,5 +292,6 @@
 		error = TCP_ACP_CEP(NET_CONS_CEPID, NET_CONS_REPID, &dst, TMO_NBLK);
 #if 0
-		syslog(LOG_NOTICE, "[NCS:%02d ACP] status: %s",NET_CONS_CEPID, itron_strerror(error));
+		syslog(LOG_NOTICE, "[NCS%c:%02d ACP] status: %s",
+		                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 #endif
 		if (error != E_WBLK)
@@ -307,5 +308,5 @@
 					case TELNET_OPT_DO:
 					case TELNET_OPT_DONT:
-						req = cons_getchar_raw();
+						cons_getchar_raw();
 						break;
 					case TELNET_OPT_SB:
@@ -354,18 +355,18 @@
 		if (snd_off > 0) {
 			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
-				syslog(LOG_NOTICE, "[NCS:%02d SND] send buff error: %s",
-				                   NET_CONS_CEPID, itron_strerror(error));
+				syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
+				                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 			}
 		if ((error = tcp_sht_cep(NET_CONS_CEPID)) != E_OK)
-			syslog(LOG_NOTICE, "[NCS:%02d SHT] shutdown error: %s",
-			                   NET_CONS_CEPID, itron_strerror(error));
+			syslog(LOG_NOTICE, "[NCS%c:%02d SHT] shutdown error: %s",
+			                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 		if ((error = tcp_cls_cep(NET_CONS_CEPID, TMO_FEVR)) != E_OK)
-			syslog(LOG_NOTICE, "[NCS:%02d CLS] close error: %s",
-			                   NET_CONS_CEPID, itron_strerror(error));
+			syslog(LOG_NOTICE, "[NCS%c:%02d CLS] close error: %s",
+			                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
 		connected = false;
 		syscall(sig_sem(SEM_NET_CONS_SEND));
 		get_tim(&now);
-		syslog(LOG_NOTICE, "[NCS:%02u SND] disconnected:%5lu, from: %s.%u",
-		                   NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+		syslog(LOG_NOTICE, "[NCS%c:%02u SND] discn: %7lu, from: %s.%u",
+		                   API_PROTO, NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 		}
 	return error;
@@ -499,5 +500,5 @@
 			case 'M':
 				str = va_arg(ap, char*);
-				put_macaddr(CONSOLE_PORTID, str, width);
+				put_macaddr(CONSOLE_PORTID, (uint8_t *)str, width);
 				break;
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/net_cons.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp.h	(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
  *
@@ -39,11 +39,17 @@
  */
 
+#if defined(SUPPORT_INET6)
+
+#define PUT_IPADDR(p,a,w)	put_ipv6addr(p,a,w)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
 #if defined(SUPPORT_INET4)
+
 #define PUT_IPADDR(p,a,w)	put_ipv4addr(p,a,w)
-#endif
 
-#if defined(SUPPORT_INET6)
-#define PUT_IPADDR(p,a,w)	put_ipv6addr(p,a,w)
-#endif
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -52,8 +58,12 @@
 
 #ifndef CONSOLE_PORTID
+#define	CONSOLE_PORTID		LOGTASK_PORTID
+#endif
 
-#define	CONSOLE_PORTID		LOGTASK_PORTID
+/*
+ *  コンソールに用いる LCD ポート番号
+ */
 
-#endif	/* of #ifndef CONSOLE_PORTID */
+#define	LCD_PORTID		0
 
 /*
@@ -80,9 +90,8 @@
 extern int_t put_macaddr (ID portid, uint8_t *mac, int_t width);
 
-#if defined(SUPPORT_INET4)
+#ifdef T_IN4_ADDR_DEFINED
 extern int_t put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width);
 #endif
-
-#if defined(SUPPORT_INET6)
+#ifdef T_IN6_ADDR_DEFINED
 extern int_t put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width);
 #endif
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.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
  *
@@ -44,4 +44,6 @@
 #include <sil.h>
 #include <syssvc/serial.h>
+#include <syssvc/logtask.h>
+#include <t_syslog.h>
 #include "kernel_cfg.h"
 #include "tinet_cfg.h"
@@ -62,4 +64,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 
 #include <netinet/in.h>
@@ -68,6 +71,244 @@
 #include <netapp/netapp.h>
 #include <netapp/netapp_var.h>
+#include <netapp/resolver.h>
 
 #ifdef USE_NETAPP_SUBR
+
+/*
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
+ */
+
+#if defined(SUPPORT_INET6)
+
+#ifdef USE_TCP_EXTENTIONS
+
+const ID vrid_tcp6_cep[] =
+{
+#if NUM_VRID_TCP6_CEPS >= 1
+	TCP6_RSV_CEPID1,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 2
+	TCP6_RSV_CEPID2,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 3
+	TCP6_RSV_CEPID3,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 4
+	TCP6_RSV_CEPID4,
+#endif
+	};
+
+const ID vrid_tcp6_rep[] =
+{
+#if NUM_VRID_TCP6_REPS >= 1
+	TCP6_RSV_REPID1,
+#endif
+#if NUM_VRID_TCP6_REPS >= 2
+	TCP6_RSV_REPID2,
+#endif
+	};
+
+ID tskid_tcp6_cep[NUM_VRID_TCP6_CEPS];
+ID tskid_tcp6_rep[NUM_VRID_TCP6_REPS];
+
+#endif	/* #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+const ID vrid_udp6_cep[] =
+{
+#if NUM_VRID_UDP6_CEPS >= 1
+	UDP6_RSV_CEPID1,
+#endif
+#if NUM_VRID_UDP6_CEPS >= 2
+	UDP6_RSV_CEPID2,
+#endif
+	};
+
+ID tskid_udp6_cep[NUM_VRID_UDP6_CEPS];
+
+#endif	/* #ifdef USE_UDP_EXTENTIONS */
+
+#undef	TCP_CRE_REP
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	TCP_IS_CEPID
+#undef  ALLOC_TCP_REP
+#undef  ALLOC_TCP_CEP
+#undef  ALLOC_UDP_CEP
+#undef  FREE_TCP_REP
+#undef  FREE_TCP_CEP
+#undef  FREE_UDP_CEP
+#undef	T_TCPN_CREP
+#undef	T_UDPN_CCEP
+#undef	NUM_VRID_TCP_CEPS
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_UDP_CEP
+#undef	VRID_TCP_REP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+#undef	API_IPPROTO
+
+#define TCP_CRE_REP		tcp6_cre_rep
+#define UDP_CRE_CEP		udp6_cre_cep
+#define UDP_DEL_CEP		udp6_del_cep
+
+#define TCP_IS_CEPID		tcp6_is_cepid
+#define ALLOC_TCP_REP		alloc_tcp6_rep
+#define ALLOC_TCP_CEP		alloc_tcp6_cep
+#define ALLOC_UDP_CEP		alloc_udp6_cep
+#define FREE_TCP_REP		free_tcp6_rep
+#define FREE_TCP_CEP		free_tcp6_cep
+#define FREE_UDP_CEP		free_udp6_cep
+#define T_TCPN_CREP		T_TCP6_CREP
+#define T_UDPN_CCEP		T_UDP6_CCEP
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP6_CEPS
+#define NUM_VRID_TCP_REPS	NUM_VRID_TCP6_REPS
+#define NUM_VRID_UDP_CEPS	NUM_VRID_UDP6_CEPS
+#define VRID_TCP_CEP		vrid_tcp6_cep
+#define VRID_TCP_REP		vrid_tcp6_rep
+#define VRID_UDP_CEP		vrid_udp6_cep
+#define TSKID_TCP_CEP		tskid_tcp6_cep
+#define TSKID_TCP_REP		tskid_tcp6_rep
+#define TSKID_UDP_CEP		tskid_udp6_cep
+#define API_IPPROTO		API_PROTO_IPV6
+
+#include <netapp/netappn_subr.c>
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#ifdef USE_TCP_EXTENTIONS
+
+const ID vrid_tcp4_cep[] =
+{
+#if NUM_VRID_TCP4_CEPS >= 1
+	TCP4_RSV_CEPID1,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 2
+	TCP4_RSV_CEPID2,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 3
+	TCP4_RSV_CEPID3,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 4
+	TCP4_RSV_CEPID4,
+#endif
+	};
+
+const ID vrid_tcp4_rep[] =
+{
+#if NUM_VRID_TCP4_REPS >= 1
+	TCP4_RSV_REPID1,
+#endif
+#if NUM_VRID_TCP4_REPS >= 2
+	TCP4_RSV_REPID2,
+#endif
+	};
+
+ID tskid_tcp4_cep[NUM_VRID_TCP4_CEPS];
+ID tskid_tcp4_rep[NUM_VRID_TCP4_REPS];
+
+#endif	/* #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+const ID vrid_udp4_cep[] =
+{
+#if NUM_VRID_UDP4_CEPS >= 1
+	UDP4_RSV_CEPID1,
+#endif
+#if NUM_VRID_UDP4_CEPS >= 2
+	UDP4_RSV_CEPID2,
+#endif
+	};
+
+ID tskid_udp4_cep[NUM_VRID_UDP4_CEPS];
+
+#endif	/* #ifdef USE_UDP_EXTENTIONS */
+
+#undef	TCP_CRE_REP
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	TCP_IS_CEPID
+#undef  ALLOC_TCP_REP
+#undef  ALLOC_TCP_CEP
+#undef  ALLOC_UDP_CEP
+#undef  FREE_TCP_REP
+#undef  FREE_TCP_CEP
+#undef  FREE_UDP_CEP
+#undef	T_TCPN_CREP
+#undef	T_UDPN_CCEP
+#undef	NUM_VRID_TCP_CEPS
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_TCP_REP
+#undef	VRID_UDP_CEP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+#undef	API_IPPROTO
+
+#define TCP_CRE_REP		tcp_cre_rep
+#define UDP_CRE_CEP		udp_cre_cep
+#define UDP_DEL_CEP		udp_del_cep
+#define TCP_IS_CEPID		tcp4_is_cepid
+#define ALLOC_TCP_REP		alloc_tcp4_rep
+#define ALLOC_TCP_CEP		alloc_tcp4_cep
+#define ALLOC_UDP_CEP		alloc_udp4_cep
+#define FREE_TCP_REP		free_tcp4_rep
+#define FREE_TCP_CEP		free_tcp4_cep
+#define FREE_UDP_CEP		free_udp4_cep
+#define T_TCPN_CREP		T_TCP_CREP
+#define T_UDPN_CCEP		T_UDP_CCEP
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP4_CEPS
+#define NUM_VRID_TCP_REPS	NUM_VRID_TCP4_REPS
+#define NUM_VRID_UDP_CEPS	NUM_VRID_UDP4_CEPS
+#define VRID_TCP_CEP		vrid_tcp4_cep
+#define VRID_TCP_REP		vrid_tcp4_rep
+#define VRID_UDP_CEP		vrid_udp4_cep
+#define TSKID_TCP_CEP		tskid_tcp4_cep
+#define TSKID_TCP_REP		tskid_tcp4_rep
+#define TSKID_UDP_CEP		tskid_udp4_cep
+#define API_IPPROTO		API_PROTO_IPV4
+
+#include <netapp/netappn_subr.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#undef	TCP_CRE_REP
+#undef  ALLOC_TCPN_REP
+#undef  ALLOC_TCPN_CEP
+#undef  ALLOC_UDPN_CEP
+#undef  FREE_TCPN_REP
+#undef  FREE_TCPN_CEP
+#undef  FREE_UDPN_CEP
+#undef	T_TCPN_CREP
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_TCP_REP
+#undef	VRID_UDP_CEP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+
+/*
+ *  変数
+ */
+
+static uint32_t rand_next = ULONG_C(1);
+
+#if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+const T_IN6_ADDR in6_addr_unspecified =
+	IPV6_ADDR_UNSPECIFIED_INIT;
+
+#endif	/* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
 
 /*
@@ -83,4 +324,28 @@
 const char radhex[] = "0123456789abcdef";
 const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  netapp_rand -- 乱数を返す。
+ */
+
+uint32_t
+netapp_rand (void)
+{
+	rand_next = (rand_next * 99991 + 12345) & ULONG_C(0x7fffffff);
+	return rand_next;
+	}
+
+/*
+ *  srand -- 乱数を初期化する。
+ */
+
+void
+netapp_srand (uint32_t seed)
+{
+	SYSTIM now;
+
+	syscall(get_tim(&now));
+	rand_next += now + seed;
+	}
 
 #ifndef USE_NET_CONS
@@ -160,6 +425,4 @@
 	return pchars;
 	}
-
-#if defined(SUPPORT_INET4)
 
 /*
@@ -186,10 +449,4 @@
 	}
 
-#define PUT_IPADDR(p,a,w)	put_ipv4addr(p,a,w)
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
 /*
  *  ipv6addr -- IPv6 アドレス出力
@@ -199,8 +456,8 @@
 put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width)
 {
-	int_t	len = 0, ix;
+	int_t	len = 0, ix, len6;
 	bool_t	omit = false, zero = false;
 
-	if (addr == NULL) {
+	if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) {
 		cons_putchar(portid, '0');
 		cons_putchar(portid, ':');
@@ -210,5 +467,9 @@
 		}
 	else {
-		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+		if (in6_is_addr_ipv4mapped(addr))
+			len6 = sizeof(T_IN6_ADDR) / 2 - 2;
+		else
+			len6 = sizeof(T_IN6_ADDR) / 2;
+		for (ix = 0; ix < len6; ix ++) {
 			if (omit) {
 				len += cons_putnumber(portid, ntohs(addr->s6_addr16[ix]), 16, radhex, 0, false, ' '); 
@@ -234,4 +495,11 @@
 			}
 
+		if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
+			T_IN4_ADDR ip4addr;
+
+			ip4addr = ntohl(addr->s6_addr32[3]);
+			len += put_ipv4addr(portid, &ip4addr, 0);
+			}
+
 		for ( ; len < width; len ++)
 			cons_putchar(portid, ' ');
@@ -239,8 +507,4 @@
 	return len;
 	}
-
-#define PUT_IPADDR(p,a,w)	put_ipv6addr(p,a,w)
-
-#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -275,9 +539,6 @@
 	long_t	val;
 	char	padchar, *str;
-	int_t	ch, width, longflag, left;
-
-#if defined(SUPPORT_INET4)
+	int_t	ch, width, longflag, shortflag, left;
 	T_IN4_ADDR	*addr;
-#endif	/* of #if defined(SUPPORT_INET4) */
 
 	va_start(ap, fmt);
@@ -288,8 +549,8 @@
 			}
 
-		width = longflag = 0;
+		width = longflag = shortflag = 0;
 		padchar = ' ';
 
-		if (ch == '-') {		/* 左詰め */
+		if (*fmt == '-') {		/* 左詰め */
 			fmt ++;
 			left = -1;
@@ -310,4 +571,9 @@
 		while (ch == 'l') {		/* long (long) の指定 */
 			longflag ++;
+			ch = *fmt ++;
+			}
+
+		while (ch == 'h') {		/* short の指定 */
+			shortflag ++;
 			ch = *fmt ++;
 			}
@@ -358,23 +624,36 @@
 		case 'I':
 
+			if (longflag) {
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+				}
+			else if (shortflag) {
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+				}
+			else {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
 #if defined(SUPPORT_INET4)
 
-			addr = va_arg(ap, T_IN4_ADDR *);
-			put_ipv4addr(portid, addr, width);
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
 
 #endif	/* of #if defined(SUPPORT_INET4) */
 
-#if defined(SUPPORT_INET6)
-
-			str = va_arg(ap, char*);
-			put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
-
 #endif	/* of #if defined(SUPPORT_INET6) */
 
+				}
 			break;
 
 		case 'M':
 			str = va_arg(ap, char*);
-			put_macaddr(portid, str, width);
+			put_macaddr(portid, (uint8_t *)str, width);
 			break;
 
@@ -396,4 +675,56 @@
 
 /*
+ *  host2msg16 -- 16ビットの値を、バイトオーダーを調整してメッセージに書き込む。
+ */
+
+void
+host2msg16 (void *msg, uint16_t host_data)
+{
+	uint16_t	msg_data;
+
+	msg_data = htons(host_data);
+	memcpy(msg, &msg_data, sizeof(msg_data));
+	}
+
+/*
+ *  host2msg32 -- 32ビットの値を、バイトオーダーを調整してメッセージに書き込む。
+ */
+
+void
+host2msg32 (void *msg, uint32_t host_data)
+{
+	uint32_t	msg_data;
+
+	msg_data = htonl(host_data);
+	memcpy(msg, &msg_data, sizeof(msg_data));
+	}
+
+/*
+ *  msg2host16 -- 16ビットの値を、バイトオーダーを調整してメッセージから読み出す。
+ */
+
+uint16_t
+msg2host16 (void *msg)
+{
+	uint16_t	host_data;
+
+	memcpy(&host_data, msg, sizeof(host_data));
+	return htons(host_data);
+	}
+
+/*
+ *  msg2host32 -- 32ビットの値を、バイトオーダーを調整してメッセージから読み出す。
+ */
+
+uint32_t
+msg2host32 (void *msg)
+{
+	uint32_t	host_data;
+
+	memcpy(&host_data, msg, sizeof(host_data));
+	return htonl(host_data);
+	}
+
+/*
  *  skip_blanks -- 空白と TAB をスキップする。
  */
@@ -416,5 +747,5 @@
 	int_t oct;
 
-	*addr = 0;
+	*addr = IPV4_ADDRANY;
 	while ('0' <= *line && *line <= '9') {
 		oct = 0;
@@ -425,8 +756,12 @@
 			line ++;
 		}
+#if 1
+	return *addr == IPV4_ADDRANY ? NULL : line;
+#else
 	return line;
-	}
-
-#if defined(SUPPORT_INET6)
+#endif
+	}
+
+#if defined(SUPPORT_INET6) || defined(USE_RESOLVER)
 
 /*
@@ -438,35 +773,51 @@
 {
 	int_t word, ix = 0, omit = 0, six;
+	char *ipv4line;
 
 	memset(addr, 0, sizeof(T_IN6_ADDR));
-	while (ix < 8 &&
-	       (('0' <= *line && *line <= '9') ||
-	        ('a' <= *line && *line <= 'f') ||
-	        ('A' <= *line && *line <= 'F'))) {
-		word = 0;
-		while (('0' <= *line && *line <= '9') ||
- 	               ('a' <= *line && *line <= 'f') ||
-	               ('A' <= *line && *line <= 'F')) {
-			if      ('0' <= *line && *line <= '9')
-				word = (word << 4) + (*line ++) - '0';
-			else if ('a' <= *line && *line <= 'f')
-				word = (word << 4) + (*line ++) - 'a' + 10;
-			else if ('A' <= *line && *line <= 'F')
-				word = (word << 4) + (*line ++) - 'A' + 10;
-			}
-		addr->s6_addr16[ix ++] = htons(word);
-		if (*line == ':') {
-			line ++;
+
+	/*
+	 * IPv4 アドレス（数字.）を検出したら IPv4 アドレスとして入力し、
+	 * IPv4 射影アドレスに変換する。
+	 */
+	for (ipv4line = line; '0' <= *ipv4line && *ipv4line <= '9'; ipv4line ++)
+		;
+	if (*ipv4line == '.') {
+		T_IN4_ADDR ipv4addr;
+
+		line = get_ipv4addr(&ipv4addr, line);
+		in6_make_ipv4mapped (addr, ipv4addr);
+		}
+	else {
+		while (ix < 8 &&
+		       (('0' <= *line && *line <= '9') ||
+		        ('a' <= *line && *line <= 'f') ||
+		        ('A' <= *line && *line <= 'F'))) {
+			word = 0;
+			while (('0' <= *line && *line <= '9') ||
+ 		               ('a' <= *line && *line <= 'f') ||
+		               ('A' <= *line && *line <= 'F')) {
+				if      ('0' <= *line && *line <= '9')
+					word = (word << 4) + (*line ++) - '0';
+				else if ('a' <= *line && *line <= 'f')
+					word = (word << 4) + (*line ++) - 'a' + 10;
+				else if ('A' <= *line && *line <= 'F')
+					word = (word << 4) + (*line ++) - 'A' + 10;
+				}
+			addr->s6_addr16[ix ++] = htons(word);
 			if (*line == ':') {
-				omit = ix;
 				line ++;
-				}
-			}
-		}
-	if (omit > 0) {
-		six = 7;
-		while (ix > omit) {
-			addr->s6_addr16[six --] = addr->s6_addr16[-- ix];
-			addr->s6_addr16[ ix   ] = 0;
+				if (*line == ':') {
+					omit = ix;
+					line ++;
+					}
+				}
+			}
+		if (omit > 0) {
+			six = 7;
+			while (ix > omit) {
+				addr->s6_addr16[six --] = addr->s6_addr16[-- ix];
+				addr->s6_addr16[ ix   ] = 0;
+				}
 			}
 		}
@@ -474,5 +825,5 @@
 	}
 
-#endif	/* of #if defined(SUPPORT_INET6) */
+#endif	/* of #if defined(SUPPORT_INET6) || defined(USE_RESOLVER) */
 
 /*
@@ -559,199 +910,319 @@
 	}
 
-#ifdef USE_TCP_EXTENTIONS
-
-const ID vrid_tcp_rep[] =
-{
-#if NUM_VRID_TCP_REPS >= 1
-	TCP_RSV_REPID1,
-#endif
-#if NUM_VRID_TCP_REPS >= 2
-	TCP_RSV_REPID2,
-#endif
-	};
-
-const ID vrid_tcp_cep[] =
-{
-#if NUM_VRID_TCP_CEPS >= 1
-	TCP_RSV_CEPID1,
-#endif
-#if NUM_VRID_TCP_CEPS >= 2
-	TCP_RSV_CEPID2,
-#endif
-#if NUM_VRID_TCP_CEPS >= 3
-	TCP_RSV_CEPID3,
-#endif
-#if NUM_VRID_TCP_CEPS >= 4
-	TCP_RSV_CEPID4,
-#endif
-	};
-
-ID tskid_tcp_rep[NUM_VRID_TCP_REPS];
-ID tskid_tcp_cep[NUM_VRID_TCP_CEPS];
-
-/*
- *  alloc_tcp_rep -- TCP 受付口を獲得する。
- */
-
-ER
-alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep)
-{
-	int_t	ix;
-
-	*repid = TCP_REP_NONE;
-	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
-	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
-		if (tskid_tcp_rep[ix] == TSK_NONE) {
-			*repid = vrid_tcp_rep[ix];
-			tskid_tcp_rep[ix] = tskid;
+#ifdef USE_RESOLVER
+
+/*
+ *  dns_strtype -- DNS の type の文字列を返す。
+ */
+
+const char *
+dns_strtype (uint_t type)
+{
+	switch (type) {
+	case DNS_TYPE_A:
+		return "A";
+		break;
+	case DNS_TYPE_NS:
+		return "NS";
+		break;
+	case DNS_TYPE_CNAME:
+		return "CNAME";
+		break;
+	case DNS_TYPE_SOA:
+		return "SOA";
+		break;
+	case DNS_TYPE_PTR:
+		return "PTR";
+		break;
+	case DNS_TYPE_AAAA:
+		return "AAAA";
+		break;
+	default:
+		return "unknown type";
+		break;
+		}
+	}
+
+/*
+ *  dns_strclass -- DNS の class を表示する。
+ */
+
+const char *
+dns_strclass (uint_t class)
+{
+	switch (class) {
+	case DNS_CLASS_IN:
+		return "IN";
+		break;
+	default:
+		return "unknown class";
+		break;
+		}
+	}
+
+/*
+ *  resolv_hoststr -- 文字列のFQDN・ホスト名・IPv6/IPv4 アドレスを解析する。
+ */
+
+#define IS_HOSTCH_DIGIT(c)	(('0'<=(c)&&(c)<='9'))
+#define IS_HOSTCH_XDIGIT(c)	(IS_HOSTCH_DIGIT(c)||('a'<=(c)&&(c)<='f')||('A'<=(c)&&(c)<='F'))
+#define IS_HOSTCH_ALPHA(c)	(('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='z'))
+#define IS_HOSTCH_ALNUM(c)	(IS_HOSTCH_ALPHA(c)||IS_HOSTCH_DIGIT(c))
+#define IS_HOSTCH_IPV6ADDR(c)	(IS_HOSTCH_XDIGIT(c)||(c)==':')
+#define IS_HOSTCH_IPV4ADDR(c)	(IS_HOSTCH_DIGIT(c)||(c)=='.')
+#define IS_HOSTCH_IPADDR(c)	(IS_HOSTCH_XDIGIT(c)||(c)==':'||(c)=='.')
+#define IS_HOSTCH_NAME_FIRST(c)	(IS_HOSTCH_ALPHA(c))
+#define IS_HOSTCH_NAME(c)	(IS_HOSTCH_ALNUM(c)||(c)=='-'||(c)=='.')
+#define IS_HOSTCH_BLANK(c)	((c)=='\0'||(c)==' '||(c)=='\t')
+
+char *
+resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line)
+{
+	char *h, *p;
+
+	h = hostname;
+	p = line = skip_blanks(line);
+
+	if (IS_HOSTCH_IPADDR(*p)) {
+		while (IS_HOSTCH_DIGIT(*p)) {
+			if (h - hostname > name_size)
+				return NULL;
+			*h ++ = *p ++;
+			}
+		if (p > line && *p == '.') {
+			while (IS_HOSTCH_IPV4ADDR(*p)) {
+				if (h - hostname > name_size)
+					return NULL;
+				*h ++ = *p ++;
+				}
+			if (IS_HOSTCH_BLANK(*p)) {
+				*flags |= HOSTSTR_IPV4;
+				*h = '\0';
+				return p;
+				}
+			}
+		else if (IS_HOSTCH_IPADDR(*p)) {
+			while (IS_HOSTCH_IPADDR(*p)) {
+				if (h - hostname > name_size)
+					return NULL;
+				*h ++ = *p ++;
+				}
+			if (IS_HOSTCH_BLANK(*p)) {
+				*flags |= HOSTSTR_IPV6;
+				*h = '\0';
+				return p;
+				}
+			}
+		h = hostname;
+		p = line;
+		}
+
+	if (IS_HOSTCH_NAME_FIRST(*p)) {
+		*flags |= HOSTSTR_HOSTNAME;
+		while (IS_HOSTCH_NAME(*p)) {
+			if (h - hostname > name_size)
+				return NULL;
+			if (*p == '.')
+				*flags |= HOSTSTR_FQDN;
+			*h ++ = *p ++;
+			}
+		}
+	else
+		*flags |= HOSTSTR_OTHER;
+
+	*h = '\0';
+	return p;
+	}
+
+/*
+ *  show_dns_domain_name -- DNS のドメイン名を表示する。
+ */
+
+uint_t
+show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset)
+{
+	uint8_t	*ptr;
+	uint_t	c;
+
+	ptr = hdr + offset;
+	while (*ptr) {
+		if ((*ptr & DNS_MSG_COMP_MARK) == DNS_MSG_COMP_MARK) {
+			show_dns_domain_name(portid, hdr, (*ptr & ~DNS_MSG_COMP_MARK) << 8 | *(ptr + 1));
+			ptr += 2;
 			break;
 			}
-		}
-	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
-
-	if (*repid == TCP_REP_NONE)
-		return E_NOEXS;
+		else {
+			for (c = 1; c <= *ptr; c++)
+				cons_printf(portid, "%c", *(ptr + c));
+			ptr += *ptr + 1;
+			if (*ptr)
+				cons_printf(portid, ".");
+			}
+		}
+	return ptr - hdr;
+	}
+
+/*
+ *  resolv_options -- アドレス解決のオプション解析
+ */
+
+char *
+resolv_options (uint_t *flags, char *line, char apip)
+{
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	in6_addr;
+#endif
+
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	in4_addr;
+#endif
+
+	line = skip_blanks(line);
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	*flags |= DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4;
+	if (apip == API_PROTO_IPV4)
+		*flags |= DNS_LUP_FLAGS_QTYPE_A;
 	else
-		return TCP_CRE_REP(*repid, crep);
-	}
-
-/*
- *  free_tcp_rep -- TCP 受付口を解放する。
- */
-
-ER
-free_tcp_rep (ID repid, bool_t call_tcp_del_rep)
-{
-	int_t	ix;
-
-	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
-	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
-		if (repid == vrid_tcp_rep[ix]) {
-			tskid_tcp_rep[ix] = TSK_NONE;
-			break;
-			}
-		}
-	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
-
-	if (call_tcp_del_rep)
-		return tcp_del_rep(repid);
-	else
-		return E_OK;
-	}
-
-/*
- *  alloc_tcp_cep -- TCP 通信端点を獲得する。
- */
-
-ER
-alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep)
-{
-	int_t	ix;
-
-	*cepid = TCP_CEP_NONE;
-	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
-	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
-		if (tskid_tcp_cep[ix] == TSK_NONE) {
-			*cepid = vrid_tcp_cep[ix];
-			tskid_tcp_cep[ix] = tskid;
-			break;
-			}
-		}
-	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
-
-	if (*cepid == TCP_CEP_NONE)
-		return E_NOEXS;
-	else
-		return tcp_cre_cep(*cepid, ccep);
-	}
-
-/*
- *  free_tcp_cep -- TCP 通信端点を解放する。
- */
-
-ER
-free_tcp_cep (ID cepid)
-{
-	int_t	ix;
-
-	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
-	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
-		if (cepid == vrid_tcp_cep[ix]) {
-			tskid_tcp_cep[ix] = TSK_NONE;
-			break;
-			}
-		}
-	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
-
-	return tcp_del_cep(cepid);
-	}
-
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
-#ifdef USE_UDP_EXTENTIONS
-
-const ID vrid_udp_cep[] =
-{
-#if NUM_VRID_UDP_CEPS >= 1
-	UDP_RSV_CEPID1,
-#endif
-#if NUM_VRID_UDP_CEPS >= 2
-	UDP_RSV_CEPID2,
-#endif
-	};
-
-ID tskid_udp_cep[NUM_VRID_UDP_CEPS];
-
-/*
- *  alloc_udp_cep -- UDP 通信端点を獲得する。
- */
-
-ER
-alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep)
-{
-	int_t	ix;
-
-	*cepid = UDP_CEP_NONE;
-	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
-	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
-		if (tskid_udp_cep[ix] == TSK_NONE) {
-			*cepid = vrid_udp_cep[ix];
-			tskid_udp_cep[ix] = tskid;
-			break;
-			}
-		}
-	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
-
-	if (*cepid == UDP_CEP_NONE)
-		return E_NOEXS;
-	else
-		return UDP_CRE_CEP(*cepid, ccep);
-	}
-
-/*
- *  free_udp_cep -- UDP 通信端点を解放する。
- */
-
-ER
-free_udp_cep (ID cepid, bool_t call_udp_del_cep)
-{
-	int_t	ix;
-
-	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
-	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
-		if (cepid == vrid_udp_cep[ix]) {
-			tskid_udp_cep[ix] = TSK_NONE;
-			break;
-			}
-		}
-	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
-
-	if (call_udp_del_cep)
-		return udp_del_cep(cepid);
-	else
-		return E_OK;
-	}
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+		*flags |= DNS_LUP_FLAGS_QTYPE_AAAA;
+
+	if (*line == '-') {
+		line ++;
+		if (*line == '6') {
+			line ++;
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
+			}
+		else if (*line == '4') {
+			line ++;
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
+			}
+		if (*line == 'Q' || *line == 'q') {
+			*flags &= ~DNS_LUP_FLAGS_QTYPE_A;
+			line ++;                   
+			}
+		else if (*line == 'A' || *line == 'a') {
+			*flags &= ~DNS_LUP_FLAGS_QTYPE_AAAA;
+			line ++;                   
+			}
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+	*flags = DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_QTYPE_AAAA;
+	if (*line == '-') {
+		line ++;
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	*flags = DNS_LUP_FLAGS_PROTO_IPV4 | DNS_LUP_FLAGS_QTYPE_A;
+	if (*line == '-') {
+		line ++;
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET6)
+
+	if (*flags | DNS_LUP_FLAGS_PROTO_IPV6) {
+		/*
+		 *  IPv6 で DNS サーバに照会することが指定されても、
+		 *  サーバの IPv6 アドレスが未定義の時は、指定を外す。
+		 */
+		dns_in6_get_addr(&in6_addr);
+		if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	if (*flags | DNS_LUP_FLAGS_PROTO_IPV4) {
+		/*
+		 *  IPv4 で DNS サーバに照会することが指定されても、
+		 *  サーバの IPv4 アドレスが未定義の時は、指定を外す。
+		 */
+		dns_in4_get_addr(&in4_addr);
+		if (in4_addr == IPV4_ADDRANY)
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+	return line;
+	}
+
+#endif	/* of #ifdef USE_RESOLVER */
+
+/*
+ *  lookup_ipaddr -- ホスト名・リテラルのIPアドレスをIP アドレスに変換する。
+ */
+
+char *
+lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip)
+{
+
+#ifdef USE_RESOLVER
+
+	static char hostname[DBG_LINE_SIZE + 1];
+
+	ER_UINT	error;
+	uint_t	flags = 0;
+	char	*last;
+
+	line = skip_blanks(resolv_options(&flags, line, apip));
+	if ((last = resolv_hoststr(&flags, hostname, sizeof(hostname), line)) == NULL) {
+		cons_printf(CONSOLE_PORTID, "unknown host: %s.\n", hostname);
+		return NULL;
+		}
+
+	switch (flags & DNS_LUP_FLAGS_NAME_MASK) {
+	case DNS_LUP_FLAGS_NAME_IPV4:
+	case DNS_LUP_FLAGS_NAME_IPV6:
+		line = GET_IPADDR(addr, line);		/* IP Address by Literal */
+		break;
+
+	case DNS_LUP_FLAGS_NAME_HOST:
+	case DNS_LUP_FLAGS_NAME_FQDN:
+		line = last;
+		if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
+			cons_printf(CONSOLE_PORTID, "DNS server not available.\n");
+			return NULL;
+			}
+
+		flags |= DNS_LUP_OPCODE_FORWARD;
+		if ((error = dns_host_addr(flags, hostname, addr)) != E_OK) {
+			cons_printf(CONSOLE_PORTID, "error: %s.\n", itron_strerror(error));
+			return NULL;
+			}
+		break;
+
+		}
+
+	return line;
+
+#else	/* of #ifdef USE_RESOLVER */
+
+	return GET_IPADDR(addr, skip_blanks(line));		/* IP Address by Literal */
+
+#endif	 /* of #ifdef USE_RESOLVER */
+
+	}
 
 #endif	/* of #ifdef USE_NETAPP_SUBR */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_var.h	(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
  *
@@ -36,14 +36,111 @@
 
 /*
- *  マクロ定義
- */
-
-#if defined(SUPPORT_INET4)
-#define T_IPEP		T_IPV4EP
+ *  TOPPERS/JSP カーネル、システム時刻 (SYSTIM) の周波数
+ */
+
+#define SYSTIM_HZ		ULONG_C(1000000)	/* [us]					*/
+
+/*
+ *  IPv6/IPv4 に関する定義
+ */
+
+/*
+ *  指定されたマクロに対するサンプルアプリケーション内部のマクロの定義
+ *
+ *    SUPPORT_INET6		 .   .  ON  ON  ON  ON
+ *    SUPPORT_INET4		ON  ON   .   .  ON  ON
+ *    API_CFG_IP4MAPPED_ADDR	 .  ON   .  ON   .  ON
+ *    ----------------------    ----------------------
+ *    NETAPP_IP6_CFG             .   .  ON  ON  ON  ON
+ *    NETAPP_IP4_CFG            ON  ON   .  ON  ON  ON
+ *    
+ */
+
+#if defined(SUPPORT_INET6)
+
+#define	NETAPP_IP6_CFG
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
+#define NETAPP_IP4_CFG
 #endif
 
-#if defined(SUPPORT_INET6)
-#define T_IPEP		T_IPV6EP
+/*
+ *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
+ */
+
+#define DBG_LINE_SIZE		63
+
+#if defined(SUPPORT_INET6)
+
+#define T_IN_ADDR		T_IN6_ADDR
+#define T_IPEP			T_IPV6EP
+#define IP_ADDRANY		IPV6_ADDRANY
+#define T_TCPN_CREP		T_TCP6_CREP
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#define T_IN_ADDR		T_IN4_ADDR
+#define T_IPEP			T_IPV4EP
+#define IP_ADDRANY		IPV4_ADDRANY
+#define T_TCPN_CREP		T_TCP_CREP
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  API IPプロトコルの指定
+ */
+
+#if defined(SUPPORT_INET6)
+#define DEFAULT_API_PROTO	API_PROTO_IPV6
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV4
 #endif
+
+/*
+ *  resolv_hoststr が返す flags の値の定義
+ *
+ *    注意:
+ *
+ *      dns.h で定義されている DNS_OPCODE、
+ *      resolver.h で定義されている DNS_LUP_FLAGS と重ならない事。
+ */
+
+#define HOSTSTR_OTHER		0x0000U
+#define HOSTSTR_IPV4		DNS_LUP_FLAGS_NAME_IPV4
+#define HOSTSTR_IPV6		DNS_LUP_FLAGS_NAME_IPV6
+#define HOSTSTR_HOSTNAME	DNS_LUP_FLAGS_NAME_HOST
+#define HOSTSTR_FQDN		DNS_LUP_FLAGS_NAME_FQDN
+
+/*
+ *  定数の定義
+ */
+
+#define DBG_LINE_SIZE		63
+
+#if defined(SUPPORT_INET6)
+
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP6_CEPS
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP4_CEPS
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  関数シミュレーションマクロ
+ */
+
+/* メッセージからの読出し */
+
+#define MSG2HOST16(p)		(msg2host16((void*)&(p)))
+#define MSG2HOST32(p)		(msg2host32((void*)&(p)))
+
+/* メッセージへの書込み */
+
+#define HOST2MSG16(p,v)		(host2msg16((void*)&(p),(v)))
+#define HOST2MSG32(p,v)		(host2msg32((void*)&(p),(v)))
 
 /*
@@ -80,4 +177,6 @@
 extern const char *in_strtfn (FN fncd);
 extern const char *itron_strerror (ER ercd);
+extern const char *dns_strtype (uint_t type);
+extern const char *dns_strclass (uint_t class);
 extern ER	net_syslog(uint_t prio, const char *format, ...) throw();
 extern ER	net_serial_ctl_por(ID portid, uint_t ioctl) throw();
@@ -85,10 +184,57 @@
 extern ER	discon_net_cons (void);
 extern void	wup_net_cons (void);
-extern ER	alloc_tcp_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
-extern ER	free_tcp_rep (ID repid, bool_t call_tcp_del_rep);
-extern ER	alloc_tcp_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
-extern ER	free_tcp_cep (ID cepid);
-extern ER	alloc_udp_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
-extern ER	free_udp_cep (ID cepid, bool_t call_udp_del_cep);
+extern bool_t	tcp6_is_cepid (ID cepid);
+extern ER	alloc_tcp6_rep (ID *repid, ID tskid, T_TCP6_CREP *crep);
+extern ER	alloc_tcp6_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
+extern ER	alloc_udp6_cep (ID *cepid, ID tskid, T_UDP6_CCEP *ccep);
+extern ER	free_tcp6_rep (ID repid, bool_t call_tcp_del_rep);
+extern ER	free_tcp6_cep (ID cepid);
+extern ER	free_udp6_cep (ID cepid, bool_t call_udp_del_cep);
+extern bool_t	tcp4_is_cepid (ID cepid);
+extern ER	alloc_tcp4_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
+extern ER	alloc_tcp4_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
+extern ER	alloc_udp4_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
+extern ER	free_tcp4_rep (ID repid, bool_t call_tcp_del_rep);
+extern ER	free_tcp4_cep (ID cepid);
+extern ER	free_udp4_cep (ID cepid, bool_t call_udp_del_cep);
+extern void	ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
+extern void	ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
+extern char	*get_ipv6addr (T_IN6_ADDR *addr, char *line);
+extern char	*get_ipv4addr (T_IN4_ADDR *addr, char *line);
+extern char	*resolv_options (uint_t *flags, char *line, char apip);
+extern char	*resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line);
+extern char	*lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip);
+extern uint_t	show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset);
+extern void	host2msg16 (void *msg, uint16_t host_data);
+extern void	host2msg32 (void *msg, uint32_t host_data);
+extern uint16_t	msg2host16 (void *msg);
+extern uint32_t	msg2host32 (void *msg);
+extern uint32_t	netapp_rand (void);
+extern void	netapp_srand (uint32_t seed);
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_CRE_REP(i,r)	tcp6_cre_rep(i,r)
+#define TCP_CRE_CEP(i,c)	tcp6_cre_cep(i,c)
+#define UDP_CRE_CEP(i,c)	udp6_cre_cep(i,c)
+#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
+#define TCP_CON_CEP(c,m,d,t)	tcp6_con_cep(c,m,d,t)
+
+#define UDP_SND_DAT(c,d,b,l,t)	udp6_snd_dat(c,d,b,l,t)
+#define UDP_RCV_DAT(c,d,b,l,t)	udp6_rcv_dat(c,d,b,l,t)
+
+#define TCP_IS_CEPID(i)		tcp6_is_cepid(i)
+#define ALLOC_TCP_REP(i,t,r)	alloc_tcp6_rep(i,t,r)
+#define ALLOC_TCP_CEP(i,t,c)	alloc_tcp6_cep(i,t,c)
+#define ALLOC_UDP_CEP(i,t,c)	alloc_udp6_cep(i,t,c)
+#define FREE_TCP_REP(i,r)	free_tcp6_rep(i,r)
+#define FREE_TCP_CEP(i)		free_tcp6_cep(i)
+#define FREE_UDP_CEP(i,c)	free_udp6_cep(i,c)
+
+#define IP2STR(s,a)		ipv62str(s,a)
+#define GET_IPADDR(a,l)		get_ipv6addr(a,l)
+#define PING(a,t,l)		ping6(a,t,l)
+
+#else	/* of #if defined(SUPPORT_INET6) */
 
 #if defined(SUPPORT_INET4)
@@ -103,33 +249,18 @@
 #define UDP_RCV_DAT(c,d,b,l,t)	udp_rcv_dat(c,d,b,l,t)
 
+#define TCP_IS_CEPID(i)		tcp4_is_cepid(i)
+#define ALLOC_TCP_REP(i,t,r)	alloc_tcp4_rep(i,t,r)
+#define ALLOC_TCP_CEP(i,t,c)	alloc_tcp4_cep(i,t,c)
+#define ALLOC_UDP_CEP(i,t,c)	alloc_udp4_cep(i,t,c)
+#define FREE_TCP_REP(i,r)	free_tcp4_rep(i,r)
+#define FREE_TCP_CEP(i)		free_tcp4_cep(i)
+#define FREE_UDP_CEP(i,c)	free_udp4_cep(i,c)
+
 #define IP2STR(s,a)		ip2str(s,a)
-
 #define GET_IPADDR(a,l)		get_ipv4addr(a,l)
 #define PING(a,t,l)		ping4(a,t,l)
 
-extern void ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
-extern char *get_ipv4addr (T_IN4_ADDR *addr, char *line);
-
 #endif	/* of #if defined(SUPPORT_INET4) */
 
-#if defined(SUPPORT_INET6)
-
-#define TCP_CRE_REP(i,r)	tcp6_cre_rep(i,r)
-#define TCP_CRE_CEP(i,c)	tcp6_cre_cep(i,c)
-#define UDP_CRE_CEP(i,c)	udp6_cre_cep(i,c)
-#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
-#define TCP_CON_CEP(c,m,d,t)	tcp6_con_cep(c,m,d,t)
-
-#define UDP_SND_DAT(c,d,b,l,t)	udp6_snd_dat(c,d,b,l,t)
-#define UDP_RCV_DAT(c,d,b,l,t)	udp6_rcv_dat(c,d,b,l,t)
-
-#define IP2STR(s,a)		ipv62str(s,a)
-
-#define GET_IPADDR(a,l)		get_ipv6addr(a,l)
-#define PING(a,t,l)		ping6(a,t,l)
-
-extern void ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
-extern char *get_ipv6addr (T_IN6_ADDR *addr, char *line);
-
 #endif	/* of #if defined(SUPPORT_INET6) */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netappn_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netappn_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netappn_subr.c	(revision 331)
@@ -0,0 +1,219 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ãµãã¼ãã«ã¼ãã³
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  alloc_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+ER
+ALLOC_TCP_REP (ID *repid, ID tskid, T_TCPN_CREP *crep)
+{
+	int_t	ix;
+
+	*repid = TCP_REP_NONE;
+	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
+	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
+		if (TSKID_TCP_REP[ix] == TSK_NONE) {
+			*repid = VRID_TCP_REP[ix];
+			TSKID_TCP_REP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
+
+	if (*repid == TCP_REP_NONE)
+		return E_NOEXS;
+	else
+		return TCP_CRE_REP(*repid, crep);
+	}
+
+/*
+ *  free_tcp_rep -- TCP åä»å£ãè§£æ¾ããã
+ */
+
+ER
+FREE_TCP_REP (ID repid, bool_t call_tcp_del_rep)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
+	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
+		if (repid == VRID_TCP_REP[ix]) {
+			TSKID_TCP_REP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
+
+	if (call_tcp_del_rep)
+		return tcp_del_rep(repid);
+	else
+		return E_OK;
+	}
+
+/*
+ *  tcpn_is_cepid -- TCP éä¿¡ç«¯ç¹ãæå®ããããããã¯ã¼ã¯å±¤ãªã true ãè¿ãã
+ */
+
+bool_t
+TCP_IS_CEPID (ID cepid)
+{
+	int_t	ix;
+
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_TCP_CEP[ix])
+			return true;
+		}
+	return false;
+	}
+
+/*
+ *  alloc_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+ER
+ALLOC_TCP_CEP (ID *cepid, ID tskid, T_TCP_CCEP *ccep)
+{
+	int_t	ix;
+
+	*cepid = TCP_CEP_NONE;
+	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (TSKID_TCP_CEP[ix] == TSK_NONE) {
+			*cepid = VRID_TCP_CEP[ix];
+			TSKID_TCP_CEP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
+
+	if (*cepid == TCP_CEP_NONE)
+		return E_NOEXS;
+	else
+		return tcp_cre_cep(*cepid, ccep);
+	}
+
+/*
+ *  free_tcp_cep -- TCP éä¿¡ç«¯ç¹ãè§£æ¾ããã
+ */
+
+ER
+FREE_TCP_CEP (ID cepid)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_TCP_CEP[ix]) {
+			TSKID_TCP_CEP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
+
+	return tcp_del_cep(cepid);
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+/*
+ *  alloc_udp_cep -- UDP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+ER
+ALLOC_UDP_CEP (ID *cepid, ID tskid, T_UDPN_CCEP *ccep)
+{
+	int_t	ix;
+
+	*cepid = UDP_CEP_NONE;
+	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
+	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
+		if (TSKID_UDP_CEP[ix] == TSK_NONE) {
+			*cepid = VRID_UDP_CEP[ix];
+			TSKID_UDP_CEP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
+
+	if (*cepid == UDP_CEP_NONE)
+		return E_NOEXS;
+	else
+		return UDP_CRE_CEP(*cepid, ccep);
+	}
+
+/*
+ *  free_udp_cep -- UDP éä¿¡ç«¯ç¹ãè§£æ¾ããã
+ */
+
+ER
+FREE_UDP_CEP (ID cepid, bool_t call_udp_del_cep)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
+	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_UDP_CEP[ix]) {
+			TSKID_UDP_CEP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
+
+	if (call_udp_del_cep)
+		return UDP_DEL_CEP(cepid);
+	else
+		return E_OK;
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping.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
  *
@@ -61,4 +61,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -74,11 +75,16 @@
 #ifdef USE_PING
 
+#if defined(SUPPORT_INET4)
+
 /*
  *  変数
  */
 
-static uint16_t	icmp_id = 0;
+#if 0
 static uint16_t	curr_icmp_id;
 static uint16_t	curr_icmp_len;
+#endif
+
+static uint16_t	icmp_id = 0;
 static SYSTIM	icmp_start_time;
 
@@ -90,5 +96,5 @@
 icmp_reply_timeout (void *arg)
 {
-	syslog(LOG_NOTICE, "[PING] request timeout.");
+	syslog(LOG_NOTICE, "[PING4] request timeout.");
 	}
 
@@ -100,10 +106,13 @@
 icmp_echo_reply (T_NET_BUF *input, uint_t ihoff)
 {
-	SYSTIM time;
+	SYSTIM		time;
+	T_IN4_ADDR	addr;
 
 	syscall(get_tim(&time));
+	addr = ntohl(GET_IP4_HDR(input)->src);
 	untimeout(icmp_reply_timeout, NULL);
-	syslog(LOG_NOTICE, "[PING] reply, %d [ms].",
-	                   (time - icmp_start_time) * 1000 / SYSTIM_HZ);
+	syslog(LOG_NOTICE, "[PING4] reply: %5ld [ms] from: %s",
+	                   (time - icmp_start_time) * 1000 / SYSTIM_HZ,
+	                   ip2str(NULL, &addr));
 	}
 
@@ -143,6 +152,8 @@
 
 	/* 応答チェック用の変数を設定する。*/
+#if 0
 	curr_icmp_id  = icmp_id ++;
 	curr_icmp_len = len;
+#endif
 
 	NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
@@ -157,3 +168,5 @@
 	}
 
+#endif	/* of #if defined(SUPPORT_INET4) */
+
 #endif	/* of #ifdef USE_PING */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/ping6.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
  *
@@ -61,4 +61,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -67,16 +68,15 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet6/nd6.h>
 
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#include <net/if6_var.h>
+#include <net/if_var.h>
 
 #ifdef USE_PING
+
+#if defined(SUPPORT_INET6)
 
 /*
@@ -84,7 +84,10 @@
  */
 
-static uint16_t	send_icmp6_id = 0;
+#if 0
 static uint16_t	curr_icmp6_id;
 static uint16_t	curr_icmp6_size;
+#endif
+
+static uint16_t	send_icmp6_id = 0;
 static uint16_t	reply_count;
 static SYSTIM	icmp6_start_time;
@@ -108,13 +111,11 @@
 icmp6_echo_reply (T_NET_BUF *input, uint_t ihoff)
 {
-	T_IP6_HDR	*ip6h;
-	SYSTIM		time;
+	SYSTIM	time;
 
 	syscall(get_tim(&time));
-	ip6h  = GET_IP6_HDR(input);
-
-	syslog(LOG_NOTICE, "[PING6] reply: %5d [ms] from: %s",
+	untimeout(icmp6_reply_timeout, NULL);
+	syslog(LOG_NOTICE, "[PING6] reply: %5ld [ms] from: %s",
 	                   (time - icmp6_start_time) * 1000 / SYSTIM_HZ,
-	                   ipv62str(NULL, &ip6h->src));
+	                   ipv62str(NULL, &GET_IP6_HDR(input)->src));
 	reply_count ++;
 	}
@@ -169,12 +170,16 @@
 
 	/* 応答チェック用の変数を設定する。*/
+	reply_count = 0;
+
+#if 0
 	curr_icmp6_id   = send_icmp6_id ++;
 	curr_icmp6_size = size;
+#endif
 
-	reply_count = 0;
-
+#if 0
 	syslog(LOG_NOTICE, "[PING6] send: TMO:%d, SIZE:%d, to: %s, from %s",
 	                   tmo, size,
 	                   ipv62str(NULL, addr), ipv62str(NULL, &ia->addr));
+#endif
 
 	/* 送信後、現在の時間を記憶し、タイムアウトを設定する。*/
@@ -188,3 +193,5 @@
 	}
 
+#endif	/* of #if defined(SUPPORT_INET6) */
+
 #endif	/* of #ifdef USE_PING */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c	(revision 331)
@@ -0,0 +1,1204 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãã¹ãåââIP ã¢ãã¬ã¹å¤æ
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include <syssvc/logtask.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/resolver.h>
+
+#if defined(USE_RESOLVER)
+
+/*
+ *  å±æå¤æ°
+ */
+
+static uint8_t	dns_domain_name[DNS_NAME_LENGTH + 1] = RSLV_CFG_DNS_DOMAIN_NAME_STR;
+
+#if defined(SUPPORT_INET6)
+static T_IN6_ADDR in6_addr_dns      = IPV6_ADDR_DNS_INIT;
+static T_IN6_ADDR in6_addr_dns_init = IPV6_ADDR_DNS_INIT;
+#endif
+
+#if defined(SUPPORT_INET4)
+static T_IN4_ADDR in4_addr_dns = IPV4_ADDR_DNS;
+#endif
+
+static uint16_t	dns_msg_id = 0;
+
+/*
+ *  get_dns_header -- DNS ã¡ãã»ã¼ã¸ãã DNS ããããåãåºãã
+ */
+
+static ER_UINT
+get_dns_header (uint8_t *msg, uint_t length, T_RSLV_DNS_MSG *rslv)
+{
+	T_DNS_HDR	*dns_hdr;
+
+	/* DNS ããããåãåºãã*/
+	if (length < sizeof(rslv->dns_hdr))
+		return EV_RSLV_ESIZE;
+	dns_hdr = (T_DNS_HDR*)msg;
+	rslv->dns_hdr.id	= MSG2HOST16(dns_hdr->id);
+	rslv->dns_hdr.code	= MSG2HOST16(dns_hdr->code);
+	rslv->dns_hdr.qdcount	= MSG2HOST16(dns_hdr->qdcount);
+	rslv->dns_hdr.ancount	= MSG2HOST16(dns_hdr->ancount);
+	rslv->dns_hdr.nscount	= MSG2HOST16(dns_hdr->nscount);
+	rslv->dns_hdr.arcount	= MSG2HOST16(dns_hdr->arcount);
+	return sizeof(rslv->dns_hdr);
+	}
+
+/*
+ *  dns_strtype -- DNS ã® type ã®æå­åãè¿ãã
+ */
+
+static const char *
+dns_flag_qtype (uint16_t flags)
+{
+	if      (flags & DNS_LUP_FLAGS_QTYPE_AAAA)
+		return "AAAA";
+	else if (flags & DNS_LUP_FLAGS_QTYPE_A)
+		return "   A";
+	else if (flags & DNS_LUP_FLAGS_QTYPE_PTR)
+		return " PTR";
+	else
+		return "unknown type";
+	}
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  udp6_dns -- UDP/IPv6 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER
+udp6_dns (uint16_t flags, T_IN6_ADDR *addr, uint8_t *msg, uint_t msg_size, uint_t length)
+{
+	T_IPV6EP	ep_dns;
+	ER_UINT		len = E_OK;
+	int		retry;
+
+	/* DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãã©ã¡ã¼ã¿ã¨ã©ã¼ */
+	if (IN6_IS_ADDR_UNSPECIFIED(addr) || (in6_is_addr_ipv4mapped(addr) && addr->s6_addr32[3] == IPV4_ADDRANY)) {
+		syslog(LOG_NOTICE, "[RSLV] undefined IPv6 DNS server address.");
+		return E_PAR;
+		}
+
+	memcpy(&ep_dns.ipaddr, addr, sizeof(*addr));
+	ep_dns.portno = RSLV_CFG_DNS_PORTNO;
+	for (retry = NUM_DNS_UDP_RETRY + 1; retry -- > 0; ) {
+		if ((len = udp6_snd_dat(UDP6_RESOLVER_CEPID, &ep_dns, msg, length, TMO_DNS_UDP_SND)) >= 0) {
+			if ((len = udp6_rcv_dat(UDP6_RESOLVER_CEPID, &ep_dns, msg, msg_size, TMO_DNS_UDP_RCV)) >= 0)
+				return len;
+			}
+		if (flags & DNS_LUP_FLAGS_MSG) {
+			if (len == E_TMOUT)
+				syslog(LOG_NOTICE, "[RSLV] TMOUT: %d, type: %s, server: %s.%d.",
+				       NUM_DNS_UDP_RETRY + 1 - retry,
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] error:  %s, type: %s,\n       server: %s.%d.",
+				       itron_strerror(len),
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+				return len;
+				}
+			}
+		}
+	return E_TMOUT;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  udp4_dns -- UDP/IPv4 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER
+udp4_dns (uint16_t flags, T_IN4_ADDR *addr, uint8_t *msg, uint_t msg_size, uint_t length)
+{
+	T_IPV4EP	ep_dns;
+	ER_UINT		len = E_OK;
+	int		retry;
+
+	/* DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãã©ã¡ã¼ã¿ã¨ã©ã¼ */
+	if (*addr == IPV4_ADDRANY) {
+		syslog(LOG_NOTICE, "[RSLV] undefined IPv4 DNS server address.");
+		return E_PAR;
+		}
+
+	memcpy(&ep_dns.ipaddr, addr, sizeof(*addr));
+	ep_dns.portno = RSLV_CFG_DNS_PORTNO;
+	for (retry = NUM_DNS_UDP_RETRY + 1; retry -- > 0; ) {
+		if ((len = udp_snd_dat(UDP4_RESOLVER_CEPID, &ep_dns, msg, length, TMO_DNS_UDP_SND)) >= 0) {
+			if ((len = udp_rcv_dat(UDP4_RESOLVER_CEPID, &ep_dns, msg, msg_size, TMO_DNS_UDP_RCV)) >= 0)
+				return len;
+			}
+		if (flags & DNS_LUP_FLAGS_MSG) {
+			if (len == E_TMOUT)
+				syslog(LOG_NOTICE, "[RSLV] TMOUT: %d, type: %s, server: %s.%d.",
+				       NUM_DNS_UDP_RETRY + 1 - retry,
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] error: %s, type: %s, server: %s.%d.",
+				       itron_strerror(len),
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+				return len;
+				}
+			}
+		}
+	return E_TMOUT;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  skip_label -- ã©ãã«ãèª­ã¿é£ã°ãã
+ */
+
+static char *
+skip_label (char *name)
+{
+	while (!(*name == '\0' || *name == '.'))
+		name ++;
+	return name;
+	}
+
+/*
+ *  add_name -- ã¡ãã»ã¼ã¸ã«ååãè¿½å ããã
+ */
+
+static ER_UINT
+add_name (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	uint_t		label_len;
+	uint8_t		*tail;
+
+	while (*name != '\0') {
+
+		/* ã¡ãã»ã¼ã¸ãµã¤ãºã«éãã¦ãããã¨ã©ã¼ */
+		if (offset + 1 > size)
+			return E_BOVR;
+
+		/* ã©ãã«ã®çµãããè¦ã¤ããã*/
+		tail = skip_label(name);
+
+		/* ã©ãã«é·ãè¨­å®ããã*/
+		label_len = tail - (uint8_t*)name;
+		if (label_len > DNS_LABEL_LENGTH) {	/* 63 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] label length(%d) too long > %d.",
+			                   label_len, DNS_LABEL_LENGTH);
+			return E_PAR;
+			}
+
+		*(msg + offset) = (uint8_t)label_len;
+		offset ++;
+
+		/* ã©ãã«åãè¨­å®ããã*/
+		if (offset + label_len > size) {	/* ã¡ãã»ã¼ã¸ãµã¤ãºãè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] message length(%d) too long > %d.",
+			                   offset + label_len, size);
+			return E_BOVR;
+			}
+
+		memcpy((void*)(msg + offset), (void*)name, label_len);
+		offset += label_len;
+
+		/* æ¬¡ã®ã©ãã«ã«ç§»åããã*/
+		if (*tail == '\0')
+			name = tail;
+		else
+			name = tail + 1;	/* '.' ãã¹ã­ããããã*/
+		}
+
+	return offset;
+	}
+
+/*
+ *  add_ipv6addr -- ã¡ãã»ã¼ã¸ã« IPv6 ã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+static ER_UINT
+add_ipv6addr (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	T_IN6_ADDR	addr;
+	ER_UINT		error;
+	uint_t		len;
+	int			col;
+	char		digit[2];
+
+	len = strlen(name);
+	if (len == 0)
+		return E_PAR;
+
+	digit[1] = '\0';
+	get_ipv6addr(&addr, name);
+	for (col = sizeof(T_IN6_ADDR) * 2; -- col >= 0; ) {
+
+		/* 16é²æ° 1æ¡ã®å¤ããååã¨ãã¦è¿½å ããã*/
+		digit[0] = (addr.s6_addr8[col / 2] >> ((1 - (col % 2)) << 2)) & 0x0f;
+		if (digit[0] >= 10)
+			digit[0] += 'a' - 10;
+		else
+			digit[0] += '0';
+		if ((error = add_name(msg, size, offset, digit)) < 0)
+			return error;
+		offset = error;
+		}
+
+	/* "ip6" ãè¿½å ããã*/
+	if ((error = add_name(msg, size, offset, "ip6")) < 0)
+		return error;
+
+	/* "arpa" ãè¿½å ããã*/
+	return add_name(msg, size, error, "arpa");
+	}
+
+/*
+ *  add_ipv4addr -- ã¡ãã»ã¼ã¸ã« IPv4 ã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+static ER_UINT
+add_ipv4addr (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	T_IN4_ADDR	addr;
+	ER_UINT		error;
+	uint_t		len, octet;
+	int			col;
+	char		*op, ostr[4];
+
+	len = strlen(name);
+	if (len == 0)
+		return E_PAR;
+
+	ostr[3] = '\0';
+	get_ipv4addr(&addr, name);
+	for (col = 0; col < sizeof(T_IN4_ADDR); col ++) {
+
+		/* 1ãªã¯ãããã®å¤ããæ´æ°å¤ãããªãã©ã«ã«å¤æããã*/
+		octet = (addr >> (col << 3)) & 0xff;
+		op = &ostr[3];
+		while (octet > 0) {
+			*(-- op) = octet % 10 + '0';
+			octet   /= 10;
+			}
+
+		/* 1ãªã¯ãããã®å¤ããååã¨ãã¦è¿½å ããã*/
+		if ((error = add_name(msg, size, offset, op)) < 0)
+			return error;
+		offset = error;
+		}
+
+	/* "in-addr" ãè¿½å ããã*/
+	if ((error = add_name(msg, size, offset, "in-addr")) < 0)
+		return error;
+
+	/* "arpa" ãè¿½å ããã*/
+	return add_name(msg, size, error, "arpa");
+	}
+
+/*
+ *  setup_dns_msg -- DNS ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_dns_msg (uint16_t flags, char *name, uint8_t *msg, uint_t msg_size)
+{
+	T_DNS_HDR	dns_hdr;
+	ER_UINT		offset;
+
+	memset((void*)&dns_hdr, 0, sizeof(dns_hdr));
+
+	dns_msg_id++;
+	HOST2MSG16(dns_hdr.id,      dns_msg_id);
+	HOST2MSG16(dns_hdr.code,    (flags & DNS_OPCODE_MASK) | DNS_RECURSION_DESIRED);
+	HOST2MSG16(dns_hdr.qdcount, 1);
+
+	memcpy((void*)msg, (void*)&dns_hdr, sizeof(dns_hdr));
+	offset = sizeof(dns_hdr);
+
+	switch (flags & DNS_LUP_FLAGS_NAME_MASK) {
+
+	case DNS_LUP_FLAGS_NAME_HOST:
+	case DNS_LUP_FLAGS_NAME_FQDN:
+
+		/* ãã¹ãåãã¾ãã¯ FQDN ã®æã®å¦çã*/
+		/* ãã¹ãåãè¿½å ããã*/
+		if ((offset = add_name(msg, msg_size, offset, name)) < 0)
+			return offset;
+
+		if (offset - sizeof(dns_hdr) > DNS_NAME_LENGTH) {		/* ååã 255 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] name length(%d) too long > %d.",
+			                   offset - sizeof(dns_hdr), DNS_NAME_LENGTH);
+			return E_PAR;
+			}
+
+		/* ãã¹ãåã ãã®æã¯ããã¡ã¤ã³åãè¿½å ããã*/
+		if ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_HOST) {
+
+			/* ãã¡ã¤ã³åãè¿½å ããã*/
+			if ((offset = add_name(msg, msg_size, offset, dns_domain_name)) < 0)
+				return offset;
+
+			if (offset - sizeof(dns_hdr) > DNS_NAME_LENGTH) {		/* ååã 255 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+				syslog(LOG_NOTICE, "[RSLV] name length(%d) too long > %d.",
+				                   offset - sizeof(dns_hdr), DNS_NAME_LENGTH);
+				return E_PAR;
+				}
+			}
+		break;
+
+	case DNS_LUP_FLAGS_NAME_IPV4:
+		if ((offset = add_ipv4addr(msg, msg_size, offset, name)) < 0)
+			return offset;
+		break;
+
+	case DNS_LUP_FLAGS_NAME_IPV6:
+		if ((offset = add_ipv6addr(msg, msg_size, offset, name)) < 0)
+			return offset;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[RSLV] unknown name type: %04x.", flags & DNS_LUP_FLAGS_NAME_MASK);
+		return E_PAR;
+		break;
+
+		}
+
+	/* ååã®çµäºã³ã¼ããTYPEãCLASS ãè¿½å ãã¦ãã¡ãã»ã¼ã¸é·ãè¶
+ããªããã¨ãç¢ºèªããã*/
+	if (offset + sizeof(uint16_t) * 2 + 1 > msg_size) {
+		syslog(LOG_NOTICE, "[RSLV] message length(%d) too long > %d.",
+		                   offset + sizeof(uint16_t) * 2 + 1, msg_size);
+		return E_BOVR;
+		}
+
+	/* ååã®çµäºã³ã¼ããè¨­å®ããã*/
+	*(msg + offset) = '\0';
+	offset ++;
+
+	/* DNS ã® TYPE ãè¨­å®ããã*/
+	if (flags & DNS_LUP_FLAGS_QTYPE_PTR)
+		host2msg16(msg + offset, DNS_TYPE_PTR);
+	else if (flags & DNS_LUP_FLAGS_QTYPE_AAAA)
+		host2msg16(msg + offset, DNS_TYPE_AAAA);
+	else if (flags & DNS_LUP_FLAGS_QTYPE_A)
+		host2msg16(msg + offset, DNS_TYPE_A);
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+		return E_PAR;
+		}
+	offset += sizeof(uint16_t);
+
+	/* DNS ã® CLASS ãè¨­å®ããã*/
+	host2msg16(msg + offset, DNS_CLASS_IN);
+
+	return offset + sizeof(uint16_t);
+	}
+
+/*
+ *  skip_dns_name -- DNS ã¡ãã»ã¼ã¸ã®ååãèª­ã¿é£ã°ãã
+ *
+ *    æ³¨æ: å§ç¸®å½¢å¼ãèæ
+®ãããä¸ä½ 2ãããã 11ãªãå§ç¸®å½¢å¼ã
+ */
+
+static ER_UINT
+skip_dns_name (uint8_t *name, uint_t offset, uint_t length)
+{
+	while (*(name + offset)) {
+		if ((*(name + offset) & 0xc0) == 0xc0) {
+			if (offset + 2 > length)
+				return EV_RSLV_ESIZE;
+			else
+				return offset + 2;
+			}
+		else if (offset + *name + 1 > length)
+			return EV_RSLV_ESIZE;
+		else
+			offset += *name + 1;
+		}
+	return offset + 1;
+	}
+
+/*
+ *  skip_dns_qd -- DNS Question section ãèª­ã¿é£ã°ãã
+ */
+
+static ER_UINT
+skip_dns_qd (uint8_t *msg, uint_t offset, uint_t length, uint_t count)
+{
+	ER_UINT	next;
+
+	while (count != 0) {
+		/* name ãèª­ã¿é£ã°ãã*/
+		if ((next = skip_dns_name(msg, offset, length)) < 0)
+			return next;
+		offset = next;
+
+		/* typeãclass ãèª­ã¿é£ã°ãã*/
+		if ((offset + sizeof(uint16_t) + sizeof(uint16_t)) > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + sizeof(uint16_t);
+
+		count --;
+		}
+
+	return offset;
+	}
+
+/*
+ *  skip_dns_rr -- DNS RR ãèª­ã¿é£ã°ãã
+ */
+
+static ER_UINT
+skip_dns_rr (uint8_t *msg, uint_t offset, uint_t length, uint_t count)
+{
+	ER_UINT		next;
+	uint16_t	len = 0;
+
+	while (count != 0) {
+		/* name ãèª­ã¿é£ã°ãã*/
+		if ((next = skip_dns_name(msg, offset, length)) < 0)
+			return next;
+		offset = next;
+
+		/* typeãclassãTTL ãèª­ã¿é£ã°ãã*/
+		if (offset + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t);
+
+		/* RD length ã¨ RDATA ãèª­ã¿é£ã°ãã*/
+		if (offset + sizeof(uint16_t) > length)
+			return EV_RSLV_ESIZE;
+		len = msg2host16(msg + offset);
+
+		if (offset + sizeof(uint16_t) + len > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + len;
+
+		count --;
+		}
+
+	return offset;
+	}
+
+/*
+ *  dns_analyze_qd -- DNS ã¡ãã»ã¼ã¸ã® question section ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_qd (T_RSLV_QD *qd, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_QD	*dns_qd;
+
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_QD_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_qd = (T_DNS_QD*)(msg + offset);
+	qd->type  = MSG2HOST16(dns_qd->type);
+	qd->class = MSG2HOST16(dns_qd->class);
+
+	return offset + T_DNS_QD_SIZE;
+	}
+
+/*
+ *  dns_analyze_soa -- DNS ã¡ãã»ã¼ã¸ã® SOA RDATA ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_soa (T_RSLV_SOA *soa, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_SOA	*dns_soa;
+
+	/* MNAME ãã¹ã­ããããã*/
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* RNAME ãã¹ã­ããããã*/
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_SOA_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_soa = (T_DNS_SOA*)(msg + offset);
+	soa->serial  = MSG2HOST32(dns_soa->serial);
+	soa->refresh = MSG2HOST32(dns_soa->refresh);
+	soa->retry   = MSG2HOST32(dns_soa->retry);
+	soa->expire  = MSG2HOST32(dns_soa->expire);
+	soa->minimum = MSG2HOST32(dns_soa->minimum);
+
+	return offset + T_DNS_SOA_SIZE;
+	}
+
+/*
+ *  dns_analyze_rr -- DNS ã¡ãã»ã¼ã¸ã® AN/NS/AR section ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_rr (T_RSLV_RR *rr, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_RR	*dns_rr;
+
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_RR_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_rr = (T_DNS_RR*)(msg + offset);
+	rr->type	= MSG2HOST16(dns_rr->type);
+	rr->class	= MSG2HOST16(dns_rr->class);
+	rr->ttl		= MSG2HOST32(dns_rr->ttl);
+	rr->rdlength	= MSG2HOST16(dns_rr->rdlength);
+	rr->rdata_offset= offset + sizeof(rr->type) + sizeof(rr->class)
+	                         + sizeof(rr->ttl)  + sizeof(rr->rdlength);
+
+	return offset + T_DNS_RR_SIZE + rr->rdlength;
+	}
+
+/*
+ *  analyze_dns_msg -- DNS ã¡ãã»ã¼ã¸ãè§£æããã
+ */
+
+static ER_UINT
+analyze_dns_msg (uint8_t *msg, uint_t length, T_RSLV_DNS_MSG *rslv)
+{
+	ER_UINT	offset;
+
+	/* DNS ããããåãåºãã*/
+	if ((offset = get_dns_header(msg, length, rslv)) < 0)
+		return offset;
+
+	/* question section ãèª­ã¿é£ã°ãã*/
+	rslv->qd_offset = offset;
+	if ((offset = skip_dns_qd(msg, offset, length, rslv->dns_hdr.qdcount)) < 0)
+		return offset;
+
+	/* answer section ãèª­ã¿é£ã°ãã*/
+	rslv->an_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.ancount)) < 0)
+		return offset;
+
+	/* authority records section ãèª­ã¿é£ã°ãã*/
+	rslv->ns_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.nscount)) < 0)
+		return offset;
+
+	/* additional records  section ãèª­ã¿é£ã°ãã*/
+	rslv->ar_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.arcount)) < 0)
+		return offset;
+
+	return E_OK;
+	}
+
+/*
+ *  dns_lookup_host_sub -- DNS ã«ãããã¹ãã®æ
+å ±ãåå¾ããï¼è£å©é¢æ°ï¼ã
+ */
+
+static ER_UINT
+dns_lookup_host_sub (uint16_t flags, char *hostname, uint8_t *msg, 
+                     uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	uint16_t	proto;
+#endif
+	ER_UINT		length;
+	ER		error;
+
+	if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+		return length;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV6) {
+		proto = DNS_LUP_FLAGS_PROTO_IPV6;
+		if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else if (flags & DNS_LUP_FLAGS_PROTO_IPV4) {
+		proto = DNS_LUP_FLAGS_PROTO_IPV4;
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV6) {
+		if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV4) {
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	if ((error = analyze_dns_msg(msg, length, rslv)) != E_OK)
+		return error;
+	else {
+		if ((rslv->dns_hdr.ancount > 0) && (flags & DNS_LUP_FLAGS_MSG)) {
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+			if (proto & DNS_LUP_FLAGS_PROTO_IPV6) {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &in6_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			else {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &in4_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+			       dns_flag_qtype(flags),
+			       ipv62str(NULL, &in6_addr_dns),
+			       RSLV_CFG_DNS_PORTNO);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+			syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+			       dns_flag_qtype(flags),
+			       ip2str(NULL, &in4_addr_dns),
+			       RSLV_CFG_DNS_PORTNO);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+			}
+		return length;
+		}
+	}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+/*
+ *  udp64_dns -- DNS/IPv6ãDNS/IPv4 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER_UINT
+udp64_dns (uint16_t flags, char *hostname, uint8_t *msg, 
+           uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+	ER_UINT		length;
+	ER		error;
+	uint16_t	proto;
+
+	/* DNS ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+		return length;
+
+	/* UDP/IPv6 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+	proto = DNS_LUP_FLAGS_PROTO_IPV6;
+	if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0) {
+		/*  UDP/IPv6 ã® DNS ãµã¼ãã¸ã®ç
+§ä¼ãã¨ã©ã¼ã«ãªã£ãæã¯ãUDP/IPv4 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+		if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+			return length;
+
+		/* UDP/IPv4 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+		proto = DNS_LUP_FLAGS_PROTO_IPV4;
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+
+	/* DNS ã¡ãã»ã¼ã¸ãè§£æããã*/
+	if ((error = analyze_dns_msg(msg, length, rslv)) != E_OK)
+		return error;
+	else {
+		if ((rslv->dns_hdr.ancount > 0) && (flags & DNS_LUP_FLAGS_MSG)) {
+			if (proto & DNS_LUP_FLAGS_PROTO_IPV6) {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &in6_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			else {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &in4_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			}
+		return length;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  dns_lookup_host -- DNS ã«ãããã¹ãã®æ
+å ±ãåå¾ããã
+ */
+
+ER_UINT
+dns_lookup_host (uint16_t flags, char *hostname, uint8_t *msg, 
+              uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+	ER	error;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if ((flags & DNS_LUP_FLAGS_PROTO_MASK) == (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) {
+
+		/*
+		 *  IPv6/IPv4 ã®ä¸¡æ¹ãæå®ãããæã®å¦ç
+		 *  ã¾ã type == AAAA ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+		 */
+		if (flags & DNS_LUP_FLAGS_QTYPE_PTR) {
+			if ((error = udp64_dns(flags, hostname, msg, msg_size, rslv)) < 0)
+				return error;
+			}
+		else if (flags & DNS_LUP_FLAGS_QTYPE_AAAA) {
+			if ((error = udp64_dns(flags & ~DNS_LUP_FLAGS_QTYPE_A, hostname, msg, msg_size, rslv)) < 0)
+				return error;
+			}
+		else {
+			HOST2MSG16(rslv->dns_hdr.ancount, 0);
+			error = E_OK;
+			}
+
+		if (rslv->dns_hdr.ancount == 0) {
+
+			/*
+			 *  type == AAAA ã§ã¢ãã¬ã¹è§£æ±ºãã§ããªãã£ãæã®å¦ç
+			 *  type == A ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+			 */
+			if (flags & DNS_LUP_FLAGS_QTYPE_A)
+				return udp64_dns(flags & ~DNS_LUP_FLAGS_QTYPE_AAAA, hostname, msg, msg_size, rslv);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+				return E_PAR;
+				}
+			}
+		else
+			return error;
+		}
+
+	if ((flags & DNS_LUP_FLAGS_QTYPE_MASK) == (DNS_LUP_FLAGS_QTYPE_AAAA | DNS_LUP_FLAGS_QTYPE_A)) {
+
+		/*
+		 *  type == AAAA ã¨ A ã®ä¸¡æ¹ãæå®ãããæã®å¦ç
+		 *  ã¾ã type == AAAA ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+		 */
+		if ((error = dns_lookup_host_sub(flags & ~DNS_LUP_FLAGS_QTYPE_A, hostname, msg, msg_size, rslv)) < 0)
+			return error;
+
+		if (rslv->dns_hdr.ancount == 0) {
+
+			/*
+			 *  type == AAAA ã§ã¢ãã¬ã¹è§£æ±ºãã§ããªãã£ãæã®å¦ç
+			 *  type == A ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+			 */
+			return dns_lookup_host_sub(flags & ~DNS_LUP_FLAGS_QTYPE_AAAA, hostname, msg, msg_size, rslv);
+			}
+#if 0
+		else {
+			syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+			return E_PAR;
+			}
+#endif
+		}
+
+	else {
+		/* IPv6/IPv4 ã®ã©ã¡ããä¸æ¹ãæå®ãããæã®å¦ç */
+		error = dns_lookup_host_sub(flags, hostname, msg, msg_size, rslv);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	error = dns_lookup_host_sub(flags, hostname, msg, msg_size, rslv);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return error;
+	}
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  dns_in6_set_dname -- DNS ã® ãã¡ã¤ã³åãè¨­å®ããï¼DHCPv6ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+const uint8_t *
+dns_in6_set_dname (const uint8_t *new, uint_t len)
+{
+	uint8_t	*dst;
+	int	label_len, name_len = DNS_NAME_LENGTH;
+
+	if (new == NULL)
+		strcpy(dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
+	else {
+		dst = dns_domain_name;
+		while ((*new != 0) && (name_len > 0) && (len > 0)) {
+			label_len = *new ++;
+			len --;
+			while ((name_len > 0) && (len > 0) && (label_len > 0)) {
+				*dst ++ = *new ++;
+				name_len  --;
+				len       --;
+				label_len --;
+				}
+			if ((*new != 0) && (name_len > 0)) {
+				*dst ++ = '.';
+				name_len --;
+				}
+			}
+		*dst = '\0';
+		}
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in6_get_dname -- DNS ã® ãã¡ã¤ã³åãå¾ãã
+ */
+
+const uint8_t *
+dns_in6_get_dname (void)
+{
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in6_set_addr -- DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãè¨­å®ããï¼DHCPv6ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+T_IN6_ADDR *
+dns_in6_set_addr (T_IN6_ADDR *new)
+{
+	if (new == NULL)
+		in6_addr_dns = in6_addr_dns_init;
+	else
+		in6_addr_dns = *new;
+	return &in6_addr_dns;
+	}
+
+/*
+ *  dns_in6_get_addr -- DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãå¾ãã
+ */
+
+T_IN6_ADDR *
+dns_in6_get_addr (T_IN6_ADDR *dst)
+{
+	if (dst == NULL)
+		return NULL;
+	else {
+		*dst = in6_addr_dns;
+		return dst;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  dns_in4_set_dname -- DNS ã® ãã¡ã¤ã³åãè¨­å®ããï¼DHCPv4ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+const uint8_t *
+dns_in4_set_dname (const uint8_t *new, uint_t len)
+{
+	uint8_t	*dst;
+	int	name_len = DNS_NAME_LENGTH;
+
+	if (new == NULL)
+		strcpy(dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
+	else {
+		dst = dns_domain_name;
+		while ((name_len -- > 0) && (len -- > 0) && *new)
+			*dst ++ = *new ++;
+		*dst = '\0';
+		}
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in4_get_dname -- DNS ã® ãã¡ã¤ã³åãå¾ãã
+ */
+
+const uint8_t *
+dns_in4_get_dname (void)
+{
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in4_set_addr -- DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãè¨­å®ããï¼DHCPv4ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+T_IN4_ADDR *
+dns_in4_set_addr (T_IN4_ADDR *new)
+{
+	if (new == NULL)
+		in4_addr_dns = IPV4_ADDR_DNS;
+	else
+		in4_addr_dns = *new;
+	return &in4_addr_dns;
+	}
+
+/*
+ *  dns_in4_get_addr -- DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãå¾ãã
+ */
+
+T_IN4_ADDR *
+dns_in4_get_addr (T_IN4_ADDR *dst)
+{
+	if (dst == NULL)
+		return NULL;
+	else {
+		*dst = in4_addr_dns;
+		return dst;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  dns_host_addr -- ãã¹ãåã IP ã¢ãã¬ã¹ã«å¤æããã
+ */
+
+ER
+dns_host_addr (uint16_t flags, char *hostname, T_IN_ADDR *addr)
+{
+	T_RSLV_DNS_MSG	rslv;
+	T_RSLV_RR	rr;
+	ER_UINT		length, offset;
+	ER		error = E_OK;
+	int		scount;
+	uint8_t 	*msg;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	T_IN4_ADDR	addr4;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK)
+		return error;
+
+	if ((length = dns_lookup_host(flags, hostname, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
+		error = length;
+		goto err_ret;
+		}
+
+	offset = rslv.an_offset;
+	for (scount = 1; scount <= rslv.dns_hdr.ancount; scount ++) {
+		if ((offset = dns_analyze_rr(&rr, offset, msg, length)) < 0) {
+			error = offset;
+			goto err_ret;
+			}
+
+#if defined(SUPPORT_INET6)
+
+		if (rr.type == DNS_TYPE_AAAA && rr.class == DNS_CLASS_IN &&  rr.rdlength == sizeof(*addr)) {
+			memcpy((void*)addr, (void*)(msg + rr.rdata_offset), sizeof(*addr));
+			break;
+			}
+
+#if defined(SUPPORT_INET4)
+
+		if (rr.type == DNS_TYPE_A && rr.class == DNS_CLASS_IN && rr.rdlength == sizeof(addr4)) {
+			addr4 = msg2host32(msg + rr.rdata_offset);
+			in6_make_ipv4mapped(addr, addr4);
+			break;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+		if (rr.type == DNS_TYPE_A && rr.class == DNS_CLASS_IN && rr.rdlength == sizeof(*addr)) {
+			*addr = msg2host32((msg + rr.rdata_offset));
+			break;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+		}
+	if (scount > rslv.dns_hdr.ancount)
+		error = EV_RSLV_UNEXPCT;
+
+err_ret:
+	rel_mpf(MPF_RSLV_SRBUF, (void*)msg);
+	return error;
+	}
+
+#endif	/* of #if defined(USE_RESOLVER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h	(revision 331)
@@ -0,0 +1,332 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãã¹ãåââIP ã¢ãã¬ã¹å¤æ
+ */
+
+#ifndef RESOLVER_H
+#define RESOLVER_H
+
+#include <netapp/dns.h>
+
+/*
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã®æå®
+ */
+
+/* ãã¼ãçªå· */
+
+#define RSLV_CFG_DNS_PORTNO	53
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå¤
+ */
+
+#define TMO_DNS_UDP_SND		ULONG_C(1*1000)	/* [ms]ãDNS ãµã¼ãã¸ã®   UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DNS_UDP_RCV		ULONG_C(5*1000)	/* [ms]ãDNS ãµã¼ãããã® UDP åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define NUM_DNS_UDP_RETRY	1		/* ãªãã©ã¤åæ°					*/
+
+/*
+ *  ãã¡ã¤ã³å
+ */
+
+
+#if !defined(RSLV_CFG_DNS_DOMAIN_NAME_STR)
+#define RSLV_CFG_DNS_DOMAIN_NAME_STR	""
+#endif
+
+/*
+ *  DNS ãµã¼ãã¼ã® IPã¢ãã¬ã¹
+ */
+
+#if !defined(IPV6_ADDR_DNS_INIT)
+#define IPV6_ADDR_DNS_INIT	IPV6_ADDR_UNSPECIFIED_INIT
+#endif
+
+#if !defined(IPV4_ADDR_DNS)
+#define	IPV4_ADDR_DNS		IPV4_ADDRANY
+#endif
+
+/*
+ *  éåä¿¡ãããã¡æ°
+ */
+
+#define NUM_MPF_RSLV_SRBUF	1
+
+/*
+ *  ãã­ã°ã©ã ã§ä½¿ç¨ããæ
+å ±ã®å®ç¾©
+ */
+
+/*
+ *  ãã­ã°ã©ã ã§ä½¿ç¨ãã DNS ããã
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                      ID                       |
+ *  +--+-----------+--+--+--+--+--------+-----------+
+ *  |QR|   Opcode  |AA|TC|RD|RA|    Z   |   RCODE   |
+ *  +--+--------+--+--+--+--+--+--------+-----------+
+ *  |                    QDCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ANCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    NSCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ARCOUNT                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct rslv_dns_hdr {
+	uint16_t	id;		/* ID */
+	uint16_t	code;	/* QR:		1
+				   Opcode:	4
+				   AA:		1
+				   TC:		1
+				   RD:		1
+				   RA:		1
+				   Z:		3
+				   RCODE:	4
+				   */
+	uint16_t	qdcount;	/* question   section */
+	uint16_t	ancount;	/* answer     section */
+	uint16_t	nscount;	/* authority  section */
+	uint16_t	arcount;	/* additional section */
+	} __attribute__((packed))T_RSLV_DNS_HDR;
+
+/*
+ *  DNS message data
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_dns_msg {
+	T_RSLV_DNS_HDR	dns_hdr;	/* DNS heder                            */
+	uint_t		qd_offset;	/* offset of question           section */
+	uint_t		an_offset;	/* offset of answer             section */
+	uint_t		ns_offset;	/* offset of authority  records section */
+	uint_t		ar_offset;	/* offset of additional records section */
+	} __attribute__((packed))T_RSLV_DNS_MSG;
+
+/*
+ *  RR (Resouce Record) å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                      NAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                      TYPE                     |
+ *  +-----------------------------------------------+
+ *  |                      CLASS                    |
+ *  +-----------------------------------------------+
+ *  |                       TTL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    RDLENGTH                   |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RDATA                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ *          ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_rr {
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	uint32_t	ttl;		/* TTL			*/
+	uint16_t	rdlength;	/* RDATA length		*/
+	uint_t		rdata_offset;	/* offset of RDATA	*/
+	} __attribute__((packed))T_RSLV_RR;
+
+/*
+ *  Question section å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     QNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                     QTYPE                     |
+ *  +-----------------------------------------------+
+ *  |                     QCLASS                    |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_qd {
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	} __attribute__((packed))T_RSLV_QD;
+
+/*
+ *  SOA RDATA å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     MNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                    SERIAL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    REFRESH                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                     RETRY                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    EXPIRE                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    MINIMUM                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ *          ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_soa {
+	uint32_t	serial;		/* SERIAL		*/
+	uint32_t	refresh;	/* REFRESH		*/
+	uint32_t	retry;		/* RETRY		*/
+	uint32_t	expire;		/* EXPIRE		*/
+	uint32_t	minimum;	/* MINIMUM		*/
+	} __attribute__((packed))T_RSLV_SOA;
+
+/*
+ *  dns_lookup_host ã® flags ã®å®ç¾©
+ *
+ *    æ³¨æ:
+ *      dns.h ã§å®ç¾©ããã¦ãã DNS_OPCODE ã¨éãªããªããã¨ã
+ *      #define DNS_OPCODE_MASK		0x7800U
+ */
+
+#define DNS_LUP_FLAGS_NAME_IPV4		0x0004U
+#define DNS_LUP_FLAGS_NAME_IPV6		0x0006U
+#define DNS_LUP_FLAGS_NAME_HOST		0x0010U
+#define DNS_LUP_FLAGS_NAME_FQDN		0x0011U
+#define DNS_LUP_FLAGS_NAME_MASK		0x001fU
+
+#define DNS_LUP_OPCODE_FORWARD		DNS_OPCODE_FORWARD
+#define DNS_LUP_OPCODE_REVERSE		DNS_OPCODE_REVERSE
+#define DNS_LUP_OPCODE_STATUS		DNS_OPCODE_STATUS
+#define DNS_LUP_OPCODE_MASK		DNS_OPCODE_MASK
+
+#define DNS_LUP_FLAGS_PROTO_IPV4	0x0040U
+#define DNS_LUP_FLAGS_PROTO_IPV6	0x0080U
+#define DNS_LUP_FLAGS_PROTO_MASK	0x00c0U
+
+#define DNS_LUP_FLAGS_QTYPE_A		0x0100U
+#define DNS_LUP_FLAGS_QTYPE_AAAA	0x0200U
+#define DNS_LUP_FLAGS_QTYPE_PTR		0x0400U
+#define DNS_LUP_FLAGS_QTYPE_MASK	0x0700U
+
+#define DNS_LUP_FLAGS_MSG		0x0020U
+
+/*
+ *  ãããã¯ã¼ã¯ã¨ã©ã¼ã³ã¼ã
+ */
+
+#define EV_RSLV_ESIZE			(-100)		/* DNSã¡ãã»ã¼ã¸ã®ååé·ç°å¸¸	*/
+#define EV_RSLV_UNEXPCT			(-101)		/* äºæããªãDNSã¡ãã»ã¼ã¸	*/
+
+/*
+ *  é¢æ°
+ */
+
+extern ER_UINT	dns_lookup_host (uint16_t flags, char *hostname, uint8_t *msg, uint_t msg_len, T_RSLV_DNS_MSG *rslv);
+extern ER	dns_host_addr (uint16_t flags, char *hostname, T_IN_ADDR *addr);
+extern ER_UINT	dns_analyze_qd (T_RSLV_QD *qd, uint_t offset, uint8_t *msg, uint_t length);
+extern ER_UINT	dns_analyze_rr (T_RSLV_RR *rr, uint_t offset, uint8_t *msg, uint_t length);
+extern ER_UINT	dns_analyze_soa (T_RSLV_SOA *soa, uint_t offset, uint8_t *msg, uint_t length);
+
+/*
+ *  æ³¨æ: dns_in6_set_dnameãdns_in4_set_dnameã
+ *        dns_in6_set_addrã dns_in4_set_addr ã§ã
+ *        new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+extern const uint8_t *dns_in6_set_dname (const uint8_t *new, uint_t len);
+extern const uint8_t *dns_in6_get_dname (void);
+extern const uint8_t *dns_in4_set_dname (const uint8_t *new, uint_t len);
+extern const uint8_t *dns_in4_get_dname (void);
+extern T_IN6_ADDR *dns_in6_set_addr (T_IN6_ADDR *new);
+extern T_IN6_ADDR *dns_in6_get_addr (T_IN6_ADDR *dst);
+extern T_IN4_ADDR *dns_in4_set_addr (T_IN4_ADDR *new);
+extern T_IN4_ADDR *dns_in4_get_addr (T_IN4_ADDR *dst);
+
+#endif	/* of #ifndef RESOLVER_H */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_asp.cfg	(revision 331)
@@ -0,0 +1,66 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ Resolver ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_RSLV_SRBUF, {
+	TA_TFIFO,
+	NUM_MPF_RSLV_SRBUF,
+	DNS_UDP_MSG_LENGTH,
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_jsp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_jsp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver_jsp.cfg	(revision 331)
@@ -0,0 +1,65 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ Resolver ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_RSLV_SRBUF, {
+	TA_TFIFO,
+	NUM_MPF_RSLV_SRBUF,
+	DNS_UDP_MSG_LENGTH,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.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,24 +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_var.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_cli.h>
 
 #ifdef USE_TCP_DISCARD_CLI
@@ -88,4 +74,33 @@
 
 /*#define SHOW_RCV_RANGE*/
+
+/* 送信間隔 */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/* 自動実行 */
+
+#if defined(TCP_DISCARD_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#if defined(SUPPORT_INET6)
+#define TCP_DISCARD_CLI_AUTO_RUN_STR	"fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
+#else
+#define TCP_DISCARD_CLI_AUTO_RUN_STR	"172.25.129.142 - 0"
+#endif
+#endif
+#endif
 
 /*
@@ -143,5 +158,5 @@
 	case TFN_TCP_CLS_CEP:
 		if (nblk_error < 0)
-			syslog(LOG_NOTICE, "[TDC:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
+			syslog(LOG_NOTICE, "[TDCn:%02u CBN] close error: %s", cepid, itron_strerror(nblk_error));
 		syscall(sig_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
 		break;
@@ -162,5 +177,5 @@
  */
 
-static void
+static ER
 send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
 {
@@ -183,6 +198,6 @@
 
 	if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(error));
-		return;
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
+		return error;
 		}
 
@@ -191,8 +206,8 @@
 
 	if (nblk_error != E_OK)
-		syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(nblk_error));
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(nblk_error));
 	else {
 		get_tim(&time);
-		syslog(LOG_NOTICE, "[TDC:%02d SND] connecting: %6ld, to:   %s.%d",
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
 		                   cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);
 
@@ -202,5 +217,5 @@
 			while (soff < SND_BUF_SIZE) {
 				if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
-					syslog(LOG_NOTICE, "[TDC:%02d SND] send error: %s",
+					syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s",
 					                   cepid, itron_strerror(slen));
 					goto cls_ret;
@@ -211,9 +226,9 @@
 
 #ifdef SHOW_RCV_RANGE
-				syslog(LOG_NOTICE, "[TDC:%02d SND] snd: %2d, len: %4d, off: %4d",
+				syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
 				                   cepid, scount, (uint16_t)slen, soff);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
-				syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
+				syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
 				}
 			}
@@ -221,16 +236,18 @@
 	cls_ret:
 		get_tim(&time);
-		syslog(LOG_NOTICE, "[TDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
 		                   cepid, time / SYSTIM_HZ, scount, total);
 
 		if ((error = tcp_sht_cep(cepid)) < 0)
-			syslog(LOG_NOTICE, "[TDC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
 
 		if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
-			syslog(LOG_NOTICE, "[TDC:%02d SND] close error: %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
 
 		/* 開放が完了するまで待つ。*/
 		syscall(wai_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
 		}
+
+	return E_OK;
 	}
 
@@ -241,5 +258,5 @@
  */
 
-static void
+static ER
 send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
 {
@@ -266,10 +283,10 @@
 
 	if ((error = TCP_CON_CEP(cepid, &src, &dst, 60 * 1000)) != E_OK) {
-		syslog(LOG_NOTICE, "[TDC:%02d SND] connect error: %s", cepid, itron_strerror(error));
-		return;
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
+		return error;
 		}
 
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDC:%02d SND] connecting: %6ld, to:   %s.%d",
+	syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
 	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 
@@ -279,5 +296,5 @@
 		while (soff < SND_BUF_SIZE) {
 			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
-				syslog(LOG_NOTICE, "[TDC:%02d SND] send error: %s", cepid, itron_strerror(slen));
+				syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s", cepid, itron_strerror(slen));
 				goto cls_ret;
 				}
@@ -287,9 +304,9 @@
 
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TDC:%02d SND] snd: %3d, len: %4d, off: %4d",
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
 			                   cepid, scount, (uint16_t)slen, soff);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
-			syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
+			syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
 			}
 		}
@@ -297,105 +314,205 @@
 cls_ret:
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[TDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
+	syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
 	                   cepid, time / SYSTIM_HZ, scount, total);
 
 	if ((error = tcp_sht_cep(cepid)) < 0)
-		syslog(LOG_NOTICE, "[TDC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
 
 	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) < 0)
-		syslog(LOG_NOTICE, "[TDC:%02d SND] close error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
+
+	return E_OK;
 	}
 
 #endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+/*
+ *  getcomd -- コマンドを得る。
+ */
+
+#ifdef TCP_DISCARD_CLI_AUTO_RUN_STR
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = TCP_DISCARD_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || (count == 0)) {
+		line = auto_run_str;
+		dly_tsk(3 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
 
 void
 tcp_discard_cli_task (intptr_t exinf)
 {
+	ID		tskid, cepid;
 	T_IN_ADDR	addr;
-	ID		tskid, cepid;
-	int_t		rep;
-	uint32_t	count;
+	ER		error;
+	uint8_t		*line;
+	int_t		rep, count;
+	bool_t		retry = false;
 	uint16_t	portno;
-	uint8_t		*line;
+	char		apip;
 
 #ifdef USE_TCP_EXTENTIONS
 
-	ER		error;
 	T_TCP_CCEP	ccep;
 
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
 
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
+	dly_tsk(START_DLY);
+#endif
 	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+
+#if defined(SUPPORT_INET6)
+	apip = API_PROTO_IPV6;
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#endif
+#else
+	apip = API_PROTO_IPV4;
+	syslog(LOG_NOTICE, "[TCP4 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#endif
+
 	while (true) {
-		if (rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line) == E_OK) {
-			line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));	/* IP Address */
-
-			if ('0' <= *line && *line <= '9') {				/* Port No */
-				line = get_int(&rep, line);
-				portno = (uint16_t)rep;
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+		if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+		else
+			retry = false;
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else {
+			line ++;
+			portno = DISCARD_SRV_PORTNO;
+			}
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9')	/* Repeat */
+			line = get_int(&rep, line);
+		else
+			rep = 1;
+
+#ifdef USE_TCP_EXTENTIONS
+
+		ccep.cepatr = 0;
+		ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE;
+		ccep.rbufsz = 0;
+		ccep.rbuf = NADR;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+		ccep.sbuf = NADR;
+#else
+		ccep.sbuf = tcp_discard_cli_swbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_tcp_discard_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP create error: %s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		cepid = (ID)exinf;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		tcp_discard_cli_valid = true;
+		count = 0;
+		while (rep == 0 || count < rep) {
+			if (!tcp_discard_cli_valid) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] canceled.", cepid);
+				break;
+				}
+
+			count ++;
+			if (rep == 0) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d", cepid, count);
+				error = send_tcp_discard(cepid, &addr, portno);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d", cepid, count);
 				}
 			else {
-				line ++;
-				portno = DISCARD_SRV_PORTNO;
-				}
-
-			line = skip_blanks(line);
-			if ('0' <= *line && *line <= '9')				/* Repeat */
-				line = get_int(&rep, line);
-			else
-				rep = 1;
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d/%d", cepid, count, rep);
+				error = send_tcp_discard(cepid, &addr, portno);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d/%d", cepid, count, rep);
+				}
+
+			if (error != E_OK) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], error: %s",
+				                   cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
+				tslp_tsk(SLP_ITV);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", cepid);
+				}
+
+#if defined(SND_ITV)
+#if SND_ITV > 0
+			if (count < rep) {
+				uint_t itv;
+				
+				itv = SND_ITV;
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] interval: %d[s].", cepid, itv / SYSTIM_HZ);
+				syscall(dly_tsk(SND_ITV));
+				}
+#endif
+#endif
+			}
 
 #ifdef USE_TCP_EXTENTIONS
 
-			ccep.cepatr = 0;
-			ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE;
-			ccep.rbufsz = 0;
-			ccep.rbuf = NADR;
-
-#ifdef TCP_CFG_SWBUF_CSAVE
-			ccep.sbuf = NADR;
-#else
-			ccep.sbuf = tcp_discard_cli_swbuf;
-#endif
-#ifdef USE_TCP_NON_BLOCKING
-			ccep.callback = (FP)callback_nblk_tcp_discard_cli;
-#else
-			ccep.callback = NULL;
-#endif
-
-			if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) {
-				syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
-				continue;
-				}
-
-#else	/* of #ifdef USE_TCP_EXTENTIONS */
-
-			cepid = (ID)exinf;
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP delete error: %s", cepid, itron_strerror(error));
 
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
 
-			tcp_discard_cli_valid = true;
-			for (count = rep; count -- > 0; ) {
-				if (!tcp_discard_cli_valid) {
-					syslog(LOG_NOTICE, "[TDC:%02d TSK] canceled.", (ID)exinf);
-					break;
-					}
-				syslog(LOG_NOTICE, "[TDC:%02d TSK] start:              repeat: %d/%d",
-				                   (ID)exinf, rep - count, rep);
-				send_tcp_discard(cepid, &addr, portno);
-				syslog(LOG_NOTICE, "[TDC:%02d TSK] finished:           repeat: %d/%d",
-				                   (ID)exinf, rep - count, rep);
-				syscall(dly_tsk(500 + net_rand() % SYSTIM_HZ));
-				}
-
-#ifdef USE_TCP_EXTENTIONS
-
-			if ((error = free_tcp_cep(cepid)) != E_OK)
-				syslog(LOG_NOTICE, "[TDC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
-
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
-			}
 		}
 	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_cli.h	(revision 331)
@@ -0,0 +1,100 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_DISCARD_CLI_H_
+#define _TCP_DISCARD_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_DISCARD_CLI_STACK_SIZE	1024		/* TCP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+/* åªå
+åº¦ */
+
+#define TCP_DISCARD_CLI_MAIN_PRIORITY	5	/* TCP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦ */
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  å¤æ°
+ */
+
+extern bool_t	tcp_discard_cli_valid;
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_discard_cli_swbuf[];
+extern uint8_t tcp_discard_cli_rwbuf[];
+
+/* ã¿ã¹ã¯ */
+
+extern void tcp_discard_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_nblk_tcp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _TCP_DISCARD_CLI_H_ */
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)
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_discard_srv.h	(revision 331)
@@ -0,0 +1,90 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_DISCARD_SRV_H_
+#define _TCP_DISCARD_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_DISCARD_SRV_STACK_SIZE	1024		/* TCP DISCARD ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+/* åªå
+åº¦ */
+
+#define TCP_DISCARD_SRV_MAIN_PRIORITY	5	/* TCP DISCARD ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦ */
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_discard_srv_swbuf[];
+extern uint8_t tcp_discard_srv_rwbuf[];
+
+/* ã¿ã¹ã¯ */
+
+extern void tcp_discard_srv_task(intptr_t exinf);
+
+#endif	/* of #ifndef _TCP_DISCARD_SRV_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.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
  *
@@ -50,4 +50,5 @@
 #include <t_syslog.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -57,27 +58,14 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #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/net.h>
-#include <net/ethernet.h>
-#include <net/net_var.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/echo.h>
+#include <netapp/tcp_echo_cli.h>
 
 #ifdef USE_TCP_ECHO_CLI
@@ -96,45 +84,44 @@
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
 
-/* 表示 */
-
-//#define SHOW_RCV_RANGE
-
-/* タイムアウト */
-
-#define CON_TMO		TMO_FEVR
-//#define CON_TMO		(60*SYSTIM_HZ)
-//#define CLS_TMO		TMO_FEVR				/* Close Wait は標準で 60秒 */
-#define CLS_TMO		(70*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*10)
-//#define RCV_TMO		TMO_FEVR
-#define RCV_TMO		(40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20)
-//#define SND_TMO		TMO_FEVR
-#define SND_TMO		(30*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*30)
-
 /* 送信間隔 */
 
-//#define SND_DLY			ULONG_C(500)
-#define SND_ITV		(5*SYSTM_HZ)
+#ifdef TOPPERS_S810_CLG3_85
+
+//#define SND_DLY		(500)
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define SND_DLY		(500)
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
 #define SLP_ITV		(60*SYSTIM_HZ)
 
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
 /* 自動実行 */
 
+#if defined(TCP_ECHO_CLI_AUTO_RUN_STR)
+#else
 #if 0
 #if defined(SUPPORT_INET6)
-#define AUTO_RUN_STR	"fe80::211:2fff:fe8a:e8c0 - 0"
-#else
-#define AUTO_RUN_STR	"172.25.193.140 - 0"
-#endif
-#endif
-
-/*
- *  バッファサイズの定義
- */
-
-#define NUM_ECHO		20
-#define NUM_REP_PAT		20
-#define PAT_BEGIN		' '
-#define PAT_END			'~'
-#define SND_BUF_SIZE		((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)
-#define RCV_BUF_SIZE		(SND_BUF_SIZE*15/10)
+#define TCP_ECHO_CLI_AUTO_RUN_STR	"fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
+#else
+#define TCP_ECHO_CLI_AUTO_RUN_STR	"172.25.129.140 - 0"
+#endif
+#endif
+#endif
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+#define API_PROTO		'n'
+#else
+#define API_PROTO		'6'
+#endif
+#else
+#define API_PROTO		'4'
+#endif
 
 /*
@@ -142,5 +129,6 @@
  */
 
-bool_t tcp_echo_cli_valid;
+bool_t	tcp_echo_cli_valid;
+uint_t	tcp_echo_cli_scount;
 
 /* TCP 送受信ウィンドバッファ */
@@ -154,19 +142,11 @@
 #endif
 
-/*
- *  変数
- */
-
-static uint_t	scount;
-static uint_t	rcount;
-
 #ifdef USE_TCP_NON_BLOCKING
 
-static T_IPEP	nblk_src = {
-			IP_ADDRANY,
-			TCP_PORTANY,
-			};
-static T_IPEP	nblk_dst;
-static ER_UINT	nblk_error;
+/*
+ *  全域変数
+ */
+
+ER_UINT	tcp_echo_cli_nblk_error;
 
 /*
@@ -179,5 +159,5 @@
 	ER	error = E_OK;
 
-	nblk_error = *(ER*)p_parblk;
+	tcp_echo_cli_nblk_error = *(ER*)p_parblk;
 
 	switch (fncd) {
@@ -188,26 +168,31 @@
 
 	case TFN_TCP_RCV_BUF:
-		if (nblk_error < 0)
-			syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv buf error: %s", cepid, itron_strerror(nblk_error));
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
 		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
 		break;
 
 	case TFN_TCP_CLS_CEP:
-		if (nblk_error < 0)
-			syslog(LOG_NOTICE, "[TEC:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
 		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
 		break;
 
 	case TFN_TCP_RCV_DAT:
-		if (nblk_error < 0)
-			syslog(LOG_NOTICE, "[TEC:%02d CBN] rcv dat error: %s", cepid, itron_strerror(nblk_error));
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
 		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
 		break;
 
 	case TFN_TCP_SND_OOB:
-		if (nblk_error > 0)
-			syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg: %4d", cepid, nblk_error);
+		if (tcp_echo_cli_nblk_error > 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] snd urg: %4u",
+			                   API_PROTO, cepid, tcp_echo_cli_nblk_error);
 		else
-			syslog(LOG_NOTICE, "[TEC:%02d CBN] snd urg error: %s", cepid, itron_strerror(nblk_error));
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
 		break;
 
@@ -222,447 +207,4 @@
 	}
 
-/*
- *  send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。
- */
-
-static ER
-send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
-{
-	static char smsg[SND_BUF_SIZE];
-
-	ER_UINT		slen;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	soff, echo, rep;
-	char		*p, pat;
-
-#ifdef SND_URG_DATA_SIZE
-	int_t	urg = SND_URG_COUNT;
-#endif
-
-	nblk_dst.ipaddr = *ipaddr;
-	nblk_dst.portno = portno;
-
-	p = smsg;
-	for (rep = NUM_REP_PAT; rep -- > 0; )
-		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
-			*p ++ = pat;
-
-	if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-	/* 接続が完了するまで待つ。*/
-	syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
-
-	if (nblk_error != E_OK)
-		syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(nblk_error));
-	else {
-		get_tim(&time);
-		syslog(LOG_NOTICE, "[TEC:%02d SND] connecting: %6lu, to:   %s.%u",
-		                   cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);
-
-		if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));
-			goto cls_ret;
-			}
-
-		scount = total = 0;
-		for (echo = NUM_ECHO; echo -- > 0; ) {
-			soff = 0;
-			while (soff < SND_BUF_SIZE) {
-				if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
-					syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s",
-					                   cepid, itron_strerror(slen));
-					goto cls_ret;
-					}
-				soff  += (uint16_t)slen;
-				total +=     slen;
-				scount ++;
-#ifdef SHOW_RCV_RANGE
-				syslog(LOG_NOTICE, "[TEC:%02d SND] send cnt: %2d, len: %4d, off: %4d",
-				                   cepid, scount, (uint16_t)slen, soff);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-#ifdef SND_URG_DATA_SIZE
-				if (urg) {
-					if (urg == 1) {
-						if ((error = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, TMO_NBLK)) != E_WBLK)
-							syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",
-							                   cepid, itron_strerror(error));
-						}
-					urg --;
-					}
-#endif	/* of #ifdef SND_URG_DATA_SIZE */
-
-#if SND_DLY > 0
-				syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));
-#endif
-				}
-			}
-
-	cls_ret:
-		if ((error = tcp_sht_cep(cepid)) < 0)
-			syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
-
-		/* 受信が完了するまで待つ。*/
-		syscall(slp_tsk());
-		}
-
-	return error;
-	}
-
-/*
- *  TCP ECHO クライアント受信タスク
- */
-
-#ifdef USE_COPYSAVE_API
-
-void
-tcp_echo_cli_rcv_task (intptr_t exinf)
-{
-	ID		tskid, cepid;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	roff, rlen;
-	char		*rmsg, head, tail;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK,CS) RCV:%d] started.", tskid);
-	while (true) {
-		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
-			                   cepid, itron_strerror(error));
-			}
-                else {
-			roff = rcount = total = 0;
-			while (true) {
-				if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s", cepid, itron_strerror(error));
-					break;
-					}
-
-				/* 受信バッファの獲得が完了するまで待つ。*/
-				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
-				if (nblk_error < 0)
-					break;
-
-				rlen = nblk_error;
-				head = *rmsg;
-				tail = *(rmsg + rlen - 1);
-				if (rlen > 0) {
-					roff  += rlen;
-					total += rlen;
-					rcount ++;
-#ifdef SHOW_RCV_RANGE
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] "
-					                   "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",
-					                   cepid, rcount, rlen, roff, head, tail);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-					}
-				else
-					break;
-
-				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s", 
-					                   cepid, itron_strerror(error));
-				}
-
-			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
-				syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));
-
-			/* 切断が完了するまで待つ。*/
-			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
-
-			get_tim(&time);
-			syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
-			                   cepid, time / SYSTIM_HZ, scount, rcount, total);
-			}
-
-		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
-		}
-	}
-
-#else	/* of #ifdef USE_COPYSAVE_API */
-
-void
-tcp_echo_cli_rcv_task (intptr_t exinf)
-{
-	static char rmsg[RCV_BUF_SIZE];
-
-	ID		tskid, cepid;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	roff, rlen;
-	char		head, tail;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP ECHO CLI (NBLK) RCV:%d] started.", tskid);
-	while (true) {
-		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
-			                   cepid, itron_strerror(error));
-			}
-                else {
-			roff = rcount = total = 0;
-			while (true) {
-				if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv error: %s", cepid, itron_strerror(error));
-					break;
-					}
-
-				/* 受信が完了するまで待つ。*/
-				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
-				if (nblk_error < 0)
-					break;
-
-				rlen = nblk_error;
-				head = *rmsg;
-				tail = *(rmsg + rlen - 1);
-				rcount ++;
-				if (rlen > 0) {
-					roff  += rlen;
-					total += rlen;
-#ifdef SHOW_RCV_RANGE
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] "
-					                   "recv cnt: %2d, len: %4d, off: %4d, data: %02x -> %02x",
-					                   cepid, rcount, rlen, roff, head, tail);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-					}
-				else
-					break;
-				}
-
-			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
-				syslog(LOG_NOTICE, "[TEC:%02d SND] close error: %s", cepid, itron_strerror(error));
-
-			/* 切断が完了するまで待つ。*/
-			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
-
-			get_tim(&time);
-			syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
-			                   cepid, time / SYSTIM_HZ, scount, rcount, total);
-			}
-
-		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
-		}
-	}
-
-#endif	/* of #ifdef USE_COPYSAVE_API */
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-/*
- *  send_tcp_echo -- ECHO/TCP サーバにメッセージを送信する。
- */
-
-static ER
-send_tcp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
-{
-	static char smsg[SND_BUF_SIZE];
-	static T_IPEP src = {
-		IP_ADDRANY,
-		TCP_PORTANY,
-		};
-
-	T_IPEP		dst;
-	ER_UINT		slen;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	soff, echo, rep;
-	char 		pat, *p;
-
-#ifdef SND_URG_DATA_SIZE
-	int_t	urg = SND_URG_COUNT;
-#endif
-
-	dst.ipaddr = *ipaddr;
-	dst.portno = portno;
-
-	p = smsg;
-	for (rep = NUM_REP_PAT; rep -- > 0; )
-		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
-			*p ++ = pat;
-
-	if ((error = TCP_CON_CEP(cepid, &src, &dst, CON_TMO)) != E_OK) {
-		syslog(LOG_NOTICE, "[TEC:%02d SND] connect error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-	get_tim(&time);
-	syslog(LOG_NOTICE, "[TEC:%02u SND] connecting: %6lu, to:   %s.%u",
-	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-
-	if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
-		syslog(LOG_NOTICE, "[TEC:%02d SND] sync error: %s", cepid, itron_strerror(error));
-		goto cls_ret;
-		}
-
-	scount = total = 0;
-	for (echo = NUM_ECHO; echo -- > 0; ) {
-		soff = 0;
-		while (soff < SND_BUF_SIZE) {
-			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
-				syslog(LOG_NOTICE, "[TEC:%02d SND] snd dat error: %s", cepid, itron_strerror(slen));
-				goto cls_ret;
-				}
-			soff  += (uint16_t)slen;
-			total +=     slen;
-			scount ++;
-#ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TEC:%02d SND] send count: %3d, len: %4d, offset: %4d",
-			                   cepid, scount, (uint16_t)slen, soff);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-#ifdef SND_URG_DATA_SIZE
-			if (urg > 0) {
-				if (urg == 1) {
-					if ((slen = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, SND_TMO)) >= 0)
-						syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg: %4d",
-						                   cepid, (uint16_6)slen);
-					else
-						syslog(LOG_NOTICE, "[TEC:%02d SND] snd urg error: %s",
-						                   cepid, itron_strerror(slen));
-					}
-				urg --;
-				}
-#endif	/* of #ifdef SND_URG_DATA_SIZE */
-
-#if SND_DLY > 0
-			syscall(dly_tsk(SND_DLY + net_rand() % SYSTIM_HZ));
-#endif
-			}
-		}
-
-cls_ret:
-	if ((error = tcp_sht_cep(cepid)) < 0)
-		syslog(LOG_NOTICE, "[TEC:%02d SND] shutdown error: %s", cepid, itron_strerror(error));
-
-	/* 受信が完了するまで待つ。*/
-	syscall(slp_tsk());
-
-	return error;
-	}
-
-/*
- *  TCP ECHO クライアント受信タスク
- */
-
-#ifdef USE_COPYSAVE_API
-
-void
-tcp_echo_cli_rcv_task (intptr_t exinf)
-{
-	ID		tskid, cepid;
-	ER_UINT		rlen;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	roff;
-	char		*rmsg;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP ECHO CLI (CS) RCV:%d] started.", tskid);
-	while (true) {
-		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
-			                   cepid, itron_strerror(error));
-			}
-		else {
-			roff = rcount = total = 0;
-			while (true) {
-				if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, RCV_TMO)) < 0) {
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv buf error: %s",
-					                   cepid, itron_strerror(rlen));
-					break;
-					}
-				else if (rlen > 0) {
-					roff  += (uint16_t)rlen;
-					total +=     rlen;
-					rcount ++;
-#ifdef SHOW_RCV_RANGE
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",
-					                   cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-					}
-				else
-					break;
-				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rel buf error: %s", cepid, itron_strerror(error));
-				}
-
-			if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)
-				syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));
-
-			get_tim(&time);
-			syslog(LOG_NOTICE, "[TEC:%02u RCV] finished:   %6lu, snd: %4u, rcv: %4u, len: %u",
-			                   cepid, time / SYSTIM_HZ, scount, rcount, total);
-			}
-
-		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
-		}
-	}
-
-#else	/* of #ifdef USE_COPYSAVE_API */
-
-void
-tcp_echo_cli_rcv_task (intptr_t exinf)
-{
-	static char rmsg[RCV_BUF_SIZE];
-
-	ID		tskid, cepid;
-	ER_UINT		rlen;
-	ER		error;
-	SYSTIM		time;
-	uint32_t	total;
-	uint16_t	roff;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP ECHO CLI RCV:%d] started.", tskid);
-	while (true) {
-		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d RCV] sync error: %s",
-			                   cepid, itron_strerror(error));
-			}
-                else {
-			roff = rcount = total = 0;
-			while (true) {
-				if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), RCV_TMO)) < 0) {
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] rcv dat error: %s", cepid, itron_strerror(rlen));
-					tcp_can_cep(cepid, TFN_TCP_ALL);
-					break;
-					}
-				else if (rlen > 0) {
-					roff  += (uint16_t)rlen;
-					total +=     rlen;
-					rcount ++;
-#ifdef SHOW_RCV_RANGE
-					syslog(LOG_NOTICE, "[TEC:%02d RCV] recv count: %3d, len: %4d, data: %02x -> %02x",
-					                   cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-					}
-				else
-					break;
-				}
-
-			if ((error = tcp_cls_cep(cepid, CLS_TMO)) < 0)
-				syslog(LOG_NOTICE, "[TEC:%02d RCV] close error: %s", cepid, itron_strerror(error));
-
-			get_tim(&time);
-			syslog(LOG_NOTICE, "[TEC:%02u RCV] received:   %6lu, snd: %4u, rcv: %4u, len: %u",
-			                   cepid, time / SYSTIM_HZ, scount, rcount, total);
-			}
-
-		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
-		}
-	}
-
-#endif	/* of #ifdef USE_COPYSAVE_API */
-
 #endif	/* of #ifdef USE_TCP_NON_BLOCKING */
 
@@ -671,15 +213,15 @@
  */
 
-#ifdef AUTO_RUN_STR
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
 
 static char *
-getcomd (ID cepid)
+getcomd (ID cepid, bool_t retry, char *apip)
 {
 	ER		error;
 	char		*line = NULL;
-	static char	auto_run_str[] = AUTO_RUN_STR;
+	static char	auto_run_str[] = TCP_ECHO_CLI_AUTO_RUN_STR;
 	static int_t	count = 0;
 
-	if (count == 0) {
+	if (retry || (count == 0)) {
 		line = auto_run_str;
 		dly_tsk(3 * 1000);
@@ -687,5 +229,5 @@
 	else {
 		while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d TSK] error: %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
 			dly_tsk(SLP_ITV);
 			}
@@ -696,8 +238,8 @@
 	}
 
-#else	/* of #ifdef AUTO_RUN_STR */
+#else	/* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
 
 static char *
-getcomd (ID cepid)
+getcomd (ID cepid, bool_t retry, char *apip)
 {
 	ER	error;
@@ -705,15 +247,48 @@
 
 	while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
-		syslog(LOG_NOTICE, "[TEC:%02d TSK] error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
 		dly_tsk(SLP_ITV);
 		}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (*line == '6') {
+		line ++;
+		*apip = API_PROTO_IPV6;
+		}
+	else if (*line == '4') {
+		line ++;
+		*apip = API_PROTO_IPV4;
+		}
+	else {
+		*apip= DEFAULT_API_PROTO;
+		if (*line && *line != ' ')
+			line ++;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	*apip= DEFAULT_API_PROTO;
+	if (*line && *line != ' ')
+		line ++;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
 	return line;
 	}
 
-#endif	/* of #ifdef AUTO_RUN_STR */
+#endif	/* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
 
 /*
  *  TCP ECHO クライアント送信タスク
  */
+
+/*
+ *  IP アドレスの指定
+ */
+
+#define ADDR_IPVn	'n'
+#define ADDR_IPV6	'6'
+#define ADDR_IPV4	'4'
 
 void
@@ -723,7 +298,9 @@
 	ER		error;
 	T_IN_ADDR	addr;
+	char		*line;
+	int_t		rep, count;
+	bool_t		retry = false;
 	uint16_t	portno;
-	int_t		rep, count;
-	char		*line;
+	char		apip;
 
 #ifdef USE_TCP_EXTENTIONS
@@ -733,11 +310,58 @@
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
 
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
+	dly_tsk(START_DLY);
+#endif
 	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[TCP ECHO CLI SND:%d,%d] started.", tskid, (ID)exinf);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI SND:%d,%d] started.", DEFAULT_API_PROTO, tskid, (ID)exinf);
 	while (true) {
-		line = getcomd((ID)exinf);
-		line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));	/* IP Address */
-
-		if ('0' <= *line && *line <= '9') {				/* Port No */
+		line = skip_blanks(getcomd((ID)exinf, retry, &apip));
+
+#if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+		if (apip == API_PROTO_IPV4) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR) */
+
+		if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       API_PROTO, (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+		else
+			retry = false;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP4_ECHO_CLI)
+
+#else	/* of #if defined(USE_TCP4_ECHO_CLI) */
+
+		if (in6_is_addr_ipv4mapped(&addr))
+			apip = API_PROTO_IPV4;
+		else
+			apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(USE_TCP4_ECHO_CLI) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+		if (apip == API_PROTO_IPV6) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
 			line = get_int(&rep, line);
 			portno = (uint16_t)rep;
@@ -749,8 +373,10 @@
 
 		line = skip_blanks(line);
-		if ('0' <= *line && *line <= '9')				/* Repeat */
+		if ('0' <= *line && *line <= '9')	/* Repeat */
 			line = get_int(&rep, line);
-		else
+		else {
+			line ++;
 			rep = 1;
+			}
 
 #ifdef USE_TCP_EXTENTIONS
@@ -776,12 +402,42 @@
 #endif
 
-		if ((error = alloc_tcp_cep(&cepid, tskid, &ccep)) != E_OK) {
-			syslog(LOG_NOTICE, "[TEC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+		if (apip == API_PROTO_IPV6) {
+			if ((error = alloc_tcp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+				continue;
+				}
+			}
+		else {
+			if ((error = alloc_tcp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+				continue;
+				}
+			}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+		if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
 			continue;
 			}
 
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
 #else	/* of #ifdef USE_TCP_EXTENTIONS */
 
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+		if (apip == API_PROTO_IPV6)
+			cepid = (ID)exinf;
+		else
+			cepid = TCP4_ECHO_CLI_CEPID;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
 		cepid = (ID)exinf;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
 
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
@@ -791,5 +447,5 @@
 		while (rep == 0 || count < rep) {
 			if (!tcp_echo_cli_valid) {
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] canceled.", cepid);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] canceled.", apip, cepid);
 				break;
 				}
@@ -797,28 +453,28 @@
 			count ++;
 			if (rep == 0) {
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] start:              repeat: %d", cepid, count);
-				error = send_tcp_echo(cepid, &addr, portno);
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] finished:           repeat: %d", cepid, count);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d", apip, cepid, count);
+				error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d", apip, cepid, count);
 				}
 			else {
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] start:              repeat: %d/%d", cepid, count, rep);
-				error = send_tcp_echo(cepid, &addr, portno);
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] finished:           repeat: %d/%d", cepid, count, rep);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d/%d", apip, cepid, count, rep);
+				error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d/%d", apip, cepid, count, rep);
 				}
 
 			if (error != E_OK) {
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] sleep %d[ms], error: %s",
-				                   cepid, SLP_ITV, itron_strerror(error));
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], error: %s",
+				                   apip, cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
 				tslp_tsk(SLP_ITV);
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] resume.", cepid);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", apip, cepid);
 				}
 
 #if defined(SND_ITV)
 #if SND_ITV > 0
-			if (count > 0) {
+			if (count < rep) {
 				uint_t itv;
 				
 				itv = SND_ITV;
-				syslog(LOG_NOTICE, "[TEC:%02d TSK] interval: %d[ms].", cepid, itv);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] interval: %d[s].", apip, cepid, itv / SYSTIM_HZ);
 				syscall(dly_tsk(SND_ITV));
 				}
@@ -829,6 +485,6 @@
 #ifdef USE_TCP_EXTENTIONS
 
-		if ((error = free_tcp_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TEC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
 
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli.h	(revision 331)
@@ -0,0 +1,133 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_ECHO_CLI_H_
+#define _TCP_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define TCP_ECHO_CLI_RCV_STACK_SIZE	512		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#define TCP_ECHO_CLI_SND_STACK_SIZE	512		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define TCP_ECHO_CLI_RCV_STACK_SIZE	1024		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#define TCP_ECHO_CLI_SND_STACK_SIZE	1024		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_CLI_RCV_MAIN_PRIORITY	5		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®åªå
+åº¦		*/
+#define TCP_ECHO_CLI_SND_MAIN_PRIORITY	5		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(1024)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(512)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(2048)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  ãããã¡ãµã¤ãºã®å®ç¾©
+ */
+
+#define NUM_ECHO		20
+#define NUM_REP_PAT		20
+#define PAT_BEGIN		' '
+#define PAT_END			'~'
+#define SND_BUF_SIZE		((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)
+#define RCV_BUF_SIZE		(SND_BUF_SIZE*15/10)
+
+/*
+ *  å¤æ°
+ */
+
+extern bool_t	tcp_echo_cli_valid;
+extern uint_t	tcp_echo_cli_scount;
+extern ER_UINT	tcp_echo_cli_nblk_error;
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_echo_cli_swbuf[];
+extern uint8_t tcp_echo_cli_rwbuf[];
+
+/* ã¿ã¹ã¯*/
+
+extern void	tcp_echo_cli_rcv_task(intptr_t exinf);
+extern void	tcp_echo_cli_snd_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_nblk_tcp_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#ifdef T_IN_ADDR
+extern ER tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip);
+#endif
+
+#endif	/* of #ifndef _TCP_ECHO_CLI_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_rcv.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_rcv.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_rcv.c	(revision 331)
@@ -0,0 +1,454 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_cli.h>
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* è¡¨ç¤º */
+
+//#define SHOW_TIME_OUT
+//#define SHOW_RCV_RANGE
+
+/* ã¿ã¤ã ã¢ã¦ã */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR					/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR				/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/*
+ *  API IPãã­ãã³ã«ã®æå®
+ */
+
+#undef  DEFAULT_API_PROTO
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+#define DEFAULT_API_PROTO	API_PROTO_IPVn
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV6
+#endif
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV4
+#endif
+
+/*
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
+ */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total, rcount;
+	uint16_t	roff, rlen;
+	char		*rmsg, head, tail, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK,CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+#ifdef USE_TCP_EXTENTIONS
+
+			apip = API_PROTO_IPVn;
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+				if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
+					break;
+					}
+
+				/* åä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+				if (tcp_echo_cli_nblk_error < 0)
+					break;
+
+				rlen = tcp_echo_cli_nblk_error;
+				head = *rmsg;
+				tail = *(rmsg + rlen - 1);
+				if (rlen > 0) {
+					roff  += rlen;
+					total += rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
+					                   "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, rlen, roff, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+
+				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
+					syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s", 
+					                   apip, cepid, itron_strerror(error));
+				}
+
+			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			/* åæ­ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	static char rmsg[RCV_BUF_SIZE];
+
+	ID		tskid, cepid;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total, rcount;
+	uint16_t	roff, rlen;
+	char		head, tail, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+				if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
+					break;
+					}
+
+				/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+				if (tcp_echo_cli_nblk_error < 0)
+					break;
+
+				rlen = tcp_echo_cli_nblk_error;
+				head = *rmsg;
+				tail = *(rmsg + rlen - 1);
+				rcount ++;
+				if (rlen > 0) {
+					roff  += rlen;
+					total += rlen;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
+					                   "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, rlen, roff, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				}
+
+			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			/* åæ­ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time, tmo;
+	uint32_t	total = 0, rcount;
+	uint16_t	roff;
+	char		*rmsg, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+#ifdef USE_TCP_EXTENTIONS
+
+			if (tcp6_is_cepid(cepid))
+				apip = API_PROTO_IPV6;
+			else
+				apip = API_PROTO_IPV4;
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			}
+		else {
+			roff = rcount = total = 0;
+			while (true) {
+				tmo = RCV_TMO;
+#ifdef SHOW_TIME_OUT
+				syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+				if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, tmo)) < 0) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s",
+					                   apip, cepid, itron_strerror(rlen));
+					break;
+					}
+				else if (rlen > 0) {
+					roff  += (uint16_t)rlen;
+					total +=     rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
+					syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s", apip, cepid, itron_strerror(error));
+				}
+
+			tmo = CLS_TMO;
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			if ((error = tcp_cls_cep(cepid, tmo)) < 0)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	static char rmsg[RCV_BUF_SIZE];
+
+	ID		tskid, cepid;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time, tmo;
+	uint32_t	total, rcount;
+	uint16_t	roff;
+	char		apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+#ifdef SHOW_TIME_OUT
+				syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+				tmo = RCV_TMO;
+				if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), tmo)) < 0) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(rlen));
+					tcp_can_cep(cepid, TFN_TCP_ALL);
+					break;
+					}
+				else if (rlen > 0) {
+					roff  += (uint16_t)rlen;
+					total +=     rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				}
+
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			tmo = CLS_TMO;
+			if ((error = tcp_cls_cep(cepid, tmo)) < 0)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_snd.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_snd.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_cli_snd.c	(revision 331)
@@ -0,0 +1,499 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡é¢æ°
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_cli.h>
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* è¡¨ç¤º */
+
+//#define SHOW_TIME_OUT
+//#define SHOW_SND_COUNT
+
+/* ã¿ã¤ã ã¢ã¦ã */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CON_TMO		TMO_FEVR
+//#define CON_TMO		(60*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define CON_TMO		TMO_FEVR
+//#define CON_TMO		(60*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+static T_IPV4EP	nblk_src4 = {
+			IPV4_ADDRANY,
+			TCP_PORTANY,
+			};
+static T_IPV4EP	nblk_dst4;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+static T_IPEP	nblk_src = {
+			IP_ADDRANY,
+			TCP_PORTANY,
+			};
+static T_IPEP	nblk_dst;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+/*
+ *  tcp4_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+static ER
+tcp4_active_open (ID cepid, T_IN4_ADDR ipaddr, uint16_t portno)
+{
+	ER		error;
+	SYSTIM		time;
+
+	nblk_dst4.ipaddr = ipaddr;
+	nblk_dst4.portno = portno;
+
+	if ((error = tcp_con_cep(cepid, &nblk_src4, &nblk_dst4, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[TEC4:%02u CON] error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* æ¥ç¶ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+	if ((error = tcp_echo_cli_nblk_error) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC4:%02u CON] error: %s", cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC4:%02u CON] conct: %7lu,  to: %s.%u",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &nblk_dst4.ipaddr), nblk_dst4.portno);
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+/*
+ *  tcp_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+static ER
+tcp_active_open (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	ER		error;
+	SYSTIM		time;
+
+	nblk_dst.ipaddr = *ipaddr;
+	nblk_dst.portno = portno;
+
+	if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
+		if (error == E_PAR || error == E_ID)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, API: IPv%c, addr: %s",
+			                   apip, cepid, itron_strerror(error), apip, IP2STR(NULL, ipaddr));
+		else
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s",
+			                   apip, cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* æ¥ç¶ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+	if ((error = tcp_echo_cli_nblk_error) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s",
+		                   apip, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   apip, cepid, time / SYSTIM_HZ,
+	                   IP2STR(NULL, &nblk_dst.ipaddr), nblk_dst.portno);
+	return error;
+	}
+
+/*
+ *  tcp_echo_cli_snd -- ECHO/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+ER
+tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static char smsg[SND_BUF_SIZE];
+
+	ER_UINT		slen;
+	ER		error;
+	uint32_t	total;
+	uint16_t	soff, echo, rep;
+	char		*p, pat;
+
+#ifdef SND_URG_DATA_SIZE
+	int_t	urg = SND_URG_COUNT;
+#endif
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (apip == API_PROTO_IPV6) {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+	else if (in6_is_addr_ipv4mapped(ipaddr)) {
+		if ((error = tcp4_active_open(cepid, ntohl(ipaddr->s6_addr32[3]), portno)) != E_OK)
+			return error;
+		}
+	else {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+		return error;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s", apip, cepid, itron_strerror(error));
+		goto cls_ret;
+		}
+
+	tcp_echo_cli_scount = total = 0;
+	for (echo = NUM_ECHO; echo -- > 0; ) {
+		soff = 0;
+		while (soff < SND_BUF_SIZE) {
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);;
+#endif/* of #ifdef SHOW_TIME_OUT */
+			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u SND] error: %s",
+				                   apip, cepid, itron_strerror(slen));
+				error = slen;
+				goto cls_ret;
+				}
+			soff  += (uint16_t)slen;
+			total +=     slen;
+			tcp_echo_cli_scount ++;
+#ifdef SHOW_SND_COUNT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] count: %7lu, len: %4u, off: %4u",
+			                   apip, cepid, tcp_echo_cli_scount, (uint16_t)slen, soff);
+#endif/* of #ifdef SHOW_SND_COUNT */
+
+#ifdef SND_URG_DATA_SIZE
+			if (urg) {
+				if (urg == 1) {
+					if ((error = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, TMO_NBLK)) != E_WBLK)
+						syslog(LOG_NOTICE, "[TEC%c:%02u OOB] error: %s",
+						                   apip, cepid, itron_strerror(error));
+					}
+				urg --;
+				}
+#endif/* of #ifdef SND_URG_DATA_SIZE */
+
+#if defined(SND_DLY)
+#if SND_DLY > 0
+			syscall(dly_tsk(SND_DLY + netapp_rand() % SYSTIM_HZ));
+#endif
+#endif
+			}
+		}
+
+cls_ret:
+	if ((error = tcp_sht_cep(cepid)) < 0)
+		syslog(LOG_NOTICE, "[TEC%c:%02u SHT] error: %s", apip, cepid, itron_strerror(error));
+
+	/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(slp_tsk());
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+/*
+ *  tcp4_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp4_active_open (ID cepid, T_IN4_ADDR ipaddr, uint16_t portno)
+{
+	static T_IPV4EP src = {
+		IPV4_ADDRANY,
+		TCP_PORTANY,
+		};
+
+	T_IPV4EP	dst;
+	ER		error;
+	SYSTIM		time;
+
+	dst.ipaddr = ipaddr;
+	dst.portno = portno;
+
+#ifdef SHOW_TIME_OUT
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] tmo:   %7lu", API_PROTO_IPV4, cepid, CON_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+	if ((error = tcp_con_cep(cepid, &src, &dst, CON_TMO)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, addr: %s",
+		                   API_PROTO_IPV4, cepid, itron_strerror(error), ip2str(NULL, &ipaddr));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   API_PROTO_IPV4, cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno);
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+/*
+ *  tcp_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp_active_open (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static T_IPEP src = {
+		IP_ADDRANY,
+		TCP_PORTANY,
+		};
+
+	T_IPEP		dst;
+	ER		error;
+	SYSTIM		time;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+
+#ifdef SHOW_TIME_OUT
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] tmo:   %7lu", apip, cepid, CON_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+	if ((error = TCP_CON_CEP(cepid, &src, &dst, CON_TMO)) != E_OK) {
+		if (error == E_PAR || error == E_ID)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, API: IPv%c, addr: %s",
+			                   apip, cepid, itron_strerror(error), apip, IP2STR(NULL, ipaddr));
+		else
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s", apip, cepid, itron_strerror(error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   apip, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	return error;
+	}
+
+/*
+ *  tcp_echo_cli_snd -- ECHO/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+ER
+tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static char smsg[SND_BUF_SIZE];
+
+	ER_UINT		slen;
+	ER		error;
+	uint32_t	total;
+	uint16_t	soff, echo, rep;
+	char		*p, pat;
+
+#ifdef SND_URG_DATA_SIZE
+	int_t	urg = SND_URG_COUNT;
+#endif
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (apip == API_PROTO_IPV6) {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+	else if (in6_is_addr_ipv4mapped(ipaddr)) {
+		if ((error = tcp4_active_open(cepid, ntohl(ipaddr->s6_addr32[3]), portno)) != E_OK)
+			return error;
+		}
+	else {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+		return error;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s", apip, cepid, itron_strerror(error));
+		goto cls_ret;
+		}
+
+	tcp_echo_cli_scount = total = 0;
+	for (echo = NUM_ECHO; echo -- > 0; ) {
+		soff = 0;
+		while (soff < SND_BUF_SIZE) {
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u SND] error: %s", apip, cepid, itron_strerror(slen));
+				error = slen;
+				goto cls_ret;
+				}
+			soff  += (uint16_t)slen;
+			total +=     slen;
+			tcp_echo_cli_scount ++;
+#ifdef SHOW_SND_COUNT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] count: %7lu, len: %4u",
+			                   apip, cepid, tcp_echo_cli_scount, (uint16_t)slen);
+#endif	/* of #ifdef SHOW_SND_COUNT */
+
+#ifdef SND_URG_DATA_SIZE
+			if (urg > 0) {
+				if (urg == 1) {
+#ifdef SHOW_TIME_OUT
+					syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+					if ((slen = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, SND_TMO)) >= 0)
+						syslog(LOG_NOTICE, "[TEC%c:%02u SND] urg:   %7lu",
+						                   apip, cepid, (uint16_6)slen);
+					else
+						syslog(LOG_NOTICE, "[TEC%c:%02u OOB] error: %s",
+						                   apip, cepid, itron_strerror(slen));
+					}
+				urg --;
+				}
+#endif	/* of #ifdef SND_URG_DATA_SIZE */
+
+#if defined(SND_DLY)
+#if SND_DLY > 0
+			syscall(dly_tsk(SND_DLY + netapp_rand() % SYSTIM_HZ));
+#endif
+#endif
+			}
+		}
+
+cls_ret:
+	if ((error = tcp_sht_cep(cepid)) < 0)
+		syslog(LOG_NOTICE, "[TEC%c:%02u SHT] error: %s", apip, cepid, itron_strerror(error));
+
+	/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(slp_tsk());
+
+	return error;
+	}
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.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
  *
@@ -62,23 +62,15 @@
 #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/echo.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#if defined(_NET_CFG_BYTE_ORDER)
+#error "net/net.h included."
+#endif
 
 #ifdef USE_TCP_ECHO_SRV1
@@ -100,10 +92,22 @@
  */
 
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait は標準で 60秒 */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
 //#define CLS_TMO		TMO_FEVR	/* Close Wait は標準で 60秒 */
-#define CLS_TMO		(70*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*10)
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
 //#define RCV_TMO		TMO_FEVR
-#define RCV_TMO		(30*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*30)
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
 //#define SND_TMO		TMO_FEVR
-#define SND_TMO		(40*SYSTIM_HZ+(net_rand()%SYSTIM_HZ)*20)
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
 
 /*
@@ -121,223 +125,236 @@
 #endif
 
+#ifndef USE_TCP_NON_BLOCKING
+
 /*
  *  変数
  */
 
-/*
- *  注意:
- *
- *    BUF_SIZE は TCP の
- *    送信ウインドウバッファサイズ + 受信ウインドウバッファサイズの 
- *    3/2 倍以上の大きさがなければ、デッドロックする可能性がある。
- */
-
-#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
-                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
-
-static T_IPEP		dst;			/* 接続相手		*/
-
-#ifdef USE_TCP_NON_BLOCKING
-
-static char		buffer[BUF_SIZE];
-static ER		nblk_error = E_OK;
-static ER_UINT		nblk_slen  = 0;
-static ER_UINT		nblk_rlen  = 0;
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#ifdef USE_COPYSAVE_API
-
-#else	/* of #ifdef USE_COPYSAVE_API */
-
-static char		buffer[BUF_SIZE];
-
-#endif	/* of #ifdef USE_COPYSAVE_API */
-
-#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#ifdef USE_TCP_NON_BLOCKING
-
-/*
- *  ノンブロッキングコールのコールバック関数
- */
-
-ER
-callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+#ifdef USE_TCP_EXTENTIONS
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[NUM_TCP_ECHO_SRV_TASKS];
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	{ TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	{ TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  tcp_passive_open -- 受動オープンを実行する。
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
 {
-	ER	error = E_OK;
-
-	switch (fncd) {
-
-	case TFN_TCP_ACP_CEP:
-		nblk_error = *(ER*)p_parblk;
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
-
-	case TFN_TCP_RCV_DAT:
-		if ((nblk_rlen = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] recv error: %s", cepid, itron_strerror(nblk_rlen));
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
-
-	case TFN_TCP_SND_DAT:
-		if ((nblk_slen = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] send error: %s", cepid, itron_strerror(nblk_slen));
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
-
-	case TFN_TCP_CLS_CEP:
-		if ((nblk_error = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] close error: %s", cepid, itron_strerror(nblk_error));
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
-
-	case TFN_TCP_RCV_BUF:
-		if ((nblk_rlen = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] rbuf error: %s", cepid, itron_strerror(nblk_rlen));
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
-
-	case TFN_TCP_GET_BUF:
-		if ((nblk_slen = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] sbuf error: %s", cepid, itron_strerror(nblk_slen));
-		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-		break;
+	ER		error = E_OK;
+
+#if TNUM_TCP4_REPID > 0
+	T_IPV4EP	dst4;
+#endif
+
+	if (apip == API_PROTO_IPV6) {
+
+#if TNUM_TCP6_REPID > 0
+
+		/* 受付口は IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+			return error;
 
 #ifdef USE_TCP_EXTENTIONS
-
-	case TEV_TCP_RCV_OOB:
-		if ((nblk_rlen = *(ER*)p_parblk) < 0)
-			syslog(LOG_NOTICE, "[TES:%02d OOB] callback error: %s", cepid, itron_strerror(nblk_rlen));
-		else if (nblk_rlen > 0) {
-			char ch;
-
-			if ((nblk_rlen = tcp_rcv_oob(cepid, &ch, sizeof(ch))) > 0)
-				syslog(LOG_NOTICE, "[TES:%02d OOB] recv oob: 0x%02x", cepid, ch);
-			else if (nblk_rlen < 0)
-				syslog(LOG_NOTICE, "[TES:%02d OOB] recv error: %s", cepid, itron_strerror(nblk_rlen));
-			}
-		break;
-
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
 
-	case TFN_TCP_CON_CEP:
-	case TFN_TCP_SND_OOB:
-	default:
-		error = E_PAR;
-		break;
-		}
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+
+		}
+	else {
+
+#if TNUM_TCP4_REPID > 0
+
+		/* 受付口は IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
+			return error;
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+
+		}
+
 	return error;
 	}
 
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  tcp_passive_open -- 受動オープンを実行する。
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+		return error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
 #ifdef USE_COPYSAVE_API
 
-static ER
-tcp_echo_srv (ID cepid, ID repid)
+/*
+ *  tcp_echo_srv -- TCP エコーサーバ
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ *    USE_COPYSAVE_API		ON
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
 {
-	ER		error;
+	ER		error = E_OK;
+	ER_UINT		rblen, sblen;
 	SYSTIM		now;
 	uint32_t	total;
-	uint16_t	rblen, sblen, rlen, slen, soff, scount, rcount;
-	char		*rbuf, *sbuf, head, tail;
-
-	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
+	uint16_t	rlen, slen, soff, scount, rcount;
+	char		*rbuf, *sbuf;
+
+#ifdef SHOW_RCV_RANGE
+	char		head, tail;
+#endif
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
 		return error;
 		}
 
-	/* 相手から接続されるまで待つ。*/
-	syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-	if (nblk_error == E_OK) {
-		syscall(get_tim(&now));
-		syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
-		                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-		}
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
 	else {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error));
-		return nblk_error;
-		}
-
-#ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
-	rlen = scount = rcount = total = 0;
+		T_IN4_ADDR	addr;
+
+		addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	scount = rcount = total = 0;
 	while (true) {
-		if ((error = tcp_rcv_buf(cepid, (void**)&rbuf, TMO_NBLK)) != E_WBLK) {
-			syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", cepid, itron_strerror(error));
+		if ((rblen = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, RCV_TMO)) <= 0) {
+			if (rblen != E_OK)
+				syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(rblen));
 			break;
 			}
 
-		/* 受信するまで待つ。*/
-		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-		if (nblk_rlen < 0) {	/* エラー */
-			syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s", 
-			                   cepid, itron_strerror(nblk_rlen));
-			break;
-			}
-		else if (nblk_rlen == 0)	/* 受信終了 */
-			break;
-
-		rblen = nblk_rlen;
-
-		/* バッファの残りにより、受信長を調整する。*/
-		if (rblen > BUF_SIZE - rlen)
-			rblen = BUF_SIZE - rlen;
-		total += rblen;
-		rlen   = rblen;
-
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
 		head = *rbuf;
 		tail = *(rbuf + rblen - 1);
-		rcount ++;
-
-#ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TES:%02d RCV] "
-		                   "rcount: %4d, len: %4d, data %02x -> %02x",
-		                   cepid, rcount, rblen, head, tail);
+
+		//syslog(LOG_NOTICE, "[TES%c:%02u RCV] len:   %7lu",
+		//                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)rblen);
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %7lu, len: %6lu, data %02x -> %02x",
+		                   apip, tcp_echo_srv_info[six].cepid, rcount, (uint16_t)rblen, head, tail);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
-		memcpy(buffer, rbuf, rblen);
-
-		if ((error = tcp_rel_buf(cepid, rlen)) < 0) {
-			syslog(LOG_NOTICE, "[TES:%02d REL] error: %s",
-			                   cepid, itron_strerror(error));
-			break;
-			}
-
+		rlen   = (uint16_t)rblen;
+		total +=     rblen;
 		soff = 0;
 		while (rlen > 0) {
 
-			if ((error = tcp_get_buf(cepid, (void**)&sbuf, TMO_NBLK)) != E_WBLK) {
-				syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
-				                   cepid, itron_strerror(error));
+			if ((sblen = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(sblen));
 				goto err_fin;
 				}
 
-			/* 送信バッファの獲得が完了するまで待つ。*/
-			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-			if (nblk_slen < 0) {
-				syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
-				                   cepid, itron_strerror(nblk_slen));
-				goto err_fin;
-				}
-
-			sblen = nblk_slen;
+			//syslog(LOG_NOTICE, "[TES%c:%02u SND] len:   %7lu",
+			//                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)sblen);
 			scount ++;
-			slen = sblen < rlen ? sblen : rlen;
-			memcpy(sbuf, buffer + soff, slen);
-
-			if ((error = tcp_snd_buf(cepid, slen)) != E_OK) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
-				                   cepid, itron_strerror(error));
+			slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
+			memcpy(sbuf, rbuf + soff, slen);
+			if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
 				goto err_fin;
 				}
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d",
-			                   cepid, scount, slen);
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+			                   apip, tcp_echo_srv_info[six].cepid, scount, slen);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
@@ -345,86 +362,103 @@
 			soff += slen;
 			}
+
+		if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rblen)) < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s",
+			                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
 		}
 err_fin:
 
 #ifdef USE_TCP_SHT_CEP
-	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
 #endif	/* of #ifdef USE_TCP_SHT_CEP */
 
-	if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
-		syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
-
-	/* 開放が完了するまで待つ。*/
-	syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, CLS_TMO)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
 
 	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
-	                   cepid, now / SYSTIM_HZ, scount, rcount, total);
-
-	return error == E_WBLK ? E_OK : error;
+#if 1
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+#else
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu, error: %s",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total, itron_strerror(error));
+#endif
+
+	return error;
 	}
 
 #else	/* of #ifdef USE_COPYSAVE_API */
 
-static ER
-tcp_echo_srv (ID cepid, ID repid)
+/*
+ *  tcp_echo_srv -- TCP エコーサーバ
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ *    USE_COPYSAVE_API		OFF
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
 {
+	ID		cepid;
+	ER		error = E_OK;
+	ER_UINT		rlen, slen;
 	SYSTIM		now;
-	ER		error;
 	uint32_t	total;
-	uint16_t	rlen, slen, soff, scount, rcount;
-	char		head, tail;
-
-	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
+	uint16_t	soff, scount, rcount;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
 		return error;
 		}
-
-	/* 相手から接続されるまで待つ。*/
-	syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-	if (nblk_error == E_OK) {
-		syscall(get_tim(&now));
-		syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
-		                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-		}
-	else {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(nblk_error));
-		return nblk_error;
-		}
-
-#ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
+	
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else	{
+		T_IN4_ADDR	addr;
+
+		addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	cepid =  tcp_echo_srv_info[six].cepid;
 	scount = rcount = total = 0;
 	while (true) {
-		if ((error = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
-			syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
-			                   cepid, itron_strerror(error));
+		if ((rlen = tcp_rcv_dat(cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {
+			if (rlen != E_OK)
+				syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+				                   apip, cepid, itron_strerror(rlen));
 			break;
 			}
 
-		/* 受信完了まで待つ。*/
-		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-		if (nblk_rlen < 0) {
-			syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
-			                   cepid, itron_strerror(nblk_rlen));
-			break;
-			}
-		else if (nblk_rlen == 0)
-			break;
-
-		rlen = nblk_rlen;
-		head = *buffer;
-		tail = *(buffer + rlen - 1);
 		rcount ++;
-
 #ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
-		                   cepid, rcount, rlen, head, tail);
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x",
+		                   apip, cepid, rcount,
+		                   (uint16_t)rlen, * tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer,
+		                                   *(tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer + rlen - 1));
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
@@ -433,24 +467,12 @@
 		while (rlen > 0) {
 			scount ++;
-			if ((error = tcp_snd_dat(cepid, &buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
-				                   cepid, itron_strerror(error));
+			if ((slen = tcp_snd_dat(cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+				                   apip, cepid, itron_strerror(slen));
 				goto err_fin;
 				}
-
-			/* 送信完了まで待つ。*/
-			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
-
-			if (nblk_slen < 0) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
-				                   cepid, itron_strerror(nblk_slen));
-				goto err_fin;
-				}
-
-			slen = nblk_slen;
-
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d",
-			                   cepid, scount, slen);
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+			                   apip, cepid, scount, (uint16_t)slen);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
 
@@ -463,301 +485,24 @@
 #ifdef USE_TCP_SHT_CEP
 	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s", 
+		                    apip, cepid, itron_strerror(error));
 #endif	/* of #ifdef USE_TCP_SHT_CEP */
 
-	if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
-		syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
-
-	/* 開放が完了するまで待つ。*/
-	syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+	if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+		                   apip, cepid, itron_strerror(error));
 
 	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
-	                   cepid, now / SYSTIM_HZ, scount, rcount, total);
-
-	return error == E_WBLK ? E_OK : error;
-	}
-
-#endif	/* of #ifdef USE_COPYSAVE_API */
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#ifdef USE_COPYSAVE_API
-
-static ER
-tcp_echo_srv (ID cepid, ID repid)
-{
-	ER_UINT		rblen, sblen;
-	SYSTIM		now;
-	ER		error;
-	uint32_t	total;
-	uint16_t	rlen, slen, soff, scount, rcount;
-	char		*rbuf, *sbuf, head, tail;
-
-	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-#ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
-	scount = rcount = total = 0;
-	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
-	                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-	while (true) {
-		if ((rblen = tcp_rcv_buf(cepid, (void**)&rbuf, RCV_TMO)) <= 0) {
-			if (rblen != E_OK)
-				syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
-				                   cepid, itron_strerror(rblen));
-			break;
-			}
-
-		head = *rbuf;
-		tail = *(rbuf + rblen - 1);
-		rcount ++;
-
-		//syslog(LOG_NOTICE, "[TES:%02d RCV] len: %4d", cepid, (uint16_t)rblen);
-#ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
-		       cepid, rcount, (uint16_t)rblen, head, tail);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-		rlen   = (uint16_t)rblen;
-		total +=     rblen;
-		soff = 0;
-		while (rlen > 0) {
-
-			if ((sblen = tcp_get_buf(cepid, (void**)&sbuf, SND_TMO)) < 0) {
-				syslog(LOG_NOTICE, "[TES:%02d GET] error: %s",
-				                   cepid, itron_strerror(sblen));
-				goto err_fin;
-				}
-
-			//syslog(LOG_NOTICE, "[TES:%02d SND] len: %4d", cepid, (uint16_t)sblen);
-			scount ++;
-			slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
-			memcpy(sbuf, rbuf + soff, slen);
-			if ((error = tcp_snd_buf(cepid, slen)) != E_OK) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
-				                   cepid, itron_strerror(error));
-				goto err_fin;
-				}
-#ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, slen);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-			rlen -= slen;
-			soff += slen;
-			}
-
-		if ((error = tcp_rel_buf(cepid, rblen)) < 0) {
-			syslog(LOG_NOTICE, "[TES:%02d REL] error: %s", cepid, itron_strerror(error));
-			break;
-			}
-		}
-err_fin:
-
-#ifdef USE_TCP_SHT_CEP
-	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_SHT_CEP */
-
-	if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
-
-	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
-	                   cepid, now / SYSTIM_HZ, scount, rcount, total);
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, cepid, now / SYSTIM_HZ, total);
 
 	return error;
 	}
 
-#else	/* of #ifdef USE_COPYSAVE_API */
-
-/*
- *  tcp_echo_srv -- TCP エコーサーバ
- */
-
-static ER
-tcp_echo_srv (ID cepid, ID repid)
-{
-	ER_UINT		rlen, slen;
-	ER		error = E_OK;
-	SYSTIM		now;
-	uint32_t	total;
-	uint16_t	soff, scount, rcount;
-
-	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-#ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
-	scount = rcount = total = 0;
-	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6lu, from: %s.%u",
-	                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-	while (true) {
-		if ((rlen = tcp_rcv_dat(cepid, buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {
-			if (rlen != E_OK)
-				syslog(LOG_NOTICE, "[TES:%02d RCV] error: %s",
-				                   cepid, itron_strerror(rlen));
-			break;
-			}
-
-		rcount ++;
-#ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TES:%02d RCV] rcount: %4d, len: %4d, data %02x -> %02x",
-		       cepid, rcount, (uint16_t)rlen, *buffer, *(buffer + rlen - 1));
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-		total += rlen;
-		soff = 0;
-		while (rlen > 0) {
-			scount ++;
-			if ((slen = tcp_snd_dat(cepid, &buffer[soff], rlen, SND_TMO)) < 0) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] error: %s",
-				                   cepid, itron_strerror(slen));
-				goto err_fin;
-				}
-#ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d SND] scount: %4d, len: %4d", cepid, scount, (uint16_t)slen);
-#endif	/* of #ifdef SHOW_RCV_RANGE */
-
-			rlen -= slen;
-			soff += slen;
-			}
-		}
-err_fin:
-
-#ifdef USE_TCP_SHT_CEP
-	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d SHT] error: %s", cepid, itron_strerror(error));
-#endif	/* of #ifdef USE_TCP_SHT_CEP */
-
-	if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
-		syslog(LOG_NOTICE, "[TES:%02d CLS] error: %s", cepid, itron_strerror(error));
-
-	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d FIN] finished:   %6lu, snd: %4u, rcv: %4u, len: %lu",
-	                   cepid, now / SYSTIM_HZ, scount, rcount, total);
-
-	return error;
-	}
-
 #endif	/* of #ifdef USE_COPYSAVE_API */
 
-#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#ifdef USE_TCP_EXTENTIONS
-
-/*
- *  get_tcp_rep -- TCP 受付口を獲得する。
- */
-
-static ER
-get_tcp_rep (ID *repid)
-{
-	ID		tskid;
-	T_TCP_CREP	crep;
-
-	get_tid(&tskid);
-
-	crep.repatr = UINT_C(0);
-	crep.myaddr.portno = UINT_C(7);
-
-#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);
-	}
-
-/*
- *  get_tcp_cep -- TCP 通信端点とを獲得する。
- */
-
-static ER
-get_tcp_cep (ID *cepid)
-{
-	ID		tskid;
-	T_TCP_CCEP	ccep;
-
-	get_tid(&tskid);
-
-	ccep.cepatr = UINT_C(0);
-	ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE;
-	ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE;
-
-#ifdef TCP_CFG_SWBUF_CSAVE
-	ccep.sbuf = NADR;
-#else
-	ccep.sbuf = tcp_echo_srv_swbuf;
-#endif
-#ifdef TCP_CFG_RWBUF_CSAVE
-	ccep.rbuf = NADR;
-#else
-	ccep.rbuf = tcp_echo_srv_rwbuf;
-#endif
-#ifdef USE_TCP_NON_BLOCKING
-	ccep.callback = (FP)callback_nblk_tcp_echo_srv;
-#else
-	ccep.callback = NULL;
-#endif
-
-	return alloc_tcp_cep(cepid, tskid, &ccep);
-	}
-
-/*
- *  tcp_echo_srv_task -- TCP エコーサーバタスク
- */
-
-void
-tcp_echo_srv_task (intptr_t exinf)
-{
-	ID	tskid, cepid, repid;
-	ER	error = E_OK;
-
-	syscall(get_tid(&tskid));
-	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid);
-	while (true) {
-
-		syscall(slp_tsk());
-		if ((error = get_tcp_cep (&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TES:00 EXT] CEP create error: %s", itron_strerror(error));
-			continue;
-			}
-
-		while (true) {
-
-			if ((error = get_tcp_rep (&repid)) != E_OK) {
-				syslog(LOG_NOTICE, "[TES:00 EXT] REP create error: %s", itron_strerror(error));
-				break;
-				}
-			else if ((error = tcp_echo_srv(cepid, repid)) != E_OK) {
-				error = free_tcp_rep(repid, error != E_DLT);
-				break;
-				}
-			}
-
-		if ((error = free_tcp_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
-
-		}
-	}
-
-#else	/* of #ifdef USE_TCP_EXTENTIONS */
+#endif	/* of #ifndef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_TCP_EXTENTIONS
 
 /*
@@ -768,18 +513,46 @@
 tcp_echo_srv_task(intptr_t exinf)
 {
-	ID	tskid;
+	ID	tskid, cepid;
 	ER	error;
+	uint_t	six;
+	char	apip;
+
+	six = INDEX_SRV_INFO((ID)exinf);
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	if (six >= NUM_TCP4_ECHO_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+	apip = API_PROTO_IPV4;
+
+#endif	/* of #if defined(SUPPORT_INET6) */
 
 	syscall(get_tid(&tskid));
-	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	cepid = tcp_echo_srv_info[six].cepid;
+	syslog(LOG_NOTICE, "[TCP%c ECHO SRV:%d,%d] started.", apip, tskid, cepid);
+
 	while (true) {
-		while ((error = tcp_echo_srv((ID)exinf, TCP_ECHO_SRV_REPID)) == E_OK)
+		while ((error = tcp_echo_srv(six, apip)) == E_OK)
 			;
-		syslog(LOG_NOTICE, "[TES:%02d] goto sleep 60[s], error: %s", (ID)exinf, itron_strerror(error));
-		tslp_tsk(60 * 1000);
+		syslog(LOG_NOTICE, "[TES%c:%02u TSK] sleep 60[s], error: %s", apip, cepid, itron_strerror(error));
+		tslp_tsk(60 * 1000 * 1000);
+		syslog(LOG_NOTICE, "[TES%c:%02u TSK] resume.", apip, cepid);
 		}
 	}
 
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
 
 #endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.cfg	(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
  *
@@ -41,9 +41,7 @@
 /* タスク */
 
-#ifdef USE_TCP_EXTENTIONS
-
-CRE_TSK(TCP_ECHO_SRV_TASK,  {
+CRE_TSK(TCP_ECHO_SRV_TASK1,  {
 	TA_HLNG | TA_ACT,
-	0,
+	1,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -52,22 +50,9 @@
 	});
 
-#else	/* of #ifdef USE_TCP_EXTENTIONS */
-
-CRE_TSK(TCP_ECHO_SRV_TASK,  {
-	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID1,
-	tcp_echo_srv_task,
-	TCP_ECHO_SRV_MAIN_PRIORITY,
-	TCP_ECHO_SRV_STACK_SIZE,
-	NULL
-	});
-
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
 #if NUM_TCP_ECHO_SRV_TASKS >= 2
 
 CRE_TSK(TCP_ECHO_SRV_TASK2,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID2,
+	2,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -82,5 +67,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK3,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID3,
+	3,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -95,5 +80,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK4,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID4,
+	4,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -108,5 +93,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK5,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID5,
+	5,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -121,5 +106,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK6,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID6,
+	6,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -134,5 +119,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK7,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID7,
+	7,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -147,5 +132,5 @@
 CRE_TSK(TCP_ECHO_SRV_TASK8,  {
 	TA_HLNG | TA_ACT,
-	TCP_ECHO_SRV_CEPID8,
+	8,
 	tcp_echo_srv_task,
 	TCP_ECHO_SRV_MAIN_PRIORITY,
@@ -160,5 +145,27 @@
 #ifdef USE_TCP_NON_BLOCKING
 
-CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY1,	{ TA_TPRI, 0, 1 });
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY2,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY3,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY4,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY5,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY6,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY7,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY8,	{ TA_TPRI, 0, 1 });
+#endif
 
 #endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1.h	(revision 331)
@@ -0,0 +1,135 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV1
+
+#ifndef _TCP_ECHO_SRV1_H_
+#define _TCP_ECHO_SRV1_H_
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(512)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  ã¿ã¹ã¯æ°
+ */
+
+#ifndef NUM_TCP_ECHO_SRV_TASKS
+#define NUM_TCP_ECHO_SRV_TASKS		1
+#endif
+
+/* IPv4 ç¨ã® TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯ã¯ 1åã«å¶éããã*/
+
+#ifdef  NUM_TCP4_ECHO_SRV_TASKS
+#undef  NUM_TCP4_ECHO_SRV_TASKS
+#endif
+#define NUM_TCP4_ECHO_SRV_TASKS		1
+
+/*
+ *  å¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+extern uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+extern uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	tcp_echo_srv_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER wakeup_tcp_echo_srv (char apip);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV1_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_ext.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_ext.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_ext.c	(revision 331)
@@ -0,0 +1,381 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+#define USE_TCP_SHT_CEP
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR	/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  å¤æ°
+ */
+
+typedef struct t_tcp_echo_srv_task_info {
+	ID	taskid;		/* ã¿ã¹ã¯ ID		*/
+	bool_t	active;		/* åä½ç¶æ
+		*/
+	char	apip;		/* API IPãã­ãã³ã«	*/
+	} T_TCP_ECHO_SRV_TASK_INFO;
+
+static T_TCP_ECHO_SRV_TASK_INFO tcp_echo_srv_task_info[NUM_TCP_ECHO_SRV_TASKS] = {
+
+				{ TCP_ECHO_SRV_TASK1, false },
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+				{ TCP_ECHO_SRV_TASK2, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+				{ TCP_ECHO_SRV_TASK3, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+				{ TCP_ECHO_SRV_TASK4, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+				{ TCP_ECHO_SRV_TASK5, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+				{ TCP_ECHO_SRV_TASK6, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+				{ TCP_ECHO_SRV_TASK7, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+				{ TCP_ECHO_SRV_TASK8, false },
+#endif
+
+			};
+
+/*
+ *  get_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+get_tcp_rep (ID *repid, char apip)
+{
+	ID		tskid;
+	T_TCP6_CREP	crep6;
+	T_TCP_CREP	crep4;
+
+	get_tid(&tskid);
+	if (apip == API_PROTO_IPV6) {
+		crep6.repatr = UINT_C(0);
+		crep6.myaddr.portno = UINT_C(7);
+		memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+		return alloc_tcp6_rep(repid, tskid, &crep6);
+		}
+	else {
+		crep4.repatr = UINT_C(0);
+		crep4.myaddr.portno = UINT_C(7);
+		crep4.myaddr.ipaddr = IPV4_ADDRANY;
+		return alloc_tcp4_rep(repid, tskid, &crep4);
+		}
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+get_tcp_rep (ID *repid, char apip)
+{
+	ID		tskid;
+	T_TCPN_CREP	crep;
+
+	get_tid(&tskid);
+
+	crep.repatr = UINT_C(0);
+	crep.myaddr.portno = UINT_C(7);
+
+#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
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  get_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+static ER
+get_tcp_cep (ID *cepid, char apip)
+{
+	ID		tskid;
+	T_TCP_CCEP	ccep;
+
+	get_tid(&tskid);
+
+	ccep.cepatr = UINT_C(0);
+	ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE;
+	ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	ccep.sbuf = NADR;
+#else
+	ccep.sbuf = tcp_echo_srv_swbuf;
+#endif
+#ifdef TCP_CFG_RWBUF_CSAVE
+	ccep.rbuf = NADR;
+#else
+	ccep.rbuf = tcp_echo_srv_rwbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+	ccep.callback = (FP)callback_nblk_tcp_echo_srv;
+#else
+	ccep.callback = NULL;
+#endif
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		return alloc_tcp6_cep(cepid, tskid, &ccep);
+	else
+		return alloc_tcp4_cep(cepid, tskid, &ccep);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	}
+
+/*
+ *  wakeup_tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯ã®ä¼æ­¢è§£é¤
+ */
+
+ER
+wakeup_tcp_echo_srv (char apip)
+{
+	int	ix;
+
+	for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; )
+		if (!tcp_echo_srv_task_info[ix].active) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] wake up.",
+			                   apip, tcp_echo_srv_task_info[ix].taskid);
+			tcp_echo_srv_task_info[ix].apip   = apip;
+			tcp_echo_srv_task_info[ix].active = true;
+			return syscall(wup_tsk(tcp_echo_srv_task_info[ix].taskid));
+			}
+	syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] wake up error: %s.",
+			   apip, tcp_echo_srv_task_info[ix].taskid, itron_strerror(E_ID));
+	return E_ID;
+	}
+
+/*
+ *  tcp_echo_srv_task -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+tcp_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+	int	ix;
+	char	apip;
+
+	syscall(get_tid(&tskid));
+	syslog(LOG_NOTICE, "[TCPn ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+		syslog(LOG_NOTICE, "[TCPn ECHO SRV(EXT):%d] goto sleep.", tskid);
+		syscall(slp_tsk());
+
+		for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; ) {
+			if (tcp_echo_srv_task_info[ix].taskid == tskid) {
+				break;
+				}
+			}
+
+		apip = tcp_echo_srv_task_info[ix].apip;
+		if ((error = get_tcp_cep(&tcp_echo_srv_info[ix].cepid, apip)) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] create CEP error: %s",
+		                           apip, tskid, itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			if ((error = get_tcp_rep(&tcp_echo_srv_info[ix].repid, apip)) != E_OK) {
+				syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] create REP error: %s",
+		                                   apip, tskid, itron_strerror(error));
+				break;
+				}
+			else if ((error = tcp_echo_srv(ix, apip)) != E_OK) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (apip == API_PROTO_IPV6)
+					error = free_tcp6_rep(tcp_echo_srv_info[ix].repid, error != E_DLT);
+				else
+					error = free_tcp4_rep(tcp_echo_srv_info[ix].repid, error != E_DLT);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				error = FREE_TCP_REP(tcp_echo_srv_info[ix].repid, error != E_DLT);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (error != E_OK) {
+					syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] delete REP error: %s",
+		                                           apip, tskid, itron_strerror(error));
+					}
+
+				break;
+				}
+			}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		if (apip == API_PROTO_IPV6)
+			error = free_tcp6_cep(tcp_echo_srv_info[ix].cepid);
+		else
+			error = free_tcp4_cep(tcp_echo_srv_info[ix].cepid);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		error = FREE_TCP_CEP(tcp_echo_srv_info[ix].cepid);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if (error != E_OK) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] delete CEP error: %s",
+		                           apip, tskid, itron_strerror(error));
+			}
+
+		for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; ) {
+			if (tcp_echo_srv_task_info[ix].taskid == tskid) {
+				tcp_echo_srv_task_info[ix].active = false;
+				break;
+				}
+			}
+
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_nblk.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_nblk.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_nblk.c	(revision 331)
@@ -0,0 +1,656 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+#define USE_TCP_SHT_CEP
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR	/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY2 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY3 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY4 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY5 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY6 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY7 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY8 },
+#endif
+
+	};
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	{ TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	{ TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY2 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY3 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY4 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY5 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY6 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY7 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY8 },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  find_srv_info -- æ¥ç¶ç¸æã®æ
+å ±æ§é ä½ãæ¢ç´¢ããã
+ */
+
+static 
+T_TCP_ECHO_SRV_INFO *find_srv_info (ID cepid)
+{
+	T_TCP_ECHO_SRV_INFO	*ri;
+
+	for (ri = &tcp_echo_srv_info[sizeof(tcp_echo_srv_info) / sizeof(T_TCP_ECHO_SRV_INFO)]; ri --; )
+		if (ri->cepid == cepid)
+			return ri;
+	return NULL;
+	}
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER		error = E_OK;
+	T_TCP_ECHO_SRV_INFO	*ri;
+
+	if ((ri = find_srv_info(cepid)) == NULL) {
+		syslog(LOG_NOTICE, "[TESn:%02u CBN] CEPID not found", cepid);
+		return E_PAR;
+		}
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		ri->error = *(ER*)p_parblk;
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->rlen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_SND_DAT:
+		if ((ri->slen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->slen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if ((ri->error = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->error));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_RCV_BUF:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->rlen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_GET_BUF:
+		if ((ri->slen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->slen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+#ifdef USE_TCP_EXTENTIONS
+
+	case TEV_TCP_RCV_OOB:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u OOB] error: %s", cepid, itron_strerror(ri->rlen));
+		else if (ri->rlen > 0) {
+			char ch;
+
+			if ((ri->rlen = tcp_rcv_oob(cepid, &ch, sizeof(ch))) > 0)
+				syslog(LOG_NOTICE, "[TESn:%02u OOB] recv oob: 0x%02x", cepid, ch);
+			else if (ri->rlen < 0)
+				syslog(LOG_NOTICE, "[TESn:%02u OOB] error: %s", cepid, itron_strerror(ri->rlen));
+			}
+		break;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error;
+	T_IPV4EP	dst4;
+
+	if (apip == API_PROTO_IPV6) {
+		/* åä»å£ã¯ IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_NBLK)) != E_WBLK)
+			return error;
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(info->semid));
+
+		if (info->error != E_OK)
+			return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	else {
+		/* åä»å£ã¯ IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_NBLK)) != E_WBLK)
+			return error;
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(info->semid));
+
+		if (info->error != E_OK)
+			return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+		}
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_NBLK)) != E_WBLK)
+		return error;
+
+	/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(info->semid));
+
+	if (info->error != E_OK)
+		return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return E_OK;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#ifdef USE_COPYSAVE_API
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ *    USE_COPYSAVE_API		ON
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	T_IN4_ADDR	ipv4addr;
+#endif
+	ER		error;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	rblen, sblen, rlen, slen, soff, scount, rcount;
+	char		*rbuf, *sbuf, head, tail;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else {
+		ipv4addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &ipv4addr),
+		                   tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	rlen = scount = rcount = total = 0;
+	while (true) {
+		if ((error = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		/* åä¿¡ããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+		if (tcp_echo_srv_info[six].rlen < 0) {	/* ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s", 
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].rlen));
+			break;
+			}
+		else if (tcp_echo_srv_info[six].rlen == 0)	/* åä¿¡çµäº */
+			break;
+
+		rblen = tcp_echo_srv_info[six].rlen;
+
+		/* ãããã¡ã®æ®ãã«ãããåä¿¡é·ãèª¿æ´ããã*/
+		if (rblen > BUF_SIZE - rlen)
+			rblen = BUF_SIZE - rlen;
+		total += rblen;
+		rlen   = rblen;
+
+		head = *rbuf;
+		tail = *(rbuf + rblen - 1);
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] "
+		                   "rcount: %7lu, len: %6lu, data %02x -> %02x",
+	                           apip, tcp_echo_srv_info[six].cepid, rcount, rblen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		memcpy(tcp_echo_srv_info[six].buffer, rbuf, rblen);
+
+		if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rlen)) < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		soff = 0;
+		while (rlen > 0) {
+
+			if ((error = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+
+			/* éä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+			if (tcp_echo_srv_info[six].slen < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].slen));
+				goto err_fin;
+				}
+
+			sblen = tcp_echo_srv_info[six].slen;
+			scount ++;
+			slen = sblen < rlen ? sblen : rlen;
+			memcpy(sbuf, tcp_echo_srv_info[six].buffer + soff, slen);
+
+			if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %7lu, len: %4u",
+	                                   apip, cepid, scount, slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, TMO_NBLK)) != E_WBLK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+
+	/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+
+	return error == E_WBLK ? E_OK : error;
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ *    USE_COPYSAVE_API		OFF
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+	T_IN4_ADDR	ipv4addr;
+	ER		error;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, scount, rcount;
+	char		head, tail;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else {
+		ipv4addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &ipv4addr),
+		                   tcp_echo_srv_info[six].dst.portno);
+		}
+
+	scount = rcount = total = 0;
+	while (true) {
+		if ((error = tcp_rcv_dat(tcp_echo_srv_info[six].cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		/* åä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+		if (tcp_echo_srv_info[six].rlen < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].rlen));
+			break;
+			}
+		else if (tcp_echo_srv_info[six].rlen == 0)
+			break;
+
+		rlen = tcp_echo_srv_info[six].rlen;
+		head = * tcp_echo_srv_info[six].buffer;
+		tail = *(tcp_echo_srv_info[six].buffer + rlen - 1);
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x",
+	                           apip, tcp_echo_srv_info[six].cepid, rcount, rlen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		total += rlen;
+		soff = 0;
+		while (rlen > 0) {
+			scount ++;
+			if ((error = tcp_snd_dat(tcp_echo_srv_info[six].cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+
+			/* éä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+			if (tcp_echo_srv_info[six].slen < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].slen));
+				goto err_fin;
+				}
+
+			slen = tcp_echo_srv_info[six].slen;
+
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+	                                   apip, tcp_echo_srv_info[six].cepid, scount, slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, TMO_NBLK)) != E_WBLK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+
+	/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+
+	return error == E_WBLK ? E_OK : error;
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv1_var.h	(revision 331)
@@ -0,0 +1,111 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV1
+
+#ifndef _TCP_ECHO_SRV1_VAR_H_
+#define _TCP_ECHO_SRV1_VAR_H_
+
+/*
+ *  æ³¨æ:
+ *
+ *    BUF_SIZE ã¯ TCP ã®
+ *    éä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãº + åä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãºã® 
+ *    3/2 åä»¥ä¸ã®å¤§ããããªããã°ããããã­ãã¯ããå¯è½æ§ãããã
+ */
+
+#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
+                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
+
+/*
+ *  ãµã¼ãæ
+å ±æ§é ä½
+ */
+
+typedef struct t_tcp_echo_srv_info {
+	ID	cepid;		/* éä¿¡ç«¯ç¹ ID		*/
+	ID	repid;		/* åä»å£   ID		*/
+
+#ifdef USE_TCP_NON_BLOCKING
+	ID	semid;		/* NBLK ç¨ ã»ããã©ID	*/
+	ER	error;		/* NBLK ç¨ error	*/
+	ER_UINT	slen;		/* NBLK ç¨ éä¿¡ãã¼ã¿æ°	*/
+	ER_UINT	rlen;		/* NBLK ç¨ åä¿¡ãã¼ã¿æ°	*/
+#endif
+
+	T_IPEP	dst;		/* æ¥ç¶ç¸æã¢ãã¬ã¹æ
+å ±	*/
+
+#ifdef USE_TCP_NON_BLOCKING
+
+	char	buffer[BUF_SIZE];
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_COPYSAVE_API
+	char	buffer[BUF_SIZE];
+#endif
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+	} T_TCP_ECHO_SRV_INFO;
+
+#define INDEX_SRV_INFO(id)	((id)-1)
+
+/*
+ *  å¤æ°
+ */
+
+extern T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[];
+
+/*
+ *  é¢æ°
+ */
+
+extern ER tcp_echo_srv (uint_t six, char apip);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV1_VAR_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.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
  *
@@ -70,10 +70,9 @@
 #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/echo.h>
+#include <netapp/tcp_echo_srv2.h>
 
 #ifdef USE_TCP_ECHO_SRV2
@@ -161,9 +160,9 @@
 			snd_error = 1;
 			ena_rcv   = true;
-			syslog(LOG_NOTICE, "[TES:%02d CBN] connected:  %6ld, from: %s.%d",
+			syslog(LOG_NOTICE, "[TES:%02u CBN] connect: %6lu, from: %s.%d",
 			                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 			}
 		else
-			syslog(LOG_NOTICE, "[TES:%02d CBN] accept error: %s\n", cepid, itron_strerror(rcv_error));
+			syslog(LOG_NOTICE, "[TES:%02u CBN] accept error: %s\n", cepid, itron_strerror(rcv_error));
 
 		syscall(sig_sem(SEM_TCP_ECHO_SRV_RCV_READY));
@@ -176,5 +175,5 @@
 			tail = *(sptr + slen - 1);
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d CBN] send len: %4d, data %02x -> %02x",
+			syslog(LOG_NOTICE, "[TES:%02u CBN] send len: %4u, data %02x -> %02x",
 			                   cepid, (uint16_t)slen, head, tail);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -205,5 +204,5 @@
 			}
 		else {
-			syslog(LOG_NOTICE, "[TES:%02d CBN] send error = %s", cepid, itron_strerror(snd_error));
+			syslog(LOG_NOTICE, "[TES:%02u CBN] send error = %s", cepid, itron_strerror(snd_error));
 			sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
 			}
@@ -216,5 +215,5 @@
 			tail = *(rptr + rlen - 1);
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d CBN] recv len: %4d, data %02x -> %02x",
+			syslog(LOG_NOTICE, "[TES:%02u CBN] recv len: %4u, data %02x -> %02x",
 			                   cepid, (uint16_t)rlen, head, tail);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -246,5 +245,5 @@
 		else {
 			if (rlen < 0)
-				syslog(LOG_NOTICE, "[TES:%02d CBN] recv error = %s", cepid, itron_strerror(rcv_error));
+				syslog(LOG_NOTICE, "[TES:%02u CBN] recv error = %s", cepid, itron_strerror(rcv_error));
 			sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
 			}
@@ -254,7 +253,7 @@
 		snd_error = *(ER*)p_parblk;
 		if (snd_error != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d CBN] close error = %s", cepid, itron_strerror(snd_error));
-
-		syslog(LOG_NOTICE, "[TES:%02d CBN] finished:   %6ld, snd: %4d, rcv: %4d, len: %ld",
+			syslog(LOG_NOTICE, "[TES:%02u CBN] close error = %s", cepid, itron_strerror(snd_error));
+
+		syslog(LOG_NOTICE, "[TES:%02u CBN] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
 		                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
 
@@ -283,10 +282,10 @@
 
 	if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d RCV] sync error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
 		return error;
 		}
 
 	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] accept error = %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error));
 		return error;
 		}
@@ -300,6 +299,6 @@
 
 #ifdef USE_TCP_EXTENTIONS
-	if ((error = free_tcp_rep(repid, true)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
 		return error;
 		}
@@ -318,5 +317,5 @@
 		/* 受信する。*/
 		if ((error = tcp_rcv_dat(cepid, rptr, blen, TMO_NBLK)) != E_WBLK) {
-			syslog(LOG_NOTICE, "[TES:%02d RCV] recv error = %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s", cepid, itron_strerror(error));
 			break;
 			}
@@ -359,5 +358,5 @@
 	while (true) {
 		if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TES:%02d SND] sync error: %s",
+			syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
 			                   cepid, itron_strerror(error));
 			continue;
@@ -387,5 +386,5 @@
 			/* 送信する。*/
 			if ((error = tcp_snd_dat(cepid, sptr, blen, TMO_NBLK)) != E_WBLK) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] send error = %s", cepid, itron_strerror(error));
+				syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(error));
 				break;
 				}
@@ -398,9 +397,9 @@
 #ifdef USE_TCP_SHT_CEP
 		if ((error = tcp_sht_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d SND] shutdown error = %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u SND] shutdown error = %s", cepid, itron_strerror(error));
 #endif	/* of #ifdef USE_TCP_SHT_CEP */
 
 		if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) {
-			syslog(LOG_NOTICE, "[TES:%02d SND] close error = %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
 			}
 
@@ -426,16 +425,16 @@
 
 	if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d RCV] sync error: %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
 		return error;
 		}
 
 	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_NOTICE, "[TES:%02d ACP] accept error = %s", cepid, itron_strerror(error));
+		syslog(LOG_NOTICE, "[TES:%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, "[TES:%02d DEL] REP delete error: %s", cepid, itron_strerror(error));
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
 		return error;
 		}
@@ -443,5 +442,5 @@
 
 	syscall(get_tim(&now));
-	syslog(LOG_NOTICE, "[TES:%02d ACP] connected:  %6ld, from: %s.%d",
+	syslog(LOG_NOTICE, "[TES:%02u ACP] connect: %6lu, from: %s.%d",
 	                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 	sptr = rptr = buffer;
@@ -461,5 +460,5 @@
 		if ((rlen = tcp_rcv_dat(cepid, rptr, blen, TMO_FEVR)) <= 0) {
 			if (rlen < 0)
-				syslog(LOG_NOTICE, "[TES:%02d RCV] recv error = %s",
+				syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s",
 				                   cepid, itron_strerror(rlen));
 			break;
@@ -468,5 +467,5 @@
 		tail = *(rptr + rlen - 1);
 #ifdef SHOW_RCV_RANGE
-		syslog(LOG_NOTICE, "[TES:%02d RCV] len: %4d, data %02x -> %02x",
+		syslog(LOG_NOTICE, "[TES:%02u RCV] len: %4u, data %02x -> %02x",
 		                   cepid, (uint16_t)rlen, head, tail);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -531,5 +530,5 @@
 	while (true) {
 		if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[TES:%02d SND] sync error: %s",
+			syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
 			                   cepid, itron_strerror(error));
 			continue;
@@ -554,5 +553,5 @@
 
 			if ((slen = tcp_snd_dat(cepid, sptr, blen, TMO_FEVR)) <= 0) {
-				syslog(LOG_NOTICE, "[TES:%02d SND] send error = %s", cepid, itron_strerror(slen));
+				syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(slen));
 				break;
 				}
@@ -561,5 +560,5 @@
 			tail = *(sptr + slen - 1);
 #ifdef SHOW_RCV_RANGE
-			syslog(LOG_NOTICE, "[TES:%02d SND] len: %4d, data %02x -> %02x",
+			syslog(LOG_NOTICE, "[TES:%02u SND] len: %4u, data %02x -> %02x",
 			                   cepid, (uint16_t)slen, head, tail);
 #endif	/* of #ifdef SHOW_RCV_RANGE */
@@ -602,12 +601,12 @@
 #ifdef USE_TCP_SHT_CEP
 		if ((error = tcp_sht_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d SND] shtudown error = %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u SND] shtudown error = %s", cepid, itron_strerror(error));
 #endif	/* of #ifdef USE_TCP_SHT_CEP */
 
 		if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d SND] close error = %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
 
 		get_tim(&now);
-		syslog(LOG_NOTICE, "[TES:%02d SND] finished:   %6ld, snd: %4d, rcv: %4d, len: %ld",
+		syslog(LOG_NOTICE, "[TES:%02u SND] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
 		                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
 
@@ -646,5 +645,5 @@
 #endif
 
-	return alloc_tcp_rep(repid, tskid, &crep);
+	return ALLOC_TCP_REP(repid, tskid, &crep);
 	}
 
@@ -681,5 +680,5 @@
 #endif
 
-	return alloc_tcp_cep(cepid, tskid, &ccep);
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
 	}
 
@@ -711,5 +710,5 @@
 				}
 			else if ((error = tcp_echo_srv_rcv(cepid, repid)) != E_OK) {
-				error = free_tcp_rep(repid, error != E_DLT);
+				error = FREE_TCP_REP(repid, error != E_DLT);
 				break;
 				}
@@ -717,5 +716,5 @@
 
 		if ((error = free_tcp_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[TES:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
+			syslog(LOG_NOTICE, "[TES:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
 
 		}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tcp_echo_srv2.h	(revision 331)
@@ -0,0 +1,127 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV2
+
+#ifndef _TCP_ECHO_SRV2_H_
+#define _TCP_ECHO_SRV2_H_
+
+/* 
+ *  TCP ECHO ãµã¼ã #2
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åé¢å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»IPv4/IPv6
+ */
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(512)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/* ã¿ã¹ã¯æ° */
+
+#if defined(USE_TCP_ECHO_SRV2)
+#if defined(NUM_TCP_ECHO_SRV_TASKS)
+#undef  NUM_TCP_ECHO_SRV_TASKS
+#endif	/* of #if defined(NUM_TCP_ECHO_SRV_TASKS) */
+#define NUM_TCP_ECHO_SRV_TASKS		1
+#endif	/* of #if defined(USE_TCP_ECHO_SRV2) */
+
+/*
+ *  å¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+extern uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+extern uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	tcp_echo_srv_rcv_task(intptr_t exinf);
+extern void	tcp_echo_srv_snd_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV2_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV2 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dbg_cons.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dbg_cons.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dbg_cons.cfg	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (UDP/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
  *
@@ -43,69 +43,69 @@
 /* TCP 受付口 */
 
+#ifdef SUPPORT_INET6
+
+#if NUM_VRID_TCP6_REPS >= 1
+VRID_TCP6_REP (TCP6_RSV_REPID1);
+#endif
+
+#if NUM_VRID_TCP6_REPS >= 2
+VRID_TCP6_REP (TCP6_RSV_REPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
-#if NUM_VRID_TCP_REPS >= 1
-VRID_TCP_REP (TCP_RSV_REPID1);
+#if NUM_VRID_TCP4_REPS >= 1
+VRID_TCP_REP (TCP4_RSV_REPID1);
 #endif
 
-#if NUM_VRID_TCP_REPS >= 2
-VRID_TCP_REP (TCP_RSV_REPID2);
+#if NUM_VRID_TCP4_REPS >= 2
+VRID_TCP_REP (TCP4_RSV_REPID2);
 #endif
 
 #endif	/* of #ifdef SUPPORT_INET4 */
 
+/* TCP 通信端点 */
+
 #ifdef SUPPORT_INET6
 
-#if NUM_VRID_TCP_REPS >= 1
-VRID_TCP6_REP (TCP_RSV_REPID1);
+#if NUM_VRID_TCP6_CEPS >= 1
+VRID_TCP6_CEP (TCP6_RSV_CEPID1);
 #endif
 
-#if NUM_VRID_TCP_REPS >= 2
-VRID_TCP6_REP (TCP_RSV_REPID2);
+#if NUM_VRID_TCP6_CEPS >= 2
+VRID_TCP6_CEP (TCP6_RSV_CEPID2);
+#endif
+
+#if NUM_VRID_TCP6_CEPS >= 3
+VRID_TCP6_CEP (TCP6_RSV_CEPID3);
+#endif
+
+#if NUM_VRID_TCP6_CEPS >= 4
+VRID_TCP6_CEP (TCP6_RSV_CEPID4);
 #endif
 
 #endif	/* of #ifdef SUPPORT_INET6 */
 
-/* TCP 通信端点 */
-
 #ifdef SUPPORT_INET4
 
-#if NUM_VRID_TCP_CEPS >= 1
-VRID_TCP_CEP (TCP_RSV_CEPID1);
+#if NUM_VRID_TCP4_CEPS >= 1
+VRID_TCP_CEP (TCP4_RSV_CEPID1);
 #endif
 
-#if NUM_VRID_TCP_CEPS >= 2
-VRID_TCP_CEP (TCP_RSV_CEPID2);
+#if NUM_VRID_TCP4_CEPS >= 2
+VRID_TCP_CEP (TCP4_RSV_CEPID2);
 #endif
 
-#if NUM_VRID_TCP_CEPS >= 3
-VRID_TCP_CEP (TCP_RSV_CEPID3);
+#if NUM_VRID_TCP4_CEPS >= 3
+VRID_TCP_CEP (TCP4_RSV_CEPID3);
 #endif
 
-#if NUM_VRID_TCP_CEPS >= 4
-VRID_TCP_CEP (TCP_RSV_CEPID4);
+#if NUM_VRID_TCP4_CEPS >= 4
+VRID_TCP_CEP (TCP4_RSV_CEPID4);
 #endif
 
 #endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-#if NUM_VRID_TCP_CEPS >= 1
-VRID_TCP6_CEP (TCP_RSV_CEPID1);
-#endif
-
-#if NUM_VRID_TCP_CEPS >= 2
-VRID_TCP6_CEP (TCP_RSV_CEPID2);
-#endif
-
-#if NUM_VRID_TCP_CEPS >= 3
-VRID_TCP6_CEP (TCP_RSV_CEPID3);
-#endif
-
-#if NUM_VRID_TCP_CEPS >= 4
-VRID_TCP6_CEP (TCP_RSV_CEPID4);
-#endif
-
-#endif	/* of #ifdef SUPPORT_INET6 */
 
 #endif	/* of #ifdef USE_TCP_EXTENTIONS */
@@ -115,28 +115,28 @@
 /* UDP 通信端点 */
 
+#ifdef SUPPORT_INET6
+
+#if NUM_VRID_UDP6_CEPS >= 1
+VRID_UDP6_CEP (UDP6_RSV_CEPID1);
+#endif
+
+#if NUM_VRID_UDP6_CEPS >= 2
+VRID_UDP6_CEP (UDP6_RSV_CEPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
-#if NUM_VRID_UDP_CEPS >= 1
-VRID_UDP_CEP (UDP_RSV_CEPID1);
+#if NUM_VRID_UDP4_CEPS >= 1
+VRID_UDP_CEP (UDP4_RSV_CEPID1);
 #endif
 
-#if NUM_VRID_UDP_CEPS >= 2
-VRID_UDP_CEP (UDP_RSV_CEPID2);
+#if NUM_VRID_UDP4_CEPS >= 2
+VRID_UDP_CEP (UDP4_RSV_CEPID2);
 #endif
 
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-#if NUM_VRID_UDP_CEPS >= 1
-VRID_UDP6_CEP (UDP_RSV_CEPID1);
-#endif
-
-#if NUM_VRID_UDP_CEPS >= 2
-VRID_UDP6_CEP (UDP_RSV_CEPID2);
-#endif
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifdef USE_UDP_EXTENTIONS */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp4_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp4_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp4_cli.cfg	(revision 331)
@@ -0,0 +1,61 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+UDP_CRE_CEP (UDP4_DHCP_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, DHCP4_CLI_CFG_PORTNO },
+	callback_nblk_dhcp4_cli
+	} );
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp6_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp6_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_dhcp6_cli.cfg	(revision 331)
@@ -0,0 +1,61 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCP/DHCPv6 ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+UDP6_CRE_CEP (UDP6_DHCP_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, DHCP6_CLI_CFG_PORTNO },
+	callback_nblk_dhcp6_cli
+	} );
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_net_cons.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_net_cons.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_net_cons.cfg	(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
  *
@@ -41,4 +41,13 @@
 /* TCP 受付口 */
 
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (NET_CONS_REPID, {
+	0,
+	{ IPV6_ADDRANY, 23 }
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
@@ -50,14 +59,35 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_REP (NET_CONS_REPID, {
-	0,
-	{ IPV6_ADDRANY, 23 }
-	} );
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
 /* TCP 通信端点 */
+
+#ifdef SUPPORT_INET6
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+TCP6_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	NADR,
+	NET_CONS_SWBUF_SIZE,
+	NADR,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+TCP6_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	net_cons_swbuf,
+	NET_CONS_SWBUF_SIZE,
+	net_cons_rwbuf,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#else	/* of #ifdef SUPPORT_INET6 */
 
 #ifdef SUPPORT_INET4
@@ -89,30 +119,4 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-#ifdef TCP_CFG_SWBUF_CSAVE
-
-TCP6_CRE_CEP (NET_CONS_CEPID, {
-	0,
-	NADR,
-	NET_CONS_SWBUF_SIZE,
-	NADR,
-	NET_CONS_RWBUF_SIZE,
-	callback_nblk_net_cons
-	} );
-
-#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
-
-TCP6_CRE_CEP (NET_CONS_CEPID, {
-	0,
-	net_cons_swbuf,
-	NET_CONS_SWBUF_SIZE,
-	net_cons_rwbuf,
-	NET_CONS_RWBUF_SIZE,
-	callback_nblk_net_cons
-	} );
-
-#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_resolver.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_resolver.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_resolver.cfg	(revision 331)
@@ -0,0 +1,75 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  RESOLVER ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+UDP6_CRE_CEP (UDP6_RESOLVER_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+UDP_CRE_CEP (UDP4_RESOLVER_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1.cfg	(revision 331)
@@ -0,0 +1,488 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg	(revision 331)
@@ -0,0 +1,486 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1.cfg	(revision 331)
@@ -0,0 +1,362 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP åä»å£
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS == 1
+ * 
+ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+/*
+ * TCP åä»å£
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (TCP_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV6_ADDRANY, 7 }
+	} );
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+TCP_CRE_REP (TCP4_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+TCP_CRE_REP (TCP_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+/*
+ * TCP éä¿¡ç«¯ç¹
+ *
+ * å®ç¾©ãã TCP éä¿¡ç«¯ç¹ï¼TCP?_ECHO_SRV_CEPID1ï¼ã®é¸æ
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     â    â     â          Ã         TCP4
+ *     â    â     Ã          TCP        Ã
+ *     â    Ã     â          TCP        Ã
+ *     â    Ã     Ã          TCP        Ã
+ *     Ã    â     â          Ã         TCP
+ *     Ã    â     Ã          Ã         TCP
+ *     Ã    Ã     â          Ã         Ã
+ *     Ã    Ã     Ã          Ã         Ã
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP4_ECHO_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg	(revision 331)
@@ -0,0 +1,320 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS == 1
+ * 
+ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+/*
+ * TCP éä¿¡ç«¯ç¹
+ *
+ * å®ç¾©ãã TCP éä¿¡ç«¯ç¹ï¼TCP?_ECHO_SRV_CEPID1ï¼ã®é¸æ
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     â    â     â          Ã         TCP4
+ *     â    â     Ã          TCP        Ã
+ *     â    Ã     â          TCP        Ã
+ *     â    Ã     Ã          TCP        Ã
+ *     Ã    â     â          Ã         TCP
+ *     Ã    â     Ã          Ã         TCP
+ *     Ã    Ã     â          Ã         Ã
+ *     Ã    Ã     Ã          Ã         Ã
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP4_ECHO_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1.cfg	(revision 331)
@@ -0,0 +1,482 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg	(revision 331)
@@ -0,0 +1,482 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_cli.cfg	(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
  *
@@ -43,4 +43,62 @@
 /* TCP 通信端点 */
 
+#ifdef SUPPORT_INET6
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
@@ -50,5 +108,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
+	TA_NULL,
 	NADR,
 	TCP_DISCARD_CLI_SWBUF_SIZE,
@@ -61,5 +119,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
+	TA_NULL,
 	tcp_discard_cli_swbuf,
 	TCP_DISCARD_CLI_SWBUF_SIZE,
@@ -76,5 +134,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
+	TA_NULL,
 	NADR,
 	TCP_DISCARD_CLI_SWBUF_SIZE,
@@ -87,5 +145,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
+	TA_NULL,
 	tcp_discard_cli_swbuf,
 	TCP_DISCARD_CLI_SWBUF_SIZE,
@@ -101,60 +159,4 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-#ifdef USE_TCP_NON_BLOCKING
-
-#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
-
-TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_DISCARD_CLI_SWBUF_SIZE,
-	NADR,
-	0,
-	callback_nblk_tcp_discard_cli
-	} );
-
-#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
-
-TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
-	tcp_discard_cli_swbuf,
-	TCP_DISCARD_CLI_SWBUF_SIZE,
-	NADR,
-	0,
-	callback_nblk_tcp_discard_cli
-	} );
-
-#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
-
-TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_DISCARD_CLI_SWBUF_SIZE,
-	NADR,
-	0,
-	NULL
-	} );
-
-#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
-
-TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
-	0,
-	tcp_discard_cli_swbuf,
-	TCP_DISCARD_CLI_SWBUF_SIZE,
-	NADR,
-	0,
-	NULL
-	} );
-
-#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
-
-#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_srv.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_discard_srv.cfg	(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
  *
@@ -42,8 +42,17 @@
 /* TCP 受付口 */
 
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {
+	TA_NULL,
+	{ IPV6_ADDRANY, 9 }
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
 TCP_CRE_REP (TCP_DISCARD_SRV_REPID, {
-	0,
+	TA_NULL,
 	{ IPV4_ADDRANY, 9 }
 	} );
@@ -51,14 +60,35 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {
-	0,
-	{ IPV6_ADDRANY, 9 }
-	} );
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
 /* TCP 通信端点 */
+
+#ifdef SUPPORT_INET6
+
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	NADR,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	tcp_discard_srv_rwbuf,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef SUPPORT_INET6 */
 
 #ifdef SUPPORT_INET4
@@ -67,5 +97,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
-	0,
+	TA_NULL,
 	NADR,
 	0,
@@ -78,5 +108,5 @@
 
 TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
-	0,
+	TA_NULL,
 	NADR,
 	0,
@@ -90,30 +120,4 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
-
-TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
-	0,
-	NADR,
-	0,
-	NADR,
-	TCP_DISCARD_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
-
-TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
-	0,
-	NADR,
-	0,
-	tcp_discard_srv_rwbuf,
-	TCP_DISCARD_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_cli.cfg	(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
  *
@@ -43,6 +43,124 @@
 /* TCP 通信端点 */
 
+#ifdef SUPPORT_INET6
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
 #ifdef SUPPORT_INET4
 
+#ifdef USE_TCP4_ECHO_CLI
+
 #ifdef USE_TCP_NON_BLOCKING
 
@@ -51,42 +169,42 @@
 #if defined(TCP_CFG_RWBUF_CSAVE)
 
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	tcp_echo_cli_rwbuf,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	tcp_echo_cli_swbuf,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
 	0,
 	tcp_echo_cli_swbuf,
@@ -107,42 +225,42 @@
 #if defined(TCP_CFG_RWBUF_CSAVE)
 
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	tcp_echo_cli_rwbuf,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	tcp_echo_cli_swbuf,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
 	0,
 	tcp_echo_cli_swbuf,
@@ -159,7 +277,11 @@
 #endif	/* of #ifdef USE_TCP_NON_BLOCKING */
 
+#endif	/* of #ifdef USE_TCP4_ECHO_CLI */
+
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
 
 #ifdef USE_TCP_NON_BLOCKING
@@ -169,42 +291,42 @@
 #if defined(TCP_CFG_RWBUF_CSAVE)
 
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	tcp_echo_cli_rwbuf,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	tcp_echo_cli_swbuf,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	callback_nblk_tcp_echo_cli
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
 	0,
 	tcp_echo_cli_swbuf,
@@ -225,42 +347,42 @@
 #if defined(TCP_CFG_RWBUF_CSAVE)
 
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	NADR,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	tcp_echo_cli_rwbuf,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
-	0,
-	tcp_echo_cli_swbuf,
-	TCP_ECHO_CLI_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_CLI_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
 	0,
 	tcp_echo_cli_swbuf,
@@ -277,4 +399,6 @@
 #endif	/* of #ifdef USE_TCP_NON_BLOCKING */
 
+#endif	/* of #ifdef SUPPORT_INET4 */
+
 #endif	/* of #ifdef SUPPORT_INET6 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_srv.cfg	(revision 321)
+++ 	(revision )
@@ -1,1122 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/*
- *  TCP ECHO サーバの TCP/IP コンフィギュレーションファイル
- */
-
-#if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2)
-
-#ifndef USE_TCP_EXTENTIONS
-
-/* TCP 受付口 */
-
-#ifdef SUPPORT_INET4
-
-TCP_CRE_REP (TCP_ECHO_SRV_REPID, {
-	0,
-	{ IPV4_ADDRANY, 7 }
-	} );
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_REP (TCP_ECHO_SRV_REPID, {
-	0,
-	{ IPV6_ADDRANY, 7 }
-	} );
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-/* TCP 通信端点 */
-
-#ifdef SUPPORT_INET4
-
-#ifdef USE_TCP_NON_BLOCKING
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[0],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf[0],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf[0],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[0],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#ifdef USE_TCP_ECHO_SRV1
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 2
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[1],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	tcp_echo_srv_swbuf[1],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	tcp_echo_srv_swbuf[1],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[1],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 3
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[2],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	tcp_echo_srv_swbuf[2],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	tcp_echo_srv_swbuf[2],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[2],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 4
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[3],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	tcp_echo_srv_swbuf[3],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	tcp_echo_srv_swbuf[3],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[3],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 5
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[4],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	tcp_echo_srv_swbuf[4],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	tcp_echo_srv_swbuf[4],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[4],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 6
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[5],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	tcp_echo_srv_swbuf[5],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	tcp_echo_srv_swbuf[5],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[5],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 7
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[6],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	tcp_echo_srv_swbuf[6],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	tcp_echo_srv_swbuf[6],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[6],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 8
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[7],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	tcp_echo_srv_swbuf[7],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	tcp_echo_srv_swbuf[7],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[7],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
-
-#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
-
-#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-#ifdef USE_TCP_NON_BLOCKING
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	callback_nblk_tcp_echo_srv
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#else	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[0],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf[0],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
-	0,
-	tcp_echo_srv_swbuf[0],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[0],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#ifdef USE_TCP_ECHO_SRV1
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 2
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[1],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	tcp_echo_srv_swbuf[1],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
-	0,
-	tcp_echo_srv_swbuf[1],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[1],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 3
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[2],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	tcp_echo_srv_swbuf[2],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
-	0,
-	tcp_echo_srv_swbuf[2],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[2],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 4
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[3],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	tcp_echo_srv_swbuf[3],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
-	0,
-	tcp_echo_srv_swbuf[3],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[3],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 5
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[4],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	tcp_echo_srv_swbuf[4],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
-	0,
-	tcp_echo_srv_swbuf[4],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[4],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 6
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[5],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	tcp_echo_srv_swbuf[5],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
-	0,
-	tcp_echo_srv_swbuf[5],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[5],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 7
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[6],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	tcp_echo_srv_swbuf[6],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
-	0,
-	tcp_echo_srv_swbuf[6],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[6],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
-
-#if NUM_TCP_ECHO_SRV_TASKS >= 8
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	NADR,
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[7],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	tcp_echo_srv_swbuf[7],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	NADR,
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
-	0,
-	tcp_echo_srv_swbuf[7],
-	TCP_ECHO_SRV_SWBUF_SIZE,
-	tcp_echo_srv_rwbuf[7],
-	TCP_ECHO_SRV_RWBUF_SIZE,
-	NULL 
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
-
-#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
-
-#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#endif	/* of #ifndef USE_TCP_EXTENTIONS */
-
-#endif	/* of #if defined(USE_TCP_ECHO_SRV1) || defined(USE_TCP_ECHO_SRV2) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_srv2.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_srv2.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_tcp_echo_srv2.cfg	(revision 331)
@@ -0,0 +1,318 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_TCP_ECHO_SRV2)
+
+#ifndef USE_TCP_EXTENTIONS
+
+/* TCP åä»å£ */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (TCP_ECHO_SRV_REPID, {
+	0,
+	{ IPV6_ADDRANY, 7 }
+	} );
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+TCP_CRE_REP (TCP_ECHO_SRV_REPID, {
+	0,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #defined(USE_TCP_ECHO_SRV2) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_cli.cfg	(revision 331)
@@ -0,0 +1,89 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+#if !defined(USE_UDP_EXTENTIONS)
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	callback_nblk_udp4_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	callback_udp4_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_UDP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_srv.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp4_echo_srv.cfg	(revision 331)
@@ -0,0 +1,91 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ *  UDP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv4
+ */
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+#ifndef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	callback_nblk_udp4_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#ifdef USE_UDP_CALL_BACK
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	callback_udp4_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	NULL
+	} );
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#endif	/* of #ifndef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_cli.cfg	(revision 331)
@@ -0,0 +1,89 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if !defined(USE_UDP_EXTENTIONS)
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	callback_nblk_udp6_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	callback_udp6_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_UDP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_srv.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp6_echo_srv.cfg	(revision 331)
@@ -0,0 +1,91 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ *  UDP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv6
+ */
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+#ifndef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	callback_nblk_udp6_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#ifdef USE_UDP_CALL_BACK
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	callback_udp6_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	NULL
+	} );
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#endif	/* of #ifndef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_discard_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_discard_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_discard_cli.cfg	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (UDP/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
  *
@@ -43,4 +43,14 @@
 /* UDP 通信端点 */
 
+#ifdef SUPPORT_INET6
+
+UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, { 
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
 #ifdef SUPPORT_INET4
 
@@ -53,12 +63,4 @@
 #endif	/* of #ifdef SUPPORT_INET4 */
 
-#ifdef SUPPORT_INET6
-
-UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, { 
-	0,
-	{ IPV6_ADDRANY, UDP_PORTANY },
-	NULL
-	} );
-
 #endif	/* of #ifdef SUPPORT_INET6 */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_echo_cli.cfg	(revision 321)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/*
- *  TINET (UDP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/*
- *  UDP ECHO クライアント
- *  TCP/IP コンフィギュレーションファイル
- */
-
-#ifdef USE_UDP_ECHO_CLI
-
-#ifndef USE_UDP_EXTENTIONS
-
-/* UDP 通信端点 */
-
-#ifdef SUPPORT_INET4
-
-#ifdef USE_UDP_NON_BLOCKING
-
-UDP_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV4_ADDRANY, UDP_PORTANY },
-	callback_nblk_udp_echo_cli
-	} );
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#ifdef USE_UDP_CALL_BACK
-
-UDP_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV4_ADDRANY, UDP_PORTANY },
-	callback_udp_echo_cli
-	} );
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-UDP_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV4_ADDRANY, UDP_PORTANY },
-	NULL
-	} );
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-#ifdef USE_UDP_NON_BLOCKING
-
-UDP6_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV6_ADDRANY, UDP_PORTANY },
-	callback_nblk_udp_echo_cli
-	} );
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#ifdef USE_UDP_CALL_BACK
-
-UDP6_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV6_ADDRANY, UDP_PORTANY },
-	callback_udp_echo_cli
-	} );
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-UDP6_CRE_CEP (UDP_ECHO_CLI_CEPID, {
-	0,
-	{ IPV6_ADDRANY, UDP_PORTANY },
-	NULL
-	} );
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#endif	/* of #ifndef USE_UDP_EXTENTIONS */
-
-#endif	/* of #ifdef USE_UDP_ECHO_CLI */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_udp_echo_srv.cfg	(revision 321)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/*
- *  TINET (UDP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/*
- *  UDP ECHO サーバ
- *  UDP/IP コンフィギュレーションファイル
- */
-
-#ifdef USE_UDP_ECHO_SRV
-
-#ifndef USE_UDP_EXTENTIONS
-
-/* UDP 通信端点 */
-
-#ifdef SUPPORT_INET4
-
-#ifdef USE_UDP_NON_BLOCKING
-
-UDP_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV4_ADDRANY, 7 },
-	callback_nblk_udp_echo_srv
-	} );
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#ifdef USE_UDP_CALL_BACK
-
-UDP_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV4_ADDRANY, 7 },
-	callback_udp_echo_srv
-	} );
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-UDP_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV4_ADDRANY, 7 },
-	NULL
-	} );
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-#ifdef USE_UDP_NON_BLOCKING
-
-UDP6_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV6_ADDRANY, 7 },
-	callback_nblk_udp_echo_srv
-	} );
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#ifdef USE_UDP_CALL_BACK
-
-UDP6_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV6_ADDRANY, 7 },
-	callback_udp_echo_srv
-	} );
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-UDP6_CRE_CEP (UDP_ECHO_SRV_CEPID, {
-	0,
-	{ IPV6_ADDRANY, 7 },
-	NULL
-	} );
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#endif	/* of #ifndef USE_UDP_EXTENTIONS */
-
-#endif	/* of #ifdef USE_UDP_ECHO_SRV */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_wwws.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_wwws.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/tinet_wwws.cfg	(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
  *
@@ -34,13 +34,43 @@
 /*
  *  WWW サーバの TCP/IP コンフィギュレーションファイル
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP 受付口
+ *    TCP 通信端点
+ * 
  */
 
-#ifdef USE_WWW_SRV
-
-#ifndef USE_TCP_EXTENTIONS
-
-/* TCP 受付口 */
-
-#ifdef SUPPORT_INET4
+#if defined(USE_WWW_SRV)
+
+/*
+ * TCP 受付口
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (WWW_SRV_REPID, {
+	0,
+	{ IPV6_ADDRANY, 80 }
+	} );
+
+#if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+TCP_CRE_REP (WWW4_SRV_REPID, {
+	0,
+	{ IPV4_ADDRANY, 80 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6 */
+
+#if defined(SUPPORT_INET4)
 
 TCP_CRE_REP (WWW_SRV_REPID, {
@@ -49,18 +79,266 @@
 	} );
 
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-TCP6_CRE_REP (WWW_SRV_REPID, {
-	0,
-	{ IPV6_ADDRANY, 80 }
-	} );
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-/* TCP 通信端点 */
-
-#ifdef SUPPORT_INET4
+#endif	/* of #if defined(SUPPORT_INET4 */
+
+#endif	/* of #if defined(SUPPORT_INET6 */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS */
+
+/*
+ * TCP 通信端点
+ *
+ * 定義する TCP 通信端点（WWW?_CEPID1）の選択
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     ○    ○     ○          ×         WWW4
+ *     ○    ○     ×          WWW        ×
+ *     ○    ×     ○          WWW        ×
+ *     ○    ×     ×          WWW        ×
+ *     ×    ○     ○          ×         WWW
+ *     ×    ○     ×          ×         WWW
+ *     ×    ×     ○          ×         ×
+ *     ×    ×     ×          ×         ×
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_WWW4_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_WWW4_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_WWW4_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4 */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4 */
+
+#if NUM_WWW_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
 
 #if defined(TCP_CFG_SWBUF_CSAVE)
@@ -176,123 +454,7 @@
 #endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
 
-#endif	/* of #ifdef SUPPORT_INET4 */
-
-#ifdef SUPPORT_INET6
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (WWW_SRV_CEPID1, {
-	0,
-	NADR,
-	WWW_SRV_SWBUF_SIZE,
-	NADR,
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (WWW_SRV_CEPID1, {
-	0,
-	NADR,
-	WWW_SRV_SWBUF_SIZE,
-	www_srv_rwbuf[0],
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (WWW_SRV_CEPID1, {
-	0,
-	www_srv_swbuf[0],
-	WWW_SRV_SWBUF_SIZE,
-	NADR,
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (WWW_SRV_CEPID1, {
-	0,
-	www_srv_swbuf[0],
-	WWW_SRV_SWBUF_SIZE,
-	www_srv_rwbuf[0],
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if NUM_WWW_SRV_TASKS >= 2
-
-#if defined(TCP_CFG_SWBUF_CSAVE)
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (WWW_SRV_CEPID2, {
-	0,
-	NADR,
-	WWW_SRV_SWBUF_SIZE,
-	NADR,
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (WWW_SRV_CEPID2, {
-	0,
-	NADR,
-	WWW_SRV_SWBUF_SIZE,
-	www_srv_rwbuf[1],
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#if defined(TCP_CFG_RWBUF_CSAVE)
-
-TCP6_CRE_CEP (WWW_SRV_CEPID2, {
-	0,
-	www_srv_swbuf[1],
-	WWW_SRV_SWBUF_SIZE,
-	NADR,
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-TCP6_CRE_CEP (WWW_SRV_CEPID2, {
-	0,
-	www_srv_swbuf[1],
-	WWW_SRV_SWBUF_SIZE,
-	www_srv_rwbuf[1],
-	WWW_SRV_RWBUF_SIZE,
-	NULL
-	} );
-
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
-
-#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
-
-#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
-
-#endif	/* of #ifdef SUPPORT_INET6 */
-
-#endif	/* of #ifndef USE_TCP_EXTENTIONS */
-
-#endif	/* of #ifdef USE_WWW_SRV */
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_WWW_SRV) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.c	(revision 331)
@@ -0,0 +1,490 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP4 ECHO ã¯ã©ã¤ã¢ã³ã
+ */
+
+#include <string.h>
+
+#if defined(TARGET_KERNEL_ASP)
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+
+#if defined(TARGET_KERNEL_JSP)
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_cli.h>
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+/* echo ãµã¼ãã®ãã¼ãçªå· */
+
+#define ECHO_SRV_PORTNO		UINT_C(7)
+
+/* éä¿¡éé */
+
+#if defined(TOPPERS_S810_CLG3_85)
+
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+/* èªåå®è¡ */
+
+#if defined(UDP4_ECHO_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#define UDP4_ECHO_CLI_AUTO_RUN_STR	"172.25.193.140 - 1000"
+#endif
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t udp4_echo_cli_valid;
+
+/*
+ * å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+static char		udp_buf[BUF_SIZE];
+static T_IPV4EP		dst;
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+static ER_UINT		nblk_len;
+static ID		nblk_tskid;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	nblk_len = *(ER_UINT*)p_parblk;
+	syscall(wup_tsk(nblk_tskid));
+	return E_OK;
+	}
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	ER_UINT	error;
+	SYSTIM	time;
+	uint_t	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	get_tid(&nblk_tskid);
+	if ((error = udp_snd_dat(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(NBLK)] send:  %7lu,  to: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC4:%02u CBR(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+
+	if ((error = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+	else {
+		udp_buf[nblk_len] = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] recv:  %7lu,from: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		nblk_len = E_OK;
+		}
+
+	return nblk_len;
+	}
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	get_tim(&time);
+	if ((len = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
+		*(udp_buf + len) = '\0';
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(CB)] recv:  %7lu,from: %s.%d\n"
+		                   "                                  msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(CB)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°ä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len        = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC4:%02u SND(CB)] send:  %7lu,  to: %s.%d\n"
+	                   "                                  msg: %s",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0)
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(CB)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°æªä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC4:%02u SND] send:  %7lu,  to: %s.%d\n"
+	                   "                              msg: %s",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0) {
+		syslog(LOG_NOTICE, "[UEC4:%02u SND] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+
+	if ((len = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
+		*(udp_buf + len) = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		return E_OK;
+		}
+	else {
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV] error: %7lu,%s",
+		       cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#if defined(UDP4_ECHO_CLI_AUTO_RUN_STR)
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = UDP4_ECHO_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || count == 0) {
+		line = auto_run_str;
+		dly_tsk(6 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] error:%s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #if defined(UDP4_ECHO_CLI_AUTO_RUN_STR) */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u TSK] error:%s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #if defined(UDP4_ECHO_CLI_AUTO_RUN_STR) */
+
+#define MESSAGE_FORMAT	"MSG 1000000"
+
+/*
+ *  UDP4 ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+udp4_echo_cli_task (intptr_t exinf)
+{
+	static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
+
+	ID		tskid, cepid;
+	ER		error = E_OK;
+	SYSTIM		time;
+	T_IN4_ADDR	addr;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	T_IN6_ADDR	addr6;
+#endif
+
+	char		*line, *p;
+	int_t		rep;
+	uint32_t	count, msgno;
+	bool_t		retry = false;
+	uint16_t	portno = ECHO_SRV_PORTNO;
+
+#if defined(USE_UDP_EXTENTIONS)
+	T_UDP_CCEP	ccep;
+#endif
+
+	dly_tsk(10*1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		line = lookup_ipaddr(&addr6, line, API_PROTO_IPV4);
+		if (line == NULL || !in6_is_addr_ipv4mapped(&addr6)) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+		addr = ntohl(addr6.s6_addr32[3]);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if ((line = lookup_ipaddr(&addr, line, DEFAULT_API_PROTO)) == NULL) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else if (*line == '-')
+			line ++;
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UDP_PORTANY;
+
+#if defined(SUPPORT_INET6)
+
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+		ccep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+#if defined(USE_UDP_NON_BLOCKING)
+		ccep.callback = (FP)callback_nblk_udp4_echo_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		cepid = (ID)exinf;
+
+#endif/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {				/* Repeat */
+			line = get_int(&rep, line);
+#if 0
+			if (rep > 1000000)
+				rep = 1000000;
+#endif
+			udp4_echo_cli_valid = true;
+			count = 0;
+			while (rep == 0 || count < rep) {
+				if (!udp4_echo_cli_valid) {
+					syslog(LOG_NOTICE, "[UEC4:%02u TSK] canceled.", cepid);
+					break;
+					}
+					
+				count ++;
+				p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
+				for (msgno = count; msgno > 0; msgno /= 10)
+					*(-- p) = msgno % 10 + '0';
+				while (*(p - 2) != 'G')
+					*(-- p) = ' ';
+
+				if ((error = udp4_echo_cli(cepid, &addr, portno, msg)) != E_OK)
+					dly_tsk(30 * SYSTIM_HZ);
+
+				dly_tsk(25 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
+				}
+			}
+
+		else								/* Single Message */
+			error = udp4_echo_cli(cepid, &addr, portno, line);
+
+		if (error != E_OK) {
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[UEC4:%02u SND] error: %7lu,%s",
+			                   cepid, time / SYSTIM_HZ, itron_strerror(error));
+			}
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		if ((error = free_udp4_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.cfg	(revision 331)
@@ -0,0 +1,82 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP4_ECHO_CLI_TSK
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP4_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	udp4_echo_cli_task,
+	UDP4_ECHO_CLI_MAIN_PRIORITY,
+	UDP4_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP4_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP4_ECHO_CLI_CEPID,
+	udp4_echo_cli_task,
+	UDP4_ECHO_CLI_MAIN_PRIORITY,
+	UDP4_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_UDP4_ECHO_CLI,  { TA_TFIFO, 1, NULL });
+
+#endif	/* of #ifdef USE_UDP4_ECHO_CLI_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_cli.h	(revision 331)
@@ -0,0 +1,76 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP4_ECHO_CLI_H_
+#define _UDP4_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP4_ECHO_CLI_STACK_SIZE	1024		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv4ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP4_ECHO_CLI_MAIN_PRIORITY	5		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv4ï¼ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp4_echo_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp4_echo_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#ifdef T_IN4_ADDR_DEFINED
+extern ER udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line);
+#endif
+
+#endif	/* of #ifndef _UDP4_ECHO_CLI_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.c	(revision 331)
@@ -0,0 +1,315 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    IPv4
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_srv.h>
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+/*
+ *  åä¿¡ã¿ã¤ã ã¢ã¦ã
+ */
+
+#define RCV_TMOUT	TMO_FEVR
+//#define RCV_TMOUT	(30*ULONG_C(1000))
+
+#define BUF_SIZE	2048
+
+static char	echo_rcv_buf[BUF_SIZE];
+static T_IPV4EP	dst;
+
+#ifdef USE_UDP_CALL_BACK
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_FEVR)) >= 0) {
+		echo_rcv_buf[len] = '\0';
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u UCB] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES4:%02u UCB] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, len);
+			else
+				syslog(LOG_NOTICE, "[UES4:%02u UCB] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		len = E_OK;
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u UCB] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len;
+	}
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+static ER_UINT		nblk_len;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	now;
+
+	get_tim(&now);
+	nblk_len = *(ER_UINT*)p_parblk;
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UES4:%02u CBR] error,      %7lu,%s, fncd: %s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(nblk_len), in_strtfn(fncd));
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {
+		echo_rcv_buf[nblk_len] = '\0';
+		syslog(LOG_NOTICE, "[UES4:%02u CBR] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		}
+	syscall(wup_tsk(UDP4_ECHO_SRV_TASK));
+	return E_OK;
+	}
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp4_echo_srv (ID cepid)
+{
+	ER	error;
+	SYSTIM	now;
+
+	if ((error = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_NBLK)) != E_WBLK) {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	if (nblk_len < 0)
+		error = nblk_len;
+	else {
+		if ((error = udp_snd_dat(cepid, &dst, echo_rcv_buf, nblk_len, TMO_NBLK)) != E_WBLK) {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES4:%02u SND] error: %7lu,%s",
+			                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+			return error;
+			}
+
+		syscall(slp_tsk());
+		if (nblk_len < 0)
+			error = nblk_len;
+		else {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES4:%02u SND] send:  %7lu, len: %d",
+			                   cepid, now / SYSTIM_HZ, nblk_len);
+			error = E_OK;
+			}
+		}
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp4_echo_srv (ID cepid)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), RCV_TMOUT)) >= 0) {
+		get_tim(&now);
+		echo_rcv_buf[len] = '\0';
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES4:%02u SND] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, (uint16_t)len);
+			else
+				syslog(LOG_NOTICE, "[UES4:%02u SND] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len >= 0 || len == E_TMOUT ? E_OK : len;
+	}
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+void
+udp4_echo_srv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	T_UDP_CCEP	ccep;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		syslog(LOG_NOTICE, "[UDP4 ECHO SRV(EXT):%d] wake up.", tskid);
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UINT_C(7);
+		ccep.myaddr.ipaddr = IPV4_ADDRANY;
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp4_echo_srv;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UES4:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (error == E_OK) {
+			if ((error = udp4_echo_srv(cepid)) != E_OK) {
+				if ((error = free_udp4_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+					syslog(LOG_NOTICE, "[UES4:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+				break;
+				}
+			}
+
+		}
+	slp_tsk();
+	}
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+void
+udp4_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	while (error == E_OK) {
+		error = udp4_echo_srv((ID)exinf);
+		}
+	slp_tsk();
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.cfg	(revision 331)
@@ -0,0 +1,88 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv4
+ */
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_CALL_BACK
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP4_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	0,
+	udp4_echo_srv_task,
+	UDP4_ECHO_SRV_MAIN_PRIORITY,
+	UDP4_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP4_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	UDP4_ECHO_SRV_CEPID,
+	udp4_echo_srv_task,
+	UDP4_ECHO_SRV_MAIN_PRIORITY,
+	UDP4_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp4_echo_srv.h	(revision 331)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP4_ECHO_SRV_H_
+#define _UDP4_ECHO_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP4_ECHO_SRV_STACK_SIZE	1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPV4ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP4_ECHO_SRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPV4ï¼ã®åªå
+åº¦		*/
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp4_echo_srv_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP4_ECHO_SRV_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.c	(revision 331)
@@ -0,0 +1,460 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP6 ECHO ã¯ã©ã¤ã¢ã³ã
+ */
+
+#include <string.h>
+
+#if defined(TARGET_KERNEL_ASP)
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+
+#if defined(TARGET_KERNEL_JSP)
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_cli.h>
+#include <netapp/udp6_echo_cli.h>
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+/* echo ãµã¼ãã®ãã¼ãçªå· */
+
+#define ECHO_SRV_PORTNO		UINT_C(7)
+
+/* éä¿¡éé */
+
+#if defined(TOPPERS_S810_CLG3_85)
+
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+/* èªåå®è¡ */
+
+#if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#define UDP6_ECHO_CLI_AUTO_RUN_STR	"fe80::211:2fff:fe8a:e8c0 - 1000"
+#endif
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t udp6_echo_cli_valid;
+
+/*
+ * å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+static char		udp_buf[BUF_SIZE];
+static T_IPV6EP		dst;
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+static ER_UINT		nblk_len;
+static ID		nblk_tskid;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	nblk_len = *(ER_UINT*)p_parblk;
+	syscall(wup_tsk(nblk_tskid));
+	return E_OK;
+	}
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	ER_UINT	error;
+	SYSTIM	time;
+	uint_t	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	get_tid(&nblk_tskid);
+	if ((error = udp6_snd_dat(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u SDN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC6:%02u SDN] send:  %7lu,  to: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC6:%02u CBR] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+
+	if ((error = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+	else {
+		udp_buf[nblk_len] = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] recv:  %7lu,from: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		nblk_len = E_OK;
+		}
+
+	return nblk_len;
+	}
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	get_tim(&time);
+	if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
+		*(udp_buf + len) = '\0';
+		syslog(LOG_NOTICE, "[UEC6:%02u RVC)] recv:  %7lu,from: %s.%d\n"
+		                   "                                  msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC6:%02u RVC] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°ä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len        = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC6:%02u SDC)] send:  %7lu,  to: %s.%d\n"
+		           "                                  msg: %s",
+	                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0)
+		syslog(LOG_NOTICE, "[UEC6:%02u SDC] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°æªä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC6:%02u SND] send:  %7lu,  to: %s.%d\n"
+		           "                              msg: %s",
+	                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0) {
+		syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+
+	if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
+		*(udp_buf + len) = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		return E_OK;
+		}
+	else {
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RCV] error: %7lu,%s",
+		       cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = UDP6_ECHO_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || count == 0) {
+		line = auto_run_str;
+		dly_tsk(6 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
+
+#define MESSAGE_FORMAT	"MSG 1000000"
+
+/*
+ *  UDP6 ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+udp6_echo_cli_task (intptr_t exinf)
+{
+	static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
+
+	ID		tskid, cepid;
+	ER		error = E_OK;
+	SYSTIM		time;
+	T_IN6_ADDR	addr;
+	char		*line, *p;
+	int_t		rep;
+	uint32_t	count, msgno;
+	bool_t		retry = false;
+	uint16_t	portno = ECHO_SRV_PORTNO;
+
+#if defined(USE_UDP_EXTENTIONS)
+	T_UDP6_CCEP	ccep;
+#endif
+
+	dly_tsk(10*1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+		if ((line = lookup_ipaddr(&addr, line, API_PROTO_IPV6)) == NULL) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else if (*line == '-')
+			line ++;
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UDP_PORTANY;
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp6_echo_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else/* of #ifdef USE_UDP_EXTENTIONS */
+
+		cepid = (ID)exinf;
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {				/* Repeat */
+			line = get_int(&rep, line);
+#if 0
+			if (rep > 1000000)
+				rep = 1000000;
+#endif
+			udp6_echo_cli_valid = true;
+			count = 0;
+			while (rep == 0 || count < rep) {
+				if (!udp6_echo_cli_valid) {
+					syslog(LOG_NOTICE, "[UEC6:%02u TSK] canceled.", cepid);
+					break;
+					}
+					
+				count ++;
+				p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
+				for (msgno = count; msgno > 0; msgno /= 10)
+					*(-- p) = msgno % 10 + '0';
+				while (*(p - 2) != 'G')
+					*(-- p) = ' ';
+
+				if ((error = udp6_echo_cli(cepid, &addr, portno, msg)) != E_OK)
+					dly_tsk(30 * SYSTIM_HZ);
+
+				dly_tsk(25 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
+				}
+			}
+
+		else								/* Single Message */
+
+			error = udp6_echo_cli(cepid, &addr, portno, line);
+
+		if (error != E_OK) {
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
+			                   cepid, time / SYSTIM_HZ, itron_strerror(error));
+			}
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		if ((error = free_udp6_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.cfg	(revision 331)
@@ -0,0 +1,82 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP6_ECHO_CLI_TSK
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP6_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	udp6_echo_cli_task,
+	UDP6_ECHO_CLI_MAIN_PRIORITY,
+	UDP6_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP6_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP6_ECHO_CLI_CEPID,
+	udp6_echo_cli_task,
+	UDP6_ECHO_CLI_MAIN_PRIORITY,
+	UDP6_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_UDP6_ECHO_CLI,  { TA_TFIFO, 1, NULL });
+
+#endif	/* of #ifdef USE_UDP6_ECHO_CLI_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_cli.h	(revision 331)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP6_ECHO_CLI_H_
+#define _UDP6_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP6_ECHO_CLI_STACK_SIZE	1024		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv6ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP6_ECHO_CLI_MAIN_PRIORITY	5		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv6ï¼ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp6_echo_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp6_echo_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP6_ECHO_CLI_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.c	(revision 331)
@@ -0,0 +1,314 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    IPv6
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp6_echo_srv.h>
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+/*
+ *  åä¿¡ã¿ã¤ã ã¢ã¦ã
+ */
+
+#define RCV_TMOUT	TMO_FEVR
+//#define RCV_TMOUT	(30*ULONG_C(1000))
+
+#define BUF_SIZE	2048
+
+static char	echo_rcv_buf[BUF_SIZE];
+static T_IPV6EP	dst;
+
+#ifdef USE_UDP_CALL_BACK
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_FEVR)) >= 0) {
+		echo_rcv_buf[len] = '\0';
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u UCB] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp6_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES6:%02u UCB] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, len);
+			else
+				syslog(LOG_NOTICE, "[UES6:%02u UCB] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		len = E_OK;
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u UCB] recv:  %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len;
+	}
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+static ER_UINT		nblk_len;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	now;
+
+	get_tim(&now);
+	nblk_len = *(ER_UINT*)p_parblk;
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UES6:%02u CBR] error: %7lu,%s, fncd: %s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(nblk_len), in_strtfn(fncd));
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {
+		echo_rcv_buf[nblk_len] = '\0';
+		syslog(LOG_NOTICE, "[UES6:%02u CBR] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		}
+	syscall(wup_tsk(UDP6_ECHO_SRV_TASK));
+	return E_OK;
+	}
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp6_echo_srv (ID cepid)
+{
+	ER	error;
+	SYSTIM	now;
+
+	if ((error = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_NBLK)) != E_WBLK) {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] error: %7lu,%s", cepid, now / SYSTIM_HZ, itron_strerror(error));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	if (nblk_len < 0)
+		error = nblk_len;
+	else {
+		if ((error = udp6_snd_dat(cepid, &dst, echo_rcv_buf, nblk_len, TMO_NBLK)) != E_WBLK) {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES6:%02u SND] error  %7lu,%s",
+			                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+			return error;
+			}
+
+		syscall(slp_tsk());
+		if (nblk_len < 0)
+			error = nblk_len;
+		else {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES6:%02u SND] send:  %7lu, len: %d",
+			                   cepid, now / SYSTIM_HZ, nblk_len);
+			error = E_OK;
+			}
+		}
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp6_echo_srv (ID cepid)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), RCV_TMOUT)) >= 0) {
+		get_tim(&now);
+		echo_rcv_buf[len] = '\0';
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp6_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES6:%02u SND] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, (uint16_t)len);
+			else
+				syslog(LOG_NOTICE, "[UES6:%02u SND] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len >= 0 || len == E_TMOUT ? E_OK : len;
+	}
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+void
+udp6_echo_srv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	T_UDP6_CCEP	ccep;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		syslog(LOG_NOTICE, "[UDP6 ECHO SRV(EXT):%d] wake up.", tskid);
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UINT_C(7);
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp6_echo_srv;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UES6:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (error == E_OK) {
+			if ((error = udp6_echo_srv(cepid)) != E_OK) {
+				if ((error = free_udp6_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+					syslog(LOG_NOTICE, "[UES6:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+				break;
+				}
+			}
+
+		}
+	slp_tsk();
+	}
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+void
+udp6_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	while (error == E_OK) {
+		error = udp6_echo_srv((ID)exinf);
+		}
+	slp_tsk();
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.cfg	(revision 331)
@@ -0,0 +1,88 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv6
+ */
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_CALL_BACK
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP6_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	0,
+	udp6_echo_srv_task,
+	UDP6_ECHO_SRV_MAIN_PRIORITY,
+	UDP6_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP6_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	UDP6_ECHO_SRV_CEPID,
+	udp6_echo_srv_task,
+	UDP6_ECHO_SRV_MAIN_PRIORITY,
+	UDP6_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp6_echo_srv.h	(revision 331)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP6_ECHO_SRV_H_
+#define _UDP6_ECHO_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP6_ECHO_SRV_STACK_SIZE	1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPv6ï¼ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define UDP6_ECHO_SRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPv6ï¼ã®åªå
+åº¦			*/
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp6_echo_srv_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP6_ECHO_SRV_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.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
  *
@@ -56,25 +56,12 @@
 #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_var.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/udp.h>
-#include <netinet/udp_var.h>
-#include <netinet/in_itron.h>
 
 #include <netapp/netapp.h>
 #include <netapp/netapp_var.h>
-#include <netapp/discard.h>
+#include <netapp/udp_discard_cli.h>
 
 #ifdef USE_UDP_DISCARD_CLI
@@ -90,4 +77,10 @@
 #define PAT_BEGIN	' '
 #define PAT_END		'~'
+
+#if defined(SUPPORT_INET6)
+#define API_PROTO		'6'
+#else
+#define API_PROTO		'4'
+#endif
 
 /*
@@ -104,5 +97,9 @@
 send_udp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
 {
-	static char smsg[IF_MTU - IP_UDP_HDR_SIZE];
+#if defined(SUPPORT_INET6)
+	static char smsg[IPV6_MMTU - (IP6_HDR_SIZE + UDP_HDR_SIZE)];
+#else
+	static char smsg[IP4_MSS - (IP4_HDR_SIZE + UDP_HDR_SIZE)];
+#endif
 
 	T_IPEP		dst;
@@ -117,29 +114,29 @@
 
 	p = smsg;
-	for (slen = IF_MTU - IP_UDP_HDR_SIZE; slen > 0; )
+	for (slen = sizeof(smsg); slen > 0; )
 		for (pat = PAT_BEGIN; slen > 0 && pat <= PAT_END; pat ++, slen --)
 			*p ++ = pat;
 
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[UDC:%02d SND] sending:    %6ld, to:   %s.%d",
-	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, to:   %s.%d",
+	                   API_PROTO, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
 
 	scount = total = 0;
 	udp_discard_cli_valid = true;
-	for (slen = IF_MTU - IP_UDP_HDR_SIZE; udp_discard_cli_valid && slen > 0; slen --) {
+	for (slen = sizeof(smsg); udp_discard_cli_valid && slen > 0; slen --) {
 		scount ++;
 		if ((len = UDP_SND_DAT(cepid, &dst, smsg, slen, TMO_FEVR)) < 0) {
-			syslog(LOG_NOTICE, "[UDC:%02d SND] send error: %s", cepid, itron_strerror(len));
+			syslog(LOG_NOTICE, "[UDC%c:%02u SND] error: %s", API_PROTO, cepid, itron_strerror(len));
 			return len;
 			}
 		else
-			syslog(LOG_NOTICE, "[UDC:%02d SND] send: %4d, %4d", cepid, scount, slen);
+			syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, %4u", API_PROTO, cepid, scount, slen);
 		total += len;
-		dly_tsk(10 * SYSTIM_HZ + net_rand() % (10 * SYSTIM_HZ));
+		dly_tsk(10 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
 		}
 
 	get_tim(&time);
-	syslog(LOG_NOTICE, "[UDC:%02d SND] finished:   %6ld, snd: %4d,            len: %ld",
-		           cepid, time / SYSTIM_HZ, scount, total);
+	syslog(LOG_NOTICE, "[UDC%c:%02u SND] finsh: %7lu, snd: %4u,            len: %ld",
+		           API_PROTO, cepid, time / SYSTIM_HZ, scount, total);
 	return E_OK;
 	}
@@ -158,10 +155,21 @@
 	int_t		no;
 	uint16_t	portno;
+	char		apip;
 
 #ifdef USE_UDP_EXTENTIONS
 
+#if defined(SUPPORT_INET6)
+	T_UDP6_CCEP	ccep;
+#else
 	T_UDP_CCEP	ccep;
+#endif
 
 #endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#if defined(SUPPORT_INET6)
+	apip = API_PROTO_IPV6;
+#else
+	apip = API_PROTO_IPV4;
+#endif
 
 	get_tid(&tskid);
@@ -171,4 +179,9 @@
 			line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));	/* IP Address */
 
+			if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] unknown host.", (ID)exinf);
+				continue;
+				}
+
 			if ('0' <= *line && *line <= '9') {				/* Port No */
 				line = get_int(&no, line);
@@ -186,14 +199,18 @@
 			ccep.myaddr.portno = UDP_PORTANY;
 
+#if defined(SUPPORT_INET6)
+
+			memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
 #if defined(SUPPORT_INET4)
 			ccep.myaddr.ipaddr = IPV4_ADDRANY;
 #endif
 
-#if defined(SUPPORT_INET6)
-			memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
-#endif
-
-			if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) {
-				syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
+#endif	/* #if defined(SUPPORT_INET6) */
+
+			if ((error = ALLOC_UDP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP create error: %s", API_PROTO, cepid, itron_strerror(error));
 				continue;
 				}
@@ -206,10 +223,10 @@
 
 			if ((error = send_udp_discard(cepid, &addr, portno)) != E_OK)
-				syslog(LOG_NOTICE, "[UDC:%02d TSK] error: %s", cepid, itron_strerror(error));
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
 
 #ifdef USE_UDP_EXTENTIONS
 
-			if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
-				syslog(LOG_NOTICE, "[UDC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
+			if ((error = FREE_UDP_CEP(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP delete error: %s", API_PROTO, cepid, itron_strerror(error));
 
 #endif	/* of #ifdef USE_UDP_EXTENTIONS */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_discard_cli.h	(revision 331)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP_DISCARD_CLI_H_
+#define _UDP_DISCARD_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP_DISCARD_CLI_STACK_SIZE	1024		/* UDP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP_DISCARD_CLI_MAIN_PRIORITY	5		/* UDP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp_discard_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp_discard_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP_DISCARD_CLI_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_cli.c	(revision 321)
+++ 	(revision )
@@ -1,349 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/* 
- *  UDP ECHO クライアント
- */
-
-#include <string.h>
-
-#ifdef TARGET_KERNEL_ASP
-
-#include <kernel.h>
-#include <sil.h>
-#include <t_syslog.h>
-#include "kernel_cfg.h"
-
-#endif	/* of #ifdef TARGET_KERNEL_ASP */
-
-#ifdef TARGET_KERNEL_JSP
-
-#include <t_services.h>
-#include "kernel_id.h"
-#include "tinet_id.h"
-
-#endif	/* of #ifdef TARGET_KERNEL_JSP */
-
-#include <tinet_defs.h>
-#include <tinet_config.h>
-
-#include <net/net.h>
-#include <net/net_var.h>
-#include <net/net_timer.h>
-
-#include <netinet/in.h>
-#include <netinet/in_itron.h>
-
-#include <netapp/netapp.h>
-#include <netapp/netapp_var.h>
-#include <netapp/echo.h>
-
-#ifdef USE_UDP_ECHO_CLI
-
-/* echo サーバのポート番号 */
-
-#define ECHO_SRV_PORTNO		UINT_C(7)
-
-/*
- *  全域変数
- */
-
-bool_t udp_echo_cli_valid;
-
-/*
- * 変数
- */
-
-#define BUF_SIZE	2048
-
-static char		udp_buf[BUF_SIZE];
-static T_IPEP		dst;
-
-#ifdef USE_UDP_NON_BLOCKING
-
-static ER_UINT		nblk_len;
-
-/*
- *  ノンブロッキングコールのコールバック関数
- */
-
-ER
-callback_nblk_udp_echo_cli (ID cepid, FN fncd, void *p_parblk)
-{
-	nblk_len = *(ER_UINT*)p_parblk;
-	syscall(wup_tsk(UDP_ECHO_CLI_TASK));
-	return E_OK;
-	}
-
-/*
- *  send_udp_echo -- ECHO/UDP サーバにメッセージを送信する (ノンブロッキングコール使用)。
- */
-
-static ER
-send_udp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char *line)
-{
-	ER_UINT	error;
-	uint_t	len;
-
-	dst.ipaddr = *ipaddr;
-	dst.portno = portno;
-	len         = strlen(line);
-	if ((error = UDP_SND_DAT(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[UEC:%02d SND] error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-	else
-		syslog(LOG_NOTICE, "[UEC:%02d SND] sending:            to:   %s.%d: %s",
-		                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
-
-	syscall(slp_tsk());
-	if (nblk_len < 0) {	/* 0 以下の場合は、エラーコード */
-		syslog(LOG_NOTICE, "[UEC:%02d CBR] error: %s", cepid, itron_strerror(nblk_len));
-		return nblk_len;
-		}
-
-	if ((error = UDP_RCV_DAT(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-	syscall(slp_tsk());
-	if (nblk_len < 0) {	/* 0 以下の場合は、エラーコード */
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] error: %s", cepid, itron_strerror(nblk_len));
-		return nblk_len;
-		}
-	else {
-		udp_buf[nblk_len] = '\0';
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] received:           from: %s.%d: %s",
-		                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, udp_buf);
-		nblk_len = E_OK;
-		}
-
-	return nblk_len;
-	}
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#ifdef USE_UDP_CALL_BACK
-
-/*
- *  コールバック関数
- */
-
-ER
-callback_udp_echo_cli (ID cepid, FN fncd, void *p_parblk)
-{
-	ER_UINT	len;
-
-	if ((len = UDP_RCV_DAT(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
-		*(udp_buf + len) = '\0';
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] recv: addr: %s.%d: %s",
-		                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, udp_buf);
-		}
-	else
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] recv: error: %s", cepid, itron_strerror(len));
-
-	return E_OK;
-	}
-
-/*
- *  send_udp_echo -- ECHO/UDP サーバにメッセージを送信する (コールバック関数使用)。
- */
-
-static ER
-send_udp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char *line)
-{
-	ER_UINT	len;
-
-	dst.ipaddr = *ipaddr;
-	dst.portno = portno;
-	len        = strlen(line);
-	syslog(LOG_NOTICE, "[UEC:%02d SND] sending:            to:   %s.%d: %s",
-	                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
-	if ((len = UDP_SND_DAT(cepid, &dst, line, len, TMO_FEVR)) < 0)
-		syslog(LOG_NOTICE, "[UEC:%02d SND] error: %s", cepid, itron_strerror(len));
-
-	return E_OK;
-	}
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-/*
- *  send_udp_echo -- ECHO/UDP サーバにメッセージを送信する (コールバック関数未使用)。
- */
-
-static ER
-send_udp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char *line)
-{
-	ER_UINT	len;
-
-	dst.ipaddr = *ipaddr;
-	dst.portno = portno;
-	len         = strlen(line);
-	syslog(LOG_NOTICE, "[UEC:%02d SND] sending:            to:   %s.%d: %s",
-	                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
-	if ((len = UDP_SND_DAT(cepid, &dst, line, len, TMO_FEVR)) < 0) {
-		syslog(LOG_NOTICE, "[UEC:%02d SND] error: %s", cepid, itron_strerror(len));
-		return len;
-		}
-
-	if ((len = UDP_RCV_DAT(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
-		*(udp_buf + len) = '\0';
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] received:           from: %s.%d: %s",
-		                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
-		return E_OK;
-		}
-	else {
-		syslog(LOG_NOTICE, "[UEC:%02d RCV] error: %s", cepid, itron_strerror(len));
-		return len;
-		}
-	}
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-#define MESSAGE_FORMAT	"MSG 1000000"
-
-/*
- *  UDP ECHO クライアント送信タスク
- */
-
-void
-udp_echo_cli_task (intptr_t exinf)
-{
-	static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
-
-	T_IN_ADDR	addr;
-	ID		tskid, cepid;
-	ER		error = E_OK;
-	char		*line, *p;
-	int_t		rep;
-	uint32_t	count, msgno;
-	uint16_t	portno;
-
-#ifdef USE_UDP_EXTENTIONS
-
-	T_UDP_CCEP	ccep;
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[UDP ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
-	while (true) {
-		if (rcv_dtq(DTQ_UDP_ECHO_CLI, (intptr_t*)&line) == E_OK) {
-
-#ifdef USE_UDP_EXTENTIONS
-
-			ccep.cepatr = UINT_C(0);
-			ccep.myaddr.portno = UDP_PORTANY;
-
-#if defined(SUPPORT_INET4)
-			ccep.myaddr.ipaddr = IPV4_ADDRANY;
-#endif
-
-#if defined(SUPPORT_INET6)
-			memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
-#endif
-
-#ifdef USE_UDP_NON_BLOCKING
-			ccep.callback = (FP)callback_nblk_udp_echo_cli;
-#else
-			ccep.callback = NULL;
-#endif
-
-			if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) {
-				syslog(LOG_NOTICE, "[UEC:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
-				continue;
-				}
-
-#else	/* of #ifdef USE_UDP_EXTENTIONS */
-
-			cepid = (ID)exinf;
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-			line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));	/* IP Address */
-
-			if ('0' <= *line && *line <= '9') {				/* Port No */
-				line = get_int(&rep, line);
-				portno = (uint16_t)rep;
-				}
-			else {
-				line ++;
-				portno = ECHO_SRV_PORTNO;
-				}
-
-			line = skip_blanks(line);
-			if ('0' <= *line && *line <= '9') {				/* Repeat */
-				line = get_int(&rep, line);
-				if (rep > 1000000)
-					rep = 1000000;
-				udp_echo_cli_valid = true;
-				for (count = 0;  count ++ < rep; ) {
-					if (!udp_echo_cli_valid) {
-						syslog(LOG_NOTICE, "[UEC:%02d TSK] canceled.", cepid);
-						break;
-						}
-						
-					p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
-					for (msgno = count; msgno > 0; msgno /= 10)
-						*(-- p) = msgno % 10 + '0';
-					while (*(p - 2) != 'G')
-						*(-- p) = ' ';
-
-					if ((error = send_udp_echo(cepid, &addr, portno, msg)) != E_OK)
-						break;
-
-					dly_tsk(10 * SYSTIM_HZ + net_rand() % (10 * SYSTIM_HZ));
-					}
-				}
-
-			else								/* Single Message */
-				error = send_udp_echo(cepid, &addr, portno, line);
-
-			if (error != E_OK)
-				syslog(LOG_NOTICE, "[UEC:%02d TSK] error: %s", cepid, itron_strerror(error));
-
-#ifdef USE_UDP_EXTENTIONS
-
-			if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
-				syslog(LOG_NOTICE, "[UEC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-			}
-		}
-	}
-
-#endif	/* of #ifdef USE_UDP_ECHO_CLI */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_cli.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_cli.cfg	(revision 321)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/*
- *  ECHO サーバ試験プログラムのシステムコンフィギュレーションファイル
- */
-
-#ifdef USE_UDP_ECHO_CLI
-
-/* タスク */
-
-#ifdef USE_UDP_EXTENTIONS
-
-CRE_TSK(UDP_ECHO_CLI_TASK, {
-	TA_HLNG|TA_ACT,
-	0,
-	udp_echo_cli_task,
-	UDP_ECHO_CLI_MAIN_PRIORITY,
-	UDP_ECHO_CLI_STACK_SIZE,
-	NULL
-	});
-
-#else	/* of #ifdef USE_UDP_EXTENTIONS */
-
-CRE_TSK(UDP_ECHO_CLI_TASK, {
-	TA_HLNG|TA_ACT,
-	UDP_ECHO_CLI_CEPID,
-	udp_echo_cli_task,
-	UDP_ECHO_CLI_MAIN_PRIORITY,
-	UDP_ECHO_CLI_STACK_SIZE,
-	NULL
-	});
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-/* コマンドキュー */
-
-CRE_DTQ(DTQ_UDP_ECHO_CLI,  { TA_TFIFO, 1, NULL });
-
-#endif	/* of #ifdef USE_UDP_ECHO_CLI */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_srv.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_srv.c	(revision 321)
+++ 	(revision )
@@ -1,310 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/* 
- *  UDP ECHO サーバ
- */
-
-#include <string.h>
-
-#ifdef TARGET_KERNEL_ASP
-
-#include <kernel.h>
-#include <sil.h>
-#include <t_syslog.h>
-#include "kernel_cfg.h"
-
-#endif	/* of #ifdef TARGET_KERNEL_ASP */
-
-#ifdef TARGET_KERNEL_JSP
-
-#include <t_services.h>
-#include "kernel_id.h"
-#include "tinet_id.h"
-
-#endif	/* of #ifdef TARGET_KERNEL_JSP */
-
-#include <tinet_defs.h>
-#include <tinet_config.h>
-
-#include <net/net.h>
-#include <net/net_timer.h>
-
-#include <netinet/in.h>
-#include <netinet/in_itron.h>
-
-#include <netapp/netapp.h>
-#include <netapp/netapp_var.h>
-#include <netapp/echo.h>
-
-#ifdef USE_UDP_ECHO_SRV
-
-/*
- *  受信タイムアウト
- */
-
-#define RCV_TMOUT	TMO_FEVR
-//#define RCV_TMOUT	(30*ULONG_C(1000))
-
-#define BUF_SIZE	2048
-
-static char	echo_rcv_buf[BUF_SIZE];
-static T_IPEP	dst;
-
-#ifdef USE_UDP_CALL_BACK
-
-/*
- *  コールバック関数
- */
-
-ER
-callback_udp_echo_srv (ID cepid, FN fncd, void *p_parblk)
-{
-	ER_UINT	len;
-	SYSTIM	now;
-
-	if ((len = UDP_RCV_DAT(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_FEVR)) >= 0) {
-		echo_rcv_buf[len] = '\0';
-		get_tim(&now);
-		syslog(LOG_NOTICE, "[UES:%02d UCB] received,   %6ld, from: %s.%d,\n"
-		                   "                                 msg: '%s'",
-		                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
-		if (len > 0) {
-			len = UDP_SND_DAT(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
-			get_tim(&now);
-			if (len >= 0)
-				syslog(LOG_NOTICE, "[UES:%02d UCB] sent,       %6ld, len: %d",
-				                   cepid, now / SYSTIM_HZ, len);
-			else
-				syslog(LOG_NOTICE, "[UES:%02d UCB] send error, %6ld: %s",
-				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
-			}
-		len = E_OK;
-		}
-	else {
-		get_tim(&now);
-		syslog(LOG_NOTICE, "[UES:%02d UCB] recv error, %6ld: %s",
-		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
-		}
-
-	return len;
-	}
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-#ifdef USE_UDP_NON_BLOCKING
-
-/*
- *  変数
- */
-
-static ER_UINT		nblk_len;
-
-/*
- *  ノンブロッキングコールのコールバック関数
- */
-
-ER
-callback_nblk_udp_echo_srv (ID cepid, FN fncd, void *p_parblk)
-{
-	SYSTIM	now;
-
-	get_tim(&now);
-	nblk_len = *(ER_UINT*)p_parblk;
-	if (nblk_len < 0) {	/* 0 以下の場合は、エラーコード */
-		syslog(LOG_NOTICE, "[UES:%02d CBR] error,      %6ld: %s, fncd: %s",
-		                   cepid, now / SYSTIM_HZ, itron_strerror(nblk_len), in_strtfn(fncd));
-		}
-	else if (fncd == TFN_UDP_RCV_DAT) {
-		echo_rcv_buf[nblk_len] = '\0';
-		syslog(LOG_NOTICE, "[UES:%02d CBR] received,   %6ld, from: %s.%d,\n"
-		                   "                                 msg: '%s'",
-		                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
-		}
-	syscall(wup_tsk(UDP_ECHO_SRV_TASK));
-	return E_OK;
-	}
-
-/*
- *  UDP ECHO サーバ
- */
-
-ER
-udp_echo_srv (ID cepid)
-{
-	ER	error;
-	SYSTIM	now;
-
-	if ((error = UDP_RCV_DAT(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_NBLK)) != E_WBLK) {
-		get_tim(&now);
-		syslog(LOG_NOTICE, "[UES:%02d RCV] recv error, %6ld: %s", cepid, now / SYSTIM_HZ, itron_strerror(error));
-		return error;
-		}
-
-	syscall(slp_tsk());
-	if (nblk_len < 0)
-		error = nblk_len;
-	else {
-		if ((error = UDP_SND_DAT(cepid, &dst, echo_rcv_buf, nblk_len, TMO_NBLK)) != E_WBLK) {
-			get_tim(&now);
-			syslog(LOG_NOTICE, "[UES:%02d SND] send error, %6ld: %s",
-			                   cepid, now / SYSTIM_HZ, itron_strerror(error));
-			return error;
-			}
-
-		syscall(slp_tsk());
-		if (nblk_len < 0)
-			error = nblk_len;
-		else {
-			get_tim(&now);
-			syslog(LOG_NOTICE, "[UES:%02d SND] sent,       %6ld, len: %d", cepid, now / SYSTIM_HZ, nblk_len);
-			error = E_OK;
-			}
-		}
-
-	return error;
-	}
-
-#else	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-/*
- *  UDP ECHO サーバ
- */
-
-ER
-udp_echo_srv (ID cepid)
-{
-	ER_UINT	len;
-	SYSTIM	now;
-
-	if ((len = UDP_RCV_DAT(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), RCV_TMOUT)) >= 0) {
-		get_tim(&now);
-		echo_rcv_buf[len] = '\0';
-		syslog(LOG_NOTICE, "[UES:%02d RCV] received,   %6ld, from: %s.%d,\n"
-		                   "                                 msg: '%s'",
-		                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
-		if (len > 0) {
-			len = UDP_SND_DAT(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
-			get_tim(&now);
-			if (len >= 0)
-				syslog(LOG_NOTICE, "[UES:%02d SND] sent,       %6ld, len: %d",
-				                   cepid, now / SYSTIM_HZ, (uint16_t)len);
-			else
-				syslog(LOG_NOTICE, "[UES:%02d SND] send error, %6ld: %s",
-				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
-			}
-		}
-	else {
-		get_tim(&now);
-		syslog(LOG_NOTICE, "[UES:%02d RCV] recv error, %6ld: %s", cepid, now / SYSTIM_HZ, itron_strerror(len));
-		}
-
-	return len >= 0 || len == E_TMOUT ? E_OK : len;
-	}
-
-#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
-
-/*
- *  UDP ECHO サーバタスク
- */
-
-#ifdef USE_UDP_EXTENTIONS
-
-void
-udp_echo_srv_task (intptr_t exinf)
-{
-	ID		tskid, cepid;
-	ER		error;
-	T_UDP_CCEP	ccep;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[UDP ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
-	while (true) {
-
-		syscall(slp_tsk());
-
-		ccep.cepatr = UINT_C(0);
-		ccep.myaddr.portno = UINT_C(7);
-
-#if defined(SUPPORT_INET4)
-		ccep.myaddr.ipaddr = IPV4_ADDRANY;
-#endif
-
-#if defined(SUPPORT_INET6)
-		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
-#endif
-
-#ifdef USE_UDP_NON_BLOCKING
-		ccep.callback = (FP)callback_nblk_udp_echo_srv;
-#else
-		ccep.callback = NULL;
-#endif
-
-		if ((error = alloc_udp_cep(&cepid, tskid, &ccep)) != E_OK) {
-			syslog(LOG_NOTICE, "[UES:%02d TSK] CEP create error: %s", cepid, itron_strerror(error));
-			continue;
-			}
-
-		while (error == E_OK) {
-			if ((error = udp_echo_srv(cepid)) != E_OK) {
-				if ((error = free_udp_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
-					syslog(LOG_NOTICE, "[UEC:%02d TSK] CEP delete error: %s", cepid, itron_strerror(error));
-				break;
-				}
-			}
-
-		}
-	slp_tsk();
-	}
-
-#else	/* of #ifdef USE_UDP_EXTENTIONS */
-
-void
-udp_echo_srv_task (intptr_t exinf)
-{
-	ID	tskid;
-	ER	error = E_OK;
-
-	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[UDP ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
-	while (error == E_OK) {
-		error = udp_echo_srv((ID)exinf);
-		}
-	slp_tsk();
-	}
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_ECHO_SRV */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_srv.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/udp_echo_srv.cfg	(revision 321)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/*
- *  TINET (TCP/IP Protocol Stack)
- * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
- *                   Tomakomai National College of Technology, JAPAN
- *
- *  上記著作権者は，以下の (1)～(4) の条件か，Free Software Foundation 
- *  によって公表されている GNU General Public License の Version 2 に記
- *  述されている条件を満たす場合に限り，本ソフトウェア（本ソフトウェア
- *  を改変したものを含む．以下同じ）を使用・複製・改変・再配布（以下，
- *  利用と呼ぶ）することを無償で許諾する．
- *  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
- *      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
- *      スコード中に含まれていること．
- *  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
- *      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
- *      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
- *      の無保証規定を掲載すること．
- *  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
- *      用できない形で再配布する場合には，次の条件を満たすこと．
- *    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
- *        作権表示，この利用条件および下記の無保証規定を掲載すること．
- *  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
- *      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
- *
- *  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
- *  よびTOPPERSプロジェクトは，本ソフトウェアに関して，その適用可能性も
- *  含めて，いかなる保証も行わない．また，本ソフトウェアの利用により直
- *  接的または間接的に生じたいかなる損害に関しても，その責任を負わない．
- * 
- *  @(#) $Id$
- */
-
-/*
- *  UDP ECHO サーバコンフィギュレーションファイル
- */
-
-#ifdef USE_UDP_ECHO_SRV
-
-/*
- * タスク
- */
-
-#ifdef USE_UDP_CALL_BACK
-
-#else	/* of #ifdef USE_UDP_CALL_BACK */
-
-#ifdef USE_UDP_EXTENTIONS
-
-CRE_TSK(UDP_ECHO_SRV_TASK, {
-	TA_HLNG | TA_ACT,
-	0,
-	udp_echo_srv_task,
-	UDP_ECHO_SRV_MAIN_PRIORITY,
-	UDP_ECHO_SRV_STACK_SIZE,
-	NULL
-	});
-
-#else	/* of #ifdef USE_UDP_EXTENTIONS */
-
-CRE_TSK(UDP_ECHO_SRV_TASK, {
-	TA_HLNG | TA_ACT,
-	UDP_ECHO_SRV_CEPID,
-	udp_echo_srv_task,
-	UDP_ECHO_SRV_MAIN_PRIORITY,
-	UDP_ECHO_SRV_STACK_SIZE,
-	NULL
-	});
-
-#endif	/* of #ifdef USE_UDP_EXTENTIONS */
-
-#endif	/* of #ifdef USE_UDP_CALL_BACK */
-
-#endif	/* of #ifdef USE_UDP_ECHO_SRV */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.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
  *
@@ -75,14 +75,12 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
-#include <net/net_timer.h>
 #include <net/net_count.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/wwws.h>
@@ -118,4 +116,30 @@
 #endif	/* of #if NET_COUNT_ENABLE */
 
+#ifdef USE_TCP_EXTENTIONS
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+#if NUM_WWW_SRV_TASKS >= 2		/* 2 を超える個数は想定していない。	*/
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK2
+
+#else	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK1
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK1
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+
 /*
  *  全域変数
@@ -161,4 +185,48 @@
 #define ST_NOT_FOUND	1
 
+/*
+ *  接続相手の情報構造体
+ */
+
+#ifdef  NUM_WWW4_SRV_TASKS
+#undef  NUM_WWW4_SRV_TASKS
+#endif
+#define NUM_WWW4_SRV_TASKS		1
+
+typedef struct t_www_srv_info {
+	ID	cepid;		/* 通信端点 ID		*/
+	ID	repid;		/* 受付口   ID		*/
+	T_IPEP	dst;		/* 接続相手アドレス情報	*/
+	} T_WWW_SRV_INFO;
+
+#define INDEX_SRV_INFO(id)	((id)-1)
+
+#ifdef USE_TCP_EXTENTIONS
+
+static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS];
+					/* 2 を超える個数は想定していない。	*/
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+static T_WWW_SRV_INFO www_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	{ WWW4_SRV_CEPID1, WWW4_SRV_REPID },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	{ WWW_SRV_CEPID1, WWW_SRV_REPID },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#if NUM_WWW_SRV_TASKS >= 2		/* 2 を超える個数は想定していない。	*/
+	{ WWW_SRV_CEPID2, WWW_SRV_REPID },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
 #ifdef USE_COPYSAVE_API
 
@@ -180,10 +248,10 @@
 		if (srbuf->rbuf.index >= srbuf->rbuf.len) {
 			if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK)
-				syslog(LOG_WARNING, "[WWW:%02d] tcp_rel_buf error: %s",
+				syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s",
 				       cepid, itron_strerror(error));
 			srbuf->rbuf.index = 0;
 			if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) {
 				if (len < 0)
-					syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_buf error: %s",
+					syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s",
 					       cepid, itron_strerror(len));
 				srbuf->rbuf.len = 0;
@@ -228,5 +296,5 @@
 		if (srbuf->sbuf.index >= srbuf->sbuf.len)
 			if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
-				syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
+				syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
 			return 0;
 			}
@@ -234,5 +302,5 @@
 		if (srbuf->sbuf.len == 0) {
 			if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) {
-				syslog(LOG_WARNING, "[WWW:%02d] tcp_get_buf error: %s", cepid, itron_strerror(srbuf->sbuf.len));
+				syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len));
 				return 0;
 				}
@@ -272,5 +340,5 @@
 			if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) {
 				if (len < 0) {
-					syslog(LOG_WARNING, "[WWW:%02d] tcp_rcv_dat error: %s",
+					syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s",
 					       cepid, itron_strerror(len));
 					}
@@ -321,5 +389,5 @@
 		if (srbuf->sbuf.index >= srbuf->sbuf.len)
 			if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
-				syslog(LOG_WARNING, "[WWW:%02d] tcp_snd_dat error: %s", cepid, itron_strerror(error));
+				syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
 			return 0;
 			}
@@ -476,8 +544,10 @@
 	int_t	ix;
 
-	for (ix = NUM_FILES; ix -- > 0; )
+	for (ix = NUM_FILES; ix -- > 0; ) {
 		if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) {
+			//syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]);
 			return (*file[ix].func)(cepid, srbuf);
 			}
+		}
 	put_status(cepid, srbuf, ST_NOT_FOUND);
 	return E_NOEXS;
@@ -494,15 +564,14 @@
 	ER		error = E_OK;
 	int_t		blen = 0;
-	uint16_t	len;
 
 	if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) {
-		syslog(LOG_CRIT, "[WWW:%02d] get line error: %s.",
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.",
 		       cepid, itron_strerror(error));
 		return error;
 		}
 
-	if ((len = get_line(cepid, method, srbuf)) == 0) {
+	if (get_line(cepid, method, srbuf) == 0) {
 		if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
-			syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
+			syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
 			       cepid, itron_strerror(error));
 		return error;
@@ -510,18 +579,18 @@
 
 	if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) {
-		syslog(LOG_CRIT, "[WWW:%02d] get line buffer error: %s.",
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.",
 		       cepid, itron_strerror(error));
 		if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
-			syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
+			syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
 			       cepid, itron_strerror(error));
 		return error;
 		}
 
-	while ((len = get_line(cepid, line, srbuf)) > 0) {	/* ヘッダをスキップする。*/
+	while (get_line(cepid, line, srbuf) > 0) {	/* ヘッダをスキップする。*/
 		split_fields(line, ": ");
 		if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0)
 			blen = atoi(&line->buf[line->off[1]]);
 		}
-	while (blen > 0 && (len = get_line(cepid, line, srbuf)) > 0) {
+	while (blen > 0 && get_line(cepid, line, srbuf) > 0) {
 		/* エンティティ・ボディをスキップする。*/
 		blen -= line->len;
@@ -529,5 +598,5 @@
 
 	if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK)
-		syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
+		syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
 		       cepid, itron_strerror(error));
 	
@@ -539,5 +608,5 @@
 
 	if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
-		syslog(LOG_WARNING, "[WWW:%02d] release line buffer error: %s.",
+		syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
 		       cepid, itron_strerror(error));
 
@@ -567,13 +636,23 @@
 
 #ifdef TARGET_KERNEL_ASP
-		"ASP Kernel Release 1.3 (patchlevel = 2) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
+		"ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
 #endif
 
 #ifdef TARGET_KERNEL_JSP
-		"JSP Kernel Release 1.4 (patchlevel = 3) for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
+		"JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") と<br>\r\n"
 #endif
 
 		"TINET TCP/IP プロトコルスタックによりサービスしています。<br><hr>\r\n"
+
+#if NET_COUNT_ENABLE
+
 		"<ul><li type=\"square\"><a href=\"stat.html\">ネットワーク統計情報</a></ul><hr>\r\n"
+
+#else	/* of #if NET_COUNT_ENABLE */
+
+		"<ul><li type=\"square\">ネットワーク統計情報</ul><hr>\r\n"
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
 		"FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n"
 		"The Regents of the University of California.  All rights reserved.<br><br>\r\n"
@@ -629,5 +708,5 @@
 	len += put_str(cepid, srbuf, response);
 	get_tim(&finish);
-	syslog(LOG_NOTICE, "[WWW:%02u]     send:               index.html, len: %4u, time: %lu [ms]",
+	syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
 	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
 	return E_OK;
@@ -1530,5 +1609,5 @@
 
 	get_tim(&finish);
-	syslog(LOG_NOTICE, "[WWW:%02u]     send:               stat.html,  len: %4u, time: %lu [ms]",
+	syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
 	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
 	return E_OK;
@@ -1537,78 +1616,4 @@
 #endif	/* of #if NET_COUNT_ENABLE */
 
-/*
- *  WWW サーバ
- */
-
-static ER
-www_srv (ID cepid, ID repid)
-{
-#if defined(SUPPORT_INET4)
-
-	T_IPV4EP	dst;
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-	T_IPV6EP	dst;
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-	T_WWW_RWBUF	*srbuf;
-	ER		error;
-	SYSTIM		time;
-
-	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
-		syslog(LOG_WARNING, "[WWW:%02d] accept error: %s", cepid, itron_strerror(error));
-		return error;
-		}
-
-	get_tim(&time);
-	syslog(LOG_NOTICE, "[WWW:%02u]     connected:  %6lu, from: %s.%u",
-	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
-
-	if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
-		syslog(LOG_CRIT, "[WWW:%02d] get buffer error: %s.", cepid, itron_strerror(error));
-		srbuf = NULL;
-		}
-	else {
-		srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
-
-#ifdef USE_COPYSAVE_API
-
-		srbuf->sbuf.len = 0;
-
-#else	/* of #ifdef USE_COPYSAVE_API */
-
-		srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
-
-#endif	/* of #ifdef USE_COPYSAVE_API */
-
-		if ((error = parse_request(cepid, srbuf)) != E_OK)
-			syslog(LOG_WARNING, "[WWW:%02d] parse request error: %s",
-			       cepid, itron_strerror(error));
-		}
-
-	if ((error = tcp_sht_cep(cepid)) != E_OK)
-		syslog(LOG_WARNING, "[WWW:%02d] shutdown error: %s", cepid, itron_strerror(error));
-
-	if (srbuf != NULL) {
-		while (get_char(cepid, srbuf) != EOF)
-			;
-		if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
-			syslog(LOG_WARNING, "[WWW:%02d] release buffer error: %s.",
-			       cepid, itron_strerror(error));
-		}
-
-	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
-		syslog(LOG_WARNING, "[WWW:%02d] close error: %s", cepid, itron_strerror(error));
-
-	get_tim(&time);
-	syslog(LOG_NOTICE, "[WWW:%02u]     finished:   %6lu", cepid, time / SYSTIM_HZ);
-
-	return error;
-	}
-
 #ifdef USE_TCP_EXTENTIONS
 
@@ -1616,4 +1621,6 @@
  *  get_tcp_rep -- TCP 受付口を獲得する。
  */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
 
 static ER
@@ -1621,5 +1628,29 @@
 {
 	ID		tskid;
-	T_TCP_CREP	crep;
+	T_TCP6_CREP	crep6;
+	T_TCP_CREP	crep4;
+
+	get_tid(&tskid);
+	if (tskid == WWW4_SRV_TASK) {
+		crep4.repatr = UINT_C(0);
+		crep4.myaddr.portno = UINT_C(80);
+		crep4.myaddr.ipaddr = IPV4_ADDRANY;
+		return alloc_tcp4_rep(repid, tskid, &crep4);
+		}
+	else {
+		crep6.repatr = UINT_C(0);
+		crep6.myaddr.portno = UINT_C(80);
+		memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+		return alloc_tcp6_rep(repid, tskid, &crep6);
+		}
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+get_tcp_rep (ID *repid)
+{
+	ID		tskid;
+	T_TCPN_CREP	crep;
 
 	get_tid(&tskid);
@@ -1627,4 +1658,10 @@
 	crep.repatr = UINT_C(0);
 	crep.myaddr.portno = UINT_C(80);
+
+#if defined(SUPPORT_INET6)
+
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
 
 #if defined(SUPPORT_INET4)
@@ -1632,14 +1669,13 @@
 #endif
 
-#if defined(SUPPORT_INET6)
-	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
-#endif
-
-
-	return alloc_tcp_rep(repid, tskid, &crep);
-	}
-
-/*
- *  get_tcp_cep -- TCP 通信端点とを獲得する。
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  get_tcp_cep -- TCP 通信端点を獲得する。
  */
 
@@ -1668,6 +1704,167 @@
 #endif
 
-	return alloc_tcp_cep(cepid, tskid, &ccep);
-	}
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (tskid == WWW4_SRV_TASK)
+		return alloc_tcp4_cep(cepid, tskid, &ccep);
+	else
+		return alloc_tcp6_cep(cepid, tskid, &ccep);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  tcp_passive_open -- 受動オープンを実行する。
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+	T_IPV4EP	dst4;
+
+	if (apip == API_PROTO_IPV6) {
+		/* 受付口は IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+			return error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	else {
+		/* 受付口は IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
+			return error;
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+		}
+
+	return error;
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+		return error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  WWW サーバ
+ */
+
+static ER
+www_srv (uint_t six, char apip)
+{
+	T_WWW_RWBUF	*srbuf;
+	ER		error;
+	SYSTIM		now;
+
+	if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct:  %6lu,from: %s.%u",
+		                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &www_srv_info[six].dst.ipaddr),
+		                   www_srv_info[six].dst.portno);
+	else
+		syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct:  %6lu,from: %s.%u",
+		                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]),
+		                   www_srv_info[six].dst.portno);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct:  %6lu,from: %s.%u",
+	                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &www_srv_info[six].dst.ipaddr),
+	                   www_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.",
+		                 www_srv_info[six].cepid, itron_strerror(error));
+		srbuf = NULL;
+		}
+	else {
+		srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
+
+#ifdef USE_COPYSAVE_API
+
+		srbuf->sbuf.len = 0;
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+		srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+		if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s",
+			                    www_srv_info[six].cepid, itron_strerror(error));
+		}
+
+	if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s", 
+		                    www_srv_info[six].cepid, itron_strerror(error));
+
+	if (srbuf != NULL) {
+		while (get_char(www_srv_info[six].cepid, srbuf) != EOF)
+			;
+		if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.",
+			                    www_srv_info[six].cepid, itron_strerror(error));
+		}
+
+	if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s",
+ 		                    www_srv_info[six].cepid, itron_strerror(error));
+
+	get_tim(&now);
+	syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh:  %6lu",
+	                   www_srv_info[six].cepid, now / SYSTIM_HZ);
+
+	return error;
+	}
+
+#ifdef USE_TCP_EXTENTIONS
 
 /*
@@ -1678,33 +1875,106 @@
 www_srv_task(intptr_t exinf)
 {
-	ID	tskid, cepid, repid;
+	ID	tskid;
 	ER	error = E_OK;
+	uint_t	six;
+	char	apip;
 
 	syscall(get_tid(&tskid));
-	syslog(LOG_NOTICE, "[WWW:%d] started.", tskid);
+	six = INDEX_SRV_INFO((ID)exinf);
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (six >= NUM_WWW4_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	apip = API_PROTO_IPVn;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid);
 	while (true) {
 
 		syscall(slp_tsk());
-		if ((error = get_tcp_cep (&cepid)) != E_OK) {
-			syslog(LOG_NOTICE, "[WWW:00 EXT] CEP create error: %s", itron_strerror(error));
+		if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s",
+				           apip, www_srv_info[six].cepid, itron_strerror(error));
 			continue;
 			}
 
-		if ((error = get_tcp_rep (&repid)) != E_OK) {
-			syslog(LOG_NOTICE, "[WWW:00 EXT] REP create error: %s", itron_strerror(error));
-			free_tcp_cep(cepid);
-			continue;
-			}
-
-		while (true)
-			if ((error = www_srv(cepid, repid)) != E_OK) {
-				error = free_tcp_rep(repid, error != E_DLT);
+		while (true) {
+
+			if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) {
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s",
+				                   apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error));
 				break;
 				}
-
-		if ((error = free_tcp_cep(cepid)) != E_OK)
-			syslog(LOG_NOTICE, "[WWW:%02d EXT] CEP delete error: %s", cepid, itron_strerror(error));
-
-		}
+			else if ((error = www_srv(six, apip)) != E_OK) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (tskid == WWW4_SRV_TASK)
+					error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT);
+				else
+					error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (error != E_OK) {
+					syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s",
+				                           apip, www_srv_info[six].cepid,
+				                                              www_srv_info[six].repid, itron_strerror(error));
+
+					}
+				break;
+				}
+			}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		if (tskid == WWW4_SRV_TASK) {
+			if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK)
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+					           apip, www_srv_info[six].cepid, itron_strerror(error));
+			}
+		else {
+			if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK)
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+					           apip, www_srv_info[six].cepid, itron_strerror(error));
+			}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+				           apip, www_srv_info[six].cepid, itron_strerror(error));
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		}
+	}
+
+/*
+ *  wakeup_www_srv -- WWW サーバタスクの休止解除
+ */
+
+ER
+wakeup_www_srv (char apip)
+{
+	ID	taskid;
+
+	if (apip == API_PROTO_IPV6)
+		taskid = WWW6_SRV_TASK;
+	else
+		taskid = WWW4_SRV_TASK;
+	syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid);
+	return wup_tsk(taskid);
 	}
 
@@ -1718,11 +1988,30 @@
 www_srv_task(intptr_t exinf)
 {
-	ID	tskid;
+	ID	tskid, cepid;
+	uint_t	six;
+	char	apip;
 
 	get_tim(&srv_start);
 	get_tid(&tskid);
-	syslog(LOG_NOTICE, "[WWW:%d,%d] started.", tskid, (int_t)exinf);
+	six = INDEX_SRV_INFO((ID)exinf);
+	cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (six >= NUM_WWW4_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	apip = API_PROTO_IPVn;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid);
+
 	while (true) {
-		while (www_srv((int_t)exinf, WWW_SRV_REPID) == E_OK)
+		while (www_srv(six, apip) == E_OK)
 			;
 		}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.cfg	(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
  *
@@ -40,9 +40,7 @@
 /* タスク */
 
-#ifdef USE_TCP_EXTENTIONS
-
 CRE_TSK(WWW_SRV_TASK1,  {
 	TA_HLNG | TA_ACT,
-	0,
+	1,
 	www_srv_task,
 	WWW_SRV_MAIN_PRIORITY,
@@ -51,22 +49,9 @@
 	});
 
-#else	/* of #ifdef USE_TCP_EXTENTIONS */
-
-CRE_TSK(WWW_SRV_TASK1,  {
-	TA_HLNG | TA_ACT,
-	WWW_SRV_CEPID1,
-	www_srv_task,
-	WWW_SRV_MAIN_PRIORITY,
-	WWW_SRV_STACK_SIZE,
-	NULL
-	});
-
-#endif	/* of #ifdef USE_TCP_EXTENTIONS */
-
 #if NUM_WWW_SRV_TASKS >= 2
 
 CRE_TSK(WWW_SRV_TASK2,  {
 	TA_HLNG | TA_ACT,
-	WWW_SRV_CEPID2,
+	2,
 	www_srv_task,
 	WWW_SRV_MAIN_PRIORITY,
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.h	(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
  *
@@ -39,16 +39,4 @@
  */
 
-#include <tinet_defs.h>
-
-#include <net/if.h>
-#include <net/if_ppp.h>
-#include <net/if_loop.h>
-#include <net/ethernet.h>
-
-#include <netinet6/in6.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/tcp.h>
-
 #ifdef TOPPERS_S810_CLG3_85
 #define	WWW_SRV_STACK_SIZE		768		/* タスクのスタックサイズ	*/
@@ -62,26 +50,22 @@
  */
 
-#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
 
-#define WWW_SRV_SWBUF_SIZE	((IF_MTU-(IP_HDR_SIZE+TCP_HDR_SIZE))*1)
-
-#else	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
-
-#if defined(SUPPORT_INET4)
-#define WWW_SRV_SWBUF_SIZE	(TCP_MSS)
+#if defined(SUPPORT_INET6)
+#define WWW_SRV_SWBUF_SIZE	(1024)
+#elif defined(SUPPORT_INET4)
+#define WWW_SRV_SWBUF_SIZE	(512)
 #endif
 
-#if defined(SUPPORT_INET6)
-#define WWW_SRV_SWBUF_SIZE	(TCP6_MSS)
-#endif
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
 
-#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
+#define WWW_SRV_SWBUF_SIZE	(2048)
 
-#if defined(SUPPORT_INET4)
-#define WWW_SRV_RWBUF_SIZE	(TCP_MSS)
-#endif
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
 
 #if defined(SUPPORT_INET6)
-#define WWW_SRV_RWBUF_SIZE	(TCP6_MSS)
+#define WWW_SRV_RWBUF_SIZE	(1024)
+#elif defined(SUPPORT_INET4)
+#define WWW_SRV_RWBUF_SIZE	(512)
 #endif
 
@@ -89,4 +73,8 @@
 #define WWW_LINE_SIZE		80
 #define WWW_NUM_FIELDS		4
+
+/*
+ *  タスク数
+ */
 
 #ifndef _MACRO_ONLY
@@ -128,10 +116,22 @@
 
 /*
- *  TCP 送受信バッファ
+ *  変数
  */
+
+/* TCP 送受信ウィンドバッファ */
+
+#ifdef NUM_WWW_SRV_TASKS
 
 extern uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE];
 extern uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE];
 
+#endif	/* of #ifdef NUM_WWW_SRV_TASKS */
+
+/*
+ *  関数
+ */
+
+extern ER	wakeup_www_srv (char apip);
+
 #endif	/* of #ifndef _MACRO_ONLY */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_asp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_asp.cfg	(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
  *
@@ -42,4 +42,6 @@
 INCLUDE("netapp/wwws.cfg");
 
+#ifdef USE_WWW_SRV
+
 /*
  * 固定メモリプール
@@ -65,2 +67,4 @@
 	NULL
 	});
+
+#endif	/* of #ifdef USE_WWW_SRV */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_jsp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_jsp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws_jsp.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/Makefile.tinet
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/Makefile.tinet	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/Makefile.tinet	(revision 331)
@@ -36,5 +36,5 @@
 #
 INCLUDES	:= $(INCLUDES) -I$(TINET_ROOT)/netdev/$(NET_DEV)
-TINET_DIR	:= $(TINET_DIR):$(TINET_ROOT)/netdev/$(NET_DEV)
+TINET_DIRS	:= $(TINET_DIRS):$(TINET_ROOT)/netdev/$(NET_DEV)
 TINET_COBJS	:= $(TINET_COBJS) if_mbed.o
 TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netdev/$(NET_DEV)/if_mbed.cfg
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c	(revision 331)
@@ -210,5 +210,5 @@
 if_mbed_addmulti(T_IF_SOFTC *ic)
 {
-	mbed_setrcr(ic);
+	if_mbed_setrcr(ic);
 	return E_OK;
 }
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h	(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
  *
@@ -102,6 +102,4 @@
 #define _IP_ICMP6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  ICMPv6 ヘッダ
@@ -117,5 +115,5 @@
 		uint8_t		data8[4];
 		} data;
-	} __attribute__((packed, aligned(2)))T_ICMP6_HDR;
+	} __attribute__((packed, aligned(2))) T_ICMP6_HDR;
 
 #define icmp6_data32			data.data32
@@ -133,5 +131,5 @@
 #define GET_ICMP6_SDU(nbuf,ihoff)	((uint8_t*)((nbuf)->buf) + ihoff + ICMP6_HDR_SIZE)
 
-#define GET_IP6_ICMP6_HDR_SIZE(nbuf)	(GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ICMP6_HDR_SIZE)
+#define GET_IP6_ICMP6_HDR_SIZE(nbuf)	(GET_IP6_HDR_SIZE(nbuf) + ICMP6_HDR_SIZE)
 #define GET_IF_IP6_ICMP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + GET_IP6_ICMP6_HDR_SIZE(nbuf))
 
@@ -218,5 +216,5 @@
 	T_IN6_ADDR	target;
 	/* この後にオプションが続く */
-	} __attribute__((packed, aligned(2)))T_NEIGHBOR_SOLICIT_HDR;
+	} T_NEIGHBOR_SOLICIT_HDR;
 
 #define NEIGHBOR_SOLICIT_HDR_SIZE	(sizeof(T_NEIGHBOR_SOLICIT_HDR))
@@ -230,5 +228,5 @@
 
 #define GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)		\
-					(GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + NEIGHBOR_SOLICIT_HDR_SIZE)
+					(GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_SOLICIT_HDR_SIZE)
 #define GET_IF_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)	\
 					(GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
@@ -242,5 +240,5 @@
 	T_IN6_ADDR	target;
 	/* この後にオプションが続く */
-	} __attribute__((packed, aligned(2)))T_NEIGHBOR_ADVERT_HDR;
+	} __attribute__((packed, aligned(2))) T_NEIGHBOR_ADVERT_HDR;
 
 /* ICMP6 ヘッダのデータ部の定義 */
@@ -261,5 +259,5 @@
 
 #define GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)		\
-					(GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + NEIGHBOR_ADVERT_HDR_SIZE)
+					(GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_ADVERT_HDR_SIZE)
 #define GET_IF_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)	\
 					(GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
@@ -285,4 +283,8 @@
 /*
  *  ルータ通知
+ *
+ *    RFC4291: IP Version 6 Addressing Architecture
+ *    RFC4941: Privacy Extensions for Stateless Address Autoconfiguration in IPv6
+ *    RFC6106: IPv6 Router Advertisement Options for DNS Configuration
  */
 
@@ -292,5 +294,5 @@
 	uint32_t	retransmit;		/* [ms] 近隣要請送信間隔	*/
 	/* この後にオプションが続く */
-	} __attribute__((packed, aligned(2)))T_ROUTER_ADVERT_HDR;
+	} __attribute__((packed, aligned(2))) T_ROUTER_ADVERT_HDR;
 
 /* ICMP6 ヘッダのデータ部の定義 */
@@ -311,5 +313,5 @@
 
 #define GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf)	\
-					(GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ROUTER_ADVERT_HDR_SIZE)
+					(GET_IP6_HDR_SIZE(nbuf) + ROUTER_ADVERT_HDR_SIZE)
 #define GET_IF_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf)	\
 					(GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
@@ -324,4 +326,15 @@
 
 /*
+ *  M: RA以外の方法で自動的にアドレスを設定することを許可する。
+ *  O: RA以外の方法で自動的にアドレス以外の情報を設定することをを許可する。
+ *
+ *   M   O
+ *  ON  ON	アドレスとそれ以外の情報をDHCPv6で設定する（statefull）
+ *  ON  OFF	アドレスはDHCPv6で設定するが、それ以外は手動で設定する。
+ *  OFF ON	アドレスは RA で設定するが、それ以外の情報をDHCPv6で設定する（stateless）
+ *  OFF OFF	DHCPv6 は使用しない。
+ */
+
+/*
  *  ルータ要請
  */
@@ -329,5 +342,5 @@
 typedef struct t_router_solicit_hdr {
 	T_ICMP6_HDR	hdr;
-	} __attribute__((packed, aligned(2)))T_ROUTER_SOLICIT_HDR;
+	} __attribute__((packed, aligned(2))) T_ROUTER_SOLICIT_HDR;
 
 /* ICMP6 ヘッダのデータ部の定義 */
@@ -347,5 +360,5 @@
 
 #define GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)		\
-					(GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf)) + ROUTER_SOLICIT_HDR_SIZE)
+					(GET_IP6_HDR_SIZE(nbuf) + ROUTER_SOLICIT_HDR_SIZE)
 #define GET_IF_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)	\
 					(GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
@@ -360,5 +373,5 @@
 	T_ICMP6_HDR	hdr;
 	T_IN6_ADDR	target;
-	} __attribute__((packed, aligned(2)))T_NEIGHBOR_HDR;
+	} __attribute__((packed, aligned(2))) T_NEIGHBOR_HDR;
 
 /* 近隣探索オプションヘッダ */
@@ -367,5 +380,5 @@
 	uint8_t		type;			/* オプションタイプ			*/
 	uint8_t		len;			/* オプション長、単位は 8 バイト	*/
-	} __attribute__((packed, aligned(2)))T_ND_OPT_HDR;
+	} __attribute__((packed, aligned(2))) T_ND_OPT_HDR;
 
 #define ND_OPT_HDR_SIZE			(sizeof(T_ND_OPT_HDR))
@@ -393,5 +406,5 @@
 	uint32_t	reserved;
 	T_IN6_ADDR	prefix;		/* プレフィックス		*/
-	} __attribute__((packed, aligned(2)))T_ND_OPT_PREFIX_INFO;
+	} __attribute__((packed, aligned(2))) T_ND_OPT_PREFIX_INFO;
 
 #define ND_OPT_PI_FLAG_ONLINK	UINT_C(0x80)		/* オンリンクプレフィックス	*/
@@ -405,5 +418,5 @@
 	uint16_t	reserved;
 	uint32_t	mtu;		/* MTU				*/
-	} __attribute__((packed, aligned(2)))T_ND_OPT_MTU_HDR;
+	} __attribute__((packed, aligned(2))) T_ND_OPT_MTU_HDR;
 
 /*
@@ -416,5 +429,5 @@
 	T_IN6_ADDR	dst;		/* 向け直しの終点アドレス		*/
 	/* この後にオプションが続く */
-	} __attribute__((packed, aligned(2)))T_ND_REDIRECT_HDR;
+	} __attribute__((packed, aligned(2))) T_ND_REDIRECT_HDR;
 
 #define ND_REDIRECT_HDR_SIZE		(sizeof(T_ND_REDIRECT_HDR))
@@ -480,5 +493,3 @@
 #endif	/* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _IP_ICMP6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp_var.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.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
  *
@@ -94,4 +94,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_var.h>
@@ -106,5 +107,5 @@
 #include <net/if_var.h>
 
-#if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER)
+#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
 
 /*
@@ -118,9 +119,168 @@
  */
 
-static T_ARP_ENTRY *arp_lookup (T_IN4_ADDR addr, bool_t create);
 static void in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input);
 static void arp_timer (void *ignore);
 
 /*
+ *  in_arpinput -- TCP/IP 用 ARP の入力関数
+ */
+
+static void
+in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input)
+{
+	T_NET_BUF	*pending;
+	T_ETHER_HDR	*eth;
+	T_ARP_HDR	*arph;
+	T_ETHER_ARP_HDR	*et_arph;
+	T_ARP_ENTRY	*ent;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN4_ADDR	saddr, taddr;
+
+	et_arph = GET_ETHER_ARP_HDR(input);
+
+	ntoahl(saddr, et_arph->sproto);		/* 送信元 IP アドレス	*/
+	ntoahl(taddr, et_arph->tproto);		/* 解決対象 IP アドレス	*/
+
+	/*
+	 *  以下の場合はエラー
+	 *    ・送信ホストの物理アドレスが自分
+	 *    ・送信ホストの物理アドレスがブロードキャスト
+	 */
+	if (memcmp(et_arph->shost, ifaddr->lladdr,        ETHER_ADDR_LEN) == 0 ||
+	    memcmp(et_arph->shost, ether_broad_cast_addr, ETHER_ADDR_LEN) == 0)
+		goto err_ret;
+
+	/*
+	 *  送信ホストの IP アドレスが自分の場合は、重複しているので
+	 *  相手にも知らせる。
+	 *  ただし、自分と相手のアドレスが未定義（IPV4_ADDRANY）の時は何もしない。
+	 */
+	if ((saddr == ifp->in4_ifaddr.addr) && (saddr != IPV4_ADDRANY)) {
+
+#ifdef ARP_CFG_CALLBACK_DUPLICATED
+
+		if (arp_callback_duplicated(et_arph->shost)) {
+			syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
+			                  ip2str(NULL, &ifp->in4_ifaddr.addr),
+			                  mac2str(NULL, et_arph->shost));
+			taddr = saddr;
+			goto reply;
+			}
+		else
+			goto buf_rel;
+
+#else	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
+
+		syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
+			          ip2str(NULL, &ifp->in4_ifaddr.addr),
+			          mac2str(NULL, et_arph->shost));
+		taddr = saddr;
+		goto reply;
+
+#endif	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
+
+		}
+
+	/*
+	 *  以下の場合は何もしない。
+	 *    ・解決対象 IP アドレスが自分ではない、注: 元の FreeBSD の
+	 *      実装では、ARP PROXY 等のため、自分以外の IP アドレスの
+	 *      解決も行っているが、本実装では、自分以外の IP
+	 *      アドレスの解決は行わない。
+	 */
+	if (taddr != ifp->in4_ifaddr.addr)
+		goto buf_rel;
+
+	/*
+	 *  送信元 IP アドレスが ARP キャッシュにあるか調べる。
+	 *  キャッシュになければ、新たにエントリを登録する。
+	 */
+	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
+	ent = arp_lookup(saddr, true);
+
+	memcpy(ent->mac_addr, et_arph->shost, ETHER_ADDR_LEN);
+	ent->expire = ARP_CACHE_KEEP;
+
+	/*
+	 *  送信がペンデングされているフレームがあれば送信する。
+	 */
+	if (ent->hold) {
+
+		/* フレームの Ethernet ヘッダを設定する。*/
+		memcpy(GET_ETHER_HDR(ent->hold)->dhost, ent->mac_addr, ETHER_ADDR_LEN);
+
+		pending = ent->hold;
+		ent->hold = NULL;
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+
+		/* ペンディングされているフレームを送信する。*/
+		IF_RAW_OUTPUT(pending, TMO_FEVR);
+
+		}
+	else
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+
+reply:
+
+	arph = GET_ARP_HDR(input);
+
+	/* アドレス解決要求でなければ終了 */
+	if (ntohs(arph->opcode) != ARPOP_REQUEST)
+		goto buf_rel;
+
+	/* Ethernet ARP ヘッダを設定する。*/
+	memcpy(et_arph->thost, et_arph->shost, ETHER_ADDR_LEN);
+	memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
+	memcpy(et_arph->tproto, (uint8_t*)&et_arph->sproto, sizeof(T_IN_ADDR));
+	ahtonl(et_arph->sproto, taddr);
+
+	/* Ethernet ARP ヘッダを設定する。*/
+	arph->opcode = htons(ARPOP_REPLY);
+
+	/* Ethernet ヘッダを設定する。*/
+	eth = GET_ETHER_HDR(input);
+	memcpy(eth->dhost, eth->shost,     ETHER_ADDR_LEN);
+	memcpy(eth->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
+
+	/* ARP 応答を送信する。*/
+	IF_RAW_OUTPUT(input, TMO_FEVR);
+	return;
+
+err_ret:
+	NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
+buf_rel:
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  arp_timer -- ARP キャッシュの更新
+ */
+
+static void
+arp_timer (void *ignore)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
+
+	for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
+		if (arp_cache[ix].expire) {
+			arp_cache[ix].expire -= ARP_TIMER_TMO;
+			if (arp_cache[ix].expire == 0) {
+				/* 送信がペンデングされているフレームがあれば捨てる。*/
+				if (arp_cache[ix].hold) {
+					NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+					syscall(rel_net_buf(arp_cache[ix].hold));
+					}
+				memset(&arp_cache[ix], 0, sizeof(T_ARP_ENTRY));
+				}
+			}
+		}
+
+	syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+	timeout(arp_timer, NULL, ARP_TIMER_TMO);
+	}
+
+/*
  *  arp_lookup -- ARP キャッシュの探索と登録
  *
@@ -128,5 +288,5 @@
  */
 
-static T_ARP_ENTRY *
+T_ARP_ENTRY *
 arp_lookup (T_IN4_ADDR addr, bool_t create)
 {
@@ -170,159 +330,4 @@
 
 /*
- *  in_arpinput -- TCP/IP 用 ARP の入力関数
- */
-
-static void
-in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input)
-{
-	T_NET_BUF	*pending;
-	T_ETHER_HDR	*eth;
-	T_ARP_HDR	*arph;
-	T_ETHER_ARP_HDR	*et_arph;
-	T_ARP_ENTRY	*ent;
-	T_IFNET		*ifp = IF_GET_IFNET();
-	T_IN4_ADDR	saddr, taddr;
-
-	et_arph = GET_ETHER_ARP_HDR(input);
-
-	ntoahl(saddr, et_arph->sproto);		/* 送信元 IP アドレス	*/
-	ntoahl(taddr, et_arph->tproto);		/* 解決対象 IP アドレス	*/
-
-	/*
-	 *  以下の場合はエラー
-	 *    ・送信ホストの物理アドレスが自分
-	 *    ・送信ホストの物理アドレスがブロードキャスト
-	 */
-	if (memcmp(et_arph->shost, ifaddr->lladdr,        ETHER_ADDR_LEN) == 0 ||
-	    memcmp(et_arph->shost, ether_broad_cast_addr, ETHER_ADDR_LEN) == 0)
-		goto err_ret;
-
-	/*
-	 *  送信ホストの IP アドレスが自分の場合は、重複しているので
-	 *  相手にも知らせる。
-	 */
-	if (saddr == ifp->in_ifaddr.addr) {
-
-#ifdef ARP_CFG_CALLBACK_DUPLICATED
-
-		if (arp_callback_duplicated(et_arph->shost)) {
-			syslog(LOG_ERROR, "[ARP] IP address duplicated: %s", mac2str(NULL, et_arph->shost));
-			taddr = saddr;
-			goto reply;
-			}
-		else
-			goto buf_rel;
-
-#else	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
-
-		syslog(LOG_ERROR, "[ARP] IP address duplicated: %s", mac2str(NULL, et_arph->shost));
-		taddr = saddr;
-		goto reply;
-
-#endif	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
-
-		}
-
-	/*
-	 *  以下の場合は何もしない。
-	 *    ・解決対象 IP アドレスが自分ではない、注: 元の FreeBSD の
-	 *      実装では、ARP PROXY 等のため、自分以外の IP アドレスの
-	 *      解決も行っているが、本実装では、自分以外の IP
-	 *      アドレスの解決は行わない。
-	 */
-	if (taddr != ifp->in_ifaddr.addr)
-		goto buf_rel;
-
-	/*
-	 *  送信元 IP アドレスが ARP キャッシュにあるか調べる。
-	 *  キャッシュになければ、新たにエントリを登録する。
-	 */
-	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
-	ent = arp_lookup(saddr, true);
-
-	memcpy(ent->mac_addr, et_arph->shost, ETHER_ADDR_LEN);
-	ent->expire = ARP_CACHE_KEEP;
-
-	/*
-	 *  送信がペンデングされているフレームがあれば送信する。
-	 */
-	if (ent->hold) {
-
-		/* フレームの Ethernet ヘッダを設定する。*/
-		memcpy(GET_ETHER_HDR(ent->hold)->dhost, ent->mac_addr, ETHER_ADDR_LEN);
-
-		pending = ent->hold;
-		ent->hold = NULL;
-		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
-
-		/* ペンディングされているフレームを送信する。*/
-		IF_RAW_OUTPUT(pending, TMO_FEVR);
-
-		}
-	else
-		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
-
-reply:
-
-	arph = GET_ARP_HDR(input);
-
-	/* アドレス解決要求でなければ終了 */
-	if (ntohs(arph->opcode) != ARPOP_REQUEST)
-		goto buf_rel;
-
-	/* Ethernet ARP ヘッダを設定する。*/
-	memcpy(et_arph->thost, et_arph->shost, ETHER_ADDR_LEN);
-	memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
-	memcpy(et_arph->tproto, (uint8_t*)&et_arph->sproto, sizeof(T_IN_ADDR));
-	ahtonl(et_arph->sproto, taddr);
-
-	/* Ethernet ARP ヘッダを設定する。*/
-	arph->opcode = htons(ARPOP_REPLY);
-
-	/* Ethernet ヘッダを設定する。*/
-	eth = GET_ETHER_HDR(input);
-	memcpy(eth->dhost, eth->shost,     ETHER_ADDR_LEN);
-	memcpy(eth->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
-
-	/* ARP 応答を送信する。*/
-	IF_RAW_OUTPUT(input, TMO_FEVR);
-	return;
-
-err_ret:
-	NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
-buf_rel:
-	syscall(rel_net_buf(input));
-	}
-
-/*
- *  arp_timer -- ARP キャッシュの更新
- */
-
-static void
-arp_timer (void *ignore)
-{
-	int_t	ix;
-
-	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
-
-	for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
-		if (arp_cache[ix].expire) {
-			arp_cache[ix].expire -= ARP_TIMER_TMO;
-			if (arp_cache[ix].expire == 0) {
-				/* 送信がペンデングされているフレームがあれば捨てる。*/
-				if (arp_cache[ix].hold) {
-					NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
-					syscall(rel_net_buf(arp_cache[ix].hold));
-					}
-				memset(&arp_cache[ix], 0, sizeof(T_ARP_ENTRY));
-				}
-			}
-		}
-
-	syscall(sig_sem(SEM_ARP_CACHE_LOCK));
-	timeout(arp_timer, NULL, ARP_TIMER_TMO);
-	}
-
-/*
  *  arp_request -- MAC アドレス解決要求
  */
@@ -359,5 +364,5 @@
 		/* イーサネット ARP ヘッダを設定する。*/
 		et_arph = GET_ETHER_ARP_HDR(arp_req);
-		src     = IF_GET_IFNET()->in_ifaddr.addr;
+		src     = IF_GET_IFNET()->in4_ifaddr.addr;
 		memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
 		memset(et_arph->thost, 0,              ETHER_ADDR_LEN);
@@ -444,5 +449,5 @@
 	 */
 	if (gw == IPV4_ADDR_BROADCAST ||
-	    gw == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask)) {
+	    gw == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask)) {
 		memcpy(eth->dhost, ether_broad_cast_addr, ETHER_ADDR_LEN);
 		return true;
@@ -504,9 +509,9 @@
 	eaddr->lladdr[1] = UINT_C(0x00);
 	eaddr->lladdr[2] = UINT_C(0x5E);
-	eaddr->lladdr[3] = (maddr & 0x7F0000) >> 16;
-	eaddr->lladdr[4] = (maddr & 0xFF00) >> 8;
-	eaddr->lladdr[5] = maddr & 0xFF;
+	eaddr->lladdr[3] = (uint8_t)((maddr & 0x7F0000) >> 16);
+	eaddr->lladdr[4] = (uint8_t)((maddr & 0xFF00) >> 8);
+	eaddr->lladdr[5] = (uint8_t)(maddr & 0xFF);
 	}
 #endif	/* ETHER_CFG_MULTICAST */
 
-#endif	/* of #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER) */
+#endif	/* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.cfg	(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
  *
@@ -36,5 +36,5 @@
  */
 
-#ifdef SUPPORT_ETHER
+#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
 
 /* ARP キャッシュ更新用セマフォ */
@@ -42,3 +42,3 @@
 CRE_SEM(SEM_ARP_CACHE_LOCK, { TA_TPRI, 1, 1 });
 
-#endif	/* of #ifdef SUPPORT_ETHER */
+#endif	/* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/if_ether.h	(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
  *
@@ -106,4 +106,5 @@
  */
 
+extern T_ARP_ENTRY *arp_lookup (T_IN4_ADDR addr, bool_t create);
 extern ER arp_request (T_IF_ADDR *ifaddr, T_IN4_ADDR dst);
 extern void arp_input (T_IF_ADDR *ifaddr, T_NET_BUF *input);
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in.h	(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
  *
@@ -73,4 +73,5 @@
 #include <tinet_kernel_defs.h>
 
+#include <netinet/in4.h>
 #include <netinet6/in6.h>
 
@@ -79,5 +80,5 @@
  */
 
-#define TINET_PRVER		UINT_C(0x1054)	/* TINET のバージョン番号 */
+#define TINET_PRVER		UINT_C(0x1070)	/* TINET のバージョン番号 */
 
 /*
@@ -92,4 +93,5 @@
 #define IPPROTO_HOPOPTS		UINT_C(0)	/* IPv6 中継点 (Hop-by-Hop) オプション	*/
 #define IPPROTO_ICMP		UINT_C(1)	/* ICMP					*/
+#define IPPROTO_IGMP		UINT_C(2)	/* IGMP					*/
 #define IPPROTO_TCP		UINT_C(6)	/* TCP					*/
 #define IPPROTO_UDP		UINT_C(17)	/* UDP					*/
@@ -107,31 +109,7 @@
 
 /*
- *  IPv4 アドレス
+ *  ポートの長さ
  */
 
-/* 前方参照 */
-
-#ifndef T_IN4_ADDR_DEFINED
-
-typedef uint32_t T_IN4_ADDR;
-
-#define T_IN4_ADDR_DEFINED
-
-#endif	/* of #ifndef T_IN4_ADDR_DEFINED */
-
-/*
- *  ITRON TCP/IPv4 アドレス/ポート番号の定義
- */
-
-typedef struct t_ipv4ep {
-	uint32_t	ipaddr;		/* IPv4 アドレス	*/
-	uint16_t	portno;		/* ポート番号		*/
-	} T_IPV4EP;
-
-/*
- *  アドレス/ポートの長さ
- */
-
-#define IPV4_ADDR_LEN		4
 #define PORT_NUM_LEN		2
 
@@ -152,109 +130,43 @@
 
 /*
- *  IP アドレスの定義
+ *  API IPプロトコルの指定
  */
 
-#define IPV4_ADDRANY		ULONG_C(0x00000000)	/* ITRON TCP/IP 標準	*/
-
-#define IPV4_ADDR_LOOPBACK	ULONG_C(0x7f000001)
-#define IPV4_ADDR_LOOPBACK_MASK	IPV4_CLASS_A_MASK
-#define IPV4_ADDR_BROADCAST	ULONG_C(0xffffffff)
-
-#define IPV4_CLASS_A(i)		(((i) & ULONG_C(0x80000000)) == 0)
-#define IPV4_CLASS_A_NET	ULONG_C(0xff000000)
-#define IPV4_CLASS_A_MASK	ULONG_C(0xff000000)
-#define IPV4_CLASS_A_HOST	ULONG_C(0x00ffffff)
-
-#define IPV4_CLASS_B(i)		(((i) & ULONG_C(0xc0000000)) == ULONG_C(0x80000000))
-#define IPV4_CLASS_B_NET	ULONG_C(0xffff0000)
-#define IPV4_CLASS_B_MASK	ULONG_C(0xffff0000)
-#define IPV4_CLASS_B_HOST	ULONG_C(0x0000ffff)
-
-#define IPV4_CLASS_C(i)		(((i) & ULONG_C(0xe0000000)) == ULONG_C(0xc0000000))
-#define IPV4_CLASS_C_NET	ULONG_C(0xffffff00)
-#define IPV4_CLASS_C_MASK	ULONG_C(0xffffff00)
-#define IPV4_CLASS_C_HOST	ULONG_C(0x000000ff)
-
-#define IPV4_CLASS_D(i)		(((i) & ULONG_C(0xf0000000)) == ULONG_C(0xe0000000))
-
-#define IN4_IS_ADDR_MULTICAST(i)	IPV4_CLASS_D(i)
-
-#define MAKE_IPV4_LOCAL_BROADCAST(i)	(IPV4_CLASS_A(i)?((i)|IPV4_CLASS_A_HOST):\
-					 IPV4_CLASS_B(i)?((i)|IPV4_CLASS_B_HOST):\
-					 IPV4_CLASS_C(i)?((i)|IPV4_CLASS_C_HOST):\
-					 IPV4_ADDR_BROADCAST)
-
-#define MAKE_IPV4_LOCAL_MASK(i)		(IPV4_CLASS_A(i)?IPV4_CLASS_A_MASK:\
-					 IPV4_CLASS_B(i)?IPV4_CLASS_B_MASK:\
-					 IPV4_CLASS_C(i)?IPV4_CLASS_C_MASK:\
-					 IPV4_ADDRANY)
-
-#define MAKE_IPV4_ADDR(a,b,c,d)		((T_IN4_ADDR)(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d)))
+#define API_PROTO_IPVn			'n'
+#define API_PROTO_IPV6			'6'
+#define API_PROTO_IPV4			'4'
 
 /*
- *  動的生成用 TCP 通信端点
+ *  動的生成用 TCP/IPv6 通信端点
  */
 
-typedef struct t_tcp_ccep {
-	/* 標準 */
-	ATR		cepatr;		/* 通信端点属性			*/
-	void		*sbuf;		/* 送信用ウィンドバッファ	*/
-	int_t		sbufsz;		/* 送信用ウィンドバッファサイズ	*/
-	void		*rbuf;		/* 受信用ウィンドバッファ	*/
-	int_t		rbufsz;		/* 受信用ウィンドバッファサイズ	*/
-	FP		callback;	/* コールバック			*/
-	/* 実装依存 */
-	} T_TCP_CCEP;
+#define T_TCP6_CCEP			T_TCP_CCEP
 
 /*
- *  動的生成用 TCP 受付口
+ *  バイトオーダ関数の定義
+ *
+ *    tinet/net/net.h でもバイトオーダの定義を行っているが、
+ *    tinet/net/net.h をインクルードしない
+ *    アプリケーションプログラム用に
+ *    ターゲット依存しないバイトオーダ関数を定義する。
  */
 
-#if defined(SUPPORT_INET4)
+#if defined(_NET_CFG_BYTE_ORDER)
 
-typedef struct t_tcp_crep {
-	/* 標準 */
-	ATR		repatr;		/* 受付口属性		*/
-	T_IPV4EP	myaddr;		/* 自分のアドレス	*/
-	/* 実装依存 */
-	} T_TCP_CREP;
+/*  tinet/net/net.h をインクルードしている。*/
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#else	/* of #if defined(_NET_CFG_BYTE_ORDER) */
 
-/*
- *  動的生成用 UDP 通信端点
- */
+extern uint16_t ntohs (uint16_t net);
+extern uint16_t htons (uint16_t host);
+extern uint32_t ntohl (uint32_t net);
+extern uint32_t htonl (uint32_t host);
 
-#if defined(SUPPORT_INET4)
+#define NTOHS(n)	(n=ntohs(n))
+#define HTONS(h)	(h=htons(h))
+#define NTOHL(n)	(n=ntohl(n))
+#define HTONL(h)	(h=htonl(h))
 
-typedef struct t_udp_ccep {
-	/* 標準 */
-	ATR		cepatr;		/* UDP 通信端点属性		*/
-	T_IPV4EP	myaddr;		/* 自分のアドレス		*/
-	FP		callback;	/* コールバック関数		*/
-	/* 実装依存 */
-	} T_UDP_CCEP;
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-/*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#if defined(SUPPORT_INET4)
-
-#define T_IN_ADDR			T_IN4_ADDR
-#define T_IPEP				T_IPV4EP
-#define IP_ADDRANY			IPV4_ADDRANY
-
-#define IN_ARE_ADDR_EQUAL(n,h)		(*(n)==*(h))
-#define IN_ARE_NET_ADDR_EQUAL(n,h)	(ntohl(*(n))==*(h))
-#define IN_COPY_TO_NET(d,s)		(*(d)=htonl(*(s)))
-#define IN_COPY_TO_HOST(d,s)		(*(d)=ntohl(*(s)))
-#define IN_IS_ADDR_MULTICAST(a)		IN4_IS_ADDR_MULTICAST(*(a))
-#define IN_IS_NET_ADDR_MULTICAST(a)	IN4_IS_ADDR_MULTICAST(ntohl(*(a)))
-#define IN_IS_ADDR_ANY(a)		(*(a)==IPV4_ADDRANY)
-
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_NET_CFG_BYTE_ORDER) */
 
 /*
@@ -264,13 +176,3 @@
 extern const char *in_strtfn (FN fncd);
 
-#if defined(SUPPORT_INET4)
-
-extern ER in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask);
-extern ER in4_add_route (int_t index, T_IN4_ADDR target,
-                                      T_IN4_ADDR mask, T_IN4_ADDR gateway);
-extern char *ip2str (char *buf, const T_IN4_ADDR *p_ipaddr);
-extern const T_IN4_ADDR *in4_get_ifaddr (int_t index);
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
 #endif	/* of #ifndef _IN_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4.h	(revision 331)
@@ -0,0 +1,220 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)in.h	8.3 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
+ */
+ 
+#ifndef _IN4_H_
+#define _IN4_H_
+
+/*
+ *  IPv4 ã¢ãã¬ã¹
+ */
+
+/* åæ¹åç
+§ */
+
+#ifndef T_IN4_ADDR_DEFINED
+
+typedef uint32_t T_IN4_ADDR;
+
+#define T_IN4_ADDR_DEFINED
+
+#endif	/* of #ifndef T_IN4_ADDR_DEFINED */
+
+/*
+ *  ITRON TCP/IPv4 ã¢ãã¬ã¹/ãã¼ãçªå·ã®å®ç¾©
+ */
+
+typedef struct t_ipv4ep {
+	uint32_t	ipaddr;		/* IPv4 ã¢ãã¬ã¹	*/
+	uint16_t	portno;		/* ãã¼ãçªå·		*/
+	} T_IPV4EP;
+
+#define T_IPV4EP_DEFINED
+
+/*
+ *  ã¢ãã¬ã¹ã®é·ã
+ */
+
+#define IPV4_ADDR_LEN		4
+
+/*
+ *  IPv4 ã¢ãã¬ã¹ã®å®ç¾©
+ */
+
+#define IPV4_ADDRANY		ULONG_C(0x00000000)	/* ITRON TCP/IP æ¨æº	*/
+#define IPV4_ADDRBROADCAST	ULONG_C(0xffffffff)
+
+#define IPV4_ADDR_LOOPBACK	ULONG_C(0x7f000001)
+#define IPV4_ADDR_LOOPBACK_MASK	IPV4_CLASS_A_MASK
+#define IPV4_ADDR_BROADCAST	ULONG_C(0xffffffff)
+
+#define IPV4_CLASS_A(i)		(((i) & ULONG_C(0x80000000)) == 0)
+#define IPV4_CLASS_A_NET	ULONG_C(0xff000000)
+#define IPV4_CLASS_A_MASK	ULONG_C(0xff000000)
+#define IPV4_CLASS_A_HOST	ULONG_C(0x00ffffff)
+
+#define IPV4_CLASS_B(i)		(((i) & ULONG_C(0xc0000000)) == ULONG_C(0x80000000))
+#define IPV4_CLASS_B_NET	ULONG_C(0xffff0000)
+#define IPV4_CLASS_B_MASK	ULONG_C(0xffff0000)
+#define IPV4_CLASS_B_HOST	ULONG_C(0x0000ffff)
+
+#define IPV4_CLASS_C(i)		(((i) & ULONG_C(0xe0000000)) == ULONG_C(0xc0000000))
+#define IPV4_CLASS_C_NET	ULONG_C(0xffffff00)
+#define IPV4_CLASS_C_MASK	ULONG_C(0xffffff00)
+#define IPV4_CLASS_C_HOST	ULONG_C(0x000000ff)
+
+#define IPV4_CLASS_D(i)		(((i) & ULONG_C(0xf0000000)) == ULONG_C(0xe0000000))
+
+#define IN4_IS_ADDR_MULTICAST(i)	IPV4_CLASS_D(i)
+
+#define MAKE_IPV4_LOCAL_BROADCAST(i)	(IPV4_CLASS_A(i)?((i)|IPV4_CLASS_A_HOST):\
+					 IPV4_CLASS_B(i)?((i)|IPV4_CLASS_B_HOST):\
+					 IPV4_CLASS_C(i)?((i)|IPV4_CLASS_C_HOST):\
+					 IPV4_ADDR_BROADCAST)
+
+#define MAKE_IPV4_LOCAL_MASK(i)		(IPV4_CLASS_A(i)?IPV4_CLASS_A_MASK:\
+					 IPV4_CLASS_B(i)?IPV4_CLASS_B_MASK:\
+					 IPV4_CLASS_C(i)?IPV4_CLASS_C_MASK:\
+					 IPV4_ADDRANY)
+
+#define MAKE_IPV4_ADDR(a,b,c,d)		((T_IN4_ADDR)(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d)))
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define IN4_ARE_ADDR_EQUAL(dst,src)	(*(dst)==*(src))
+#define IN4_IS_ADDR_ANY(addr)		(*(addr)==IPV4_ADDRANY)
+#define IN4_IS_ADDR_BROADCAST(addr)	(*(addr)==IPV4_ADDRBROADCAST)
+#define ip2str(buf,p_ipaddr)		(ipv42str(buf,p_ipaddr))
+
+/*
+ *  åççæç¨ TCP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_tcp_ccep {
+	/* æ¨æº */
+	ATR		cepatr;		/* éä¿¡ç«¯ç¹å±æ§			*/
+	void		*sbuf;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		sbufsz;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	void		*rbuf;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		rbufsz;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	FP		callback;	/* ã³ã¼ã«ããã¯			*/
+	/* å®è£
+ä¾å­ */
+	} T_TCP_CCEP;
+
+/*
+ *  åççæç¨ TCP åä»å£
+ */
+
+typedef struct t_tcp_crep {
+	/* æ¨æº */
+	ATR		repatr;		/* åä»å£å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+	/* å®è£
+ä¾å­ */
+	} T_TCP_CREP;
+
+/*
+ *  åççæç¨ UDP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_udp_ccep {
+	/* æ¨æº */
+	ATR		cepatr;		/* UDP éä¿¡ç«¯ç¹å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	FP		callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+	/* å®è£
+ä¾å­ */
+	} T_UDP_CCEP;
+
+/*
+ *  TINET ç¬èª API
+ */
+
+extern char *ipv42str (char *buf, const T_IN4_ADDR *p_ipaddr);
+extern uint_t in4_get_maxnum_ifaddr (void);
+extern const T_IN4_ADDR *in4_get_ifaddr (int_t index);
+extern ER in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask);
+extern ER in4_add_route (int_t index, T_IN4_ADDR target,
+                                      T_IN4_ADDR mask, T_IN4_ADDR gateway);
+
+#endif	/* of #ifndef _IN4_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c	(revision 331)
@@ -0,0 +1,535 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+//#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG)
+
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in_rtinit -- ã«ã¼ãã£ã³ã°è¡¨ãåæåããã
+ */
+
+void
+in_rtinit (void)
+{
+	int_t ix;
+
+	for (ix = 0; ix < NUM_IN4_STATIC_ROUTE_ENTRY; ix ++)
+		routing4_tbl[ix].flags = IN_RTF_DEFINED;
+
+	for ( ; ix < NUM_IN4_ROUTE_ENTRY; ix ++)
+		routing4_tbl[ix].flags = 0;
+	}
+
+/*
+ *  in_rtnewentry -- æ°ããã¨ã³ããªãç²å¾ããã
+ */
+
+T_IN4_RTENTRY *
+in_rtnewentry (uint8_t flags, uint32_t tmo)
+{
+	SYSTIM		now;
+	T_IN4_RTENTRY	*rt, *frt = NULL;
+	int_t		ix;
+
+	/* ç©ºãã¨ã³ããªãæ¢ãã*/
+	for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+		rt = &routing4_tbl[ix];
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
+			frt = rt;
+			break;
+			}
+		}
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (frt == NULL) {
+		/* ç©ºãããªããã°ãæå¹æéããã£ã¨ãç­ãã¨ã³ããªãç©ºãã«ããã*/
+		T_IN4_RTENTRY	*srt = NULL;
+		int_t		diff, sdiff = INT_MAX;
+
+		syscall(wai_sem(SEM_IN4_ROUTING_TBL));
+		for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+			rt = &routing4_tbl[ix];
+			diff = (int_t)(rt->expire - now);
+			if (diff <= 0) {	/* rt->expire <= now */
+				/* æ¢ã«ãæå¹æéãéãã¦ããã*/
+				frt = rt;
+				break;
+				}
+			else if (diff < sdiff) {
+				srt = rt;
+				sdiff = diff;
+				}
+			}
+		if (frt == NULL)
+			frt = srt;
+		frt->flags = 0;
+		syscall(sig_sem(SEM_IN4_ROUTING_TBL));
+		}
+
+	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
+	frt->expire = now + tmo / SYSTIM_HZ;
+	return frt;
+	}
+
+/*
+ *  in_rttimer -- ã«ã¼ãã£ã³ã°è¡¨ã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+in_rttimer (void)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	syscall(wai_sem(SEM_IN4_ROUTING_TBL));
+	for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++)
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (int_t)(routing4_tbl[ix].expire - now) <= 0)
+			routing4_tbl[ix].flags = 0;
+	syscall(sig_sem(SEM_IN4_ROUTING_TBL));
+	}
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_get_maxnum_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®å¯è½ãªæå¤§ã¢ãã¬ã¹æ°ãè¿ãã
+ */
+
+uint_t
+in4_get_maxnum_ifaddr (void)
+{
+	return 1;
+	}
+
+/*
+ *  in4_get_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®ããã¦ããã¢ãã¬ã¹ãè¿ãã
+ */
+
+const T_IN4_ADDR *
+in4_get_ifaddr (int_t index)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	return &ifp->in4_ifaddr.addr;
+	}
+
+/*
+ *  in4_set_header -- IPv4 ããããè¨­å®ããã
+ */
+
+ER
+in4_set_header (T_NET_BUF *nbuf, uint_t len,
+                T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl)
+{
+	T_IP4_HDR	*ip4h = GET_IP4_HDR(nbuf);
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	/* IP ããããè¨­å®ããã*/
+	ip4h->vhl	= IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
+	ip4h->len	= htons(IP4_HDR_SIZE + len);
+	ip4h->proto	= proto;
+	ip4h->ttl	= ttl;
+	ip4h->type	= 0;
+	ip4h->id	= ip4h->flg_off = ip4h->sum = 0;
+
+	/* IP ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ip4h->dst	= htonl(*dstaddr);
+
+	if (srcaddr == NULL || *srcaddr == IPV4_ADDRANY)
+		ip4h->src = htonl(ifp->in4_ifaddr.addr);
+	else
+		ip4h->src = htonl(*srcaddr);
+
+	return E_OK;
+	}
+
+/*
+ *  in4_get_datagram -- IPv4 ãã¼ã¿ã°ã©ã ãç²å¾ããããããè¨­å®ããã
+ */
+
+ER
+in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                  T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
+                  uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout)
+{
+	ER	error;
+	uint_t	align;
+
+	/* ãã¼ã¿é·ã 4 ãªã¯ãããå¢çã«èª¿æ´ããã*/
+	align = (len + 3) >> 2 << 2;
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+	if ((error = tget_net_buf_ex(nbuf, (uint_t)(IF_IP4_HDR_SIZE + align),
+	                                   (uint_t)(IF_IP4_HDR_SIZE + maxlen), nbatr, tmout)) != E_OK)
+		return error;
+
+	/*
+	 *  ããå¤§ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ãç²å¾ããå ´åã®ã¿é·ããèª¿æ´ããã
+	 *  ããå°ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã®ç²å¾ã¯ãéä¿¡ã¦ã£ã³ããããã¡ã®
+	 *  çã³ãã¼æ©è½ã§ä½¿ç¨ãããå®éã«éä¿¡ããã¾ã§ããã¼ã¿ãµã¤ãºã¯æ±ºå®ã§ããªãã
+	 */
+	if ((nbatr & NBA_SEARCH_ASCENT) != 0)
+		(*nbuf)->len = (uint16_t)(IF_IP4_HDR_SIZE + len);
+
+	/* IP ããããè¨­å®ããã*/
+	if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
+		return error;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((GET_IP4_SDU(*nbuf) + len), 0, (size_t)(align - len));
+
+	return E_OK;
+	}
+
+/*
+ *  in4_cksum -- IPv4 ã®ãã©ã³ã¹ãã¼ãå±¤ãããã®ãã§ãã¯ãµã ãè¨ç®ããã
+ *
+ *  æ³¨æ: æ»ãå¤ã¯ãããã¯ã¼ã¯ãã¤ããªã¼ã
+ */
+
+uint16_t
+in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len)
+{
+	uint32_t	sum;
+	uint_t		align;
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((uint8_t*)nbuf->buf + off + len, 0, (size_t)(align - len));
+
+	sum = in_cksum_sum(nbuf->buf + off, align)
+	    + in_cksum_sum(&GET_IP4_HDR(nbuf)->src, sizeof(T_IN4_ADDR) * 2)
+	    + len + proto;
+	sum = in_cksum_carry(sum);
+
+	return (uint16_t)(~htons((uint16_t)sum));
+	}
+
+/*
+ *  in_cksum -- ãã§ãã¯ãµã è¨ç®é¢æ°ãIPv4ãICMPv4 ç¨
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ *
+ *        æ»ãå¤ã¯ãããã¯ã¼ã¯ãã¤ããªã¼ã
+ */
+
+uint16_t
+in_cksum (void *data, uint_t len /*ãªã¯ãããåä½*/)
+{
+	uint16_t	sum;
+
+	sum = (uint16_t)in_cksum_carry(in_cksum_sum(data, len));
+	return (uint16_t)(~htons(sum));
+	}
+
+/*
+ *  in4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+
+bool_t
+in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
+{
+	if (*myaddr == IPV4_ADDRANY)
+		return ntohl(*dstaddr) == IF_GET_IFNET()->in4_ifaddr.addr;
+	else
+		return ntohl(*dstaddr) == *myaddr;
+	}
+
+/*
+ *  inn4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+
+bool_t
+inn4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *nbuf)
+{
+	T_IP4_HDR	*iph;
+
+	iph  = GET_IP4_HDR(nbuf);
+	if (*myaddr == IPV4_ADDRANY)
+		return ntohl(iph->dst) == IF_GET_IFNET()->in4_ifaddr.addr;
+	else
+		return ntohl(iph->dst) == *myaddr;
+	}
+
+/*
+ * in4_addrwithifp -- å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+ *                   ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
+ *                   in6_addrwithifp ãã·ãã¥ã¬ã¼ãããã ãã§ã
+ *                   ã¨ã©ã¼ãè¿ããã¨ã¯ãªãã
+ */
+
+T_IN4_ADDR *
+in4_addrwithifp (T_IFNET *ifp, T_IN4_ADDR *src, T_IN4_ADDR *dst)
+{
+	*src = ifp->in4_ifaddr.addr;
+	return src;
+	}
+
+/*
+ *  in4_add_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã« IPv4 ã¢ãã¬ã¹ãè¨­å®ããã
+ */
+
+ER
+in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask)
+{
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ifp->in4_ifaddr.addr = addr;
+	ifp->in4_ifaddr.mask = mask;
+	return E_OK;
+	}
+
+#if NUM_IN4_ROUTE_ENTRY > 0
+
+/*
+ *  in4_add_route -- çµè·¯è¡¨ã«ã¨ã³ããªãè¨­å®ããã
+ */
+
+ER
+in4_add_route (int_t index, T_IN4_ADDR target, T_IN4_ADDR mask, T_IN4_ADDR gateway)
+{
+
+	if (0 <= index && index < NUM_IN4_STATIC_ROUTE_ENTRY) {
+		routing4_tbl[index].target  = target;
+		routing4_tbl[index].mask    = mask;
+		routing4_tbl[index].gateway = gateway;
+		return E_OK;
+		}
+	else
+		return E_PAR;
+	}
+
+#endif	/* of #if NUM_IN4_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_rtalloc -- ã«ã¼ãã£ã³ã°è¡¨ãæ¢ç´¢ããã
+ */
+
+T_IN4_ADDR
+in4_rtalloc (T_IN4_ADDR dst)
+{
+	int_t ix;
+#ifdef ETHER_CFG_MULTICAST
+	if(IN4_IS_ADDR_MULTICAST(dst))
+		return dst;
+#endif /* of #ifdef ETHER_CFG_MULTICAST */
+	for (ix = NUM_IN4_ROUTE_ENTRY; ix --; )
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (dst & routing4_tbl[ix].mask) == routing4_tbl[ix].target) {
+			if (routing4_tbl[ix].gateway == 0)
+				return dst;
+			else {
+				return routing4_tbl[ix].gateway;
+				}
+			}
+	return dst;
+	}
+
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in4_rtredirect -- ã«ã¼ãã£ã³ã°è¡¨ã«ã¨ã³ããªãç»é²ããã
+ *
+ *    æ³¨æ: å¼æ° tmo ã®åä½ã¯ [ms]ã
+ */
+
+void
+in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo)
+{
+	T_IN4_RTENTRY	*frt;
+
+	frt = in_rtnewentry(flags, tmo);
+	frt->gateway    = gateway;
+	frt->target     = target;
+	frt->mask       = 0xffffffff;
+	}
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_timer -- IPv4 å
+±éã¿ã¤ãã¼
+ *
+ *    1ç§å¨æã§èµ·åãããã
+ */
+
+static void
+in4_timer (void *ignore)
+{
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+	in_rttimer();
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+#ifdef IP4_CFG_FRAGMENT
+
+	ip_frag_timer();
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	timeout(in4_timer, NULL, IN_TIMER_TMO);
+	}
+
+/*
+ *  in4_init -- IPv4 å
+±éæ©è½ãåæåããã
+ */
+
+void
+in4_init (void)
+{
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+	in_rtinit();
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+#ifdef SUPPORT_IGMP
+	igmp_init();
+#endif /* of #ifdef SUPPORT_IGMP */
+
+	timeout(in4_timer, NULL, IN_TIMER_TMO);
+	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_var.h	(revision 331)
@@ -0,0 +1,215 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)in_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/in_var.h,v 1.29.2.1 1999/08/29 16:29:38 peter Exp $
+ */
+ 
+#ifndef _IN4_VAR_H_
+#define _IN4_VAR_H_
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½
+ */
+
+typedef struct t_in4_ifaddr {
+	T_IN4_ADDR		addr;		/* IPv4 ã¢ãã¬ã¹	*/
+	T_IN4_ADDR		mask;		/* ãµãããããã¹ã¯	*/
+	} T_IN4_IFADDR;
+
+/*
+ *  ã«ã¼ãã£ã³ã°è¡¨ã¨ã³ããªæ§é ä½
+ */
+
+typedef struct t_in4_rtentry {
+	T_IN4_ADDR	target;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹			*/
+	T_IN4_ADDR	mask;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹ã®ãµãããããã¹ã¯	*/
+	T_IN4_ADDR	gateway;	/* ã²ã¼ãã¦ã§ã¤ã® IP ã¢ãã¬ã¹			*/
+	uint32_t	expire;		/* æå¹æéãåããæå» [s]			*/
+	uint8_t		flags;		/* ãã©ã°					*/
+	} T_IN4_RTENTRY;
+/*
+ *  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ *
+ *  TINET 1.5 ã¨ã®äºææ§ã®ããã«å®ç¾©ãç¡å¹ã«ããã
+ */
+
+#if 0
+#ifdef NUM_ROUTE_ENTRY
+
+#define NUM_IN4_ROUTE_ENTRY		NUM_ROUTE_ENTRY
+#define NUM_IN4_STATIC_ROUTE_ENTRY	NUM_ROUTE_ENTRY
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+#define T_RT_ENTRY			T_IN4_RTENTRY
+
+#endif	/* of #ifdef NUM_ROUTE_ENTRY */
+#endif
+
+/*
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+#ifdef SUPPORT_INET4
+
+extern T_IN4_RTENTRY routing4_tbl[];
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_NET_BUF_DEFINED
+typedef struct t_net_buf T_NET_BUF;
+#define T_NET_BUF_DEFINED
+#endif
+
+#ifndef T_IFNET_DEFINED
+typedef struct t_ifnet T_IFNET;
+#define T_IFNET_DEFINED
+#endif
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define IN4_COPY_TO_HOST(dst,nbuf)	(*(dst)=ntohl(GET_IP4_HDR(nbuf)->src))
+
+/*
+ *  é¢æ°
+ */
+
+extern void ip_input (T_NET_BUF *data);
+extern ER in4_set_header (T_NET_BUF *nbuf, uint_t len,
+                          T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl);
+extern ER in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                            T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
+                            uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout);
+extern uint16_t in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
+extern T_IN4_ADDR in4_rtalloc (T_IN4_ADDR dst);
+extern void in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo);
+extern void in4_init (void);
+extern T_IN4_ADDR *in4_addrwithifp (T_IFNET *ifp, T_IN4_ADDR *src, T_IN4_ADDR *dst);
+extern const T_NET_BUF**ip_get_frag_queue (void);
+
+/*
+ *  in4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+extern bool_t in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr);
+extern bool_t inn4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input);
+
+/*
+ *  in_cksum -- ãã§ãã¯ãµã è¨ç®é¢æ°ãIPv4ãICMPv4 ç¨
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint16_t in_cksum(void *data, uint_t len /*ãªã¯ãããåä½*/);
+
+/*
+ *  in_cksum_sum -- ãã§ãã¯ãµã ã®åè¨è¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint32_t in_cksum_sum (void *data, uint_t len /*ãªã¯ãããåä½*/);
+
+/*
+ *  in_cksum_carry -- ãã§ãã¯ãµã ã®æ¡ä¸ãè¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint32_t in_cksum_carry (uint32_t sum);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _IN4_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h	(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
  *
@@ -66,10 +66,8 @@
 #define tcp_drop		_tinet_tcp_drop
 #define tcp_respond		_tinet_tcp_respond
-#define tcp_set_header		_tinet_tcp_set_header
 #define	tcp_get_segment		_tinet_tcp_get_segment
 #define tcp_rexmt_val		_tinet_tcp_rexmt_val
 #define tcp_init_cep		_tinet_tcp_init_cep
 #define tcp_notify		_tinet_tcp_notify
-#define tcp_find_cep		_tinet_tcp_find_cep
 #define tcp_alloc_auto_port	_tinet_tcp_alloc_auto_port
 #define tcp_alloc_port		_tinet_tcp_alloc_port
@@ -83,4 +81,9 @@
 #define tcp_output_trace	_tinet_tcp_output_trace
 #define tcp_input_trace		_tinet_tcp_input_trace
+#define tcp_find_cep		_tinet_tcp_find_cep
+#define tcp_find_twcep		_tinet_tcp_find_twcep
+#define tcp_is_addr_accept	_tinet_tcp_is_addr_accept
+#define tcp_move_twcep		_tinet_tcp_move_twcep
+#define tcpn_get_segment	_tinet_tcpn_get_segment
 
 /* netinet/tcp_subr_cs.c */
@@ -136,5 +139,6 @@
 /* tcp_cfg.c */
 
-#define tcp_rep			_tinet_tcp_rep
+#define tcp6_rep		_tinet_tcp6_rep
+#define tcp4_rep		_tinet_tcp4_rep
 #define tcp_cep			_tinet_tcp_cep
 #define tcp_twcep		_tinet_tcp_twcep
@@ -146,10 +150,21 @@
 /* netinet/udp_input.c */
 
-#define udp_input		_tinet_udp_input
+#define udp6_reply_no_port	_tinet_udp6_reply_no_port
+#define udp6_input_select	_tinet_udp6_input_select
+#define udp6_input		_tinet_udp6_input
+#define udp4_reply_no_port	_tinet_udp4_reply_no_port
+#define udp4_input_select	_tinet_udp4_input_select
+#define udp4_input		_tinet_udp4_input
 
 /* netinet/udp_subr.c */
 
-#define udp_alloc_port		_tinet_udp_alloc_port
-#define udp_alloc_auto_port	_tinet_udp_alloc_auto_port
+#define udp6_alloc_port		_tinet_udp6_alloc_port
+#define udp6_alloc_auto_port	_tinet_udp6_alloc_auto_port
+#define udp6_notify		_tinet_udp6_notify
+#define udp6_find_cep		_tinet_udp6_find_cep
+#define udp4_alloc_port		_tinet_udp4_alloc_port
+#define udp4_alloc_auto_port	_tinet_udp4_alloc_auto_port
+#define udp4_notify		_tinet_udp4_notify
+#define udp4_find_cep		_tinet_udp4_find_cep
 
 /* netinet/udp_usrreq.c */
@@ -164,5 +179,6 @@
 /* udp_cfg.c */
 
-#define udp_cep			_tinet_udp_cep
+#define udp6_cep		_tinet_udp6_cep
+#define udp4_cep		_tinet_udp4_cep
 #define tmax_udp_cepid		_tinet_tmax_udp_cepid
 #define tmax_udp_ccepid		_tinet_tmax_udp_cepid	/* TINET 1.3 との互換性のための定義 */
@@ -188,18 +204,33 @@
 /* netinet/in_subr.c */
 
+#define inn_addrwithifp		_tinet_inn_addrwithifp
+#define in_cksum_carry		_tinet_in_cksum_carry
+#define inn_is_addr_multicast	_tinet_inn_is_addr_multicast
+#define inn_get_datagram	_tinet_inn_get_datagram
+#define inn_is_dstaddr_accept	_tinet_inn_is_dstaddr_accept
+#define ip_exchg_addr		_tinet_ip_exchg_addr
+#define inn_copy_to_host	_tinet_inn_copy_to_host
+#define in_cksum_sum		_tinet_in_cksum_sum
+#define inn_are_net_srcaddr_equal	\
+				_tinet_inn_are_net_srcaddr_equal
+
+/* netinet/in4_subr.c */
+
+#define in4_add_ifaddr		_tinet_in4_add_ifaddr
 #define in4_set_header		_tinet_in4_set_header
+#define inn4_is_dstaddr_accept	_tinet_inn4_is_dstaddr_accept
+#define in4_rtredirect		_tinet_in4_rtredirect
+#define in_rtnewentry		_tinet_in_rtnewentry
+#define in_cksum		_tinet_in_cksum
+#define	in4_addrwithifp		_tinet_in4_addrwithifp
+#define in4_rtalloc		_tinet_in4_rtalloc
+#define in4_init		_tinet_in4_init
+#define in_rttimer		_tinet_in_rttimer
+#define in4_get_ifaddr		_tinet_in4_get_ifaddr
 #define in4_get_datagram	_tinet_in4_get_datagram
+#define in4_is_dstaddr_accept	_tinet_in4_is_dstaddr_accept
 #define in4_cksum		_tinet_in4_cksum
-#define in4_rtalloc		_tinet_in4_rtalloc
-#define in4_rtredirect		_tinet_in4_rtredirect
-#define in4_init		_tinet_in4_init
-#define in4_is_dstaddr_accept	_tinet_in4_is_dstaddr_accept
+#define in_rtinit		_tinet_in_rtinit
 #define in4_ifawithifp		_tinet_in4_ifawithifp
-#define in_cksum		_tinet_in_cksum
-#define in_cksum_carry		_tinet_in_cksum_carry
-#define in_cksum_sum		_tinet_in_cksum_sum
-#define in_rtnewentry		_tinet_in_rtnewentry
-#define in_rtinit		_tinet_in_rtinit
-#define in_rttimer		_tinet_in_rttimer
 
 /* netinet/if_ether.c */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_subr.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
  *
@@ -71,5 +71,4 @@
 #include <kernel.h>
 #include <sil.h>
-#include <t_syslog.h>
 #include "kernel_cfg.h"
 
@@ -91,6 +90,6 @@
 #include <net/if_ppp.h>
 #include <net/ethernet.h>
-#include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -98,33 +97,122 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
-#include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/tcp_timer.h>
+#include <netinet/in_itron.h>
 
 #include <net/if_var.h>
 
-#if defined(SUPPORT_INET4)
-
-/*
- *  in4_get_ifaddr -- インタフェースに設定されているアドレスを返す。
- */
-
-const T_IN4_ADDR *
-in4_get_ifaddr (int_t index)
-{
-	T_IFNET		*ifp = IF_GET_IFNET();
-
-	return &ifp->in_ifaddr.addr;
-	}
-
-/*
- *  ip2str -- IPv4 アドレスを文字列に変換する。
+/*
+ *  in_cksum_sum -- チェックサムの合計計算関数
+ *
+ *  注意: data は 4 オクテット単位でパディングすること。
+ *        data が 2 オクテット単位にアラインされていないと
+ *        例外が発生する可能性がある。
+ *        len  は 4 オクテット単位にアラインされていること。
+ *
+ *        戻り値はホストバイトオーダ
+ */
+
+uint32_t
+in_cksum_sum (void *data, uint_t len /*オクテット単位*/)
+{
+	uint32_t sum = 0;
+
+	for ( ; len > 0; len -= 2) {
+		sum += *((uint16_t*)data);
+		data = (uint8_t*)data + 2;
+		}
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+	return sum;
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+	return ((sum >> 8) & 0xffff) + ((sum & 0xff) << 8) + ((sum >> 24) & 0xff);
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	}
+
+/*
+ *  in_cksum_carry -- チェックサムの桁上げ計算関数
+ *
+ *  注意: data は 4 オクテット単位でパディングすること。
+ *        data が 2 オクテット単位にアラインされていないと
+ *        例外が発生する可能性がある。
+ *        len  は 4 オクテット単位にアラインされていること。
+ */
+
+uint32_t
+in_cksum_carry (uint32_t sum)
+{
+	uint32_t	carry;
+
+	while (sum >= 0x00010000) {
+		carry = sum >> 16;
+		sum   = (sum & 0xffff) + carry;
+		}
+
+	return sum;
+	}
+
+/*
+ *  in_strtfn -- API 機能コードの文字表現を返す。
+ */
+
+typedef struct t_strtfn {
+	FN		fncd;	/* API 機能コード	*/
+	const char	*str;	/* 文字表現		*/
+	} T_STRTFN;
+
+const T_STRTFN strtfn[] = {
+	{ TEV_TCP_RCV_OOB,	"TEV_TCP_RCV_OOB" },
+	{ TFN_TCP_DEL_REP,	"TFN_TCP_DEL_REP" },
+	{ TFN_TCP_CRE_CEP,	"TFN_TCP_CRE_CEP" },
+	{ TFN_TCP_DEL_CEP,	"TFN_TCP_DEL_CEP" },
+	{ TFN_TCP_ACP_CEP,	"TFN_TCP_ACP_CEP" },
+	{ TFN_TCP_CON_CEP,	"TFN_TCP_CON_CEP" },
+	{ TFN_TCP_SHT_CEP,	"TFN_TCP_SHT_CEP" },
+	{ TFN_TCP_CLS_CEP,	"TFN_TCP_CLS_CEP" },
+	{ TFN_TCP_SND_DAT,	"TFN_TCP_SND_DAT" },
+	{ TFN_TCP_RCV_DAT,	"TFN_TCP_RCV_DAT" },
+	{ TFN_TCP_GET_BUF,	"TFN_TCP_GET_BUF" },
+	{ TFN_TCP_SND_BUF,	"TFN_TCP_SND_BUF" },
+	{ TFN_TCP_RCV_BUF,	"TFN_TCP_RCV_BUF" },
+	{ TFN_TCP_REL_BUF,	"TFN_TCP_REL_BUF" },
+	{ TFN_TCP_SND_OOB,	"TFN_TCP_SND_OOB" },
+	{ TFN_TCP_RCV_OOB,	"TFN_TCP_RCV_OOB" },
+	{ TFN_TCP_CAN_CEP,	"TFN_TCP_CAN_CEP" },
+	{ TFN_TCP_SET_OPT,	"TFN_TCP_SET_OPT" },
+	{ TFN_TCP_GET_OPT,	"TFN_TCP_GET_OPT" },
+	{ TFN_TCP_ALL,		"TFN_TCP_ALL"     },
+
+	{ TEV_UDP_RCV_DAT,	"TEV_UDP_RCV_DAT" },
+	{ TFN_UDP_DEL_CEP,	"TFN_UDP_DEL_CEP" },
+	{ TFN_UDP_SND_DAT,	"TFN_UDP_SND_DAT" },
+	{ TFN_UDP_RCV_DAT,	"TFN_UDP_RCV_DAT" },
+	{ TFN_UDP_CAN_CEP,	"TFN_UDP_CAN_CEP" },
+	{ TFN_UDP_SET_OPT,	"TFN_UDP_SET_OPT" },
+	{ TFN_UDP_GET_OPT,	"TFN_UDP_GET_OPT" },
+	};
+
+const char *
+in_strtfn (FN fncd)
+{
+	int_t	ix;
+
+	for (ix = sizeof(strtfn) / sizeof(T_STRTFN); ix -- > 0; )
+		if (strtfn[ix].fncd == fncd)
+			return strtfn[ix].str;
+
+	return "unknown TFN";
+	}
+
+#if defined(_IP4_CFG)
+
+/*
+ *  ipv42str -- IPv4 アドレスを文字列に変換する。
  */
 
 char *
-ip2str (char *buf, const T_IN4_ADDR *ipaddr)
+ipv42str (char *buf, const T_IN4_ADDR *ipaddr)
 {
 	static char	addr_sbuf[NUM_IPV4ADDR_STR_BUFF][sizeof("123.123.123.123")];
@@ -153,515 +241,271 @@
 	}
 
-/*
- *  in4_set_header -- IPv4 ヘッダを設定する。
+#endif	/* of #if defined(_IP4_CFG) */
+
+/*
+ *  in6_is_addr_ipv4mapped -- IPv4 射影アドレスである事を検査する。
+ */
+
+bool_t
+in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr)
+{
+	return IN6_IS_ADDR_V4MAPPED(addr);
+	}
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+/*
+ *  ip_exchg_addr -- IP アドレスを交換する。
+ */
+
+static void
+ip6_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP6_HDR	*iph;
+	T_IN6_ADDR	ipaddr;
+
+	iph  = GET_IP6_HDR(nbuf);
+
+	/* IPv6 アドレスを交換する。*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+static void
+ip4_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP4_HDR	*iph;
+	T_IN4_ADDR	ipaddr;
+
+	iph  = GET_IP4_HDR(nbuf);
+
+	/* IPv4 アドレスを交換する。*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+void
+ip_exchg_addr (T_NET_BUF *nbuf)
+{
+	if (GET_IP_VER(nbuf) == 6)
+		ip6_exchg_addr(nbuf);
+	else
+		ip4_exchg_addr(nbuf);
+	}
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+/*
+ *  ip_exchg_addr -- IP アドレスを交換する。
+ */
+
+void
+ip_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP_HDR	*iph;
+	T_IN_ADDR	ipaddr;
+
+	iph  = GET_IP_HDR(nbuf);
+
+	/* IP アドレスを交換する。*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+/*
+ *  inn_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
+ */
+
+bool_t
+inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		return INN6_IS_DSTADDR_ACCEPT(myaddr, nbuf);
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h  = GET_IP4_HDR(nbuf);
+		if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
+			return ntohl(ip4h->dst) == IF_GET_IFNET()->in4_ifaddr.addr;
+		else {
+			T_IN6_ADDR	dstaddr;
+
+			return IN6_ARE_ADDR_EQUAL(myaddr, in6_make_ipv4mapped(&dstaddr, ntohl(ip4h->dst)));
+			}
+		}
+	}
+
+/*
+ *  inn_are_net_srcaddr_equal -- アドレスが同一かチェックする。
+ */
+
+bool_t
+inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		return IN6_ARE_ADDR_EQUAL(ipaddr, &GET_IP6_HDR(nbuf)->src);
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
+
+
+		T_IN6_ADDR	srcaddr;
+
+		return IN6_ARE_ADDR_EQUAL(ipaddr, in6_make_ipv4mapped(&srcaddr, ntohl(GET_IP4_HDR(nbuf)->src)));
+		}
+	}
+
+/*
+ *  inn_copy_to_host -- IP ヘッダからホスト表現変換して、IP アドレスをコピーする。
+ */
+
+void
+inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		memcpy(dst, &GET_IP6_HDR(nbuf)->src, sizeof(T_IN6_ADDR));
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/
+		in6_make_ipv4mapped(dst, ntohl(GET_IP4_HDR(nbuf)->src));
+
+	}
+
+/*
+ *  inn_get_datagram -- IPv6/IPv4 データグラムを獲得し、ヘッダを設定する。
  */
 
 ER
-in4_set_header (T_NET_BUF *nbuf, uint_t len,
-                T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl)
-{
-	T_IP4_HDR	*ip4h = GET_IP4_HDR(nbuf);
-	T_IFNET		*ifp = IF_GET_IFNET();
-
-	/* IP ヘッダを設定する。*/
-	ip4h->vhl	= IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
-	ip4h->len	= htons(IP4_HDR_SIZE + len);
-	ip4h->proto	= proto;
-	ip4h->ttl	= ttl;
-	ip4h->type	= 0;
-	ip4h->id	= ip4h->flg_off = ip4h->sum = 0;
-
-	/* IP アドレスを設定する。*/
-	ip4h->dst	= htonl(*dstaddr);
-
-	if (srcaddr == NULL || *srcaddr == IPV4_ADDRANY)
-		ip4h->src = htonl(ifp->in_ifaddr.addr);
+inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
+{
+	if (IN6_IS_ADDR_V4MAPPED(dstaddr)) {
+		T_IN4_ADDR ip4dstaddr, ip4srcaddr;
+
+		ip4dstaddr = ntohl(dstaddr->s6_addr32[3]);
+		if (IN6_IS_ADDR_UNSPECIFIED(srcaddr))
+			ip4srcaddr = IF_GET_IFNET()->in4_ifaddr.addr;
+		else
+			ip4srcaddr = ntohl(srcaddr->s6_addr32[3]);
+
+		return in4_get_datagram(nbuf, len, maxlen, &ip4dstaddr, &ip4srcaddr, next, hlim, nbatr, tmout);
+		}
 	else
-		ip4h->src = htonl(*srcaddr);
-
-	return E_OK;
-	}
-
-/*
- *  in4_get_datagram -- IPv4 データグラムを獲得し、ヘッダを設定する。
- */
-
-ER
-in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                  T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
-                  uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout)
-{
-	ER	error;
-	uint_t	align;
-
-	/* データ長を 4 オクテット境界に調整する。*/
-	align = (len + 3) >> 2 << 2;
-
-	/* ネットワークバッファを獲得する。*/
-	if ((error = tget_net_buf_ex(nbuf, (uint_t)(IF_IP4_HDR_SIZE + align),
-	                                   (uint_t)(IF_IP4_HDR_SIZE + maxlen), nbatr, tmout)) != E_OK)
-		return error;
-
-	/*
-	 *  より大きなサイズのネットワークバッファを獲得する場合のみ長さを調整する。
-	 *  より小さなサイズのネットワークバッファの獲得は、送信ウィンドバッファの
-	 *  省コピー機能で使用され、実際に送信するまで、データサイズは決定できない。
-	 */
-	if ((nbatr & NBA_SEARCH_ASCENT) != 0)
-		(*nbuf)->len = (uint16_t)(IF_IP4_HDR_SIZE + len);
-
-	/* IP ヘッダを設定する。*/
-	if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
-		return error;
-
-	/* 4 オクテット境界までパディングで埋める。*/
-	if (align > len)
-		memset((GET_IP4_SDU(*nbuf) + len), 0, (size_t)(align - len));
-
-	return E_OK;
-	}
-
-/*
- *  in4_cksum -- IPv4 のトランスポート層ヘッダのチェックサムを計算する。
- *
- *  注意: 戻り値はネットワークバイトオーダ
- */
+		return in6_get_datagram(nbuf, len, maxlen, dstaddr, srcaddr, next, hlim, nbatr, tmout);
+	}
+
+/*
+ * inn_addrwithifp -- 宛先アドレスにふさわしい送信元アドレスを、
+ *                   ネットワークインタフェースから探索する。
+ */
+
+T_IN6_ADDR *
+inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst)
+{
+	T_IN6_IFADDR *ifaddr;
+
+	if (IN6_IS_ADDR_V4MAPPED(dst))
+		return in6_make_ipv4mapped (src, ifp->in4_ifaddr.addr);
+	else if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
+		return NULL;
+	else {
+		*src = ifaddr->addr;
+		return src;
+		}
+	}
+
+/*
+ *  inn_is_addr_multicast -- アドレスがマルチキャストアドレスかチェックする。
+ */
+
+bool_t
+inn_is_addr_multicast (T_IN6_ADDR *addr)
+{
+
+	if (IN6_IS_ADDR_V4MAPPED(addr))
+		return IN4_IS_ADDR_MULTICAST(ntohl(addr->s6_addr32[3]));
+	else
+		return IN6_IS_ADDR_MULTICAST(addr);
+	}
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+/*
+ *  バイトオーダ関数の定義
+ *
+ *    tinet/net/net.h でもバイトオーダの定義を行っているが、
+ *    tinet/net/net.h をインクルードしない
+ *    アプリケーションプログラム用に
+ *    ターゲット依存しないバイトオーダ関数を定義する。
+ */
+
+#if defined(_NET_CFG_BYTE_ORDER)
+
+#undef ntohs
+#undef htons
+#undef ntohl
+#undef htonl
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
 
 uint16_t
-in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len)
-{
-	uint32_t	sum;
-	uint_t		align;
-
-	/* 4 オクテット境界のデータ長 */
-	align = (len + 3) >> 2 << 2;
-
-	/* 4 オクテット境界までパディングで埋める。*/
-	if (align > len)
-		memset((uint8_t*)nbuf->buf + off + len, 0, (size_t)(align - len));
-
-	sum = in_cksum_sum(nbuf->buf + off, align)
-	    + in_cksum_sum(&GET_IP4_HDR(nbuf)->src, sizeof(T_IN4_ADDR) * 2)
-	    + len + proto;
-	sum = in_cksum_carry(sum);
-
-	return (uint16_t)(~htons((uint16_t)sum));
-	}
-
-/*
- *  in_cksum -- チェックサム計算関数、IPv4、ICMPv4 用
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- *
- *        戻り値はネットワークバイトオーダ
- */
+ntohs (uint16_t net)
+{
+	return net;
+	}
 
 uint16_t
-in_cksum (void *data, uint_t len /*オクテット単位*/)
-{
-	uint16_t	sum;
-
-	sum = (uint16_t)in_cksum_carry(in_cksum_sum(data, len));
-	return (uint16_t)(~htons(sum));
-	}
-
-/*
- *  in4_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
- *
- *    注意: dstaddr は、
- *          TINET-1.2 からネットワークバイトオーダ、
- *          TINET-1.1 までは、ホストバイトオーダ
- */
-
-bool_t
-in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
-{
-	if (*myaddr == IPV4_ADDRANY)
-		return ntohl(*dstaddr) == IF_GET_IFNET()->in_ifaddr.addr;
-	else
-		return ntohl(*dstaddr) == *myaddr;
-	}
-
-/*
- * in4_ifawithifp -- 宛先アドレスにふさわしい送信元アドレスを、
- *                   ネットワークインタフェースから探索する。
- *                   in6_ifawithifp をシミュレートするだけで、
- *                   エラーを返すことはない。
- */
-
-T_IN4_IFADDR *
-in4_ifawithifp (T_IFNET *ifp, T_IN4_ADDR *dst)
-{
-	return &ifp->in_ifaddr;
-	}
-
-/*
- *  in4_add_ifaddr -- インタフェースに IPv4 アドレスを設定する。
- */
-
-ER
-in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask)
-{
-	T_IFNET	*ifp = IF_GET_IFNET();
-
-	ifp->in_ifaddr.addr = addr;
-	ifp->in_ifaddr.mask = mask;
-	return E_OK;
-	}
-
-#if NUM_ROUTE_ENTRY > 0
-
-/*
- *  in4_add_route -- 経路表にエントリを設定する。
- */
-
-ER
-in4_add_route (int_t index, T_IN4_ADDR target, T_IN4_ADDR mask, T_IN4_ADDR gateway)
-{
-
-	if (0 <= index && index < NUM_STATIC_ROUTE_ENTRY) {
-		routing_tbl[index].target  = target;
-		routing_tbl[index].mask    = mask;
-		routing_tbl[index].gateway = gateway;
-		return E_OK;
-		}
-	else
-		return E_PAR;
-	}
-
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
-
-/*
- *  in4_rtalloc -- ルーティング表を探索する。
- */
-
-T_IN4_ADDR
-in4_rtalloc (T_IN4_ADDR dst)
-{
-	int_t ix;
-
-	for (ix = NUM_ROUTE_ENTRY; ix --; )
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-		    (dst & routing_tbl[ix].mask) == routing_tbl[ix].target) {
-			if (routing_tbl[ix].gateway == 0)
-				return dst;
-			else {
-				return routing_tbl[ix].gateway;
-				}
-			}
-	return dst;
-	}
-
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-/*
- *  in4_rtredirect -- ルーティング表にエントリを登録する。
- *
- *    注意: 引数 tmo の単位は [ms]。
- */
-
-void
-in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo)
-{
-	T_IN_RTENTRY	*frt;
-
-	frt = in_rtnewentry(flags, tmo);
-	frt->gateway    = gateway;
-	frt->target     = target;
-	frt->mask       = 0xffffffff;
-	}
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
-
-/*
- *  in4_timer -- IPv4 共通タイマー
- *
- *    1秒周期で起動される。
- */
-
-static void
-in4_timer (void *ignore)
-{
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rttimer();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
-
-#ifdef IP4_CFG_FRAGMENT
-
-	ip_frag_timer();
-
-#endif	/* of #ifdef IP4_CFG_FRAGMENT */
-
-	timeout(in4_timer, NULL, IN_TIMER_TMO);
-	}
-
-/*
- *  in4_init -- IPv4 共通機能を初期化する。
- */
-
-void
-in4_init (void)
-{
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rtinit();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
-
-	timeout(in4_timer, NULL, IN_TIMER_TMO);
-	}
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-/*
- *  in_rtinit -- ルーティング表を初期化する。
- */
-
-void
-in_rtinit (void)
-{
-	int_t ix;
-
-	for (ix = 0; ix < NUM_STATIC_ROUTE_ENTRY; ix ++)
-		routing_tbl[ix].flags = IN_RTF_DEFINED;
-
-	for ( ; ix < NUM_ROUTE_ENTRY; ix ++)
-		routing_tbl[ix].flags = 0;
-	}
-
-/*
- *  in_rtnewentry -- 新しいエントリを獲得する。
- */
-
-T_IN_RTENTRY *
-in_rtnewentry (uint8_t flags, uint32_t tmo)
-{
-	SYSTIM		now;
-	T_IN_RTENTRY	*rt, *frt = NULL;
-	int_t		ix;
-
-	/* 空きエントリを探す。*/
-	for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++) {
-		rt = &routing_tbl[ix];
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
-			frt = rt;
-			break;
-			}
-		}
-
-	/* expire の単位は [s]。*/
-	syscall(get_tim(&now));
-	now /= SYSTIM_HZ;
-
-	if (frt == NULL) {
-		/* 空きがなければ、有効時間がもっとも短いエントリを空きにする。*/
-		T_IN_RTENTRY	*srt = NULL;
-		int_t		diff, sdiff = INT_MAX;
-
-		syscall(wai_sem(SEM_IN_ROUTING_TBL));
-		for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++) {
-			rt = &routing_tbl[ix];
-			diff = (int_t)(rt->expire - now);
-			if (diff <= 0) {	/* rt->expire <= now */
-				/* 既に、有効時間が過ぎている。*/
-				frt = rt;
-				break;
-				}
-			else if (diff < sdiff) {
-				srt = rt;
-				sdiff = diff;
-				}
-			}
-		if (frt == NULL)
-			frt = srt;
-		frt->flags = 0;
-		syscall(sig_sem(SEM_IN_ROUTING_TBL));
-		}
-
-	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
-	frt->expire = now + tmo / SYSTIM_HZ;
-	return frt;
-	}
-
-/*
- *  in_rttimer -- ルーティング表の管理タイマー
- */
-
-void
-in_rttimer (void)
-{
-	SYSTIM	now;
-	int_t	ix;
-
-	/* expire の単位は [s]。*/
-	syscall(get_tim(&now));
-	now /= SYSTIM_HZ;
-
-	syscall(wai_sem(SEM_IN_ROUTING_TBL));
-	for (ix = NUM_STATIC_ROUTE_ENTRY; ix < NUM_ROUTE_ENTRY; ix ++)
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-		    (int_t)(routing_tbl[ix].expire - now) <= 0)
-			routing_tbl[ix].flags = 0;
-	syscall(sig_sem(SEM_IN_ROUTING_TBL));
-	}
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
-
-/*
- *  in_cksum_sum -- チェックサムの合計計算関数
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- *
- *        戻り値はホストバイトオーダ
- */
+htons (uint16_t host)
+{
+	return host;
+	}
 
 uint32_t
-in_cksum_sum (void *data, uint_t len /*オクテット単位*/)
-{
-	uint32_t sum = 0;
-
-	for ( ; len > 0; len -= 2) {
-		sum += *((uint16_t*)data);
-		data = (uint8_t*)data + 2;
-		}
-
-#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
-	return sum;
-#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
-	return ((sum >> 8) & 0xffff) + ((sum & 0xff) << 8) + ((sum >> 24) & 0xff);
+ntohl (uint32_t net)
+{
+	return net;
+	}
+
+uint32_t
+htonl (uint32_t host)
+{
+	return host;
+	}
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+uint16_t
+ntohs (uint16_t net)
+{
+	return NET_REV_ENDIAN_HWORD(net);
+	}
+
+uint16_t
+htons (uint16_t host)
+{
+	return NET_REV_ENDIAN_HWORD(host);
+	}
+
+uint32_t
+ntohl (uint32_t net)
+{
+	return NET_REV_ENDIAN_WORD(net);
+	}
+
+uint32_t
+htonl (uint32_t host)
+{
+	return NET_REV_ENDIAN_WORD(host);
+	}
+
+#else	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#error "_NET_CFG_BYTE_ORDER expected."
+
 #endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
 
-	}
-
-/*
- *  in_cksum_carry -- チェックサムの桁上げ計算関数
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- */
-
-uint32_t
-in_cksum_carry (uint32_t sum)
-{
-	uint32_t	carry;
-
-	while (sum >= 0x00010000) {
-		carry = sum >> 16;
-		sum   = (sum & 0xffff) + carry;
-		}
-
-	return sum;
-	}
-
-/*
- *  in_strtfn -- API 機能コードの文字表現を返す。
- */
-
-const char *
-in_strtfn (FN fncd)
-{
-	switch (fncd) {
-
-	/* TCP 関係 */
-
-	case TFN_TCP_CRE_REP:
-		return "TFN_TCP_CRE_REP";
-		break;
-	case TFN_TCP_DEL_REP:
-		return "TFN_TCP_DEL_REP";
-		break;
-	case TFN_TCP_CRE_CEP:
-		return "TFN_TCP_CRE_CEP";
-		break;
-	case TFN_TCP_DEL_CEP:
-		return "TFN_TCP_DEL_CEP";
-		break;
-	case TFN_TCP_ACP_CEP:
-		return "TFN_TCP_ACP_CEP";
-		break;
-	case TFN_TCP_CON_CEP:
-		return "TFN_TCP_CON_CEP";
-		break;
-	case TFN_TCP_SHT_CEP:
-		return "TFN_TCP_SHT_CEP";
-		break;
-	case TFN_TCP_CLS_CEP:
-		return "TFN_TCP_CLS_CEP";
-		break;
-	case TFN_TCP_SND_DAT:
-		return "TFN_TCP_SND_DAT";
-		break;
-	case TFN_TCP_RCV_DAT:
-		return "TFN_TCP_RCV_DAT";
-		break;
-	case TFN_TCP_GET_BUF:
-		return "TFN_TCP_GET_BUF";
-		break;
-	case TFN_TCP_SND_BUF:
-		return "TFN_TCP_SND_BUF";
-		break;
-	case TFN_TCP_RCV_BUF:
-		return "TFN_TCP_RCV_BUF";
-		break;
-	case TFN_TCP_REL_BUF:
-		return "TFN_TCP_REL_BUF";
-		break;
-	case TFN_TCP_SND_OOB:
-		return "TFN_TCP_SND_OOB";
-		break;
-	case TFN_TCP_RCV_OOB:
-		return "TFN_TCP_RCV_OOB";
-		break;
-	case TFN_TCP_CAN_CEP:
-		return "TFN_TCP_CAN_CEP";
-		break;
-	case TFN_TCP_SET_OPT:
-		return "TFN_TCP_SET_OPT";
-		break;
-	case TFN_TCP_GET_OPT:
-		return "TFN_TCP_GET_OPT";
-		break;
-	case TFN_TCP_ALL:
-		return "ALL";
-		break;
-
-	/* UDP 関係 */
-
-	case TFN_UDP_CRE_CEP:
-		return "TFN_UDP_CRE_CEP";
-		break;
-	case TFN_UDP_DEL_CEP:
-		return "TFN_UDP_DEL_CEP";
-		break;
-	case TFN_UDP_SND_DAT:
-		return "TFN_UDP_SND_DAT";
-		break;
-	case TFN_UDP_RCV_DAT:
-		return "TFN_UDP_RCV_DAT";
-		break;
-	case TFN_UDP_CAN_CEP:
-		return "TFN_UDP_CAN_CEP";
-		break;
-	case TFN_UDP_SET_OPT:
-		return "TFN_UDP_SET_OPT";
-		break;
-	case TFN_UDP_GET_OPT:
-		return "TFN_UDP_GET_OPT";
-		break;
-
-	default:
-		return "unknown TFN";
-		}
-	}
+#endif	/* of #if defined(_NET_CFG_BYTE_ORDER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h	(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
  *
@@ -71,9 +71,6 @@
 #define _IN_VAR_H_
 
-#if defined(SUPPORT_INET6)
-
+#include <netinet/in4_var.h>
 #include <netinet6/in6_var.h>
-
-#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -102,43 +99,4 @@
 
 /*
- *  インタフェースアドレス構造体
- */
-
-typedef struct t_in4_ifaddr {
-	T_IN4_ADDR		addr;		/* IPv4 アドレス	*/
-	T_IN4_ADDR		mask;		/* サブネットマスク	*/
-	} T_IN4_IFADDR;
-
-/*
- *  ルーティング表エントリ構造体
- */
-
-typedef struct t_in4_rtentry {
-	T_IN4_ADDR	target;		/* 目標ネットワークアドレス			*/
-	T_IN4_ADDR	mask;		/* 目標ネットワークアドレスのサブネットマスク	*/
-	T_IN4_ADDR	gateway;	/* ゲートウェイの IP アドレス			*/
-	uint32_t	expire;		/* 有効時間が切れる時刻 [s]			*/
-	uint8_t		flags;		/* フラグ					*/
-	} T_IN4_RTENTRY;
-
-/*
- *  TINET 1.1 との互換性のための定義
- */
-
-#ifdef NUM_ROUTE_ENTRY
-
-#define NUM_STATIC_ROUTE_ENTRY		NUM_ROUTE_ENTRY
-#define NUM_REDIRECT_ROUTE_ENTRY	0
-#define T_RT_ENTRY			T_IN_RTENTRY
-
-#else	/* of #ifdef NUM_ROUTE_ENTRY */
-
-#define NUM_ROUTE_ENTRY			\
-	(NUM_STATIC_ROUTE_ENTRY + NUM_REDIRECT_ROUTE_ENTRY)
-					/* ルーティング表のエントリ数	*/
-
-#endif	/* of #ifdef NUM_ROUTE_ENTRY */
-
-/*
  *  ルーティングエントリ状態フラグ
  */
@@ -151,97 +109,99 @@
  */
 
-#if defined(SUPPORT_INET4)
-
-#define IN_SET_HEADER(nbuf,len,dst,src,proto,ttl)	\
-					in4_set_header(nbuf,len,dst,src,proto,ttl)
+#if defined(_IP6_CFG)
+
+#define T_IN_ADDR			T_IN6_ADDR
+#define T_IPEP				T_IPV6EP
+#define IP_ADDRANY			IPV6_ADDRANY
+
+#elif defined(_IP4_CFG)	/* of #if defined(_IP6_CFG) */
+
+#define T_IN_ADDR			T_IN4_ADDR
+#define T_IPEP				T_IPV4EP
+#define IP_ADDRANY			IPV4_ADDRANY
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+#define IN_CKSUM(nbuf,proto,off,len)	(GET_IP_VER(nbuf)==IPV6_VERSION	\
+					?in6_cksum(nbuf,proto,off,len)	\
+					:in4_cksum(nbuf,proto,off,len))
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					inn_is_dstaddr_accept(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION	\
+					?IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)	\
+					:IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src))
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+		    			inn_are_net_srcaddr_equal(ipaddr,nbuf)
+#define IN_COPY_TO_HOST(dst,nbuf)	inn_copy_to_host(dst,nbuf)
+#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
+					inn_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
+#define IN_IS_ADDR_MULTICAST(addr)	inn_is_addr_multicast(addr)
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
+#define IN_ADDRWITHIFP(ifp,src,dst)	inn_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN6_IS_ADDR_UNSPECIFIED(addr)
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#define IN_CKSUM(nbuf,proto,off,len)	in6_cksum(nbuf,proto,off,len)
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					INN6_IS_DSTADDR_ACCEPT(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+		    			IN6_ARE_ADDR_EQUAL(ipaddr,&GET_IP6_HDR(nbuf)->src)
+#define IN_COPY_TO_HOST(dst,nbuf)	IN6_COPY_TO_HOST(dst, nbuf)
+#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
+					in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
+#define IN_IS_ADDR_MULTICAST(addr)	IN6_IS_ADDR_MULTICAST(addr)
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
+#define IN_ADDRWITHIFP(ifp,src,dst)	in6_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN6_IS_ADDR_UNSPECIFIED(addr)
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define IN_CKSUM(nbuf,proto,off,len)	in4_cksum(nbuf,proto,off,len)
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					inn4_is_dstaddr_accept(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src)
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+					(*(ipaddr)==ntohl(GET_IP4_HDR(nbuf)->src))
+#define IN_COPY_TO_HOST(dst,nbuf)	IN4_COPY_TO_HOST(dst, nbuf)
 #define IN_GET_DATAGRAM(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)	\
 					in4_get_datagram(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)
-#define IN_CKSUM(nbuf,proto,off,len)	in4_cksum(nbuf,proto,off,len)
-#define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr)			\
-					in4_is_dstaddr_accept(myaddr,dstaddr)
-#define IN_IFAWITHIFP(ifp,dst)		in4_ifawithifp(ifp,dst)
-#define T_IN_IFADDR			T_IN4_IFADDR
-#define T_IN_RTENTRY			T_IN4_RTENTRY
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-/*
- *  ルーティング表
- */
-
-extern T_IN_RTENTRY routing_tbl[];
-
-/*
- *  前方参照
- */
-
-#ifndef T_NET_BUF_DEFINED
-typedef struct t_net_buf T_NET_BUF;
-#define T_NET_BUF_DEFINED
-#endif
-
-#ifndef T_IFNET_DEFINED
-typedef struct t_ifnet T_IFNET;
-#define T_IFNET_DEFINED
-#endif
+#define IN_IS_ADDR_MULTICAST(addr)	IN4_IS_ADDR_MULTICAST(*(addr))
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN4_IS_ADDR_MULTICAST(ntohl(GET_IP4_HDR(nbuf)->dst))
+#define IN_ADDRWITHIFP(ifp,src,dst)	in4_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN4_IS_ADDR_ANY(addr)
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#error "not implemented."
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#ifndef _MACRO_ONLY
 
 /*
  *  関数
  */
-
-extern void ip_input (T_NET_BUF *data);
-extern ER in4_set_header (T_NET_BUF *nbuf, uint_t len,
-                          T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl);
-extern ER in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                            T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
-                            uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout);
-extern uint16_t in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
-extern T_IN4_ADDR in4_rtalloc (T_IN4_ADDR dst);
-extern void in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo);
-extern void in4_init (void);
-extern T_IN4_IFADDR *in4_ifawithifp (T_IFNET *ifp, T_IN4_ADDR *dst);
-extern T_IN_RTENTRY *in_rtnewentry (uint8_t flags, uint32_t tmo);
-extern void in_rttimer (void);
-extern void in_rtinit (void);
-extern const T_NET_BUF**ip_get_frag_queue (void);
-
-/*
- *  in4_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
- *
- *    注意: dstaddr は、
- *          TINET-1.2 からネットワークバイトオーダ、
- *          TINET-1.1 までは、ホストバイトオーダ
- */
-extern bool_t in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr);
-
-/*
- *  in_cksum -- チェックサム計算関数、IPv4、ICMPv4 用
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- */
-extern uint16_t in_cksum(void *data, uint_t len /*オクテット単位*/);
-
-/*
- *  in_cksum_sum -- チェックサムの合計計算関数
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- */
-extern uint32_t in_cksum_sum (void *data, uint_t len /*オクテット単位*/);
-
-/*
- *  in_cksum_carry -- チェックサムの桁上げ計算関数
- *
- *  注意: data は 4 オクテット単位でパディングすること。
- *        data が 2 オクテット単位にアラインされていないと
- *        例外が発生する可能性がある。
- *        len  は 4 オクテット単位にアラインされていること。
- */
-extern uint32_t in_cksum_carry (uint32_t sum);
+extern bool_t	inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf);
+extern bool_t	inn_is_addr_multicast (T_IN6_ADDR *addr);
+extern bool_t	inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf);
+extern void	inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf);
+extern ER	inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+		                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+		                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
+extern T_IN6_ADDR *inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst);
+
+#endif	/* of #ifndef _MACRO_ONLY */
 
 #endif	/* of #ifndef _IN_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.cfg	(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
  *
@@ -36,5 +36,5 @@
  */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 #ifdef IP4_CFG_FRAGMENT
@@ -46,11 +46,11 @@
 #endif	/* of #ifdef IP4_CFG_FRAGMENT */
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
 
 /* ルーティング表（向け直し）*/
 
-CRE_SEM(SEM_IN_ROUTING_TBL, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_IN4_ROUTING_TBL, { TA_TPRI, 1, 1 });
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip.h	(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
  *
@@ -71,4 +71,6 @@
 #define _IP4_H_
 
+#include <netinet/ip6.h>
+
 /*
  *  IPv4 の定義、RFC791 参照
@@ -134,5 +136,5 @@
 /* IPv4 と IPv6 をコンパイル時に選択するためのマクロ */
 
-#if defined(SUPPORT_INET4)
+#if !defined(_IP6_CFG) && defined(_IP4_CFG)
 
 #define IP_HDR_SIZE	IP4_HDR_SIZE
@@ -140,5 +142,5 @@
 #define IP_DEFTTL	IP4_DEFTTL
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
 
 #endif	/* of #ifndef _IP4_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h	(revision 331)
@@ -0,0 +1,268 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)ip_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/ip_var.h,v 1.45.2.1 1999/08/29 16:29:51 peter Exp $
+ */
+ 
+#ifndef _IP4_VAR_H_
+#define _IP4_VAR_H_
+
+/*
+ *  IPv4 ãããã»ãã¤ã­ã¼ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define IF_IP4_HDR_SIZE			(IF_HDR_SIZE + IP4_HDR_SIZE)
+
+#define GET_IP4_HDR(nbuf)		((T_IP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_IP4_SDU(nbuf)		((uint8_t*)((nbuf)->buf) + GET_IF_IP4_HDR_SIZE(nbuf))
+
+#define GET_IP4_HDR_SIZE(nbuf)		((uint8_t)IP4_VHL_HL(GET_IP4_HDR(nbuf)->vhl) << 2)
+#define GET_IP4_SDU_SIZE(nbuf)		(ntohs(GET_IP4_HDR(nbuf)->len) - GET_IP4_HDR_SIZE(nbuf))
+#define GET_IF_IP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP4_HDR_SIZE(nbuf)))
+
+#define SET_IP4_SDU_SIZE(nbuf,slen)	(GET_IP4_HDR(nbuf)->len=(uint16_t)htons((slen) + IP4_HDR_SIZE))
+
+/*
+ *  IP ã® MSS ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf_ip_mss {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_HDR_SIZE + IP4_MSS];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF_IP_MSS;
+
+/*
+ *  65536 ãªã¯ããããµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf4_65536 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_IP4_HDR_SIZE + 65536];
+				/* ãããã¡æ¬ä½		*/
+#if defined(IF_PDU_HDR_PADDING)
+	uint8_t		padding[IF_PDU_HDR_PADDING];
+#endif				/* ãããã®ä½å		*/
+	} T_NET_BUF4_65536;
+
+#ifdef IP4_CFG_FRAGMENT
+
+/*
+ *  åæ§æã­ã¥ã¼ç¨ IPv4 ãããã®å®ç¾©
+ */
+
+typedef struct t_qip4_hdr {
+	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
+					/* length ã¯ 4 octets åä½		*/
+	uint8_t		type;		/* type of services			*/
+	uint16_t	len;		/* total length				*/
+
+	uint16_t	id;		/* identification			*/
+	uint16_t	flg_off;	/* fragment flag & offset		*/
+
+	uint8_t		ttl;		/* time to live				*/
+	uint8_t		proto;		/* protocol				*/
+	uint16_t	sum;		/* checksum				*/
+
+	uint32_t	src;		/* source address			*/
+
+	T_NET_BUF	*next;		/* æ¬¡ã® IPv4 ãã©ã°ã¡ã³ã			*/
+	} __attribute__((packed, aligned(2))) T_QIP4_HDR;
+
+#define QIP4_HDR_SIZE			(sizeof(T_QIP4_HDR))
+#define IF_QIP4_HDR_SIZE		(IF_HDR_SIZE + QIP4_HDR_SIZE)
+
+#define GET_QIP4_HDR(nbuf)		((T_QIP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_QIP4_SDU(nbuf)		((uint8_t*)(nbuf)->buf + GET_IF_QIP4_HDR_SIZE(nbuf))
+
+#define GET_QIP4_HDR_SIZE(iph)		((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
+#define GET_IF_QIP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_QIP4_HDR_SIZE(GET_QIP4_HDR(nbuf))))
+
+/*
+ *  ãã¼ã¿ã°ã©ã åæ§æç¨ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf4_reassm {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		align[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IP4_CFG_FRAG_REASSM_SIZE];
+				/* ãããã¡æ¬ä½		*/
+	} __attribute__((packed, aligned(2))) T_NET_BUF4_REASSM;
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+/*
+ *  TCP ã®åæ§æã­ã¥ã¼ã«ããã IPv4 ãããã®å®ç¾©
+ */
+
+typedef struct t_ip4_tcp_q_hdr {
+	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
+					/* length ã¯ 4 octets åä½		*/
+	uint8_t		type;		/* type of services			*/
+	uint16_t	len;		/* total length				*/
+
+	uint16_t	id;		/* identification			*/
+	uint16_t	flg_off;	/* fragment flag & offset		*/
+
+	uint8_t		ttl;		/* time to live				*/
+	uint8_t		proto;		/* protocol				*/
+	uint16_t	thoff;		/* TCP ãããã®ãªãã»ãã		*/
+
+	T_IN4_ADDR	src;		/* source address			*/
+	T_IN4_ADDR	dst;		/* destination address			*/
+	} __attribute__((packed, aligned(2))) T_IP4_TCP_Q_HDR;
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_ip_stats {
+	uint32_t	ipInReceives;
+	uint32_t	ipInHdrErrors;
+	uint32_t	ipInAddrErrors;
+/*	uint32_t	ipForwDatagrams;*/
+	uint32_t	ipInUnknownProtos;
+/*	uint32_t	ipInDiscards;*/
+	uint32_t	ipInDelivers;
+	uint32_t	ipOutRequests;
+	uint32_t	ipOutDiscards;
+/*	uint32_t	ipOutNoRoutes;*/
+
+#ifdef IP4_CFG_FRAGMENT
+
+	uint32_t	ipReasmReqds;
+	uint32_t	ipReasmOKs;
+	uint32_t	ipReasmFails;
+	uint32_t	ipFragOKs;
+	uint32_t	ipFragFails;
+	uint32_t	ipFragCreates;
+
+#else	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	uint32_t	ipReasmReqds;
+/*	uint32_t	ipReasmOKs;*/
+	uint32_t	ipReasmFails;
+/*	uint32_t	ipFragOKs;*/
+/*	uint32_t	ipFragFails;*/
+/*	uint32_t	ipFragCreates;*/
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+} T_IP_STATS;
+
+extern T_IP_STATS ip_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  é¢æ°
+ */
+
+extern void ip_frag_timer (void);
+extern void ip_init (void);
+extern ER ip_remove_options (T_NET_BUF *nbuf);
+extern ER ip_output (T_NET_BUF *nbuf, TMO tmout);
+extern void ip_exchg_addr (T_NET_BUF *nbuf);
+
+#endif	/* of #ifndef _IP4_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip6.h	(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
  *
@@ -102,6 +102,4 @@
 #define _IP6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  IPv6 の定義、RFC2460 参照
@@ -262,5 +260,5 @@
 
 /*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
+ *  IPv6 と IPv4 をコンパイル時に選択するためのマクロ
  */
 
@@ -273,5 +271,5 @@
 /* ルータ通知を受信する場合は、通知された値 */
 
-#define IP_DEFTTL	ip6_defhlim
+#define IP6_DEFTTL	ip6_defhlim
 
 #else	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
@@ -279,12 +277,17 @@
 /* ルータ通知を受信しない場合の値は既定値 */
 
-#define IP_DEFTTL	IPV6_DEFHLIM
+#define IP6_DEFTTL	IPV6_DEFHLIM
 
 #endif	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/* IPv4 と IPv6 をコンパイル時に選択するためのマクロ */
+
+#ifdef _IP6_CFG
 
 #define IP_HDR_SIZE	IP6_HDR_SIZE
 #define T_IP_HDR	T_IP6_HDR
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+#define IP_DEFTTL	IP6_DEFTTL
+
+#endif	/* of #ifdef _IP6_CFG */
 
 #endif	/* of #ifndef _IP6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.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
  *
@@ -76,4 +76,5 @@
 #include <t_syslog.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -83,4 +84,5 @@
 #include <s_services.h>
 #include <t_services.h>
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -95,4 +97,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -106,6 +109,10 @@
 #include <netinet/icmp_var.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG)
 
 /*
@@ -130,4 +137,5 @@
 static void icmp_unreach (T_NET_BUF *input, uint_t ihoff);
 
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
 #if NUM_REDIRECT_ROUTE_ENTRY > 0
 
@@ -135,4 +143,5 @@
 
 #endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
 
 /*
@@ -147,32 +156,40 @@
 	T_IP4_HDR	*ip4h;
 	T_ICMP4_HDR	*icmp4h;
-	T_IN4_ADDR	addr;
+	T_IFNET		*ifp = IF_GET_IFNET();
 
 	NET_COUNT_MIB(icmp_stats.icmpInEchos, 1);
 
-	/* メッセージの型をエコー要求 (8) から エコー応答 (0) に	*/
-	/* 変更して送り返す。					*/
-
-	icmp4h = GET_ICMP4_HDR(input, ihoff);
-	icmp4h->type = ICMP4_ECHO_REPLY;
-
-	/* IP ヘッダの宛先と発信元を交換する。*/
-	ip4h      = GET_IP4_HDR(input);
-	addr      = ip4h->src;
-	ip4h->src = ip4h->dst;
-	ip4h->dst = addr;
-
-	/* チェックサムを計算する。*/
-	icmp4h->sum = 0;
-	icmp4h->sum = in_cksum(icmp4h,
-	                       (uint_t)(((input->len - GET_IF_IP4_HDR_SIZE(input)) + 3) >> 2 << 2));
-
-	/* 送信する。*/
-	NET_COUNT_ICMP4(net_count_icmp4.out_octets,
-	               input->len - GET_IF_IP4_HDR_SIZE(input));
-	NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
-	NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
-	NET_COUNT_MIB(icmp_stats.icmpOutEchoReps, 1);
-	ip_output(input, TMO_ICMP_OUTPUT);
+	/* IPv4 アドレスが未定義の時は応答しない。*/
+	if (!IN4_IS_ADDR_ANY(&ifp->in4_ifaddr.addr)) {
+
+		/*
+		 *  メッセージの型をエコー要求 (8) から
+		 *  エコー応答 (0) に変更して送り返す。
+		 */
+
+		icmp4h = GET_ICMP4_HDR(input, ihoff);
+		icmp4h->type = ICMP4_ECHO_REPLY;
+
+		/*
+		 *  宛先アドレスは受信したメッセージの送信元アドレス。
+		 *  送信元アドレスは自 IPv4 アドレス。
+		 */
+		ip4h      = GET_IP4_HDR(input);
+		ip4h->dst = ip4h->src;
+		ip4h->src = htonl(ifp->in4_ifaddr.addr);
+
+		/* チェックサムを計算する。*/
+		icmp4h->sum = 0;
+		icmp4h->sum = in_cksum(icmp4h,
+		                       (uint_t)(((input->len - GET_IF_IP4_HDR_SIZE(input)) + 3) >> 2 << 2));
+
+		/* 送信する。*/
+		NET_COUNT_ICMP4(net_count_icmp4.out_octets,
+		               input->len - GET_IF_IP4_HDR_SIZE(input));
+		NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
+		NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
+		NET_COUNT_MIB(icmp_stats.icmpOutEchoReps, 1);
+		ip_output(input, TMO_ICMP_OUTPUT);
+		}
 	}
 
@@ -212,13 +229,24 @@
 	code  = GET_ICMP4_HDR(input, ihoff)->code;
 	error = code2error[code];
-	if (ip4h->proto == IPPROTO_TCP) {
-
-#ifdef SUPPORT_TCP
+
+	/* 最終ヘッダが TCP/UDP のみ対応する。*/
+	if (ip4h->proto == IPPROTO_TCP || ip4h->proto == IPPROTO_UDP) {
 
 		memcpy(GET_IP4_HDR(input), ip4h, input->len - (IP4_HDR_SIZE + ICMP4_HDR_SIZE));
 		input->len -= IP4_HDR_SIZE + ICMP4_HDR_SIZE;
-		tcp_notify(input, error);
-
-#endif	/* of #ifdef SUPPORT_TCP */
+
+#if defined(SUPPORT_TCP)
+
+		if (ip4h->proto == IPPROTO_TCP)
+			tcp_notify(input, error);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0
+
+		if (ip4h->proto == IPPROTO_UDP)
+			udp4_notify(input, error);
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
 
 		}
@@ -227,4 +255,5 @@
 	}
 
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
 #if NUM_REDIRECT_ROUTE_ENTRY > 0
 
@@ -264,4 +293,5 @@
 
 #endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
 
 /*
@@ -314,9 +344,9 @@
 	case ICMP4_ECHO_REPLY:
 
-#ifdef ICMP_CFG_CALLBACK_ECHO_REPLY
+#if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY)
 
 		icmp_echo_reply(input, *offp);
 
-#endif	/* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
+#endif	/* of #if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY) */
 
 		break;
@@ -326,4 +356,5 @@
 	case ICMP4_REDIRECT:
 
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
 #if NUM_REDIRECT_ROUTE_ENTRY > 0
 
@@ -338,4 +369,10 @@
 
 #endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+		addr = ntohl(icmp4h->data.addr);
+		syslog(LOG_INFO, "[ICMP] redirect ignored, addr: %s.", ip2str(NULL, &addr));
+
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
 
 		break;
@@ -371,5 +408,5 @@
 
 	ip4h  = GET_IP4_HDR(input);
-	ip4hl = GET_IP4_HDR_SIZE(ip4h);
+	ip4hl = GET_IP4_HDR_SIZE(input);
 
 	/* 送信用の IP データグラムを獲得する。*/
@@ -378,5 +415,5 @@
 	else
 		len = 8;
-
+	
 	saddr = ntohl(ip4h->src);
 	if (in4_get_datagram(&output, (uint_t)(ICMP4_HDR_SIZE + ip4hl + len), 0,
@@ -417,2 +454,4 @@
 
 #endif	/* of #ifdef ICMP_REPLY_ERROR */
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_icmp.h	(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
  *
@@ -71,4 +71,6 @@
 #define _IP_ICMP_H_
 
+#include <netinet/icmp6.h>
+
 /*
  *  ICMP ヘッダの定義、RFC 792
@@ -96,7 +98,7 @@
 #define GET_ICMP4_SDU(nbuf,ihoff)	((uint8_t*)((nbuf)->buf) + ihoff + ICMP4_HDR_SIZE)
 
-#define GET_ICMP4_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
+#define GET_ICMP4_HDR_OFFSET(nbuf)	(GET_IF_IP4_HDR_SIZE(nbuf))
 
-#define GET_IP4_ICMP4_HDR_SIZE(nbuf)	(GET_IP4_HDR_SIZE(GET_IP4_HDR(nbuf)) + ICMP4_HDR_SIZE)
+#define GET_IP4_ICMP4_HDR_SIZE(nbuf)	(GET_IP4_HDR_SIZE(nbuf) + ICMP4_HDR_SIZE)
 #define GET_IF_IP4_ICMP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + GET_IP4_ICMP4_HDR_SIZE(nbuf))
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c	(revision 331)
@@ -0,0 +1,409 @@
+/*
+*  TINET (TCP/IP Protocol Stack)
+*
+*  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+*                   Tomakomai National College of Technology, JAPAN
+*
+*  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation
+*  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
+*  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
+*  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
+*  pÆÄÔj·é±Æð³Åø·éD
+*  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+*       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+*      XR[hÉÜÜêÄ¢é±ÆD
+*  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+*      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+*      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+*      Ì³ÛØKèðfÚ·é±ÆD
+*  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+*      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
+*    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+*        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+*  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+*      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+*
+*  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+*  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
+*  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
+*  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+*
+*  @(#) $Id$
+*/
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+#include <netinet/ip_igmp.h>
+
+#include <net/if_var.h>
+#include <net/net_var.h>
+
+#ifdef SUPPORT_IGMP
+
+static T_IGMP_ENTRY igmp_groups[NUM_IGMP_ENTRY];
+static T_IN4_ADDR igmp_send_addrs[NUM_IGMP_ENTRY];
+
+static bool_t igmp_send_report_v2(T_IN4_ADDR dst);
+static uint16_t igmp_get_timer(T_IGMP_ENTRY *entry);
+
+ER igmp_set_loop(T_UDP_CEP *cep, uint8_t optval)
+{
+	switch (optval) {
+	case 0:
+		cep->igmp_loopback = false;
+		return E_OK;
+	case 1:
+		cep->igmp_loopback = true;
+		return E_OK;
+	}
+
+	return E_PAR;
+}
+
+ER igmp_get_loop(T_UDP_CEP *cep, uint8_t *optval)
+{
+	if (optval == NULL)
+		return E_PAR;
+
+	*optval = cep->igmp_loopback ? 1 : 0;
+
+	return E_OK;
+}
+
+ER igmp_set_ttl(T_UDP_CEP *cep, uint8_t optval)
+{
+	cep->igmp_ttl = optval;
+
+	return E_OK;
+}
+
+ER igmp_get_ttl(T_UDP_CEP *cep, uint8_t *optval)
+{
+	if (optval == NULL)
+		return E_PAR;
+
+	*optval = cep->igmp_ttl;
+
+	return E_OK;
+}
+
+ER igmp_set_if(T_UDP_CEP *cep, T_IN4_ADDR *optval)
+{
+	if (optval == NULL)
+		return E_PAR;
+
+	cep->igmp_mcaddr = *optval;
+
+	return E_OK;
+}
+
+ER igmp_get_if(T_UDP_CEP *cep, T_IN4_ADDR *optval)
+{
+	if (optval == NULL)
+		return E_PAR;
+
+	*optval = cep->igmp_mcaddr;
+
+	return E_OK;
+}
+
+ER igmp_add_membership(T_UDP_CEP *cep, T_IP_MREQ *optval)
+{
+	T_IGMP_ENTRY *entry = NULL;
+	int		i;
+	uint16_t	min;
+	T_IFNET	*ifp = IF_GET_IFNET();
+	ER ret = E_NOMEM;
+
+	if ((optval->imr_interface != IPV4_ADDRANY)
+		&& (optval->imr_interface != ifp->in4_ifaddr.addr))
+		return E_PAR;
+
+	syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
+
+	for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+		entry = &igmp_groups[i];
+		if (entry->timer == -1) {
+			entry->timer = igmp_get_timer(entry);
+			entry->ip_addr = optval->imr_multiaddr;
+			ret = E_OK;
+			break;
+		}
+	}
+
+	syscall(sig_sem(SEM_IGMP_GROUP_LOCK));
+
+	return ret;
+}
+
+ER igmp_drop_membership(T_UDP_CEP *cep, T_IP_MREQ *optval)
+{
+	T_IGMP_ENTRY *entry = NULL;
+	int		i;
+	uint16_t	min;
+	ER ret = E_PAR;
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	if ((optval->imr_interface != IPV4_ADDRANY)
+		&& (optval->imr_interface != ifp->in4_ifaddr.addr))
+		return E_PAR;
+
+	syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
+
+	for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+		entry = &igmp_groups[i];
+		if ((entry->timer >= 0) && (entry->ip_addr == optval->imr_multiaddr)) {
+			entry->timer = -1;
+			entry->ip_addr = 0;
+			ret = E_OK;
+			break;
+		}
+	}
+
+	syscall(sig_sem(SEM_IGMP_GROUP_LOCK));
+
+	return ret;
+}
+
+ER igmp_set_ip_msfilter(T_UDP_CEP *cep, const T_IP_MSFILTER *optval)
+{
+	return E_PAR;
+}
+
+ER igmp_get_ip_msfilter(T_UDP_CEP *cep, T_IP_MSFILTER *optval)
+{
+	return E_PAR;
+}
+
+uint_t igmp_input(T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_IGMPV2_HDR	*igmph;
+	T_IN4_ADDR	addr;
+	uint_t		len, align;
+	T_IP4_HDR	*ip4h;
+	int i;
+	T_IGMP_ENTRY *entry;
+	bool_t ret;
+
+	NET_COUNT_IGMP(net_count_igmp.in_octets,
+		input->len - GET_IF_IP4_HDR_SIZE(input));
+	NET_COUNT_IGMP(net_count_igmp.in_packets, 1);
+
+	/* ICMP wb_Ì·³ð`FbN·éB*/
+	if (input->len < IF_IP4_IGMP_HDR_SIZE) {
+		NET_COUNT_IGMP(net_count_igmp.in_err_packets, 1);
+		NET_COUNT_MIB(igmp_stats.igmpInErrors, 1);
+		goto buf_rel;
+	}
+
+	igmph = (T_IGMPV2_HDR *)(input->buf + *offp);
+
+	/* 4 INebg«EÌf[^· */
+	len = input->len - *offp;
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 INebg«EÜÅpfBOÅßéB*/
+	if (align > len)
+		memset((uint8_t*)input->buf + input->len, 0, (size_t)(align - len));
+
+	/* `FbNTðvZ·éB*/
+	if (in_cksum(igmph, align) != 0) {
+		NET_COUNT_IGMP(net_count_igmp.in_err_packets, 1);
+		goto buf_rel;
+	}
+
+	/* bZ[WÌ^Éæèªò·éB*/
+	switch (igmph->type) {
+	case IGMP_MEMBERSHIP_QUERY:
+		ip4h = GET_IP4_HDR(input);
+		ret = false;
+
+		/* QÁÌO[vAhX©çÌNG[Ìê */
+		syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
+
+		for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+			entry = &igmp_groups[i];
+			if ((entry->timer >= 0) && (entry->ip_addr == addr)) {
+				entry->resptime = igmph->time;
+				ret = true;
+				break;
+			}
+		}
+
+		syscall(sig_sem(SEM_IGMP_GROUP_LOCK));
+
+		if (ret) {
+			/* o[Vbv|[gðM */
+			igmp_send_report_v2(ip4h->src);
+		}
+		break;
+	}
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+}
+
+static bool_t igmp_send_report_v2(T_IN4_ADDR dst)
+{
+	T_IGMPV2_HDR	*igmph;
+	T_NET_BUF		*output;
+	uint_t			len, align;
+
+	if (in4_get_datagram(&output, (uint_t)(IF_IP4_IGMP_HDR_SIZE + len), 0,
+		&dst, NULL, IPPROTO_IGMP, IP4_DEFTTL,
+		NBA_SEARCH_ASCENT, TMO_IGMP_OUTPUT) != E_OK)
+		return false;
+
+	/* IGMP wb_ðÝè·éB*/
+	igmph = GET_IGMPV2_HDR(output, IF_IP4_IGMP_HDR_OFFSET);
+	igmph->type = IGMP_MEMBERSHIP_REPORT_V2;
+	igmph->time = 0;
+	igmph->addr = dst;
+
+	/* 4 INebg«EÌf[^· */
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 INebg«EÜÅpfBOÅßéB*/
+	if (align > len)
+		memset((uint8_t*)GET_IGMP_SDU(output, IF_IP4_IGMP_HDR_OFFSET) + IP4_HDR_SIZE + len,
+			0, (size_t)(align - len));
+
+	/* `FbNTðvZ·éB*/
+	igmph->sum = 0;
+	igmph->sum = in_cksum(igmph, (uint_t)(IF_IP4_IGMP_HDR_SIZE + align));
+
+	/* M·éB*/
+	NET_COUNT_IGMP(net_count_igmp.out_octets,
+		output->len - GET_IF_IP4_HDR_SIZE(output));
+	NET_COUNT_IGMP(net_count_igmp.out_packets, 1);
+	NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp_stats.icmpOutDestUnreachs, 1);
+	ip_output(output, TMO_IGMP_OUTPUT);
+
+	return true;
+}
+
+/*
+*  igmp_timer -- IGMP ¤Ê^C}[
+*/
+static void igmp_timer(void *ignore)
+{
+	T_IGMP_ENTRY *entry = NULL;
+	int i, j = 0;
+
+	/* memset(igmp_send_addrs, 0, sizeof(igmp_send_addrs)); */
+
+	syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
+
+	for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+		entry = &igmp_groups[i];
+		if (entry->timer > 0)
+			entry->timer--;
+		if (entry->timer == 0) {
+			entry->timer = igmp_get_timer(entry);
+			igmp_send_addrs[j++] = entry->ip_addr;
+		}
+	}
+
+	syscall(sig_sem(SEM_IGMP_GROUP_LOCK));
+
+	for (i = 0; i < j; i++) {
+		igmp_send_report_v2(igmp_send_addrs[i]);
+	}
+
+	timeout(igmp_timer, NULL, NET_TIMER_HZ / 1);
+}
+
+/*
+*  igmp_init -- IGMP @\ðú»·éB
+*/
+
+void igmp_init(void)
+{
+	T_IGMP_ENTRY *entry = NULL;
+	int i;
+
+	for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+		igmp_groups[i].timer = -1;
+	}
+
+	timeout(igmp_timer, NULL, NET_TIMER_HZ / 1);
+}
+
+bool_t igmp_is_joined_group(T_IN4_ADDR addr)
+{
+	T_IGMP_ENTRY *entry = NULL;
+	int		i;
+	bool_t ret = false;
+
+	syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
+
+	for (i = 0; i < NUM_IGMP_ENTRY; i++) {
+		entry = &igmp_groups[i];
+		if ((entry->timer >= 0) && (entry->ip_addr == addr)) {
+			ret = true;
+			break;
+		}
+	}
+
+	syscall(sig_sem(SEM_IGMP_GROUP_LOCK));
+
+	return ret;
+}
+
+uint16_t igmp_get_timer(T_IGMP_ENTRY *entry)
+{
+	uint16_t time = entry->resptime;
+
+	if (time == 0)
+		time = 10;
+
+	return net_rand() / (0x7fffffff / time);
+}
+
+#endif /* of #ifdef SUPPORT_IGMP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg	(revision 331)
@@ -0,0 +1,49 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation 
+ *  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
+ *  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
+ *  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
+ *  pÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
+ *  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
+ *  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  IGMP RtBM
+[Vt@C
+ */
+
+#if defined(_IP4_CFG) && defined(SUPPORT_IGMP)
+
+/* IGMP O[vXVpZ}tH */
+
+CRE_SEM(SEM_IGMP_GROUP_LOCK, { TA_TPRI, 1, 1 });
+
+#endif	/* of #if defined(_IP4_CFG) && defined(SUPPORT_IGMP) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h	(revision 331)
@@ -0,0 +1,184 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ *
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation
+ *  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
+ *  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
+ *  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
+ *  pÆÄÔj·é±Æð³Åø·éD
+ *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
+ *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
+ *      XR[hÉÜÜêÄ¢é±ÆD
+ *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
+gip
+ *      Ò}j
+AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
+ *      Ì³ÛØKèðfÚ·é±ÆD
+ *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
+ *      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
+ *    (a) ÄzzÉº¤hL
+gipÒ}j
+AÈÇjÉCãLÌ
+ *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
+ *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
+ *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *
+ *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
+ *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
+ *  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
+ *  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+ *
+ *  @(#) $Id$
+ */
+
+#ifndef _IP_IGMP_H_
+#define _IP_IGMP_H_
+
+#define NUM_IGMP_ENTRY				5	/* }`LXgO[vÌGg */
+
+#ifdef __CA850__
+#pragma pack(1)
+#elif __RX
+#pragma pack
+#elif _MSC_VER
+#pragma pack(push, 1)
+#endif
+
+ /*
+  *  IGMPv1 wb_Ìè`ARFC 1112
+  */
+
+typedef struct t_igmpv1_hdr
+{
+	uint8_t		type;		/* bZ[WÌ^	*/
+	uint8_t		unused;		/* ¢gp			*/
+	uint16_t	sum;		/* `FbNT		*/
+	T_IN4_ADDR	addr;		/* O[vAhX */
+} T_IGMPV1_HDR;
+
+/*
+*  IGMPv2 wb_Ìè`ARFC 2236
+*/
+
+typedef struct t_igmpv2_hdr
+{
+	uint8_t		type;		/* bZ[WÌ^	*/
+	uint8_t		time;		/* ÅåÔ		*/
+	uint16_t	sum;		/* `FbNT		*/
+	T_IN4_ADDR	addr;		/* O[vAhX */
+} T_IGMPV2_HDR;
+
+typedef struct t_igmpv3_query_hdr
+{
+	uint8_t		type;		/* bZ[WÌ^	*/
+	uint8_t		time;		/* ÅåÔ		*/
+	uint16_t	sum;		/* `FbNT		*/
+	T_IN4_ADDR	grpaddr;	/* O[vAhX */
+	uint8_t		sqrv;		/* StOAQuerier Robustness Value */
+	uint8_t		qqic;		/* Qurier's Query Interval Code */
+	uint16_t	num;		/* M³Ì */
+	T_IN4_ADDR	sdraddr;	/* M³AhX */
+} T_IGMPV3Q_HDR;
+
+typedef struct t_igmp_group_record
+{
+	uint8_t		type;		/* bZ[WÌ^	*/
+	uint8_t		len;		/* âf[^·		*/
+	uint16_t	num;		/* M³Ì */
+	T_IN4_ADDR	grpaddr;	/* O[vAhX */
+	T_IN4_ADDR	sdraddr;	/* M³AhX	*/
+							/* âf[^		*/
+} T_IGMP_GROUP_RECORD;
+
+typedef struct t_igmpv3_report_hdr
+{
+	uint8_t		type;		/* bZ[WÌ^	*/
+	uint8_t		rsv1;		/* \ñ				*/
+	uint16_t	sum;		/* `FbNT		*/
+	uint16_t	rsv2;		/* \ñ				*/
+	uint16_t	num;		/* O[vR[hÌ */
+	T_IGMP_GROUP_RECORD record;	/* O[vR[h */
+} T_IGMPV3R_HDR;
+
+#ifdef __CA850__
+#pragma pack(8)
+#elif __RX
+#pragma unpack
+#elif _MSC_VER
+#pragma pack(pop)
+#endif
+
+#define IGMP_HDR_SIZE			(sizeof(T_IGMPV1_HDR))
+#define IP4_IGMP_HDR_SIZE		(IP4_HDR_SIZE + IGMP_HDR_SIZE)
+#define IF_IP4_IGMP_HDR_SIZE		(IF_IP4_HDR_SIZE + IGMP_HDR_SIZE)
+#define IF_IP4_IGMP_HDR_OFFSET		(IF_IP4_HDR_SIZE)
+
+#define GET_IGMPV1_HDR(nbuf,ihoff)	((T_IGMPV1_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_IGMPV2_HDR(nbuf,ihoff)	((T_IGMPV2_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_IGMPV3Q_HDR(nbuf,ihoff)	((T_IGMPV3Q_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_IGMPV3R_HDR(nbuf,ihoff)	((T_IGMPV3R_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_IGMP_SDU(nbuf,ihoff)	((uint8_t*)((nbuf)->buf) + ihoff + IGMP_HDR_SIZE)
+
+/*
+*  bZ[WÌ^
+*/
+
+#define IGMP_MEMBERSHIP_QUERY		0x11	/* o[VbvNG[		*/
+#define IGMP_MEMBERSHIP_REPORT		0x12	/* o[Vbv|[g		*/
+#define IGMP_MEMBERSHIP_REPORT_V2	0x16	/* o[Vbv|[g		*/
+#define IGMP_LEAVE_GROUP			0x17	/* [uO[v				*/
+#define IGMP_MEMBERSHIP_REPORT_V3	0x22	/* o[Vbv|[g		*/
+
+/*
+*  UDPÊM[_IvV
+*/
+
+typedef struct ip_mreq
+{
+	T_IN4_ADDR imr_multiaddr; /* IP multicast address of group */
+	T_IN4_ADDR imr_interface; /* local IP address of interface */
+} T_IP_MREQ;
+
+typedef struct ip_msfilter
+{
+	T_IN4_ADDR imsf_multiaddr;     /* IP multicast group address */
+	T_IN4_ADDR imsf_interface;     /* IP address of local interface */
+	uint32_t   imsf_fmode;         /* Filter-mode */
+	uint32_t   imsf_numsrc;        /* Number of sources in the following array */
+	T_IN4_ADDR imsf_slist[1];      /* Array of source addresses */
+} T_IP_MSFILTER;
+
+#define MCAST_INCLUDE     1
+#define MCAST_EXCLUDE     2
+
+extern ER igmp_set_loop(T_UDP_CEP *cep, uint8_t optval);
+extern ER igmp_get_loop(T_UDP_CEP *cep, uint8_t *optval);
+extern ER igmp_set_ttl(T_UDP_CEP *cep, uint8_t optval);
+extern ER igmp_get_ttl(T_UDP_CEP *cep, uint8_t *optval);
+extern ER igmp_set_if(T_UDP_CEP *cep, T_IN4_ADDR *optval);
+extern ER igmp_get_if(T_UDP_CEP *cep, T_IN4_ADDR *optval);
+extern ER igmp_add_membership(T_UDP_CEP *cep, T_IP_MREQ *optval);
+extern ER igmp_drop_membership(T_UDP_CEP *cep, T_IP_MREQ *optval);
+extern ER igmp_set_ip_msfilter(T_UDP_CEP *cep, const T_IP_MSFILTER *optval);
+extern ER igmp_get_ip_msfilter(T_UDP_CEP *cep, T_IP_MSFILTER *optval);
+
+/*
+ *  IGMP O[vGg
+ */
+
+typedef struct igmp_entry
+{
+	uint16_t	timer;		/* MÜÅÌÔ[b]	*/
+	uint16_t	resptime;	/* ÅåÔ[b]	*/
+	T_IN4_ADDR	ip_addr;	/* IP AhX			*/
+} T_IGMP_ENTRY;
+
+extern void igmp_init(void);
+extern bool_t igmp_is_joined_group(T_IN4_ADDR addr);
+extern uint_t igmp_input(T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+#endif	/* of #ifndef _IP_IGMP_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_input.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
  *
@@ -77,4 +77,5 @@
 #include <t_syslog.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -85,4 +86,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -97,4 +99,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -107,8 +110,8 @@
 #include <netinet/ip_icmp.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
+#include <netinet/ip_igmp.h>
 
 #if defined(SUPPORT_IPSEC)
@@ -122,4 +125,6 @@
 
 #include <net/if_var.h>
+
+#if defined(_IP4_CFG)
 
 /*
@@ -345,14 +350,16 @@
 ip_remove_options (T_NET_BUF *nbuf)
 {
-	T_IP_HDR	*iph;
-
-	iph  = GET_IP_HDR(nbuf);
-
-	if (GET_IP_HDR_SIZE(iph) > IP4_HDR_SIZE) {
-		memmove((char *)iph + IP4_HDR_SIZE, GET_IP_SDU(nbuf),
-		        (size_t)(iph->len - GET_IP_HDR_SIZE(iph)));
+	T_IP4_HDR	*iph;
+	uint_t		hdr_size;
+
+	iph  = GET_IP4_HDR(nbuf);
+	hdr_size = GET_IP4_HDR_SIZE(nbuf);
+
+	if (hdr_size > IP4_HDR_SIZE) {
+		memmove((char *)iph + IP4_HDR_SIZE, GET_IP4_SDU(nbuf),
+		        (size_t)(iph->len - hdr_size));
 		iph->vhl   = IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
-		iph->len  -= (uint16_t)(GET_IP_HDR_SIZE(iph) - IP4_HDR_SIZE);
-		nbuf->len -= (uint16_t)(GET_IP_HDR_SIZE(iph) - IP4_HDR_SIZE);
+		iph->len  -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
+		nbuf->len -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
 		}
 
@@ -389,6 +396,6 @@
 		}
 
-	ip4h  = GET_IP4_HDR(input);
-	hlen = GET_IP4_HDR_SIZE(ip4h);
+	ip4h = GET_IP4_HDR(input);
+	hlen = GET_IP4_HDR_SIZE(input);
 
 	/* バージョンをチェックする。*/
@@ -429,5 +436,5 @@
 	/* 送信元アドレスをチェックする。*/
 	src = ntohl(ip4h->src);
-	bc  = (ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask;
+	bc  = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
 
 #ifdef SUPPORT_LOOP
@@ -441,5 +448,5 @@
 #else	/* of #ifdef SUPPORT_LOOP */
 
-	if (src == ifp->in_ifaddr.addr || src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
+	if (src == ifp->in4_ifaddr.addr || src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
 		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
 		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
@@ -459,16 +466,27 @@
 	 */
 
-	if ((ifp->in_ifaddr.addr != IPV4_ADDRANY) &&
-	    (!(dst == ifp->in_ifaddr.addr || dst == bc ||
-	       dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY))) {
+#if defined(ETHER_CFG_MULTICAST)
+	if ((ifp->in4_ifaddr.addr != IPV4_ADDRANY) &&
+		(!(dst == ifp->in4_ifaddr.addr || dst == bc ||
+		   dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY ||
+		  IN4_IS_ADDR_MULTICAST(dst)))) {
 		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
 		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
 		goto buf_rel;
 		}
+#else
+	if ((ifp->in4_ifaddr.addr != IPV4_ADDRANY) &&
+	    (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
+	       dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY))) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
+		goto buf_rel;
+		}
+#endif
 
 #else	/* of #ifdef DHCP_CFG */
 
 #if defined(ETHER_CFG_MULTICAST)
-	if (!(dst == ifp->in_ifaddr.addr || dst == bc ||
+	if (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
 		  dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY ||
 		  IN4_IS_ADDR_MULTICAST(dst))) {
@@ -478,6 +496,6 @@
 		}
 #else
-	if (!(dst == ifp->in_ifaddr.addr || dst == bc ||
-	      dst == IPV4_ADDR_BROADCAST || dst == IPV4_ADDRANY)) {
+	if (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
+	      dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY)) {
 		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
 		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
@@ -525,13 +543,5 @@
 	switch (ip4h->proto) {
 
-#ifdef SUPPORT_UDP
-	case IPPROTO_UDP:
-		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
-		udp_input(&input, &off, NULL);
-		return;
-		break;
-#endif	/* of #ifdef SUPPORT_UDP */
-
-#ifdef SUPPORT_TCP
+#if defined(SUPPORT_TCP)
 	case IPPROTO_TCP:
 		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
@@ -539,5 +549,14 @@
 		return;
 		break;
-#endif	/* of #ifdef SUPPORT_UDP */
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && ( (TNUM_UDP4_CEPID > 0) || \
+                             ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
+	case IPPROTO_UDP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		udp4_input(&input, &off, NULL);
+		return;
+		break;
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
 
 	case IPPROTO_ICMP:
@@ -546,4 +565,12 @@
 		return;
 		break;
+
+#if defined(SUPPORT_IGMP)
+	case IPPROTO_IGMP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		igmp_input(&input, &off, NULL);
+		return;
+		break;
+#endif /* of #ifdef UDP_CFG_EXTENTIONS */
 
 #if defined(SUPPORT_IPSEC)
@@ -560,5 +587,5 @@
 
 		/* ローカル IP アドレスに届いたデータグラムのみ ICMP エラーを通知する。*/
-		if (dst == ifp->in_ifaddr.addr) {
+		if (dst == ifp->in4_ifaddr.addr) {
 			T_IN4_ADDR	src;
 
@@ -578,2 +605,4 @@
 	syscall(rel_net_buf(input));
 	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_output.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_output.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
  *
@@ -93,4 +93,5 @@
 #include <net/ppp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -104,4 +105,6 @@
 #include <netinet6/ipsec.h>
 #endif
+
+#if defined(_IP4_CFG)
 
 static uint16_t frag_id = 0;
@@ -221,5 +224,5 @@
 
 		len  = ntohs(ip4h->len);
-		off  = hlen = GET_IP4_HDR_SIZE(ip4h);
+		off  = hlen = GET_IP4_HDR_SIZE(output);
 		while (off < len) {
 			if (off + (IF_MTU - IP4_HDR_SIZE) < len)
@@ -245,5 +248,5 @@
 				fip4h->id	= htons(frag_id);
 				fip4h->sum	= 0;
-				fip4h->sum	= in_cksum(fip4h, GET_IP4_HDR_SIZE(fip4h));
+				fip4h->sum	= in_cksum(fip4h, GET_IP4_HDR_SIZE(frag));
 
 				NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(fip4h->len));
@@ -279,5 +282,5 @@
 		frag_id ++;
 		ip4h->sum = 0;
-		ip4h->sum = in_cksum(ip4h, GET_IP4_HDR_SIZE(ip4h));
+		ip4h->sum = in_cksum(ip4h, GET_IP4_HDR_SIZE(output));
 
 		NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
@@ -301,5 +304,5 @@
 	frag_id ++;
 	ip4h->sum = 0;
-	ip4h->sum = in_cksum(ip4h, (uint_t)GET_IP4_HDR_SIZE(ip4h));
+	ip4h->sum = in_cksum(ip4h, (uint_t)GET_IP4_HDR_SIZE(output));
 
 	NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
@@ -327,2 +330,4 @@
 	return error;
 	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_var.h	(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
  *
@@ -71,18 +71,6 @@
 #define _IP_VAR_H_
 
-/*
- *  IPv4 ヘッダ・ペイロードアクセスマクロ
- */
-
-#define IF_IP4_HDR_SIZE			(IF_HDR_SIZE + IP4_HDR_SIZE)
-
-#define GET_IP4_HDR(nbuf)		((T_IP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
-#define GET_IP4_SDU(nbuf)		((uint8_t*)((nbuf)->buf) + GET_IF_IP4_HDR_SIZE(nbuf))
-
-#define GET_IP4_HDR_SIZE(iph)		((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
-#define GET_IP4_SDU_SIZE(iph)		(ntohs((iph)->len) - GET_IP4_HDR_SIZE(iph))
-#define GET_IF_IP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP4_HDR_SIZE(GET_IP4_HDR(nbuf))))
-
-#define SET_IP4_SDU_SIZE(iph,slen)	((iph)->len=(uint16_t)htons((slen) + IP4_HDR_SIZE))
+#include <netinet/ip4_var.h>
+#include <netinet6/ip6_var.h>
 
 /*
@@ -90,190 +78,78 @@
  */
 
-#if defined(SUPPORT_INET4)
+#define GET_IP_VER(nbuf)		(*(uint8_t*)((nbuf)->buf+IF_HDR_SIZE)>>4)
 
-#define T_TCP_IP_Q_HDR			T_TCP_IP4_Q_HDR
+#if defined(_IP6_CFG)
 
-#define IF_IP_HDR_SIZE			IF_IP4_HDR_SIZE
+#if defined(_IP4_CFG)
+
+#define IF_IP_HDR_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?IF_IP6_HDR_SIZE:IF_IP4_HDR_SIZE)
+#define IF_IP_NET_HDR_SIZE(addr)	(IN6_IS_ADDR_V4MAPPED(addr)?IF_IP4_HDR_SIZE:IF_IP6_HDR_SIZE)
+
+#define IP_OUTPUT(nbuf,tmout)		(GET_IP_VER(nbuf)==IPV6_VERSION?ip6_output(nbuf,0,tmout):ip_output(nbuf,tmout))
+#define IP_REMOVE_OPTIONS(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?ip6_remove_exthdrs(nbuf):ip_remove_options(nbuf))
+
+#define GET_IP_HDR(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR(nbuf):GET_IP4_HDR(nbuf))
+#define GET_IP_HDR_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR_SIZE(nbuf):GET_IP4_HDR_SIZE(nbuf))
+#define GET_IP_SDU_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_SDU_SIZE(nbuf):GET_IP4_SDU_SIZE(nbuf))
+#define GET_IF_IP_HDR_SIZE(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IF_IP6_HDR_SIZE(nbuf):GET_IF_IP4_HDR_SIZE(nbuf))
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION?\
+					((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff:((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
+
+#define SET_IP_CF(nbuf,cf)		(GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_CF(nbuf,cf):(0))
+#define SET_IP_SDU_SIZE(nbuf,len)	(GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_SDU_SIZE(nbuf,len):SET_IP4_SDU_SIZE(nbuf,len))
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(GET_IP_VER(nbuf)==IPV6_VERSION\
+						?(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)\
+						:(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff))
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#define IF_IP_HDR_SIZE(nbuf)		IF_IP6_HDR_SIZE
+#define IF_IP_NET_HDR_SIZE(addr)	IF_IP6_HDR_SIZE
+
+#define IP_OUTPUT(nbuf,tmout)		ip6_output(nbuf,0,tmout)
+#define IP_REMOVE_OPTIONS(nbuf)		ip6_remove_exthdrs(nbuf)
+
+#define GET_IP_HDR(nbuf)		GET_IP6_HDR(nbuf)
+#define GET_IP_HDR_SIZE(nbuf)		GET_IP6_HDR_SIZE(nbuf)
+#define GET_IP_SDU_SIZE(nbuf)		GET_IP6_SDU_SIZE(nbuf)
+#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP6_HDR_SIZE(nbuf)
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff)
+
+#define SET_IP_CF(nbuf,cf)		SET_IP6_CF(nbuf,cf)
+#define SET_IP_SDU_SIZE(nbuf,len)	SET_IP6_SDU_SIZE(nbuf,len)
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define IF_IP_HDR_SIZE(nbuf)		IF_IP4_HDR_SIZE
+#define IF_IP_NET_HDR_SIZE(addr)	IF_IP4_HDR_SIZE
+
+#define IP_OUTPUT(nbuf,tmout)		ip_output(nbuf,tmout)
+#define IP_REMOVE_OPTIONS(nbuf)		ip_remove_options(nbuf)
 
 #define GET_IP_HDR(nbuf)		GET_IP4_HDR(nbuf)
-#define GET_IP_SDU(nbuf)		GET_IP4_SDU(nbuf)
+#define GET_IP_HDR_SIZE(nbuf)		GET_IP4_HDR_SIZE(nbuf)
+#define GET_IP_SDU_SIZE(nbuf)		GET_IP4_SDU_SIZE(nbuf)
+#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP4_HDR_SIZE(nbuf)
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
 
-#define GET_IP_HDR_SIZE(iph)		GET_IP4_HDR_SIZE(iph)
-#define GET_IP_SDU_SIZE(iph)		GET_IP4_SDU_SIZE(iph)
-#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP4_HDR_SIZE(nbuf)
+#define SET_IP_SDU_SIZE(nbuf,len)	SET_IP4_SDU_SIZE(nbuf,len)
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff)
 
-#define SET_IP_SDU_SIZE(iph,len)	SET_IP4_SDU_SIZE(iph,len)
+#else	/* of #if defined(_IP4_CFG) */
 
-#define IP_OUTPUT(nbuf,tmout)		ip_output(nbuf,tmout)
-#define IP_INIT()			ip_init()
-#define IP_REMOVE_OPTIONS(nbuf)		ip_remove_options(nbuf)
+#error "not implemented."
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
 
-/*
- *  IP の MSS サイズのネットワークバッファ
- */
-
-typedef struct t_net_buf_ip_mss {
-	uint16_t	len;	/* データの長さ		*/
-	uint8_t		idix;	/* mpfid のインデックス	*/
-	uint8_t		flags;	/* フラグ		*/
-#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
-	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
-#endif
-#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
-	uint8_t		halign[4 - IF_HDR_ALIGN];
-#endif
-	uint8_t		buf[IF_HDR_SIZE + IP4_MSS];
-				/* バッファ本体		*/
-	} T_NET_BUF_IP_MSS;
-
-/*
- *  65536 オクテットサイズのネットワークバッファ
- */
-
-typedef struct t_net_buf4_65536 {
-	uint16_t	len;	/* データの長さ		*/
-	uint8_t		idix;	/* mpfid のインデックス	*/
-	uint8_t		flags;	/* フラグ		*/
-#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
-	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
-#endif
-#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
-	uint8_t		halign[4 - IF_HDR_ALIGN];
-#endif
-	uint8_t		buf[IF_IP4_HDR_SIZE + 65536];
-				/* バッファ本体		*/
-#if defined(IF_PDU_HDR_PADDING)
-	uint8_t		padding[IF_PDU_HDR_PADDING];
-#endif				/* ヘッダの余分		*/
-	} T_NET_BUF4_65536;
-
-#ifdef IP4_CFG_FRAGMENT
-
-/*
- *  再構成キュー用 IPv4 ヘッダの定義
- */
-
-typedef struct t_qip4_hdr {
-	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
-					/* length は 4 octets 単位		*/
-	uint8_t		type;		/* type of services			*/
-	uint16_t	len;		/* total length				*/
-
-	uint16_t	id;		/* identification			*/
-	uint16_t	flg_off;	/* fragment flag & offset		*/
-
-	uint8_t		ttl;		/* time to live				*/
-	uint8_t		proto;		/* protocol				*/
-	uint16_t	sum;		/* checksum				*/
-
-	uint32_t	src;		/* source address			*/
-
-	T_NET_BUF	*next;		/* 次の IPv4 フラグメント			*/
-	} __attribute__((packed, aligned(2)))T_QIP4_HDR;
-
-#define QIP4_HDR_SIZE			(sizeof(T_QIP4_HDR))
-#define IF_QIP4_HDR_SIZE		(IF_HDR_SIZE + QIP4_HDR_SIZE)
-
-#define GET_QIP4_HDR(nbuf)		((T_QIP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
-#define GET_QIP4_SDU(nbuf)		((uint8_t*)(nbuf)->buf + GET_IF_QIP4_HDR_SIZE(nbuf))
-
-#define GET_QIP4_HDR_SIZE(iph)		((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
-#define GET_IF_QIP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_QIP4_HDR_SIZE(GET_QIP4_HDR(nbuf))))
-
-/*
- *  データグラム再構成用ネットワークバッファ
- */
-
-typedef struct t_net_buf4_reassm {
-	uint16_t	len;	/* データの長さ		*/
-	uint8_t		idix;	/* mpfid のインデックス	*/
-	uint8_t		flags;	/* フラグ		*/
-#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
-	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
-#endif
-#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
-	uint8_t		align[4 - IF_HDR_ALIGN];
-#endif
-	uint8_t		buf[IP4_CFG_FRAG_REASSM_SIZE];
-				/* バッファ本体		*/
-	} T_NET_BUF4_REASSM;
-
-#endif	/* of #ifdef IP4_CFG_FRAGMENT */
-
-/*
- *  TCP の再構成キューにおける IPv4 ヘッダの定義
- */
-
-typedef struct t_tcp_ip4_q_hdr {
-	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
-					/* length は 4 octets 単位		*/
-	uint8_t		type;		/* type of services			*/
-	uint16_t	len;		/* total length				*/
-
-	uint16_t	id;		/* identification			*/
-	uint16_t	flg_off;	/* fragment flag & offset		*/
-
-	uint8_t		ttl;		/* time to live				*/
-	uint8_t		proto;		/* protocol				*/
-	uint16_t	thoff;		/* TCP ヘッダのオフセット		*/
-
-	T_IN4_ADDR	src;		/* source address			*/
-	T_IN4_ADDR	dst;		/* destination address			*/
-	} __attribute__((packed, aligned(2)))T_TCP_IP4_Q_HDR;
-
-#ifdef SUPPORT_MIB
-
-/*
- *  SNMP の 管理情報ベース (MIB)
- */
-
-typedef struct t_ip_stats {
-	uint32_t	ipInReceives;
-	uint32_t	ipInHdrErrors;
-	uint32_t	ipInAddrErrors;
-/*	uint32_t	ipForwDatagrams;*/
-	uint32_t	ipInUnknownProtos;
-/*	uint32_t	ipInDiscards;*/
-	uint32_t	ipInDelivers;
-	uint32_t	ipOutRequests;
-	uint32_t	ipOutDiscards;
-/*	uint32_t	ipOutNoRoutes;*/
-
-#ifdef IP4_CFG_FRAGMENT
-
-	uint32_t	ipReasmReqds;
-	uint32_t	ipReasmOKs;
-	uint32_t	ipReasmFails;
-	uint32_t	ipFragOKs;
-	uint32_t	ipFragFails;
-	uint32_t	ipFragCreates;
-
-#else	/* of #ifdef IP4_CFG_FRAGMENT */
-
-	uint32_t	ipReasmReqds;
-/*	uint32_t	ipReasmOKs;*/
-	uint32_t	ipReasmFails;
-/*	uint32_t	ipFragOKs;*/
-/*	uint32_t	ipFragFails;*/
-/*	uint32_t	ipFragCreates;*/
-
-#endif	/* of #ifdef IP4_CFG_FRAGMENT */
-
-} T_IP_STATS;
-
-extern T_IP_STATS ip_stats;
-
-#endif	/* of #ifdef SUPPORT_MIB */
-
-/*
- *  関数
- */
-
-extern void ip_frag_timer (void);
-extern void ip_init (void);
-extern ER ip_remove_options (T_NET_BUF *nbuf);
-extern ER ip_output (T_NET_BUF *nbuf, TMO tmout);
+#endif	/* of #if defined(_IP6_CFG) */
 
 #endif	/* of #ifndef _IP_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_fsm.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_fsm.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_fsm.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.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
  *
@@ -95,4 +95,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -102,18 +103,13 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet6/nd6.h>
 #include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/ip_icmp.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
@@ -139,5 +135,5 @@
 static void close_connection	(T_TCP_CEP *cep, bool_t *needoutput);
 static void set_rexmt_timer	(T_TCP_CEP *cep,  T_TCP_TIME rtt);
-static uint8_t reassemble		(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
+static uint8_t reassemble	(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
 static ER drop_after_ack	(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff);
 static ER listening		(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss);
@@ -147,93 +143,6 @@
 static void trim_length		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
 static void parse_option	(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
-static bool_t update_wnd		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+static bool_t update_wnd	(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
 static void proc_urg		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
-
-#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
-
-/*
- *  タスクからの Time Wait 状態 CEP 分離機能
- */
-
-/*
- *  関数
- */
-
-static T_TCP_TWCEP*tcp_find_twcep (T_IN_ADDR *dstaddr,  uint16_t dstport,
-                                   T_IN_ADDR *peeraddr, uint16_t peerport);
-
-/*
- *  変数
- */
-
-T_TCP_TWCEP tcp_twcep[NUM_TCP_TW_CEP_ENTRY];
-
-/*
- *  tcp_find_twcep -- ポート番号から Time Wait 用 TCP 通信端点を得る。
- *
- *    注意: dstaddr は、ネットワークバイトオーダ
- */
-
-static T_TCP_TWCEP*
-tcp_find_twcep (T_IN_ADDR *dstaddr, uint16_t dstport, T_IN_ADDR *peeraddr, uint16_t peerport)
-{
-	T_TCP_TWCEP*	twcep;
-	
-	/*
-	 *  状態が TIME WAIT で、
-	 *  IP アドレスとポート番号が一致する通信端点を探索する。
-	 */
-	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
-		if (twcep->fsm_state == TCP_FSM_TIME_WAIT                   &&
-		    IN_IS_DSTADDR_ACCEPT (&twcep->myaddr.ipaddr,  dstaddr)  &&
-		    IN_ARE_NET_ADDR_EQUAL(&twcep->dstaddr.ipaddr, peeraddr) &&
-		    dstport  == twcep->myaddr.portno                        &&
-		    peerport == twcep->dstaddr.portno)
-			return twcep;
-		}
-
-	return NULL;
-	}
-
-/*
- *  必要な情報を Time Wait 用 TCP 通信端点に移して、
- *  標準の TCP 通信端点を開放する。
- */
-
-void
-tcp_move_twcep (T_TCP_CEP *cep)
-{
-	T_TCP_TWCEP*	twcep;
-
-	/* 空きの Time Wait 用 TCP 通信端点を探索する。*/
-	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
-		if (twcep->fsm_state != TCP_FSM_TIME_WAIT) {
-
-			/*
-			 *  通信端点をロックし、
-			 *  必要な情報を Time Wait 用 TCP 通信端点に移す。
-			 */
-			syscall(wai_sem(cep->semid_lock));
-			twcep->rbufsz		= cep->rbufsz;
-			twcep->dstaddr		= cep->dstaddr;
-			twcep->myaddr		= cep->myaddr;
-			twcep->snd_una		= cep->snd_una;
-			twcep->rcv_nxt		= cep->rcv_nxt;
-			twcep->rwbuf_count	= cep->rwbuf_count;
-			twcep->fsm_state	= cep->fsm_state;
-			twcep->timer_2msl	= cep->timer[TCP_TIM_2MSL];
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-
-			/* 標準 TCP 通信端点を開放する。*/
-			tcp_close(cep);
-
-			break;
-			}
-		}
-	}
-
-#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
 
 /*
@@ -421,5 +330,5 @@
 
 		/*  TCP ヘッダの位置を保存する。*/
-		GET_TCP_IP_Q_HDR(input)->thoff = thoff;
+		SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
 
 		/* SDU のオフセット（元はウィンドサイズ）をリセットする。*/
@@ -448,8 +357,6 @@
 listening (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss)
 {
-	T_IP_HDR	*iph;
 	T_TCP_HDR	*tcph;
 
-	iph  = GET_IP_HDR(input);
 	tcph = GET_TCP_HDR(input, thoff);
 
@@ -473,52 +380,12 @@
 		return RET_DROP;
 
-#if defined(SUPPORT_INET4)
-
-#ifdef SUPPORT_LOOP
-
 	/*
-	 *  次のときは破棄する。
-	 *    ・ポート番号が同一で、送受信 IP アドレス が同一。
-	 *      ただし、ローカルループバック (127.0.0.1) なら良い。
-	 *    ・マルチキャストアドレス
-	 */
-
-	if (tcph->dport == tcph->sport &&
-	    (iph->dst == iph->src && ntohl(iph->src) != IPV4_ADDR_LOOPBACK))
+	 *  受信可能な IP アドレスとポート番号であることを確認する。
+	 */
+	if (!tcp_is_addr_accept(input, thoff))
 		return RET_DROP;
 
-#else	/* of #ifdef SUPPORT_LOOP */
-
-	/*
-	 *  次のときは破棄する。
-	 *    ・ポート番号が同一で、送受信 IP アドレス が同一。
-	 *    ・マルチキャストアドレス
-	 */
-
-	if (tcph->dport == tcph->sport && iph->dst == iph->src)
-		return RET_DROP;
-
-#endif	/* of #ifdef SUPPORT_LOOP */
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-	/*
-	 *  次のときは破棄する。
-	 *    ・ポート番号が同一で、送受信 IP アドレス が同一。
-	 *    ・マルチキャストアドレス
-	 */
-
-	if (tcph->dport == tcph->sport && IN_ARE_ADDR_EQUAL(&iph->dst, &iph->src))
-		return RET_DROP;
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-	if (IN_IS_NET_ADDR_MULTICAST(&iph->dst))
-		return RET_DROP;
-
 	/* 相手のアドレスを記録する。*/
-	IN_COPY_TO_HOST(&cep->dstaddr.ipaddr, &iph->src);
+	IN_COPY_TO_HOST(&cep->dstaddr.ipaddr, input);
 	cep->dstaddr.portno = tcph->sport;
 
@@ -919,4 +786,8 @@
 			cep->rep = NULL;
 
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+			cep->rep4 = NULL;
+#endif
+
 			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_ESTABLISHED));
 
@@ -926,5 +797,19 @@
 
 				/* 相手のアドレスをコピーする。*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+				if (cep->flags & TCP_CEP_FLG_IPV4) {
+					(*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+					(*cep->p_dstaddr4).portno = cep->dstaddr.portno;
+					}
+				else
+					*cep->p_dstaddr = cep->dstaddr;
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
 				*cep->p_dstaddr = cep->dstaddr;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
 
 				if (IS_PTR_DEFINED(cep->callback)) {
@@ -1369,4 +1254,5 @@
 	case TCP_FSM_ESTABLISHED:	/* コネクション開設完了		*/
 		cep->fsm_state = TCP_FSM_CLOSE_WAIT;
+		syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_RWBUF_READY));
 		break;
 
@@ -1421,5 +1307,4 @@
 {
 	T_NET_BUF	*input = *inputp;
-	T_IP_HDR	*iph;
 	T_TCP_HDR	*tcph;
 	T_TCP_CEP	*cep = NULL;
@@ -1442,10 +1327,9 @@
 
 	/* ヘッダ長をチェックする。*/
-	if (input->len < IF_IP_TCP_HDR_SIZE) {
+	if (input->len < IF_IP_TCP_HDR_SIZE(input)) {
 		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_BAD_HEADERS], 1);
 		goto drop;
 		}
 
-	iph  = GET_IP_HDR(input);
 	tcph = GET_TCP_HDR(input, *offp);
 
@@ -1487,5 +1371,5 @@
 	 *  状態が Time Wait 中の CEP を探索する。
 	 */
-	twcep = tcp_find_twcep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
+	twcep = tcp_find_twcep(input, *offp);
 	if (twcep != NULL) {
 
@@ -1510,10 +1394,10 @@
 	else
 		/* 標準の TCP 通信端点を得る。*/
-		cep = tcp_find_cep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
+		cep = tcp_find_cep(input, *offp);
 
 #else	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
 
 	/* TCP 通信端点を得る。*/
-	cep = tcp_find_cep(&iph->dst, tcph->dport, &iph->src, tcph->sport);
+	cep = tcp_find_cep(input, *offp);
 
 #endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
@@ -1894,5 +1778,5 @@
 	 */
 
-	if ((tcph->flags & TCP_FLG_RST) || IN_IS_NET_ADDR_MULTICAST(&iph->dst))
+	if ((tcph->flags & TCP_FLG_RST) || IN_IS_NET_ADDR_MULTICAST(input))
 		goto drop;
 
@@ -1907,7 +1791,6 @@
 		rbfree = cep->rbufsz - cep->rwbuf_count;
 
-	if (tcph->flags & TCP_FLG_ACK) {
+	if (tcph->flags & TCP_FLG_ACK)
 		tcp_respond(input, cep, 0, tcph->ack, rbfree, TCP_FLG_RST);
-		}
 	else {
 		if (tcph->flags & TCP_FLG_SYN)
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.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
  *
@@ -93,4 +93,6 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -98,17 +100,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
 #include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
@@ -150,5 +148,5 @@
 	T_NET_BUF	*output;
 	T_TCP_HDR	*tcph;
-	uint_t		optlen;
+	uint_t		optlen, hdr_offset;
 	ER		error;
 
@@ -210,6 +208,6 @@
 		 */
 		len = 0;
-		if ((error = tcp_get_segment(&output, cep, optlen,
-	                                    len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+	                                    len, (uint_t)net_buf_max_siz(),
 	                                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
 			if (cep->timer[TCP_TIM_REXMT] == 0)
@@ -222,6 +220,6 @@
 
 	if (IS_PTR_DEFINED(cep->sbuf)) {
-		if ((error = tcp_get_segment(&output, cep, optlen,
-		                             len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+		                             len, (uint_t)net_buf_max_siz(),
 		                             NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
 			if (cep->timer[TCP_TIM_REXMT] == 0)
@@ -247,6 +245,6 @@
 		 */
 		len = 0;
-		if ((error = tcp_get_segment(&output, cep, optlen,
-	                                    len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+	                                    len, (uint_t)net_buf_max_siz(),
 	                                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
 			if (cep->timer[TCP_TIM_REXMT] == 0)
@@ -258,6 +256,6 @@
 #else	/* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
 
-	if ((error = tcp_get_segment(&output, cep, optlen,
-	                             len, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
+	if ((error = tcpn_get_segment(&output, cep, optlen,
+	                             len, (uint_t)net_buf_max_siz(),
 	                             NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
 		if (cep->timer[TCP_TIM_REXMT] == 0)
@@ -272,4 +270,5 @@
 	 *  本実装では、最大セグメントサイズのみ設定する。
 	 */
+	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
 	if (flags & TCP_FLG_SYN) {
 		cep->snd_nxt = cep->iss;
@@ -277,5 +276,5 @@
 #ifdef TCP_CFG_OPT_MSS
 
-		optp = GET_TCP_OPT(output, IF_IP_TCP_HDR_OFFSET);
+		optp = GET_TCP_OPT(output, hdr_offset);
 		*optp ++ = TCP_OPT_MAXSEG;
 		*optp ++ = TCP_OPT_LEN_MAXSEG;
@@ -324,5 +323,5 @@
 		}
 
-	tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
+	tcph = GET_TCP_HDR(output, hdr_offset);
 
 	/*
@@ -379,9 +378,8 @@
 	 */
 	tcph->sum = 0;
-	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, (uint_t)GET_TCP_HDR_OFFSET(output),
-		             GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len);
+	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, GET_TCP_HDR_SIZE(output, hdr_offset) + len);
 
 	/* ネットワークバッファ長を調整する。*/
-	output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len);
+	output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset) + len);
 
 	/*
@@ -490,6 +488,5 @@
 	 * ・動的な通信端点の生成・削除機能
 	 */
-	cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK | 
-	               TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
 
 	return error;
@@ -864,7 +861,7 @@
 #endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
 
-		if ((error = tcp_get_segment(&cep->swbufq, cep, 0,
-		                             (uint_t) TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
-		                             (uint_t)(TCP_CFG_SWBUF_CSAVE_MAX_SIZE - IF_IP_TCP_HDR_SIZE),
+		if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
+		                             (uint_t)TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
+		                             (uint_t)TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
 		                             (ATR)(NBA_SEARCH_DESCENT |
 		                                   NBA_RESERVE_TCP    |
@@ -888,15 +885,10 @@
 				len = TCP_GET_SWBUF_ADDR(cep, cep->snd_p_buf);
 
+				/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-				/* コールバック関数を呼び出す。*/
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				/* コールバック関数を呼び出す。*/
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+#endif
 
 
@@ -924,15 +916,11 @@
 				/* フラグを、送信可能に設定し、強制的に送信する。*/
 				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT;
+
+				/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-				/* コールバック関数を呼び出す。*/
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				/* コールバック関数を呼び出す。*/
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+#endif
 
 
@@ -999,10 +987,10 @@
 	tcp_init();
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 	/* IPv6 のステートレス・アドレス自動設定を実行する。*/
 	in6_if_up(IF_GET_IFNET());
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifdef _IP6_CFG */
 
 	while (true) {
@@ -1083,15 +1071,9 @@
 
 						if (IS_PTR_DEFINED(cep->callback))
-
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 							(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 							(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 						else
 							syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_seq.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_seq.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_seq.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.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
  *
@@ -96,7 +96,6 @@
 #include <net/if_loop.h>
 #include <net/ethernet.h>
-#include <net/if_arp.h>
-#include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -105,18 +104,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/in_var.h>
+#include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
-#include <netinet/in_itron.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
@@ -147,4 +141,208 @@
 
 static uint16_t tcp_port_auto = TCP_PORT_FIRST_AUTO;	/* 自動割り当て番号	*/
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+/*
+ *  タスクからの Time Wait 状態 CEP 分離機能
+ */
+
+/*
+ *  変数
+ */
+
+T_TCP_TWCEP tcp_twcep[NUM_TCP_TW_CEP_ENTRY];
+
+/*
+ *  tcp_move_twcep -- 必要な情報を Time Wait 用 TCP 通信端点に移して、
+ *                    標準の TCP 通信端点を開放する。
+ */
+
+void
+tcp_move_twcep (T_TCP_CEP *cep)
+{
+	T_TCP_TWCEP*	twcep;
+
+	/* 空きの Time Wait 用 TCP 通信端点を探索する。*/
+	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
+		if (twcep->fsm_state != TCP_FSM_TIME_WAIT) {
+
+			/*
+			 *  通信端点をロックし、
+			 *  必要な情報を Time Wait 用 TCP 通信端点に移す。
+			 */
+			syscall(wai_sem(cep->semid_lock));
+			twcep->flags		= (uint8_t)cep->flags;
+			twcep->rbufsz		= cep->rbufsz;
+			twcep->dstaddr		= cep->dstaddr;
+			twcep->myaddr		= cep->myaddr;
+			twcep->snd_una		= cep->snd_una;
+			twcep->rcv_nxt		= cep->rcv_nxt;
+			twcep->rwbuf_count	= cep->rwbuf_count;
+			twcep->fsm_state	= cep->fsm_state;
+			twcep->timer_2msl	= cep->timer[TCP_TIM_2MSL];
+
+			/* 通信端点をロックを解除する。*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* 標準 TCP 通信端点を開放する。*/
+			tcp_close(cep);
+
+			break;
+			}
+		}
+	}
+
+/*
+ *  tcp_find_twcep -- ポート番号から Time Wait 用 TCP 通信端点を得る。
+ */
+
+T_TCP_TWCEP*
+tcp_find_twcep (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_TWCEP*	twcep;
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+	
+	/*
+	 *  状態が TIME WAIT で、
+	 *  IP アドレスとポート番号が一致する通信端点を探索する。
+	 */
+	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
+		if (twcep->fsm_state == TCP_FSM_TIME_WAIT                   &&
+		    IN_IS_DSTADDR_ACCEPT    (&twcep->myaddr.ipaddr,  input) &&
+		    IN_ARE_NET_SRCADDR_EQUAL(&twcep->dstaddr.ipaddr, input) &&
+		    tcph->dport == twcep->myaddr.portno                     &&
+		    tcph->sport == twcep->dstaddr.portno)
+			return twcep;
+		}
+
+	return NULL;
+	}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+/*
+ *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
+ */
+
+T_TCP_CEP*
+tcp_find_cep (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_CEP*	cep;
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+	
+	/*
+	 *  状態が SYN 送信済み以後は、
+	 *  IP アドレスとポート番号が一致する TCP 通信端点を探索する。
+	 */
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+		if (cep->fsm_state >= TCP_FSM_SYN_SENT                    &&
+		    IN_IS_DSTADDR_ACCEPT    (&cep->myaddr.ipaddr,  input) &&
+		    IN_ARE_NET_SRCADDR_EQUAL(&cep->dstaddr.ipaddr, input) &&
+		    tcph->dport == cep->myaddr.portno                     &&
+		    tcph->sport == cep->dstaddr.portno)
+			return cep;
+		}
+
+	/* IPv4 で受動オープン中の TCP 通信端点を先に探索する。*/	
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+		if ((cep->flags & TCP_CEP_FLG_IPV4)                   &&
+		     cep->fsm_state == TCP_FSM_LISTEN                 &&
+		     GET_IP_VER(input) == IPV4_VERSION                &&
+		     IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		     tcph->dport == cep->myaddr.portno)
+			return cep;
+		}
+
+	/* 受動オープン中の TCP 通信端点を探索する。*/	
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+		if (cep->flags & TCP_CEP_FLG_IPV4) {
+			if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+		            GET_IP_VER(input) == IPV4_VERSION                &&
+			    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+			}
+		else {
+
+#if defined(API_CFG_IP4MAPPED_ADDR)
+
+			if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+			    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+
+#else	/* of #if defined(API_CFG_IP4MAPPED_ADDR) */
+
+			if (cep->fsm_state == TCP_FSM_LISTEN                   &&
+			    INN6_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+
+#endif	/* of #if defined(API_CFG_IP4MAPPED_ADDR) */
+
+			}
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+		if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+		    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		    tcph->dport == cep->myaddr.portno)
+			return cep;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+		}
+
+	return NULL;
+	}
+
+/*
+ *  tcp_is_addr_accept -- 受信可能な IP アドレスとポート番号であることを確認する。
+ */
+
+bool_t
+tcp_is_addr_accept (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+
+#if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP)
+
+	/*
+	 *  次のときは破棄する。
+	 *    ・ポート番号が同一で、送受信 IP アドレス が同一。
+	 *      ただし、送信元 IP アドレスがローカルループバックなら良い。
+	 *    ・マルチキャストアドレス
+	 */
+
+	if (tcph->dport == tcph->sport && 
+	    (IN4_ARE_HDR_ADDR_EQUAL(input) && !IN4_ARE_NET_ADDR_EQUAL(&GET_IP4_HDR(input)->dst, &IPV4_ADDR_LOOPBACK)))
+		return RET_DROP;
+
+#else	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
+
+	/*
+	 *  次のときは、受信可能ではない。
+	 *    ・ポート番号が同一で、送受信 IP アドレス が同一。
+	 *    ・マルチキャストアドレス
+	 */
+	if (tcph->dport == tcph->sport && IN_ARE_HDR_ADDR_EQUAL(input))
+		return false;
+
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
+
+	if (IN_IS_NET_ADDR_MULTICAST(input))
+		return false;
+	else
+		return true;
+	}
 
 /*
@@ -162,5 +360,5 @@
 
 	for (q = cep->reassq; q != NULL; q = nq) {
-		nq = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff)->next;
+		nq = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q))->next;
 		syscall(rel_net_buf(q));
 		}
@@ -184,11 +382,12 @@
 			tcp_port_auto = TCP_PORT_FIRST_AUTO;
 
-#ifdef TCP_CFG_PASSIVE_OPEN
-
-		for (ix = tmax_tcp_repid; ix -- > 0; ) {
+#if defined(TNUM_TCP6_REPID)
+#if TNUM_TCP6_REPID > 0
+
+		for (ix = tmax_tcp6_repid; ix -- > 0; ) {
 
 #ifdef TCP_CFG_EXTENTIONS
 
-			if (VALID_TCP_REP(&tcp_rep[ix]) && tcp_rep[ix].myaddr.portno == portno) {
+			if (VALID_TCP_REP(&tcp6_rep[ix]) && tcp6_rep[ix].myaddr.portno == portno) {
 				portno = TCP_PORTANY;
 				break;
@@ -197,5 +396,5 @@
 #else	/* of #ifdef TCP_CFG_EXTENTIONS */
 
-			if (tcp_rep[ix].myaddr.portno == portno) {
+			if (tcp6_rep[ix].myaddr.portno == portno) {
 				portno = TCP_PORTANY;
 				break;
@@ -206,5 +405,32 @@
 			}
 
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+#endif	/* of #if defined(TNUM_TCP6_REPID) */
+
+#if defined(TNUM_TCP4_REPID)
+#if TNUM_TCP4_REPID > 0
+
+		for (ix = tmax_tcp4_repid; ix -- > 0; ) {
+
+#ifdef TCP_CFG_EXTENTIONS
+
+			if (VALID_TCP_REP(&tcp4_rep[ix]) && tcp4_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			if (tcp4_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			}
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+#endif	/* of #if defined(TNUM_TCP4_REPID) */
 
 		if (portno != TCP_PORTANY) {
@@ -273,22 +499,6 @@
 	SYSTIM now;
 
-#ifdef SUPPORT_ETHER
-
-	T_IF_SOFTC	*ic;
-
-	ic = IF_ETHER_NIC_GET_SOFTC();
-	syscall(get_tim(&now));
-	net_srand(now + (ic->ifaddr.lladdr[2] << 24)
-	              + (ic->ifaddr.lladdr[3] << 16)
-	              + (ic->ifaddr.lladdr[4] <<  8)
-	              + (ic->ifaddr.lladdr[5]      ));
-
-#else	/* of #ifdef SUPPORT_ETHER */
-
 	syscall(get_tim(&now));
 	net_srand(now);
-
-#endif	/* of #ifdef SUPPORT_ETHER */
-
 	tcp_iss = net_rand();
 	}
@@ -319,7 +529,7 @@
 	 * ・送受信ウィンドバッファの省コピー機能
 	 * ・動的な通信端点の生成・削除機能
+	 * ・通信端点のネットワーク層プロトコル
 	 */
-	cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK | 
-	               TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
 
 #ifdef TCP_CFG_NON_BLOCKING
@@ -341,4 +551,9 @@
 					/* TCP 通信端点からTCP 受付口を解放する。*/
 					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
 					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_CLS);
 					break;
@@ -397,4 +612,9 @@
 					/* TCP 通信端点から TCP 受付口を解放する。*/
 					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
 					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_CLS);
 					break;
@@ -431,6 +651,13 @@
 
 				case TFN_TCP_ACP_CEP:
+
 					/* TCP 通信端点からTCP 受付口を解放する。*/
 					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					/* 接続エラーを設定する。*/
 					len      = E_CLS;
 					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
@@ -489,6 +716,13 @@
 
 				case TFN_TCP_CON_CEP:
-					/* TCP 通信端点から TCP 受付口を解放する。*/
+
+					/* TCP 通信端点からTCP 受付口を解放する。*/
 					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					/* 接続エラーを設定する。*/
 					len      = E_CLS;
 					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
@@ -589,6 +823,7 @@
 		sig_sem(SEM_TCP_POST_OUTPUT);
 		}
-	else
+	else {
 		cep = tcp_close(cep);
+		}
 	return cep;
 	}
@@ -602,7 +837,7 @@
              T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags)
 {
-	T_IP_HDR	*iph;
 	T_TCP_HDR	*tcph;
 	uint_t		win = 0;
+	uint_t		hdr_offset;
 
 	if ((flags & TCP_FLG_RST) == 0)
@@ -614,6 +849,5 @@
 	 */
 	if (output != NULL) {
-		T_IN_ADDR	ipaddr;
-		uint16_t		portno;
+		uint16_t	portno;
 
 		/*
@@ -626,22 +860,17 @@
 			}
 
-		iph  = GET_IP_HDR(output);
-
-		/* IP アドレスを交換する。*/
-		ipaddr = iph->src;
-		iph->src = iph->dst;
-		iph->dst = ipaddr;
-
-#if defined(SUPPORT_INET6)
+		ip_exchg_addr(output);
+
+#if defined(_IP6_CFG)
 
 		/* トラヒッククラスとフローラベルをクリアする。*/
-		iph->vcf = htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(iph->vcf)), 0));
-
-#endif	/* of #if defined(SUPPORT_INET6) */
+		SET_IP_CF(output, 0);
+
+#endif	/* of #if defined(_IP6_CFG) */
 
 		/* TCP SDU 長を 0 にする。*/
-		SET_IP_SDU_SIZE(iph, TCP_HDR_SIZE);
-
-		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
+		SET_IP_SDU_SIZE(output, TCP_HDR_SIZE);
+
+		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
 
 		/* ポート番号を交換する。*/
@@ -658,9 +887,9 @@
 		return;
 	else {
-		if (tcp_get_segment(&output, cep, 0,
-		                    0, (uint_t)(net_buf_max_siz() - IF_IP_TCP_HDR_SIZE),
+		if (tcpn_get_segment(&output, cep, 0,
+		                    0, (uint_t)net_buf_max_siz(),
 		                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF) != E_OK)
 			return;
-		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET);
+		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
 		flags |= TCP_FLG_ACK;
 		}
@@ -675,9 +904,10 @@
 	 *  チェックサムを設定する。
 	 */
-	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, IF_IP_TCP_HDR_OFFSET, 
-	                     (uint_t)GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET));
+	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
+	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, 
+	                     (uint_t)GET_TCP_HDR_SIZE(output, hdr_offset));
 
 	/* ネットワークバッファ長を調整する。*/
-	output->len = (uint16_t)GET_IF_IP_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET);
+	output->len = (uint16_t)GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset);
 
 #ifdef TCP_CFG_TRACE
@@ -690,21 +920,5 @@
 	IP_OUTPUT(output, TMO_TCP_OUTPUT);
 	}
-
-/*
- *  tcp_set_header -- TCP ヘッダを設定する。
- */
-
-void
-tcp_set_header (T_NET_BUF *nbuf, T_TCP_CEP *cep, uint_t thoff, uint_t optlen)
-{
-	T_TCP_HDR	*tcph = GET_TCP_HDR(nbuf, thoff);
-
-	/* TCP ヘッダに情報を設定する。*/
-	tcph->sport	= htons(cep->myaddr.portno);
-	tcph->dport	= htons(cep->dstaddr.portno);
-	tcph->doff	= TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
-	tcph->sum	= tcph->flags = 0;
-	}
-
+#if 0
 /*
  *  tcp_get_segment -- TCP セグメントを獲得し、ヘッダを設定する。
@@ -712,4 +926,5 @@
  *    戻り値	エラーコード
  *    optlen	オプションサイズ、4 オクテット単位
+ *    maxlen	最大セグメントサイズ（IF/IP/TCP ヘッダサイズを含まない）
  *    len	TCP SDU サイズ
  */
@@ -719,4 +934,5 @@
                  uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
 {
+	T_TCP_HDR	*tcph;
 	ER		error;
 
@@ -728,4 +944,44 @@
 	                             &cep->myaddr.ipaddr,
 	                             IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
+		syslog(LOG_WARNING, "[TCP] NET BUF busy, len: %d, CEP: %d.",
+		                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
+		return error;
+		}
+
+	/* TCP ヘッダに情報を設定する。*/
+
+	/* TCP ヘッダに情報を設定する。*/
+	tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
+	tcph->sport	= htons(cep->myaddr.portno);
+	tcph->dport	= htons(cep->dstaddr.portno);
+	tcph->doff	= TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
+	tcph->sum	= tcph->flags = 0;
+
+	return E_OK;
+	}
+#endif
+/*
+ *  tcpn_get_segment -- TCP セグメントを獲得し、ヘッダを設定する。
+ *
+ *    戻り値	エラーコード
+ *    optlen	オプションサイズ、4 オクテット単位
+ *    maxlen	最大セグメントサイズ（IF/IP/TCP ヘッダサイズを含む）
+ *    len	TCP SDU サイズ
+ */
+
+ER
+tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                 uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
+{
+	T_TCP_HDR	*tcph;
+	ER		error;
+
+	/* IP データグラムを獲得する。*/
+	if ((error = IN_GET_DATAGRAM(nbuf,
+	                             (uint_t)(TCP_HDR_SIZE + optlen + len),
+	                             (uint_t)(maxlen - IF_IP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)),
+	                             &cep->dstaddr.ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
 		syslog(LOG_WARNING, "[TCP] NET BUF busy,  len:%4d, CEP: %d.",
 		                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
@@ -734,5 +990,11 @@
 
 	/* TCP ヘッダに情報を設定する。*/
-	tcp_set_header(*nbuf, cep, IF_IP_TCP_HDR_OFFSET, optlen);
+
+	/* TCP ヘッダに情報を設定する。*/
+	tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
+	tcph->sport	= htons(cep->myaddr.portno);
+	tcph->dport	= htons(cep->dstaddr.portno);
+	tcph->doff	= TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
+	tcph->sum	= tcph->flags = 0;
 
 	return E_OK;
@@ -761,17 +1023,10 @@
 				error = E_OBJ;
 			else {
-
+				/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-				/* コールバック関数を呼び出す。*/
 				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				/* コールバック関数を呼び出す。*/
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 				error = E_WBLK;
 				}
@@ -798,18 +1053,12 @@
 					error = E_OBJ;
 				else {
-
+					error = E_OBJ;
+
+					/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-					/* コールバック関数を呼び出す。*/
-					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)E_OBJ);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-					/* コールバック関数を呼び出す。*/
-					error = E_OBJ;
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
+#else
 					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 					error = E_WBLK;
 					}
@@ -859,16 +1108,10 @@
 				*error = E_OBJ;
 			else {
+				/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-				/* コールバック関数を呼び出す。*/
 				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				/* コールバック関数を呼び出す。*/
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 				*error = E_WBLK;
 				}
@@ -900,18 +1143,12 @@
 					*error = E_OBJ;
 				else {
-
+					*error = E_OBJ;
+
+					/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-					/* コールバック関数を呼び出す。*/
-					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)E_OBJ);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-					/* コールバック関数を呼び出す。*/
-					*error = E_OBJ;
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
+#else
 					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 					*error = E_WBLK;
 					}
@@ -961,6 +1198,4 @@
 				 *  受信ウィンドバッファキューのネットワークバッファを解放する。
 				 */
-#ifdef TCP_CFG_RWBUF_CSAVE
-#endif
 				syscall(wai_sem(cep->semid_lock));
 				TCP_FREE_RWBUFQ(cep);
@@ -971,6 +1206,7 @@
 			}
 		}
-	else
+	else {
 		syscall(clr_flg(cep->rcv_flgid, (FLGPTN)(~TCP_CEP_EVT_RWBUF_READY)));
+		}
 
 	return E_OK;
@@ -994,5 +1230,5 @@
 		while (cep->reassq != NULL) {
 			q = cep->reassq;
-			qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
+			qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
 			if (qhdr->seq != cep->rcv_nxt)
 				break;
@@ -1005,5 +1241,5 @@
 
 			/* データを受信ウィンドバッファに書き込む。*/
-			TCP_WRITE_RWBUF(cep, q, (uint_t)(GET_TCP_IP_Q_HDR(q)->thoff));
+			TCP_WRITE_RWBUF(cep, q, (uint_t)(GET_IP_TCP_Q_HDR_OFFSET(q)));
 			}
 		}
@@ -1028,5 +1264,5 @@
 
 	/*  TCP ヘッダの位置を保存する。*/
-	GET_TCP_IP_Q_HDR(input)->thoff = thoff;
+	SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
 
 	/*
@@ -1035,5 +1271,5 @@
 	 *  このとき、IP のオプション（拡張ヘッダ）と TCP のオプションは削除する。
 	 */
-	len  = IF_IP_TCP_HDR_SIZE + inqhdr->slen;
+	len  = IF_IP_TCP_HDR_SIZE(input) + inqhdr->slen;
 
 	if (len <= MAX_TCP_REALLOC_SIZE) {
@@ -1080,5 +1316,5 @@
 	 */
 	for (q = cep->reassq, p = NULL; q != NULL; ) {
-		qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
+		qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
 		if (SEQ_GT(qhdr->seq, inqhdr->seq))
 			break;
@@ -1106,5 +1342,5 @@
 	 */
 	if (p != NULL) {
-		qhdr = GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff);
+		qhdr = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p));
 		len = qhdr->seq + qhdr->slen - inqhdr->seq;
 		if (len > 0) {
@@ -1169,5 +1405,5 @@
 	 */
 	while (q != NULL) {
-		qhdr = GET_TCP_Q_HDR(q, GET_TCP_IP_Q_HDR(q)->thoff);
+		qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
 		len = inqhdr->seq + inqhdr->slen - qhdr->seq;
 		if (len <= 0)
@@ -1201,5 +1437,5 @@
 		nq = qhdr->next;
 		if (p)
-			GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next = nq;
+			GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = nq;
 		else
 			cep->reassq = nq;
@@ -1213,6 +1449,6 @@
 		}
 	else {
-		inqhdr->next = GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next;
-		GET_TCP_Q_HDR(p, GET_TCP_IP_Q_HDR(p)->thoff)->next = input;
+		inqhdr->next = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next;
+		GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = input;
 		}
 
@@ -1243,4 +1479,5 @@
 tcp_init_cep (T_TCP_CEP *cep)
 {
+
 #ifdef TCP_CFG_RWBUF_CSAVE
 	/*
@@ -1255,4 +1492,5 @@
 #endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
 
+
 	memset((uint8_t*)cep + offsetof(T_TCP_CEP, timer), 0,
 	       sizeof(T_TCP_CEP) - offsetof(T_TCP_CEP, timer));
@@ -1273,10 +1511,10 @@
 	 * ・送受信ウィンドバッファの省コピー機能
 	 * ・動的な通信端点の生成・削除機能
+	 * ・通信端点のネットワーク層プロトコル
 	 */
-	cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK | 
-	               TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
 
 	/* セマフォを初期化する。*/
-	sig_sem (cep->semid_lock);
+	sig_sem(cep->semid_lock);
 
 	/* フラグを初期化する。*/
@@ -1292,12 +1530,7 @@
 tcp_notify (T_NET_BUF *input, ER error)
 {
-	T_IP_HDR	*iph;
-	T_TCP_HDR	*tcph;
 	T_TCP_CEP	*cep;
 
-	iph  = GET_IP_HDR(input);
-	tcph = GET_TCP_HDR(input, GET_TCP_HDR_OFFSET(input));
-
-	if ((cep = tcp_find_cep(&iph->src, tcph->sport, &iph->dst, tcph->dport)) != NULL) {
+	if ((cep = tcp_find_cep(input, GET_TCP_HDR_OFFSET(input))) != NULL) {
 
 		/*
@@ -1328,41 +1561,4 @@
 
 /*
- *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
- *
- *    注意: dstaddr は、
- *          TINET-1.2 からネットワークバイトオーダ、
- *          TINET-1.1 までは、ホストバイトオーダ
- */
-
-T_TCP_CEP*
-tcp_find_cep (T_IN_ADDR *dstaddr, uint16_t dstport, T_IN_ADDR *peeraddr, uint16_t peerport)
-{
-	T_TCP_CEP*	cep;
-	
-	/*
-	 *  状態が SYN 送信済み以後は、
-	 *  IP アドレスとポート番号が一致する通信端点を探索する。
-	 */
-	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
-		if (cep->fsm_state >= TCP_FSM_SYN_SENT                    &&
-		    IN_IS_DSTADDR_ACCEPT (&cep->myaddr.ipaddr,  dstaddr)  &&
-		    IN_ARE_NET_ADDR_EQUAL(&cep->dstaddr.ipaddr, peeraddr) &&
-		    dstport  == cep->myaddr.portno                        &&
-		    peerport == cep->dstaddr.portno)
-			return cep;
-		}
-
-	/* 受動オープン中の通信端点を探索する。*/	
-	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
-		if (cep->fsm_state == TCP_FSM_LISTEN &&
-		    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, dstaddr) &&
-		    dstport == cep->myaddr.portno)
-			return cep;
-		}
-
-	return NULL;
-	}
-
-/*
  *  tcp_lock_cep -- TCP 通信端点をロックする。
  */
@@ -1377,5 +1573,5 @@
 
 	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
+	if (!VALID_TCP_CEPID(cepid))
 		return E_ID;
 
@@ -1424,4 +1620,8 @@
 
 #ifdef TCP_CFG_TRACE
+
+/*
+ *  トレース出力に用いるシリアルポート番号
+ */
 
 #ifndef CONSOLE_PORTID
@@ -1624,5 +1824,4 @@
 {
 	SYSTIM		time;
-	T_IP_HDR	*iph;
 	T_TCP_HDR	*tcph;
 	char		buf[9];
@@ -1632,14 +1831,25 @@
 		return;
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
+
+#if defined(_IP6_CFG)
+
+	if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
+	     ((cep->flags & TCP_CEP_FLG_IPV4) && 
+	      IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
+	      (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
+		return;
+
+#else	/* of #if defined(_IP6_CFG) */
 
 	if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
 		return;
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #if defined(_IP4_CFG) */
 
 	syscall(wai_sem(SEM_TCP_TRACE));
 	syscall(get_tim(&time));
-	iph  = GET_IP_HDR(output);
 	tcph = GET_TCP_HDR(output, GET_TCP_HDR_OFFSET(output));
 	if (time > 99999999)
@@ -1648,7 +1858,7 @@
 		trace_printf(CONSOLE_PORTID, "=O%6d.%03d", time / 1000, time % 1000);
 	if (cep == NULL)
-		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:-----");
+		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
 	else
-		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%05x",
+		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
 		                             GET_TCP_CEPID(cep),
 		                             tcp_strfsm[cep->fsm_state], cep->flags);
@@ -1663,5 +1873,5 @@
 	trace_printf(CONSOLE_PORTID, " w:%5d l:%4d>\n", 
 	                             ntohs(tcph->win),
-	                             GET_IP_SDU_SIZE(iph) - TCP_HDR_LEN(tcph->doff));
+	                             GET_IP_SDU_SIZE(output) - TCP_HDR_LEN(tcph->doff));
 	syscall(sig_sem(SEM_TCP_TRACE));
 	}
@@ -1677,5 +1887,4 @@
 {
 	SYSTIM		time;
-	T_IP_HDR	*iph;
 	T_TCP_HDR	*tcph;
 	char		buf[9];
@@ -1685,14 +1894,25 @@
 		return;
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
+
+#if defined(_IP6_CFG)
+
+	if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
+	     ((cep->flags & TCP_CEP_FLG_IPV4) && 
+	      IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
+	      (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
+		return;
+
+#else	/* of #if defined(_IP6_CFG) */
 
 	if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
 		return;
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #if defined(_IP4_CFG) */
 
 	syscall(wai_sem(SEM_TCP_TRACE));
 	syscall(get_tim(&time));
-	iph  = GET_IP_HDR(input);
 	tcph = GET_TCP_HDR(input, GET_TCP_HDR_OFFSET(input));
 	if (time > 99999999)
@@ -1701,7 +1921,7 @@
 		trace_printf(CONSOLE_PORTID, "<I%6d.%03d", time / 1000, time % 1000);
 	if (cep == NULL)
-		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:-----");
+		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
 	else
-		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%05x",
+		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
 		                             GET_TCP_CEPID(cep),
 		                             tcp_strfsm[cep->fsm_state], cep->flags);
@@ -1712,5 +1932,5 @@
 		trace_printf(CONSOLE_PORTID, " a:%10u s:%10u", tcph->ack, tcph->seq);
 	trace_printf(CONSOLE_PORTID, " w:%5d l:%4d=\n", 
-	                             tcph->win, GET_IP_SDU_SIZE(iph) - TCP_HDR_LEN(tcph->doff));
+	                             tcph->win, GET_IP_SDU_SIZE(input) - TCP_HDR_LEN(tcph->doff));
 	syscall(sig_sem(SEM_TCP_TRACE));
 	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_cs.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_cs.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_cs.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
  *
@@ -95,6 +95,6 @@
 #include <net/ethernet.h>
 #include <net/if_arp.h>
-#include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -103,18 +103,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/in_var.h>
+#include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
-#include <netinet/in_itron.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
@@ -122,5 +117,7 @@
 #ifdef TCP_CFG_SWBUF_CSAVE
 
-#ifndef TCP_CFG_SWBUF_CSAVE_ONLY
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
 
 /*
@@ -242,5 +239,5 @@
 	}
 
-#endif	/* of #ifndef TCP_CFG_SWBUF_CSAVE_ONLY */
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
 
 /*
@@ -270,10 +267,10 @@
 {
 	ER_UINT	error;
+	uint_t	hdr_size = IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
 
 	/* 通信端点をロックする。*/
 	syscall(wai_sem(cep->semid_lock));
 
-	if ((error = net_buf_siz(cep->swbufq)) > 0 && error >= IF_IP_TCP_HDR_SIZE) {
-
+	if ((error = net_buf_siz(cep->swbufq)) > 0 && error >= hdr_size) {
 
 		/*
@@ -291,10 +288,10 @@
 		 *  空きサイズを 4 オクテット境界に調整する。
 		 */
-		error = (uint_t)(((error - IF_IP_TCP_HDR_SIZE) >> 2 << 2) + IF_IP_TCP_HDR_SIZE);
+		error = (uint_t)(((error - hdr_size) >> 2 << 2) + hdr_size);
 
 		if (len > cep->sbufsz - cep->swbuf_count)
 			len = (uint_t)(cep->sbufsz - cep->swbuf_count);
-		if (len > (error - IF_IP_TCP_HDR_SIZE))
-			len = (uint_t)(error - IF_IP_TCP_HDR_SIZE);
+		if (len > (error - hdr_size))
+			len = (uint_t)(error - hdr_size);
 
 		/* 送信ウインドサイズによりサイズを調整する。*/
@@ -315,6 +312,6 @@
 
 		/* ネットワークバッファ長と IP データグラム長を設定する。*/
-		cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_HDR_SIZE);
-		SET_IP_SDU_SIZE(GET_IP_HDR(cep->swbufq), cep->swbuf_count + TCP_HDR_SIZE);
+		cep->swbufq->len = (uint16_t)(cep->swbuf_count + hdr_size);
+		SET_IP_SDU_SIZE(cep->swbufq, cep->swbuf_count + TCP_HDR_SIZE);
 
 		/* フラグを、送信可能に設定する。*/
@@ -324,5 +321,5 @@
 	else {	/* 送信ウインドバッファが不正 */
 		syslog(LOG_WARNING, "[TCP] illegal window buff for send, CEP: %d, %4d < %4d.",
-		                    GET_TCP_CEPID(cep), error, IF_IP_TCP_HDR_SIZE);
+		                    GET_TCP_CEPID(cep), error, hdr_size);
 
 		/* 送信ウィンドバッファキューのネットワークバッファを解放する。*/
@@ -348,8 +345,7 @@
 	int_t	win;
 
-
 	/* 送信ウィンドバッファが割当て済みで、空きがあれば終了する。*/
 	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_READY &&
-	    (cep->swbuf_count + IF_IP_TCP_HDR_SIZE) < net_buf_siz(cep->swbufq))
+	    (cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) < net_buf_siz(cep->swbufq))
 		return E_OK;
 
@@ -423,7 +419,7 @@
 
 	/* ネットワークバッファを獲得する。*/
-	if ((error = tcp_get_segment(&cep->swbufq, cep, 0,
+	if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
 	                             TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
-	                             TCP_CFG_SWBUF_CSAVE_MAX_SIZE - IF_IP_TCP_HDR_SIZE,
+	                             TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
 	                             NBA_SEARCH_DESCENT, tmout)) != E_OK)
 		return error;
@@ -463,5 +459,5 @@
 		 *  空きサイズを 4 オクテット境界に調整する。
 		 */
-		error = (uint_t)(((error - IF_IP_TCP_HDR_SIZE) >> 2 << 2) - cep->swbuf_count);
+		error = (uint_t)(((error - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) >> 2 << 2) - cep->swbuf_count);
 
 		/* 送信ウインドサイズによりサイズを調整する。*/
@@ -508,6 +504,6 @@
 
 	/* ネットワークバッファ長と IP データグラム長を設定する。*/
-	cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_HDR_SIZE);
-	SET_IP_SDU_SIZE(GET_IP_HDR(cep->swbufq), len + TCP_HDR_SIZE);
+	cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr));
+	SET_IP_SDU_SIZE(cep->swbufq, len + TCP_HDR_SIZE);
 
 	/* tcp_get_buf の割当て長をリセットする。*/
@@ -573,5 +569,5 @@
 {
 	return (cep->flags & TCP_CEP_FLG_WBCS_MASK) != TCP_CEP_FLG_WBCS_NBUF_READY ||
-	        cep->swbuf_count >= cep->swbufq->len - IF_IP_TCP_HDR_SIZE;
+	        cep->swbuf_count >= cep->swbufq->len - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
 	}
 
@@ -590,5 +586,5 @@
 
 	/* 送信ウインドバッファのアドレスを設定する。*/
-	cep->sbuf_wptr = cep->sbuf_rptr = GET_TCP_SDU(cep->swbufq, IF_IP_TCP_HDR_OFFSET);
+	cep->sbuf_wptr = cep->sbuf_rptr = GET_TCP_SDU(cep->swbufq, IF_IP_TCP_NET_HDR_OFFSET(&cep->dstaddr.ipaddr));
 
 	/* フラグを、ネットワークバッファ割当て済みに設定する。*/
@@ -664,5 +660,7 @@
 #ifdef TCP_CFG_RWBUF_CSAVE 
 
-#ifndef TCP_CFG_RWBUF_CSAVE_ONLY
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
 
 /*
@@ -736,5 +734,5 @@
 	}
 
-#endif	/* of #ifndef TCP_CFG_RWBUF_CSAVE_ONLY */
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
 
 /*
@@ -753,5 +751,5 @@
 	if (cep->rwbufq != NULL) {
 
-		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
 		cep->rwbuf_count -= len;
 
@@ -796,5 +794,5 @@
 	 */
 	while (cep->rwbufq != NULL && len > 0) {
-		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
 
 		/*
@@ -808,5 +806,5 @@
 
 		memcpy(buf,
-		       GET_TCP_SDU(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff,
+		       GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff,
 		       (size_t)blen);
 
@@ -850,6 +848,6 @@
 
 		/* 受信ウィンドバッファのデータのアドレスの先頭を設定する。*/
-		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
-		*p_buf = GET_TCP_SDU(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff;
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
+		*p_buf = GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
 
 		/* 受信ウィンドバッファのデータ長を計算する。*/
@@ -880,5 +878,5 @@
 	if (cep->rwbuf_count == 0 && cep->reassq == NULL) {
 		while (cep->rwbufq != NULL) {
-			next = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff)->next;
+			next = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq))->next;
 
 #ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES
@@ -961,5 +959,5 @@
 	nextp = &cep->rwbufq;
 	while (*nextp)
-		nextp = &GET_TCP_Q_HDR(*nextp, GET_TCP_IP_Q_HDR(*nextp)->thoff)->next;
+		nextp = &GET_TCP_Q_HDR(*nextp, GET_IP_TCP_Q_HDR_OFFSET(*nextp))->next;
 	*nextp = input;
 
@@ -984,5 +982,5 @@
 		int_t	len;
 
-		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff);
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
 		len = qhdr->slen;
 
@@ -999,18 +997,13 @@
 			/* 受信ウィンドバッファのアドレスを返す。*/
 			*cep->rcv_p_buf = GET_TCP_SDU(cep->rwbufq,
-			                  GET_TCP_IP_Q_HDR(cep->rwbufq)->thoff) + qhdr->soff;
+			                  GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
 
 			if (IS_PTR_DEFINED(cep->callback))
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			else
 				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
@@ -1053,13 +1046,8 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			else
 				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_ncs.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_ncs.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr_ncs.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
  *
@@ -95,6 +95,6 @@
 #include <net/ethernet.h>
 #include <net/if_arp.h>
-#include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -103,18 +103,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/in_var.h>
+#include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
-#include <netinet/in_itron.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
@@ -134,13 +129,15 @@
 {
 	uint8_t	*wptr, *rptr;
+	uint_t	sdu_size   = GET_IP_SDU_SIZE(output);
+	uint_t	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
 
 	/* SDU の大きさをチェックする。*/
-	if (GET_IP_SDU_SIZE(GET_IP_HDR(output)) < GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET) + len) {
+	if (sdu_size < GET_TCP_HDR_SIZE(output, hdr_offset) + len) {
 		syslog(LOG_INFO, "[TCP] shrink SUD len: %d -> %d",
-		       (uint16_t)len, (uint16_t)(GET_IP_SDU_SIZE(GET_IP_HDR(output)) - GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET)));
-		len = GET_IP_SDU_SIZE(GET_IP_HDR(output)) - GET_TCP_HDR_SIZE2(output, IF_IP_TCP_HDR_OFFSET);
-		}
-
-	wptr = GET_TCP_SDU(output, IF_IP_TCP_HDR_OFFSET);
+		       (uint16_t)len, (uint16_t)(sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset)));
+		len = sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset);
+		}
+
+	wptr = GET_TCP_SDU(output, hdr_offset);
 
 	/* 通信端点をロックする。*/
@@ -222,14 +219,10 @@
 
 			if (IS_PTR_DEFINED(cep->callback))
+
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			else
 				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
@@ -268,13 +261,8 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 			(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 			(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 		else
 			syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
@@ -628,13 +616,8 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			else
 				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
@@ -680,13 +663,8 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			else
 				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.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
  *
@@ -91,20 +91,16 @@
 #include <net/if_loop.h>
 #include <net/ethernet.h>
-#include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
-#include <net/net_buf.h>
 #include <net/net_timer.h>
 
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/ip.h>
-#include <netinet/ip6.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
 
 #ifdef SUPPORT_TCP
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h	(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
  *
@@ -73,5 +73,5 @@
 /* TCP タイマ変数 */
 
-#define NUM_TCP_TIMERS		4	/* TCP のタイマ数	*/
+//#define NUM_TCP_TIMERS		4	/* TCP のタイマ数	*/
 
 #define TCP_TIM_REXMT		0	/* 再送タイマ		*/
@@ -135,8 +135,4 @@
 #define TCP_MAX_REXMT_SHIFT	12	/* 最大再送回数		*/
 
-/* TCP タイマ値の型 */
-
-typedef int16_t T_TCP_TIME;
-
 /*
  *  関数
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.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
  *
@@ -75,4 +75,5 @@
 #include <sil.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -83,4 +84,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -93,6 +95,6 @@
 #include <net/if_loop.h>
 #include <net/ethernet.h>
-#include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -102,40 +104,16 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
 
 #include <net/if_var.h>
 
 #ifdef SUPPORT_TCP
-
-/*
- *  IPv4 と IPv6 の切り替えマクロ
- */
-
-#if defined(SUPPORT_INET4)
-
-#define TCP_CRE_REP	tcp_cre_rep
-#define TCP_ACP_CEP	tcp_acp_cep
-#define TCP_CON_CEP	tcp_con_cep
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-#define TCP_CRE_REP	tcp6_cre_rep
-#define TCP_ACP_CEP	tcp6_acp_cep
-#define TCP_CON_CEP	tcp6_con_cep
-
-#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -169,588 +147,68 @@
 
 /*
- *  tcp_cre_rep -- TCP 受付口の生成【拡張機能】
- */
-
-#ifdef __tcp_cre_rep
-
-#ifdef TCP_CFG_EXTENTIONS
-
-ER
-TCP_CRE_REP (ID repid, T_TCP_CREP *pk_crep)
-{
-	T_TCP_REP	*rep;
-	ER		error;
-
-	/* TCP 受付口 ID をチェックする。*/
-	if (!VAID_TCP_REPID(repid))
-		return E_ID;
-
-	/* pk_crep が NULL ならエラー */
-	if (pk_crep == NULL)
-		return E_PAR;
-
-	/* TCP 受付口を得る。*/
-	rep = GET_TCP_REP(repid);
-
-	/* TCP 受付口が、動的生成用でなければエラー */
-	if (!DYNAMIC_TCP_REP(rep))
-		return E_ID;
-
-	/* 受付口をロックする。*/
-	syscall(wai_sem(rep->semid_lock));
-
-	/*
-	 * TCP 受付口をチェックする。生成済みであればエラー
-	 */
-	if (VALID_TCP_REP(rep))
-		error = E_OBJ;
-	else {
-
-		/* TCP 受付口生成情報をコピーする。*/
-		rep->repatr = pk_crep->repatr;		/* 受付口属性		*/
-		rep->myaddr = pk_crep->myaddr;		/* 自分のアドレス	*/
-
-		/* TCP 受付口を生成済みにする。*/
-		rep->flags |= TCP_REP_FLG_VALID;
-		error = E_OK;
-		}
-
-	/* 受付口のロックを解除する。*/
-	syscall(sig_sem(rep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_cre_cep */
-
-#ifdef __tcp_del_rep
-
-#ifdef TCP_CFG_EXTENTIONS
-
-/*
- *  tcp_find_cep_rep -- TCP 受付口をリンクしている TCP 通信端点を得る。
- */
-
-static T_TCP_CEP*
-tcp_find_cep_rep (T_TCP_REP* rep)
-{
-	T_TCP_CEP*	cep;
-
-	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
-		if (cep->rep == rep)
-			return cep;
-		}
-
-	return NULL;
-	}
-
-/*
- *  tcp_del_rep -- TCP 受付口の削除【拡張機能】
- */
-
-
-ER
-tcp_del_rep (ID repid)
-{
-	T_TCP_CEP	*cep;
-	T_TCP_REP	*rep;
-	ER		error = E_OK;
-
-	/* TCP 受付口 ID をチェックする。*/
-	if (!VAID_TCP_REPID(repid))
-		return E_ID;
-
-	/* TCP 受付口を得る。*/
-	rep = GET_TCP_REP(repid);
-
-	/* TCP 受付口が、動的生成用でなければエラー */
-	if (!DYNAMIC_TCP_REP(rep))
-		return E_ID;
-
-	/* 受付口をロックする。*/
-	syscall(wai_sem(rep->semid_lock));
-
-	/* TCP 受付口をチェックする。未生成の場合はエラー */
-	if (!VALID_TCP_REP(rep))
-		error = E_NOEXS;
-	else {
-		if ((cep = tcp_find_cep_rep(rep)) != NULL) {
-			/*
-			 * すでに受動オープンしているとき
-			 *（tcp_acp_cep が呼ばれているとき）は、
-			 * tcp_acp_cep を終了させる。
-			 */
-
-			/* 通信端点をロックする。*/
-			syscall(wai_sem(cep->semid_lock));
-
-			/*
-			 *  通信端点から受付口を解放し、
-			 *  イベントフラグをクローズに設定する。
-			 */
-			cep->rep = NULL;
-			cep->fsm_state = TCP_FSM_CLOSED;
-			cep->error = E_DLT;
-			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-			if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
-				if (IS_PTR_DEFINED(cep->callback)) {
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_DLT);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-					ER	error = E_DLT;
-
-					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-					}
-				else
-					error = E_OBJ;
-				cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
-				}
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-			cep->rcv_tskid = TA_NULL;
-			cep->rcv_tfn   = TFN_TCP_UNDEF;
-
-			/* 通信端点のロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-
-			}
-		else
-			error = E_OK;
-
-		/* TCP 受付口を未生成にする。*/
-		rep->flags &= ~TCP_REP_FLG_VALID;
-		}
-
-	/* 受付口のロックを解除する。*/
-	syscall(sig_sem(rep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_del_rep */
-
-/*
- *  tcp_cre_cep -- TCP 通信端点の生成【拡張機能】
- */
-
-#ifdef __tcp_cre_cep
-
-#ifdef TCP_CFG_EXTENTIONS
-
-ER
-tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
-{
-	T_TCP_CEP	*cep;
-	ER		error;
-
-	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
-		return E_ID;
-
-	/* pk_ccep が NULL ならエラー */
-	if (pk_ccep == NULL)
-		return E_PAR;
-
-	/* TCP 通信端点を得る。*/
-	cep = GET_TCP_CEP(cepid);
-
-	/* TCP 通信端点が、動的生成用でなければエラー */
-	if (!DYNAMIC_TCP_CEP(cep))
-		return E_ID;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	/*
-	 * TCP 通信端点をチェックする。生成済みであればエラー
-	 */
-	if (VALID_TCP_CEP(cep))
-		error = E_OBJ;
-	else {
-
-		/* TCP 通信端点生成情報をコピーする。*/
-		cep->cepatr   = pk_ccep->cepatr;		/* 通信端点属性			*/
-		cep->sbuf     = pk_ccep->sbuf;			/* 送信用ウィンドバッファ	*/
-		cep->sbufsz   = pk_ccep->sbufsz;		/* 送信用ウィンドバッファサイズ	*/
-		cep->rbuf     = pk_ccep->rbuf;			/* 受信用ウィンドバッファ	*/
-		cep->rbufsz   = pk_ccep->rbufsz;		/* 受信用ウィンドバッファサイズ	*/
-		cep->callback = (void*)pk_ccep->callback;	/* コールバック			*/
-
-		/* TCP 通信端点を生成済みにする。*/
-		cep->flags |= TCP_CEP_FLG_VALID;
-		error = E_OK;
-		}
-
-	/* 通信端点のロックを解除する。*/
-	syscall(sig_sem(cep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_cre_cep */
-
-/*
- *  tcp_del_cep -- TCP 通信端点の削除【拡張機能】
- */
-
-#ifdef __tcp_del_cep
-
-#ifdef TCP_CFG_EXTENTIONS
-
-ER
-tcp_del_cep (ID cepid)
-{
-	T_TCP_CEP	*cep;
-	ER		error;
-
-	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
-		return E_ID;
-
-	/* TCP 通信端点を得る。*/
-	cep = GET_TCP_CEP(cepid);
-
-	/* TCP 通信端点が、動的生成用でなければエラー */
-	if (!DYNAMIC_TCP_CEP(cep))
-		return E_ID;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	/*
-	 * TCP 通信端点をチェックする。以下の場合はエラー
-	 * ・未生成。
-	 * ・使用中。
-	 */
-	if (!VALID_TCP_CEP(cep))
-		error = E_NOEXS;
-	else if (cep->fsm_state != TCP_FSM_CLOSED)
-		error = E_OBJ;
-	else {
-
-		/* TCP 通信端点を未生成にする。*/
-		cep->flags &= ~TCP_CEP_FLG_VALID;
-		error = E_OK;
-		}
-
-	/* 通信端点のロックを解除する。*/
-	syscall(sig_sem(cep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_del_cep */
-
-#ifdef TCP_CFG_PASSIVE_OPEN
-
-/*
- *  tcp_acp_cep -- 接続要求待ち (受動オープン)【標準機能】
- */
-
-#ifdef __tcp_acp_cep
-
-ER
-TCP_ACP_CEP (ID cepid, ID repid, T_IPEP *p_dstaddr, TMO tmout)
-{
-	T_TCP_REP	*rep;
-	T_TCP_CEP	*cep;
-	ER		error;
-	FLGPTN		flag;
-
-	/* TCP 受付口をチェックする。*/
-	if (!VAID_TCP_REPID(repid))
-		return E_ID;
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/* p_dstaddr が NULL ならエラー */
-	if (p_dstaddr == NULL)
-		return E_PAR;
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/* p_dstaddr が NULL か、tmout が TMO_NBLK ならエラー */
-	if (p_dstaddr == NULL || tmout == TMO_NBLK)
-		return E_PAR;
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/*
-	 *  CEP をロックし、API 機能コードとタスク識別子を記録する。
-	 *  すでに記録されていれば、ペンディング中なのでエラー
-	 */
-	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_ACP_CEP)) != E_OK)
-		return error;
-
-	/* CEP の FSM がクローズ状態でなければエラー。*/
-	if (cep->fsm_state != TCP_FSM_CLOSED) {
-		error = E_OBJ;
-		goto err_ret;
-		}
-	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
-
-	/* TCP 通信端点を初期化する。*/
-	tcp_init_cep(cep);
-
-	/* TCP 受付口を得る。*/
-	rep = GET_TCP_REP(repid);
-
-#ifdef TCP_CFG_EXTENTIONS
-
-	/* TCP 受付口をロックする。*/
-	syscall(wai_sem(rep->semid_lock));
-
-	/* TCP 受付口をチェックする。*/
-	if (!VALID_TCP_REP(rep)) {
-		syscall(sig_sem(rep->semid_lock));
-		error = E_NOEXS;
-		goto err_ret;
-		}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-	/* TCP 通信端点にTCP受付口を記録する。*/
-	cep->rep = rep;
-
-#ifdef TCP_CFG_EXTENTIONS
-
-	/* TCP 受付口のロックを解除する。*/
-	syscall(sig_sem(rep->semid_lock));
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-	/* TCP 受付口のアドレスをコピーする。*/
-	cep->myaddr = rep->myaddr;
-
-	/* 通信端点を設定する。*/
-	cep->fsm_state = TCP_FSM_LISTEN;
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/* タイムアウトをチェックする。*/
-	if (tmout == TMO_NBLK) {
-		/* ノンブロッキングコール */
-		cep->p_dstaddr    = p_dstaddr;
-		cep->rcv_nblk_tfn = TFN_TCP_ACP_CEP;
-		return E_WBLK;
-		}
-	else {
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-		/*
-		 *  FSM が ESTABLISHED になるまで待つ。
-		 *  FSM が CLOSED になった場合は、エラーが発生したことを意味している。
-		 */
-		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
-		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
-		if (error == E_OK) {
-			if (cep->error != E_OK)
-				error = cep->error;
-			else if (cep->fsm_state == TCP_FSM_CLOSED)
-				error = E_TMOUT;
-			}
-
-		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
-
-		if (error == E_OK) {
-			/* 相手のアドレスをコピーする。*/
-			*p_dstaddr = cep->dstaddr;
-			}
-		else {
-			/*
-			 *  通信端点から受付口を解放し、
-			 *  イベントフラグをクローズに設定する。
-			 */
-			cep->rep = NULL;
-			cep->fsm_state = TCP_FSM_CLOSED;
-			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
-			}
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-		}
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-err_ret:
-	cep->rcv_tskid = TA_NULL;
-	cep->rcv_tfn   = TFN_TCP_UNDEF;
-	return error;
-	}
-
-#endif	/* of #ifdef __tcp_acp_cep */
-
-#endif	/* of #ifdef TCP_CFG_PASSIVE_OPEN */
-
-/*
- *  tcp_con_cep -- 接続要求 (能動オープン)【標準機能】
- */
-
-#ifdef __tcp_con_cep
-
-ER
-TCP_CON_CEP (ID cepid, T_IPEP *p_myaddr, T_IPEP *p_dstaddr, TMO tmout)
-{
-	T_TCP_CEP	*cep;
-	ER		error;
-	FLGPTN		flag;
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/*
-	 *  p_dstaddr または p_myaddr が NULL か、
-	 *  あて先がマルチキャストアドレスならエラー
-	 */
-	if (p_myaddr == NULL || p_dstaddr == NULL || IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr))
-		return E_PAR;
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/*
-	 *  p_dstaddr または p_myaddr が NULL 、
-	 *  あて先がマルチキャストアドレスか、
-	 *  tmout が TMO_NBLK ならエラー
-	 */
-	if (p_myaddr == NULL || p_dstaddr == NULL ||
-	    IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr) || tmout == TMO_NBLK)
-		return E_PAR;
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/*
-	 *  CEP をロックし、API 機能コードとタスク識別子を記録する。
-	 *  すでに記録されていれば、ペンディング中なのでエラー
-	 */
-	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CON_CEP)) != E_OK)
-		return error;
-
-	/* CEP の FSM がクローズ状態でなければエラー。*/
-	if (cep->fsm_state != TCP_FSM_CLOSED) {
-		error = E_OBJ;
-		goto err_ret;
-		}
-	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
-
-	/* シーケンス番号を初期化する。*/
-	if (tcp_iss == 0)
-		tcp_init_iss();
-
-	/* 通信端点を初期化する。*/
-	tcp_init_cep(cep);
-
-	/*
-	 *  p_myaddr が NADR (-1) ではなく、自 IP アドレスが ANY でなければ、
-	 *  指定された IP アドレスを割り当てる。
-	 */
-	if (p_myaddr != NADR && !IN_IS_ADDR_ANY(&p_myaddr->ipaddr))
-		cep->myaddr.ipaddr = p_myaddr->ipaddr;
-	else {
-		T_IN_IFADDR	*ia;
-
-		if ((ia = IN_IFAWITHIFP(IF_GET_IFNET(), &p_dstaddr->ipaddr)) == NULL) {
-			error = E_PAR;
-			goto err_ret;
-			}
-		cep->myaddr.ipaddr = ia->addr;
-		}
-
-	/* 通信端点を設定する。*/
-	cep->fsm_state = TCP_FSM_SYN_SENT;
-	cep->dstaddr   = *p_dstaddr;
-	cep->iss       = tcp_iss;
-	cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INIT;
-	tcp_iss += TCP_ISS_INCR() / 2;
-	init_send_seq(cep);
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/* タイムアウトをチェックする。*/
-	if (tmout == TMO_NBLK) {
-		/* ノンブロッキングコール */
-		cep->p_dstaddr    = p_dstaddr;
-		cep->p_myaddr     = p_myaddr;
-		cep->snd_nblk_tfn = TFN_TCP_CON_CEP;
-
-		/* コネクションの開設をポストする。*/
-		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
-		sig_sem(SEM_TCP_POST_OUTPUT);
-		return E_WBLK;
-		}
-	else {
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-		/*
-		 *  p_myaddr が NADR (-1) か、
-		 *  自ポート番号が TCP_PORTANY なら、自動で割り当てる。
-		 */
-		if (p_myaddr == NADR || p_myaddr->portno == TCP_PORTANY)
-			tcp_alloc_auto_port(cep);
-		else if ((error = tcp_alloc_port(cep, p_myaddr->portno)) != E_OK)
-			goto err_ret;
-
-		/* コネクションの開設をポストする。*/
-		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
-		sig_sem(SEM_TCP_POST_OUTPUT);
-
-		/*
-		 *  イベントが ESTABLISHED になるまで待つ。
-		 *  イベントが CLOSED になった場合は、何らかのエラーが発生したか、
-		 *  接続要求が拒否されたことを意味している。
-		 */
-		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
-		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
-		if (error == E_OK) {
-			if (cep->error != E_OK)
-				error = cep->error;
-			else if (cep->fsm_state == TCP_FSM_CLOSED)
-				error = E_CLS;
-			}
-
-		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
-
-		if (error != E_OK) {
-			/*
-			 *  通信端点から受付口を解放し、
-			 *  イベントフラグをクローズに設定する。
-			 */
-			cep->rep = NULL;
-			cep->fsm_state = TCP_FSM_CLOSED;
-			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
-			}
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-		}
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-err_ret:
-	cep->snd_tskid = TA_NULL;
-	cep->snd_tfn   = TFN_TCP_UNDEF;
-	return error;
-	}
-
-#endif	/* of #ifdef __tcp_con_cep */
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
+ */
+
+#if defined(SUPPORT_INET6)
+
+#define T_IPEP			T_IPV6EP
+#define TCP_ACP_CEP		tcp6_acp_cep
+#define TCP_CON_CEP		tcp6_con_cep
+#define TCP_FIND_CEP_REP	tcp6_find_cep_rep
+
+#if defined(SUPPORT_INET4)
+
+#undef	T_TCP_REP
+#define T_TCP_REP		T_TCP6_REP
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#define TCP_CRE_REP		tcp6_cre_rep
+#define TCP_DEL_REP_BODY	tcp6_del_rep_body
+#define GET_TCP_REP		GET_TCP6_REP
+#define VALID_TCP_REPID		VALID_TCP6_REPID
+#define T_TCPN_CREP		T_TCP6_CREP
+#define API_PROTO		API_PROTO_IPV6
+
+#include <netinet/tcpn_usrreq.c>
+
+#undef  T_IPEP
+#undef  TCP_ACP_CEP
+#undef  TCP_CON_CEP
+#undef	TCP_FIND_CEP_REP
+
+#undef  TCP_CRE_REP
+#undef	TCP_DEL_REP_BODY
+#undef	GET_TCP_REP
+#undef	VALID_TCP_REPID
+#undef	T_TCPN_CREP
+#undef  API_PROTO
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#define T_IPEP			T_IPV4EP
+#define TCP_ACP_CEP		tcp_acp_cep
+#define TCP_CON_CEP		tcp_con_cep
+#define TCP_FIND_CEP_REP	tcp4_find_cep_rep
+
+#if defined(SUPPORT_INET6)
+
+#undef	T_TCP_REP
+#define T_TCP_REP		T_TCP4_REP
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#define TCP_CRE_REP		tcp_cre_rep
+#define TCP_DEL_REP_BODY	tcp4_del_rep_body
+#define GET_TCP_REP		GET_TCP4_REP
+#define VALID_TCP_REPID		VALID_TCP4_REPID
+#define T_TCPN_CREP		T_TCP_CREP
+#define API_PROTO		API_PROTO_IPV4
+
+#include <netinet/tcpn_usrreq.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) */
 
 #ifdef __tcp_cls_cep
@@ -904,6 +362,5 @@
 				 * ・動的な通信端点の生成・削除機能
 				 */
-				cep->flags &= (TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK | 
-				               TCP_CEP_FLG_DYNAMIC       | TCP_CEP_FLG_VALID);
+				cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
 
 				/* 
@@ -1025,16 +482,10 @@
 			sig_sem(SEM_TCP_POST_OUTPUT);
 
+			/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-			/* コールバック関数を呼び出す。*/
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			/* コールバック関数を呼び出す。*/
+#else
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			error = E_WBLK;
 			goto err_ret;
@@ -1082,124 +533,4 @@
 
 #endif	/* of #ifdef __tcp_snd_dat */
-
-#ifdef __tcp_snd_oob
-
-#ifdef TCP_CFG_EXTENTIONS
-
-/*
- *  tcp_snd_oob -- 緊急データの送信【拡張機能】
- */
-
-ER_UINT
-tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
-{
-	T_TCP_CEP	*cep;
-	ER_UINT		error;
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/* data が NULL か、len < 0 ならエラー */
-	if (data == NULL || len < 0)
-		return E_PAR;
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/* data が NULL、len < 0 か、tmout が TMO_NBLK ならエラー */
-	if (data == NULL || len < 0 || tmout == TMO_NBLK)
-		return E_PAR;
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	/*
-	 *  CEP をロックし、API 機能コードとタスク識別子を記録する。
-	 *  すでに記録されていれば、ペンディング中なのでエラー
-	 */
-	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
-		return error;
-
-	/* 送信できるか、通信端点の状態を見る。*/
-	if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
-		goto err_ret;
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	/* タイムアウトをチェックする。*/
-	if (tmout == TMO_NBLK) {		/* ノンブロッキングコール */
-
-		/* 送信ウィンドバッファに空きがあればコールバック関数を呼び出す。*/
-		if (!TCP_IS_SWBUF_FULL(cep)) {
-
-		 	/* 送信ウィンドバッファにデータを書き込む。*/
-			error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
-
-			/* 送信緊急ポインタを設定する。*/
-			cep->snd_up = cep->snd_una + cep->swbuf_count;
-
-			/* 出力をポストする。*/
-			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
-			sig_sem(SEM_TCP_POST_OUTPUT);
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-			/* コールバック関数を呼び出す。*/
-			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			/* コールバック関数を呼び出す。*/
-			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			error = E_WBLK;
-			goto err_ret;
-			}
-		else {
-			cep->snd_data     = data;
-			cep->snd_len      = len;
-			cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
-			TCP_ALLOC_SWBUF(cep);
-
-			return E_WBLK;
-			}
-		}
-	else {		/* 非ノンブロッキングコール */
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-	 	/* 送信ウィンドバッファが空くのを待つ。*/
-		if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
-			goto err_ret;
-
-	 	/* 送信ウィンドバッファにデータを書き込む。*/
-		if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
-
-			/* 送信緊急ポインタを設定する。*/
-			cep->snd_up = cep->snd_una + cep->swbuf_count;
-
-			/* データを送信する。送信ウィンドバッファがフルのときは強制的に送信する。*/
-			if (TCP_IS_SWBUF_FULL(cep))
-				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
-
-			/* 出力をポストする。*/
-			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
-			sig_sem(SEM_TCP_POST_OUTPUT);
-			}
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-		}
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-err_ret:
-	cep->snd_tskid = TA_NULL;
-	cep->snd_tfn   = TFN_TCP_UNDEF;
-	return error;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_snd_oob */
 
 #ifdef __tcp_get_buf
@@ -1250,16 +581,10 @@
 			error = TCP_GET_SWBUF_ADDR(cep, p_buf);
 
+			/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-			/* コールバック関数を呼び出す。*/
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			/* コールバック関数を呼び出す。*/
+#else
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			error = E_WBLK;
 			goto err_ret;
@@ -1401,14 +726,10 @@
 			len = TCP_READ_RWBUF(cep, data, (uint_t)len);
 
+			/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#else
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			error = E_WBLK;
 			goto err_ret;
@@ -1449,65 +770,4 @@
 
 #endif	/* of #ifdef __tcp_rcv_dat */
-
-#ifdef __tcp_rcv_oob
-
-#ifdef TCP_CFG_EXTENTIONS
-
-/*
- *  tcp_rcv_oob -- 緊急データの受信【拡張機能】
- *
- *    注意: 送信側が複数オクテットのデータを送信しても、
- *          緊急ポインタが指す 1 オクテットのデータのみ受信する。
- */
-
-ER_UINT
-tcp_rcv_oob (ID cepid, void *data, int_t len)
-{
-	T_TCP_CEP	*cep;
-	uint8_t		*urg;
-
-	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
-		return E_ID;
-
-	/* data が NULL か、len < 0 ならエラー */
-	if (data == NULL || len < 0)
-		return E_PAR;
-
-	/* TCP 通信端点を得る。*/
-	cep = GET_TCP_CEP(cepid);
-
-	/* 受信できるか、通信端点の状態を見る。*/
-	/* 受信できるか、fsm_state を見る。*/
-	if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
-		return E_OBJ;
-
-	/*
-	 *  緊急データ入りのセグメントの TCP ヘッダが
-	 *  設定されていなければ、緊急データを受信していない。
-	 */
-	if (cep->urg_tcph == NULL)
-		return E_OBJ;
-
-	/* len == 0 ならバッファオーバーフロー */
-	if (len == 0)
-		return E_BOVR;
-
-	/* 緊急ポインタが指す 1 オクテットのデータを読み取る。*/
-	urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
-	*(uint8_t*)data = *urg;
-
-	/* 読み取ったデータから後ろの SDU を前に詰める。*/
-	memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
-
-	/* tcp_rcv_oob() が呼出されたこと知らせるために、NULL を設定する。*/
-	cep->urg_tcph = NULL;
-
-	return 1;
-	}
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __tcp_rcv_oob */
 
 #ifdef __tcp_rcv_buf
@@ -1559,16 +819,10 @@
 			error = TCP_GET_RWBUF_ADDR(cep, p_buf);
 
+			/* コールバック関数を呼び出す。*/
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-			/* コールバック関数を呼び出す。*/
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			/* コールバック関数を呼び出す。*/
+#else
 			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
+#endif
 			error = E_WBLK;
 			goto err_ret;
@@ -1705,6 +959,14 @@
 
 			case TFN_TCP_CON_CEP:
-				/*  通信端点から受付口を解放する。*/
+				/*
+				 *  通信端点から受付口を解放し、
+				 *  イベントフラグをクローズに設定する。
+				 */
 				cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+				cep->rep4 = NULL;
+#endif
+
 				cep->fsm_state = TCP_FSM_CLOSED;
 				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
@@ -1800,4 +1062,9 @@
 				 */
 				cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+				cep->rep4 = NULL;
+#endif
+
 				cep->fsm_state = TCP_FSM_CLOSED;
 				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
@@ -1866,5 +1133,5 @@
 
 	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
+	if (!VALID_TCP_CEPID(cepid))
 		return E_ID;
 
@@ -1914,4 +1181,357 @@
 #endif	/* of #ifdef __tcp_can_cep */
 
+#ifdef TCP_CFG_EXTENTIONS
+
+#ifdef __tcp_cre_cep
+
+/*
+ *  tcp_cre_cep -- TCP 通信端点の生成【拡張機能】
+ */
+
+ER
+tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* TCP 通信端点 ID をチェックする。*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* pk_ccep が NULL ならエラー */
+	if (pk_ccep == NULL)
+		return E_PAR;
+
+	/* TCP 通信端点を得る。*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP 通信端点が、動的生成用でなければエラー */
+	if (!DYNAMIC_TCP_CEP(cep))
+		return E_ID;
+
+	/* 通信端点をロックする。*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * TCP 通信端点をチェックする。生成済みであればエラー
+	 */
+	if (VALID_TCP_CEP(cep))
+		error = E_OBJ;
+	else {
+
+		/* TCP 通信端点生成情報をコピーする。*/
+		cep->cepatr   = pk_ccep->cepatr;		/* 通信端点属性			*/
+		cep->sbuf     = pk_ccep->sbuf;			/* 送信用ウィンドバッファ	*/
+		cep->sbufsz   = pk_ccep->sbufsz;		/* 送信用ウィンドバッファサイズ	*/
+		cep->rbuf     = pk_ccep->rbuf;			/* 受信用ウィンドバッファ	*/
+		cep->rbufsz   = pk_ccep->rbufsz;		/* 受信用ウィンドバッファサイズ	*/
+		cep->callback = (void*)pk_ccep->callback;	/* コールバック			*/
+
+		/* TCP 通信端点を生成済みにする。*/
+		cep->flags |= TCP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* 通信端点のロックを解除する。*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_cre_cep */
+
+/*
+ *  tcp_del_cep -- TCP 通信端点の削除【拡張機能】
+ */
+
+#ifdef __tcp_del_cep
+
+ER
+tcp_del_cep (ID cepid)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* TCP 通信端点 ID をチェックする。*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP 通信端点を得る。*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP 通信端点が、動的生成用でなければエラー */
+	if (!DYNAMIC_TCP_CEP(cep))
+		return E_ID;
+
+	/* 通信端点をロックする。*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * TCP 通信端点をチェックする。以下の場合はエラー
+	 * ・未生成。
+	 * ・使用中。
+	 */
+	if (!VALID_TCP_CEP(cep))
+		error = E_NOEXS;
+	else if (cep->fsm_state != TCP_FSM_CLOSED)
+		error = E_OBJ;
+	else {
+
+		/* TCP 通信端点を未生成にする。*/
+		cep->flags &= ~TCP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* 通信端点のロックを解除する。*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_del_cep */
+
+#ifdef __tcp_snd_oob
+
+/*
+ *  tcp_snd_oob -- 緊急データの送信【拡張機能】
+ */
+
+ER_UINT
+tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* data が NULL か、len < 0 ならエラー */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* data が NULL、len < 0 か、tmout が TMO_NBLK ならエラー */
+	if (data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP をロックし、API 機能コードとタスク識別子を記録する。
+	 *  すでに記録されていれば、ペンディング中なのでエラー
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
+		return error;
+
+	/* 送信できるか、通信端点の状態を見る。*/
+	if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* タイムアウトをチェックする。*/
+	if (tmout == TMO_NBLK) {		/* ノンブロッキングコール */
+
+		/* 送信ウィンドバッファに空きがあればコールバック関数を呼び出す。*/
+		if (!TCP_IS_SWBUF_FULL(cep)) {
+
+		 	/* 送信ウィンドバッファにデータを書き込む。*/
+			error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
+
+			/* 送信緊急ポインタを設定する。*/
+			cep->snd_up = cep->snd_una + cep->swbuf_count;
+
+			/* 出力をポストする。*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+
+			/* コールバック関数を呼び出す。*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->snd_data     = data;
+			cep->snd_len      = len;
+			cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
+			TCP_ALLOC_SWBUF(cep);
+
+			return E_WBLK;
+			}
+		}
+	else {		/* 非ノンブロッキングコール */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	 	/* 送信ウィンドバッファが空くのを待つ。*/
+		if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
+			goto err_ret;
+
+	 	/* 送信ウィンドバッファにデータを書き込む。*/
+		if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
+
+			/* 送信緊急ポインタを設定する。*/
+			cep->snd_up = cep->snd_una + cep->swbuf_count;
+
+			/* データを送信する。送信ウィンドバッファがフルのときは強制的に送信する。*/
+			if (TCP_IS_SWBUF_FULL(cep))
+				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
+
+			/* 出力をポストする。*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_snd_oob */
+
+#ifdef __tcp_rcv_oob
+
+/*
+ *  tcp_rcv_oob -- 緊急データの受信【拡張機能】
+ *
+ *    注意: 送信側が複数オクテットのデータを送信しても、
+ *          緊急ポインタが指す 1 オクテットのデータのみ受信する。
+ */
+
+ER_UINT
+tcp_rcv_oob (ID cepid, void *data, int_t len)
+{
+	T_TCP_CEP	*cep;
+	uint8_t		*urg;
+
+	/* TCP 通信端点 ID をチェックする。*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* data が NULL か、len < 0 ならエラー */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+	/* TCP 通信端点を得る。*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* 受信できるか、通信端点の状態を見る。*/
+	/* 受信できるか、fsm_state を見る。*/
+	if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
+		return E_OBJ;
+
+	/*
+	 *  緊急データ入りのセグメントの TCP ヘッダが
+	 *  設定されていなければ、緊急データを受信していない。
+	 */
+	if (cep->urg_tcph == NULL)
+		return E_OBJ;
+
+	/* len == 0 ならバッファオーバーフロー */
+	if (len == 0)
+		return E_BOVR;
+
+	/* 緊急ポインタが指す 1 オクテットのデータを読み取る。*/
+	urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
+	*(uint8_t*)data = *urg;
+
+	/* 読み取ったデータから後ろの SDU を前に詰める。*/
+	memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
+
+	/* tcp_rcv_oob() が呼出されたこと知らせるために、NULL を設定する。*/
+	cep->urg_tcph = NULL;
+
+	return 1;
+	}
+
+#endif	/* of #ifdef __tcp_rcv_oob */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#ifdef __tcp_del_rep
+
+/*
+ *  tcp_del_rep -- TCP 受付口の削除【拡張機能】
+ */
+
+#if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0
+
+#if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/*
+	 *  TCP 受付口 ID をチェックする。
+	 *  IPv6 用 TCP 受付口であれば、
+	 *  IPv6 用の「TCP 受付口の削除関数（本体）」を呼出す。
+	 */
+	//NET_DEBUG_TCP3("tcp_del_rep1[r=%d,n=%d,x=%d]\n",
+	//               repid, TMIN_TCP6_REPID, tmax_tcp6_repid);
+	//NET_DEBUG_TCP3("tcp_del_rep2[r=%d,n=%d,x=%d]\n",
+	//               repid, TMIN_TCP4_REPID, tmax_tcp4_repid);
+	if (VALID_TCP6_REPID(repid))
+		return tcp6_del_rep_body(repid);
+
+	/*
+	 *  TCP 受付口 ID をチェックする。
+	 *  IPv4 用 TCP 受付口であれば、
+	 *  IPv4 用の「TCP 受付口の削除関数（本体）」を呼出す。
+	 */
+	else if (VALID_TCP4_REPID(repid))
+		return tcp4_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#else	/* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/* TCP 受付口 ID をチェックする。*/
+	if (VALID_TCP6_REPID(repid))
+		return tcp6_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
+
+#else	/* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/* TCP 受付口 ID をチェックする。*/
+	if (VALID_TCP4_REPID(repid))
+		return tcp4_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
+
+#endif	/* of #ifdef __tcp_del_rep */
+
 /*
  *  tcp_set_opt -- TCP 通信端点オプションの設定【拡張機能】
@@ -1922,6 +1542,4 @@
 #ifdef __tcp_set_opt
 
-#ifdef TCP_CFG_EXTENTIONS
-
 ER
 tcp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
@@ -1930,5 +1548,5 @@
 
 	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
+	if (!VALID_TCP_CEPID(cepid))
 		return E_ID;
 
@@ -1943,6 +1561,4 @@
 	}
 
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
 #endif	/* of #ifdef __tcp_set_opt */
 
@@ -1955,6 +1571,4 @@
 #ifdef __tcp_get_opt
 
-#ifdef TCP_CFG_EXTENTIONS
-
 ER
 tcp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
@@ -1963,5 +1577,5 @@
 
 	/* TCP 通信端点 ID をチェックする。*/
-	if (!VAID_TCP_CEPID(cepid))
+	if (!VALID_TCP_CEPID(cepid))
 		return E_ID;
 
@@ -1976,7 +1590,7 @@
 	}
 
+#endif	/* of #ifdef __tcp_get_opt */
+
 #endif	/* of #ifdef TCP_CFG_EXTENTIONS */
 
-#endif	/* of #ifdef __tcp_get_opt */
-
 #endif	/* of #ifdef SUPPORT_TCP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h	(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
  *
@@ -75,20 +75,19 @@
  */
 
-#define IP_TCP_HDR_SIZE			(IP_HDR_SIZE + TCP_HDR_SIZE)
-#define IF_IP_TCP_HDR_SIZE		(IF_IP_HDR_SIZE + TCP_HDR_SIZE)
-#define IF_IP_TCP_HDR_OFFSET		(IF_IP_HDR_SIZE)
-#define IF_IP_TCP_SDU_OFFSET		(IF_IP_TCP_HDR_SIZE)
-
 #define GET_TCP_HDR(nbuf,thoff)		((T_TCP_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
 #define GET_TCP_OPT(nbuf,thoff)		((uint8_t*)((nbuf)->buf) + thoff + TCP_HDR_SIZE)
-#define GET_TCP_SDU(nbuf,thoff)		((uint8_t*)((nbuf)->buf) + thoff + GET_TCP_HDR_SIZE2(nbuf,thoff))
+#define GET_TCP_SDU(nbuf,thoff)		((uint8_t*)((nbuf)->buf) + thoff + GET_TCP_HDR_SIZE(nbuf,thoff))
 
 #define GET_TCP_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
 
-#define GET_TCP_HDR_SIZE2(nbuf,thoff)	(TCP_HDR_LEN(GET_TCP_HDR(nbuf,thoff)->doff))
-#define GET_IP_TCP_HDR_SIZE2(nbuf,thoff) \
-					(GET_IP_HDR_SIZE(GET_IP_HDR(nbuf)) + GET_TCP_HDR_SIZE2(nbuf,thoff))
-#define GET_IF_IP_TCP_HDR_SIZE2(nbuf,thoff) \
-					(IF_HDR_SIZE + GET_IP_TCP_HDR_SIZE2(nbuf,thoff))
+#define GET_TCP_HDR_SIZE(nbuf,thoff)	(TCP_HDR_LEN(GET_TCP_HDR(nbuf,thoff)->doff))
+
+#define GET_IP_TCP_HDR_SIZE(nbuf,thoff) (GET_IP_HDR_SIZE(nbuf) + GET_TCP_HDR_SIZE(nbuf,thoff))
+#define GET_IF_IP_TCP_HDR_SIZE(nbuf,thoff) \
+					(IF_HDR_SIZE + GET_IP_TCP_HDR_SIZE(nbuf,thoff))
+#define IF_IP_TCP_HDR_SIZE(nbuf)	(IF_IP_HDR_SIZE(nbuf) + TCP_HDR_SIZE)
+#define IF_IP_TCP_HDR_OFFSET(nbuf)	(IF_IP_HDR_SIZE(nbuf))
+#define IF_IP_TCP_NET_HDR_SIZE(addr)	(IF_IP_NET_HDR_SIZE(addr) + TCP_HDR_SIZE)
+#define IF_IP_TCP_NET_HDR_OFFSET(addr)	(IF_IP_NET_HDR_SIZE(addr))
 
 /*
@@ -96,12 +95,12 @@
  */
 
-#if defined(SUPPORT_INET4)
+#if !defined(_IP6_CFG) && defined(_IP4_CFG)
 
 #define IP4_TCP_HDR_SIZE		IP_TCP_HDR_SIZE
 #define IF_IP4_TCP_HDR_SIZE		IF_IP_TCP_HDR_SIZE
-#define GET_IP4_TCP_HDR_SIZE(nbuf)	GET_IP_TCP_HDR_SIZE(nbuf)	
-#define GET_IF_IP4_TCP_HDR_SIZE(nbuf)	GET_IF_IP_TCP_HDR_SIZE(nbuf)	
-
-#endif	/* of #if defined(SUPPORT_INET4) */
+#define GET_IP4_TCP_HDR_SIZE(nbuf)	GET_IP_TCP_HDR_SIZE1(nbuf)	
+#define GET_IF_IP4_TCP_HDR_SIZE(nbuf)	GET_IF_IP_TCP_HDR_SIZE1(nbuf)	
+
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
 
 /*
@@ -110,6 +109,7 @@
 
 #define	TMIN_TCP_CREPID			TMIN_TCP_REPID
+#define	TNUM_TCP_CREPID			TNUM_TCP_REPID
+
 #define	TMIN_TCP_CCEPID			TMIN_TCP_CEPID
-#define	TNUM_TCP_CREPID			TNUM_TCP_REPID
 #define	TNUM_TCP_CCEPID			TNUM_TCP_CEPID
 
@@ -121,8 +121,41 @@
 
 /*
+ * TCP で使用する変数の型の定義
+ */
+
+typedef uint32_t T_TCP_SEQ;
+typedef uint16_t T_TCP_SEG;
+typedef uint16_t T_TCP_WND;
+typedef int16_t T_TCP_TIME;
+
+/*
+ *  TCP タイマ変数
+ */
+
+#define NUM_TCP_TIMERS		4	/* TCP のタイマ数	*/
+
+/*
  *  TCP 受付口
  */
 
+/* IPv6 用 TCP 受付口 */
+
+typedef struct t_tcp6_rep {
+
+	/*
+	 * ITRON TCP/IP API、TCP 受付口と同じメンバ
+	 */
+	ATR		repatr;		/* 受付口属性		*/
+	T_IPV6EP	myaddr;		/* 自分のアドレス	*/
+
+#ifdef TCP_CFG_EXTENTIONS
+	uint16_t	flags;		/* 受付口フラグ		*/
+	ID		semid_lock;	/* 受付口ロック		*/
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	} T_TCP6_REP;
+
 /* IPv4 用 TCP 受付口 */
+
 typedef struct t_tcp4_rep {
 
@@ -140,27 +173,19 @@
 	} T_TCP4_REP;
 
-/* IPv6 用 TCP 受付口 */
-typedef struct t_tcp6_rep {
-
-	/*
-	 * ITRON TCP/IP API、TCP 受付口と同じメンバ
-	 */
-	ATR		repatr;		/* 受付口属性		*/
-	T_IPV6EP	myaddr;		/* 自分のアドレス	*/
-
-#ifdef TCP_CFG_EXTENTIONS
-	uint16_t	flags;		/* 受付口フラグ		*/
-	ID		semid_lock;	/* 受付口ロック		*/
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-	} T_TCP6_REP;
-
-#if defined(SUPPORT_INET4)
+#if defined(_IP6_CFG)
+
+#define T_TCP_REP	T_TCP6_REP
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
 #define T_TCP_REP	T_TCP4_REP
-#endif
-
-#if defined(SUPPORT_INET6)
-#define T_TCP_REP	T_TCP6_REP
-#endif
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#define T_TCP_REP_DEFINED
 
 /*
@@ -175,12 +200,13 @@
  */
 
-typedef uint32_t T_TCP_SEQ;
-typedef uint16_t T_TCP_SEG;
-typedef uint16_t T_TCP_WND;
-
-/*
- * 通常の IPv4 TCP 通信端点
- */
-typedef struct t_tcp4_cep {
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+typedef struct t_tcp_cep {
 
 	/*
@@ -232,6 +258,12 @@
 #ifdef TCP_CFG_NON_BLOCKING
 
-	T_IPV4EP 	*p_dstaddr;	/* 相手のアドレスへのポインタ	*/
-	T_IPV4EP 	*p_myaddr;	/* 自分のアドレスへのポインタ	*/
+	T_IPEP 		*p_dstaddr;	/* 相手のアドレスへのポインタ	*/
+	T_IPEP	 	*p_myaddr;	/* 自分のアドレスへのポインタ	*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+	T_IPV4EP	*p_dstaddr4;	/* 相手のアドレスへのポインタ	*/
+	T_IPV4EP 	*p_myaddr4;	/* 自分のアドレスへのポインタ	*/
+#endif
+	
 	int16_t		snd_nblk_tfn;	/* 送信動作中の API 機能コード	*/
 	int16_t		rcv_nblk_tfn;	/* 受信動作中の API 機能コード	*/
@@ -247,5 +279,5 @@
 #ifdef TCP_CFG_SWBUF_CSAVE
 	T_NET_BUF	*swbufq;	/* 送信ウィンドバッファキュー	*/
-#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+#endif
 
 	/*
@@ -254,12 +286,32 @@
 
 	T_TCP_TIME	timer[NUM_TCP_TIMERS];	/* TCP のタイマ		*/
-	T_IPV4EP	dstaddr;	/* 相手のアドレス		*/
-	T_IPV4EP	myaddr;		/* 自分のアドレス		*/
-	T_TCP4_REP	*rep;		/* 受付口			*/
+	T_IPEP		dstaddr;	/* 相手のアドレス		*/
+	T_IPEP		myaddr;		/* 自分のアドレス		*/
 	T_NET_BUF	*reassq;	/* 受信再構成キュー		*/
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+	T_TCP4_REP	*rep4;		/* IPv4 用受付口		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	T_TCP6_REP	*rep;		/* IPv6 用受付口		*/
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+	T_TCP4_REP	*rep;		/* IPv4 用受付口		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
 
 #ifdef TCP_CFG_RWBUF_CSAVE
 	T_NET_BUF	*rwbufq;	/* 受信ウィンドバッファキュー	*/
-#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+#endif
 
 #ifdef TCP_CFG_EXTENTIONS
@@ -298,17 +350,21 @@
 
 #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
-	uint8_t		rwbufq_entries;	/* 受信ウィンドバッファキューのエントリ数	*/
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)	*/
-
-	} T_TCP4_CEP;
-
-/*
- * Time Wait 用 IPv4 TCP 通信端点
- */
-typedef struct t_tcp4_twcep {
+	uint16_t	rwbufq_entries;	/* 受信ウィンドバッファキューのエントリ数	*/
+#endif
+
+	} T_TCP_CEP;
+
+#define T_TCP6_CEP	T_TCP_CEP
+#define T_TCP4_CEP	T_TCP_CEP
+
+/*
+ * Time Wait 用 TCP 通信端点
+ */
+
+typedef struct t_tcp_twcep {
 	int_t		rbufsz;		/* 受信用ウィンドバッファサイズ	*/
 	T_TCP_TIME	timer_2msl;	/* 2MSL タイマ			*/
-	T_IPV4EP	dstaddr;	/* 相手のアドレス		*/
-	T_IPV4EP	myaddr;		/* 自分のアドレス		*/
+	T_IPEP		dstaddr;	/* 相手のアドレス		*/
+	T_IPEP		myaddr;		/* 自分のアドレス		*/
 	T_TCP_SEQ	snd_una;	/* 未確認の最小送信 SEQ つまり	*/
 					/* 確認された最大送信 SEQ	*/
@@ -316,159 +372,7 @@
 	uint16_t	rwbuf_count;	/* 受信ウィンドバッファの使用中サイズ	*/
 	uint8_t		fsm_state;	/* FSM 状態			*/
-
-	} T_TCP4_TWCEP;
-
-/*
- * 通常の IPv6 TCP 通信端点
- */
-typedef struct t_tcp6_cep {
-
-	/*
-	 * ITRON TCP/IP API、TCP 通信端点と同じメンバ
-	 */
-	ATR		cepatr;		/* 通信端点属性			*/
-	void		*sbuf;		/* 送信用ウィンドバッファ	*/
-	int_t		sbufsz;		/* 送信用ウィンドバッファサイズ	*/
-	void		*rbuf;		/* 受信用ウィンドバッファ	*/
-	int_t		rbufsz;		/* 受信用ウィンドバッファサイズ	*/
-	t_tcp_callback	callback;	/* コールバック関数		*/
-
-	/*
-	 * TINET 独自のメンバ
-	 */
-	uint32_t	flags;		/* 通信端点フラグ		*/
-	ID		semid_lock;	/* 通信端点ロック		*/
-	ID		est_flgid;	/* コネクション状態イベントフラグ	*/
-	ID		snd_flgid;	/* 送信イベントフラグ		*/
-	ID		rcv_flgid;	/* 受信イベントフラグ		*/
-	ID		snd_tskid;	/* 送信タスク識別子		*/
-	ID		rcv_tskid;	/* 受信タスク識別子		*/
-	uint8_t		*sbuf_rptr;	/* 送信用読み出しポインタ		*/
-	uint8_t		*sbuf_wptr;	/* 送信用書き込みポインタ		*/
-	uint8_t		*rbuf_rptr;	/* 受信用読み出しポインタ		*/
-	uint8_t		*rbuf_wptr;	/* 受信用書き込みポインタ		*/
-	T_TCP_SEQ	snd_ssthresh;	/* 輻輳ウィンドサイズ(snd_cwnd)	*/
-					/* のしきい値			*/
-	T_TCP_TIME	rxtcur;		/* 現在の再送タイムアウト		*/
-	T_TCP_TIME	srtt;		/* 平滑化された RTT		*/
-	T_TCP_TIME	rttvar;		/* 平滑化された分散		*/
-	T_TCP_WND	snd_cwnd;	/* 輻輳ウィンドサイズ		*/
-
-	/*
-	 *  相手の最大受信セグメントサイズ	
-	 *
-	 *    オリジナルでは、一般のセグメントの最大サイズ (t_maxseg) と、
-	 *    オプション付きのセグメントの最大サイズ (t_maxopd) が別に
-	 *    なっている。これは、現在のインターネットでは、オプション付きの
-	 *    セグメントのほうが多いからと説明されているためである。
-	 *    本実装では、最大セグメントサイズオプション以外のオプションは
-	 *    実装しないので、t_maxseg の使用する。
-	 */
-	T_TCP_SEG	maxseg;
-
-	T_IPV6EP 	*p_dstaddr;	/* 相手のアドレスへのポインタ	*/
-	T_IPV6EP 	*p_myaddr;	/* 自分のアドレスへのポインタ	*/
-	int16_t		snd_tfn;	/* 送信動作中の API 機能コード	*/
-	int16_t		rcv_tfn;	/* 受信動作中の API 機能コード	*/
-
-#ifdef TCP_CFG_NON_BLOCKING
-
-	int16_t		snd_nblk_tfn;	/* 送信動作中の API 機能コード	*/
-	int16_t		rcv_nblk_tfn;	/* 受信動作中の API 機能コード	*/
-	void		*snd_data;	/* 送信データ領域の先頭アドレス	*/
-	int_t		snd_len;	/* 送信データ領域の長さ		*/
-	void		*rcv_data;	/* 受信データ領域の先頭アドレス	*/
-	int_t		rcv_len;	/* 受信データ領域の長さ		*/
-	void		**snd_p_buf;	/* 送信バッファへのポインタ	*/
-	void		**rcv_p_buf;	/* 受信バッファへのポインタ	*/
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
-
-#ifdef TCP_CFG_SWBUF_CSAVE
-	T_NET_BUF	*swbufq;	/* 送信ウィンドバッファキュー	*/
-#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
-
-	/*
-	 *  これ以降のメンバーは tcp_init_cep() 関数でゼロクリアーされる。
-	 */
-
-	T_TCP_TIME	timer[NUM_TCP_TIMERS];	/* TCP のタイマ		*/
-	T_IPV6EP	dstaddr;	/* 相手のアドレス		*/
-	T_IPV6EP	myaddr;		/* 自分のアドレス		*/
-	T_TCP6_REP	*rep;		/* 受付口			*/
-	T_NET_BUF	*reassq;	/* 受信再構成キュー		*/
-
-#ifdef TCP_CFG_RWBUF_CSAVE
-	T_NET_BUF	*rwbufq;	/* 受信ウィンドバッファキュー	*/
-#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
-
-#ifdef TCP_CFG_EXTENTIONS
-	T_TCP_HDR	*urg_tcph;	/* 緊急データ入りのセグメントの TCP ヘッダ	*/
-	T_TCP_SEQ	snd_up;		/* 送信した緊急ポインタ		*/
-	T_TCP_SEQ	rcv_up;		/* 受信した緊急ポインタ		*/
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-	T_TCP_SEQ	snd_una;	/* 未確認の最小送信 SEQ つまり	*/
-					/* 確認された最大送信 SEQ	*/
-	T_TCP_SEQ	snd_max;	/* 送信した最大 SEQ		*/
-	T_TCP_SEQ	snd_nxt;	/* 次に送信する SEQ		*/
-	T_TCP_SEQ	snd_old_nxt;	/* 元の snd_nxt			*/
-	T_TCP_SEQ	snd_wl1;	/* 前回ウィンドを更新した SEQ	*/
-	T_TCP_SEQ	snd_wl2;	/* 前回ウィンドを更新した ACK	*/
-	T_TCP_SEQ	iss;		/* 自分の SEQ の初期値		*/
-	T_TCP_SEQ	irs;		/* 相手の SEQ の初期値		*/
-	T_TCP_SEQ	rcv_nxt;	/* 受信を期待している最小の SEQ	*/
-	T_TCP_SEQ	rcv_adv;	/* 受信を期待している最大の SEQ	*/
-	T_TCP_SEQ	rcv_wnd;	/* 受信可能なウィンドサイズ	*/
-	T_TCP_SEQ	rtseq;		/* 時間計測を始めた SEQ		*/
-	T_TCP_SEQ	last_ack_sent;	/* 最後に送信した ACK		*/
-	T_TCP_TIME	idle;		/* アイドル時間			*/
-	ER		error;		/* 非同期に発生したエラー		*/
-	ER		net_error;	/* ネットワークのエラー状態	*/
-	T_TCP_WND	snd_wnd;	/* 相手の受信可能ウィンドサイズ	*/
-	T_TCP_WND	max_sndwnd;	/* 今までの最大送信ウィンドサイズ	*/
-	T_TCP_TIME	rtt;		/* 往復時間			*/
-	uint16_t	swbuf_count;	/* 送信ウィンドバッファの使用中サイズ	*/
-	uint16_t	rwbuf_count;	/* 受信ウィンドバッファの使用中サイズ	*/
-	uint16_t	rcv_buf_len;	/* tcp_rcv_buf の割当て長	*/
-	uint16_t	get_buf_len;	/* tcp_rcv_buf の割当て長	*/
-	uint8_t		rxtshift;	/* 再送信回数の log(2)		*/
-	uint8_t		fsm_state;	/* FSM 状態			*/
-	uint8_t		dupacks;	/* 再送 ACK 数			*/
-
-#if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
-	uint8_t		rwbufq_entries;	/* 受信ウィンドバッファキューのエントリ数	*/
-#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)	*/
-
-	} T_TCP6_CEP;
-
-/*
- * Time Wait 用 IPv6 TCP 通信端点
- */
-typedef struct t_tcp6_twcep {
-	int_t		rbufsz;		/* 受信用ウィンドバッファサイズ	*/
-	T_TCP_TIME	timer_2msl;	/* 2MSL タイマ			*/
-	T_IPV6EP	dstaddr;	/* 相手のアドレス		*/
-	T_IPV6EP	myaddr;		/* 自分のアドレス		*/
-	T_TCP_SEQ	snd_una;	/* 未確認の最小送信 SEQ つまり	*/
-					/* 確認された最大送信 SEQ	*/
-	T_TCP_SEQ	iss;		/* 自分の SEQ の初期値		*/
-	T_TCP_SEQ	irs;		/* 相手の SEQ の初期値		*/
-	T_TCP_SEQ	rcv_nxt;	/* 受信を期待している最小の SEQ	*/
-	T_TCP_WND	snd_wnd;	/* 相手の受信可能ウィンドサイズ	*/
-	uint16_t	rwbuf_count;	/* 受信ウィンドバッファの使用中サイズ	*/
-	uint8_t		fsm_state;	/* FSM 状態			*/
-
-	} T_TCP6_TWCEP;
-
-#if defined(SUPPORT_INET4)
-#define T_TCP_CEP	T_TCP4_CEP
-#define T_TCP_TWCEP	T_TCP4_TWCEP
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-#define T_TCP_CEP	T_TCP6_CEP
-#define T_TCP_TWCEP	T_TCP6_TWCEP
-#endif	/* of #if defined(SUPPORT_INET6) */
+	uint8_t	flags;			/* 通信端点フラグ		*/
+
+	} T_TCP_TWCEP;
 
 #define T_TCP_CEP_DEFINED
@@ -478,31 +382,36 @@
  */
 
-#define TCP_CEP_FLG_ACK_NOW		ULONG_C(0x00000001)	/* 直ちに相手に ACK を送る。	*/
-#define TCP_CEP_FLG_DEL_ACK		ULONG_C(0x00000002)	/* ACK を遅延する。		*/
-#define TCP_CEP_FLG_SENT_FIN		ULONG_C(0x00000004)	/* FIN を送ってある。		*/
-#define TCP_CEP_FLG_NEED_SYN		ULONG_C(0x00000008)	/* SYN を送信する。		*/
-#define TCP_CEP_FLG_NEED_FIN		ULONG_C(0x00000010)	/* FIN を送信する。		*/
-#define TCP_CEP_FLG_FORCE		ULONG_C(0x00000020)	/* 強制送信。			*/
-#define TCP_CEP_FLG_NO_PUSH		ULONG_C(0x00000040)	/* push しない。		*/
-#define TCP_CEP_FLG_NO_DELAY		ULONG_C(0x00000080)	/* 遅延しない。			*/
-#define TCP_CEP_FLG_FORCE_CLEAR		ULONG_C(0x00000100)	/* 強制送信した後フラグをクリアーする。*/
-#define TCP_CEP_FLG_POST_OUTPUT		ULONG_C(0x00000200)	/* 送信を開始する。		*/
-#define TCP_CEP_FLG_RESERVE_OUTPUT	ULONG_C(0x00000400)	/* 送信を予約する。		*/
-#define TCP_CEP_FLG_DYNAMIC		ULONG_C(0x00001000)	/* 動的生成・削除可能通信端点。	*/
-#define TCP_CEP_FLG_VALID		ULONG_C(0x00002000)	/* 生成済みで有効な通信端点。	*/
-#define TCP_CEP_FLG_CLOSE_AFTER_OUTPUT	ULONG_C(0x00004000)	/* 送信した後コネクションを閉じる。*/
-#define TCP_CEP_FLG_RESTORE_NEXT_OUTPUT	ULONG_C(0x00008000)	/* 送信した後、snd_nxt を元に戻す。*/
+#define TCP_CEP_FLG_IPV4		ULONG_C(0x00000001)	/* IPv4 用。			*/
+#define TCP_CEP_FLG_ACK_NOW		ULONG_C(0x00000100)	/* 直ちに相手に ACK を送る。	*/
+#define TCP_CEP_FLG_DEL_ACK		ULONG_C(0x00000200)	/* ACK を遅延する。		*/
+#define TCP_CEP_FLG_SENT_FIN		ULONG_C(0x00000400)	/* FIN を送ってある。		*/
+#define TCP_CEP_FLG_NEED_SYN		ULONG_C(0x00000800)	/* SYN を送信する。		*/
+#define TCP_CEP_FLG_NEED_FIN		ULONG_C(0x00001000)	/* FIN を送信する。		*/
+#define TCP_CEP_FLG_FORCE		ULONG_C(0x00002000)	/* 強制送信。			*/
+#define TCP_CEP_FLG_NO_PUSH		ULONG_C(0x00004000)	/* push しない。		*/
+#define TCP_CEP_FLG_NO_DELAY		ULONG_C(0x00008000)	/* 遅延しない。			*/
+#define TCP_CEP_FLG_FORCE_CLEAR		ULONG_C(0x00010000)	/* 強制送信した後フラグをクリアーする。*/
+#define TCP_CEP_FLG_POST_OUTPUT		ULONG_C(0x00020000)	/* 送信を開始する。		*/
+#define TCP_CEP_FLG_RESERVE_OUTPUT	ULONG_C(0x00040000)	/* 送信を予約する。		*/
+#define TCP_CEP_FLG_DYNAMIC		ULONG_C(0x00100000)	/* 動的生成・削除可能通信端点。	*/
+#define TCP_CEP_FLG_VALID		ULONG_C(0x00200000)	/* 生成済みで有効な通信端点。	*/
+#define TCP_CEP_FLG_CLOSE_AFTER_OUTPUT	ULONG_C(0x00400000)	/* 送信した後コネクションを閉じる。*/
+#define TCP_CEP_FLG_RESTORE_NEXT_OUTPUT	ULONG_C(0x00800000)	/* 送信した後、snd_nxt を元に戻す。*/
 
 /* 送受信ウィンドバッファの省コピー機能 */
-#define TCP_CEP_FLG_WBCS_NBUF_REQ	ULONG_C(0x00080000)	/* ネットワークバッファ割当て要求	*/
-#define TCP_CEP_FLG_WBCS_MASK		ULONG_C(0x00070000)	/* マスク			*/
+#define TCP_CEP_FLG_WBCS_NBUF_REQ	ULONG_C(0x80000000)	/* ネットワークバッファ割当て要求*/
+#define TCP_CEP_FLG_WBCS_MASK		ULONG_C(0x70000000)	/* マスク			*/
 #define TCP_CEP_FLG_WBCS_FREE		ULONG_C(0x00000000)	/* 送信ウィンドバッファ未使用	*/
-#define TCP_CEP_FLG_WBCS_WOPEN_PEND	ULONG_C(0x00010000)	/* 相手の受信ウィンドの開き待ち	*/
-#define TCP_CEP_FLG_WBCS_NBUF_PEND	ULONG_C(0x00020000)	/* ネットワークバッファ予約待ち	*/
-#define TCP_CEP_FLG_WBCS_NBUF_RSVD	ULONG_C(0x00030000)	/* ネットワークバッファ予約済み	*/
-#define TCP_CEP_FLG_WBCS_NBUF_READY	ULONG_C(0x00040000)	/* ネットワークバッファ割当て済み	*/
-#define TCP_CEP_FLG_WBCS_SEND_READY	ULONG_C(0x00050000)	/* 送信可能			*/
-#define TCP_CEP_FLG_WBCS_SENT		ULONG_C(0x00060000)	/* 送信済みで、ACK待ち		*/
-#define TCP_CEP_FLG_WBCS_ACKED		ULONG_C(0x00070000)	/* 送信済みで、ACK完了		*/
+#define TCP_CEP_FLG_WBCS_WOPEN_PEND	ULONG_C(0x10000000)	/* 相手の受信ウィンドの開き待ち	*/
+#define TCP_CEP_FLG_WBCS_NBUF_PEND	ULONG_C(0x20000000)	/* ネットワークバッファ予約待ち	*/
+#define TCP_CEP_FLG_WBCS_NBUF_RSVD	ULONG_C(0x30000000)	/* ネットワークバッファ予約済み	*/
+#define TCP_CEP_FLG_WBCS_NBUF_READY	ULONG_C(0x40000000)	/* ネットワークバッファ割当て済み*/
+#define TCP_CEP_FLG_WBCS_SEND_READY	ULONG_C(0x50000000)	/* 送信可能			*/
+#define TCP_CEP_FLG_WBCS_SENT		ULONG_C(0x60000000)	/* 送信済みで、ACK待ち		*/
+#define TCP_CEP_FLG_WBCS_ACKED		ULONG_C(0x70000000)	/* 送信済みで、ACK完了		*/
+
+/* 初期化から除外するフラグの定義 */
+#define TCP_CEP_FLG_NOT_CLEAR		(TCP_CEP_FLG_WBCS_NBUF_REQ|TCP_CEP_FLG_WBCS_MASK|\
+					 TCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4)
 
 /*
@@ -513,5 +422,5 @@
 #define TCP_CEP_EVT_CLOSED		ULONG_C(0x00000002)	/* 未使用状態			*/
 #define TCP_CEP_EVT_SWBUF_READY		ULONG_C(0x00000004)	/* 送信ウィンドバッファ空き	*/
-#define TCP_CEP_EVT_RWBUF_READY		ULONG_C(0x00000008)	/* 送信ウィンドバッファデータあり	*/
+#define TCP_CEP_EVT_RWBUF_READY		ULONG_C(0x00000008)	/* 送信ウィンドバッファデータあり*/
 #define TCP_CEP_EVT_ALL			ULONG_C(0xffffffff)	/* 全イベント			*/
 
@@ -571,5 +480,4 @@
 
 #define GET_TCP_Q_HDR(nbuf,thoff)	((T_TCP_Q_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
-#define GET_TCP_IP_Q_HDR(nbuf)		((T_TCP_IP_Q_HDR*)GET_IP_HDR(nbuf))
 
 /*
@@ -577,11 +485,19 @@
  */
 
-#define	TMIN_TCP_REPID		1	/* TCP 受付口   ID の最小値			*/
-#define	TMIN_TCP_CEPID		1	/* TCP 通信端点 ID の最小値			*/
-#define	TMIN_TCP_TWCEPID	1	/* Time Wait 用 TCP 通信端点 ID の最小値	*/
+#define	TMIN_TCP_REPID		1			/* TCP      受付口 ID の最小値			*/
+#define	TMIN_TCP6_REPID		1			/* TCP/IPv6 受付口 ID の最小値			*/
+#define	TMIN_TCP4_REPID		(TNUM_TCP6_REPID+1)	/* TCP/IPv4 受付口 ID の最小値			*/
+
+#define	TMIN_TCP_CEPID		1			/* TCP      通信端点 ID の最小値			*/
+#define	TMIN_TCP6_CEPID		1			/* TCP/IPv6 通信端点 ID の最小値			*/
+#define	TMIN_TCP4_CEPID		(TNUM_TCP6_CEPID+1)	/* TCP/IPv4 通信端点 ID の最小値			*/
+
+#define	TMIN_TCP_TWCEPID	1			/* Time Wait 用 TCP 通信端点 ID の最小値	*/
 
 /*
  *  制御セグメント（データなし）サイズのネットワークバッファ
  */
+
+#if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE)
 
 typedef struct t_net_buf_cseg {
@@ -599,5 +515,5 @@
 	} T_NET_BUF_CSEG;
 
-#ifdef SUPPORT_MIB
+#endif	/* of #if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE) */
 
 /*
@@ -618,22 +534,48 @@
 } T_TCP_STATS;
 
-#endif	/* of #ifdef SUPPORT_MIB */
-
 /*
  *  関数シミュレーションマクロ
  */
 
-#define VAID_TCP_REPID(id)	(TMIN_TCP_REPID<=(id)&&(id)<=tmax_tcp_repid)
-#define VAID_TCP_CEPID(id)	(TMIN_TCP_CEPID<=(id)&&(id)<=tmax_tcp_cepid)
-
-#define INDEX_TCP_REP(id)	((id)-TMIN_TCP_REPID)
+/* TCP 受付口 */
+
+#define VALID_TCP6_REPID(id)	(TMIN_TCP6_REPID<=(id)&&(id)<=tmax_tcp6_repid)
+#define VALID_TCP4_REPID(id)	(TMIN_TCP4_REPID<=(id)&&(id)<=tmax_tcp4_repid)
+
+#define INDEX_TCP6_REP(id)	((id)-TMIN_TCP6_REPID)
+#define INDEX_TCP4_REP(id)	((id)-TMIN_TCP4_REPID)
+
+#define GET_TCP6_REP(id)	(&(tcp6_rep[INDEX_TCP6_REP(id)]))
+#define GET_TCP4_REP(id)	(&(tcp4_rep[INDEX_TCP4_REP(id)]))
+
+#define GET_TCP6_REPID(rep)	((ID)(((rep)-tcp6_rep)+TMIN_TCP6_REPID))
+#define GET_TCP4_REPID(rep)	((ID)(((rep)-tcp4_rep)+TMIN_TCP4_REPID))
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#define VALID_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_VALID)!=0)
+#define DYNAMIC_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_DYNAMIC)!=0)
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#define VALID_TCP_REP(rep)	(true)
+#define DYNAMIC_TCP_REP(rep)	(false)
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+/* TCP 通信端点 */
+
+#define VALID_TCP_CEPID(id)	(TMIN_TCP_CEPID<=(id)&&(id)<=tmax_tcp_cepid)
 #define INDEX_TCP_CEP(id)	((id)-TMIN_TCP_CEPID)
 
-#define GET_TCP_REP(id)		(&(tcp_rep[INDEX_TCP_REP(id)]))
 #define GET_TCP_CEP(id)		(&(tcp_cep[INDEX_TCP_CEP(id)]))
 
-#define GET_TCP_REPID(rep)	((ID)(((rep)-tcp_rep)+TMIN_TCP_REPID))
 #define GET_TCP_CEPID(cep)	((ID)(((cep)-tcp_cep)+TMIN_TCP_CEPID))
 #define GET_TCP_TWCEPID(cep)	((ID)(((cep)-tcp_twcep)+TMIN_TCP_TWCEPID))
+
+#define VALID_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_VALID)!=0)
+#define DYNAMIC_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_DYNAMIC)!=0)
+#define TCP_IS_CEP_IPV6(cep)	(((cep)->flags&TCP_CEP_FLG_IPV4)==0)
+#define TCP_IS_CEP_IPV4(cep)	(((cep)->flags&TCP_CEP_FLG_IPV4)!=0)
 
 #define IS_TFN_TCP_RCV(t)	((t)==TFN_TCP_ACP_CEP||(t)==TFN_TCP_RCV_DAT||\
@@ -651,35 +593,47 @@
 #define VALID_URG_POINTER(urg)	(TCP_CFG_URG_OFFSET==0||urg!=0)
 
-#define VALID_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_VALID)!=0)
-#define DYNAMIC_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_DYNAMIC)!=0)
-
-#ifdef TCP_CFG_EXTENTIONS
-
-#define VALID_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_VALID)!=0)
-#define DYNAMIC_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_DYNAMIC)!=0)
-
-#else	/* of #ifdef TCP_CFG_EXTENTIONS */
-
-#define VALID_TCP_REP(rep)	(true)
-#define DYNAMIC_TCP_REP(rep)	(false)
-
-#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
-
 /*
  *  全域変数
  */
 
-extern T_TCP_REP tcp_rep[];
+extern uint8_t tcp_initialized;
+
+extern T_TCP_STATS tcp_stats;
+
+/* TCP 受付口 */
+
+extern T_TCP6_REP tcp6_rep[];
+extern T_TCP4_REP tcp4_rep[];
+
+#if defined(SUPPORT_INET6)
+#define tcp_rep	tcp6_rep
+#elif defined(SUPPORT_INET4)
+#define tcp_rep	tcp4_rep
+#endif
+
+extern const ID tmax_tcp_repid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_tcp6_repid;
+extern const ID tmax_tcp4_repid;
+#else
+#define tmax_tcp6_repid	tmax_tcp_repid
+#define tmax_tcp4_repid	tmax_tcp_repid
+#endif
+
+/* TCP 通信端点 */
+
 extern T_TCP_CEP tcp_cep[];
-extern uint8_t tcp_initialized;
-extern const ID tmax_tcp_repid;
+extern T_TCP_TWCEP tcp_twcep[];
+
 extern const ID tmax_tcp_cepid;
-extern T_TCP_TWCEP tcp_twcep[];
-
-#ifdef SUPPORT_MIB
-
-extern T_TCP_STATS tcp_stats;
-
-#endif	/* of #ifdef SUPPORT_MIB */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_tcp6_cepid;
+extern const ID tmax_tcp4_cepid;
+#else
+#define tmax_tcp6_cepid	tmax_tcp_cepid
+#define tmax_tcp4_cepid	tmax_tcp_cepid
+#endif
 
 /*
@@ -866,7 +820,8 @@
 extern void tcp_respond (T_NET_BUF *nbuf, T_TCP_CEP *cep,
                          T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags);
-extern void tcp_set_header (T_NET_BUF *nbuf, T_TCP_CEP *cep, uint_t thoff, uint_t optlen);
 extern ER tcp_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
                            uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
+extern ER tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                            uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
 extern void tcp_init_cep (T_TCP_CEP *cep);
 extern void tcp_notify (T_NET_BUF *input, int code);
@@ -876,5 +831,4 @@
 extern void tcp_alloc_auto_port (T_TCP_CEP *cep);
 extern ER tcp_alloc_port (T_TCP_CEP *cep, uint16_t portno);
-extern void tcp_move_twcep (T_TCP_CEP *cep);
 extern ER tcp_lock_cep (ID cepid, T_TCP_CEP **p_cep, FN tfn);
 extern void tcp_free_reassq (T_TCP_CEP *cep);
@@ -885,4 +839,8 @@
 extern ER tcp_wait_rwbuf (T_TCP_CEP *cep, TMO tmout);
 extern T_TCP_CEP *tcp_user_closed (T_TCP_CEP *cep);
+extern T_TCP_CEP *tcp_find_cep (T_NET_BUF *input, uint_t off);
+extern T_TCP_TWCEP*tcp_find_twcep (T_NET_BUF *input, uint_t off);
+extern bool_t tcp_is_addr_accept (T_NET_BUF *input, uint_t off);
+extern void tcp_move_twcep (T_TCP_CEP *cep);
 
 /*
@@ -974,14 +932,4 @@
 
 /*
- *  tcp_find_cep -- ポート番号から TCP 通信端点を得る。
- *
- *    注意: myaddr は、
- *          TINET-1.2 からネットワークバイトオーダ、
- *          TINET-1.1 までは、ホストバイトオーダ
- */
-extern T_TCP_CEP *tcp_find_cep (T_IN_ADDR *dstaddr,  uint16_t dstport,
-                                T_IN_ADDR *peeraddr, uint16_t peerport);
-
-/*
  *  TCP ヘッダのトレース出力機能用関数
  */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c	(revision 331)
@@ -0,0 +1,777 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	From: @(#)tcp_usrreq.c	8.2 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.40.2.3 1999/08/29 16:29:57 peter Exp $
+ */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0)
+
+/*
+ *  tcp_cre_rep -- TCP åä»å£ã®çæãæ¡å¼µæ©è½ã
+ */
+
+#ifdef __tcp_cre_rep
+
+ER
+TCP_CRE_REP (ID repid, T_TCPN_CREP *pk_crep)
+{
+	T_TCP_REP	*rep;
+	ER		error;
+
+	/* TCP åä»å£ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_REPID(repid))
+		return E_ID;
+
+	/* pk_crep ã NULL ãªãã¨ã©ã¼ */
+	if (pk_crep == NULL)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&pk_crep->myaddr.ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* TCP åä»å£ãå¾ãã*/
+	rep = GET_TCP_REP(repid);
+
+	/* TCP åä»å£ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_REP(rep))
+		return E_ID;
+
+	/* åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/*
+	 * TCP åä»å£ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
+	 */
+	if (VALID_TCP_REP(rep))
+		error = E_OBJ;
+	else {
+
+		/* TCP åä»å£çææ
+å ±ãã³ãã¼ããã*/
+		rep->repatr = pk_crep->repatr;			/* åä»å£å±æ§		*/
+		rep->myaddr.ipaddr = pk_crep->myaddr.ipaddr;	/* èªåã®ã¢ãã¬ã¹	*/
+		rep->myaddr.portno = pk_crep->myaddr.portno;	/* èªåã®ã¢ãã¬ã¹	*/
+
+		/* TCP åä»å£ãçææ¸ã¿ã«ããã*/
+		rep->flags |= TCP_REP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_cre_rep */
+
+#ifdef __tcp_del_rep
+
+/*
+ *  tcp_find_cep_rep -- TCP åä»å£ããªã³ã¯ãã¦ãã TCP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+static T_TCP_CEP*
+TCP_FIND_CEP_REP (T_TCP_REP* rep)
+{
+	T_TCP_CEP*	cep;
+
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+		if (cep->rep4 == rep)
+#else
+		if (cep->rep == rep)
+#endif
+			return cep;
+		}
+
+	return NULL;
+	}
+
+/*
+ *  tcp_del_rep_body -- TCP åä»å£ã®åé¤ãæ¡å¼µæ©è½ãã®æ¬ä½
+ */
+
+static ER
+TCP_DEL_REP_BODY (ID repid)
+{
+	T_TCP_CEP	*cep;
+	T_TCP_REP	*rep;
+	ER		error = E_OK;
+
+	/* TCP åä»å£ ID ã®ãã§ãã¯ã¯çµäºãã¦ããã*/
+
+	/* TCP åä»å£ãå¾ãã*/
+	rep = GET_TCP_REP(repid);
+
+	/* TCP åä»å£ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_REP(rep))
+		return E_ID;
+
+	/* åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/* TCP åä»å£ããã§ãã¯ãããæªçæã®å ´åã¯ã¨ã©ã¼ */
+	if (!VALID_TCP_REP(rep))
+		error = E_NOEXS;
+	else {
+		if ((cep = TCP_FIND_CEP_REP(rep)) != NULL) {
+			/*
+			 * ãã§ã«ååãªã¼ãã³ãã¦ããã¨ã
+			 *ï¼tcp_acp_cep ãå¼ã°ãã¦ããã¨ãï¼ã¯ã
+			 * tcp_acp_cep ãçµäºãããã
+			 */
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+			syscall(wai_sem(cep->semid_lock));
+
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			cep->error = E_DLT;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
+				if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_DLT);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					ER	error = E_DLT;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					}
+				else
+					error = E_OBJ;
+				cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			cep->rcv_tskid = TA_NULL;
+			cep->rcv_tfn   = TFN_TCP_UNDEF;
+
+			/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			}
+		else
+			error = E_OK;
+
+		/* TCP åä»å£ãæªçæã«ããã*/
+		rep->flags &= ~TCP_REP_FLG_VALID;
+		}
+
+	/* åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_del_rep */
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0) */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0)
+
+/*
+ *  tcp_acp_cep -- æ¥ç¶è¦æ±å¾
+ã¡ (ååãªã¼ãã³)ãæ¨æºæ©è½ã
+ */
+
+#ifdef __tcp_acp_cep
+
+ER
+TCP_ACP_CEP (ID cepid, ID repid, T_IPEP *p_dstaddr, TMO tmout)
+{
+	T_TCP_REP	*rep;
+	T_TCP_CEP	*cep;
+	ER		error;
+	FLGPTN		flag;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	/*
+	 * API (tcp6_acp_cep ã¨ tcp_acp_cep) ã¨ã
+	 * TCPéä¿¡ç«¯ç¹ã®ãã­ãã³ã«ãçç¾ãã¦ããã°ã¨ã©ã¼
+	 */
+
+#if API_PROTO == API_PROTO_IPV6
+
+	if (GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	if ((GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4) == 0)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	/* TCP åä»å£ããã§ãã¯ããã*/
+	if (!VALID_TCP_REPID(repid))
+		return E_ID;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* p_dstaddr ã NULL ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* p_dstaddr ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_ACP_CEP)) != E_OK)
+		return error;
+
+	/* CEP ã® FSM ãã¯ã­ã¼ãºç¶æ
+ã§ãªããã°ã¨ã©ã¼ã*/
+	if (cep->fsm_state != TCP_FSM_CLOSED) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
+
+	/* TCP éä¿¡ç«¯ç¹ãåæåããã*/
+	tcp_init_cep(cep);
+
+	/* TCP åä»å£ãå¾ãã*/
+
+	rep = GET_TCP_REP(repid);
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	/* TCP åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/* TCP åä»å£ããã§ãã¯ããã*/
+	if (!VALID_TCP_REP(rep)) {
+		syscall(sig_sem(rep->semid_lock));
+		error = E_NOEXS;
+		goto err_ret;
+		}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	/* TCP éä¿¡ç«¯ç¹ã«TCPåä»å£ãè¨é²ããã*/
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV6
+
+	cep->rep = rep;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+	cep->rep4 = rep;
+
+#endif	/*of #if API_PROTO == API_PROTO_IPV6 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	cep->rep = rep;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	/* TCP åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	/* TCP åä»å£ã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (rep->myaddr.ipaddr == IPV4_ADDRANY)
+		memcpy(&cep->myaddr.ipaddr, &in6_addr_unspecified,
+		                      sizeof(in6_addr_unspecified));
+	else
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, rep->myaddr.ipaddr);
+	cep->myaddr.portno = rep->myaddr.portno;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	cep->myaddr = rep->myaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	/* TCP éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ãè¨­å®ããã*/
+	cep->flags |= TCP_CEP_FLG_IPV4;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+	/* éä¿¡ç«¯ç¹ãè¨­å®ããã*/
+	cep->fsm_state = TCP_FSM_LISTEN;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV4
+
+		cep->p_dstaddr4   = p_dstaddr;
+		cep->p_dstaddr    = NULL;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+		cep->p_dstaddr4   = NULL;
+		cep->p_dstaddr    = p_dstaddr;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->p_dstaddr    = p_dstaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->rcv_nblk_tfn = TFN_TCP_ACP_CEP;
+		return E_WBLK;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/*
+		 *  FSM ã ESTABLISHED ã«ãªãã¾ã§å¾
+ã¤ã
+		 *  FSM ã CLOSED ã«ãªã£ãå ´åã¯ãã¨ã©ã¼ãçºçãããã¨ãæå³ãã¦ããã
+		 */
+		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
+		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
+		if (error == E_OK) {
+			if (cep->error != E_OK)
+				error = cep->error;
+			else if (cep->fsm_state == TCP_FSM_CLOSED)
+				error = E_TMOUT;
+			}
+
+		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
+
+		if (error == E_OK) {
+			/* ç¸æã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+			p_dstaddr->ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+			p_dstaddr->portno = cep->dstaddr.portno;
+#else
+			*p_dstaddr = cep->dstaddr;
+#endif
+			}
+		else {
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_acp_cep */
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0) */
+
+/*
+ *  tcp_con_cep -- æ¥ç¶è¦æ± (è½åãªã¼ãã³)ãæ¨æºæ©è½ã
+ */
+
+#ifdef __tcp_con_cep
+
+ER
+TCP_CON_CEP (ID cepid, T_IPEP *p_myaddr, T_IPEP *p_dstaddr, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+	FLGPTN		flag;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	/*
+	 * API (tcp6_acp_cep ã¨ tcp_acp_cep) ã¨ã
+	 * TCPéä¿¡ç«¯ç¹ã®ãã­ãã³ã«ãçç¾ãã¦ããã°ã¨ã©ã¼
+	 */
+
+#if API_PROTO == API_PROTO_IPV6
+
+	if (GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	if ((GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4) == 0)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	/*
+	 *  ãã¦å
+ããã«ãã­ã£ã¹ãã¢ãã¬ã¹ãªãã¨ã©ã¼
+	 */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (IN4_IS_ADDR_MULTICAST(p_dstaddr->ipaddr))
+		return E_PAR;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	if (IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/*
+	 *  p_dstaddr ã¾ãã¯ p_myaddr ã NULL ãªãã¨ã©ã¼
+	 */
+	if (p_myaddr == NULL || p_dstaddr == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  p_dstaddr ã¾ãã¯ p_myaddr ã NULL ã
+	 *  tmout ã TMO_NBLK ãªãã¨ã©ã¼
+	 */
+	if (p_myaddr == NULL || p_dstaddr == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CON_CEP)) != E_OK)
+		return error;
+
+	/* CEP ã® FSM ãã¯ã­ã¼ãºç¶æ
+ã§ãªããã°ã¨ã©ã¼ã*/
+	if (cep->fsm_state != TCP_FSM_CLOSED) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
+
+	/* ã·ã¼ã±ã³ã¹çªå·ãåæåããã*/
+	if (tcp_iss == 0)
+		tcp_init_iss();
+
+	/* éä¿¡ç«¯ç¹ãåæåããã*/
+	tcp_init_cep(cep);
+
+	/*
+	 *  IP ã¢ãã¬ã¹ãè¨­å®ããã
+	 *  p_myaddr ã NADR (-1) ã§ã¯ãªããèª IP ã¢ãã¬ã¹ã ANY ã§ãªããã°ã
+	 *  æå®ããã IP ã¢ãã¬ã¹ãå²ãå½ã¦ãã
+	 */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (p_myaddr != NADR && !IN4_IS_ADDR_ANY(&p_myaddr->ipaddr))
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, p_myaddr->ipaddr);
+	else
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+
+	in6_make_ipv4mapped(&cep->dstaddr.ipaddr, p_dstaddr->ipaddr);
+	cep->dstaddr.portno = p_dstaddr->portno;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	if (p_myaddr != NADR && !IN_IS_ADDR_ANY(&p_myaddr->ipaddr))
+		cep->myaddr.ipaddr = p_myaddr->ipaddr;
+	else {
+		if (IN_ADDRWITHIFP(IF_GET_IFNET(), &cep->myaddr.ipaddr, &p_dstaddr->ipaddr) == NULL) {
+			error = E_PAR;
+			goto err_ret;
+			}
+		}
+
+	cep->dstaddr   = *p_dstaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	/* TCP éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ãè¨­å®ããã*/
+	cep->flags |= TCP_CEP_FLG_IPV4;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+	/* éä¿¡ç«¯ç¹ãè¨­å®ããã*/
+	//NET_DEBUG_TCP5("tcp_con_cep3[c=%d,d=%lI.%d,s=%lI.%d]\n",
+	cep->fsm_state = TCP_FSM_SYN_SENT;
+	cep->iss       = tcp_iss;
+	cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INIT;
+	tcp_iss += TCP_ISS_INCR() / 2;
+	init_send_seq(cep);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV4
+
+		cep->p_dstaddr4   = p_dstaddr;
+		cep->p_myaddr4    = p_myaddr;
+		cep->p_dstaddr    = NULL;
+		cep->p_myaddr     = NULL;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+		cep->p_dstaddr4   = NULL;
+		cep->p_myaddr4    = NULL;
+		cep->p_dstaddr    = p_dstaddr;
+		cep->p_myaddr     = p_myaddr;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->p_dstaddr    = p_dstaddr;
+		cep->p_myaddr     = p_myaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->snd_nblk_tfn = TFN_TCP_CON_CEP;
+
+		/* ã³ãã¯ã·ã§ã³ã®éè¨­ããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		return E_WBLK;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/*
+		 *  p_myaddr ã NADR (-1) ãã
+		 *  èªãã¼ãçªå·ã TCP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+		 */
+		if (p_myaddr == NADR || p_myaddr->portno == TCP_PORTANY)
+			tcp_alloc_auto_port(cep);
+		else if ((error = tcp_alloc_port(cep, p_myaddr->portno)) != E_OK)
+			goto err_ret;
+
+		/* ã³ãã¯ã·ã§ã³ã®éè¨­ããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+
+		/*
+		 *  ã¤ãã³ãã ESTABLISHED ã«ãªãã¾ã§å¾
+ã¤ã
+		 *  ã¤ãã³ãã CLOSED ã«ãªã£ãå ´åã¯ãä½ããã®ã¨ã©ã¼ãçºçãããã
+		 *  æ¥ç¶è¦æ±ãæå¦ããããã¨ãæå³ãã¦ããã
+		 */
+		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
+		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
+		if (error == E_OK) {
+			if (cep->error != E_OK)
+				error = cep->error;
+			else if (cep->fsm_state == TCP_FSM_CLOSED)
+				error = E_CLS;
+			}
+
+		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
+
+		if (error != E_OK) {
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_con_cep */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.cfg	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_input.c	(revision 331)
@@ -0,0 +1,106 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp_reply_no_port -- éä¿¡å
+ã«ãã¼ããå®ç¾©ããã¦ããªããã¨ãéç¥ããã
+ */
+
+void
+UDP_REPLY_NO_PORT (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+
+	/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+	if (ntohl(GET_IP4_HDR(input)->dst) == IF_GET_IFNET()->in4_ifaddr.addr) {
+		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+		icmp_error(ICMP4_UNREACH_PORT, input);
+		/* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
+	
+		}
+	syscall(rel_net_buf(input));
+
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp4_subr.c	(revision 331)
@@ -0,0 +1,203 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef SUPPORT_IGMP
+#define UDP4_IS_ADDR_MULTICAST igmp_is_joined_group
+#else
+#define UDP4_IS_ADDR_MULTICAST IN4_IS_ADDR_MULTICAST
+#endif
+
+#ifdef DHCP_CFG
+#ifdef ETHER_CFG_MULTICAST
+/*
+ *  udp4_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IN4_ADDR	dst;
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+	dst = ntohl(ip4h->dst);
+
+	if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+		dst == IPV4_ADDR_BROADCAST ||
+		dst == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask) ||
+		UDP4_IS_ADDR_MULTICAST(dst))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+#else
+/*
+ *  udp4_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+
+	if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+	    ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+	    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+#endif	/* of #ifdef ETHER_CFG_MULTICAST */
+#else
+#ifdef ETHER_CFG_MULTICAST
+
+/*
+ *  udp_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IN4_ADDR	dst;
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+	dst = ntohl(ip4h->dst);
+
+	if (dst == IPV4_ADDR_BROADCAST ||
+	    dst == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask) ||
+		UDP4_IS_ADDR_MULTICAST(dst))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+
+#else	/* of #ifdef ETHER_CFG_MULTICAST */
+
+/*
+ *  udp4_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+
+	if (ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+	    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+
+#endif	/* of #ifdef ETHER_CFG_MULTICAST */
+#endif	/* of #ifdef DHCP_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_input.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
  *
@@ -72,4 +72,5 @@
 #include <sil.h>
 #include <t_syslog.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -79,5 +80,5 @@
 #include <s_services.h>
 #include <t_services.h>
-#include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -92,4 +93,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -97,14 +99,8 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
 #include <netinet/in_itron.h>
 #include <netinet/ip.h>
 #include <netinet/ip_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
 #include <netinet/ip_icmp.h>
-#include <netinet/icmp6.h>
-
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
@@ -124,256 +120,56 @@
 #endif	/* of #ifdef SUPPORT_MIB */
 
-#if defined(SUPPORT_INET4)
-
-#ifdef DHCP_CFG
-
 /*
- *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
- *
- *    DHCP_CFG が定義されているときは、以下のデータグラムを受信する。
- *
- *      ・あて先アドレスがブロードキャスト
- *      ・ローカルアドレスが未定義
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
  */
 
-static bool_t
-udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
-{
-	T_IFNET	*ifp = IF_GET_IFNET();
+#undef	IN_COPY_TO_HOST
 
-	if (ifp->in_ifaddr.addr == IPV4_ADDRANY ||
-	    ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
-	    ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
-		return true;
-	else
-		return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
-	}
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
 
-#elif defined(ETHER_CFG_MULTICAST)
+#define UDP_INPUT		udp6_input
+#define UDP_INPUT_SELECT	udp6_input_select
+#define UDP_REPLY_NO_PORT	udp6_reply_no_port
+#define UDP_FIND_CEP		udp6_find_cep
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define API_PROTO		API_PROTO_IPV6
 
-/*
- *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
- *
- *    以下の場合もデータグラムを受信する。
- *
- *      ・あて先アドレスがブロードキャスト
- */
+#if defined(_IP4_CFG)
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
 
-static bool_t
-udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
-{
-	T_IFNET	*ifp = IF_GET_IFNET();
-	T_IN4_ADDR	dst = ntohl(*dstaddr);
+#include <netinet6/udp6_input.c>
+#include <netinet/udpn_input.c>
 
-	if (dst == IPV4_ADDR_BROADCAST ||
-	    dst == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask) ||
-		IN4_IS_ADDR_MULTICAST(dst))
-		return true;
-	else
-		return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
-	}
+#undef	UDP_INPUT
+#undef	UDP_INPUT_SELECT
+#undef	UDP_REPLY_NO_PORT
+#undef	UDP_FIND_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef	IN_COPY_TO_HOST
+#undef  API_PROTO
 
-#else	/* of #ifdef DHCP_CFG */
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
 
-/*
- *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
- *
- *    以下の場合もデータグラムを受信する。
- *
- *      ・あて先アドレスがブロードキャスト
- */
+#if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \
+                          ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
 
-static bool_t
-udp_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
-{
-	T_IFNET	*ifp = IF_GET_IFNET();
+#define UDP_INPUT		udp4_input
+#define UDP_INPUT_SELECT	udp4_input_select
+#define UDP_REPLY_NO_PORT	udp4_reply_no_port
+#define UDP_FIND_CEP		udp4_find_cep
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
+#define API_PROTO		API_PROTO_IPV4
 
-	if (ntohl(*dstaddr) == IPV4_ADDR_BROADCAST ||
-	    ntohl(*dstaddr) == ((ifp->in_ifaddr.addr & ifp->in_ifaddr.mask) | ~ifp->in_ifaddr.mask))
-		return true;
-	else
-		return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
-	}
+#include <netinet/udp4_input.c>
+#include <netinet/udpn_input.c>
 
-#endif	/* of #ifdef DHCP_CFG */
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-/*
- *  udp_dstaddr_accept -- UDP のあて先アドレスが正しいかチェックする。
- *
- *    以下の場合もデータグラムを受信する。
- *
- *      ・あて先アドレスがマルチキャスト
- */
-
-static bool_t
-udp_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
-{
-	if (IN6_IS_ADDR_MULTICAST(dstaddr))
-		return true;
-	else
-		return IN_IS_DSTADDR_ACCEPT(myaddr, dstaddr);
-	}
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-/*
- *  udp_input -- UDP の入力関数
- */
-
-uint_t
-udp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
-{
-	T_NET_BUF	*input = *inputp;
-	T_UDP_CEP	*cep;
-	T_UDP_HDR	*udph;
-	T_IP_HDR	*iph;
-	int_t		ix;
-	uint_t		len, hlen, ulen;
-
-	hlen = (uint_t)GET_IF_IP_HDR_SIZE(input);
-
-	NET_COUNT_UDP(net_count_udp.in_octets,  input->len - hlen);
-	NET_COUNT_UDP(net_count_udp.in_packets, 1);
-	NET_COUNT_MIB(udp_stats.udpInDatagrams, 1);
-
-	/* ヘッダ長をチェックする。*/
-	if (input->len < hlen + UDP_HDR_SIZE)
-		goto buf_rel;
-
-	udph = (T_UDP_HDR *)(input->buf + *offp);
-
-	/* データグラム長をチェックする */
-	ulen  = ntohs(udph->ulen);
-	if (ulen != input->len - hlen)
-		goto buf_rel;
-
-	/* 宛先ポートが 0 のデータグラムは破棄する。RFC768 */
-	if (udph->dport == 0)
-		goto buf_rel;
-
-#ifdef UDP_CFG_IN_CHECKSUM
-
-	/* チェックサムをチェックする */
-	if (udph->sum && IN_CKSUM(input, IPPROTO_UDP, *offp, ulen) != 0)
-		goto buf_rel;
-
-#endif	/* of #ifdef UDP_CFG_IN_CHECKSUM */
-
-	iph = GET_IP_HDR(input);
-
-	/* 宛先アドレスとポートをチェックする */
-	for (ix = tmax_udp_ccepid; ix -- > 0; ) {
-		cep = &udp_cep[ix];
-		if (VALID_UDP_CEP(cep) &&
-		    udp_is_dstaddr_accept(&cep->myaddr.ipaddr, &iph->dst) &&
-		    ntohs(udph->dport) == cep->myaddr.portno) {
-			len = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
-
-			if (cep->rcv_tskid != TA_NULL) {	/* 非ノンブロッキングコールでペンディング中 */
-				if (psnd_dtq(cep->rcvqid, (intptr_t)input) != E_OK)
-					goto buf_rel;
-				}
-
-#ifdef UDP_CFG_NON_BLOCKING
-
-			else if (cep->rcv_p_dstaddr != NULL) {	/* ノンブロッキングコールでペンディング中 */
-
-				/* p_dstaddr を設定する。*/
-				cep->rcv_p_dstaddr->portno = ntohs(udph->sport);
-				IN_COPY_TO_HOST(&cep->rcv_p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
-
-				/* データをバッファに移す。*/
-				memcpy(cep->rcv_data, GET_UDP_SDU(input, *offp),
-				       (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
-				syscall(rel_net_buf(input));
-
-				if (IS_PTR_DEFINED(cep->callback))
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-					(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-					(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				else
-					syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
-				cep->rcv_p_dstaddr = NULL;
-				}
-
-#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
-
-			else if (IS_PTR_DEFINED(cep->callback)) {
-
-				/* コールバック関数を呼び出す。*/
-				cep->cb_netbuf = input;
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-				(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-				/*
-				 *  ネットワークバッファがそのままであれば、コールバック関数内で
-				 *  データを読み出さなかったことになるので、捨てる。
-				 */
-				if (cep->cb_netbuf != NULL)
-					syscall(rel_net_buf(cep->cb_netbuf));
-				}
-			else
-				goto buf_rel;
-
-			return IPPROTO_DONE;
-			}
-		}
-
-	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
-
-#if defined(SUPPORT_INET4)
-
-	/* ローカル IP アドレスに届いたデータグラムのみ ICMP エラーを通知する。*/
-	if (ntohl(iph->dst) == IF_GET_IFNET()->in_ifaddr.addr) {
-		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
-
-		icmp_error(ICMP4_UNREACH_PORT, input);
-		/* icmp_error では、ネットワークバッファ input を返却しないので下へ抜ける。*/
-		}
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-	/* マルチキャストアドレスに届いたデータグラムは ICMP エラーを通知しない。*/
-	if (!IN6_IS_ADDR_MULTICAST(&iph->dst)) {
-		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
-
-		/* icmp6_error で、ネットワークバッファ input を返却する。*/
-		icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
-
-		NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
-		NET_COUNT_MIB(udp_stats.udpInErrors, 1);
-		return IPPROTO_DONE;
-		}
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
-buf_rel:
-	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
-	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
-	syscall(rel_net_buf(input));
-	return IPPROTO_DONE;
-	}
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
 
 #endif	/* of #ifdef SUPPORT_UDP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.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
  *
@@ -73,4 +73,5 @@
 #include <t_syslog.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -81,4 +82,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -92,9 +94,9 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
 #include <netinet/in_itron.h>
@@ -102,9 +104,4 @@
 #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
-#include <netinet/icmp6.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
@@ -115,109 +112,44 @@
 
 /*
- *  関数
- */
-
-static void udp_output (T_UDP_CEP *cep);
-
-/*
- *  UDP 出力タスク
- *  ノンブロッキングコールを組み込んだとき使用する。
- */
-
-static void
-udp_output (T_UDP_CEP *cep)
-{
-	T_NET_BUF	*output;
-	T_UDP_HDR	*udph;
-	ER_UINT		error;
-
-#ifdef UDP_CFG_OUT_CHECKSUM
-	uint16_t	sum;
-#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
-
-	/* IP データグラムを割り当てる。*/
-	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + cep->snd_len), 0,
-	                             &cep->snd_p_dstaddr->ipaddr,
-	                             &cep->myaddr.ipaddr,
-	                             IPPROTO_UDP, IP_DEFTTL, 
-	                             NBA_SEARCH_ASCENT, TMO_UDP_OUTPUT)) != E_OK) {
-		goto err_ret;
-		}
-
-	/* UDP ヘッダに情報を設定する。*/
-	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET);
-	udph->sport	= htons(cep->myaddr.portno);
-	udph->dport	= htons(cep->snd_p_dstaddr->portno);
-	udph->ulen	= htons(UDP_HDR_SIZE + cep->snd_len);
-	udph->sum	= 0;
-
-	/* データをコピーする。*/
-	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET),
-	       cep->snd_data, (size_t)cep->snd_len);
-
-#ifdef UDP_CFG_OUT_CHECKSUM
-
-	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET,
-	               (uint_t)(UDP_HDR_SIZE + cep->snd_len));
-
-	/* 計算したチェックサムの値が 0 なら 0xffff を入れる。*/
-	if (sum == 0)
-		sum = UINT_C(0xffff);
-	udph->sum = sum;
-
-#endif/* of #ifdef UDP_CFG_OUT_CHECKSUM */
-
-	/* ネットワークバッファ長を調整する。*/
-	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE + cep->snd_len);
-
-	/* ネットワーク層 (IP) の出力関数を呼び出す。*/
-	if ((error = IP_OUTPUT(output, TMO_UDP_OUTPUT)) != E_OK)
-		goto err_ret;
-
-
-	NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
-
-	if (IS_PTR_DEFINED(cep->callback)) {
-
-		if (error == E_OK)
-			error = cep->snd_len;
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-		}
-	else
-		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
-	cep->snd_p_dstaddr = NULL;
-	return;
-
-err_ret:
-	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
-	if (IS_PTR_DEFINED(cep->callback)) {
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)E_NOMEM);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-		error = E_NOMEM;
-		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-		}
-	else
-		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
-	cep->snd_p_dstaddr = NULL;
-	return;
-	}
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
+ */
+
+#undef	IN_GET_DATAGRAM
+
+#if defined(_IP6_CFG) 
+
+#define UDP_OUTPUT		udp6_output
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(_IP4_CFG)
+#define	IN_GET_DATAGRAM		inn_get_datagram
+#else
+#define	IN_GET_DATAGRAM		in6_get_datagram
+#endif
+
+#include <netinet/udpn_output.c>
+
+#undef	UDP_OUTPUT
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef  API_PROTO
+#undef	IN_GET_DATAGRAM
+
+#endif	/* of #if defined(_IP6_CFG)  */
+
+#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
+
+#define UDP_OUTPUT		udp4_output
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define API_PROTO		API_PROTO_IPV4
+
+#define	IN_GET_DATAGRAM		in4_get_datagram
+
+#include <netinet/udpn_output.c>
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
 
 /*
@@ -236,10 +168,10 @@
 
 
-#if defined(SUPPORT_INET6) && !defined(SUPPORT_TCP)
+#if defined(_IP6_CFG) && !defined(SUPPORT_TCP)
 
 	/* IPv6 のステートレス・アドレス自動設定を実行する。*/
 	in6_if_up(IF_GET_IFNET());
 
-#endif	/* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_TCP) */
+#endif	/* of #if defined(_IP6_CFG) && !defined(SUPPORT_TCP) */
 
 	while (true) {
@@ -248,11 +180,28 @@
 		syscall(wai_sem(SEM_UDP_POST_OUTPUT));
 
-		for (ix = tmax_udp_ccepid; ix -- > 0; ) {
-
-			if (udp_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
-				udp_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
-				udp_output(&udp_cep[ix]);
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
+
+		for (ix = tmax_udp6_cepid; ix -- > 0; ) {
+
+			if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
+				udp6_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
+				udp6_output(&udp6_cep[ix]);
 				}
 			}
+
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
+
+		for (ix = tmax_udp4_cepid; ix -- > 0; ) {
+
+			if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
+				udp4_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
+				udp4_output(&udp4_cep[ix]);
+				}
+			}
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
+
 		}
 	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (UDP/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
  *
@@ -71,5 +71,7 @@
 #include <kernel.h>
 #include <sil.h>
+#include <t_syslog.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -80,4 +82,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -91,4 +94,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -96,5 +100,4 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
 #include <netinet/in_itron.h>
@@ -102,11 +105,9 @@
 #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
-#include <netinet/icmp6.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
+#include <netinet/ip_igmp.h>
+
+#include <net/if_var.h>
 
 #ifdef SUPPORT_UDP
@@ -116,61 +117,80 @@
  */
 
+#if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0)
+
 static uint16_t udp_port_auto = UDP_PORT_FIRST_AUTO;	/* 自動割り当て番号	*/
 
+#endif	/* of #if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0) */
+
 /*
- *  udp_alloc_auto_port -- 自動割り当てポート番号を設定する。
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
  */
 
-ER
-udp_alloc_auto_port (T_UDP_CEP *cep)
-{
-	int_t	ix;
-	uint16_t	portno, portno_start;
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
 
-	portno_start = udp_port_auto;
-	do {
-		portno = udp_port_auto ++;
-		if (udp_port_auto > UDP_PORT_LAST_AUTO)
-			udp_port_auto = UDP_PORT_FIRST_AUTO;
+#if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR)
 
-		syscall(wai_sem(SEM_UDP_CEP));
-		for (ix = tmax_udp_ccepid; ix -- > 0; ) {
-			if (VALID_UDP_CEP(&udp_cep[ix]) && udp_cep[ix].myaddr.portno == portno) {
-				portno = UDP_PORTANY;
-				break;
-				}
-			}
+#define UDP_IS_DSTADDR_ACCEPT	udpn_is_dstaddr_accept
 
-		if (portno != UDP_PORTANY) {
-			cep->myaddr.portno = portno;
-			syscall(sig_sem(SEM_UDP_CEP));
-			return E_OK;
-			}
-		syscall(sig_sem(SEM_UDP_CEP));
+#else	/* of #if defined(_IP4_CFG) */
 
-		} while (portno_start != udp_port_auto);
+#define UDP_IS_DSTADDR_ACCEPT	udp6_is_dstaddr_accept
 
-	return E_NOID;
-	}
+#endif	/* of #if defined(_IP4_CFG) */
 
-/*
- *  udp_alloc_port -- 指定されたポート番号を設定する。
- */
+#define UDP_SEND_DATA		udp6_send_data
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_ALLOC_PORT		udp6_alloc_port
+#define UDP_FIND_CEP		udp6_find_cep
+#define UDP_NOTIFY		udp6_notify
+#define TMAX_UDP_CEPID		tmax_udp6_cepid
+#define UDP_CEP			udp6_cep
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
 
-ER
-udp_alloc_port (T_UDP_CEP *cep, uint16_t portno)
-{
-	int_t	ix;
+#include <netinet6/udp6_subr.c>
+#include <netinet/udpn_subr.c>
 
-	syscall(wai_sem(SEM_UDP_CEP));
-	for (ix = tmax_udp_ccepid; ix -- > 0; )
-		if (VALID_UDP_CEP(&udp_cep[ix]) && udp_cep[ix].myaddr.portno == portno) {
-			syscall(sig_sem(SEM_UDP_CEP));
-			return E_PAR;
-			}
-	cep->myaddr.portno = portno;
-	syscall(sig_sem(SEM_UDP_CEP));
-	return E_OK;
-	}
+#undef	UDP_SEND_DATA
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_ALLOC_PORT
+#undef	UDP_FIND_CEP
+#undef	UDP_NOTIFY
+#undef	UDP_IS_DSTADDR_ACCEPT
+#undef	TMAX_UDP_CEPID
+#undef	UDP_CEP
+#undef	T_UDP_CEP
+#undef  T_IPEP
+#undef  API_PROTO
+
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \
+                          ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
+
+#define UDP_IS_DSTADDR_ACCEPT	udp4_is_dstaddr_accept
+
+#define UDP_SEND_DATA		udp4_send_data
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_ALLOC_PORT		udp4_alloc_port
+#define UDP_FIND_CEP		udp4_find_cep
+#define UDP_NOTIFY		udp4_notify
+#define TMAX_UDP_CEPID		tmax_udp4_cepid
+#define T_UDP_CEP		T_UDP4_CEP
+#define UDP_CEP			udp4_cep
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
+
+#include <netinet/udp4_subr.c>
+#include <netinet/udpn_subr.c>
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
 
 #endif	/* of #ifdef SUPPORT_UDP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (UDP/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
  *
@@ -78,4 +78,5 @@
 #include <kernel.h>
 #include <sil.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -85,5 +86,5 @@
 #include <s_services.h>
 #include <t_services.h>
-#include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -97,4 +98,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -102,5 +104,4 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
 #include <netinet/in_itron.h>
@@ -108,33 +109,9 @@
 #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
-#include <netinet/icmp6.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
+#include <netinet/ip_igmp.h>
 
 #ifdef SUPPORT_UDP
-
-/*
- *  IPv4 と IPv6 の切り替えマクロ
- */
-
-#if defined(SUPPORT_INET4)
-
-#define UDP_CRE_CEP	udp_cre_cep
-#define UDP_SND_DAT	udp_snd_dat
-#define UDP_RCV_DAT	udp_rcv_dat
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-#define UDP_CRE_CEP	udp6_cre_cep
-#define UDP_SND_DAT	udp6_snd_dat
-#define UDP_RCV_DAT	udp6_rcv_dat
-
-#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -158,609 +135,137 @@
 #endif	/* of #ifndef UDP_CFG_LIBRARY */
 
-#ifdef __udp_send_data
-
-/*
- *  udp_send_data -- パケット送信の主要部
- */
-
-ER_UINT
-udp_send_data (T_UDP_CEP *cep, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
-{
-	T_NET_BUF	*output;
-	T_UDP_HDR	*udph;
-	SYSTIM		before, after;
-	ER		error = E_OK;
-
-#ifdef UDP_CFG_OUT_CHECKSUM
-	uint16_t	sum;
-#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
-
-	NET_COUNT_UDP(net_count_udp.out_octets,  len);
-	NET_COUNT_UDP(net_count_udp.out_packets, 1);
-
-	/* IP データグラム割り当ての時間を tmout から減ずる。*/
-	if (!(tmout == TMO_POL || tmout == TMO_FEVR))
-		syscall(get_tim(&before));
-
-	/* IP データグラムを割り当てる。*/
-	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + len), 0,
-	                             &p_dstaddr->ipaddr,
-	                             &cep->myaddr.ipaddr,
-	                             IPPROTO_UDP, IP_DEFTTL, 
-	                             NBA_SEARCH_ASCENT, tmout)) != E_OK)
-		goto err_ret;
-
-	/* IP データグラム割り当ての時間を tmout から減ずる。*/
-	if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
-		syscall(get_tim(&after));
-		if (after - before > tmout) {
-			syscall(rel_net_buf(output));
-			error = E_TMOUT;
-			goto err_ret;
-			}
-		tmout -= (TMO)(after - before);
-		}
-
-	/* UDP ヘッダに情報を設定する。*/
-	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET);
-	udph->sport	= htons(cep->myaddr.portno);
-	udph->dport	= htons(p_dstaddr->portno);
-	udph->ulen	= htons(UDP_HDR_SIZE + len);
-	udph->sum	= 0;
-
-	/* データをコピーする。*/
-	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET), data, (size_t)len);
-
-#ifdef UDP_CFG_OUT_CHECKSUM
-
-	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET, (uint_t)(UDP_HDR_SIZE + len));
-
-	/* 計算したチェックサムの値が 0 なら 0xffff を入れる。*/
-	if (sum == 0)
-		sum = 0xffff;
-	udph->sum = sum;
-
-#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
-
-	/* ネットワークバッファ長を調整する。*/
-	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE + len);
-
-	/* ネットワーク層 (IP) の出力関数を呼び出す。*/
-	if ((error = IP_OUTPUT(output, tmout)) == E_OK) {
-		NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
-		cep->snd_tskid = TA_NULL;
-		return len;
-		}
-
-err_ret:
-	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
-	cep->snd_tskid = TA_NULL;
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_send_data */
-
-/*
- *  udp_cre_cep -- UDP 通信端点の生成【拡張機能】
- */
-
-#ifdef __udp_cre_cep
-
-#ifdef UDP_CFG_EXTENTIONS
-
-ER
-UDP_CRE_CEP (ID cepid, T_UDP_CCEP *pk_ccep)
-{
-	T_UDP_CEP	*cep;
-	ER		error;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* pk_ccep が NULL ならエラー */
-	if (pk_ccep == NULL)
-		return E_PAR;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (VALID_UDP_CEP(cep))
-		return E_OBJ;
-
-	/* UDP 通信端点が、動的生成用でなければエラー */
-	if (!DYNAMIC_UDP_CEP(cep))
-		return E_ID;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	/*
-	 * UDP 通信端点をチェックする。生成済みであればエラー
-	 */
-	if (VALID_UDP_CEP(cep))
-		error = E_OBJ;
-	else {
-
-		/*
-		 *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
-		 */
-		if (pk_ccep->myaddr.portno == UDP_PORTANY)
-			error = udp_alloc_auto_port(cep);
-		else 
-			error = udp_alloc_port(cep, pk_ccep->myaddr.portno);
-		
-                if (error == E_OK) {
-
-			/* UDP 通信端点生成情報をコピーする。*/
-			cep->cepatr        = pk_ccep->cepatr;			/* 通信端点属性		*/
-			cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;		/* 自分のアドレス	*/
-			cep->callback      = (void*)pk_ccep->callback;		/* コールバック		*/
-
-			/* UDP 通信端点を生成済みにする。*/
-			cep->flags |= UDP_CEP_FLG_VALID;
-			}
-		}
-
-	/* 通信端点のロックを解除する。*/
-	syscall(sig_sem(cep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __udp_cre_cep */
-
-/*
- *  udp_del_cep -- UDP 通信端点の削除【拡張機能】
- */
-
-#ifdef __udp_del_cep
-
-#ifdef UDP_CFG_EXTENTIONS
-
-ER
-udp_del_cep (ID cepid)
-{
-	T_UDP_CEP	*cep;
-	ER		error;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/* UDP 通信端点が、動的生成用でなければエラー */
-	if (!DYNAMIC_UDP_CEP(cep))
-		return E_ID;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	/*
-	 * UDP 通信端点をチェックする。未生成の場合はエラー
-	 * ・未生成。
-	 */
-	if (!VALID_UDP_CEP(cep))
-		error = E_NOEXS;
-	else {
-		udp_can_snd(cep, E_DLT);
-		udp_can_rcv(cep, E_DLT);
-
-		/* UDP 通信端点を未生成にする。*/
-		cep->flags &= ~UDP_CEP_FLG_VALID;
-		error = E_OK;
-		}
-
-	/* 通信端点のロックを解除する。*/
-	syscall(sig_sem(cep->semid_lock));
-
-	return error;
-	}
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __udp_del_cep */
+/*
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
+ */
+
+#undef	IN_GET_DATAGRAM
+#undef	IN_COPY_TO_HOST
+
+#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
+
+#define UDP_CANCEL_CEP		udp6_cancel_cep
+#define UDP_DELETE_CEP		udp6_delete_cep
+#define UDP_SET_OPTION		udp6_set_option
+#define UDP_GET_OPTION		udp6_get_option
+#define UDP_CRE_CEP		udp6_cre_cep
+#define UDP_DEL_CEP		udp6_del_cep
+#define UDP_SET_OPT		udp6_set_opt
+#define UDP_GET_OPT		udp6_get_opt
+#define UDP_SND_DAT		udp6_snd_dat
+#define UDP_RCV_DAT		udp6_rcv_dat
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_ALLOC_PORT		udp6_alloc_port
+#define UDP_SEND_DATA		udp6_send_data
+#define VALID_UDP_CEPID		VALID_UDP6_CEPID
+#define GET_UDP_CEP		GET_UDP6_CEP
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_UDPN_CCEP		T_UDP6_CCEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(_IP4_CFG)
+#define	IN_GET_DATAGRAM		inn_get_datagram
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define	IN_GET_DATAGRAM		in6_get_datagram
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
+
+#include <netinet/udpn_usrreq.c>
+
+#undef	UDP_CANCEL_CEP
+#undef	UDP_DELETE_CEP
+#undef	UDP_SET_OPTION
+#undef	UDP_GET_OPTION
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	UDP_SET_OPT
+#undef	UDP_GET_OPT
+#undef	UDP_SND_DAT
+#undef	UDP_RCV_DAT
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_ALLOC_PORT
+#undef	UDP_SEND_DATA
+#undef	VALID_UDP_CEPID
+#undef	GET_UDP_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef	T_UDPN_CCEP
+#undef  T_IPEP
+#undef  API_PROTO
+#undef	IN_GET_DATAGRAM
+#undef	IN_COPY_TO_HOST
+
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
+
+#define UDP_CANCEL_CEP		udp4_cancel_cep
+#define UDP_DELETE_CEP		udp4_delete_cep
+#define UDP_SET_OPTION		udp4_set_option
+#define UDP_GET_OPTION		udp4_get_option
+#define UDP_CRE_CEP		udp_cre_cep
+#define UDP_DEL_CEP		udp_del_cep
+#define UDP_SET_OPT		udp_set_opt
+#define UDP_GET_OPT		udp_get_opt
+#define UDP_SND_DAT		udp_snd_dat
+#define UDP_RCV_DAT		udp_rcv_dat
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_ALLOC_PORT		udp4_alloc_port
+#define UDP_SEND_DATA		udp4_send_data
+#define VALID_UDP_CEPID		VALID_UDP4_CEPID
+#define GET_UDP_CEP		GET_UDP4_CEP
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define T_UDPN_CCEP		T_UDP_CCEP
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
+
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
+#define	IN_GET_DATAGRAM		in4_get_datagram
+
+#include <netinet/udpn_usrreq.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
+
+#if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0)
+
+/*
+ *  udp_can_cep -- ペンディングしている処理のキャンセル【標準機能】
+ */
 
 #ifdef __udp_can_cep
-
-/*
- *  udp_can_cep -- ペンディングしている処理のキャンセル【標準機能】
- */
 
 ER
 udp_can_cep (ID cepid, FN fncd)
 {
-	T_UDP_CEP	*cep;
-	ER		error = E_OK, snd_err, rcv_err;
-
-	/* API 機能コードをチェックする。*/
-	if (!VALID_TFN_UDP_CAN(fncd))
-		return E_PAR;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
+	/* IPv6 用の UDP 通信端点 ID をチェックする。*/
+	if (VALID_UDP6_CEPID(cepid)) {
+
+		/* UDP 通信端点を得てメイン関数を呼び出す。*/
+		return udp6_cancel_cep(GET_UDP6_CEP(cepid), fncd);
+		}
+
+	/* IPv4 用の UDP 通信端点 ID をチェックする。*/
+	else if (VALID_UDP4_CEPID(cepid)) {
+
+		/* UDP 通信端点を得てメイン関数を呼び出す。*/
+		return udp4_cancel_cep(GET_UDP4_CEP(cepid), fncd);
+		}
+
+	else
 		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	if (fncd == TFN_UDP_ALL) {	/* TFN_UDP_ALL の処理 */
-
-		snd_err = udp_can_snd(cep, E_RLWAI);
-		rcv_err = udp_can_rcv(cep, E_RLWAI);
-
-		/*
-		 *  snd_err と rcv_err のどちらも EV_NOPND
-		 *  なら、ペンディングしていないのでエラー
-		 */
-		if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
-			error = E_OBJ;
-		else {
-			if (snd_err == EV_NOPND)
-				snd_err = E_OK;
-			if (rcv_err == EV_NOPND)
-				rcv_err = E_OK;
-
-			if (snd_err != E_OK)
-				error = snd_err;
-			else if (rcv_err != E_OK)
-				error = rcv_err;
-			}
-		}
-	else if (fncd == TFN_UDP_SND_DAT) {	/* 送信処理のキャンセル */
-		if ((error = udp_can_snd(cep, E_RLWAI)) == EV_NOPND)
-			error = E_OBJ;
-		}
-	else if (fncd == TFN_UDP_RCV_DAT) {	/* 受信処理のキャンセル */
-		if ((error = udp_can_rcv(cep, E_RLWAI)) == EV_NOPND)
-			error = E_OBJ;
-		}
-	else
-		error = E_PAR;
-
-	/* 通信端点をロックを解除する。*/
-	syscall(sig_sem(cep->semid_lock));
-
-	return error;
 	}
 
 #endif	/* of #ifdef __udp_can_cep */
 
-/*
- *  udp_set_opt -- UDP 通信端点オプションの設定【拡張機能】
- *
- *  注意: 設定可能な UDP 通信端点オプションは無いため、E_PAR が返される。
- */
-
-#ifdef __udp_set_opt
-
-#ifdef UDP_CFG_EXTENTIONS
-
-ER
-udp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
-{
-	T_UDP_CEP	*cep;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	return E_OK/*E_PAR*/;
-	}
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __udp_set_opt */
-
-/*
- *  udp_get_opt -- UDP 通信端点オプションの設定【拡張機能】
- *
- *  注意: 設定可能な UDP 通信端点オプションは無いため、E_PAR が返される。
- */
-
-#ifdef __udp_get_opt
-
-#ifdef UDP_CFG_EXTENTIONS
-
-ER
-udp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
-{
-	T_UDP_CEP	*cep;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	return E_OK/*E_PAR*/;
-	}
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-#endif	/* of #ifdef __udp_get_opt */
-
-#ifdef UDP_CFG_NON_BLOCKING
-
-#include "udp_usrreq_nblk.c"
-
-#else	/* of #ifdef UDP_CFG_NON_BLOCKING */
-
-#ifdef __udp_can_snd
-
-/*
- *  udp_can_snd -- ペンディングしている送信のキャンセル
- */
-
-ER
-udp_can_snd (T_UDP_CEP *cep, ER error)
-{
-	if (cep->snd_tskid != TA_NULL) {	/* 非ノンブロッキングコールでペンディング中 */
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報を設定する。*/
-		cep->error = error;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-		error = rel_wai(cep->snd_tskid);
-		cep->snd_tskid = TA_NULL;
-		}
-	else					/* どちらでもないならペンディングしていない */
-		error = EV_NOPND;
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_can_snd */
-
-#ifdef __udp_can_rcv
-
-/*
- *  udp_can_rcv -- ペンディングしている受信のキャンセル
- */
-
-ER
-udp_can_rcv (T_UDP_CEP *cep, ER error)
-{
-	if (cep->rcv_tskid != TA_NULL) {	/* 非ノンブロッキングコールでペンディング中 */
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報を設定する。*/
-		cep->error = error;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-		error = rel_wai(cep->rcv_tskid);
-		cep->rcv_tskid = TA_NULL;
-		}
-	else					/* どちらでもないならペンディングしていない */
-		error = EV_NOPND;
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_can_rcv */
-
-#ifdef __udp_snd_dat
-
-/*
- *  udp_snd_dat -- パケットの送信【標準機能】
- */
-
-ER_UINT
-UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
-{
-	T_UDP_CEP	*cep;
-	ER		error;
-
-	/* p_dstaddr または data が NULL か、tmout が TMO_NBLK ならエラー */
-	if (p_dstaddr == NULL || data == NULL || tmout == TMO_NBLK)
-		return E_PAR;
-
-	/* データ長をチェックする。*/
-	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
-		return E_PAR;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/*
-	 *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
-	 */
-	if (cep->myaddr.portno == UDP_PORTANY) {
-		if ((error = udp_alloc_auto_port(cep)) != E_OK)
-			return error;
-		}
-	
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	if (cep->snd_tskid != TA_NULL) {
-
-		/* 非ノンブロッキングコールでペンディング中 */
-		error = E_QOVR;
-
-		/* 通信端点をロックを解除する。*/
-		syscall(sig_sem(cep->semid_lock));
-		}
-	else {
-		/* 現在のタスク識別子を記録する。*/
-		get_tid(&(cep->snd_tskid));
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報をリセットする。*/
-		cep->error = E_OK;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-		/* 通信端点をロックを解除する。*/
-		syscall(sig_sem(cep->semid_lock));
-
-		/* パケットを送信する。*/
-		error = udp_send_data(cep, p_dstaddr, data, len, tmout);
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報を返す。*/
-		if (error == E_RLWAI)
-			error = cep->error;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-		}
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_snd_dat */
-
-#ifdef __udp_rcv_dat
-
-/*
- *  udp_rcv_dat -- パケットの受信【標準機能】
- */
-
-ER_UINT
-UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
-{
-	T_NET_BUF	*input;
-	T_UDP_CEP	*cep;
-	T_UDP_HDR	*udph;
-	ER_UINT		error;
-	uint_t		ulen, uhoff;
-
-	/* p_dstaddr または data が NULL 、len < 0 か、tmout が TMO_NBLK ならエラー */
-	if (p_dstaddr == NULL || data == NULL || len < 0 || tmout == TMO_NBLK)
-		return E_PAR;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/* 通信端点をロックする。*/
-	syscall(wai_sem(cep->semid_lock));
-
-	if (cep->rcv_tskid != TA_NULL) {
-
-		/* 非ノンブロッキングコールでペンディング中 */
-		error = E_QOVR;
-
-		/* 通信端点をロックを解除する。*/
-		syscall(sig_sem(cep->semid_lock));
-		}
-	else {
-
-		/* 現在のタスク識別子を記録する。*/
-		get_tid(&(cep->rcv_tskid));
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報をリセットする。*/
-		cep->error = E_OK;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-		/* 通信端点をロックを解除する。*/
-		syscall(sig_sem(cep->semid_lock));
-
-		/* 入力があるまで待つ。*/
-		if (cep->cb_netbuf != NULL) {
-
-			/*
-			 *  ここにくる場合は、コールバック関数の中から
-			 *  udp_rcv_dat を呼び出していることになり、
-			 *  すでに入力済みである。
-			 */
-			input = cep->cb_netbuf;
-			cep->cb_netbuf = NULL;
-			}
-		else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
-
-#ifdef UDP_CFG_EXTENTIONS
-
-			/* 待ち中に発生したエラー情報を返す。*/
-			if (error == E_RLWAI)
-				error = cep->error;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-			cep->rcv_tskid = TA_NULL;
-			return error;
-			}
-
-		/* p_dstaddr を設定する。*/
-		uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
-		udph = GET_UDP_HDR(input, uhoff);
-		p_dstaddr->portno = ntohs(udph->sport);
-		IN_COPY_TO_HOST(&p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
-
-		/* データをバッファに移す。*/
-		ulen = ntohs(udph->ulen);
-		if (ulen - UDP_HDR_SIZE > len)
-			error = E_BOVR;
-		else {
-			len   =    (uint_t)(ulen - UDP_HDR_SIZE);
-			error = (ER_UINT)(ulen - UDP_HDR_SIZE);
-			}
-
-		memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
-
-		syscall(rel_net_buf(input));
-
-		cep->rcv_tskid = TA_NULL;
-		}
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_rcv_dat */
-
-#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
 
 #endif	/* of #ifdef SUPPORT_UDP */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq_nblk.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq_nblk.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_usrreq_nblk.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (UDP/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
  *
@@ -75,4 +75,5 @@
 #include <sil.h>
 #include "kernel_cfg.h"
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -83,4 +84,5 @@
 #include <t_services.h>
 #include "kernel_id.h"
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -94,4 +96,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
@@ -99,5 +102,4 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
 #include <netinet/in_var.h>
 #include <netinet/in_itron.h>
@@ -105,31 +107,8 @@
 #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet6/nd6.h>
-#include <netinet/icmp6.h>
 #include <netinet/udp.h>
 #include <netinet/udp_var.h>
 
 #ifdef SUPPORT_UDP
-
-/*
- *  IPv4 と IPv6 の切り替えマクロ
- */
-
-#if defined(SUPPORT_INET4)
-
-#define UDP_SND_DAT	udp_snd_dat
-#define UDP_RCV_DAT	udp_rcv_dat
-
-#endif	/* of #if defined(SUPPORT_INET4) */
-
-#if defined(SUPPORT_INET6)
-
-#define UDP_SND_DAT	udp6_snd_dat
-#define UDP_RCV_DAT	udp6_rcv_dat
-
-#endif	/* of #if defined(SUPPORT_INET6) */
 
 /*
@@ -140,8 +119,8 @@
 #ifndef UDP_CFG_LIBRARY
 
-#define __udp_can_snd
-#define __udp_can_rcv
-#define __udp_snd_dat
-#define __udp_rcv_dat
+#define __udp_can_snd_nblk
+#define __udp_can_rcv_nblk
+#define __udp_snd_dat_nblk
+#define __udp_rcv_dat_nblk
 
 #endif	/* of #ifndef UDP_CFG_LIBRARY */
@@ -149,343 +128,69 @@
 #ifdef UDP_CFG_NON_BLOCKING
 
-#ifdef __udp_can_snd
-
 /*
- *  udp_can_snd -- ペンディングしている送信のキャンセル
+ *  IPv6 と IPv4 で引数が異なる関数のコンパイル
  */
 
-ER
-udp_can_snd (T_UDP_CEP *cep, ER error)
-{
-	if (cep->snd_p_dstaddr != NULL) {	/* ノンブロッキングコールでペンディング中 */
-		if (IS_PTR_DEFINED(cep->callback))
+#undef	IN_COPY_TO_HOST
 
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
 
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
+#define UDP_SND_DAT		udp6_snd_dat
+#define UDP_RCV_DAT		udp6_rcv_dat
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_SEND_DATA		udp6_send_data
+#define VALID_UDP_CEPID		VALID_UDP6_CEPID
+#define GET_UDP_CEP		GET_UDP6_CEP
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
 
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+#if defined(SUPPORT_INET4)
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
 
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+#include <netinet/udpn_usrreq_nblk.c>
 
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+#undef	UDP_SND_DAT
+#undef	UDP_RCV_DAT
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_SEND_DATA
+#undef	VALID_UDP_CEPID
+#undef	GET_UDP_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef  T_IPEP
+#undef  API_PROTO
+#undef	IN_COPY_TO_HOST
 
-		else
-			error = E_OBJ;
-		cep->snd_p_dstaddr = NULL;
-		}
-	else if (cep->snd_tskid != TA_NULL) {	/* 非ノンブロッキングコールでペンディング中 */
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
 
-#ifdef UDP_CFG_EXTENTIONS
+#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
 
-		/* 待ち中に発生したエラー情報を設定する。*/
-		cep->error = error;
+#define UDP_SND_DAT		udp_snd_dat
+#define UDP_RCV_DAT		udp_rcv_dat
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_SEND_DATA		udp4_send_data
+#define VALID_UDP_CEPID		VALID_UDP4_CEPID
+#define GET_UDP_CEP		GET_UDP4_CEP
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
 
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
 
-		error = rel_wai(cep->snd_tskid);
-		cep->snd_tskid = TA_NULL;
-		}
-	else					/* どちらでもないならペンディングしていない */
-		error = EV_NOPND;
+#include <netinet/udpn_usrreq_nblk.c>
 
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_can_snd */
-
-#ifdef __udp_can_rcv
-
-/*
- *  udp_can_rcv -- ペンディングしている受信のキャンセル
- */
-
-ER
-udp_can_rcv (T_UDP_CEP *cep, ER error)
-{
-	if (cep->rcv_p_dstaddr != NULL) {	/* ノンブロッキングコールでペンディング中 */
-		if (IS_PTR_DEFINED(cep->callback))
-
-#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
-
-#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
-
-#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
-
-		else
-			error = E_OBJ;
-		cep->rcv_p_dstaddr = NULL;
-		}
-	else if (cep->rcv_tskid != TA_NULL) {	/* 非ノンブロッキングコールでペンディング中 */
-
-#ifdef UDP_CFG_EXTENTIONS
-
-		/* 待ち中に発生したエラー情報を設定する。*/
-		cep->error = error;
-
-#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
-
-		error = rel_wai(cep->rcv_tskid);
-		cep->rcv_tskid = TA_NULL;
-		}
-	else					/* どちらでもないならペンディングしていない */
-		error = EV_NOPND;
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_can_rcv */
-
-#ifdef __udp_snd_dat
-
-/*
- *  udp_snd_dat -- パケットの送信【標準機能】
- */
-
-ER_UINT
-UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
-{
-	T_UDP_CEP	*cep;
-	ER		error;
-
-	/* p_dstaddr または data が NULL ならエラー */
-	if (p_dstaddr == NULL || data == NULL)
-		return E_PAR;
-
-	/* データ長をチェックする。*/
-	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
-		return E_PAR;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/*
-	 *  自ポート番号が UDP_PORTANY なら、自動で割り当てる。
-	 */
-	if (cep->myaddr.portno == UDP_PORTANY) {
-		if ((error = udp_alloc_auto_port(cep)) != E_OK)
-			return error;
-		}
-
-	/*
-	 * タイムアウトをチェックする。
-	 */
-
-	if (tmout == TMO_NBLK) {	/* ノンブロッキングコール */
-
-		/* 通信端点をロックする。*/
-		syscall(wai_sem(cep->semid_lock));
-
-		if (cep->snd_p_dstaddr != NULL) {
-
-			/* ノンブロッキングコールでペンディング中 */
-			error = E_QOVR;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else if (cep->snd_tskid != TA_NULL) {
-
-			/* 非ノンブロッキングコールでペンディング中 */
-			error = E_OBJ;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else {
-
-			cep->snd_p_dstaddr = p_dstaddr;
-			cep->snd_data	= data;
-			cep->snd_len	= len;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-
-			cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
-			sig_sem(SEM_UDP_POST_OUTPUT);
-			error = E_WBLK;
-			}
-		}
-	else {				/* 非ノンブロッキングコール */
-	
-		/* 通信端点をロックする。*/
-		syscall(wai_sem(cep->semid_lock));
-
-		if (cep->snd_p_dstaddr != NULL) {
-
-			/* ノンブロッキングコールでペンディング中 */
-			error = E_OBJ;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else if (cep->snd_tskid != TA_NULL) {
-
-			/* 非ノンブロッキングコールでペンディング中 */
-			error = E_QOVR;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else {
-
-			/* 現在のタスク識別子を記録する。*/
-			get_tid(&(cep->snd_tskid));
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-
-			/* パケットを送信する。*/
-			error = udp_send_data(cep, p_dstaddr, data, len, tmout);
-			}
-		}
-
-	return error;
-	}
-
-#endif	/* of #ifdef __udp_snd_dat */
-
-#ifdef __udp_rcv_dat
-
-/*
- *  udp_rcv_dat -- パケットの受信【標準機能】
- */
-
-ER_UINT
-UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
-{
-	T_NET_BUF	*input;
-	T_UDP_CEP	*cep;
-	T_UDP_HDR	*udph;
-	ER_UINT		error;
-	uint_t		ulen, uhoff;
-
-	/* p_dstaddr または data が NULL か、len < 0 ならエラー */
-	if (p_dstaddr == NULL || data == NULL || len < 0)
-		return E_PAR;
-
-	/* UDP 通信端点 ID をチェックする。*/
-	if (!VALID_UDP_CEPID(cepid))
-		return E_ID;
-
-	/* UDP 通信端点を得る。*/
-	cep = GET_UDP_CEP(cepid);
-
-	/* UDP 通信端点をチェックする。*/
-	if (!VALID_UDP_CEP(cep))
-		return E_NOEXS;
-
-	/*
-	 * タイムアウトをチェックする。
-	 */
-
-	if (tmout == TMO_NBLK) {	/* ノンブロッキングコール */
-
-		/* 通信端点をロックする。*/
-		syscall(wai_sem(cep->semid_lock));
-
-		if (cep->rcv_p_dstaddr != NULL)
-
-			/* ノンブロッキングコールでペンディング中 */
-			error = E_QOVR;
-
-		else if (cep->rcv_tskid != TA_NULL)
-
-			/* 非ノンブロッキングコールでペンディング中 */
-			error = E_OBJ;
-		else {
-			cep->rcv_p_dstaddr = p_dstaddr;
-			cep->rcv_data	= data;
-			cep->rcv_len	= len;
-			error = E_WBLK;
-			}
-
-		/* 通信端点をロックを解除する。*/
-		syscall(sig_sem(cep->semid_lock));
-		return error;
-		}
-	else {				/* 非ノンブロッキングコール */
-
-		/* 通信端点をロックする。*/
-		syscall(wai_sem(cep->semid_lock));
-
-		if (cep->rcv_p_dstaddr != NULL) {
-
-			/* ノンブロッキングコールでペンディング中 */
-			error = E_OBJ;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else if (cep->rcv_tskid != TA_NULL) {
-
-			/* 非ノンブロッキングコールでペンディング中 */
-			error = E_QOVR;
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-			}
-		else {
-
-			/* 現在のタスク識別子を記録する。*/
-			get_tid(&(cep->rcv_tskid));
-
-			/* 通信端点をロックを解除する。*/
-			syscall(sig_sem(cep->semid_lock));
-
-			/* 入力があるまで待つ。*/
-			if (cep->cb_netbuf != NULL) {
-
-				/*
-				 *  ここにくる場合は、コールバック関数の中から
-				 *  udp_rcv_dat を呼び出していることになり、
-				 *  すでに入力済みである。
-				 */
-				input = cep->cb_netbuf;
-				cep->cb_netbuf = NULL;
-				}
-			else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
-				cep->rcv_tskid = TA_NULL;
-				return error;
-				}
-
-			/* p_dstaddr を設定する。*/
-			uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
-			udph = GET_UDP_HDR(input, uhoff);
-			p_dstaddr->portno = ntohs(udph->sport);
-			IN_COPY_TO_HOST(&p_dstaddr->ipaddr, &GET_IP_HDR(input)->src);
-
-			/* データをバッファに移す。*/
-			ulen = ntohs(udph->ulen);
-			if (ulen - UDP_HDR_SIZE > len)
-				error = E_BOVR;
-			else {
-				len   =     (int_t)(ulen - UDP_HDR_SIZE);
-				error = (ER_UINT)(ulen - UDP_HDR_SIZE);
-				}
-
-			memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
-
-			syscall(rel_net_buf(input));
-
-			cep->rcv_tskid = TA_NULL;
-			}
-		return error;
-		}
-	}
-
-#endif	/* of #ifdef __udp_rcv_dat */
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
 
 #endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h	(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
  *
@@ -75,15 +75,10 @@
  */
 
-#define IP_UDP_HDR_SIZE			(IP_HDR_SIZE + UDP_HDR_SIZE)
-#define IF_IP_UDP_HDR_SIZE		(IF_IP_HDR_SIZE + UDP_HDR_SIZE)
-#define IF_IP_UDP_HDR_OFFSET		(IF_IP_HDR_SIZE)
-
 #define GET_UDP_HDR(nbuf,uhoff)		((T_UDP_HDR*)((uint8_t*)((nbuf)->buf) + uhoff))
+#define GET_UDP_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
 #define GET_UDP_SDU(nbuf,uhoff)		((uint8_t*)((nbuf)->buf) + uhoff+ UDP_HDR_SIZE)
 
-#define GET_UDP_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
-
-#define GET_IP_UDP_HDR_SIZE(nbuf)	(GET_IP_HDR_SIZE(GET_IP_HDR(nbuf)) + UDP_HDR_SIZE)
-#define GET_IF_IP_UDP_HDR_SIZE(nbuf)	(IF_HDR_SIZE + GET_IP_UDP_HDR_SIZE(nbuf))
+#define IF_IP_UDP_HDR_SIZE(nbuf)	(IF_IP_HDR_SIZE(nbuf) + UDP_HDR_SIZE)
+#define IF_IP_UDP_HDR_OFFSET(nbuf)	(IF_IP_HDR_SIZE(nbuf))
 
 /*
@@ -91,5 +86,5 @@
  */
 
-#if defined(SUPPORT_INET4)
+#if defined(_IP4_CFG)
 
 #define IP4_UDP_HDR_SIZE		IP_UDP_HDR_SIZE
@@ -98,5 +93,5 @@
 #define GET_IF_IP4_UDP_HDR_SIZE(nbuf)	GET_IF_IP_UDP_HDR_SIZE(nbuf)
 
-#endif	/* of #if defined(SUPPORT_INET4) */
+#endif	/* of #if defined(_IP4_CFG) */
 
 /*
@@ -110,9 +105,7 @@
  */
 
-
-/*
- *  IPv4 UDP 通信端点
- */
-typedef struct t_udp4_cep {
+/* IPv6 用 UDP 通信端点 */
+
+typedef struct t_udp6_cep {
 
 	/*
@@ -120,5 +113,5 @@
 	 */
 	ATR		cepatr;		/* UDP 通信端点属性		*/
-	T_IPV4EP	myaddr;		/* 自分のアドレス		*/
+	T_IPV6EP	myaddr;		/* 自分のアドレス		*/
 	t_udp_callback	callback;	/* コールバック関数		*/
 
@@ -135,6 +128,6 @@
 #ifdef UDP_CFG_NON_BLOCKING
 
-	T_IPV4EP 	*snd_p_dstaddr;	/* 送信相手のアドレスへのポインタ*/
-	T_IPV4EP 	*rcv_p_dstaddr;	/* 受信相手のアドレスへのポインタ*/
+	T_IPV6EP 	*snd_p_dstaddr;	/* 送信相手のアドレスへのポインタ*/
+	T_IPV6EP 	*rcv_p_dstaddr;	/* 受信相手のアドレスへのポインタ*/
 	void		*snd_data;	/* 送信データ領域の先頭アドレス	*/
 	int_t		snd_len;	/* 送信データ領域の長さ		*/
@@ -148,15 +141,9 @@
 #endif
 
-	} T_UDP4_CEP;
-
-#if defined(SUPPORT_INET4)
-#define T_UDP_CEP	T_UDP4_CEP
-#endif
-
-/*
- *  IPv6 UDP 通信端点
- */
-
-typedef struct t_udp6_cep {
+	} T_UDP6_CEP;
+
+/* IPv4 用 UDP 通信端点 */
+
+typedef struct t_udp4_cep {
 
 	/*
@@ -164,5 +151,5 @@
 	 */
 	ATR		cepatr;		/* UDP 通信端点属性		*/
-	T_IPV6EP	myaddr;		/* 自分のアドレス		*/
+	T_IPV4EP	myaddr;		/* 自分のアドレス		*/
 	t_udp_callback	callback;	/* コールバック関数		*/
 
@@ -179,6 +166,6 @@
 #ifdef UDP_CFG_NON_BLOCKING
 
-	T_IPV6EP 	*snd_p_dstaddr;	/* 送信相手のアドレスへのポインタ*/
-	T_IPV6EP 	*rcv_p_dstaddr;	/* 受信相手のアドレスへのポインタ*/
+	T_IPV4EP 	*snd_p_dstaddr;	/* 送信相手のアドレスへのポインタ*/
+	T_IPV4EP	*rcv_p_dstaddr;	/* 受信相手のアドレスへのポインタ*/
 	void		*snd_data;	/* 送信データ領域の先頭アドレス	*/
 	int_t		snd_len;	/* 送信データ領域の長さ		*/
@@ -191,10 +178,24 @@
 	ER		error;		/* 待ち中に発生したエラー	*/
 #endif
-
-	} T_UDP6_CEP;
-
-#if defined(SUPPORT_INET6)
+#ifdef SUPPORT_IGMP
+	bool_t igmp_loopback;
+	uint8_t igmp_ttl;
+	T_IN4_ADDR 	igmp_mcaddr;	/*  */
+#endif
+	} T_UDP4_CEP;
+
+#if defined(_IP6_CFG)
+
 #define T_UDP_CEP	T_UDP6_CEP
-#endif
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define T_UDP_CEP	T_UDP4_CEP
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
 
 /*
@@ -210,7 +211,7 @@
  */
 
-#define	TMIN_UDP_CEPID		1	/* UDP 通信端点 ID の最小値 */
-
-#ifdef SUPPORT_MIB
+#define	TMIN_UDP_CEPID		1			/* UDP      通信端点 ID の最小値 */
+#define	TMIN_UDP6_CEPID		1			/* UDP/IPv6 通信端点 ID の最小値 */
+#define	TMIN_UDP4_CEPID		(TNUM_UDP6_CEPID+1)	/* UDP/IPv4 通信端点 ID の最小値 */
 
 /*
@@ -225,17 +226,19 @@
 } T_UDP_STATS;
 
-#endif	/* of #ifdef SUPPORT_MIB */
-
 /*
  *  関数シミュレーションマクロ
  */
 
-#define VALID_UDP_CEPID(id)	(TMIN_UDP_CEPID<=(id)&&(id)<=tmax_udp_cepid)
-
-#define INDEX_UDP_CEP(id)	((id)-TMIN_UDP_CEPID)
-
-#define GET_UDP_CEP(id)		(&(udp_cep[INDEX_UDP_CEP(id)]))
-
-#define GET_UDP_CEPID(cep)	((ID)(((cep)-udp_cep)+TMIN_UDP_CEPID))
+#define VALID_UDP6_CEPID(id)	(TMIN_UDP6_CEPID<=(id)&&(id)<=tmax_udp6_cepid)
+#define VALID_UDP4_CEPID(id)	(TMIN_UDP4_CEPID<=(id)&&(id)<=tmax_udp4_cepid)
+
+#define INDEX_UDP6_CEP(id)	((id)-TMIN_UDP6_CEPID)
+#define INDEX_UDP4_CEP(id)	((id)-TMIN_UDP4_CEPID)
+
+#define GET_UDP6_CEP(id)	(&(udp6_cep[INDEX_UDP6_CEP(id)]))
+#define GET_UDP4_CEP(id)	(&(udp4_cep[INDEX_UDP4_CEP(id)]))
+
+#define GET_UDP6_CEPID(cep)	((ID)(((cep)-udp6_cep)+TMIN_UDP6_CEPID))
+#define GET_UDP4_CEPID(cep)	((ID)(((cep)-udp4_cep)+TMIN_UDP4_CEPID))
 
 #define VALID_TFN_UDP_CAN(t)	((t)==TFN_UDP_SND_DAT||(t)==TFN_UDP_RCV_DAT||\
@@ -249,12 +252,26 @@
  */
 
-extern T_UDP_CEP udp_cep[];
+extern T_UDP_STATS udp_stats;
+
+/* UDP 通信端点 */
+
+extern T_UDP6_CEP udp6_cep[];
+extern T_UDP4_CEP udp4_cep[];
+
+#if defined(SUPPORT_INET6)
+#define udp_cep	udp6_cep
+#elif defined(SUPPORT_INET4)
+#define udp_cep	udp4_cep
+#endif
+
 extern const ID tmax_udp_cepid;
 
-#ifdef SUPPORT_MIB
-
-extern T_UDP_STATS udp_stats;
-
-#endif	/* of #ifdef SUPPORT_MIB */
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_udp6_cepid;
+extern const ID tmax_udp4_cepid;
+#else
+#define tmax_udp6_cepid	tmax_udp_cepid
+#define tmax_udp4_cepid	tmax_udp_cepid
+#endif
 
 /*
@@ -269,11 +286,29 @@
  */
 
-extern uint_t udp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
-extern ER_UINT udp_send_data (T_UDP_CEP *cep, T_IPEP *p_dstaddr,
-                              void *data, int_t len, TMO tmout);
-extern ER udp_can_snd (T_UDP_CEP *cep, ER error);
-extern ER udp_can_rcv (T_UDP_CEP *cep, ER error);
-extern ER udp_alloc_auto_port (T_UDP_CEP *cep);
-extern ER udp_alloc_port (T_UDP_CEP *cep, uint16_t portno);
+/* IPv6 */
+
+extern uint_t udp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern ER_UINT udp6_send_data (T_UDP6_CEP *cep, T_IPV6EP *p_dstaddr,
+                               void *data, int_t len, TMO tmout);
+extern ER udp6_can_snd (T_UDP6_CEP *cep, ER error);
+extern ER udp6_can_rcv (T_UDP6_CEP *cep, ER error);
+extern ER udp6_alloc_auto_port (T_UDP6_CEP *cep);
+extern ER udp6_alloc_port (T_UDP6_CEP *cep, uint16_t portno);
+extern T_UDP6_CEP*udp6_find_cep (T_NET_BUF *input, uint_t off);
+extern void udp6_notify (T_NET_BUF *input, ER error);
+extern void udp6_input_select (T_UDP6_CEP *cep, T_NET_BUF *input, uint_t off);
+
+/* IPv4 */
+
+extern uint_t udp4_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern ER_UINT udp4_send_data (T_UDP4_CEP *cep, T_IPV4EP *p_dstaddr,
+                               void *data, int_t len, TMO tmout);
+extern ER udp4_can_snd (T_UDP4_CEP *cep, ER error);
+extern ER udp4_can_rcv (T_UDP4_CEP *cep, ER error);
+extern ER udp4_alloc_auto_port (T_UDP4_CEP *cep);
+extern ER udp4_alloc_port (T_UDP4_CEP *cep, uint16_t portno);
+extern T_UDP4_CEP*udp4_find_cep (T_NET_BUF *input, uint_t off);
+extern void udp4_notify (T_NET_BUF *input, ER error);
+extern void udp4_input_select (T_UDP4_CEP *cep, T_NET_BUF *input, uint_t off);
 
 /* ノンブロッキングコールを行う場合に組み込むタスク */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c	(revision 331)
@@ -0,0 +1,252 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if (API_PROTO == API_PROTO_IPV6) || (TNUM_UDP4_CEPID > 0)
+
+/*
+ *  udp_input_select -- UDP ã®å
+¥åå¦çã®é¸æ
+ */
+
+void
+UDP_INPUT_SELECT (T_UDP_CEP *cep, T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+	uint_t		len;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+	len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
+
+	if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (psnd_dtq(cep->rcvqid, (intptr_t)input) != E_OK) {
+			NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+			NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+			syscall(rel_net_buf(input));
+			}
+		}
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+	else if (cep->rcv_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+		/* p_dstaddr ãè¨­å®ããã*/
+		cep->rcv_p_dstaddr->portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&cep->rcv_p_dstaddr->ipaddr, input);
+
+		/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+		memcpy(cep->rcv_data, GET_UDP_SDU(input, off),
+		       (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
+		syscall(rel_net_buf(input));
+
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
+#endif
+		else
+			syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+		cep->rcv_p_dstaddr = NULL;
+		}
+
+#endif/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+	else if (IS_PTR_DEFINED(cep->callback)) {
+
+		/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		cep->cb_netbuf = input;
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
+#else
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
+#endif
+		/*
+		 *  ãããã¯ã¼ã¯ãããã¡ããã®ã¾ã¾ã§ããã°ãã³ã¼ã«ããã¯é¢æ°å
+ã§
+		 *  ãã¼ã¿ãèª­ã¿åºããªãã£ããã¨ã«ãªãã®ã§ãæ¨ã¦ãã
+		 */
+		if (cep->cb_netbuf != NULL)
+			syscall(rel_net_buf(cep->cb_netbuf));
+		}
+	else {
+		NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+		NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+		syscall(rel_net_buf(input));
+		}
+
+	}
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) || (TNUM_UDP4_CEPID > 0) */
+
+/*
+ *  udp_input -- UDP ã®å
+¥åé¢æ°
+ */
+
+uint_t
+UDP_INPUT (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	uint_t		hlen, ulen;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4
+	T_UDP6_CEP	*cep6;
+#endif
+
+	hlen = (uint_t)GET_IF_IP_HDR_SIZE(input);
+
+	NET_COUNT_UDP(net_count_udp.in_octets,  input->len - hlen);
+	NET_COUNT_UDP(net_count_udp.in_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInDatagrams, 1);
+
+	/* ãããé·ããã§ãã¯ããã*/
+	if (input->len < hlen + UDP_HDR_SIZE)
+		goto buf_rel;
+
+	udph = (T_UDP_HDR *)(input->buf + *offp);
+
+	/* ãã¼ã¿ã°ã©ã é·ããã§ãã¯ãã */
+	ulen  = ntohs(udph->ulen);
+	if (ulen != input->len - hlen)
+		goto buf_rel;
+
+	/* å®å
+ãã¼ãã 0 ã®ãã¼ã¿ã°ã©ã ã¯ç ´æ£ãããRFC768 */
+	if (udph->dport == 0)
+		goto buf_rel;
+
+#ifdef UDP_CFG_IN_CHECKSUM
+
+	/* ãã§ãã¯ãµã ããã§ãã¯ãã */
+	if (udph->sum && IN_CKSUM(input, IPPROTO_UDP, *offp, ulen) != 0)
+		goto buf_rel;
+
+#endif	/* of #ifdef UDP_CFG_IN_CHECKSUM */
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4
+
+#if TNUM_UDP4_CEPID > 0
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = udp4_find_cep(input, *offp);
+
+	if (cep != NULL)
+		udp4_input_select(cep, input, *offp);
+	else if ((cep6 = udp6_find_cep(input, *offp)) != NULL)
+		udp6_input_select(cep6, input, *offp);
+	else
+		udp4_reply_no_port(input, *offp);
+
+	return IPPROTO_DONE;
+
+#else	/* of #if TNUM_UDP4_CEPID > 0 */
+
+	cep = 0;	/* warning åé¿ç¨ã®ããã¼ */
+	if ((cep6 = udp6_find_cep(input, *offp)) != NULL)
+		udp6_input_select(cep6, input, *offp);
+	else
+		udp4_reply_no_port(input, *offp);
+
+	return IPPROTO_DONE;
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4 */
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = UDP_FIND_CEP(input, *offp);
+
+	if (cep != NULL)
+		UDP_INPUT_SELECT(cep, input, *offp);
+	else
+		UDP_REPLY_NO_PORT(input, *offp);
+
+	return IPPROTO_DONE;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4 */
+
+buf_rel:
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_output.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_output.c	(revision 331)
@@ -0,0 +1,175 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp_output -- UDP ã®åºåé¢æ°
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãçµã¿è¾¼ãã ã¨ãä½¿ç¨ããã
+ */
+
+static void
+UDP_OUTPUT (T_UDP_CEP *cep)
+{
+	T_NET_BUF	*output;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+	uint16_t	sum;
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* IP ãã¼ã¿ã°ã©ã ãå²ãå½ã¦ãã*/
+	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + cep->snd_len), 0,
+	                             &cep->snd_p_dstaddr->ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_UDP, IP_DEFTTL, 
+	                             NBA_SEARCH_ASCENT, TMO_UDP_OUTPUT)) != E_OK) {
+		goto err_ret;
+		}
+
+	/* UDP ãããã«æ
+å ±ãè¨­å®ããã*/
+	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET(output));
+	udph->sport	= htons(cep->myaddr.portno);
+	udph->dport	= htons(cep->snd_p_dstaddr->portno);
+	udph->ulen	= htons(UDP_HDR_SIZE + cep->snd_len);
+	udph->sum	= 0;
+
+	/* ãã¼ã¿ãã³ãã¼ããã*/
+	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET(output)),
+	       cep->snd_data, (size_t)cep->snd_len);
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+
+	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET(output),
+	               (uint_t)(UDP_HDR_SIZE + cep->snd_len));
+
+	/* è¨ç®ãããã§ãã¯ãµã ã®å¤ã 0 ãªã 0xffff ãå
+¥ããã*/
+	if (sum == 0)
+		sum = UINT_C(0xffff);
+	udph->sum = sum;
+
+#endif/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE(output) + cep->snd_len);
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	if ((error = IP_OUTPUT(output, TMO_UDP_OUTPUT)) != E_OK)
+		goto err_ret;
+
+
+	NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
+
+	if (IS_PTR_DEFINED(cep->callback)) {
+
+		if (error == E_OK)
+			error = cep->snd_len;
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
+#else
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+#endif
+		}
+	else
+		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+	cep->snd_p_dstaddr = NULL;
+	return;
+
+err_ret:
+	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
+	if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)E_NOMEM);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		error = E_NOMEM;
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		}
+	else
+		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+	cep->snd_p_dstaddr = NULL;
+	return;
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_subr.c	(revision 331)
@@ -0,0 +1,170 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp_alloc_auto_port -- èªåå²ãå½ã¦ãã¼ãçªå·ãè¨­å®ããã
+ */
+
+ER
+UDP_ALLOC_AUTO_PORT (T_UDP_CEP *cep)
+{
+	int_t	ix;
+	uint16_t	portno, portno_start;
+
+	portno_start = udp_port_auto;
+	do {
+		portno = udp_port_auto ++;
+		if (udp_port_auto > UDP_PORT_LAST_AUTO)
+			udp_port_auto = UDP_PORT_FIRST_AUTO;
+
+		syscall(wai_sem(SEM_UDP_CEP));
+		for (ix = TMAX_UDP_CEPID; ix -- > 0; ) {
+			if (VALID_UDP_CEP(&UDP_CEP[ix]) && UDP_CEP[ix].myaddr.portno == portno) {
+				portno = UDP_PORTANY;
+				break;
+				}
+			}
+
+		if (portno != UDP_PORTANY) {
+			cep->myaddr.portno = portno;
+			syscall(sig_sem(SEM_UDP_CEP));
+			return E_OK;
+			}
+		syscall(sig_sem(SEM_UDP_CEP));
+
+		} while (portno_start != udp_port_auto);
+
+	return E_NOID;
+	}
+
+/*
+ *  udp_alloc_port -- æå®ããããã¼ãçªå·ãè¨­å®ããã
+ */
+
+ER
+UDP_ALLOC_PORT (T_UDP_CEP *cep, uint16_t portno)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_UDP_CEP));
+	for (ix = TMAX_UDP_CEPID; ix -- > 0; )
+		if (VALID_UDP_CEP(&UDP_CEP[ix]) && UDP_CEP[ix].myaddr.portno == portno) {
+			syscall(sig_sem(SEM_UDP_CEP));
+			return E_PAR;
+			}
+	cep->myaddr.portno = portno;
+	syscall(sig_sem(SEM_UDP_CEP));
+	return E_OK;
+	}
+
+/*
+ *  udp_find_cep -- ãã¼ãçªå·ãã UDP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+T_UDP_CEP*
+UDP_FIND_CEP (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_CEP*	cep;
+	T_UDP_HDR	*udph;
+
+	udph = GET_UDP_HDR(input, off);
+	
+	/*
+	 *  IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ãä¸è´ããéä¿¡ç«¯ç¹ãæ¢ç´¢ããã
+	 */
+	for (cep = &UDP_CEP[TMAX_UDP_CEPID]; cep -- != UDP_CEP; ) {
+		if (VALID_UDP_CEP(cep)                                &&
+		    UDP_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		    ntohs(udph->dport) == cep->myaddr.portno)
+			return cep;
+		}
+
+	return NULL;
+	}
+
+/*
+ *  udp_notify -- ICMP ã¨ã©ã¼ã®å¦ç
+ */
+
+void
+UDP_NOTIFY (T_NET_BUF *input, ER error)
+{
+	if (UDP_FIND_CEP(input, GET_UDP_HDR_OFFSET(input)) != NULL) {
+		syslog(LOG_NOTICE, "[UDP] error, code: %d.", error);
+		}
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c	(revision 331)
@@ -0,0 +1,836 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+#ifdef __udp_send_data
+
+/*
+ *  udp_send_data -- ãã±ããéä¿¡ã®ä¸»è¦é¨
+ */
+
+ER_UINT
+UDP_SEND_DATA (T_UDP_CEP *cep, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*output;
+	T_UDP_HDR	*udph;
+	SYSTIM		before, after;
+	ER		error = E_OK;
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+	uint16_t	sum;
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	NET_COUNT_UDP(net_count_udp.out_octets,  len);
+	NET_COUNT_UDP(net_count_udp.out_packets, 1);
+
+	/* IP ãã¼ã¿ã°ã©ã å²ãå½ã¦ã®æéã tmout ããæ¸ããã*/
+	if (!(tmout == TMO_POL || tmout == TMO_FEVR))
+		syscall(get_tim(&before));
+
+	/* IP ãã¼ã¿ã°ã©ã ãå²ãå½ã¦ãã*/
+	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + len), 0,
+	                             &p_dstaddr->ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_UDP, IP_DEFTTL, 
+	                             NBA_SEARCH_ASCENT, tmout)) != E_OK)
+		goto err_ret;
+
+	/* IP ãã¼ã¿ã°ã©ã å²ãå½ã¦ã®æéã tmout ããæ¸ããã*/
+	if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
+		syscall(get_tim(&after));
+		if (after - before > tmout) {
+			syscall(rel_net_buf(output));
+			error = E_TMOUT;
+			goto err_ret;
+			}
+		tmout -= (TMO)(after - before);
+		}
+
+	/* UDP ãããã«æ
+å ±ãè¨­å®ããã*/
+	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET(output));
+	udph->sport	= htons(cep->myaddr.portno);
+	udph->dport	= htons(p_dstaddr->portno);
+	udph->ulen	= htons(UDP_HDR_SIZE + len);
+	udph->sum	= 0;
+
+	/* ãã¼ã¿ãã³ãã¼ããã*/
+	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET(output)), data, (size_t)len);
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+
+	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET(output), (uint_t)(UDP_HDR_SIZE + len));
+
+	/* è¨ç®ãããã§ãã¯ãµã ã®å¤ã 0 ãªã 0xffff ãå
+¥ããã*/
+	if (sum == 0)
+		sum = 0xffff;
+	udph->sum = sum;
+
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE(output) + len);
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	if ((error = IP_OUTPUT(output, tmout)) == E_OK) {
+		NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
+		cep->snd_tskid = TA_NULL;
+		return len;
+		}
+
+err_ret:
+	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
+	cep->snd_tskid = TA_NULL;
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_send_data */
+
+/*
+ *  udp_cancel_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çãã­ã£ã³ã»ã«ããã
+ *
+ *    udp_can_cep ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+#ifdef __udp_can_cep
+
+static ER
+UDP_CANCEL_CEP (T_UDP_CEP *cep, FN fncd)
+{
+	ER	error = E_OK, snd_err, rcv_err;
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* API æ©è½ã³ã¼ãããã§ãã¯ããã*/
+	if (!VALID_TFN_UDP_CAN(fncd))
+		return E_PAR;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (fncd == TFN_UDP_ALL) {	/* TFN_UDP_ALL ã®å¦ç */
+
+		snd_err = UDP_CAN_SND(cep, E_RLWAI);
+		rcv_err = UDP_CAN_RCV(cep, E_RLWAI);
+
+		/*
+		 *  snd_err ã¨ rcv_err ã®ã©ã¡ãã EV_NOPND
+		 *  ãªãããã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
+		 */
+		if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
+			error = E_OBJ;
+		else {
+			if (snd_err == EV_NOPND)
+				snd_err = E_OK;
+			if (rcv_err == EV_NOPND)
+				rcv_err = E_OK;
+
+			if (snd_err != E_OK)
+				error = snd_err;
+			else if (rcv_err != E_OK)
+				error = rcv_err;
+			}
+		}
+	else if (fncd == TFN_UDP_SND_DAT) {	/* éä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = UDP_CAN_SND(cep, E_RLWAI)) == EV_NOPND)
+			error = E_OBJ;
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {	/* åä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = UDP_CAN_RCV(cep, E_RLWAI)) == EV_NOPND)
+			error = E_OBJ;
+		}
+	else
+		error = E_PAR;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_cep */
+
+#if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0)
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
+
+/*
+ *  udp_can_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çã®ã­ã£ã³ã»ã«ãæ¨æºæ©è½ã
+ */
+
+#ifdef __udp_can_cep
+
+ER
+udp_can_cep (ID cepid, FN fncd)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_CANCEL_CEP(cep, fncd);
+	}
+
+#endif	/* of #ifdef __udp_can_cep */
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+/*
+ *  udp_cre_cep -- UDP éä¿¡ç«¯ç¹ã®çæãæ¡å¼µæ©è½ã
+ */
+
+#ifdef __udp_cre_cep
+
+ER
+UDP_CRE_CEP (ID cepid, T_UDPN_CCEP *pk_ccep)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* pk_ccep ã NULL ãªãã¨ã©ã¼ */
+	if (pk_ccep == NULL)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&pk_ccep->myaddr.ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (VALID_UDP_CEP(cep))
+		return E_OBJ;
+
+	/* UDP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_UDP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * UDP éä¿¡ç«¯ç¹ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
+	 */
+	if (VALID_UDP_CEP(cep))
+		error = E_OBJ;
+	else {
+
+		/*
+		 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+		 */
+		if (pk_ccep->myaddr.portno == UDP_PORTANY)
+			error = UDP_ALLOC_AUTO_PORT(cep);
+		else 
+			error = UDP_ALLOC_PORT(cep, pk_ccep->myaddr.portno);
+		
+                if (error == E_OK) {
+
+			/* UDP éä¿¡ç«¯ç¹çææ
+å ±ãã³ãã¼ããã*/
+			cep->cepatr        = pk_ccep->cepatr;			/* éä¿¡ç«¯ç¹å±æ§		*/
+			cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+			cep->callback      = (void*)pk_ccep->callback;		/* ã³ã¼ã«ããã¯		*/
+
+			/* UDP éä¿¡ç«¯ç¹ãçææ¸ã¿ã«ããã*/
+			cep->flags |= UDP_CEP_FLG_VALID;
+			}
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_cre_cep */
+
+#ifdef __udp_del_cep
+
+/*
+ *  udp_delete_cep -- UDP éä¿¡ç«¯ç¹ãåé¤ããã
+ *
+ *    udp_del_cep ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_DELETE_CEP (T_UDP_CEP *cep)
+{
+	ER	error;
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* UDP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_UDP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * UDP éä¿¡ç«¯ç¹ããã§ãã¯ãããæªçæã®å ´åã¯ã¨ã©ã¼
+	 * ã»æªçæã
+	 */
+	if (!VALID_UDP_CEP(cep))
+		error = E_NOEXS;
+	else {
+		UDP_CAN_SND(cep, E_DLT);
+		UDP_CAN_RCV(cep, E_DLT);
+
+		/* UDP éä¿¡ç«¯ç¹ãæªçæã«ããã*/
+		cep->flags &= ~UDP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  udp_del_cep -- UDP éä¿¡ç«¯ç¹ã®åé¤ãæ¡å¼µæ©è½ã
+ */
+
+ER
+UDP_DEL_CEP (ID cepid)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_DELETE_CEP(cep);
+	}
+
+#endif	/* of #ifdef __udp_del_cep */
+
+#ifdef __udp_set_opt
+
+/*
+ *  udp_set_option -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ãè¨­å®ããã
+ *
+ *    udp_set_opt ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_SET_OPTION (T_UDP_CEP *cep, int_t optname, void *optval, int_t optlen)
+{
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+#if defined(SUPPORT_INET6)
+#endif
+#if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
+	switch (optname) {
+	case IP_MULTICAST_LOOP:
+		if (optlen >= sizeof(uint8_t)) {
+			return igmp_set_loop(cep, *(uint8_t *)optval);
+			}
+		break;
+	case IP_MULTICAST_TTL:
+		if (optlen >= sizeof(uint8_t)) {
+			return igmp_set_ttl(cep, *(uint8_t *)optval);
+			}
+		break;
+	case IP_MULTICAST_IF:
+		if (optlen >= sizeof(T_IN4_ADDR)) {
+			return igmp_set_if(cep, (T_IN4_ADDR *)optval);
+			}
+		break;
+	case IP_ADD_MEMBERSHIP:
+		if (optlen >= sizeof(T_IP_MREQ)) {
+			return igmp_add_membership(cep, (T_IP_MREQ *)optval);
+			}
+		break;
+	case IP_DROP_MEMBERSHIP:
+		if (optlen >= sizeof(T_IP_MREQ)) {
+			return igmp_drop_membership(cep, (T_IP_MREQ *)optval);
+			}
+		break;
+	case IP_MSFILTER:
+		if (optlen >= sizeof(T_IP_MSFILTER)) {
+			return igmp_set_ip_msfilter(cep, (T_IP_MSFILTER *)optval);
+			}
+		break;
+		}
+#endif
+	return E_PAR;
+	}
+
+/*
+ *  udp_set_opt -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®è¨­å®ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+ER
+UDP_SET_OPT (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_SET_OPTION(cep, optname, optval, optlen);
+	}
+
+#endif	/* of #ifdef __udp_set_opt */
+
+#ifdef __udp_get_opt
+
+/*
+ *  udp_get_option -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ãç²å¾ããã
+ *
+ *    udp_get_opt ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_GET_OPTION (T_UDP_CEP *cep, int_t optname, void *optval, int_t optlen)
+{
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+#if defined(SUPPORT_INET6)
+#endif
+#if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
+	switch (optname) {
+	case IP_MULTICAST_LOOP:
+		if (optlen >= sizeof(uint8_t)) {
+			return igmp_get_loop(cep, (uint8_t *)optval);
+			}
+		break;
+	case IP_MULTICAST_TTL:
+		if (optlen >= sizeof(uint8_t)) {
+			return igmp_get_ttl(cep, (uint8_t *)optval);
+			}
+		break;
+	case IP_MULTICAST_IF:
+		if (optlen >= sizeof(uint32_t)) {
+			return igmp_get_if(cep, (uint32_t *)optval);
+			}
+		break;
+	case IP_MSFILTER:
+		if (optlen >= sizeof(T_IP_MSFILTER)) {
+			return igmp_get_ip_msfilter(cep, (T_IP_MSFILTER *)optval);
+			}
+		break;
+		}
+#endif
+	return E_PAR;
+	}
+
+/*
+ *  udp_get_opt -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®ç²å¾ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+ER
+UDP_GET_OPT (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_GET_OPTION(cep, optname, optval, optlen);
+	}
+
+#endif	/* of #ifdef __udp_get_opt */
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+#else	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#ifdef __udp_can_snd
+
+/*
+ *  udp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_SND (T_UDP_CEP *cep, ER error)
+{
+	if (cep->snd_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->snd_tskid);
+		cep->snd_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_snd */
+
+#ifdef __udp_can_rcv
+
+/*
+ *  udp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_RCV (T_UDP_CEP *cep, ER error)
+{
+	if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->rcv_tskid);
+		cep->rcv_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_rcv */
+
+#ifdef __udp_snd_dat
+
+/*
+ *  udp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+	/* ãã¼ã¿é·ããã§ãã¯ããã*/
+	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+	 */
+	if (cep->myaddr.portno == UDP_PORTANY) {
+		if ((error = UDP_ALLOC_AUTO_PORT(cep)) != E_OK)
+			return error;
+		}
+	
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (cep->snd_tskid != TA_NULL) {
+
+		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		error = E_QOVR;
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		}
+	else {
+		/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+		get_tid(&(cep->snd_tskid));
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ããªã»ããããã*/
+		cep->error = E_OK;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/* ãã±ãããéä¿¡ããã*/
+		error = UDP_SEND_DATA(cep, p_dstaddr, data, len, tmout);
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¿ãã*/
+		if (error == E_RLWAI)
+			error = cep->error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_snd_dat */
+
+#ifdef __udp_rcv_dat
+
+/*
+ *  udp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*input;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+	uint_t		ulen, uhoff;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (cep->rcv_tskid != TA_NULL) {
+
+		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		error = E_QOVR;
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		}
+	else {
+
+		/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+		get_tid(&(cep->rcv_tskid));
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ããªã»ããããã*/
+		cep->error = E_OK;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/* å
+¥åãããã¾ã§å¾
+ã¤ã*/
+		if (cep->cb_netbuf != NULL) {
+
+			/*
+			 *  ããã«ããå ´åã¯ãã³ã¼ã«ããã¯é¢æ°ã®ä¸­ãã
+			 *  udp_rcv_dat ãå¼ã³åºãã¦ãããã¨ã«ãªãã
+			 *  ãã§ã«å
+¥åæ¸ã¿ã§ããã
+			 */
+			input = cep->cb_netbuf;
+			cep->cb_netbuf = NULL;
+			}
+		else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
+
+#ifdef UDP_CFG_EXTENTIONS
+
+			/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¿ãã*/
+			if (error == E_RLWAI)
+				error = cep->error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+			cep->rcv_tskid = TA_NULL;
+			return error;
+			}
+
+		/* p_dstaddr ãè¨­å®ããã*/
+		uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
+		udph = GET_UDP_HDR(input, uhoff);
+		p_dstaddr->portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&p_dstaddr->ipaddr, input);
+
+		/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+		ulen = ntohs(udph->ulen);
+		if (ulen - UDP_HDR_SIZE > len)
+			error = E_BOVR;
+		else {
+			len   =    (uint_t)(ulen - UDP_HDR_SIZE);
+			error = (ER_UINT)(ulen - UDP_HDR_SIZE);
+			}
+
+		memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
+
+		syscall(rel_net_buf(input));
+
+		cep->rcv_tskid = TA_NULL;
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_rcv_dat */
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c	(revision 331)
@@ -0,0 +1,427 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+#ifdef __udp_can_snd_nblk
+
+/*
+ *  udp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_SND (T_UDP_CEP *cep, ER error)
+{
+	if (cep->snd_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+#endif
+		else
+			error = E_OBJ;
+		cep->snd_p_dstaddr = NULL;
+		}
+	else if (cep->snd_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->snd_tskid);
+		cep->snd_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_snd_nblk */
+
+#ifdef __udp_can_rcv_nblk
+
+/*
+ *  udp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_RCV (T_UDP_CEP *cep, ER error)
+{
+	if (cep->rcv_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
+#endif
+		else
+			error = E_OBJ;
+		cep->rcv_p_dstaddr = NULL;
+		}
+	else if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->rcv_tskid);
+		cep->rcv_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_rcv_nblk */
+
+#ifdef __udp_snd_dat_nblk
+
+/*
+ *  udp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL)
+		return E_PAR;
+
+	/* ãã¼ã¿é·ããã§ãã¯ããã*/
+	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+	 */
+	if (cep->myaddr.portno == UDP_PORTANY) {
+		if ((error = UDP_ALLOC_AUTO_PORT(cep)) != E_OK)
+			return error;
+		}
+
+	/*
+	 * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
+	 */
+	if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->snd_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->snd_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			cep->snd_p_dstaddr = p_dstaddr;
+			cep->snd_data	= data;
+			cep->snd_len	= len;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_UDP_POST_OUTPUT);
+			error = E_WBLK;
+			}
+		}
+	else {				/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+	
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->snd_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->snd_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+			get_tid(&(cep->snd_tskid));
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* ãã±ãããéä¿¡ããã*/
+			error = UDP_SEND_DATA(cep, p_dstaddr, data, len, tmout);
+			}
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_snd_dat_nblk */
+
+#ifdef __udp_rcv_dat_nblk
+
+/*
+ *  udp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*input;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+	uint_t		ulen, uhoff;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || len < 0)
+		return E_PAR;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
+	 */
+
+	if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->rcv_p_dstaddr != NULL)
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+		else if (cep->rcv_tskid != TA_NULL)
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+		else {
+			cep->rcv_p_dstaddr = p_dstaddr;
+			cep->rcv_data	= data;
+			cep->rcv_len	= len;
+			error = E_WBLK;
+			}
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		return error;
+		}
+	else {				/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->rcv_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->rcv_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+			get_tid(&(cep->rcv_tskid));
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* å
+¥åãããã¾ã§å¾
+ã¤ã*/
+			if (cep->cb_netbuf != NULL) {
+
+				/*
+				 *  ããã«ããå ´åã¯ãã³ã¼ã«ããã¯é¢æ°ã®ä¸­ãã
+				 *  udp_rcv_dat ãå¼ã³åºãã¦ãããã¨ã«ãªãã
+				 *  ãã§ã«å
+¥åæ¸ã¿ã§ããã
+				 */
+				input = cep->cb_netbuf;
+				cep->cb_netbuf = NULL;
+				}
+			else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
+				cep->rcv_tskid = TA_NULL;
+				return error;
+				}
+
+			/* p_dstaddr ãè¨­å®ããã*/
+			uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
+			udph = GET_UDP_HDR(input, uhoff);
+			p_dstaddr->portno = ntohs(udph->sport);
+			IN_COPY_TO_HOST(&p_dstaddr->ipaddr, input);
+
+			/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+			ulen = ntohs(udph->ulen);
+			if (ulen - UDP_HDR_SIZE > len)
+				error = E_BOVR;
+			else {
+				len   =     (int_t)(ulen - UDP_HDR_SIZE);
+				error = (ER_UINT)(ulen - UDP_HDR_SIZE);
+				}
+
+			memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
+
+			syscall(rel_net_buf(input));
+
+			cep->rcv_tskid = TA_NULL;
+			}
+		return error;
+		}
+	}
+
+#endif	/* of #ifdef __udp_rcv_dat_nblk */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h	(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
  *
@@ -67,6 +67,4 @@
 #define _AH_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  RFC2402 認証ヘッダ
@@ -80,7 +78,5 @@
 	uint32_t	spi;	/* Security Parameter Index (SPI)	*/
 	uint32_t	seq;	/* シーケンス番号			*/
-	} __attribute__((packed, aligned(2)))T_IP6_AH_HDR;
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+	} __attribute__((packed, aligned(2))) T_IP6_AH_HDR;
 
 #endif	/* of #ifndef _AH_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h	(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
  *
@@ -67,6 +67,4 @@
 #define _AH6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
@@ -75,5 +73,3 @@
 extern uint_t ah6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _AH6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.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
  *
@@ -82,4 +82,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/if.h>
 #include <net/if_loop.h>
@@ -92,14 +93,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah.h>
 #include <netinet6/ah6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -116,3 +116,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.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
  *
@@ -88,16 +88,16 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -163,3 +163,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h	(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
  *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
@@ -68,6 +68,4 @@
 #define _ESP_H_
 
-#if defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC)
-
 /*
  *  RFC2406 暗号化ヘッダ
@@ -129,5 +127,3 @@
 #endif	/* of #ifdef T_IPSEC_REQUEST_DEFINED */
 
-#endif /* defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC) */
-
 #endif	/* of #ifndef _ESP_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h	(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
  *
@@ -67,6 +67,4 @@
 #define _ESP6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
@@ -75,5 +73,3 @@
 extern uint_t esp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _ESP6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.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
  *
@@ -88,14 +88,14 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah.h>
 #include <netinet6/ah6.h>
@@ -103,5 +103,5 @@
 #include <netinet6/esp6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -122,3 +122,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.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
  *
@@ -92,4 +92,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_var.h>
@@ -97,12 +98,11 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 #ifdef IP6_CFG_FRAGMENT
@@ -606,5 +606,5 @@
 			/* 送信先アドレスを元に戻す。*/
 			ip6h = GET_IP6_HDR(input);
-			ip6h->dst = ip6_frag_dest[ip6fq - ip6_frag_queue];
+			memcpy(&ip6h->dst, &ip6_frag_dest[ip6fq - ip6_frag_queue], sizeof(T_IN6_ADDR));
 
 			/* offp を、再構成した断片の先頭に設定する。*/
@@ -669,3 +669,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.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
  *
@@ -106,4 +106,5 @@
 #include <sil.h>
 #include <t_syslog.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -113,4 +114,5 @@
 #include <s_services.h>
 #include <t_services.h>
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -124,4 +126,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -130,15 +133,14 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 /*
@@ -178,5 +180,5 @@
 		return;
 		}
-	ip6h->src = ia->addr;
+	memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
 
 	icmp6h = GET_ICMP6_HDR(output, off);
@@ -241,7 +243,7 @@
 
 	/* IPv6 ヘッダの発信元アドレスと宛先アドレスを入替える。*/
-	dst 	  = ip6h->dst;
-	ip6h->dst = ip6h->src;
-	ip6h->src = dst;
+	memcpy(&dst, &ip6h->dst, sizeof(T_IN6_ADDR));
+	memcpy(&ip6h->dst, &ip6h->src, sizeof(T_IN6_ADDR));
+	memcpy(&ip6h->src, &dst, sizeof(T_IN6_ADDR));
 
 	/*
@@ -256,10 +258,10 @@
 			}
 		else
-			ip6h->src = ia->addr;
+			memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
 		}
 
 	/* 次ヘッダとホップリミットを設定する。*/
 	ip6h->next = IPPROTO_ICMPV6;
-	ip6h->hlim = IP_DEFTTL;
+	ip6h->hlim = IP6_DEFTTL;
 
 	/* チェックサムを計算する。*/
@@ -299,15 +301,26 @@
 	loff = ip6_lasthdr(input, poff + ICMP6_HDR_SIZE, IPPROTO_IPV6, &next);
 
-	/* 最終ヘッダが TCP のみ対応する。*/
-	if (loff >= 0 && next == IPPROTO_TCP) {
-
-#ifdef SUPPORT_TCP
+	/* 最終ヘッダが TCP/UDP のみ対応する。*/
+	if (loff >= 0 && (next == IPPROTO_TCP || next == IPPROTO_UDP)) {
 
 		memcpy(GET_IP6_HDR(input), input->buf + (loff + ICMP6_HDR_SIZE),
 		                           input->len - (loff + ICMP6_HDR_SIZE));
 		input->len -= loff + ICMP6_HDR_SIZE;
-		tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
-
-#endif	/* of #ifdef SUPPORT_TCP */
+
+#if defined(SUPPORT_TCP)
+
+		if (next == IPPROTO_TCP)
+
+			tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+		if (next == IPPROTO_UDP)
+
+			udp6_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
 
 		}
@@ -340,5 +353,6 @@
 #endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 /*
@@ -350,5 +364,5 @@
 {
 	T_IP6_HDR		*ip6h;
-	T_IN6_ADDR		*gw;
+	const T_IN6_ADDR	*gw;
 	T_ND_REDIRECT_HDR	*rdh;
 	T_ND_OPT_HDR		*opth;
@@ -440,5 +454,6 @@
 	}
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
 
 /*
@@ -472,5 +487,5 @@
 
 	/* チェックサムを計算する。*/
-	if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP_HDR_SIZE)) & 0xffff) != 0) {
+	if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE)) & 0xffff) != 0) {
 		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
 		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
@@ -530,5 +545,6 @@
 		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRedirects, 1);
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 		if (code != 0 || len < ND_REDIRECT_HDR_SIZE)
@@ -537,9 +553,14 @@
 		return IPPROTO_DONE;
 
-#else	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
+
+		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
+
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
 
 		break;
@@ -571,5 +592,5 @@
 	case ICMP6_FQDN_QUERY:			/* FQDN 照会			*/
 	case ICMP6_FQDN_REPLY:			/* FQDN 応答			*/
-		syslog(LOG_WARNING, "[ICMP6] unsupported type: %d.", icmp6h->type);
+		syslog(LOG_INFO, "[ICMP6] unsupported type: %d.", icmp6h->type);
 		break;
 
@@ -693,3 +714,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.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
  *
@@ -87,4 +87,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_timer.h>
 #include <net/net_buf.h>
@@ -92,4 +93,5 @@
 
 #include <netinet/in.h>
+#include <netinet/in_var.h>
 #include <netinet/ip.h>
 #include <netinet/if_ether.h>
@@ -98,7 +100,7 @@
 #include <netinet6/in6_var.h>
 
-#include <net/if6_var.h>
+#include <net/if_var.h>
 
-#if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER)
+#if defined(_IP6_CFG) && defined(SUPPORT_ETHER)
 
 /*
@@ -107,5 +109,5 @@
 
 void
-ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr)
+ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr)
 {
 	eaddr->lladdr[0] = UINT_C(0x33);
@@ -117,3 +119,3 @@
 	}
 
-#endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER) */
+#endif /* of #if defined(_IP6_CFG) && defined(SUPPORT_ETHER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h	(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
  *
@@ -68,13 +68,9 @@
 #define _IF6_ETHER_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
  */
 
-extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr);
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr);
 
 #endif	/* of #ifndef _IF6_ETHER_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.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
  *
@@ -126,7 +126,11 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
 #include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
@@ -135,7 +139,7 @@
 #include <netinet6/in6_ifattach.h>
 
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -143,11 +147,11 @@
  */
 
-T_IN6_ADDR in6_addr_unspecified =
+const T_IN6_ADDR in6_addr_unspecified =
 	IPV6_ADDR_UNSPECIFIED_INIT;
 
-T_IN6_ADDR in6_addr_linklocal_allnodes =
+const T_IN6_ADDR in6_addr_linklocal_allnodes =
 	IPV6_ADDR_LINKLOCAL_ALLNODES_INIT;
 
-T_IN6_ADDR in6_addr_linklocal_allrouters =
+const T_IN6_ADDR in6_addr_linklocal_allrouters =
 	IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT;
 
@@ -172,5 +176,5 @@
 
 static ER
-in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr, uint_t prefix_len)
+in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr, uint_t prefix_len)
 {
 	/* アドレスとプレフィックス長を設定する。*/
@@ -200,5 +204,5 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		memset(ia, sizeof(T_IN6_IFADDR), 0);
 		ia->router_index = IN6_RTR_IX_UNREACH;
@@ -226,5 +230,5 @@
 
 int_t
-in6_addr2ifaix (T_IN6_ADDR *addr)
+in6_addr2ifaix (const T_IN6_ADDR *addr)
 {
 	T_IFNET		*ifp = IF_GET_IFNET();
@@ -233,5 +237,5 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
 		    in6_are_prefix_equal(addr, &ia->addr, ia->prefix_len))
@@ -247,5 +251,5 @@
 
 int_t
-in6_addr2maix (T_IN6_ADDR *addr)
+in6_addr2maix (const T_IN6_ADDR *addr)
 {
 	if (addr->s6_addr8[0] == 0xff) {
@@ -268,5 +272,5 @@
 
 ER
-in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
+in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
                 uint_t prefix_len, uint32_t vltime, uint32_t pltime,
                 int_t router_index, int_t prefix_index, uint_t flags)
@@ -365,5 +369,5 @@
 in6ifa_ifpwithix (T_IFNET *ifp, int_t ix)
 {
-	return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in_ifaddrs[ix] : NULL;
+	return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in6_ifaddrs[ix] : NULL;
 	}
 
@@ -379,16 +383,16 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
-		if (ifp->in_ifaddrs[ix].router_index == router_index)
-			return &ifp->in_ifaddrs[ix];
+		if (ifp->in6_ifaddrs[ix].router_index == router_index)
+			return &ifp->in6_ifaddrs[ix];
 	return NULL;
 	}
 
 /*
- * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレスを、
+ * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレス情報を、
  *                   ネットワークインタフェースから探索する。
  */
 
 T_IN6_IFADDR *
-in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst)
+in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst)
 {
 	uint_t	scope;
@@ -397,18 +401,36 @@
 	/* 宛先アドレスと同じスコープのアドレスを返す。*/
 	if ((ix = in6_addr2ifaix(dst)) != IPV6_IFADDR_IX_INVALID)
-		return &ifp->in_ifaddrs[ix];
+		return &ifp->in6_ifaddrs[ix];
 	else if ((ix = in6_addr2maix(dst)) == IPV6_MADDR_IX_SOL_NODE ||
 	          ix                       == IPV6_MADDR_IX_LL_ALL_NODE)
-		return &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+		return &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 	else {
 		scope = in6_addrscope(dst);
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-			    (ifp->in_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
-			    in6_addrscope(&ifp->in_ifaddrs[ix].addr) == scope) {
-				return &ifp->in_ifaddrs[ix];
+			if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+			    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
+			    in6_addrscope(&ifp->in6_ifaddrs[ix].addr) == scope) {
+				return &ifp->in6_ifaddrs[ix];
 				}
 			}
 		return NULL;
+		}
+	}
+
+/*
+ * in6_addrwithifp -- 宛先アドレスにふさわしい送信元アドレスを、
+ *                    ネットワークインタフェースから探索する。
+ */
+
+const T_IN6_ADDR *
+in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst)
+{
+	T_IN6_IFADDR *ifaddr;
+
+	if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
+		return NULL;
+	else {
+		*src = ifaddr->addr;
+		return src;
 		}
 	}
@@ -431,7 +453,7 @@
 	dad_delay = 0;
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
-		if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-		    (ifp->in_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
-			nd6_dad_start(ifp, &ifp->in_ifaddrs[ix], &dad_delay);
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
+			nd6_dad_start(ifp, &ifp->in6_ifaddrs[ix], &dad_delay);
 #endif	/* of #if 0 */
 
@@ -449,5 +471,5 @@
 
 bool_t
-in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix, uint_t prefix_len)
+in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix, uint_t prefix_len)
 {
 	uint_t bitlen, bytelen;
@@ -478,5 +500,5 @@
 	syscall(get_tim(&now));
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 
 		if ((ia->flags & IN6_IFF_DEFINED) == 0)
@@ -500,3 +522,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h	(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
  *
@@ -103,4 +103,10 @@
 
 /*
+ *  IPv6 アドレス構造
+ *
+ *    RFC4291（RFC1884、RFC2373、RFC3513 のアップデート）
+ */
+
+/*
  *  IPv6 アドレス
  */
@@ -150,38 +156,4 @@
 
 /*
- *  アドレスの定義
- */
-
-#ifdef _NET_CFG_BYTE_ORDER
-
-#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
-
-#define IPV6_ADDR_INT32_ONE		ULONG_C(0x00000001)
-#define IPV6_ADDR_INT32_TWO		ULONG_C(0x00000002)
-#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0x0000ffff)
-#define IPV6_ADDR_INT32_MNL		ULONG_C(0xff010000)
-#define IPV6_ADDR_INT32_MLL		ULONG_C(0xff020000)
-#define IPV6_ADDR_INT32_ULL		ULONG_C(0xfe800000)
-#define IPV6_ADDR_INT16_ULL		UINT_C(0xfe80)
-#define IPV6_ADDR_INT16_USL		UINT_C(0xfec0)
-#define IPV6_ADDR_INT16_MLL		UINT_C(0xff02)
-
-#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
-
-#define IPV6_ADDR_INT32_ONE		ULONG_C(0x01000000)
-#define IPV6_ADDR_INT32_TWO		ULONG_C(0x02000000)
-#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0xffff0000)
-#define IPV6_ADDR_INT32_MNL		ULONG_C(0x000001ff)
-#define IPV6_ADDR_INT32_MLL		ULONG_C(0x000002ff)
-#define IPV6_ADDR_INT32_ULL		ULONG_C(0x000080fe)
-#define IPV6_ADDR_INT16_ULL		UINT_C(0x80fe)
-#define IPV6_ADDR_INT16_USL		UINT_C(0xc0fe)
-#define IPV6_ADDR_INT16_MLL		UINT_C(0x02ff)
-
-#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
-
-#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
-
-/*
  *  特別なアドレスのチェック
  */
@@ -197,17 +169,4 @@
 	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
 	 (a)->s6_addr8[15] == 0x01)
-
-/* IPv4 互換 */
-
-#define IN6_IS_ADDR_V4COMPAT(a)		\
-	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
-	 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
-
-/* IPv4 マップ */
-
-#define IN6_IS_ADDR_V4MAPPED(a)		\
-	(((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
 
 /*
@@ -248,12 +207,4 @@
 #define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr8[0] == UINT_C(0xff))
 
-/* 要請マルチキャスト */
-
-#define IN6_IS_ADDR_NS_MULTICAST(a)	\
-	(((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
-	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
-	 ((a)->s6_addr8[12] == UINT_C(0xff)))
-
 /*
  *  同一のチェック
@@ -272,5 +223,6 @@
  */
 
-#define IPV6_DEFAULT_MULTICAST_HOPS	1	/* マルチキャスト時のホップリミットの規定値 */
+#define IPV6_DEFAULT_MULTICAST_HOPS	1	/* マルチキャスト時のホップリミットの規定値	*/
+#define ND6_INFINITE_LIFETIME		0xffffffff	/* アドレスの無制限有効時間		*/
 
 /*
@@ -282,4 +234,6 @@
 	uint16_t	portno;		/* ポート番号	*/
 	} T_IPV6EP;
+
+#define T_IPV6EP_DEFINED
 
 /*
@@ -299,8 +253,4 @@
 	/* 実装依存 */
 	} T_TCP6_CREP;
-
-#if defined(SUPPORT_INET6)
-#define T_TCP_CREP	T_TCP6_CREP
-#endif
 
 /*
@@ -316,28 +266,4 @@
 	} T_UDP6_CCEP;
 
-#if defined(SUPPORT_INET6)
-#define T_UDP_CCEP	T_UDP6_CCEP
-#endif
-
-/*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#if defined(SUPPORT_INET6)
-
-#define T_IN_ADDR			T_IN6_ADDR
-#define T_IPEP				T_IPV6EP
-#define IP_ADDRANY			IPV6_ADDRANY
-
-#define IN_ARE_ADDR_EQUAL(n,h)		IN6_ARE_ADDR_EQUAL(n,h)
-#define IN_ARE_NET_ADDR_EQUAL(n,h)	IN6_ARE_ADDR_EQUAL(n,h)
-#define IN_COPY_TO_NET(d,s)		memcpy(d,s,sizeof(T_IN6_ADDR))
-#define IN_COPY_TO_HOST(d,s)		memcpy(d,s,sizeof(T_IN6_ADDR))
-#define IN_IS_ADDR_MULTICAST(a)		IN6_IS_ADDR_MULTICAST(a)
-#define IN_IS_NET_ADDR_MULTICAST(a)	IN6_IS_ADDR_MULTICAST(a)
-#define IN_IS_ADDR_ANY(a)		IN6_IS_ADDR_UNSPECIFIED(a)
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
 /*
  *  前方参照
@@ -356,7 +282,7 @@
  */
 
-extern T_IN6_ADDR in6_addr_unspecified;
-extern T_IN6_ADDR in6_addr_linklocal_allnodes;
-extern T_IN6_ADDR in6_addr_linklocal_allrouters;
+extern const T_IN6_ADDR in6_addr_unspecified;
+extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
+extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
 
 #define ipv6_addrany	in6_addr_unspecified
@@ -366,7 +292,12 @@
  */
 
-extern char *ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr);
-extern ER_UINT in6_get_maxnum_ifaddr (void);
+extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
+extern uint_t in6_get_maxnum_ifaddr (void);
 extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
+extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
+                          uint32_t vltime, uint32_t pltime);
+extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
+extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
+extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
 
 #endif	/* of #ifndef _IN6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.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
  *
@@ -87,4 +87,8 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
@@ -93,7 +97,7 @@
 #include <netinet6/in6_ifattach.h>
 
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -126,4 +130,18 @@
 #endif	/* of #ifdef SUPPORT_ETHER */
 
+#ifdef SUPPORT_PPP
+
+/*
+ * get_rand_ifid -- 乱数により、インタフェース識別子を設定する。
+ */
+
+static ER
+get_rand_ifid (T_IFNET *ifp, T_IN6_ADDR *ifra_addr)
+{
+	return E_OK;
+	}
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
 #ifdef IP6_CFG_AUTO_LINKLOCAL
 
@@ -149,5 +167,5 @@
 
 	/* インタフェースのアドレス情報を更新する。*/
-	if ((error = in6_update_ifa(ifp, &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
+	if ((error = in6_update_ifa(ifp, &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
 	                            &addr, 64, ND6_INFINITE_LIFETIME,
 	                                       ND6_INFINITE_LIFETIME, 
@@ -171,5 +189,5 @@
 #ifdef IP6_CFG_AUTO_LINKLOCAL
 
-	if ((ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
+	if ((ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
 		if ((error = in6_ifattach_linklocal(ifp)) != E_OK)
 			return error;
@@ -180,3 +198,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h	(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
  *
@@ -41,20 +41,17 @@
 /* netinet6/in6.c */
 
+#define in6_are_prefix_equal	_tinet_in6_are_prefix_equal
+#define in6ifa_ifpwithrtrix	_tinet_in6ifa_ifpwithrtrix
+#define in6_if_up		_tinet_in6_if_up
+#define in6_if2idlen		_tinet_in6_if2idlen
+#define in6_ifaddr_timer	_tinet_in6_ifaddr_timer
+#define in6ifa_ifpwithix	_tinet_in6ifa_ifpwithix
+#define in6_addr2maix		_tinet_in6_addr2maix
+#define in6_ifawithifp		_tinet_in6_ifawithifp
+#define in6_addr2ifaix		_tinet_in6_addr2ifaix
+#define in6_update_ifa		_tinet_in6_update_ifa
+#define in6_ifainit		_tinet_in6_ifainit
+#define in6_addrwithifp		_tinet_in6_addrwithifp
 #define in6_addr_loopback	_tinet_in6_addr_loopback
-#define in6_ifainit		_tinet_in6_ifainit
-#define in6_addr2ifaix		_tinet_in6_addr2ifaix
-#define in6_addr2maix		_tinet_in6_addr2maix
-#define in6_update_ifa		_tinet_in6_update_ifa
-#define in6ifa_ifpwithix	_tinet_in6ifa_ifpwithix
-#define in6ifa_ifpwithrtrix	_tinet_in6ifa_ifpwithrtrix
-#define in6_ifawithifp		_tinet_in6_ifawithifp
-#define in6_if_up		_tinet_in6_if_up
-#define in6_rtalloc		_tinet_in6_rtalloc
-#define in6_are_prefix_equal	_tinet_in6_are_prefix_equal
-#define in6_addr_linklocal_allrouters	\
-				_tinet_in6_addr_linklocal_allrouters
-#define in6_addr_linklocal_allnodes	\
-				_tinet_in6_addr_linklocal_allnodes
-#define in6_ifaddr_timer	_tinet_in6_ifaddr_timer
 
 /* netinet6/in6_ifattach.c */
@@ -64,17 +61,23 @@
 /* netinet6/in6_subr.c */
 
+#define inn6_is_dstaddr_accept	_tinet_inn6_is_dstaddr_accept
+#define in6_lookup_ifaddr	_tinet_in6_lookup_ifaddr
+#define in6_rtalloc		_tinet_in6_rtalloc
+#define in6_get_ifaddr		_tinet_in6_get_ifaddr
+#define in6_cksum		_tinet_in6_cksum
+#define in6_gateway_lookup	_tinet_in6_gateway_lookup
+#define in6_is_dstaddr_accept	_tinet_in6_is_dstaddr_accept
+#define in6_hostcache_getmtu	_tinet_in6_hostcache_getmtu
+#define in6_set_header		_tinet_in6_set_header
+#define in6_get_datagram	_tinet_in6_get_datagram
+#define in6_rtredirect		_tinet_in6_rtredirect
+#define get_ip6_hdr_size	_tinet_get_ip6_hdr_size
+#define in6_plen2pmask		_tinet_in6_plen2pmask
+#define in6_rtnewentry		_tinet_in6_rtnewentry
+#define in6_rtinit		_tinet_in6_rtinit
+#define in6_rttimer		_tinet_in6_rttimer
 #define in6_lookup_multi	_tinet_in6_lookup_multi
-#define get_ip6_hdr_size	_tinet_get_ip6_hdr_size
-#define in6_lookup_ifaddr	_tinet_in6_lookup_ifaddr
-#define in6_get_datagram	_tinet_in6_get_datagram
-#define in6_cksum		_tinet_in6_cksum
-#define in6_is_dstaddr_accept	_tinet_in6_is_dstaddr_accept
-#define in6_plen2pmask		_tinet_in6_plen2pmask
+#define in6_hostcache_update	_tinet_in6_hostcache_update
 #define in6_init		_tinet_in6_init
-#define in6_rtredirect		_tinet_in6_rtredirect
-#define in6_gateway_lookup	_tinet_in6_gateway_lookup
-#define in6_set_header		_tinet_in6_set_header
-#define in6_hostcache_getmtu	_tinet_in6_hostcache_getmtu
-#define in6_hostcache_update	_tinet_in6_hostcache_update
 
 /* netinet6/if6_ether.c */
@@ -151,9 +154,17 @@
 /* netinet6/nd6_rtr.c */
 
+#define nd6_get_prl		_tinet_nd6_get_prl
 #define nd6_router_lookup	_tinet_nd6_router_lookup
+#define nd6_onlink_prefix_lookup	\
+				_tinet_nd6_onlink_prefix_lookup
+#define nd6_defrtrlist_del	_tinet_nd6_defrtrlist_del
+#define nd6_prefix_onlink	_tinet_nd6_prefix_onlink
+#define nd6_get_drl		_tinet_nd6_get_drl
+#define nd6_rtrsol_ctl		_tinet_nd6_rtrsol_ctl
 #define nd6_defrtrlist_timer	_tinet_nd6_defrtrlist_timer
+#define nd6_ra_input		_tinet_nd6_ra_input
 #define nd6_prelist_timer	_tinet_nd6_prelist_timer
-#define nd6_ra_input		_tinet_nd6_ra_input
-#define nd6_rtrsol_ctl		_tinet_nd6_rtrsol_ctl
+#define nd6_prefix_offlink	_tinet_nd6_prefix_offlink
+#define nd6_defrtrlist_lookup	_tinet_nd6_defrtrlist_lookup
 #define ip6_defhlim		_tinet_ip6_defhlim
 #define nd6_reachable_time	_tinet_nd6_reachable_time
@@ -162,10 +173,4 @@
 				_tinet_nd6_recalc_reachtm_interval
 #define nd6_retrans_time	_tinet_nd6_retrans_time
-#define nd6_defrtrlist_lookup	_tinet_nd6_defrtrlist_lookup
-#define nd6_prefix_onlink	_tinet_nd6_prefix_onlink
-#define nd6_prefix_offlink	_tinet_nd6_prefix_offlink
-#define nd6_get_prl		_tinet_nd6_get_prl
-#define nd6_get_drl		_tinet_nd6_get_drl
-#define nd6_defrtrlist_del	_tinet_nd6_defrtrlist_del
 
 /* netinet6/scope6.c */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.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
  *
@@ -122,4 +122,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -128,15 +129,128 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <netinet6/nd6.h>
 #include <netinet6/ah.h>
-#include <netinet6/nd6.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+/*
+ *  in6_make_ipv4mapped -- IPv4 射影アドレスを生成する。
+ *
+ *  注意:
+ *    src はホストバイトオーダー
+ *
+ */
+
+T_IN6_ADDR *
+in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src)
+{
+	dst->s6_addr32[0] = ULONG_C(0x00000000);
+	dst->s6_addr32[1] = ULONG_C(0x00000000);
+	dst->s6_addr32[2] = IPV6_ADDR_INT32_0000FFFF;
+	dst->s6_addr32[3] = htonl(src);
+
+	return dst;
+	}
+
+#ifdef _IP6_CFG
+
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in6_rtinit -- ルーティング表を初期化する。
+ */
+
+void
+in6_rtinit (void)
+{
+	int_t ix;
+
+	for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = IN_RTF_DEFINED;
+
+	for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = 0;
+	}
+
+/*
+ *  in6_rtnewentry -- 新しいエントリを獲得する。
+ */
+
+T_IN6_RTENTRY *
+in6_rtnewentry (uint8_t flags, uint32_t tmo)
+{
+	SYSTIM		now;
+	T_IN6_RTENTRY	*rt, *frt = NULL;
+	int_t		ix;
+
+	/* 空きエントリを探す。*/
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+		rt = &routing6_tbl[ix];
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
+			frt = rt;
+			break;
+			}
+		}
+
+	/* expire の単位は [s]。*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (frt == NULL) {
+		/* 空きがなければ、有効時間がもっとも短いエントリを空きにする。*/
+		T_IN6_RTENTRY	*srt = NULL;
+		int_t		diff, sdiff = INT_MAX;
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+			rt = &routing6_tbl[ix];
+			diff = (int_t)(rt->expire - now);
+			if (diff <= 0) {	/* rt->expire <= now */
+				/* 既に、有効時間が過ぎている。*/
+				frt = rt;
+				break;
+				}
+			else if (diff < sdiff) {
+				srt = rt;
+				sdiff = diff;
+				}
+			}
+		if (frt == NULL)
+			frt = srt;
+		frt->flags = 0;
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+		}
+
+	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
+	frt->expire = now + tmo / SYSTIM_HZ;
+	return frt;
+	}
+
+/*
+ *  in6_rttimer -- ルーティング表の管理タイマー
+ */
+
+void
+in6_rttimer (void)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	/* expire の単位は [s]。*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (int_t)(routing6_tbl[ix].expire - now) <= 0)
+			routing6_tbl[ix].flags = 0;
+	syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+	}
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #if NUM_IN6_HOSTCACHE_ENTRY > 0
@@ -155,12 +269,12 @@
 
 T_IN6_IFADDR *
-in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr)
+in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr)
 {
 	int_t ix;
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-		    IN6_ARE_ADDR_EQUAL(addr, &ifp->in_ifaddrs[ix].addr))
-			return &ifp->in_ifaddrs[ix];
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(addr, &ifp->in6_ifaddrs[ix].addr))
+			return &ifp->in6_ifaddrs[ix];
 		}
 	return NULL;
@@ -172,10 +286,10 @@
 
 bool_t
-in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr)
+in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr)
 {
 	int_t ix;
 
 	for (ix = MAX_IN6_MADDR_CNT; ix -- > 0; )
-		if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in_maddrs[ix]))
+		if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in6_maddrs[ix]))
 			return true;
 	return false;
@@ -188,5 +302,5 @@
 ER
 in6_set_header (T_NET_BUF *nbuf, uint_t len,
-                T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                 uint8_t next, uint8_t hlim)
 {
@@ -216,10 +330,10 @@
 		memset(&ip6h->dst, 0, sizeof(T_IN6_ADDR));
 	else
-		ip6h->dst = *dstaddr;
+		memcpy(&ip6h->dst, dstaddr, sizeof(T_IN6_ADDR));
 
 	if (srcaddr == NULL)
 		memset(&ip6h->src, 0, sizeof(T_IN6_ADDR));
 	else
-		ip6h->src = *srcaddr;
+		memcpy(&ip6h->src, srcaddr, sizeof(T_IN6_ADDR));
 
 	return E_OK;
@@ -232,5 +346,5 @@
 ER
 in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                  const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                   uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
 {
@@ -269,5 +383,5 @@
  */
 
-ER_UINT
+uint_t
 in6_get_maxnum_ifaddr (void)
 {
@@ -285,6 +399,6 @@
 
 	if (index < NUM_IN6_IFADDR_ENTRY &&
-	    (ifp->in_ifaddrs[index].flags & IN6_IFF_DEFINED))
-		return &ifp->in_ifaddrs[index].addr;
+	    (ifp->in6_ifaddrs[index].flags & IN6_IFF_DEFINED))
+		return &ifp->in6_ifaddrs[index].addr;
 	else
 		return NULL;
@@ -296,12 +410,12 @@
 
 char *
-ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr)
-{
-	static char	addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:89ab:cdef")];
+ipv62str (char *buf, const T_IN6_ADDR *p_addr)
+{
+	static char	addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:255.255.255.255")];
 	static int_t	bix = NUM_IPV6ADDR_STR_BUFF;
 
 	bool_t	omit = false, zero = false;
 	char	*start;
-	int_t	ix;
+	int_t	ix, len6;
 
 	if (buf == NULL) {
@@ -314,16 +428,22 @@
 
 	start = buf;
-	if (p_ip6addr == NULL) {
+	if (p_addr == NULL || IN6_IS_ADDR_UNSPECIFIED(p_addr)) {
+		*buf ++ = '0';
 		*buf ++ = ':';
 		*buf ++ = ':';
+		*buf ++ = '0';
 		}
 	else {
-		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+		if (IN6_IS_ADDR_V4MAPPED(p_addr))
+			len6 = sizeof(T_IN6_ADDR) / 2 - 2;
+		else
+			len6 = sizeof(T_IN6_ADDR) / 2;
+		for (ix = 0; ix < len6; ix ++) {
 			if (omit) {
-				buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' '); 
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
 				if (ix < 7)
 					*buf ++ = ':';
 				}
-			else if (ix > 0 && ix < 7 && p_ip6addr->s6_addr16[ix] == 0)
+			else if (ix > 0 && ix < 7 && p_addr->s6_addr16[ix] == 0)
 				zero = true;
 			else {
@@ -332,9 +452,22 @@
 					*buf ++ = ':';
 					}
-				buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' '); 
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
 				if (ix < 7)
 					*buf ++ = ':';
 				}
 			}
+
+		if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
+			T_IN4_ADDR ipv4addr;
+
+			ipv4addr = ntohl(p_addr->s6_addr32[3]);
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 24) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 16) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >>  8) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr      ) & 0xff), 10, 0, ' ');
+			}
 		}
 	*buf = '\0';
@@ -370,26 +503,14 @@
 
 /*
- *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
- */
-
-bool_t
-in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
-{
-	if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
-		return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
-	else
-		return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
-	}
-
-/*
  *  get_ip6_hdr_size -- 拡張ヘッダも含めた IPv6 ヘッダ長を返す。
  */
 
 uint_t
-get_ip6_hdr_size (T_IP6_HDR *iph)
-{
-	uint_t	size = IP6_HDR_SIZE, hsize;
-	uint8_t	curr = iph->next, next;
-	uint8_t	*hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
+get_ip6_hdr_size (T_NET_BUF *nbuf)
+{
+	T_IP6_HDR	*iph = GET_IP6_HDR(nbuf);
+	uint_t		size = IP6_HDR_SIZE, hsize;
+	uint8_t		curr = iph->next, next;
+	uint8_t		*hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
 
 	while (1) {
@@ -436,6 +557,6 @@
  */
 
-T_IN6_ADDR *
-in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst)
+const T_IN6_ADDR *
+in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst)
 {
 	if (IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MULTICAST(dst))
@@ -456,5 +577,5 @@
 		/* 推奨有効時間内のアドレスを探索する。*/
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if (IFA6_IS_READY(ia) &&
 			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
@@ -467,5 +588,5 @@
 		/* 有効時間内のアドレスを探索する。*/
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if (IFA6_IS_READY(ia) &&
 			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
@@ -485,11 +606,11 @@
 		 */
 
-#if NUM_ROUTE_ENTRY > 0
-
-		syscall(wai_sem(SEM_IN_ROUTING_TBL));
-		for (ix = NUM_ROUTE_ENTRY; ix --; ) {
-			if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-			    in6_are_prefix_equal(dst, &routing_tbl[ix].target,
-			                               routing_tbl[ix].prefix_len)) {
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_ROUTE_ENTRY; ix --; ) {
+			if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+			    in6_are_prefix_equal(dst, &routing6_tbl[ix].target,
+			                               routing6_tbl[ix].prefix_len)) {
 
 				/*
@@ -498,18 +619,18 @@
 				 *  TMO_IN_REDIRECT の単位は [ms]。
 				 */
-				if (ix > NUM_STATIC_ROUTE_ENTRY) {
+				if (ix > NUM_IN6_STATIC_ROUTE_ENTRY) {
 					SYSTIM	now;
 
 					syscall(get_tim(&now));
-					routing_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
+					routing6_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
 					}
 
-				syscall(sig_sem(SEM_IN_ROUTING_TBL));
-				return &routing_tbl[ix].gateway;
+				syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+				return &routing6_tbl[ix].gateway;
 				}
 			}
-		syscall(sig_sem(SEM_IN_ROUTING_TBL));
-
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
 
 		/*
@@ -520,5 +641,5 @@
 	}
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 /*
@@ -526,13 +647,13 @@
  */
 
-T_IN_RTENTRY *
-in6_gateway_lookup (T_IN6_ADDR *gw)
+T_IN6_RTENTRY *
+in6_gateway_lookup (const T_IN6_ADDR *gw)
 {
 	int_t	ix;
 
-	for (ix = NUM_ROUTE_ENTRY; ix --; )
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-		    IN6_ARE_ADDR_EQUAL(&routing_tbl[ix].gateway, gw))
-			return &routing_tbl[ix];
+	for (ix = NUM_IN6_ROUTE_ENTRY; ix --; )
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(&routing6_tbl[ix].gateway, gw))
+			return &routing6_tbl[ix];
 	return NULL;
 	}
@@ -545,15 +666,15 @@
 
 void
-in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
-{
-	T_IN_RTENTRY	*frt;
-
-	frt = in_rtnewentry(flags, tmo);
-	frt->gateway    = *gateway;
-	frt->target     = *target;
+in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
+{
+	T_IN6_RTENTRY	*frt;
+
+	frt = in6_rtnewentry(flags, tmo);
+	memcpy(&frt->gateway, gateway, sizeof(T_IN6_ADDR));
+	memcpy(&frt->target, target, sizeof(T_IN6_ADDR));
 	frt->prefix_len = prefix_len;
 	}
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #if NUM_IN6_HOSTCACHE_ENTRY > 0
@@ -564,5 +685,5 @@
 
 static T_IN6_HOSTCACHE_ENTRY*
-in6_hostcache_lookup (T_IN6_ADDR *dst)
+in6_hostcache_lookup (const T_IN6_ADDR *dst)
 {
 	int_t ix;
@@ -625,5 +746,5 @@
 		return;
 		}
-	hc->dst    = *dst;
+	memcpy(&hc->dst, dst, sizeof(T_IN6_ADDR));
 	hc->expire = now + IN6_HOSTCACHE_EXPIRE;
 	hc->mtu    = mtu;
@@ -637,5 +758,5 @@
 
 uint32_t
-in6_hostcache_getmtu (T_IN6_ADDR *dst)
+in6_hostcache_getmtu (const T_IN6_ADDR *dst)
 {
 	T_IN6_HOSTCACHE_ENTRY	*hc;
@@ -679,9 +800,9 @@
 in6_timer (void)
 {
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rttimer();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rttimer();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #ifdef IP6_CFG_FRAGMENT
@@ -707,9 +828,9 @@
 in6_init (void)
 {
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rtinit();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rtinit();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 	timeout((callout_func)nd6_timer, NULL, ND6_TIMER_TMO);
@@ -717,3 +838,106 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+/*
+ *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
+ */
+
+bool_t
+in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr)
+{
+	if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
+		return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
+	else
+		return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
+	}
+
+#if defined(DHCP6_CLI_CFG)
+
+/*
+ *  in6_add_ifaddr -- インタフェースに IPv6 アドレスを設定する。
+ *
+ *    vltime と pltime の単位は[s]
+ */
+
+static ER
+in6_add_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia = NULL;
+	int_t		ix;
+
+	/* 空きのエントリーを探す。*/
+	ix = 0;
+	while (true) {
+		ia = in6ifa_ifpwithix(ifp, ix ++);
+
+		/* 空きが無ければエラー */
+		if (ia == NULL)
+			return E_OBJ;
+
+		if ((ia->flags & IN6_IFF_DEFINED) == 0)
+			break;
+		}
+
+	/* 登録する。*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_upd_ifaddr -- インタフェースに設定されている IPv6 アドレスを更新する。
+ *
+ *    登録されていなければ、追加する。
+ *    vltime と pltime の単位は[s]
+ */
+
+ER
+in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	int_t		ix;
+
+	/*
+	 *  アドレスが一致するエントリーを探す。
+	 *  無ければ登録する。
+	 */
+	if ((ix = in6_addr2ifaix(addr)) == IPV6_IFADDR_IX_INVALID)
+		return in6_add_ifaddr(addr, prefix_len, vltime, pltime);
+
+	/*
+	 *  インデックス番号から、エントリーに変換する。
+	 *  エラーにならないはずであるが、確認する。
+	 */
+	if ((ia = in6ifa_ifpwithix (ifp, ix)) == NULL)
+		return E_OBJ;
+
+	/* 更新する。*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_del_ifaddr -- インタフェースに設定されている IPv6 アドレスを削除する。
+ */
+
+ER
+in6_del_ifaddr (T_IN6_ADDR *addr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	int_t		ix;
+
+	/* アドレスが一致するエントリーを探す。*/
+	if ((ix = in6_addr2ifaix(addr)) != IPV6_IFADDR_IX_INVALID) {
+
+		/* エントリーを無効にする。*/
+		ifp->in6_ifaddrs[ix].flags &= ~IN6_IFF_DEFINED;
+		return E_OK;
+		}
+	return E_PAR;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(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
  *
@@ -102,5 +102,70 @@
 #define _IN6_VAR_H_
 
-#ifdef SUPPORT_INET6
+/*
+ *  アドレスの定義
+ */
+
+#ifdef _NET_CFG_BYTE_ORDER
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x00000001)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x00000002)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0x0000ffff)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0xff010000)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0xff020000)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0xfe800000)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0xfe80)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xfec0)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0xff02)
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x01000000)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x02000000)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0xffff0000)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0x000001ff)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0x000002ff)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0x000080fe)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0x80fe)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xc0fe)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0x02ff)
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
+
+/*
+ *  特別なアドレスのチェック
+ */
+
+/* IPv4 互換 */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4COMPAT(a)		\
+	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
+	 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
+#endif
+
+/* IPv4 射影 */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4MAPPED(a)		\
+	(((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
+#endif
+
+/* 要請マルチキャスト */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_NS_MULTICAST(a)	\
+	(((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
+	 ((a)->s6_addr8[12] == UINT_C(0xff)))
+#endif
+
+#ifndef _MACRO_ONLY
 
 /*
@@ -197,8 +262,4 @@
 						/* IPv6 マルチキャストアドレス配列の最大サイズ	*/
 
-/*
- *  ルーティングの制御
- */
-
 /* ルーティング表エントリ構造体 */
 
@@ -231,17 +292,8 @@
 
 /*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#define IN_SET_HEADER(nbuf,len,dst,src,next,hlim)	\
-					in6_set_header(nbuf,len,dst,src,next,hlim)
-#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
-					in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
-#define IN_CKSUM(nbuf,proto,off,len)	in6_cksum(nbuf,proto,off,len)
-#define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr)			\
-					in6_is_dstaddr_accept(myaddr,dstaddr)
-#define IN_IFAWITHIFP(ifp,dst)		in6_ifawithifp(ifp,dst)
-#define T_IN_IFADDR			T_IN6_IFADDR
-#define T_IN_RTENTRY			T_IN6_RTENTRY
+ *  ルーティング表
+ */
+
+extern T_IN6_RTENTRY routing6_tbl[];
 
 /*
@@ -264,44 +316,54 @@
 
 /*
+ *  関数シミュレーションマクロ
+ */
+
+#define IN6_COPY_TO_HOST(dst,nbuf)	memcpy(dst,&GET_IP6_HDR(nbuf)->src,sizeof(T_IN6_ADDR))
+#define INN6_IS_DSTADDR_ACCEPT(addr,nbuf)	\
+					in6_is_dstaddr_accept(addr,&GET_IP6_HDR(nbuf)->dst)
+
+/*
  *  関数
  */
 
 extern void in6_ifainit (void);
-extern int_t in6_addr2maix (T_IN6_ADDR *addr);
-extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
+extern int_t in6_addr2maix (const T_IN6_ADDR *addr);
+extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
                           uint_t prefix_len, uint32_t vltime, uint32_t pltime,
                           int_t router_index, int_t prefix_index, uint_t flags);
 extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
-                          T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                          const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                           uint8_t next, uint8_t hlim);
 extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                            T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                            const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                             uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
 extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
 extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
 extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
-extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst);
+extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst);
+extern const T_IN6_ADDR *in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst);
 extern void ip6_input (T_NET_BUF *input);
-extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr);
-extern bool_t in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr);
-extern bool_t in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr);
-extern T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst);
+extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr);
+extern bool_t in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr);
+extern bool_t in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr);
+extern bool_t inn6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, T_NET_BUF *input);
+extern const T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst);
 extern int_t in6_if2idlen (T_IFNET *ifp);
-extern int_t in6_addr2ifaix (T_IN6_ADDR *addr);
+extern int_t in6_addr2ifaix (const T_IN6_ADDR *addr);
 extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
-extern bool_t in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix,
+extern bool_t in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix,
                                   uint_t prefix_len);
 extern void in6_ifaddr_timer (T_IFNET *ifp);
-extern T_IN6_RTENTRY *in6_gateway_lookup (T_IN6_ADDR *src);
-extern void in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target,
+extern T_IN6_RTENTRY *in6_gateway_lookup (const T_IN6_ADDR *src);
+extern void in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target,
                             uint_t prefix_len, uint8_t flags, uint32_t tmo);
 extern void in6_init (void);
 extern void in6_if_up (T_IFNET *ifp);
 extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
-extern uint32_t in6_hostcache_getmtu (T_IN6_ADDR *dst);
-extern uint_t in6_addrscope (T_IN6_ADDR *addr);
+extern uint32_t in6_hostcache_getmtu (const T_IN6_ADDR *dst);
+extern uint_t in6_addrscope (const T_IN6_ADDR *addr);
 extern const T_NET_BUF**ip6_get_frag_queue (void);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifndef _MACRO_ONLY */
 
 #endif	/* of #ifndef _IN6_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg	(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
  *
@@ -36,5 +36,5 @@
  */
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /* 近隣キャッシュ */
@@ -58,11 +58,11 @@
 #endif	/* of #ifdef IP6_CFG_FRAGMENT */
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if NUM_IN6_ROUTE_ENTRY > 0
 
-/* ルーティング表（向け直し）*/
+/* ルーティング表 */
 
-CRE_SEM(SEM_IN_ROUTING_TBL, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_IN6_ROUTING_TBL, { TA_TPRI, 1, 1 });
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.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
  *
@@ -105,4 +105,6 @@
 #include <kernel.h>
 #include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -112,4 +114,5 @@
 #include <s_services.h>
 #include <t_services.h>
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -124,24 +127,24 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah6.h>
 #include <netinet6/esp6.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#include <netinet/udp_var.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -170,15 +173,15 @@
 	{ icmp6_input,	IPPROTO_ICMPV6		},
 
-#ifdef SUPPORT_UDP
-
-	{ udp_input,	IPPROTO_UDP		},
-
-#endif	/* of #ifdef SUPPORT_UDP */
-
-#ifdef SUPPORT_TCP
+#if defined(SUPPORT_TCP)
 
 	{ tcp_input,	IPPROTO_TCP		},
 
-#endif	/* of #ifdef SUPPORT_TCP */
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+	{ udp6_input,	IPPROTO_UDP		},
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
 
 	};
@@ -640,5 +643,5 @@
 
 	/* 開始オフセットを IP ヘッダに設定する。*/
-	off = ((uint8_t *)GET_IP_HDR(nbuf)) - nbuf->buf;
+	off = ((uint8_t *)GET_IP6_HDR(nbuf)) - nbuf->buf;
 
 	/* 最終ヘッダを探索する。*/
@@ -650,8 +653,8 @@
 		uint_t sdu;
 
-		sdu = GET_IP_SDU(nbuf) - nbuf->buf;
+		sdu = GET_IP6_SDU(nbuf) - nbuf->buf;
 		if (off > sdu) {
 			memmove(nbuf->buf + sdu, nbuf->buf + off, off - sdu);
-			GET_IP_HDR(nbuf)->plen -= off - sdu;
+			GET_IP6_HDR(nbuf)->plen -= off - sdu;
 			nbuf->len              -= off - sdu;
 			}
@@ -660,3 +663,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.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
  *
@@ -125,18 +125,19 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -165,8 +166,8 @@
 ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout)
 {
-	T_IP6_HDR	*ip6h;
-	T_IN6_ADDR	*gw;
-	T_IFNET		*ifp = IF_GET_IFNET();
-	ER		error = E_OK;
+	T_IP6_HDR		*ip6h;
+	const T_IN6_ADDR	*gw;
+	T_IFNET			*ifp = IF_GET_IFNET();
+	ER			error = E_OK;
 
 #ifdef IP6_CFG_FRAGMENT
@@ -185,5 +186,5 @@
 
 	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_OCTETS],
-	              GET_IP_HDR_SIZE(ip6h) + GET_IP_SDU_SIZE(ip6h));
+	              GET_IP6_HDR_SIZE(output) + GET_IP6_SDU_SIZE(output));
 	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_PACKETS], 1);
 	NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutRequests, 1);
@@ -371,3 +372,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(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
  *
@@ -102,6 +102,4 @@
 #define _IP6_VAR_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  IPv6 ヘッダ・ペイロードアクセスマクロ
@@ -114,9 +112,10 @@
 #define GET_IP6_NEXT_HDR(nbuf)		((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
 
-#define GET_IP6_HDR_SIZE(iph)		(get_ip6_hdr_size(iph))
-#define GET_IP6_SDU_SIZE(iph)		(ntohs((iph)->plen))
-#define GET_IF_IP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf))))
-
-#define SET_IP6_SDU_SIZE(iph,slen)	((iph)->plen=htons(slen))
+#define GET_IP6_HDR_SIZE(nbuf)		(get_ip6_hdr_size(nbuf))
+#define GET_IP6_SDU_SIZE(nbuf)		(ntohs(GET_IP6_HDR(nbuf)->plen))
+#define GET_IF_IP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP6_HDR_SIZE(nbuf)))
+
+#define SET_IP6_CF(nbuf,cf)		(GET_IP6_HDR(nbuf)->vcf=htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(GET_IP6_HDR(nbuf)->vcf)),cf)))
+#define SET_IP6_SDU_SIZE(nbuf,slen)	(GET_IP6_HDR(nbuf)->plen=htons(slen))
 
 /* ip6_output のフラグ */
@@ -144,27 +143,8 @@
 
 /*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#define T_TCP_IP_Q_HDR			T_TCP_IP6_Q_HDR
-
-#define IF_IP_HDR_SIZE			IF_IP6_HDR_SIZE
-
-#define GET_IP_HDR(nbuf)		GET_IP6_HDR(nbuf)
-#define GET_IP_SDU(nbuf)		GET_IP6_SDU(nbuf)
-
-#define GET_IP_HDR_SIZE(iph)		GET_IP6_HDR_SIZE(iph)
-#define GET_IP_SDU_SIZE(iph)		GET_IP6_SDU_SIZE(iph)
-#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP6_HDR_SIZE(nbuf)
-
-#define SET_IP_SDU_SIZE(iph,len)	SET_IP6_SDU_SIZE(iph,len)
-
-#define IP_OUTPUT(nbuf,tmout)		ip6_output(nbuf,0,tmout)
-#define IP_INIT()			ip6_init()
-#define IP_REMOVE_OPTIONS(nbuf)		ip6_remove_exthdrs(nbuf)
-
-/*
  *  IPv6 の MMTU サイズのネットワークバッファ
  */
+
+#if defined(IF_HDR_SIZE)
 
 typedef struct t_net_buf_ipv6_mmtu {
@@ -181,4 +161,6 @@
 				/* バッファ本体		*/
 	} T_NET_BUF_IPV6_MMTU;
+
+#endif	/* of #if defined(IF_HDR_SIZE) */
 
 /*
@@ -258,5 +240,5 @@
  */
 
-typedef struct t_tcp_ip6_q_hdr {
+typedef struct t_ip6_tcp_q_hdr {
 	uint8_t vc;		/* Version:        4 bit		*/
 	uint8_t cf;		/* Traffic Class:  8 bit		*/
@@ -268,5 +250,5 @@
 	T_IN6_ADDR src;	/* Source Address			*/
 	T_IN6_ADDR dst;	/* Destination Address			*/
-	} __attribute__((packed, aligned(2)))T_TCP_IP6_Q_HDR;
+	} __attribute__((packed, aligned(2))) T_IP6_TCP_Q_HDR;
 
 #ifdef SUPPORT_MIB
@@ -304,4 +286,10 @@
 
 /*
+ *  変数
+ */
+
+extern uint8_t	ip6_defhlim;
+
+/*
  *  関数
  */
@@ -310,5 +298,5 @@
 extern void ip6_init (void);
 extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
-extern uint_t get_ip6_hdr_size (T_IP6_HDR *iph);
+extern uint_t get_ip6_hdr_size (T_NET_BUF *nbuf);
 extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
 extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
@@ -320,5 +308,3 @@
 extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _IP6_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg	(revision 331)
@@ -3,5 +3,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
  *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.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
  *
@@ -98,6 +98,8 @@
 #include <net/ethernet.h>
 #include <net/if_arp.h>
+#include <net/ppp.h>
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -107,15 +109,13 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -328,5 +328,5 @@
 
 T_LLINFO_ND6 *
-nd6_lookup (T_IN6_ADDR *addr, bool_t create)
+nd6_lookup (const T_IN6_ADDR *addr, bool_t create)
 {
 	SYSTIM	min = 0xffffffff;
@@ -370,5 +370,5 @@
 
 T_LLINFO_ND6 *
-nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from,
+nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from,
                   T_IF_ADDR *lladdr, uint8_t type, uint8_t code)
 {
@@ -487,5 +487,5 @@
 
 bool_t
-nd6_is_addr_neighbor (T_IFNET *ifp, T_IN6_ADDR *addr)
+nd6_is_addr_neighbor (T_IFNET *ifp, const T_IN6_ADDR *addr)
 {
 	if (IN6_IS_ADDR_LINKLOCAL(addr))
@@ -508,5 +508,5 @@
 
 ER
-nd6_output (T_IFNET *ifp, T_NET_BUF *output, T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
+nd6_output (T_IFNET *ifp, T_NET_BUF *output, const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
 {
 	ER	error = E_OK;
@@ -622,5 +622,5 @@
 
 ER
-nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa)
+nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa)
 {
 	if (IN6_IS_ADDR_MULTICAST(dst)) {
@@ -696,3 +696,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(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
  *
@@ -67,6 +67,4 @@
 #define _ND6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  ネットワークインタフェース構造体（T_IFNET）のフラグ
@@ -118,6 +116,4 @@
 #define ND6_MAX_UCAST_QUERY		3		/* ユニキャストアドレス要請の再送回数	*/
 
-#define ND6_INFINITE_LIFETIME		0xffffffff
-
 #define ND6_GCOLLECTION_TIME		(60*60*24*SYSTIM_HZ)
 							/* ゴミ拾い周期、1 日			*/
@@ -234,5 +230,4 @@
 extern SYSTIM	nd6_recalc_reachtm_interval;
 extern SYSTIM	nd6_retrans_time;
-extern uint8_t	ip6_defhlim;
 
 /*
@@ -241,25 +236,25 @@
 
 extern void nd6_ifattach (T_IFNET *ifp);
-extern void nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-                           T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
-extern void nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-                           T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
+extern void nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
+extern void nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
 extern void nd6_dad_start (T_IFNET *ifp, T_IN6_IFADDR *ia, int_t *tick);
 extern ER nd6_output (T_IFNET *ifp, T_NET_BUF *output,
-                      T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
+                      const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
 extern void nd6_na_input (T_NET_BUF *input, uint_t off);
 extern void nd6_ns_input (T_NET_BUF *input, uint_t off);
 extern void nd6_ra_input (T_NET_BUF *input, uint_t off);
-extern ER nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa);
+extern ER nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa);
 extern ER nd6_options (uint8_t *opt, void *nh, uint_t len);
-extern T_LLINFO_ND6 *nd6_lookup (T_IN6_ADDR *addr, bool_t create);
+extern T_LLINFO_ND6 *nd6_lookup (const T_IN6_ADDR *addr, bool_t create);
 extern ER nd6_output_hold (T_IFNET *ifp, T_LLINFO_ND6 *ln);
-extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from, 
+extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from, 
                                        T_IF_ADDR *lladdr, uint8_t type, uint8_t code);
 extern void nd6_defrtrlist_timer (void);
 extern void nd6_prelist_timer (void);
 extern void nd6_rtrsol_ctl (void);
-extern T_IN6_ADDR *nd6_router_lookup (void);
-extern T_DEF_ROUTER *nd6_defrtrlist_lookup (T_IN6_ADDR *src);
+extern const T_IN6_ADDR *nd6_router_lookup (void);
+extern T_DEF_ROUTER *nd6_defrtrlist_lookup (const T_IN6_ADDR *src);
 extern void nd6_defrtrlist_del (T_DEF_ROUTER *dr);
 extern void nd6_timer (void);
@@ -269,7 +264,5 @@
 extern ER nd6_prefix_onlink (T_ND6_PREFIX *pr);
 extern ER nd6_prefix_offlink (T_ND6_PREFIX *pr);
-extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (T_IN6_ADDR *dst);
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst);
 
 #endif	/* of #ifndef _ND6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.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
  *
@@ -93,4 +93,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -100,16 +101,13 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
 #include <net/if6_var.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -363,6 +361,6 @@
 
 void
-nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-               T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
+nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
 {
 	T_NEIGHBOR_SOLICIT_HDR	*nsh;
@@ -429,5 +427,5 @@
 
 		if (saddr && in6_lookup_ifaddr(ifp, saddr))
-			ip6h->src = *saddr;
+			memcpy(&ip6h->src, saddr, sizeof(T_IN6_ADDR));
 		else {
 			/*
@@ -441,5 +439,5 @@
 				return;
 				}
-			ip6h->src = ifa->addr;
+			memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
 			}
 		}
@@ -455,5 +453,5 @@
  	nsh->hdr.code        = 0;
  	nsh->hdr.data.data32 = 0;
- 	nsh->target          = *taddr;
+	memcpy(&nsh->target, taddr, sizeof(T_IN6_ADDR));
 
 	if (!dad && (mac = IF_SOFTC_TO_IFADDR(ifp->ic)) != NULL) {
@@ -699,6 +697,6 @@
 
 void
-nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-               T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
+nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
 {
 	T_NEIGHBOR_ADVERT_HDR	*nah;
@@ -747,5 +745,5 @@
 		}
 	else
-		ip6h->dst = *daddr;
+		memcpy(&ip6h->dst, daddr, sizeof(T_IN6_ADDR));
 
 	/*
@@ -757,11 +755,11 @@
 		return;
 		}
-	ip6h->src = ifa->addr;
-
- 	/* 近隣通知ヘッダを設定する。*/
- 	nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
- 	nah->hdr.type        = ND_NEIGHBOR_ADVERT;
- 	nah->hdr.code        = 0;
- 	nah->target          = *taddr;
+	memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
+
+	/* 近隣通知ヘッダを設定する。*/
+	nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
+	nah->hdr.type        = ND_NEIGHBOR_ADVERT;
+	nah->hdr.code        = 0;
+	memcpy(&nah->target, taddr, sizeof(T_IN6_ADDR));
 
 	/* tlladdr が真ならネットワークインタフェースのアドレスを追加する。*/
@@ -851,3 +849,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.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
  *
@@ -93,4 +93,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -100,13 +101,12 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 #include <netinet6/in6_ifattach.h>
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
-#include <net/if6_var.h>
+
+#include <net/if_var.h>
 
 /*
@@ -116,5 +116,5 @@
 extern const char *itron_strerror (ER ercd);
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 #if NUM_ND6_DEF_RTR_ENTRY > 0
@@ -284,5 +284,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
 		     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
@@ -299,5 +299,5 @@
 		 */
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
 			     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
@@ -316,5 +316,5 @@
 		 */
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0)
 				ia->flags &= ~IN6_IFF_DETACHED;
@@ -448,5 +448,5 @@
 	/* 各メンバに値を設定する。*/
 	fdr->plistmap = 0;
-	fdr->addr     = *src;
+	memcpy(&fdr->addr, src, sizeof(T_IN6_ADDR));
 	fdr->lifetime = lifetime * SYSTIM_HZ;		/* lifetime の単位は秒 */
 	fdr->flags    = flags;
@@ -478,5 +478,5 @@
 	int_t		ix;
 
-	lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 
 	/*
@@ -585,5 +585,5 @@
 
 	/* リンクローカルアドレスが未登録であれば何もしない。*/
-	lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 	if ((lla->flags & IN6_IFF_DEFINED) == 0)
 		return E_OK;
@@ -594,5 +594,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if (ia->prefix_index == (pr - nd6_prefix))
 			break;
@@ -634,5 +634,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if (ia->prefix_index == (pr - nd6_prefix))
 			break;
@@ -692,5 +692,4 @@
 	T_ND6_PREFIX	*pr = NULL;
 	int_t		ix;
-	ER		error;
 
 	/* プレフィックスリストから空きのプレフィックスエントリを探索する。*/
@@ -723,5 +722,5 @@
 
 	if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) != 0) {
-		if ((error = nd6_prefix_onlink(pr)) != E_OK)
+		if (nd6_prefix_onlink(pr) != E_OK)
 			return NULL;
 		}
@@ -812,4 +811,11 @@
 			}
 
+#if 1		/* プレフィックスが未登録の場合だけ表示する。*/
+		syslog(LOG_NOTICE, "[ND6 RTR] add prefix: flags[MOH]: %02x, addr: %s\n"
+		                   "                                      from: %s.",
+		                   nd6_def_router[router_index].flags,
+		                   ipv62str(NULL, &pi->prefix),
+		                   ipv62str(NULL, &nd6_def_router[router_index].addr));
+#endif
 		if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0) {
 			/*
@@ -836,5 +842,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
 		    ia->prefix_len == pr->prefix_len &&
@@ -892,5 +898,5 @@
 				}
 
-			lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+			lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 
 			/* プレフィックスマスクを生成する。*/
@@ -922,5 +928,5 @@
 
 			for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-				ia = &ifp->in_ifaddrs[ix];
+				ia = &ifp->in6_ifaddrs[ix];
 				if ((ia->flags & IN6_IFF_DEFINED) == 0) {
 					in6_ifadd(pr, ia, router_index);
@@ -971,5 +977,5 @@
 	T_NET_BUF		*output;
 	T_IN6_IFADDR		*ifa;
-	T_IN6_ADDR		*saddr;
+	const T_IN6_ADDR	*saddr;
 	uint16_t		len;
 
@@ -1017,5 +1023,5 @@
 
 T_DEF_ROUTER *
-nd6_defrtrlist_lookup (T_IN6_ADDR *src)
+nd6_defrtrlist_lookup (const T_IN6_ADDR *src)
 {
 	T_DEF_ROUTER	*dr = NULL;
@@ -1036,5 +1042,5 @@
  */
 
-T_IN6_ADDR *
+const T_IN6_ADDR *
 nd6_router_lookup (void)
 {
@@ -1260,6 +1266,9 @@
 				syslog(LOG_NOTICE, "[ND6 RTR] preferred(%d) > valid time(%d).", ntohl(pi->preferred), ntohl(pi->valid));
 			else {
-				syslog(LOG_NOTICE, "[ND6 RTR] update prefix: %s from %s.",
-				                   ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#if 0	/* プレフィックスが未登録の場合だけ表示する。*/
+				syslog(LOG_NOTICE, "[ND6 RTR] update prefix: flags[MOH]: %02x, addr: %s\n"
+				                   "                                         from: %s.",
+				                   rah->nd_ra_flags, ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#endif
 				if (rix >= 0) {
 					/*
@@ -1391,5 +1400,5 @@
 
 T_ND6_PREFIX *
-nd6_onlink_prefix_lookup (T_IN6_ADDR *dst)
+nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst)
 {
 	SYSTIM		now;
@@ -1427,3 +1436,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.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
  *
@@ -82,4 +82,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/if.h>
 #include <net/if_loop.h>
@@ -92,18 +93,17 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 #if 0
-	/*
-	 *  通信帯域を食いつぶす攻撃への対応のため、
-	 *  タイプ 0 経路制御ヘッダの処理を行わない。
-	 */
+/*
+ *  通信帯域を食いつぶす攻撃への対応のため、
+ *  タイプ 0 経路制御ヘッダの処理を行わない。
+ */
 
 /*
@@ -229,3 +229,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.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
  *
@@ -123,10 +123,14 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
 #include <netinet6/in6_var.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -135,5 +139,5 @@
 
 uint_t
-in6_addrscope (T_IN6_ADDR *addr)
+in6_addrscope (const T_IN6_ADDR *addr)
 {
 	uint_t scope;
@@ -168,3 +172,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c	(revision 331)
@@ -0,0 +1,136 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp_reply_no_port -- éä¿¡å
+ã«ãã¼ããå®ç¾©ããã¦ããªããã¨ãéç¥ããã
+ */
+
+void
+UDP_REPLY_NO_PORT (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+
+#if defined(_IP4_CFG)
+
+	if (GET_IP_VER(input)==IPV6_VERSION) {
+
+		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+		if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+			icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+			}
+		else
+			syscall(rel_net_buf(input));
+		}
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+
+		/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+		if (ntohl(GET_IP4_HDR(input)->dst) == IF_GET_IFNET()->in4_ifaddr.addr) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			icmp_error(ICMP4_UNREACH_PORT, input);
+			/* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
+			}
+		syscall(rel_net_buf(input));
+		}
+
+#else	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+
+	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+	if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+		/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+		icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+		}
+	else
+		syscall(rel_net_buf(input));
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c	(revision 331)
@@ -0,0 +1,172 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp6_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP6_HDR	*ip6h;
+
+	ip6h = GET_IP6_HDR(input);
+
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst))
+		return true;
+	else
+		return INN6_IS_DSTADDR_ACCEPT(myaddr, input);
+	}
+
+#if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR)
+
+#ifdef DHCP_CFG
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input)==IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+		    ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#else	/* of #ifdef DHCP_CFG */
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input) == IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input) == IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#endif	/* of #ifdef DHCP_CFG */
+
+#endif	/* of #if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.csv
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.csv	(revision 321)
+++ 	(revision )
@@ -1,12 +1,0 @@
-tcp4_rep,TCP_CRE_REP, #tcp4_repid { .tcp4_repatr { &ipv4addr &portno } },,
-tcp6_rep,TCP6_CRE_REP,#tcp6_repid { .tcp6_repatr { &ipv6addr &portno } },,
-tcp4_cep,TCP_CRE_CEP, #tcp4_cepid { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback },,
-tcp6_cep,TCP6_CRE_CEP,#tcp6_cepid { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback },,
-udp4_cep,UDP_CRE_CEP, #udp4_cepid { .udp4_cepatr { &ipv4addr &portno } &callback },,
-udp6_cep,UDP6_CRE_CEP,#udp6_cepid { .udp6_cepatr { &ipv6addr &portno } &callback },,
-vrid_tcp4_rep,VRID_TCP_REP, #vrid_tcp4_repid,,
-vrid_tcp4_cep,VRID_TCP_CEP, #vrid_tcp4_cepid,,
-vrid_tcp6_rep,VRID_TCP6_REP,#vrid_tcp6_repid,,
-vrid_tcp6_cep,VRID_TCP6_CEP,#vrid_tcp6_cepid,,
-vrid_udp4_cep,VRID_UDP_CEP, #vrid_udp4_cepid,,
-vrid_udp6_cep,VRID_UDP6_CEP,#vrid_udp6_cepid,,
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_api.def	(revision 331)
@@ -1,12 +1,12 @@
-TCP_CRE_REP  #tcp4_repid* { .tcp4_repatr { &ipv4addr &portno } }
-TCP6_CRE_REP #tcp6_repid* { .tcp6_repatr { &ipv6addr &portno } }
-TCP_CRE_CEP  #tcp4_cepid* { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }
-TCP6_CRE_CEP #tcp6_cepid* { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }
-UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback }
-UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback }
-VRID_TCP4_REP  #vrid_tcp4_repid*
-VRID_TCP4_CEP  #vrid_tcp4_cepid*
-VRID_TCP6_REP #vrid_tcp6_repid*
-VRID_TCP6_CEP #vrid_tcp6_cepid*
-VRID_UDP4_CEP  #vrid_udp4_cepid*
-VRID_UDP6_CEP #vrid_udp6_cepid*
+TCP_CRE_REP  #tcp4_repid* { .tcp4_repatr { &ipv4addr &portno } }  
+TCP6_CRE_REP #tcp6_repid* { .tcp6_repatr { &ipv6addr &portno } }  
+TCP_CRE_CEP  #tcp4_cepid* { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }  
+TCP6_CRE_CEP #tcp6_cepid* { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }  
+UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback }  
+UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback }  
+VRID_TCP_REP  #vrid_tcp4_repid*  
+VRID_TCP_CEP  #vrid_tcp4_cepid*  
+VRID_TCP6_REP #vrid_tcp6_repid*  
+VRID_TCP6_CEP #vrid_tcp6_cepid*  
+VRID_UDP_CEP  #vrid_udp4_cepid*  
+VRID_UDP6_CEP #vrid_udp6_cepid*  
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def	(revision 331)
@@ -48,4 +48,5 @@
 TCP_REP_FLG_DYNAMIC
 TCP_REP_FLG_VALID
+TCP_CEP_FLG_IPV4
 TCP_CEP_FLG_ACK_NOW
 TCP_CEP_FLG_DEL_ACK
@@ -73,4 +74,5 @@
 TCP_CEP_FLG_WBCS_SENT
 TCP_CEP_FLG_WBCS_ACKED
+TCP_CEP_FLG_NOT_CLEAR
 TCP_CEP_EVT_ESTABLISHED
 TCP_CEP_EVT_CLOSED
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.tf
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.tf	(revision 321)
+++ 	(revision )
@@ -1,439 +1,0 @@
-$ ======================================================================
-$ 
-$   TINET (TCP/IP Protocol Stack)
-$ 
-$   Copyright (C) 2001-2007 by Dep. of Computer Science and Engineering
-$                    Tomakomai National College of Technology, JAPAN
-$  
-$   上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
-$   ア（本ソフトウェアを改変したものを含む．以下同じ）を使用・複製・改
-$   変・再配布（以下，利用と呼ぶ）することを無償で許諾する．
-$   (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
-$       権表示，この利用条件および下記の無保証規定が，そのままの形でソー
-$       スコード中に含まれていること．
-$   (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
-$       用できる形で再配布する場合には，再配布に伴うドキュメント（利用
-$       者マニュアルなど）に，上記の著作権表示，この利用条件および下記
-$       の無保証規定を掲載すること．
-$   (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
-$       用できない形で再配布する場合には，次のいずれかの条件を満たすこ
-$       と．
-$     (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
-$         作権表示，この利用条件および下記の無保証規定を掲載すること．
-$   (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
-$       害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
-$       また，本ソフトウェアのユーザまたはエンドユーザからのいかなる理
-$       由に基づく請求からも，上記著作権者およびTOPPERSプロジェクトを
-$       免責すること．
-$  
-$   本ソフトウェアは，無保証で提供されているものである．上記著作権者お
-$   よびTOPPERSプロジェクトは，本ソフトウェアに関して，特定の使用目的
-$   に対する適合性も含めて，いかなる保証も行わない．また，本ソフトウェ
-$   アの利用により直接的または間接的に生じたいかなる損害に関しても，そ
-$   の責任を負わない．
-$ 
-$   @(#) $Id$
-$  
-$ =====================================================================
-
-$ =====================================================================
-$ tinet_cfg.h の生成
-$ =====================================================================
-
-$FILE "tinet_cfg.h"$
-/* tinet_cfg.h */$NL$
-#ifndef _TINET_CFG_H_$NL$
-#define _TINET_CFG_H_$NL$
-$NL$
-$FOREACH id TCP4_REP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id TCP6_REP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id TCP4_CEP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id TCP6_CEP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id UDP4_CEP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id UDP6_CEP.ID_LIST$
-	#define $id$	$+id$$NL$
-$END$
-$FOREACH id VRID_TCP4_REP.ID_LIST$
-	#define $id$	$+id + LENGTH(TCP4_REP.ID_LIST)$$NL$
-$END$
-$FOREACH id VRID_TCP4_CEP.ID_LIST$
-	#define $id$	$+id + LENGTH(TCP4_CEP.ID_LIST)$$NL$
-$END$
-$FOREACH id VRID_TCP6_REP.ID_LIST$
-	#define $id$	$+id + LENGTH(TCP6_REP.ID_LIST)$$NL$
-$END$
-$FOREACH id VRID_TCP6_CEP.ID_LIST$
-	#define $id$	$+id + LENGTH(TCP6_CEP.ID_LIST)$$NL$
-$END$
-$FOREACH id VRID_UDP4_CEP.ID_LIST$
-	#define $id$	$+id + LENGTH(UDP4_CEP.ID_LIST)$$NL$
-$END$
-$FOREACH id VRID_UDP6_CEP.ID_LIST$
-	#define $id$	$+id + LENGTH(UDP6_CEP.ID_LIST)$$NL$
-$END$
-$NL$
-#endif /* _TINET_CFG_H_ */$NL$
-
-$ =====================================================================
-$ tinet_cfg.c の生成
-$ =====================================================================
-
-$FILE "tinet_cfg.c"$
-/* tinet_cfg.c */$NL$
-$NL$
-#include <kernel.h>$NL$
-#include <sil.h>$NL$
-#include "kernel_cfg.h"$NL$
-#include "tinet_cfg.h"$NL$
-#include <tinet_defs.h>$NL$
-#include <tinet_config.h>$NL$
-#include <net/if.h>$NL$
-#include <net/if_ppp.h>$NL$
-#include <net/if_loop.h>$NL$
-#include <net/ethernet.h>$NL$
-#include <net/net.h>$NL$
-#include <net/net_buf.h>$NL$
-#include <netinet/in.h>$NL$
-#include <netinet/in_itron.h>$NL$
-#include <netinet/ip.h>$NL$
-#include <netinet/ip6.h>$NL$
-#include <netinet/tcp.h>$NL$
-#include <netinet/tcp_timer.h>$NL$
-#include <netinet/tcp_var.h>$NL$
-#include <netinet/tcp_fsm.h>$NL$
-#include <netinet/udp_var.h>$NL$
-
-$ 
-$  インクルードディレクティブ（#include）
-$ 
-$NL$
-/*$NL$
-$SPC$*  Include Directives (#include)$NL$
-$SPC$*/$NL$
-$NL$
-$INCLUDES$
-
-$	// TCP (IPv4) 受付口
-$IF LENGTH(TCP4_REP.ID_LIST) + LENGTH(VRID_TCP4_REP.ID_LIST)$
-	$NL$
-	#define TNUM_TCP_REPID	$LENGTH(TCP4_REP.ID_LIST) + LENGTH(VRID_TCP4_REP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);$NL$
-	$NL$
-	T_TCP4_REP tcp_rep[TNUM_TCP_REPID] = {$NL$
-	$FOREACH id TCP4_REP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$TCP4_REP.TCP4_REPATR[id]$,$NL$
-			$TAB$$TAB${ $TCP4_REP.IPV4ADDR[id]$, $TCP4_REP.PORTNO[id]$ },$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-			$TAB$$TAB$TCP_REP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_TCP_REP_LOCK$+id$,$NL$
-	#endif$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_TCP4_REP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB${ IPV4_ADDRANY, TCP_PORTANY },$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-			$TAB$$TAB$TCP_REP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_TCP_REP_LOCK$+id + LENGTH(TCP4_REP.ID_LIST)$,$NL$
-	#endif$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$	// TCP (IPv6) 受付口
-$IF LENGTH(TCP6_REP.ID_LIST) + LENGTH(VRID_TCP6_REP.ID_LIST)$
-	$NL$
-	#define TNUM_TCP_REPID	$LENGTH(TCP6_REP.ID_LIST) + LENGTH(VRID_TCP6_REP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);$NL$
-	$NL$
-	T_TCP6_REP tcp_rep[TNUM_TCP_REPID] = {$NL$
-	$FOREACH id TCP6_REP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$TCP6_REP.TCP6_REPATR[id]$,$NL$
-			$TAB$$TAB${ $TCP6_REP.IPV6ADDR[id]$, $TCP6_REP.PORTNO[id]$ },$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-			$TAB$$TAB$TCP_REP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_TCP_REP_LOCK$+id$,$NL$
-	#endif$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_TCP6_REP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB${ IPV6_ADDRANY, TCP_PORTANY },$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-			$TAB$$TAB$TCP_REP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_TCP_REP_LOCK$+id + LENGTH(TCP6_REP.ID_LIST)$,$NL$
-	#endif$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$	// TCP (IPv4) 通信端点
-$IF LENGTH(TCP4_CEP.ID_LIST) + LENGTH(VRID_TCP4_CEP.ID_LIST)$
-	$NL$
-	#define TNUM_TCP_CEPID	$LENGTH(TCP4_CEP.ID_LIST) + LENGTH(VRID_TCP4_CEP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);$NL$
-	$NL$
-	T_TCP4_CEP tcp_cep[TNUM_TCP_CEPID] = {$NL$
-	$FOREACH id TCP4_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$TCP4_CEP.TCP4_CEPATR[id]$,$NL$
-			$TAB$$TAB$(void*)$TCP4_CEP.SBUF[id]$,$NL$
-			$TAB$$TAB$$TCP4_CEP.SBUFSZ[id]$,$NL$
-			$TAB$$TAB$(void*)$TCP4_CEP.RBUF[id]$,$NL$
-			$TAB$$TAB$$TCP4_CEP.RBUFSZ[id]$,$NL$
-			$TAB$$TAB$(t_tcp_callback)(FP)$TCP4_CEP.CALLBACK[id]$,$NL$
-			$TAB$$TAB$TCP_CEP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_TCP_CEP_LOCK$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_EST$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_SND$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_RCV$+id$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_TCP4_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(void*)NULL,$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(void*)NULL,$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(t_tcp_callback)(FP)NULL,$NL$
-			$TAB$$TAB$TCP_CEP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_TCP_CEP_LOCK$+id + LENGTH(TCP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_EST$+id + LENGTH(TCP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_SND$+id + LENGTH(TCP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_RCV$+id + LENGTH(TCP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$	// TCP (IPv6) 通信端点
-$IF LENGTH(TCP6_CEP.ID_LIST) + LENGTH(VRID_TCP6_CEP.ID_LIST)$
-	$NL$
-	#define TNUM_TCP_CEPID	$LENGTH(TCP6_CEP.ID_LIST) + LENGTH(VRID_TCP6_CEP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);$NL$
-	$NL$
-	T_TCP6_CEP tcp_cep[TNUM_TCP_CEPID] = {$NL$
-	$FOREACH id TCP6_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$TCP6_CEP.TCP6_CEPATR[id]$,$NL$
-			$TAB$$TAB$(void*)$TCP6_CEP.SBUF[id]$,$NL$
-			$TAB$$TAB$$TCP6_CEP.SBUFSZ[id]$,$NL$
-			$TAB$$TAB$(void*)$TCP6_CEP.RBUF[id]$,$NL$
-			$TAB$$TAB$$TCP6_CEP.RBUFSZ[id]$,$NL$
-			$TAB$$TAB$(t_tcp_callback)(FP)$TCP6_CEP.CALLBACK[id]$,$NL$
-			$TAB$$TAB$TCP_CEP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_TCP_CEP_LOCK$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_EST$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_SND$+id$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_RCV$+id$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_TCP6_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(void*)NULL,$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(void*)NULL,$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB$(t_tcp_callback)(FP)NULL,$NL$
-			$TAB$$TAB$TCP_CEP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_TCP_CEP_LOCK$+id + LENGTH(TCP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_EST$+id + LENGTH(TCP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_SND$+id + LENGTH(TCP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$FLG_TCP_CEP_RCV$+id + LENGTH(TCP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$	// UDP (IPv4) 通信端点
-$IF LENGTH(UDP4_CEP.ID_LIST) + LENGTH(VRID_UDP4_CEP.ID_LIST)$
-	$NL$
-	#define TNUM_UDP_CEPID	$LENGTH(UDP4_CEP.ID_LIST) + LENGTH(VRID_UDP4_CEP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);$NL$
-	$NL$
-	T_UDP4_CEP udp_cep[TNUM_UDP_CEPID] = {$NL$
-	$FOREACH id UDP4_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$UDP4_CEP.UDP4_CEPATR[id]$,$NL$
-			$TAB$$TAB${ $UDP4_CEP.IPV4ADDR[id]$, $UDP4_CEP.PORTNO[id]$ },$NL$
-			$TAB$$TAB$(t_udp_callback)(FP)$UDP4_CEP.CALLBACK[id]$,$NL$
-			$TAB$$TAB$UDP_CEP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_UDP_CEP_LOCK$+id$,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$DTQ_UDP_RCVQ$+id$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_UDP4_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB${ IPV4_ADDRANY, UDP_PORTANY },$NL$
-			$TAB$$TAB$(t_udp_callback)(FP)NULL,$NL$
-			$TAB$$TAB$UDP_CEP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_UDP_CEP_LOCK$+id + LENGTH(UDP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$DTQ_UDP_RCVQ$+id + LENGTH(UDP4_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$	// UDP (IPv6) 通信端点
-$IF LENGTH(UDP6_CEP.ID_LIST) + LENGTH(VRID_UDP6_CEP.ID_LIST)$
-	$NL$
-	#define TNUM_UDP_CEPID	$LENGTH(UDP6_CEP.ID_LIST) + LENGTH(VRID_UDP6_CEP.ID_LIST)$$NL$
-	$NL$
-	const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);$NL$
-	$NL$
-	T_UDP6_CEP udp_cep[TNUM_UDP_CEPID] = {$NL$
-	$FOREACH id UDP6_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$$UDP6_CEP.UDP6_CEPATR[id]$,$NL$
-			$TAB$$TAB${ $UDP6_CEP.IPV6ADDR[id]$, $UDP6_CEP.PORTNO[id]$ },$NL$
-			$TAB$$TAB$(t_udp_callback)(FP)$UDP6_CEP.CALLBACK[id]$,$NL$
-			$TAB$$TAB$UDP_CEP_FLG_VALID,$NL$
-			$TAB$$TAB$SEM_UDP_CEP_LOCK$+id$,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$DTQ_UDP_RCVQ$+id$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-	$FOREACH id VRID_UDP6_CEP.ID_LIST$
-		$TAB${$NL$
-			$TAB$$TAB$0,$NL$
-			$TAB$$TAB${ IPV6_ADDRANY, UDP_PORTANY },$NL$
-			$TAB$$TAB$(t_udp_callback)(FP)NULL,$NL$
-			$TAB$$TAB$UDP_CEP_FLG_DYNAMIC,$NL$
-			$TAB$$TAB$SEM_UDP_CEP_LOCK$+id + LENGTH(UDP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$TA_NULL,$NL$
-			$TAB$$TAB$DTQ_UDP_RCVQ$+id + LENGTH(UDP6_CEP.ID_LIST)$,$NL$
-			$TAB$$TAB$},$NL$
-	$END$
-		$TAB$};$NL$
-$END$
-
-$ =====================================================================
-$ tinet_kern.cfg の生成
-$ =====================================================================
-
-$FILE "tinet_kern.cfg"$
-/* tinet_kern.cfg */$NL$
-
-$	// TCP (IPv4) 受付口
-$IF LENGTH(TCP4_REP.ID_LIST) + LENGTH(VRID_TCP4_REP.ID_LIST)$
-	$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-	$FOREACH id TCP4_REP.ID_LIST$
-		CRE_SEM(SEM_TCP_REP_LOCK$+id$, { TA_TPRI, 1, 1 });$NL$
-	$END$
-	$FOREACH id VRID_TCP4_REP.ID_LIST$
-		CRE_SEM(SEM_TCP_REP_LOCK$+id + LENGTH(TCP4_REP.ID_LIST)$, { TA_TPRI, 1, 1 });$NL$
-	$END$
-	#endif$NL$
-$END$
-
-$	// TCP (IPv4) 受付口
-$IF LENGTH(TCP6_REP.ID_LIST) + LENGTH(VRID_TCP6_REP.ID_LIST)$
-	$NL$
-	#if defined(TCP_CFG_EXTENTIONS)$NL$
-	$FOREACH id TCP6_REP.ID_LIST$
-		CRE_SEM(SEM_TCP_REP_LOCK$+id$, { TA_TPRI, 1, 1 });$NL$
-	$END$
-	$FOREACH id VRID_TCP6_REP.ID_LIST$
-		CRE_SEM(SEM_TCP_REP_LOCK$+id + LENGTH(TCP6_REP.ID_LIST)$, { TA_TPRI, 1, 1 });$NL$
-	$END$
-	#endif$NL$
-$END$
-
-$	// TCP (IPv4) 通信端点
-$IF LENGTH(TCP4_CEP.ID_LIST) + LENGTH(VRID_TCP4_CEP.ID_LIST)$
-	$NL$
-	$FOREACH id TCP4_CEP.ID_LIST$
-		$NL$
-		CRE_SEM(SEM_TCP_CEP_LOCK$+id$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_FLG(FLG_TCP_CEP_EST$+id$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_CLOSED });$NL$
-		CRE_FLG(FLG_TCP_CEP_SND$+id$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_SWBUF_READY });$NL$
-		CRE_FLG(FLG_TCP_CEP_RCV$+id$,{ TA_TFIFO|TA_WSGL, 0 });$NL$
-	$END$
-	$FOREACH id VRID_TCP4_CEP.ID_LIST$
-		$NL$
-		CRE_SEM(SEM_TCP_CEP_LOCK$+id + LENGTH(TCP4_CEP.ID_LIST)$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_FLG(FLG_TCP_CEP_EST$+id + LENGTH(TCP4_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_CLOSED });$NL$
-		CRE_FLG(FLG_TCP_CEP_SND$+id + LENGTH(TCP4_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_SWBUF_READY });$NL$
-		CRE_FLG(FLG_TCP_CEP_RCV$+id + LENGTH(TCP4_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, 0 });$NL$
-	$END$
-$END$
-
-$	// TCP (IPv6) 通信端点
-$IF LENGTH(TCP6_CEP.ID_LIST) + LENGTH(VRID_TCP6_CEP.ID_LIST)$
-	$NL$
-	$FOREACH id TCP6_CEP.ID_LIST$
-		$NL$
-		CRE_SEM(SEM_TCP_CEP_LOCK$+id$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_FLG(FLG_TCP_CEP_EST$+id$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_CLOSED });$NL$
-		CRE_FLG(FLG_TCP_CEP_SND$+id$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_SWBUF_READY });$NL$
-		CRE_FLG(FLG_TCP_CEP_RCV$+id$,{ TA_TFIFO|TA_WSGL, 0 });$NL$
-	$END$
-	$FOREACH id VRID_TCP6_CEP.ID_LIST$
-		$NL$
-		CRE_SEM(SEM_TCP_CEP_LOCK$+id + LENGTH(TCP6_CEP.ID_LIST)$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_FLG(FLG_TCP_CEP_EST$+id + LENGTH(TCP6_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_CLOSED });$NL$
-		CRE_FLG(FLG_TCP_CEP_SND$+id + LENGTH(TCP6_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, TCP_CEP_EVT_SWBUF_READY });$NL$
-		CRE_FLG(FLG_TCP_CEP_RCV$+id + LENGTH(TCP6_CEP.ID_LIST)$,{ TA_TFIFO|TA_WSGL, 0 });$NL$
-	$END$
-$END$
-
-$	// UDP (IPv4) 通信端点
-$IF LENGTH(UDP4_CEP.ID_LIST) + LENGTH(VRID_UDP4_CEP.ID_LIST)$
-	$NL$
-	$FOREACH id UDP4_CEP.ID_LIST$
-		CRE_SEM(SEM_UDP_CEP_LOCK$+id$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_DTQ(DTQ_UDP_RCVQ$+id$,{ TA_TFIFO, NUM_DTQ_UDP_RCVQ, NULL });$NL$
-		$NL$
-	$END$
-	$FOREACH id VRID_UDP4_CEP.ID_LIST$
-		CRE_SEM(SEM_UDP_CEP_LOCK$+id + LENGTH(UDP4_CEP.ID_LIST)$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_DTQ(DTQ_UDP_RCVQ$+id + LENGTH(UDP4_CEP.ID_LIST)$,{ TA_TFIFO, NUM_DTQ_UDP_RCVQ, NULL });$NL$
-		$NL$
-	$END$
-$END$
-
-$	// UDP (IPv6) 通信端点
-$IF LENGTH(UDP6_CEP.ID_LIST) + LENGTH(VRID_UDP6_CEP.ID_LIST)$
-	$NL$
-	$FOREACH id UDP6_CEP.ID_LIST$
-		CRE_SEM(SEM_UDP_CEP_LOCK$+id$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_DTQ(DTQ_UDP_RCVQ$+id$,{ TA_TFIFO, NUM_DTQ_UDP_RCVQ, NULL });$NL$
-		$NL$
-	$END$
-	$FOREACH id VRID_UDP6_CEP.ID_LIST$
-		CRE_SEM(SEM_UDP_CEP_LOCK$+id + LENGTH(UDP6_CEP.ID_LIST)$,{ TA_TPRI, 1, 1 });$NL$
-		CRE_DTQ(DTQ_UDP_RCVQ$+id + LENGTH(UDP6_CEP.ID_LIST)$,{ TA_TFIFO, NUM_DTQ_UDP_RCVQ, NULL });$NL$
-		$NL$
-	$END$
-$END$
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 331)
@@ -47,39 +47,58 @@
 $tinetCfgH.add()
 
-$cfgData[:TCP_CRE_REP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp4_repid]}	#{params[:tcp4_repid].val}")
-end
+$tinetCfgH.add("#define TNUM_TCP6_REPID	#{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+$tinetCfgH.add("#define TNUM_TCP4_REPID	#{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
+$tinetCfgH.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size + $cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
+$tinetCfgH.add()
+
+$tinetCfgH.add("#define TNUM_TCP6_CEPID	#{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+$tinetCfgH.add("#define TNUM_TCP4_CEPID	#{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
+$tinetCfgH.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size + $cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
+$tinetCfgH.add()
+
+$tinetCfgH.add("#define TNUM_UDP6_CEPID	#{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
+$tinetCfgH.add("#define TNUM_UDP4_CEPID	#{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
+$tinetCfgH.add("#define TNUM_UDP_CEPID	#{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size + $cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
+$tinetCfgH.add()
+
 $cfgData[:TCP6_CRE_REP].each do |key, params|
 	$tinetCfgH.add("#define #{params[:tcp6_repid]}	#{params[:tcp6_repid].val}")
 end
-$cfgData[:TCP_CRE_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:tcp4_cepid]}	#{params[:tcp4_cepid].val}")
-end
+$cfgData[:VRID_TCP6_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}	#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
+end
+$cfgData[:TCP_CRE_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp4_repid]}	#{params[:tcp4_repid].val + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+end
+$cfgData[:VRID_TCP_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}	#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+end
+$tinetCfgH.add()
+
 $cfgData[:TCP6_CRE_CEP].each do |key, params|
 	$tinetCfgH.add("#define #{params[:tcp6_cepid]}	#{params[:tcp6_cepid].val}")
 end
-$cfgData[:UDP_CRE_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:udp4_cepid]}	#{params[:udp4_cepid].val}")
-end
+$cfgData[:VRID_TCP6_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}	#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
+end
+$cfgData[:TCP_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp4_cepid]}	#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+end
+$cfgData[:VRID_TCP_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}	#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+end
+$tinetCfgH.add()
+
 $cfgData[:UDP6_CRE_CEP].each do |key, params|
 	$tinetCfgH.add("#define #{params[:udp6_cepid]}	#{params[:udp6_cepid].val}")
 end
-$cfgData[:VRID_TCP4_REP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}	#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}")
-end
-$cfgData[:VRID_TCP4_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}	#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}")
-end
-$cfgData[:VRID_TCP6_REP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}	#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
-end
-$cfgData[:VRID_TCP6_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}	#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
-end
-$cfgData[:VRID_UDP4_CEP].each do |key, params|
-	$tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}	#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}")
-end
 $cfgData[:VRID_UDP6_CEP].each do |key, params|
 	$tinetCfgH.add("#define #{params[:vrid_udp6_cepid]}	#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}")
+end
+$cfgData[:UDP_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:udp4_cepid]}	#{params[:udp4_cepid].val + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
+end
+$cfgData[:VRID_UDP_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}	#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
 end
 $tinetCfgH.add()
@@ -110,9 +129,6 @@
 #include <netinet/in_itron.h>
 #include <netinet/ip.h>
-#include <netinet/ip6.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
-#include <netinet/tcp_fsm.h>
 #include <netinet/udp_var.h>
 
@@ -130,12 +146,65 @@
 end
 
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP6_REPID + TNUM_TCP4_REPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_tcp6_repid = (TMIN_TCP6_REPID + TNUM_TCP6_REPID - 1);")
+$tinetCfgC.add("const ID tmax_tcp4_repid = (TMIN_TCP4_REPID + TNUM_TCP4_REPID - 1);")
+$tinetCfgC.add("#endif")
+
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID + TNUM_TCP4_CEPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_tcp6_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID - 1);")
+$tinetCfgC.add("const ID tmax_tcp4_cepid = (TMIN_TCP_CEPID + TNUM_TCP4_CEPID - 1);")
+$tinetCfgC.add("#endif")
+
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP6_CEPID + TNUM_UDP4_CEPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_udp6_cepid = (TMIN_UDP6_CEPID + TNUM_UDP6_CEPID - 1);")
+$tinetCfgC.add("const ID tmax_udp4_cepid = (TMIN_UDP4_CEPID + TNUM_UDP4_CEPID - 1);")
+$tinetCfgC.add("#endif")
+
+#	// TCP (IPv6) 受付口
+$sem_tcp_rep_lock_id = 0
+if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_TCP6_REP tcp6_rep[TNUM_TCP6_REPID] = {")
+	$cfgData[:TCP6_CRE_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp6_repatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
+		$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+		$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP6_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, TCP_PORTANY },")
+	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+	$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$tinetCfgC.add("\t};")
+end
+
 #	// TCP (IPv4) 受付口
-if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
 	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP4_REP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_TCP_REP tcp_rep[TNUM_TCP_REPID] = {")
+	$tinetCfgC.add("T_TCP4_REP tcp4_rep[TNUM_TCP4_REPID] = {")
 	$cfgData[:TCP_CRE_REP].each do |key, params|
 		$tinetCfgC.add("\t{")
@@ -144,9 +213,10 @@
 	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
 			$tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp4_repid].val},")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
 	$tinetCfgC.add("#endif")
 			$tinetCfgC.add("\t\t},")
-	end
-	$cfgData[:VRID_TCP4_REP].each do |key, params|
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP_REP].each do |key, params|
 		$tinetCfgC.add("\t{")
 			$tinetCfgC.add("\t\t0,")
@@ -154,91 +224,16 @@
 	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
 			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size},")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
 	$tinetCfgC.add("#endif")
 			$tinetCfgC.add("\t\t},")
-	end
-		$tinetCfgC.add("\t};")
-end
-
-#	// TCP (IPv6) 受付口
-if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$tinetCfgC.add("\t};")
+end
+
+#	// TCP 通信端点
+if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0 || $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
 	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP_REPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_TCP6_REP tcp_rep[TNUM_TCP_REPID] = {")
-	$cfgData[:TCP6_CRE_REP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t#{params[:tcp6_repatr]},")
-			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
-	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
-			$tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:tcp6_repid].val},")
-	$tinetCfgC.add("#endif")
-			$tinetCfgC.add("\t\t},")
-	end
-	$cfgData[:VRID_TCP6_REP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t0,")
-			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, TCP_PORTANY },")
-	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
-			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size},")
-	$tinetCfgC.add("#endif")
-			$tinetCfgC.add("\t\t},")
-	end
-		$tinetCfgC.add("\t};")
-end
-
-#	// TCP (IPv4) 通信端点
-if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP4_CEP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_TCP_CEP tcp_cep[TNUM_TCP_CEPID] = {")
-	$cfgData[:TCP_CRE_CEP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t#{params[:tcp4_cepatr]},")
-			$tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
-			$tinetCfgC.add("\t\t#{params[:sbufsz]},")
-			$tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
-			$tinetCfgC.add("\t\t#{params[:rbufsz]},")
-			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
-			$tinetCfgC.add("\t\tTCP_CEP_FLG_VALID,")
-			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val},")
-			$tinetCfgC.add("\t\t},")
-	end
-	$cfgData[:VRID_TCP4_CEP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t0,")
-			$tinetCfgC.add("\t\t(void*)NULL,")
-			$tinetCfgC.add("\t\t0,")
-			$tinetCfgC.add("\t\t(void*)NULL,")
-			$tinetCfgC.add("\t\t0,")
-			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
-			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\t},")
-	end
-		$tinetCfgC.add("\t};")
-end
-
-#	// TCP (IPv6) 通信端点
-if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP_CEPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_TCP6_CEP tcp_cep[TNUM_TCP_CEPID] = {")
+	$tinetCfgC.add("T_TCP_CEP tcp_cep[TNUM_TCP6_CEPID + TNUM_TCP4_CEPID] = {")
 	$cfgData[:TCP6_CRE_CEP].each do |key, params|
 		$tinetCfgC.add("\t{")
@@ -271,15 +266,72 @@
 			$tinetCfgC.add("\t\t},")
 	end
+	$cfgData[:TCP_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp4_cepatr]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
+			$tinetCfgC.add("\t\t#{params[:sbufsz]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
+			$tinetCfgC.add("\t\t#{params[:rbufsz]},")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_TCP_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_IPV4,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
 		$tinetCfgC.add("\t};")
 end
 
+#	// UDP (IPv6) 通信端点
+if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_UDP6_CEP udp6_cep[TNUM_UDP6_CEPID] = {")
+	$cfgData[:UDP6_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:udp6_cepatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:udp6_cepid].val},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_UDP6_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, UDP_PORTANY },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+		$tinetCfgC.add("\t};")
+end
+
 #	// UDP (IPv4) 通信端点
-if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
 	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_UDP_CEPID	#{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP4_CEP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_UDP_CEP udp_cep[TNUM_UDP_CEPID] = {")
+	$tinetCfgC.add("T_UDP4_CEP udp4_cep[TNUM_UDP4_CEPID] = {")
 	$cfgData[:UDP_CRE_CEP].each do |key, params|
 		$tinetCfgC.add("\t{")
@@ -288,11 +340,11 @@
 			$tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
 			$tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp4_cepid].val},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp4_cepid].val},")
-			$tinetCfgC.add("\t\t},")
-	end
-	$cfgData[:VRID_UDP4_CEP].each do |key, params|
+			$tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:udp4_cepid].val},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_UDP_CEP].each do |key, params|
 		$tinetCfgC.add("\t{")
 			$tinetCfgC.add("\t\t0,")
@@ -300,8 +352,8 @@
 			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
 			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
 			$tinetCfgC.add("\t\t},")
 	end
@@ -309,136 +361,54 @@
 end
 
-#	// UDP (IPv6) 通信端点
-if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
-	$tinetCfgC.add()
-	$tinetCfgC.add("#define TNUM_UDP_CEPID	#{cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
-	$tinetCfgC.add()
-	$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP_CEPID - 1);")
-	$tinetCfgC.add()
-	$tinetCfgC.add("T_UDP6_CEP udp_cep[TNUM_UDP_CEPID] = {")
-	$cfgData[:UDP6_CRE_CEP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t#{params[:udp6_cepatr]},")
-			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
-			$tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
-			$tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:udp6_cepid].val},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:udp6_cepid].val},")
-			$tinetCfgC.add("\t\t},")
-	end
-	$cfgData[:VRID_UDP6_CEP].each do |key, params|
-		$tinetCfgC.add("\t{")
-			$tinetCfgC.add("\t\t0,")
-			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, UDP_PORTANY },")
-			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
-			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
-			$tinetCfgC.add("\t\tSEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tTA_NULL,")
-			$tinetCfgC.add("\t\tDTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
-			$tinetCfgC.add("\t\t},")
-	end
-		$tinetCfgC.add("\t};")
-end
-
 # =====================================================================
 # tinet_kern.cfg の生成
 # =====================================================================
 
-#	// TCP (IPv4) 受付口
-if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP4_REP].size > 0
-	$cfgData[:TCP_CRE_REP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp4_repid].val}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-	end
-	$cfgData[:VRID_TCP4_REP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-	end
-end
-
 #	// TCP (IPv6) 受付口
+$sem_tcp_rep_lock_id = 0
 if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
 	$cfgData[:TCP6_CRE_REP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:tcp6_repid].val}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
 	end
 	$cfgData[:VRID_TCP6_REP].each do |key, params|
 		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-	end
-end
-
-#	// TCP (IPv4) 通信端点
-if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP4_CEP].size > 0
-	$cfgData[:TCP_CRE_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-	end
-	$cfgData[:VRID_TCP4_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+end
+
+#	// TCP (IPv4) 受付口
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
+	$cfgData[:TCP_CRE_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
 	end
 end
@@ -463,23 +433,79 @@
 		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp6_cepid].val}"
 		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_TCP6_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
 		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
 		$cfgFileInfo.push(cfgInfo)
 
 		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val}"
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
+
+#	// TCP (IPv4) 通信端点
+if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
+	$cfgData[:TCP_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
 		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
 		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
 		$cfgFileInfo.push(cfgInfo)
-	end
-	$cfgData[:VRID_TCP6_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
-		cfgInfo["isemcnt"] = 1
-		cfgInfo["maxsem"] = 1
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_TCP_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
 		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
 		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
@@ -487,22 +513,22 @@
 
 		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-
-		cfgInfo = { APINAME: "CRE_FLG" }
-		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
-		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
-		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
-		$cfgFileInfo.push(cfgInfo)
-	end
-end
-
-#	// UDP (IPv4) 通信端点
-if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP4_CEP].size > 0
-	$cfgData[:UDP_CRE_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp4_cepid].val}"
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
+
+#	// UDP (IPv6) 通信端点
+if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
+	$cfgData[:UDP6_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -511,5 +537,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp4_cepid].val}"
+		cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:udp6_cepid].val}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
@@ -517,7 +543,7 @@
 		$cfgFileInfo.push(cfgInfo)
 	end
-	$cfgData[:VRID_UDP4_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+	$cfgData[:VRID_UDP6_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -526,5 +552,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+		cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
@@ -534,9 +560,9 @@
 end
 
-#	// UDP (IPv6) 通信端点
-if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
-	$cfgData[:UDP6_CRE_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:udp6_cepid].val}"
+#	// UDP (IPv4) 通信端点
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
+	$cfgData[:UDP_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -545,5 +571,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:udp6_cepid].val}"
+		cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:udp4_cepid].val}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
@@ -551,7 +577,7 @@
 		$cfgFileInfo.push(cfgInfo)
 	end
-	$cfgData[:VRID_UDP6_CEP].each do |key, params|
-		cfgInfo = { APINAME: "CRE_SEM" }
-		cfgInfo["semid"] = "SEM_UDP_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+	$cfgData[:VRID_UDP_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
 		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
 		cfgInfo["isemcnt"] = 1
@@ -560,5 +586,5 @@
 
 		cfgInfo = { APINAME: "CRE_DTQ" }
-		cfgInfo["dtqid"] = "DTQ_UDP_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+		cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
 		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
 		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2007 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -36,4 +36,6 @@
  */
 
+#include "target_sil.h"
+
 #include <itron.h>
 
@@ -47,4 +49,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -52,13 +55,10 @@
 #include <net/ether_var.h>
 #include <netinet/in.h>
+#include <netinet/in_var.h>
 #include <netinet/ip.h>
-#include <netinet/ip6.h>
 #include <netinet/ip_var.h>
 #include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/udp_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/ip6_var.h>
 
 /*
@@ -69,6 +69,6 @@
 
 INCLUDE("net/net_asp.cfg");
+INCLUDE("net/ethernet.cfg");
 
-INCLUDE("net/ethernet.cfg");
 INCLUDE("netinet/if_ether.cfg");
 INCLUDE("netinet/ip.cfg");
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp_configure
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp_configure	(revision 321)
+++ 	(revision )
@@ -1,488 +1,0 @@
-#! /usr/bin/perl
-#
-#   TINET (TCP/IP Protocol Stack)
-#  
-#  Copyright (C) 2001-2003 by Embedded and Real-Time Systems Laboratory
-#                              Toyohashi Univ. of Technology, JAPAN
-#  Copyright (C) 2006-2008 by Embedded and Real-Time Systems Laboratory
-#              Graduate School of Information Science, Nagoya Univ., JAPAN
-#  Copyright (C) 2001-2007 by Dep. of Computer Science and Engineering
-#                   Tomakomai National College of Technology, JAPAN
-# 
-#  上記著作権者は，以下の(1)〜(4)の条件を満たす場合に限り，本ソフトウェ
-#  ア（本ソフトウェアを改変したものを含む．以下同じ）を使用・複製・改
-#  変・再配布（以下，利用と呼ぶ）することを無償で許諾する．
-#  (1) 本ソフトウェアをソースコードの形で利用する場合には，上記の著作
-#      権表示，この利用条件および下記の無保証規定が，そのままの形でソー
-#      スコード中に含まれていること．
-#  (2) 本ソフトウェアを，ライブラリ形式など，他のソフトウェア開発に使
-#      用できる形で再配布する場合には，再配布に伴うドキュメント（利用
-#      者マニュアルなど）に，上記の著作権表示，この利用条件および下記
-#      の無保証規定を掲載すること．
-#  (3) 本ソフトウェアを，機器に組み込むなど，他のソフトウェア開発に使
-#      用できない形で再配布する場合には，次のいずれかの条件を満たすこ
-#      と．
-#    (a) 再配布に伴うドキュメント（利用者マニュアルなど）に，上記の著
-#        作権表示，この利用条件および下記の無保証規定を掲載すること．
-#  (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
-#      害からも，上記著作権者およびTOPPERSプロジェクトを免責すること．
-#      また，本ソフトウェアのユーザまたはエンドユーザからのいかなる理
-#      由に基づく請求からも，上記著作権者およびTOPPERSプロジェクトを
-#      免責すること．
-# 
-#  本ソフトウェアは，無保証で提供されているものである．上記著作権者お
-#  よびTOPPERSプロジェクトは，本ソフトウェアに関して，特定の使用目的
-#  に対する適合性も含めて，いかなる保証も行わない．また，本ソフトウェ
-#  アの利用により直接的または間接的に生じたいかなる損害に関しても，そ
-#  の責任を負わない．
-# 
-#  @(#) $Id: tinet_asp_configure,v 1.5 2009/12/24 06:42:46 abe Exp abe $
-# 
-
-require "getopt.pl";
-
-#  オプションの定義
-#
-#  -T <target>		ターゲット名（必須）
-#  -A <applname>	アプリケーションプログラム名
-#  -a <appldir>		アプリケーションのディレクトリ名
-#  -U <applobjs>	他のアプリケーションプログラムファイル
-#			（.oファイル名で指定．複数指定可）
-#  -L <kernel_lib>	カーネルライブラリ（libkernel.a）のディレクトリ名
-#			（省略した場合，カーネルライブラリもmakeする）
-#  -f			カーネルを関数単位でコンパイルするかどうかの指定
-#  -D <srcdir>		カーネル等のソースの置かれているディレクトリ
-#  -l <srclang>		プログラミング言語（現時点ではcとc++のみサポート）
-#  -t <templatedir>	テンプレートディレクトリを指定（デフォルトはtinet/asp_sample）
-#  -d <dbgenv>		実行環境の名称
-#  -r			トレースログ記録のサンプルコードを使用するかどうかの指定
-#  -p <perl>		perlのパス名（明示的に指定する場合）
-#  -g <cfg>		コンフィギュレータ（cfg）のパス名
-#  -e <tinetdir>	TINET のソースの置かれているディレクトリ
-#  -i <net_if>		ネットワークインタフェース（必須）
-#			ether、ppp、loop の何れかを指定する。
-#  -v <net_dev>		イーサネット・ディバイスドライバ
-#  			（ネットワークインタフェースに ether を指定した場合は必須）
-#  -n <net_proto>	ネットワーク層プロトコル（必須）
-#			inet4、inet6 の何れかを指定する。
-#  -s <trans_proto>	トランスポート層プロトコル（必須）
-#			tcp、udp、tcp/udp の何れかを指定する。
-
-#  使用例(1)
-#
-#  % ../tinet/tinet_asp_configure -T akih8_3069f_gcc -A echos4 -i ether -v if_ed -n inet4 -s tcp
-
-#
-#  オプションの処理
-#
-do Getopt("TAaULDltdpgiensv");
-
-#
-#  変数の初期化
-#
-
-$target = $opt_T;
-$applname = $opt_A ? $opt_A : "";
-$appldir = $opt_a ? $opt_a : "";
-$applobjs = $opt_U ? $opt_U : "";
-$kernel_lib = $opt_L ? $opt_L : "";
-$kernel_funcobjs = $opt_f ? "true" : "";
-$srclang = $opt_l ? $opt_l : "c";
-$templatedir = $opt_t ? $opt_t : "asp_sample";
-$dbgenv = $opt_d ? "TOPPERS_".$opt_d : "";
-$enable_trace = $opt_r ? "true" : "";
-$net_if = $opt_i;
-$net_dev = $opt_v;
-$net_proto = $opt_n;
-$trans_proto = $opt_s;
-$aspsampledir = "sample";
-
-#
-#  オブジェクトファイル名の拡張子を返す
-#
-sub get_objext {
-	local(@uname);
-
-	use POSIX;
-	@uname = do uname();
-	if ($uname[0] =~ /^cygwin/i) {
-		return("exe");
-	}
-	else {
-		return("");
-	}
-}
-
-#
-#  プログラムの場所を検索する
-#
-sub get_path {
-	local($progname, @pathlist) = @_;
-	local($path);
-
-	foreach $path (@pathlist) {
-		if (-x $path."/".$progname) {
-			return($path."/".$progname);
-		}
-	}
-	return("");
-}
-
-#
-#  Makefile を変換する
-#
-sub convMakefileSub {
-	local($infile, $outfile) = @_;
-	local($line, $varname, $varval);
-
-	unless (open(INFILE, $infile)) {
-		print STDERR "tinet_asp_configure: can't open $infile\n";
-		exit(1);
-	}
-	unless (open(OUTFILE, ">> ".$outfile)) {
-		print STDERR "tinet_asp_configure: can't open $outfile\n";
-		exit(1);
-	}
-
-	while ($line = <INFILE>) {
-		chop $line;
-		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
-			$line = $1.$vartable{$2}.$3;
-		}
-		print OUTFILE $line,"\n";
-	}
-
-	close(INFILE);
-	close(OUTFILE);
-}
-
-#
-#  Makefile を変換する
-#
-sub convMakefile {
-	local($infile, $copyright, $outfile) = @_;
-	local($aspMakefile);
-
-	# Mekfile 有ればリネームする。
-	print STDERR "tinet_asp_configure: Generating $outfile from $infile.\n";
-	if (-f $outfile) {
-		print STDERR "tinet_asp_configure: $outfile exists.",
-						"  Save as $outfile.bak.\n";
-		rename($outfile, $outfile.".bak");
-	}
-
-	# TINET のコピーライトを書き込む
-	&convMakefileSub($copyright, $outfile);
-
-	# 出力する Makefile をオープンする
-	unless (open(OUTFILE, ">> ".$outfile)) {
-		print STDERR "tinet_asp_configure: can't open $outfile\n";
-		exit(1);
-	}
-
-	# 参照する sample/Makefile をオープンする。
-	$aspMakefile = $aspsampledir."/Makefile";
-	unless (open(ASPFILE, $aspMakefile)) {
-		print STDERR "tinet_asp_configure: can't open $aspMakefile\n";
-		exit(1);
-	}
-
-	# 参照する sample/Makefile のコピーライトを読み飛ばす。
-	while ($line = <ASPFILE>) {
-		chop $line;
-		if ($line !~ /^#/) {
-			print OUTFILE $line,"\n";
-			last;
-		}
-	}
-
-	# 'APPLNAME = @(APPLNAME)' の行まで書き込む
-	while ($line = <ASPFILE>) {
-		chop $line;
-		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
-			$line = $1.$vartable{$2}.$3;
-		}
-		print OUTFILE $line,"\n";
-		if ($line =~ /^APPLNAME = /) {
-			last;
-		}
-	}
-
-	# '#' 前の行まで書き込む
-	while ($line = <ASPFILE>) {
-		chop $line;
-		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
-			$line = $1.$vartable{$2}.$3;
-		}
-		if ($line =~ /^#/) {
-			last;
-		}
-		print OUTFILE $line,"\n";
-	}
-
-	# 一度出力する Makefile をクローズする。
-	close(OUTFILE);
-
-	# TINET の Makefile を書き込む
-	&convMakefileSub($infile, $outfile);
-
-	# もう一度出力する Makefile をオープンする
-	unless (open(OUTFILE, ">> ".$outfile)) {
-		print STDERR "tinet_asp_configure: can't open $outfile\n";
-		exit(1);
-	}
-
-	# 参照する sample/Makefile の最終行まで書き込む
-	while ($line = <ASPFILE>) {
-		chop $line;
-		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
-			$line = $1.$vartable{$2}.$3;
-		}
-		print OUTFILE $line,"\n";
-	}
-
-	close(OUTFILE);
-	close(ASPFILE);
-}
-
-#
-#  Makefile を生成する
-#
-sub genMakefile {
-	local($file, $mandatory) = @_;
-	local($path, $copyright);
-
-	$path = $sampledir.$file.".".$applname;
-	$copyright = $sampledir.$file.".copyright";
-	if (-f $path) {
-		&convMakefile($path, $copyright, $file);
-		return;
-	}	
-
-	$path = $sampledir.$file;
-	if ($mandatory || -f $path) {
-		&convMakefile($path, $copyright, $file);
-	}	
-}
-
-#
-#  ファイルを変換する
-#
-sub convert {
-	local($infile, $outfile) = @_;
-	local($line, $varname, $varval);
-
-	print STDERR "tinet_asp_configure: Generating $outfile from $infile.\n";
-	if (-f $outfile) {
-		print STDERR "tinet_asp_configure: $outfile exists.",
-						"  Save as $outfile.bak.\n";
-		rename($outfile, $outfile.".bak");
-	}
-	unless (open(INFILE, $infile)) {
-		print STDERR "tinet_asp_configure: can't open $infile\n";
-		exit(1);
-	}
-	unless (open(OUTFILE, "> ".$outfile)) {
-		print STDERR "tinet_asp_configure: can't open $outfile\n";
-		exit(1);
-	}
-
-	while ($line = <INFILE>) {
-		chop $line;
-		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
-			$line = $1.$vartable{$2}.$3;
-		}
-		print OUTFILE $line,"\n";
-	}
-
-	close(INFILE);
-	close(OUTFILE);
-}
-
-#
-#  サンプルを見つけてファイルを生成する
-#
-sub generate {
-	local($file, $mandatory) = @_;
-	local($path);
-
-	$path = $sampledir.$file.".".$applname;
-	if (-f $path) {
-		do convert($path, $file);
-		return;
-	}	
-
-	$path = $sampledir.$file;
-	if ($mandatory || -f $path) {
-		do convert($path, $file);
-	}	
-}
-
-#
-#  TINET のソースディレクトリ名を取り出す
-#
-$pwd = `pwd`; chop $pwd;
-if ($opt_e) {
-	$tinetabsdir = $tinetdir = $opt_e;
-}
-elsif ($0 =~ /(.*)\/tinet_asp_configure/) {
-	$tinetdir = $1;
-	if ($tinetdir =~ /^\//) {
-		$tinetabsdir = $tinetdir;
-	}
-	else {
-		$tinetabsdir = $pwd."/".$tinetdir;
-	}
-}
-else {
-	$tinetabsdir = $tinetdir = $pwd;
-}
-$sampledir = $tinetdir."/".$templatedir."/";
-
-#
-#  ソースディレクトリ名を取り出す
-#
-$pwd = `pwd`; chop $pwd;
-if ($opt_D) {
-	$srcabsdir = $srcdir = $opt_D;
-}
-elsif ($0 =~ /(.*)\/tinet\/tinet_asp_configure/) {
-	$srcdir = $1;
-	if ($srcdir =~ /^\//) {
-		$srcabsdir = $srcdir;
-	}
-	else {
-		$srcabsdir = $pwd."/".$srcdir;
-	}
-}
-else {
-	$srcabsdir = $srcdir = $pwd;
-}
-$aspsampledir = $srcdir."/".$aspsampledir;
-
-$perl = $opt_p ? $opt_p : do get_path("perl", ("/usr/local/bin", "/usr/bin"));
-$cfg = $opt_g ? $opt_g : "\$(SRCDIR)/cfg/cfg/cfg";
-$cfgfile = $opt_g ? $opt_g : $srcdir."/cfg/cfg/cfg";
-
-#
-#  オプションの確認
-#
-unless ($opt_T) {
-	print STDERR "tinet_asp_configure: -T option is mandatory\n";
-	print STDERR "Installed targets are:\n";
-	foreach $targetname (<$srcdir/target/[a-zA-Z1-9]*>) {
-		$targetname =~ s|$srcdir/target/||;
-		print STDERR "\t$targetname\n";
-	}
-	exit(1);
-}
-unless ($opt_i) {
-	print STDERR "tinet_jsp_configure: -i option is mandatory\n";
-	exit(1);
-}
-else {
-	unless ($opt_v) {
-		print STDERR "tinet_jsp_configure: -v option is mandatory\n";
-		exit(1);
-	}
-}
-if ($opt_n) {
-	unless ($opt_n eq "inet4" || $opt_n eq "inet6") {
-		print STDERR "tinet_jsp_configure: inet4 or inet6 expected in -n option\n";
-		exit(1);
-	}
-}
-else {
-	print STDERR "tinet_jsp_configure: -n option is mandatory\n";
-	exit(1);
-}
-if ($opt_s) {
-	unless ($opt_s eq "tcp" || $opt_s eq "udp" || $opt_s eq "tcp/udp") {
-		print STDERR "tinet_jsp_configure: tcp, udp or tcp/udp expected in -s option\n";
-		exit(1);
-	}
-}
-else {
-	print STDERR "tinet_jsp_configure: -s option is mandatory\n";
-	exit(1);
-}
-
-#
-#  変数テーブルの作成
-#
-%vartable = ();
-$vartable{"TARGET"} = $target;
-$vartable{"APPLNAME"} = $applname;
-$vartable{"APPLDIR"} = $appldir;
-$vartable{"APPLOBJS"} = $applobjs;
-$vartable{"KERNEL_LIB"} = $kernel_lib;
-$vartable{"KERNEL_FUNCOBJS"} = $kernel_funcobjs;
-$vartable{"SRCDIR"} = $srcdir;
-$vartable{"SRCABSDIR"} = $srcabsdir;
-$vartable{"SRCLANG"} = $srclang;
-$vartable{"DBGENV"} = $dbgenv;
-$vartable{"ENABLE_TRACE"} = $enable_trace;
-$vartable{"PERL"} = $perl;
-$vartable{"CFG"} = $cfg;
-$objext = do get_objext();
-$vartable{"OBJEXT"} = $objext;
-$vartable{"TINETDIR"} = $tinetdir;
-$vartable{"TINETABSDIR"} = $tinetabsdir;
-$vartable{"NET_IF"} = $net_if;
-$vartable{"NET_DEV"} = $net_dev;
-
-#
-#  -n オプションの処理
-#
-
-$vartable{"SUPPORT_INET4"} = "#SUPPORT_INET4 = true";
-$vartable{"SUPPORT_INET6"} = "#SUPPORT_INET6 = true";
-if ($net_proto eq "inet4") {
-	$vartable{"SUPPORT_INET4"} = "SUPPORT_INET4 = true";
-}
-if ($net_proto eq "inet6") {
-	$vartable{"SUPPORT_INET6"} = "SUPPORT_INET6 = true";
-}
-
-#
-#  -s オプションの処理
-#
-
-$vartable{"SUPPORT_TCP"} = "#SUPPORT_TCP = true";
-$vartable{"SUPPORT_UDP"} = "#SUPPORT_UDP = true";
-if ($trans_proto eq "tcp" || $trans_proto eq "tcp/udp") {
-	$vartable{"SUPPORT_TCP"} = "SUPPORT_TCP = true";
-}
-if ($trans_proto eq "udp" || $trans_proto eq "tcp/udp") {
-	$vartable{"SUPPORT_UDP"} = "SUPPORT_UDP = true";
-}
-
-#
-#  ターゲットディレクトリのチェック
-#
-
-if (! -d $srcdir."/target/".$target) {
-	print STDERR "tinet_asp_configure: $srcdir/target/$target not exist\n";
-	exit(1);
-}
-
-#
-#  Makefile とアプリケーションファイルの生成
-#
-
-&genMakefile("Makefile", 1);
-do generate($applname.".c", 0);
-do generate($applname.".cpp", 0);
-do generate($applname.".h", 0);
-do generate($applname.".cfg", 0);
-do generate("tinet_".$applname.".cfg", 0);
-do generate("route_cfg.c", 0);
-do generate("tinet_app_config.h", 0);
-
-#
-#  cfg ができているかのチェック
-#
-
-if (!(-x ($objext == "" ? $cfgfile : $cfgfile.".".$objext))) {
-	print STDERR "Please compile the configurator (cfg).\n";
-}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_config.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_config.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_config.h	(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
  *
@@ -39,7 +39,9 @@
  */
 
-/* TCPの受動オープンをサポートする。*/
-
+/* TCPの受動オープンをサポートする【TINET 1.7 以降不要になった】。*/
+
+#if 0
 #define TCP_CFG_PASSIVE_OPEN
+#endif
 
 /* TCPのノンブロッキングコール機能を組込む。*/
@@ -104,4 +106,94 @@
 #endif
  */
+
+/*
+ *  TINET 1.5 との互換性のための定義
+ */
+
+/* ルーティング表のエントリ数の定義 */
+
+#define NUM_IN6_ROUTE_ENTRY			\
+	(NUM_IN6_STATIC_ROUTE_ENTRY + NUM_IN6_REDIRECT_ROUTE_ENTRY)
+					/* ルーティング表のエントリ数	*/
+
+#define NUM_IN4_ROUTE_ENTRY		\
+	(NUM_IN4_STATIC_ROUTE_ENTRY + NUM_IN4_REDIRECT_ROUTE_ENTRY)
+					/* ルーティング表のエントリ数	*/
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#else	/* #if defined(SUPPORT_INET4) */
+
+#ifndef NUM_IN6_STATIC_ROUTE_ENTRY
+#define NUM_IN6_STATIC_ROUTE_ENTRY	NUM_STATIC_ROUTE_ENTRY
+#endif
+
+#ifndef NUM_IN6_REDIRECT_ROUTE_ENTRY
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	NUM_REDIRECT_ROUTE_ENTRY
+#endif
+
+#ifdef  NUM_ROUTE_ENTRY
+#undef  NUM_ROUTE_ENTRY
+#endif
+#define NUM_ROUTE_ENTRY			NUM_IN6_ROUTE_ENTRY
+
+#endif	/* #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#ifndef NUM_IN4_STATIC_ROUTE_ENTRY
+#define NUM_IN4_STATIC_ROUTE_ENTRY	NUM_STATIC_ROUTE_ENTRY
+#endif
+
+#ifndef NUM_IN4_REDIRECT_ROUTE_ENTRY
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	NUM_REDIRECT_ROUTE_ENTRY
+#endif
+
+#ifdef  NUM_ROUTE_ENTRY
+#undef  NUM_ROUTE_ENTRY
+#endif
+#define NUM_ROUTE_ENTRY			NUM_IN4_ROUTE_ENTRY
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/* DHCP の定義 */
+
+#ifdef  DHCP4_CLI_CFG
+#define DHCP_CFG
+#endif
+
+/*
+ *  IPv6/IPv4 に関する定義
+ */
+
+/*
+ *  指定されたマクロに対する TINET 内部のマクロの定義
+ *
+ *    SUPPORT_INET6		 .   .  ON  ON  ON  ON
+ *    SUPPORT_INET4		ON  ON   .   .  ON  ON
+ *    API_CFG_IP4MAPPED_ADDR	 .  ON   .  ON   .  ON
+ *    ----------------------    ----------------------
+ *    _IP6_CFG                   .   .  ON  ON  ON  ON
+ *    _IP4_CFG                  ON  ON   .  ON  ON  ON
+ *    
+ */
+
+#if !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
+#error option selection: !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
+#endif
+
+#if defined(SUPPORT_INET6)
+#define	_IP6_CFG
+#endif
+
+#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
+#define _IP4_CFG
+#endif
 
 /*
@@ -211,57 +303,61 @@
 
 #ifndef TMO_IP4_FRAG_GET_NET_BUF
-#define TMO_IP4_FRAG_GET_NET_BUF	ULONG_C(1000*1000)	/* [ms]、IPv4 データグラム再構成用ネットワークバッファ獲得タイムアウト	*/
+#define TMO_IP4_FRAG_GET_NET_BUF	ULONG_C(1000000)	/* [us]、IPv4 データグラム再構成用ネットワークバッファ獲得タイムアウト	*/
 #endif
 
 #ifndef TMO_IP6_FRAG_GET_NET_BUF
-#define TMO_IP6_FRAG_GET_NET_BUF	ULONG_C(1000*1000)	/* [ms]、IPv6 データグラム再構成用ネットワークバッファ獲得タイムアウト	*/
+#define TMO_IP6_FRAG_GET_NET_BUF	ULONG_C(1000000)	/* [us]、IPv6 データグラム再構成用ネットワークバッファ獲得タイムアウト	*/
 #endif
 
 #ifndef TMO_PPP_GET_NET_BUF
-#define TMO_PPP_GET_NET_BUF		ULONG_C(1000*1000)	/* [ms]、PPP 受信用ネットワークバッファ獲得タイムアウト	*/
+#define TMO_PPP_GET_NET_BUF		ULONG_C(1000000)	/* [us]、PPP 受信用ネットワークバッファ獲得タイムアウト	*/
 #endif
 
 #ifndef TMO_ARP_GET_NET_BUF
-#define TMO_ARP_GET_NET_BUF		ULONG_C(1000*1000)	/* [ms]、ARP のネットワークバッファ獲得タイムアウト	*/
+#define TMO_ARP_GET_NET_BUF		ULONG_C(1000000)	/* [us]、ARP のネットワークバッファ獲得タイムアウト	*/
 #endif
 
 #ifndef TMO_TCP_GET_NET_BUF
-#define TMO_TCP_GET_NET_BUF		ULONG_C(1000*1000)	/* [ms]、TCP のネットワークバッファ獲得タイムアウト	*/
+#define TMO_TCP_GET_NET_BUF		ULONG_C(1000000)	/* [us]、TCP のネットワークバッファ獲得タイムアウト	*/
 #endif
 
 #ifndef TMO_TCP_OUTPUT
-#define TMO_TCP_OUTPUT			ULONG_C(1000*1000)	/* [ms]、TCP 出力タイムアウト				*/
+#define TMO_TCP_OUTPUT			ULONG_C(1000000)	/* [us]、TCP 出力タイムアウト				*/
 #endif
 
 #ifndef TMO_UDP_OUTPUT
-#define TMO_UDP_OUTPUT			ULONG_C(1000*1000)	/* [ms]、UDP 出力タイムアウト				*/
+#define TMO_UDP_OUTPUT			ULONG_C(1000000)	/* [us]、UDP 出力タイムアウト				*/
 #endif
 
 #ifndef TMO_ICMP_OUTPUT
-#define TMO_ICMP_OUTPUT			ULONG_C(1000*1000)	/* [ms]、ICMP 出力タイムアウト				*/
+#define TMO_ICMP_OUTPUT			ULONG_C(1000000)	/* [us]、ICMP 出力タイムアウト				*/
+#endif
+
+#ifndef TMO_IGMP_OUTPUT
+#define TMO_IGMP_OUTPUT			ULONG_C(1000000)	/* [us]、IGMP 出力タイムアウト				*/
 #endif
 
 #ifndef TMO_ND6_NS_OUTPUT
-#define TMO_ND6_NS_OUTPUT		ULONG_C(1000*1000)	/* [ms]、近隣要請出力タイムアウト			*/
+#define TMO_ND6_NS_OUTPUT		ULONG_C(1000000)	/* [us]、近隣要請出力タイムアウト			*/
 #endif
 
 #ifndef TMO_ND6_NA_OUTPUT
-#define TMO_ND6_NA_OUTPUT		ULONG_C(1000*1000)	/* [ms]、近隣通知出力タイムアウト			*/
+#define TMO_ND6_NA_OUTPUT		ULONG_C(1000000)	/* [us]、近隣通知出力タイムアウト			*/
 #endif
 
 #ifndef TMO_ND6_RS_OUTPUT
-#define TMO_ND6_RS_OUTPUT		ULONG_C(1000*1000)	/* [ms]、ルータ要請出力タイムアウト			*/
+#define TMO_ND6_RS_OUTPUT		ULONG_C(1000000)	/* [us]、ルータ要請出力タイムアウト			*/
 #endif
 
 #ifndef TMO_ARP_OUTPUT
-#define TMO_ARP_OUTPUT			ULONG_C(1000*1000)	/* [ms]、アドレス解決要求出力タイムアウト		*/
+#define TMO_ARP_OUTPUT			ULONG_C(1000000)	/* [us]、アドレス解決要求出力タイムアウト		*/
 #endif
 
 #ifndef TMO_ND6_RTR_SOL_DELAY
-#define TMO_ND6_RTR_SOL_DELAY		ULONG_C(1000*1000)	/* [ms]、ルータ要請出力遅延				*/
+#define TMO_ND6_RTR_SOL_DELAY		ULONG_C(1000000)	/* [us]、ルータ要請出力遅延				*/
 #endif
 
 #ifndef TMO_ND6_RTR_SOL_INTERVAL
-#define TMO_ND6_RTR_SOL_INTERVAL	ULONG_C(4000*1000)	/* [ms]、ルータ要請出力間隔				*/
+#define TMO_ND6_RTR_SOL_INTERVAL	ULONG_C(4000000)	/* [us]、ルータ要請出力間隔				*/
 #endif
 
@@ -387,10 +483,5 @@
 #include <net/net_rename.h>
 #include <netinet/in_rename.h>
-
-#ifdef SUPPORT_INET6
-
 #include <netinet6/in6_rename.h>
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif /* _TINET_CONFIG_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_defs.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_defs.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_defs.h	(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
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_kernel_defs.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_kernel_defs.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_kernel_defs.h	(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
  *
