Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -67,6 +67,4 @@
 #define _AH_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  RFC2402 認証ヘッダ
@@ -80,7 +78,5 @@
 	uint32_t	spi;	/* Security Parameter Index (SPI)	*/
 	uint32_t	seq;	/* シーケンス番号			*/
-	} __attribute__((packed, aligned(2)))T_IP6_AH_HDR;
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+	} __attribute__((packed, aligned(2))) T_IP6_AH_HDR;
 
 #endif	/* of #ifndef _AH_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah6.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -67,6 +67,4 @@
 #define _AH6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
@@ -75,5 +73,3 @@
 extern uint_t ah6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _AH6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ah_input.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -82,4 +82,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/if.h>
 #include <net/if_loop.h>
@@ -92,14 +93,13 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah.h>
 #include <netinet6/ah6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -116,3 +116,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/dest6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -88,16 +88,16 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -163,3 +163,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
@@ -68,6 +68,4 @@
 #define _ESP_H_
 
-#if defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC)
-
 /*
  *  RFC2406 暗号化ヘッダ
@@ -129,5 +127,3 @@
 #endif	/* of #ifdef T_IPSEC_REQUEST_DEFINED */
 
-#endif /* defined(SUPPORT_INET6) || defined(SUPPORT_IPSEC) */
-
 #endif	/* of #ifndef _ESP_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp6.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -67,6 +67,4 @@
 #define _ESP6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
@@ -75,5 +73,3 @@
 extern uint_t esp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _ESP6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/esp_input.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -88,14 +88,14 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah.h>
 #include <netinet6/ah6.h>
@@ -103,5 +103,5 @@
 #include <netinet6/esp6.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -122,3 +122,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/frag6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -92,4 +92,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_var.h>
@@ -97,12 +98,11 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 #ifdef IP6_CFG_FRAGMENT
@@ -606,5 +606,5 @@
 			/* 送信先アドレスを元に戻す。*/
 			ip6h = GET_IP6_HDR(input);
-			ip6h->dst = ip6_frag_dest[ip6fq - ip6_frag_queue];
+			memcpy(&ip6h->dst, &ip6_frag_dest[ip6fq - ip6_frag_queue], sizeof(T_IN6_ADDR));
 
 			/* offp を、再構成した断片の先頭に設定する。*/
@@ -669,3 +669,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/icmp6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -106,4 +106,5 @@
 #include <sil.h>
 #include <t_syslog.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -113,4 +114,5 @@
 #include <s_services.h>
 #include <t_services.h>
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -124,4 +126,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
@@ -130,15 +133,14 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 /*
@@ -178,5 +180,5 @@
 		return;
 		}
-	ip6h->src = ia->addr;
+	memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
 
 	icmp6h = GET_ICMP6_HDR(output, off);
@@ -241,7 +243,7 @@
 
 	/* IPv6 ヘッダの発信元アドレスと宛先アドレスを入替える。*/
-	dst 	  = ip6h->dst;
-	ip6h->dst = ip6h->src;
-	ip6h->src = dst;
+	memcpy(&dst, &ip6h->dst, sizeof(T_IN6_ADDR));
+	memcpy(&ip6h->dst, &ip6h->src, sizeof(T_IN6_ADDR));
+	memcpy(&ip6h->src, &dst, sizeof(T_IN6_ADDR));
 
 	/*
@@ -256,10 +258,10 @@
 			}
 		else
-			ip6h->src = ia->addr;
+			memcpy(&ip6h->src, &ia->addr, sizeof(T_IN6_ADDR));
 		}
 
 	/* 次ヘッダとホップリミットを設定する。*/
 	ip6h->next = IPPROTO_ICMPV6;
-	ip6h->hlim = IP_DEFTTL;
+	ip6h->hlim = IP6_DEFTTL;
 
 	/* チェックサムを計算する。*/
@@ -299,15 +301,26 @@
 	loff = ip6_lasthdr(input, poff + ICMP6_HDR_SIZE, IPPROTO_IPV6, &next);
 
-	/* 最終ヘッダが TCP のみ対応する。*/
-	if (loff >= 0 && next == IPPROTO_TCP) {
-
-#ifdef SUPPORT_TCP
+	/* 最終ヘッダが TCP/UDP のみ対応する。*/
+	if (loff >= 0 && (next == IPPROTO_TCP || next == IPPROTO_UDP)) {
 
 		memcpy(GET_IP6_HDR(input), input->buf + (loff + ICMP6_HDR_SIZE),
 		                           input->len - (loff + ICMP6_HDR_SIZE));
 		input->len -= loff + ICMP6_HDR_SIZE;
-		tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
-
-#endif	/* of #ifdef SUPPORT_TCP */
+
+#if defined(SUPPORT_TCP)
+
+		if (next == IPPROTO_TCP)
+
+			tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+		if (next == IPPROTO_UDP)
+
+			udp6_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
 
 		}
@@ -340,5 +353,6 @@
 #endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 /*
@@ -350,5 +364,5 @@
 {
 	T_IP6_HDR		*ip6h;
-	T_IN6_ADDR		*gw;
+	const T_IN6_ADDR	*gw;
 	T_ND_REDIRECT_HDR	*rdh;
 	T_ND_OPT_HDR		*opth;
@@ -440,5 +454,6 @@
 	}
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
 
 /*
@@ -472,5 +487,5 @@
 
 	/* チェックサムを計算する。*/
-	if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP_HDR_SIZE)) & 0xffff) != 0) {
+	if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE)) & 0xffff) != 0) {
 		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
 		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
@@ -530,5 +545,6 @@
 		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRedirects, 1);
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 		if (code != 0 || len < ND_REDIRECT_HDR_SIZE)
@@ -537,9 +553,14 @@
 		return IPPROTO_DONE;
 
-#else	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
+
+		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
+
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
 
 		break;
@@ -571,5 +592,5 @@
 	case ICMP6_FQDN_QUERY:			/* FQDN 照会			*/
 	case ICMP6_FQDN_REPLY:			/* FQDN 応答			*/
-		syslog(LOG_WARNING, "[ICMP6] unsupported type: %d.", icmp6h->type);
+		syslog(LOG_INFO, "[ICMP6] unsupported type: %d.", icmp6h->type);
 		break;
 
@@ -693,3 +714,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -87,4 +87,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_timer.h>
 #include <net/net_buf.h>
@@ -92,4 +93,5 @@
 
 #include <netinet/in.h>
+#include <netinet/in_var.h>
 #include <netinet/ip.h>
 #include <netinet/if_ether.h>
@@ -98,7 +100,7 @@
 #include <netinet6/in6_var.h>
 
-#include <net/if6_var.h>
+#include <net/if_var.h>
 
-#if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER)
+#if defined(_IP6_CFG) && defined(SUPPORT_ETHER)
 
 /*
@@ -107,5 +109,5 @@
 
 void
-ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr)
+ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr)
 {
 	eaddr->lladdr[0] = UINT_C(0x33);
@@ -117,3 +119,3 @@
 	}
 
-#endif /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_ETHER) */
+#endif /* of #if defined(_IP6_CFG) && defined(SUPPORT_ETHER) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/if6_ether.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -68,13 +68,9 @@
 #define _IF6_ETHER_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  関数
  */
 
-extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, T_IN6_ADDR *maddr);
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr);
 
 #endif	/* of #ifndef _IF6_ETHER_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -126,7 +126,11 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_timer.h>
 #include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
@@ -135,7 +139,7 @@
 #include <netinet6/in6_ifattach.h>
 
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -143,11 +147,11 @@
  */
 
-T_IN6_ADDR in6_addr_unspecified =
+const T_IN6_ADDR in6_addr_unspecified =
 	IPV6_ADDR_UNSPECIFIED_INIT;
 
-T_IN6_ADDR in6_addr_linklocal_allnodes =
+const T_IN6_ADDR in6_addr_linklocal_allnodes =
 	IPV6_ADDR_LINKLOCAL_ALLNODES_INIT;
 
-T_IN6_ADDR in6_addr_linklocal_allrouters =
+const T_IN6_ADDR in6_addr_linklocal_allrouters =
 	IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT;
 
@@ -172,5 +176,5 @@
 
 static ER
