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_ */
