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