-in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr, uint_t prefix_len)
+in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr, uint_t prefix_len)
 {
 	/* アドレスとプレフィックス長を設定する。*/
@@ -200,5 +204,5 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		memset(ia, sizeof(T_IN6_IFADDR), 0);
 		ia->router_index = IN6_RTR_IX_UNREACH;
@@ -226,5 +230,5 @@
 
 int_t
-in6_addr2ifaix (T_IN6_ADDR *addr)
+in6_addr2ifaix (const T_IN6_ADDR *addr)
 {
 	T_IFNET		*ifp = IF_GET_IFNET();
@@ -233,5 +237,5 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
 		    in6_are_prefix_equal(addr, &ia->addr, ia->prefix_len))
@@ -247,5 +251,5 @@
 
 int_t
-in6_addr2maix (T_IN6_ADDR *addr)
+in6_addr2maix (const T_IN6_ADDR *addr)
 {
 	if (addr->s6_addr8[0] == 0xff) {
@@ -268,5 +272,5 @@
 
 ER
-in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
+in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
                 uint_t prefix_len, uint32_t vltime, uint32_t pltime,
                 int_t router_index, int_t prefix_index, uint_t flags)
@@ -365,5 +369,5 @@
 in6ifa_ifpwithix (T_IFNET *ifp, int_t ix)
 {
-	return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in_ifaddrs[ix] : NULL;
+	return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in6_ifaddrs[ix] : NULL;
 	}
 
@@ -379,16 +383,16 @@
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
-		if (ifp->in_ifaddrs[ix].router_index == router_index)
-			return &ifp->in_ifaddrs[ix];
+		if (ifp->in6_ifaddrs[ix].router_index == router_index)
+			return &ifp->in6_ifaddrs[ix];
 	return NULL;
 	}
 
 /*
- * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレスを、
+ * in6_ifawithifp -- 宛先アドレスにふさわしい送信元アドレス情報を、
  *                   ネットワークインタフェースから探索する。
  */
 
 T_IN6_IFADDR *
-in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst)
+in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst)
 {
 	uint_t	scope;
@@ -397,18 +401,36 @@
 	/* 宛先アドレスと同じスコープのアドレスを返す。*/
 	if ((ix = in6_addr2ifaix(dst)) != IPV6_IFADDR_IX_INVALID)
-		return &ifp->in_ifaddrs[ix];
+		return &ifp->in6_ifaddrs[ix];
 	else if ((ix = in6_addr2maix(dst)) == IPV6_MADDR_IX_SOL_NODE ||
 	          ix                       == IPV6_MADDR_IX_LL_ALL_NODE)
-		return &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+		return &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 	else {
 		scope = in6_addrscope(dst);
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-			    (ifp->in_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
-			    in6_addrscope(&ifp->in_ifaddrs[ix].addr) == scope) {
-				return &ifp->in_ifaddrs[ix];
+			if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+			    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
+			    in6_addrscope(&ifp->in6_ifaddrs[ix].addr) == scope) {
+				return &ifp->in6_ifaddrs[ix];
 				}
 			}
 		return NULL;
+		}
+	}
+
+/*
+ * in6_addrwithifp -- 宛先アドレスにふさわしい送信元アドレスを、
+ *                    ネットワークインタフェースから探索する。
+ */
+
+const T_IN6_ADDR *
+in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst)
+{
+	T_IN6_IFADDR *ifaddr;
+
+	if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
+		return NULL;
+	else {
+		*src = ifaddr->addr;
+		return src;
 		}
 	}
@@ -431,7 +453,7 @@
 	dad_delay = 0;
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
-		if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-		    (ifp->in_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
-			nd6_dad_start(ifp, &ifp->in_ifaddrs[ix], &dad_delay);
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
+			nd6_dad_start(ifp, &ifp->in6_ifaddrs[ix], &dad_delay);
 #endif	/* of #if 0 */
 
@@ -449,5 +471,5 @@
 
 bool_t
-in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix, uint_t prefix_len)
+in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix, uint_t prefix_len)
 {
 	uint_t bitlen, bytelen;
@@ -478,5 +500,5 @@
 	syscall(get_tim(&now));
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 
 		if ((ia->flags & IN6_IFF_DEFINED) == 0)
@@ -500,3 +522,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -103,4 +103,10 @@
 
 /*
+ *  IPv6 アドレス構造
+ *
+ *    RFC4291（RFC1884、RFC2373、RFC3513 のアップデート）
+ */
+
+/*
  *  IPv6 アドレス
  */
@@ -150,38 +156,4 @@
 
 /*
- *  アドレスの定義
- */
-
-#ifdef _NET_CFG_BYTE_ORDER
-
-#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
-
-#define IPV6_ADDR_INT32_ONE		ULONG_C(0x00000001)
-#define IPV6_ADDR_INT32_TWO		ULONG_C(0x00000002)
-#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0x0000ffff)
-#define IPV6_ADDR_INT32_MNL		ULONG_C(0xff010000)
-#define IPV6_ADDR_INT32_MLL		ULONG_C(0xff020000)
-#define IPV6_ADDR_INT32_ULL		ULONG_C(0xfe800000)
-#define IPV6_ADDR_INT16_ULL		UINT_C(0xfe80)
-#define IPV6_ADDR_INT16_USL		UINT_C(0xfec0)
-#define IPV6_ADDR_INT16_MLL		UINT_C(0xff02)
-
-#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
-
-#define IPV6_ADDR_INT32_ONE		ULONG_C(0x01000000)
-#define IPV6_ADDR_INT32_TWO		ULONG_C(0x02000000)
-#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0xffff0000)
-#define IPV6_ADDR_INT32_MNL		ULONG_C(0x000001ff)
-#define IPV6_ADDR_INT32_MLL		ULONG_C(0x000002ff)
-#define IPV6_ADDR_INT32_ULL		ULONG_C(0x000080fe)
-#define IPV6_ADDR_INT16_ULL		UINT_C(0x80fe)
-#define IPV6_ADDR_INT16_USL		UINT_C(0xc0fe)
-#define IPV6_ADDR_INT16_MLL		UINT_C(0x02ff)
-
-#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
-
-#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
-
-/*
  *  特別なアドレスのチェック
  */
@@ -197,17 +169,4 @@
 	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
 	 (a)->s6_addr8[15] == 0x01)
-
-/* IPv4 互換 */
-
-#define IN6_IS_ADDR_V4COMPAT(a)		\
-	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
-	 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
-
-/* IPv4 マップ */
-
-#define IN6_IS_ADDR_V4MAPPED(a)		\
-	(((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
 
 /*
@@ -248,12 +207,4 @@
 #define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr8[0] == UINT_C(0xff))
 
-/* 要請マルチキャスト */
-
-#define IN6_IS_ADDR_NS_MULTICAST(a)	\
-	(((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
-	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
-	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
-	 ((a)->s6_addr8[12] == UINT_C(0xff)))
-
 /*
  *  同一のチェック
@@ -272,5 +223,6 @@
  */
 
-#define IPV6_DEFAULT_MULTICAST_HOPS	1	/* マルチキャスト時のホップリミットの規定値 */
+#define IPV6_DEFAULT_MULTICAST_HOPS	1	/* マルチキャスト時のホップリミットの規定値	*/
+#define ND6_INFINITE_LIFETIME		0xffffffff	/* アドレスの無制限有効時間		*/
 
 /*
@@ -282,4 +234,6 @@
 	uint16_t	portno;		/* ポート番号	*/
 	} T_IPV6EP;
+
+#define T_IPV6EP_DEFINED
 
 /*
@@ -299,8 +253,4 @@
 	/* 実装依存 */
 	} T_TCP6_CREP;
-
-#if defined(SUPPORT_INET6)
-#define T_TCP_CREP	T_TCP6_CREP
-#endif
 
 /*
@@ -316,28 +266,4 @@
 	} T_UDP6_CCEP;
 
-#if defined(SUPPORT_INET6)
-#define T_UDP_CCEP	T_UDP6_CCEP
-#endif
-
-/*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#if defined(SUPPORT_INET6)
-
-#define T_IN_ADDR			T_IN6_ADDR
-#define T_IPEP				T_IPV6EP
-#define IP_ADDRANY			IPV6_ADDRANY
-
-#define IN_ARE_ADDR_EQUAL(n,h)		IN6_ARE_ADDR_EQUAL(n,h)
-#define IN_ARE_NET_ADDR_EQUAL(n,h)	IN6_ARE_ADDR_EQUAL(n,h)
-#define IN_COPY_TO_NET(d,s)		memcpy(d,s,sizeof(T_IN6_ADDR))
-#define IN_COPY_TO_HOST(d,s)		memcpy(d,s,sizeof(T_IN6_ADDR))
-#define IN_IS_ADDR_MULTICAST(a)		IN6_IS_ADDR_MULTICAST(a)
-#define IN_IS_NET_ADDR_MULTICAST(a)	IN6_IS_ADDR_MULTICAST(a)
-#define IN_IS_ADDR_ANY(a)		IN6_IS_ADDR_UNSPECIFIED(a)
-
-#endif	/* of #if defined(SUPPORT_INET6) */
-
 /*
  *  前方参照
@@ -356,7 +282,7 @@
  */
 
-extern T_IN6_ADDR in6_addr_unspecified;
-extern T_IN6_ADDR in6_addr_linklocal_allnodes;
-extern T_IN6_ADDR in6_addr_linklocal_allrouters;
+extern const T_IN6_ADDR in6_addr_unspecified;
+extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
+extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
 
 #define ipv6_addrany	in6_addr_unspecified
@@ -366,7 +292,12 @@
  */
 
-extern char *ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr);
-extern ER_UINT in6_get_maxnum_ifaddr (void);
+extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
+extern uint_t in6_get_maxnum_ifaddr (void);
 extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
+extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
+                          uint32_t vltime, uint32_t pltime);
+extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
+extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
+extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
 
 #endif	/* of #ifndef _IN6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -87,4 +87,8 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
@@ -93,7 +97,7 @@
 #include <netinet6/in6_ifattach.h>
 
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -126,4 +130,18 @@
 #endif	/* of #ifdef SUPPORT_ETHER */
 
+#ifdef SUPPORT_PPP
+
+/*
+ * get_rand_ifid -- 乱数により、インタフェース識別子を設定する。
+ */
+
+static ER
+get_rand_ifid (T_IFNET *ifp, T_IN6_ADDR *ifra_addr)
+{
+	return E_OK;
+	}
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
 #ifdef IP6_CFG_AUTO_LINKLOCAL
 
@@ -149,5 +167,5 @@
 
 	/* インタフェースのアドレス情報を更新する。*/
-	if ((error = in6_update_ifa(ifp, &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
+	if ((error = in6_update_ifa(ifp, &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
 	                            &addr, 64, ND6_INFINITE_LIFETIME,
 	                                       ND6_INFINITE_LIFETIME, 
@@ -171,5 +189,5 @@
 #ifdef IP6_CFG_AUTO_LINKLOCAL
 
-	if ((ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
+	if ((ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
 		if ((error = in6_ifattach_linklocal(ifp)) != E_OK)
 			return error;
@@ -180,3 +198,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_ifattach.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_rename.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -41,20 +41,17 @@
 /* netinet6/in6.c */
 
+#define in6_are_prefix_equal	_tinet_in6_are_prefix_equal
+#define in6ifa_ifpwithrtrix	_tinet_in6ifa_ifpwithrtrix
+#define in6_if_up		_tinet_in6_if_up
+#define in6_if2idlen		_tinet_in6_if2idlen
+#define in6_ifaddr_timer	_tinet_in6_ifaddr_timer
+#define in6ifa_ifpwithix	_tinet_in6ifa_ifpwithix
+#define in6_addr2maix		_tinet_in6_addr2maix
+#define in6_ifawithifp		_tinet_in6_ifawithifp
+#define in6_addr2ifaix		_tinet_in6_addr2ifaix
+#define in6_update_ifa		_tinet_in6_update_ifa
+#define in6_ifainit		_tinet_in6_ifainit
+#define in6_addrwithifp		_tinet_in6_addrwithifp
 #define in6_addr_loopback	_tinet_in6_addr_loopback
-#define in6_ifainit		_tinet_in6_ifainit
-#define in6_addr2ifaix		_tinet_in6_addr2ifaix
-#define in6_addr2maix		_tinet_in6_addr2maix
-#define in6_update_ifa		_tinet_in6_update_ifa
-#define in6ifa_ifpwithix	_tinet_in6ifa_ifpwithix
-#define in6ifa_ifpwithrtrix	_tinet_in6ifa_ifpwithrtrix
-#define in6_ifawithifp		_tinet_in6_ifawithifp
-#define in6_if_up		_tinet_in6_if_up
-#define in6_rtalloc		_tinet_in6_rtalloc
-#define in6_are_prefix_equal	_tinet_in6_are_prefix_equal
-#define in6_addr_linklocal_allrouters	\
-				_tinet_in6_addr_linklocal_allrouters
-#define in6_addr_linklocal_allnodes	\
-				_tinet_in6_addr_linklocal_allnodes
-#define in6_ifaddr_timer	_tinet_in6_ifaddr_timer
 
 /* netinet6/in6_ifattach.c */
@@ -64,17 +61,23 @@
 /* netinet6/in6_subr.c */
 
+#define inn6_is_dstaddr_accept	_tinet_inn6_is_dstaddr_accept
+#define in6_lookup_ifaddr	_tinet_in6_lookup_ifaddr
+#define in6_rtalloc		_tinet_in6_rtalloc
+#define in6_get_ifaddr		_tinet_in6_get_ifaddr
+#define in6_cksum		_tinet_in6_cksum
+#define in6_gateway_lookup	_tinet_in6_gateway_lookup
+#define in6_is_dstaddr_accept	_tinet_in6_is_dstaddr_accept
+#define in6_hostcache_getmtu	_tinet_in6_hostcache_getmtu
+#define in6_set_header		_tinet_in6_set_header
+#define in6_get_datagram	_tinet_in6_get_datagram
+#define in6_rtredirect		_tinet_in6_rtredirect
+#define get_ip6_hdr_size	_tinet_get_ip6_hdr_size
+#define in6_plen2pmask		_tinet_in6_plen2pmask
+#define in6_rtnewentry		_tinet_in6_rtnewentry
+#define in6_rtinit		_tinet_in6_rtinit
+#define in6_rttimer		_tinet_in6_rttimer
 #define in6_lookup_multi	_tinet_in6_lookup_multi
-#define get_ip6_hdr_size	_tinet_get_ip6_hdr_size
-#define in6_lookup_ifaddr	_tinet_in6_lookup_ifaddr
-#define in6_get_datagram	_tinet_in6_get_datagram
-#define in6_cksum		_tinet_in6_cksum
-#define in6_is_dstaddr_accept	_tinet_in6_is_dstaddr_accept
-#define in6_plen2pmask		_tinet_in6_plen2pmask
+#define in6_hostcache_update	_tinet_in6_hostcache_update
 #define in6_init		_tinet_in6_init
-#define in6_rtredirect		_tinet_in6_rtredirect
-#define in6_gateway_lookup	_tinet_in6_gateway_lookup
-#define in6_set_header		_tinet_in6_set_header
-#define in6_hostcache_getmtu	_tinet_in6_hostcache_getmtu
-#define in6_hostcache_update	_tinet_in6_hostcache_update
 
 /* netinet6/if6_ether.c */
@@ -151,9 +154,17 @@
 /* netinet6/nd6_rtr.c */
 
+#define nd6_get_prl		_tinet_nd6_get_prl
 #define nd6_router_lookup	_tinet_nd6_router_lookup
+#define nd6_onlink_prefix_lookup	\
+				_tinet_nd6_onlink_prefix_lookup
+#define nd6_defrtrlist_del	_tinet_nd6_defrtrlist_del
+#define nd6_prefix_onlink	_tinet_nd6_prefix_onlink
+#define nd6_get_drl		_tinet_nd6_get_drl
+#define nd6_rtrsol_ctl		_tinet_nd6_rtrsol_ctl
 #define nd6_defrtrlist_timer	_tinet_nd6_defrtrlist_timer
+#define nd6_ra_input		_tinet_nd6_ra_input
 #define nd6_prelist_timer	_tinet_nd6_prelist_timer
-#define nd6_ra_input		_tinet_nd6_ra_input
-#define nd6_rtrsol_ctl		_tinet_nd6_rtrsol_ctl
+#define nd6_prefix_offlink	_tinet_nd6_prefix_offlink
+#define nd6_defrtrlist_lookup	_tinet_nd6_defrtrlist_lookup
 #define ip6_defhlim		_tinet_ip6_defhlim
 #define nd6_reachable_time	_tinet_nd6_reachable_time
@@ -162,10 +173,4 @@
 				_tinet_nd6_recalc_reachtm_interval
 #define nd6_retrans_time	_tinet_nd6_retrans_time
-#define nd6_defrtrlist_lookup	_tinet_nd6_defrtrlist_lookup
-#define nd6_prefix_onlink	_tinet_nd6_prefix_onlink
-#define nd6_prefix_offlink	_tinet_nd6_prefix_offlink
-#define nd6_get_prl		_tinet_nd6_get_prl
-#define nd6_get_drl		_tinet_nd6_get_drl
-#define nd6_defrtrlist_del	_tinet_nd6_defrtrlist_del
 
 /* netinet6/scope6.c */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -122,4 +122,5 @@
 #include <net/if_arp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -128,15 +129,128 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <netinet6/nd6.h>
 #include <netinet6/ah.h>
-#include <netinet6/nd6.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+/*
+ *  in6_make_ipv4mapped -- IPv4 射影アドレスを生成する。
+ *
+ *  注意:
+ *    src はホストバイトオーダー
+ *
+ */
+
+T_IN6_ADDR *
+in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src)
+{
+	dst->s6_addr32[0] = ULONG_C(0x00000000);
+	dst->s6_addr32[1] = ULONG_C(0x00000000);
+	dst->s6_addr32[2] = IPV6_ADDR_INT32_0000FFFF;
+	dst->s6_addr32[3] = htonl(src);
+
+	return dst;
+	}
+
+#ifdef _IP6_CFG
+
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in6_rtinit -- ルーティング表を初期化する。
+ */
+
+void
+in6_rtinit (void)
+{
+	int_t ix;
+
+	for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = IN_RTF_DEFINED;
+
+	for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = 0;
+	}
+
+/*
+ *  in6_rtnewentry -- 新しいエントリを獲得する。
+ */
+
+T_IN6_RTENTRY *
+in6_rtnewentry (uint8_t flags, uint32_t tmo)
+{
+	SYSTIM		now;
+	T_IN6_RTENTRY	*rt, *frt = NULL;
+	int_t		ix;
+
+	/* 空きエントリを探す。*/
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+		rt = &routing6_tbl[ix];
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
+			frt = rt;
+			break;
+			}
+		}
+
+	/* expire の単位は [s]。*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (frt == NULL) {
+		/* 空きがなければ、有効時間がもっとも短いエントリを空きにする。*/
+		T_IN6_RTENTRY	*srt = NULL;
+		int_t		diff, sdiff = INT_MAX;
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+			rt = &routing6_tbl[ix];
+			diff = (int_t)(rt->expire - now);
+			if (diff <= 0) {	/* rt->expire <= now */
+				/* 既に、有効時間が過ぎている。*/
+				frt = rt;
+				break;
+				}
+			else if (diff < sdiff) {
+				srt = rt;
+				sdiff = diff;
+				}
+			}
+		if (frt == NULL)
+			frt = srt;
+		frt->flags = 0;
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+		}
+
+	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
+	frt->expire = now + tmo / SYSTIM_HZ;
+	return frt;
+	}
+
+/*
+ *  in6_rttimer -- ルーティング表の管理タイマー
+ */
+
+void
+in6_rttimer (void)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	/* expire の単位は [s]。*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (int_t)(routing6_tbl[ix].expire - now) <= 0)
+			routing6_tbl[ix].flags = 0;
+	syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+	}
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #if NUM_IN6_HOSTCACHE_ENTRY > 0
@@ -155,12 +269,12 @@
 
 T_IN6_IFADDR *
-in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr)
+in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr)
 {
 	int_t ix;
 
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		if ((ifp->in_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
-		    IN6_ARE_ADDR_EQUAL(addr, &ifp->in_ifaddrs[ix].addr))
-			return &ifp->in_ifaddrs[ix];
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(addr, &ifp->in6_ifaddrs[ix].addr))
+			return &ifp->in6_ifaddrs[ix];
 		}
 	return NULL;
@@ -172,10 +286,10 @@
 
 bool_t
-in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr)
+in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr)
 {
 	int_t ix;
 
 	for (ix = MAX_IN6_MADDR_CNT; ix -- > 0; )
-		if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in_maddrs[ix]))
+		if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in6_maddrs[ix]))
 			return true;
 	return false;
@@ -188,5 +302,5 @@
 ER
 in6_set_header (T_NET_BUF *nbuf, uint_t len,
-                T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                 uint8_t next, uint8_t hlim)
 {
@@ -216,10 +330,10 @@
 		memset(&ip6h->dst, 0, sizeof(T_IN6_ADDR));
 	else
-		ip6h->dst = *dstaddr;
+		memcpy(&ip6h->dst, dstaddr, sizeof(T_IN6_ADDR));
 
 	if (srcaddr == NULL)
 		memset(&ip6h->src, 0, sizeof(T_IN6_ADDR));
 	else
-		ip6h->src = *srcaddr;
+		memcpy(&ip6h->src, srcaddr, sizeof(T_IN6_ADDR));
 
 	return E_OK;
@@ -232,5 +346,5 @@
 ER
 in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                  const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                   uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
 {
@@ -269,5 +383,5 @@
  */
 
-ER_UINT
+uint_t
 in6_get_maxnum_ifaddr (void)
 {
@@ -285,6 +399,6 @@
 
 	if (index < NUM_IN6_IFADDR_ENTRY &&
-	    (ifp->in_ifaddrs[index].flags & IN6_IFF_DEFINED))
-		return &ifp->in_ifaddrs[index].addr;
+	    (ifp->in6_ifaddrs[index].flags & IN6_IFF_DEFINED))
+		return &ifp->in6_ifaddrs[index].addr;
 	else
 		return NULL;
@@ -296,12 +410,12 @@
 
 char *
-ipv62str (char *buf, const T_IN6_ADDR *p_ip6addr)
-{
-	static char	addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:89ab:cdef")];
+ipv62str (char *buf, const T_IN6_ADDR *p_addr)
+{
+	static char	addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:255.255.255.255")];
 	static int_t	bix = NUM_IPV6ADDR_STR_BUFF;
 
 	bool_t	omit = false, zero = false;
 	char	*start;
-	int_t	ix;
+	int_t	ix, len6;
 
 	if (buf == NULL) {
@@ -314,16 +428,22 @@
 
 	start = buf;
-	if (p_ip6addr == NULL) {
+	if (p_addr == NULL || IN6_IS_ADDR_UNSPECIFIED(p_addr)) {
+		*buf ++ = '0';
 		*buf ++ = ':';
 		*buf ++ = ':';
+		*buf ++ = '0';
 		}
 	else {
-		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+		if (IN6_IS_ADDR_V4MAPPED(p_addr))
+			len6 = sizeof(T_IN6_ADDR) / 2 - 2;
+		else
+			len6 = sizeof(T_IN6_ADDR) / 2;
+		for (ix = 0; ix < len6; ix ++) {
 			if (omit) {
-				buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' '); 
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
 				if (ix < 7)
 					*buf ++ = ':';
 				}
-			else if (ix > 0 && ix < 7 && p_ip6addr->s6_addr16[ix] == 0)
+			else if (ix > 0 && ix < 7 && p_addr->s6_addr16[ix] == 0)
 				zero = true;
 			else {
@@ -332,9 +452,22 @@
 					*buf ++ = ':';
 					}
-				buf += convert_hexdigit(buf, ntohs(p_ip6addr->s6_addr16[ix]), 16, 0, ' '); 
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
 				if (ix < 7)
 					*buf ++ = ':';
 				}
 			}
+
+		if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
+			T_IN4_ADDR ipv4addr;
+
+			ipv4addr = ntohl(p_addr->s6_addr32[3]);
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 24) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 16) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >>  8) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr      ) & 0xff), 10, 0, ' ');
+			}
 		}
 	*buf = '\0';
@@ -370,26 +503,14 @@
 
 /*
- *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
- */
-
-bool_t
-in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr)
-{
-	if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
-		return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
-	else
-		return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
-	}
-
-/*
  *  get_ip6_hdr_size -- 拡張ヘッダも含めた IPv6 ヘッダ長を返す。
  */
 
 uint_t
-get_ip6_hdr_size (T_IP6_HDR *iph)
-{
-	uint_t	size = IP6_HDR_SIZE, hsize;
-	uint8_t	curr = iph->next, next;
-	uint8_t	*hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
+get_ip6_hdr_size (T_NET_BUF *nbuf)
+{
+	T_IP6_HDR	*iph = GET_IP6_HDR(nbuf);
+	uint_t		size = IP6_HDR_SIZE, hsize;
+	uint8_t		curr = iph->next, next;
+	uint8_t		*hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
 
 	while (1) {
@@ -436,6 +557,6 @@
  */
 
-T_IN6_ADDR *
-in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst)
+const T_IN6_ADDR *
+in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst)
 {
 	if (IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MULTICAST(dst))
@@ -456,5 +577,5 @@
 		/* 推奨有効時間内のアドレスを探索する。*/
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if (IFA6_IS_READY(ia) &&
 			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
@@ -467,5 +588,5 @@
 		/* 有効時間内のアドレスを探索する。*/
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if (IFA6_IS_READY(ia) &&
 			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
@@ -485,11 +606,11 @@
 		 */
 
-#if NUM_ROUTE_ENTRY > 0
-
-		syscall(wai_sem(SEM_IN_ROUTING_TBL));
-		for (ix = NUM_ROUTE_ENTRY; ix --; ) {
-			if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-			    in6_are_prefix_equal(dst, &routing_tbl[ix].target,
-			                               routing_tbl[ix].prefix_len)) {
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_ROUTE_ENTRY; ix --; ) {
+			if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+			    in6_are_prefix_equal(dst, &routing6_tbl[ix].target,
+			                               routing6_tbl[ix].prefix_len)) {
 
 				/*
@@ -498,18 +619,18 @@
 				 *  TMO_IN_REDIRECT の単位は [ms]。
 				 */
-				if (ix > NUM_STATIC_ROUTE_ENTRY) {
+				if (ix > NUM_IN6_STATIC_ROUTE_ENTRY) {
 					SYSTIM	now;
 
 					syscall(get_tim(&now));
-					routing_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
+					routing6_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
 					}
 
-				syscall(sig_sem(SEM_IN_ROUTING_TBL));
-				return &routing_tbl[ix].gateway;
+				syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+				return &routing6_tbl[ix].gateway;
 				}
 			}
-		syscall(sig_sem(SEM_IN_ROUTING_TBL));
-
-#endif	/* of #if NUM_ROUTE_ENTRY > 0 */
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
 
 		/*
@@ -520,5 +641,5 @@
 	}
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
 
 /*
@@ -526,13 +647,13 @@
  */
 
-T_IN_RTENTRY *
-in6_gateway_lookup (T_IN6_ADDR *gw)
+T_IN6_RTENTRY *
+in6_gateway_lookup (const T_IN6_ADDR *gw)
 {
 	int_t	ix;
 
-	for (ix = NUM_ROUTE_ENTRY; ix --; )
-		if ((routing_tbl[ix].flags & IN_RTF_DEFINED) &&
-		    IN6_ARE_ADDR_EQUAL(&routing_tbl[ix].gateway, gw))
-			return &routing_tbl[ix];
+	for (ix = NUM_IN6_ROUTE_ENTRY; ix --; )
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(&routing6_tbl[ix].gateway, gw))
+			return &routing6_tbl[ix];
 	return NULL;
 	}
@@ -545,15 +666,15 @@
 
 void
-in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
-{
-	T_IN_RTENTRY	*frt;
-
-	frt = in_rtnewentry(flags, tmo);
-	frt->gateway    = *gateway;
-	frt->target     = *target;
+in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
+{
+	T_IN6_RTENTRY	*frt;
+
+	frt = in6_rtnewentry(flags, tmo);
+	memcpy(&frt->gateway, gateway, sizeof(T_IN6_ADDR));
+	memcpy(&frt->target, target, sizeof(T_IN6_ADDR));
 	frt->prefix_len = prefix_len;
 	}
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #if NUM_IN6_HOSTCACHE_ENTRY > 0
@@ -564,5 +685,5 @@
 
 static T_IN6_HOSTCACHE_ENTRY*
-in6_hostcache_lookup (T_IN6_ADDR *dst)
+in6_hostcache_lookup (const T_IN6_ADDR *dst)
 {
 	int_t ix;
@@ -625,5 +746,5 @@
 		return;
 		}
-	hc->dst    = *dst;
+	memcpy(&hc->dst, dst, sizeof(T_IN6_ADDR));
 	hc->expire = now + IN6_HOSTCACHE_EXPIRE;
 	hc->mtu    = mtu;
@@ -637,5 +758,5 @@
 
 uint32_t
-in6_hostcache_getmtu (T_IN6_ADDR *dst)
+in6_hostcache_getmtu (const T_IN6_ADDR *dst)
 {
 	T_IN6_HOSTCACHE_ENTRY	*hc;
@@ -679,9 +800,9 @@
 in6_timer (void)
 {
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rttimer();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rttimer();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 #ifdef IP6_CFG_FRAGMENT
@@ -707,9 +828,9 @@
 in6_init (void)
 {
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
-
-	in_rtinit();
-
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rtinit();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
 
 	timeout((callout_func)nd6_timer, NULL, ND6_TIMER_TMO);
@@ -717,3 +838,106 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+/*
+ *  in6_is_dstaddr_accept -- 宛先アドレスとして正しいかチェックする。
+ */
+
+bool_t
+in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr)
+{
+	if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
+		return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
+	else
+		return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
+	}
+
+#if defined(DHCP6_CLI_CFG)
+
+/*
+ *  in6_add_ifaddr -- インタフェースに IPv6 アドレスを設定する。
+ *
+ *    vltime と pltime の単位は[s]
+ */
+
+static ER
+in6_add_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia = NULL;
+	int_t		ix;
+
+	/* 空きのエントリーを探す。*/
+	ix = 0;
+	while (true) {
+		ia = in6ifa_ifpwithix(ifp, ix ++);
+
+		/* 空きが無ければエラー */
+		if (ia == NULL)
+			return E_OBJ;
+
+		if ((ia->flags & IN6_IFF_DEFINED) == 0)
+			break;
+		}
+
+	/* 登録する。*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_upd_ifaddr -- インタフェースに設定されている IPv6 アドレスを更新する。
+ *
+ *    登録されていなければ、追加する。
+ *    vltime と pltime の単位は[s]
+ */
+
+ER
+in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	int_t		ix;
+
+	/*
+	 *  アドレスが一致するエントリーを探す。
+	 *  無ければ登録する。
+	 */
+	if ((ix = in6_addr2ifaix(addr)) == IPV6_IFADDR_IX_INVALID)
+		return in6_add_ifaddr(addr, prefix_len, vltime, pltime);
+
+	/*
+	 *  インデックス番号から、エントリーに変換する。
+	 *  エラーにならないはずであるが、確認する。
+	 */
+	if ((ia = in6ifa_ifpwithix (ifp, ix)) == NULL)
+		return E_OBJ;
+
+	/* 更新する。*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_del_ifaddr -- インタフェースに設定されている IPv6 アドレスを削除する。
+ */
+
+ER
+in6_del_ifaddr (T_IN6_ADDR *addr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	int_t		ix;
+
+	/* アドレスが一致するエントリーを探す。*/
+	if ((ix = in6_addr2ifaix(addr)) != IPV6_IFADDR_IX_INVALID) {
+
+		/* エントリーを無効にする。*/
+		ifp->in6_ifaddrs[ix].flags &= ~IN6_IFF_DEFINED;
+		return E_OK;
+		}
+	return E_PAR;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -102,5 +102,70 @@
 #define _IN6_VAR_H_
 
-#ifdef SUPPORT_INET6
+/*
+ *  アドレスの定義
+ */
+
+#ifdef _NET_CFG_BYTE_ORDER
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x00000001)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x00000002)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0x0000ffff)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0xff010000)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0xff020000)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0xfe800000)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0xfe80)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xfec0)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0xff02)
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x01000000)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x02000000)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0xffff0000)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0x000001ff)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0x000002ff)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0x000080fe)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0x80fe)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xc0fe)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0x02ff)
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
+
+/*
+ *  特別なアドレスのチェック
+ */
+
+/* IPv4 互換 */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4COMPAT(a)		\
+	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
+	 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
+#endif
+
+/* IPv4 射影 */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4MAPPED(a)		\
+	(((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
+#endif
+
+/* 要請マルチキャスト */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_NS_MULTICAST(a)	\
+	(((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
+	 ((a)->s6_addr8[12] == UINT_C(0xff)))
+#endif
+
+#ifndef _MACRO_ONLY
 
 /*
@@ -197,8 +262,4 @@
 						/* IPv6 マルチキャストアドレス配列の最大サイズ	*/
 
-/*
- *  ルーティングの制御
- */
-
 /* ルーティング表エントリ構造体 */
 
@@ -231,17 +292,8 @@
 
 /*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#define IN_SET_HEADER(nbuf,len,dst,src,next,hlim)	\
-					in6_set_header(nbuf,len,dst,src,next,hlim)
-#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
-					in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
-#define IN_CKSUM(nbuf,proto,off,len)	in6_cksum(nbuf,proto,off,len)
-#define IN_IS_DSTADDR_ACCEPT(myaddr,dstaddr)			\
-					in6_is_dstaddr_accept(myaddr,dstaddr)
-#define IN_IFAWITHIFP(ifp,dst)		in6_ifawithifp(ifp,dst)
-#define T_IN_IFADDR			T_IN6_IFADDR
-#define T_IN_RTENTRY			T_IN6_RTENTRY
+ *  ルーティング表
+ */
+
+extern T_IN6_RTENTRY routing6_tbl[];
 
 /*
@@ -264,44 +316,54 @@
 
 /*
+ *  関数シミュレーションマクロ
+ */
+
+#define IN6_COPY_TO_HOST(dst,nbuf)	memcpy(dst,&GET_IP6_HDR(nbuf)->src,sizeof(T_IN6_ADDR))
+#define INN6_IS_DSTADDR_ACCEPT(addr,nbuf)	\
+					in6_is_dstaddr_accept(addr,&GET_IP6_HDR(nbuf)->dst)
+
+/*
  *  関数
  */
 
 extern void in6_ifainit (void);
-extern int_t in6_addr2maix (T_IN6_ADDR *addr);
-extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, T_IN6_ADDR *addr,
+extern int_t in6_addr2maix (const T_IN6_ADDR *addr);
+extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
                           uint_t prefix_len, uint32_t vltime, uint32_t pltime,
                           int_t router_index, int_t prefix_index, uint_t flags);
 extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
-                          T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                          const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                           uint8_t next, uint8_t hlim);
 extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
-                            T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                            const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
                             uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
 extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
 extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
 extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
-extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, T_IN6_ADDR *dst);
+extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst);
+extern const T_IN6_ADDR *in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst);
 extern void ip6_input (T_NET_BUF *input);
-extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, T_IN6_ADDR *addr);
-extern bool_t in6_lookup_multi (T_IFNET *ifp, T_IN6_ADDR *maddr);
-extern bool_t in6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_IN6_ADDR *dstaddr);
-extern T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, T_IN6_ADDR *dst);
+extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr);
+extern bool_t in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr);
+extern bool_t in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr);
+extern bool_t inn6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, T_NET_BUF *input);
+extern const T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst);
 extern int_t in6_if2idlen (T_IFNET *ifp);
-extern int_t in6_addr2ifaix (T_IN6_ADDR *addr);
+extern int_t in6_addr2ifaix (const T_IN6_ADDR *addr);
 extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
-extern bool_t in6_are_prefix_equal (T_IN6_ADDR *addr, T_IN6_ADDR *prefix,
+extern bool_t in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix,
                                   uint_t prefix_len);
 extern void in6_ifaddr_timer (T_IFNET *ifp);
-extern T_IN6_RTENTRY *in6_gateway_lookup (T_IN6_ADDR *src);
-extern void in6_rtredirect (T_IN6_ADDR *gateway, T_IN6_ADDR *target,
+extern T_IN6_RTENTRY *in6_gateway_lookup (const T_IN6_ADDR *src);
+extern void in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target,
                             uint_t prefix_len, uint8_t flags, uint32_t tmo);
 extern void in6_init (void);
 extern void in6_if_up (T_IFNET *ifp);
 extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
-extern uint32_t in6_hostcache_getmtu (T_IN6_ADDR *dst);
-extern uint_t in6_addrscope (T_IN6_ADDR *addr);
+extern uint32_t in6_hostcache_getmtu (const T_IN6_ADDR *dst);
+extern uint_t in6_addrscope (const T_IN6_ADDR *addr);
 extern const T_NET_BUF**ip6_get_frag_queue (void);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifndef _MACRO_ONLY */
 
 #endif	/* of #ifndef _IN6_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6.cfg	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -36,5 +36,5 @@
  */
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /* 近隣キャッシュ */
@@ -58,11 +58,11 @@
 #endif	/* of #ifdef IP6_CFG_FRAGMENT */
 
-#if NUM_REDIRECT_ROUTE_ENTRY > 0
+#if NUM_IN6_ROUTE_ENTRY > 0
 
-/* ルーティング表（向け直し）*/
+/* ルーティング表 */
 
-CRE_SEM(SEM_IN_ROUTING_TBL, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_IN6_ROUTING_TBL, { TA_TPRI, 1, 1 });
 
-#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
 
-#endif	/* of #ifdef SUPPORT_INET6 */
+#endif	/* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_input.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -105,4 +105,6 @@
 #include <kernel.h>
 #include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_ASP */
@@ -112,4 +114,5 @@
 #include <s_services.h>
 #include <t_services.h>
+#include "tinet_id.h"
 
 #endif	/* of #ifdef TARGET_KERNEL_JSP */
@@ -124,24 +127,24 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
 #include <netinet6/ah6.h>
 #include <netinet6/esp6.h>
-#include <netinet/tcp.h>
-#include <netinet/tcp_timer.h>
-#include <netinet/tcp_var.h>
-#include <netinet/udp_var.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -170,15 +173,15 @@
 	{ icmp6_input,	IPPROTO_ICMPV6		},
 
-#ifdef SUPPORT_UDP
-
-	{ udp_input,	IPPROTO_UDP		},
-
-#endif	/* of #ifdef SUPPORT_UDP */
-
-#ifdef SUPPORT_TCP
+#if defined(SUPPORT_TCP)
 
 	{ tcp_input,	IPPROTO_TCP		},
 
-#endif	/* of #ifdef SUPPORT_TCP */
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+	{ udp6_input,	IPPROTO_UDP		},
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
 
 	};
@@ -640,5 +643,5 @@
 
 	/* 開始オフセットを IP ヘッダに設定する。*/
-	off = ((uint8_t *)GET_IP_HDR(nbuf)) - nbuf->buf;
+	off = ((uint8_t *)GET_IP6_HDR(nbuf)) - nbuf->buf;
 
 	/* 最終ヘッダを探索する。*/
@@ -650,8 +653,8 @@
 		uint_t sdu;
 
-		sdu = GET_IP_SDU(nbuf) - nbuf->buf;
+		sdu = GET_IP6_SDU(nbuf) - nbuf->buf;
 		if (off > sdu) {
 			memmove(nbuf->buf + sdu, nbuf->buf + off, off - sdu);
-			GET_IP_HDR(nbuf)->plen -= off - sdu;
+			GET_IP6_HDR(nbuf)->plen -= off - sdu;
 			nbuf->len              -= off - sdu;
 			}
@@ -660,3 +663,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_output.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -125,18 +125,19 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <net/net_count.h>
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -165,8 +166,8 @@
 ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout)
 {
-	T_IP6_HDR	*ip6h;
-	T_IN6_ADDR	*gw;
-	T_IFNET		*ifp = IF_GET_IFNET();
-	ER		error = E_OK;
+	T_IP6_HDR		*ip6h;
+	const T_IN6_ADDR	*gw;
+	T_IFNET			*ifp = IF_GET_IFNET();
+	ER			error = E_OK;
 
 #ifdef IP6_CFG_FRAGMENT
@@ -185,5 +186,5 @@
 
 	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_OCTETS],
-	              GET_IP_HDR_SIZE(ip6h) + GET_IP_SDU_SIZE(ip6h));
+	              GET_IP6_HDR_SIZE(output) + GET_IP6_SDU_SIZE(output));
 	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_PACKETS], 1);
 	NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutRequests, 1);
@@ -371,3 +372,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -102,6 +102,4 @@
 #define _IP6_VAR_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  IPv6 ヘッダ・ペイロードアクセスマクロ
@@ -114,9 +112,10 @@
 #define GET_IP6_NEXT_HDR(nbuf)		((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
 
-#define GET_IP6_HDR_SIZE(iph)		(get_ip6_hdr_size(iph))
-#define GET_IP6_SDU_SIZE(iph)		(ntohs((iph)->plen))
-#define GET_IF_IP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP6_HDR_SIZE(GET_IP6_HDR(nbuf))))
-
-#define SET_IP6_SDU_SIZE(iph,slen)	((iph)->plen=htons(slen))
+#define GET_IP6_HDR_SIZE(nbuf)		(get_ip6_hdr_size(nbuf))
+#define GET_IP6_SDU_SIZE(nbuf)		(ntohs(GET_IP6_HDR(nbuf)->plen))
+#define GET_IF_IP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP6_HDR_SIZE(nbuf)))
+
+#define SET_IP6_CF(nbuf,cf)		(GET_IP6_HDR(nbuf)->vcf=htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(GET_IP6_HDR(nbuf)->vcf)),cf)))
+#define SET_IP6_SDU_SIZE(nbuf,slen)	(GET_IP6_HDR(nbuf)->plen=htons(slen))
 
 /* ip6_output のフラグ */
@@ -144,27 +143,8 @@
 
 /*
- *  IPv4 と IPv6 をコンパイル時に選択するためのマクロ
- */
-
-#define T_TCP_IP_Q_HDR			T_TCP_IP6_Q_HDR
-
-#define IF_IP_HDR_SIZE			IF_IP6_HDR_SIZE
-
-#define GET_IP_HDR(nbuf)		GET_IP6_HDR(nbuf)
-#define GET_IP_SDU(nbuf)		GET_IP6_SDU(nbuf)
-
-#define GET_IP_HDR_SIZE(iph)		GET_IP6_HDR_SIZE(iph)
-#define GET_IP_SDU_SIZE(iph)		GET_IP6_SDU_SIZE(iph)
-#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP6_HDR_SIZE(nbuf)
-
-#define SET_IP_SDU_SIZE(iph,len)	SET_IP6_SDU_SIZE(iph,len)
-
-#define IP_OUTPUT(nbuf,tmout)		ip6_output(nbuf,0,tmout)
-#define IP_INIT()			ip6_init()
-#define IP_REMOVE_OPTIONS(nbuf)		ip6_remove_exthdrs(nbuf)
-
-/*
  *  IPv6 の MMTU サイズのネットワークバッファ
  */
+
+#if defined(IF_HDR_SIZE)
 
 typedef struct t_net_buf_ipv6_mmtu {
@@ -181,4 +161,6 @@
 				/* バッファ本体		*/
 	} T_NET_BUF_IPV6_MMTU;
+
+#endif	/* of #if defined(IF_HDR_SIZE) */
 
 /*
@@ -258,5 +240,5 @@
  */
 
-typedef struct t_tcp_ip6_q_hdr {
+typedef struct t_ip6_tcp_q_hdr {
 	uint8_t vc;		/* Version:        4 bit		*/
 	uint8_t cf;		/* Traffic Class:  8 bit		*/
@@ -268,5 +250,5 @@
 	T_IN6_ADDR src;	/* Source Address			*/
 	T_IN6_ADDR dst;	/* Destination Address			*/
-	} __attribute__((packed, aligned(2)))T_TCP_IP6_Q_HDR;
+	} __attribute__((packed, aligned(2))) T_IP6_TCP_Q_HDR;
 
 #ifdef SUPPORT_MIB
@@ -304,4 +286,10 @@
 
 /*
+ *  変数
+ */
+
+extern uint8_t	ip6_defhlim;
+
+/*
  *  関数
  */
@@ -310,5 +298,5 @@
 extern void ip6_init (void);
 extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
-extern uint_t get_ip6_hdr_size (T_IP6_HDR *iph);
+extern uint_t get_ip6_hdr_size (T_NET_BUF *nbuf);
 extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
 extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
@@ -320,5 +308,3 @@
 extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
 
-#endif	/* of #ifdef SUPPORT_INET6 */
-
 #endif	/* of #ifndef _IP6_VAR_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ipsec.cfg	(revision 331)
@@ -3,5 +3,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -98,6 +98,8 @@
 #include <net/ethernet.h>
 #include <net/if_arp.h>
+#include <net/ppp.h>
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -107,15 +109,13 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
-#include <net/if6_var.h>
-
-#ifdef SUPPORT_INET6
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
 
 /*
@@ -328,5 +328,5 @@
 
 T_LLINFO_ND6 *
-nd6_lookup (T_IN6_ADDR *addr, bool_t create)
+nd6_lookup (const T_IN6_ADDR *addr, bool_t create)
 {
 	SYSTIM	min = 0xffffffff;
@@ -370,5 +370,5 @@
 
 T_LLINFO_ND6 *
-nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from,
+nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from,
                   T_IF_ADDR *lladdr, uint8_t type, uint8_t code)
 {
@@ -487,5 +487,5 @@
 
 bool_t
-nd6_is_addr_neighbor (T_IFNET *ifp, T_IN6_ADDR *addr)
+nd6_is_addr_neighbor (T_IFNET *ifp, const T_IN6_ADDR *addr)
 {
 	if (IN6_IS_ADDR_LINKLOCAL(addr))
@@ -508,5 +508,5 @@
 
 ER
-nd6_output (T_IFNET *ifp, T_NET_BUF *output, T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
+nd6_output (T_IFNET *ifp, T_NET_BUF *output, const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
 {
 	ER	error = E_OK;
@@ -622,5 +622,5 @@
 
 ER
-nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa)
+nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa)
 {
 	if (IN6_IS_ADDR_MULTICAST(dst)) {
@@ -696,3 +696,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -67,6 +67,4 @@
 #define _ND6_H_
 
-#ifdef SUPPORT_INET6
-
 /*
  *  ネットワークインタフェース構造体（T_IFNET）のフラグ
@@ -118,6 +116,4 @@
 #define ND6_MAX_UCAST_QUERY		3		/* ユニキャストアドレス要請の再送回数	*/
 
-#define ND6_INFINITE_LIFETIME		0xffffffff
-
 #define ND6_GCOLLECTION_TIME		(60*60*24*SYSTIM_HZ)
 							/* ゴミ拾い周期、1 日			*/
@@ -234,5 +230,4 @@
 extern SYSTIM	nd6_recalc_reachtm_interval;
 extern SYSTIM	nd6_retrans_time;
-extern uint8_t	ip6_defhlim;
 
 /*
@@ -241,25 +236,25 @@
 
 extern void nd6_ifattach (T_IFNET *ifp);
-extern void nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-                           T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
-extern void nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-                           T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
+extern void nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
+extern void nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
 extern void nd6_dad_start (T_IFNET *ifp, T_IN6_IFADDR *ia, int_t *tick);
 extern ER nd6_output (T_IFNET *ifp, T_NET_BUF *output,
-                      T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
+                      const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
 extern void nd6_na_input (T_NET_BUF *input, uint_t off);
 extern void nd6_ns_input (T_NET_BUF *input, uint_t off);
 extern void nd6_ra_input (T_NET_BUF *input, uint_t off);
-extern ER nd6_storelladdr (T_IF_ADDR *out, T_IN6_ADDR *dst, T_IF_ADDR *ifa);
+extern ER nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa);
 extern ER nd6_options (uint8_t *opt, void *nh, uint_t len);
-extern T_LLINFO_ND6 *nd6_lookup (T_IN6_ADDR *addr, bool_t create);
+extern T_LLINFO_ND6 *nd6_lookup (const T_IN6_ADDR *addr, bool_t create);
 extern ER nd6_output_hold (T_IFNET *ifp, T_LLINFO_ND6 *ln);
-extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, T_IN6_ADDR *from, 
+extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from, 
                                        T_IF_ADDR *lladdr, uint8_t type, uint8_t code);
 extern void nd6_defrtrlist_timer (void);
 extern void nd6_prelist_timer (void);
 extern void nd6_rtrsol_ctl (void);
-extern T_IN6_ADDR *nd6_router_lookup (void);
-extern T_DEF_ROUTER *nd6_defrtrlist_lookup (T_IN6_ADDR *src);
+extern const T_IN6_ADDR *nd6_router_lookup (void);
+extern T_DEF_ROUTER *nd6_defrtrlist_lookup (const T_IN6_ADDR *src);
 extern void nd6_defrtrlist_del (T_DEF_ROUTER *dr);
 extern void nd6_timer (void);
@@ -269,7 +264,5 @@
 extern ER nd6_prefix_onlink (T_ND6_PREFIX *pr);
 extern ER nd6_prefix_offlink (T_ND6_PREFIX *pr);
-extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (T_IN6_ADDR *dst);
-
-#endif	/* of #ifdef SUPPORT_INET6 */
+extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst);
 
 #endif	/* of #ifndef _ND6_H_ */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_nbr.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -93,4 +93,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -100,16 +101,13 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
 #include <net/if6_var.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -363,6 +361,6 @@
 
 void
-nd6_ns_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-               T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
+nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
 {
 	T_NEIGHBOR_SOLICIT_HDR	*nsh;
@@ -429,5 +427,5 @@
 
 		if (saddr && in6_lookup_ifaddr(ifp, saddr))
-			ip6h->src = *saddr;
+			memcpy(&ip6h->src, saddr, sizeof(T_IN6_ADDR));
 		else {
 			/*
@@ -441,5 +439,5 @@
 				return;
 				}
-			ip6h->src = ifa->addr;
+			memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
 			}
 		}
@@ -455,5 +453,5 @@
  	nsh->hdr.code        = 0;
  	nsh->hdr.data.data32 = 0;
- 	nsh->target          = *taddr;
+	memcpy(&nsh->target, taddr, sizeof(T_IN6_ADDR));
 
 	if (!dad && (mac = IF_SOFTC_TO_IFADDR(ifp->ic)) != NULL) {
@@ -699,6 +697,6 @@
 
 void
-nd6_na_output (T_IFNET *ifp, T_IN6_ADDR *daddr,
-               T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
+nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
 {
 	T_NEIGHBOR_ADVERT_HDR	*nah;
@@ -747,5 +745,5 @@
 		}
 	else
-		ip6h->dst = *daddr;
+		memcpy(&ip6h->dst, daddr, sizeof(T_IN6_ADDR));
 
 	/*
@@ -757,11 +755,11 @@
 		return;
 		}
-	ip6h->src = ifa->addr;
-
- 	/* 近隣通知ヘッダを設定する。*/
- 	nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
- 	nah->hdr.type        = ND_NEIGHBOR_ADVERT;
- 	nah->hdr.code        = 0;
- 	nah->target          = *taddr;
+	memcpy(&ip6h->src, &ifa->addr, sizeof(T_IN6_ADDR));
+
+	/* 近隣通知ヘッダを設定する。*/
+	nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
+	nah->hdr.type        = ND_NEIGHBOR_ADVERT;
+	nah->hdr.code        = 0;
+	memcpy(&nah->target, taddr, sizeof(T_IN6_ADDR));
 
 	/* tlladdr が真ならネットワークインタフェースのアドレスを追加する。*/
@@ -851,3 +849,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -93,4 +93,5 @@
 #include <net/ppp_ipcp.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_var.h>
 #include <net/net_buf.h>
@@ -100,13 +101,12 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
 #include <netinet6/nd6.h>
 #include <netinet6/in6_ifattach.h>
-#include <netinet/ip6.h>
-#include <netinet/icmp6.h>
-#include <netinet6/ip6_var.h>
-
-#include <net/if6_var.h>
+
+#include <net/if_var.h>
 
 /*
@@ -116,5 +116,5 @@
 extern const char *itron_strerror (ER ercd);
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 #if NUM_ND6_DEF_RTR_ENTRY > 0
@@ -284,5 +284,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
 		     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
@@ -299,5 +299,5 @@
 		 */
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
 			     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
@@ -316,5 +316,5 @@
 		 */
 		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
-			ia = &ifp->in_ifaddrs[ix];
+			ia = &ifp->in6_ifaddrs[ix];
 			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0)
 				ia->flags &= ~IN6_IFF_DETACHED;
@@ -448,5 +448,5 @@
 	/* 各メンバに値を設定する。*/
 	fdr->plistmap = 0;
-	fdr->addr     = *src;
+	memcpy(&fdr->addr, src, sizeof(T_IN6_ADDR));
 	fdr->lifetime = lifetime * SYSTIM_HZ;		/* lifetime の単位は秒 */
 	fdr->flags    = flags;
@@ -478,5 +478,5 @@
 	int_t		ix;
 
-	lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 
 	/*
@@ -585,5 +585,5 @@
 
 	/* リンクローカルアドレスが未登録であれば何もしない。*/
-	lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 	if ((lla->flags & IN6_IFF_DEFINED) == 0)
 		return E_OK;
@@ -594,5 +594,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if (ia->prefix_index == (pr - nd6_prefix))
 			break;
@@ -634,5 +634,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if (ia->prefix_index == (pr - nd6_prefix))
 			break;
@@ -692,5 +692,4 @@
 	T_ND6_PREFIX	*pr = NULL;
 	int_t		ix;
-	ER		error;
 
 	/* プレフィックスリストから空きのプレフィックスエントリを探索する。*/
@@ -723,5 +722,5 @@
 
 	if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) != 0) {
-		if ((error = nd6_prefix_onlink(pr)) != E_OK)
+		if (nd6_prefix_onlink(pr) != E_OK)
 			return NULL;
 		}
@@ -812,4 +811,11 @@
 			}
 
+#if 1		/* プレフィックスが未登録の場合だけ表示する。*/
+		syslog(LOG_NOTICE, "[ND6 RTR] add prefix: flags[MOH]: %02x, addr: %s\n"
+		                   "                                      from: %s.",
+		                   nd6_def_router[router_index].flags,
+		                   ipv62str(NULL, &pi->prefix),
+		                   ipv62str(NULL, &nd6_def_router[router_index].addr));
+#endif
 		if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0) {
 			/*
@@ -836,5 +842,5 @@
 	 */
 	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-		ia = &ifp->in_ifaddrs[ix];
+		ia = &ifp->in6_ifaddrs[ix];
 		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
 		    ia->prefix_len == pr->prefix_len &&
@@ -892,5 +898,5 @@
 				}
 
-			lla = &ifp->in_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+			lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
 
 			/* プレフィックスマスクを生成する。*/
@@ -922,5 +928,5 @@
 
 			for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
-				ia = &ifp->in_ifaddrs[ix];
+				ia = &ifp->in6_ifaddrs[ix];
 				if ((ia->flags & IN6_IFF_DEFINED) == 0) {
 					in6_ifadd(pr, ia, router_index);
@@ -971,5 +977,5 @@
 	T_NET_BUF		*output;
 	T_IN6_IFADDR		*ifa;
-	T_IN6_ADDR		*saddr;
+	const T_IN6_ADDR	*saddr;
 	uint16_t		len;
 
@@ -1017,5 +1023,5 @@
 
 T_DEF_ROUTER *
-nd6_defrtrlist_lookup (T_IN6_ADDR *src)
+nd6_defrtrlist_lookup (const T_IN6_ADDR *src)
 {
 	T_DEF_ROUTER	*dr = NULL;
@@ -1036,5 +1042,5 @@
  */
 
-T_IN6_ADDR *
+const T_IN6_ADDR *
 nd6_router_lookup (void)
 {
@@ -1260,6 +1266,9 @@
 				syslog(LOG_NOTICE, "[ND6 RTR] preferred(%d) > valid time(%d).", ntohl(pi->preferred), ntohl(pi->valid));
 			else {
-				syslog(LOG_NOTICE, "[ND6 RTR] update prefix: %s from %s.",
-				                   ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#if 0	/* プレフィックスが未登録の場合だけ表示する。*/
+				syslog(LOG_NOTICE, "[ND6 RTR] update prefix: flags[MOH]: %02x, addr: %s\n"
+				                   "                                         from: %s.",
+				                   rah->nd_ra_flags, ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#endif
 				if (rix >= 0) {
 					/*
@@ -1391,5 +1400,5 @@
 
 T_ND6_PREFIX *
-nd6_onlink_prefix_lookup (T_IN6_ADDR *dst)
+nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst)
 {
 	SYSTIM		now;
@@ -1427,3 +1436,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/route6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -82,4 +82,5 @@
 
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/if.h>
 #include <net/if_loop.h>
@@ -92,18 +93,17 @@
 
 #include <netinet/in.h>
-#include <netinet6/in6.h>
-#include <netinet6/in6_var.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
 #include <netinet6/nd6.h>
-#include <netinet/ip6.h>
-#include <netinet6/ip6_var.h>
-#include <netinet/icmp6.h>
-
-#ifdef SUPPORT_INET6
+
+#ifdef _IP6_CFG
 
 #if 0
-	/*
-	 *  通信帯域を食いつぶす攻撃への対応のため、
-	 *  タイプ 0 経路制御ヘッダの処理を行わない。
-	 */
+/*
+ *  通信帯域を食いつぶす攻撃への対応のため、
+ *  タイプ 0 経路制御ヘッダの処理を行わない。
+ */
 
 /*
@@ -229,3 +229,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.c	(revision 321)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/scope6.c	(revision 331)
@@ -2,5 +2,5 @@
  *  TINET (TCP/IP Protocol Stack)
  * 
- *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
  *
@@ -123,10 +123,14 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
 
 #include <netinet6/in6.h>
 #include <netinet6/in6_var.h>
 
-#ifdef SUPPORT_INET6
+#ifdef _IP6_CFG
 
 /*
@@ -135,5 +139,5 @@
 
 uint_t
-in6_addrscope (T_IN6_ADDR *addr)
+in6_addrscope (const T_IN6_ADDR *addr)
 {
 	uint_t scope;
@@ -168,3 +172,3 @@
 	}
 
-#endif /* of #ifdef SUPPORT_INET6 */
+#endif /* of #ifdef _IP6_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_input.c	(revision 331)
@@ -0,0 +1,136 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp_reply_no_port -- éä¿¡å
+ã«ãã¼ããå®ç¾©ããã¦ããªããã¨ãéç¥ããã
+ */
+
+void
+UDP_REPLY_NO_PORT (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+
+#if defined(_IP4_CFG)
+
+	if (GET_IP_VER(input)==IPV6_VERSION) {
+
+		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+		if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+			icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+			}
+		else
+			syscall(rel_net_buf(input));
+		}
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+
+		/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+		if (ntohl(GET_IP4_HDR(input)->dst) == IF_GET_IFNET()->in4_ifaddr.addr) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			icmp_error(ICMP4_UNREACH_PORT, input);
+			/* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
+			}
+		syscall(rel_net_buf(input));
+		}
+
+#else	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+
+	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+	if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+		/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+		icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+		}
+	else
+		syscall(rel_net_buf(input));
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+	}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/udp6_subr.c	(revision 331)
@@ -0,0 +1,172 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ *  udp6_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP6_HDR	*ip6h;
+
+	ip6h = GET_IP6_HDR(input);
+
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst))
+		return true;
+	else
+		return INN6_IS_DSTADDR_ACCEPT(myaddr, input);
+	}
+
+#if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR)
+
+#ifdef DHCP_CFG
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input)==IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+		    ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#else	/* of #ifdef DHCP_CFG */
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input) == IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input) == IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#endif	/* of #ifdef DHCP_CFG */
+
+#endif	/* of #if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR) */
