Index: EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/Makefile.tinet	(revision 429)
@@ -93,4 +93,5 @@
                in_subr.o route_cfg.o
 TINET_CFG_COBJS := $(TINET_CFG_COBJS) tinet_cfg.o
+TINET_CFG2_OUT_SRCS := $(TINET_CFG2_OUT_SRCS) tinet_cfg.h tinet_cfg.c
 
 #  IPv6
@@ -328,4 +329,5 @@
 
 	CFG_COBJS := $(CFG_COBJS) $(TINET_CFG_COBJS)
+	CFG2_OUT_SRCS := $(CFG2_OUT_SRCS) $(TINET_CFG2_OUT_SRCS)
 
 	CLEAN_FILES := $(CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.c	(revision 429)
@@ -195,52 +195,83 @@
 
 /**
- * Called by a driver when its link goes up
- */
-void ether_set_link_up(T_IFNET *ether)
-{
-  if (!(ether->flags & IF_FLAG_LINK_UP)) {
-    ether->flags |= IF_FLAG_LINK_UP;
-
-    if (ether->flags & IF_FLAG_UP) {
-#if LWIP_ARP
-      /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ 
-      if (ether->flags & IF_FLAG_ETHARP) {
-        etharp_gratuitous(ether);
-      }
-#endif /* LWIP_ARP */
-
-#if LWIP_IGMP
-      /* resend IGMP memberships */
-      if (ether->_flags & IF_FLAG_IGMP) {
-        igmp_report_groups(ether);
-      }
-#endif /* LWIP_IGMP */
-    }
-    if (ether->link_callback) {
-      (ether->link_callback)(ether);
-    }
-  }
-}
+ * ether_set_link_up -- リンクしたときにNICから呼び出される
+ */
+void
+ether_set_link_up()
+{
+	if (!(ether_ifnet.flags & IF_FLAG_LINK_UP)) {
+		ether_ifnet.flags |= IF_FLAG_LINK_UP;
+
+		if (ether_ifnet.flags & IF_FLAG_UP) {
+#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
+			/* ARP再構築？ */
+#endif /* #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
+
+#ifdef SUPPORT_IGMP
+			/* IGMP参加 */
+#endif /* #ifdef SUPPORT_IGMP */
+			}
+		if (ether_ifnet.link_callback) {
+			(ether_ifnet.link_callback)(&ether_ifnet);
+			}
+		}
+	}
 
 /**
- * Called by a driver when its link goes down
- */
-void ether_set_link_down(T_IFNET *ether)
-{
-  if (ether->flags & IF_FLAG_LINK_UP) {
-    ether->flags &= ~IF_FLAG_LINK_UP;
-    if (ether->link_callback) {
-      (ether->link_callback)(ether);
-    }
-  }
-}
-
-/**
- * Set callback to be called when link is brought up/down
- */
-void ether_set_link_callback(ether_status_callback_fn link_callback)
+ * ether_set_link_up -- リンクが切断したときにNICから呼び出される
+ */
+void
+ether_set_link_down()
+{
+	if (ether_ifnet.flags & IF_FLAG_LINK_UP) {
+		ether_ifnet.flags &= ~IF_FLAG_LINK_UP;
+		if (ether_ifnet.link_callback) {
+			(ether_ifnet.link_callback)(&ether_ifnet);
+			}
+		}
+	}
+
+/*
+ * ether_set_up -- DHCPでアドレスが設定されたとき呼び出される
+ */
+
+void
+ether_set_up()
+{
+	if (!(ether_ifnet.flags & IF_FLAG_UP)) {
+		ether_ifnet.flags |= IF_FLAG_UP;
+		if (ether_ifnet.link_callback) {
+			(ether_ifnet.link_callback)(&ether_ifnet);
+			}
+		}
+	}
+
+/*
+ * ether_set_down -- DHCPでアドレスが解放されたとき呼び出される
+ */
+
+void
+ether_set_down()
+{
+	if (ether_ifnet.flags & IF_FLAG_UP) {
+		ether_ifnet.flags &= ~IF_FLAG_UP;
+		if (ether_ifnet.link_callback) {
+			(ether_ifnet.link_callback)(&ether_ifnet);
+			}
+		}
+	}
+
+/*
+ * ether_set_link_callback -- リンク状態変化時のコールバック登録
+ */
+
+void
+ether_set_link_callback(ether_status_callback_fn link_callback)
 {
 	ether_ifnet.link_callback = link_callback;
-}
+	if (ether_ifnet.link_callback) {
+		(ether_ifnet.link_callback)(&ether_ifnet);
+		}
+	}
 
 /*
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/ethernet.h	(revision 429)
@@ -99,6 +99,11 @@
 
 #if defined(__RX)
-
 #pragma pack
+#elif defined(_MSC_VER)
+#pragma pack(push, 1)
+#endif
+
+#if defined(__RX) || defined(_MSC_VER)
+
 typedef struct t_ether_header {
 
@@ -113,5 +118,4 @@
 	uint16_t	type;
 	} T_ETHER_HDR;
-#pragma packoption
 
 #elif defined(TOPPERS_S810_CLG3_85)	/* of #if defined(__RX) */
@@ -143,5 +147,5 @@
 	uint8_t		shost[ETHER_ADDR_LEN];
 	uint16_t	type;
-	} __attribute__((packed, aligned(2)))T_ETHER_HDR;
+	} __attribute__((packed, aligned(2))) T_ETHER_HDR;
 
 #endif	/* of #if defined(__RX) */
@@ -158,5 +162,11 @@
 typedef struct t_ether_addr {
 	uint8_t		lladdr[ETHER_ADDR_LEN];
-	} __attribute__((packed, aligned(2)))T_ETHER_ADDR;
+	} __attribute__((packed, aligned(2))) T_ETHER_ADDR;
+
+#if defined(__RX)
+#pragma packoption
+#elif defined(_MSC_VER)
+#pragma pack(pop)
+#endif
 
 /*
@@ -208,4 +218,7 @@
 							/* インタフェースのマルチキャストアドレスへの変換		*/
 
+#define IF_FLAG_UP				0x01U
+#define IF_FLAG_LINK_UP			0x10U
+
 /*
  *  前方参照
@@ -266,7 +279,4 @@
 #endif	/* of #ifdef T_IF_ETHER_NIC_SOFTC */
 
-#define IF_FLAG_UP				0x01U
-#define IF_FLAG_LINK_UP			0x10U
-
 /*
  *  変数
@@ -304,9 +314,10 @@
 extern uint32_t ether_srand (void);
 
-/** Function prototype for netif status- or link-callback functions. */
 typedef void (*ether_status_callback_fn)(T_IFNET *ether);
 extern void ether_set_link_callback(ether_status_callback_fn link_callback);
-extern void ether_set_link_up(T_IFNET *ether);
-extern void ether_set_link_down(T_IFNET *ether);
+extern void ether_set_link_up();
+extern void ether_set_link_down();
+extern void ether_set_up();
+extern void ether_set_down();
 
 #endif	/* of #ifdef SUPPORT_ETHER */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/if_arp.h	(revision 429)
@@ -91,5 +91,5 @@
 	uint8_t		proto_len;	/* プロトコル長			*/
 	uint16_t	opcode;		/* 命令コード			*/
-	} __attribute__((packed, aligned(2)))T_ARP_HDR;
+	} __attribute__((packed, aligned(2))) T_ARP_HDR;
 
 #define ARP_HDR_SIZE			(sizeof(T_ARP_HDR))
@@ -119,5 +119,5 @@
 typedef struct arpcom {
 	uint8_t		mac_addr[ETHER_ADDR_LEN];
-	} __attribute__((packed, aligned(2)))T_ARPCOM;
+	} __attribute__((packed, aligned(2))) T_ARPCOM;
 
 /*
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_asp.cfg	(revision 429)
@@ -41,4 +41,6 @@
 
 INCLUDE("net/net.cfg");
+
+#ifndef NOUSE_MPF_NET_BUF
 
 /*
@@ -169,2 +171,4 @@
 		});
 #endif	/* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
+
+#endif
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.c	(revision 429)
@@ -68,4 +68,6 @@
 #include <netinet/tcp_var.h>
 
+#ifndef NOUSE_MPF_NET_BUF
+
 /*
  *  関数
@@ -226,5 +228,21 @@
 #endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
 
-#if defined(_IP4_CFG)
+#if defined(_IP6_CFG)
+
+#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
+	{
+		MPF_NET_BUF_CSEG,
+		IF_HDR_SIZE + IP_HDR_SIZE + TCP_HDR_SIZE,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_CSEG,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
+
+#endif	/* of #if defined(_IP6_CFG) */
 
 #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
@@ -242,5 +260,5 @@
 #endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
 
-#endif	/* of #if defined(_IP4_CFG) */
+#if defined(_IP4_CFG) && !defined(_IP6_CFG)
 
 #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
@@ -257,4 +275,6 @@
 		},
 #endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
+
+#endif	/* of #if defined(_IP4_CFG) && !defined(_IP6_CFG) */
 
 	};
@@ -307,9 +327,11 @@
 
 	while (1) {
-		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
+		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
 			(*buf)->idix  = (uint8_t)ix;
 			(*buf)->len   = (uint16_t)minlen;
 			(*buf)->flags = 0;
-
+#ifdef IF_ETHER_MULTI_NIC
+			(*buf)->conn_pos = 0;
+#endif
 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
 			NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
@@ -318,7 +340,7 @@
 			return error;
 			}
-		else if (ix == 0 || net_buf_table[ix].size > maxlen)
+		ix --;
+		if (ix < 0 || net_buf_table[ix].size > maxlen)
 			break;
-		ix --;
 		}
 
@@ -349,9 +371,12 @@
 
 	while (1) {
-		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf,
+		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf,
 		                      ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) {
 			(*buf)->idix  = (uint8_t)ix;
 			(*buf)->len   = net_buf_table[ix].size;
 			(*buf)->flags = 0;
+#ifdef IF_ETHER_MULTI_NIC
+			(*buf)->conn_pos = 0;
+#endif
 
 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
@@ -450,9 +475,10 @@
 		/* 固定メモリプールに返す。*/
 
-#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
-		net_buf_table[buf->idix].busies --;
-#endif
-		if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
-			syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
+		int idix = buf->idix;
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+		net_buf_table[idix].busies --;
+#endif
+		if ((error = rel_mpf((ID)net_buf_table[idix].index, buf)) != E_OK) {
+			syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), idix);
 			}
 		}
@@ -505,2 +531,63 @@
 	return (uint_t)net_buf_table[0].size;
 	}
+
+#else
+#include <stdlib.h>
+
+/*
+ *  tget_net_buf_ex -- ネットワークバッファを獲得する（拡張機能）。
+ */
+
+ER
+tget_net_buf_ex (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout)
+{
+	uint_t len = (minlen > maxlen) ? minlen : maxlen;
+	*buf = (T_NET_BUF *)malloc(sizeof(T_NET_BUF) - sizeof(((T_NET_BUF *)0)->buf) + len);
+	if (*buf == NULL)
+		return E_NOMEM;
+
+	(*buf)->idix = 0;
+	(*buf)->len = (uint16_t)len;
+	(*buf)->flags = 0;
+#ifdef IF_ETHER_MULTI_NIC
+	(*buf)->conn_pos = 0;
+#endif
+
+	return E_OK;
+	}
+
+/*
+ *  tget_net_buf -- ネットワークバッファを獲得する（互換）。
+ */
+
+ER
+tget_net_buf (T_NET_BUF **buf, uint_t len, TMO tmout)
+{
+	return tget_net_buf_ex(buf, len, len, NBA_SEARCH_ASCENT, tmout);
+	}
+
+
+/*
+ * rel_net_buf -- ネットワークバッファを返却する。
+ */
+
+ER
+rel_net_buf (T_NET_BUF *buf)
+{
+	free(buf);
+
+	return E_OK;
+	}
+
+
+/*
+ * net_buf_max_siz -- ネットワークバッファの最大サイズを返す。
+ */
+
+uint_t
+net_buf_max_siz (void)
+{
+	return (uint_t)IF_PDU_SIZE;
+	}
+
+#endif
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_buf.h	(revision 429)
@@ -55,4 +55,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -80,4 +83,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -97,4 +103,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -114,4 +123,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -131,4 +143,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -148,4 +163,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -167,4 +185,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_count.c	(revision 429)
@@ -222,5 +222,5 @@
 T_NET_COUNT	net_count_igmp;
 
-#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IGMP */
 
 #endif	/* of #if defined(_IP4_CFG) */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/net/net_rename.h	(revision 429)
@@ -71,7 +71,7 @@
 #define tget_net_buf_ex		_tinet_tget_net_buf_ex
 #define tget_net_buf		_tinet_tget_net_buf
-#define rel_net_buf		_tinet_rel_net_buf
-#define rus_net_buf		_tinet_rus_net_buf
-#define net_buf_siz		_tinet_net_buf_siz
+#define rel_net_buf			_tinet_rel_net_buf
+#define rus_net_buf			_tinet_rus_net_buf
+#define net_buf_siz			_tinet_net_buf_siz
 #define net_buf_max_siz		_tinet_net_buf_max_siz
 #define nbuf_get_tbl		_tinet_nbuf_get_tbl
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/Makefile.netapp	(revision 429)
@@ -183,5 +183,5 @@
 		NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o
 		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg
-	
+
 		ifeq ($(SUPPORT_INET4),true)
 			ifeq ($(USE_UDP4_ECHO_CLI),true)
@@ -191,5 +191,5 @@
 			endif
 		endif
-        else
+		else
 		ifeq ($(SUPPORT_INET4),true)
 			SUPPORT_UDP = true
@@ -364,5 +364,5 @@
 ifeq ($(TARGET_KERNEL),ASP)
 
-	APPLDIR := $(APPLDIR) $(NETAPP_DIRS)
+	APPLDIRS := $(APPLDIRS) $(NETAPP_DIRS)
 	APPL_COBJS := $(APPL_COBJS) $(NETAPP_COBJS)
 	APPL_CFLAGS := $(APPL_CFLAGS) -fno-strict-aliasing
@@ -382,5 +382,5 @@
 ifeq ($(TARGET_KERNEL),ASP)
 
-	APPLDIR := $(APPLDIR) $(SRCDIR)/pdic/sc1602
+	APPLDIRS := $(APPLDIRS) $(SRCDIR)/pdic/sc1602
 
 endif
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dbg_cons.c	(revision 429)
@@ -666,5 +666,5 @@
 	            "IX Expire State      MAC Address       IP Address\n");
 
-	/* expire の単位は [ms]。*/
+	/* expire の単位は [us]。*/
 	get_tim(&now);
 	cache = nd6_get_cache();
@@ -705,5 +705,5 @@
 	            "IX Expire MAC Address       IP Address\n");
 
-	/* expire の単位は [ms]。*/
+	/* expire の単位は [us]。*/
 	cache = arp_get_cache();
 	for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
@@ -753,5 +753,5 @@
 	WAI_NET_CONS_PRINTF();
 	get_tim(&now);
-	cons_printf(portid, "ネットワーク統計情報\t経過時間[ms]\t%lu\t", now);
+	cons_printf(portid, "ネットワーク統計情報\t経過時間[us]\t%lu\t", now);
 	if (now > (1000 * 3600 * 24))
 		cons_printf(portid, "%3lu日 %2lu時間 %2lu分 %2lu秒\n",
@@ -938,5 +938,5 @@
 		}
 
-	cons_printf(portid, "\nネットワーク統計情報\t経過時間[ms]\t%lu\t", now);
+	cons_printf(portid, "\nネットワーク統計情報\t経過時間[us]\t%lu\t", now);
 	if (now > (1000 * 3600 * 24))
 		cons_printf(portid, "%3lu日 %2lu時間 %2lu分 %2lu秒\n",
@@ -1065,5 +1065,5 @@
 	WAI_NET_CONS_PRINTF();
 	get_tim(&now);
-	cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%u\n", now);
+	cons_printf(portid, "ネットワークバッファ情報\t経過時間[us]\t%u\n", now);
 
 #if NET_COUNT_ENABLE
@@ -1577,5 +1577,5 @@
 	cons_printf(portid, " IP Address\n");
 
-	/* expire の単位は [ms]。*/
+	/* expire の単位は [us]。*/
 	get_tim(&now);
 	dr = nd6_get_drl(&count);
@@ -2298,6 +2298,6 @@
 
 	cons_printf(portid, "ND:\n");
-	cons_printf(portid, "  TMO_ND6_RTR_SOL_DELAY:    %5d[ms]\n", TMO_ND6_RTR_SOL_DELAY);
-	cons_printf(portid, "  TMO_ND6_RTR_SOL_INTERVAL: %5d[ms]\n", TMO_ND6_RTR_SOL_INTERVAL);
+	cons_printf(portid, "  TMO_ND6_RTR_SOL_DELAY:    %5d[us]\n", TMO_ND6_RTR_SOL_DELAY);
+	cons_printf(portid, "  TMO_ND6_RTR_SOL_INTERVAL: %5d[us]\n", TMO_ND6_RTR_SOL_INTERVAL);
 	cons_printf(portid, "  NUM_IP6_DAD_COUNT:        %5d\n",     NUM_IP6_DAD_COUNT);
 	cons_printf(portid, "  NUM_ND6_CACHE_ENTRY:      %5d\n",     NUM_ND6_CACHE_ENTRY);
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4.h	(revision 429)
@@ -93,5 +93,5 @@
 	uint8_t		file   [DHCP4_FILE_LEN];		/* boot file name		*/
 	uint8_t		options[DHCP4_DFLT_OPT_LEN];	/* optional parameters field	*/
-	} T_DHCP4_MSG;
+	} __attribute__((packed)) T_DHCP4_MSG;
 
 /* packet type ã®å®ç¾© */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c	(revision 429)
@@ -206,4 +206,20 @@
 #endif
 
+#ifdef SEM_DHCP4_CLI_TIMER
+#define DHCP4_CLI_TIMER_LOCK() do { syscall(wai_sem(SEM_DHCP4_CLI_TIMER)); } while(0)
+#define DHCP4_CLI_TIMER_UNLOCK() do { syscall(sig_sem(SEM_DHCP4_CLI_TIMER)); } while(0)
+#else
+#define DHCP4_CLI_TIMER_LOCK() do { } while(0)
+#define DHCP4_CLI_TIMER_UNLOCK() do { } while(0)
+#endif
+
+#ifdef SEM_DHCP4_CLI_READY
+#define DHCP4_CLI_READY_WAIT(ct) do { syscall(wai_sem(SEM_DHCP4_CLI_READY)); } while(0)
+#define DHCP4_CLI_READY_SIGNAL(ct) do { syscall(sig_sem(SEM_DHCP4_CLI_READY)); } while(0)
+#else
+#define DHCP4_CLI_READY_WAIT(ct) do { } while(0)
+#define DHCP4_CLI_READY_SIGNAL(ct) do { ct->sig = 1; syscall(wup_tsk(ct->tskid)); } while(0)
+#endif
+
 /*
  *  dhcp4_cksum -- ãã§ãã¯ãµã ã®è¨ç®é¢æ°
@@ -381,5 +397,5 @@
 #endif	/* of #ifdef USE_LCD */
 #endif
-
+		ether_set_down();
 		}
 	}
@@ -508,7 +524,5 @@
 		lcd_putc(LCD_PORTID, '\n');
 #endif	/* of #ifdef USE_LCD */
-	if (ct->set_addr_callback != NULL)
-		ct->set_addr_callback();
-
+		ether_set_up();
 		}
 	}
@@ -951,8 +965,8 @@
 	int ix;
 
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; )
 		ct->timers[ix] = 0;
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_UNLOCK();
 	}
 
@@ -970,7 +984,7 @@
 
 	/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	ct->timers[DHCP4C_TIMER_RCV_OFFER] = SYSTIM2TIMER(TMO_DHCP4C_OFFER);
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_UNLOCK();
 
 	/* éä¿¡å
@@ -987,5 +1001,5 @@
 	/* DISCOVER ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
 	ct->flags |= DHCP4C_FLAG_TMOUT_SND_DISC;
-	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	DHCP4_CLI_READY_SIGNAL(ct);
 	}
 
@@ -1018,9 +1032,9 @@
 
 	/* EXPIREãRENEWãREBIND ã¿ã¤ãã¼ãè¨­å®ããã*/
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	ct->timers[DHCP4C_TIMER_EXPIRE] = SYSTIM2TIMER(ct->expire);		/* EXPIRE      ã¾ã§ã®æé */
 	ct->timers[DHCP4C_TIMER_REBIND] = SYSTIM2TIMER(ct->rebind);		/* REBINDï¼T2ï¼ã¾ã§ã®æé */
 	ct->timers[DHCP4C_TIMER_RENEW]  = SYSTIM2TIMER(ct->renew);		/* RENEW ï¼T1ï¼ã¾ã§ã®æé */
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_UNLOCK();
 
 	/* BOUND ç¶æ
@@ -1048,7 +1062,7 @@
 ã RENEW ä»¥å¤ã§ã¯ ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
 	if (fsm != DHCP4_FSM_RENEW) { 
-		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_LOCK();
 		ct->timers[DHCP4C_TIMER_RCV_ACK] = SYSTIM2TIMER(TMO_DHCP4C_ACK);
-		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_UNLOCK();
 		}
 
@@ -1073,5 +1087,5 @@
 	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
 	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REQ;
-	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	DHCP4_CLI_READY_SIGNAL(ct);
 	}
 
@@ -1103,5 +1117,5 @@
 	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
 	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REL;
-	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	DHCP4_CLI_READY_SIGNAL(ct);
 	}
 
@@ -1116,5 +1130,5 @@
 	uint8_t	*option;
 
-	memset((void*)&ct->snd_msg->msg, sizeof(ct->snd_msg->msg), 0);
+	memset((void*)&ct->snd_msg->msg, 0, sizeof(ct->snd_msg->msg));
 	ct->snd_msg->len = sizeof(ct->snd_msg->msg);
 
@@ -1410,7 +1424,7 @@
 
 		/* REQUEST ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
-		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_LOCK();
 		ct->timers[DHCP4C_TIMER_SND_REQ] = 0;
-		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_UNLOCK();
 
 		/*
@@ -1464,7 +1478,7 @@
 
 		/* ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
-		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_LOCK();
 		ct->timers[DHCP4C_TIMER_RCV_ACK] = 0;
-		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_UNLOCK();
 
 		/*
@@ -1544,7 +1558,7 @@
 
 	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	ct->timers[DHCP4C_TIMER_SND_REQ] = SYSTIM2TIMER(ct->interval);
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_UNLOCK();
 	}
 
@@ -1582,5 +1596,5 @@
 	/* ã¡ãã»ã¼ã¸éä¿¡å¾
 ã¡ãè¡ãã*/
-	syscall(wai_sem(SEM_DHCP4_CLI_READY));
+	DHCP4_CLI_READY_WAIT(ct);
 
 	/* SLEEP ç¶æ
@@ -1602,7 +1616,7 @@
 
 		/* DISCOVER ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
-		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_LOCK();
 		ct->timers[DHCP4C_TIMER_SND_DISC] = 0;
-		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_UNLOCK();
 
 		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
@@ -1634,7 +1648,7 @@
 
 		/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
-		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_LOCK();
 		ct->timers[DHCP4C_TIMER_RCV_OFFER] = 0;
-		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		DHCP4_CLI_TIMER_UNLOCK();
 
 		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
@@ -1692,8 +1706,10 @@
 
 	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	ct->timers[DHCP4C_TIMER_SND_DISC] = SYSTIM2TIMER(ct->interval);
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
-	}
+	DHCP4_CLI_TIMER_UNLOCK();
+	}
+
+#ifdef DHCP4_CLI_TASK
 
 /*
@@ -1706,5 +1722,5 @@
 	int ix;
 
-	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_LOCK();
 	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; ) {
 		if (ct->timers[ix] != 0) {
@@ -1712,13 +1728,15 @@
 			if (ct->timers[ix] == 0) {
 				ct->flags = (ct->flags & ~DHCP4C_FLAG_TMOUT_MASK) | DHCP4C_FLAG_TMOUT_TIMER | ix;
-				syscall(sig_sem(SEM_DHCP4_CLI_READY));
+				DHCP4_CLI_READY_SIGNAL(ct);
 				}
 			}
 		}
-	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	DHCP4_CLI_TIMER_UNLOCK();
 
 	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããã*/
 	timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ);
 	}
+
+#endif
 
 /*
@@ -1832,4 +1850,6 @@
 	}
 
+#ifdef DHCP4_CLI_TASK
+
 /*
  *  dispatch_event -- ã¤ãã³ãæ¯ã®å¦ç
@@ -1845,5 +1865,5 @@
 		/* ã¡ãã»ã¼ã¸ã®åä¿¡ã¨ã¿ã¤ã ã¢ã¦ããå¾
 ã¤ã*/
-		syscall(wai_sem(SEM_DHCP4_CLI_READY));
+		DHCP4_CLI_READY_WAIT(ct);
 
 		if (ct->flags & DHCP4C_FLAG_RCV_MSG) {
@@ -1863,4 +1883,6 @@
 	}
 
+#endif
+
 /*
  *  init_context -- DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã
@@ -1868,12 +1890,12 @@
 
 static void
-init_context (T_DHCP4_CLI_CONTEXT *ct, ID cepid)
+init_context (T_DHCP4_CLI_CONTEXT *ct, ID tskid, ID cepid)
 {
   	memset(ct, 0, sizeof(*ct));
+	ct->tskid	= tskid;
 	ct->cepid	= cepid;
 	ct->sc		= IF_ETHER_NIC_GET_SOFTC();
 	ct->dst.portno	= DHCP4_SRV_CFG_PORTNO;
 	ct->dst.ipaddr	= IPV4_ADDRANY;
-	ct->set_addr_callback = DHCP4_CLI_SET_ADDR_CALLBACK;
 	}
 
@@ -1968,5 +1990,6 @@
 
 		/* SLEEP ãè§£é¤ããã*/
-		wup_tsk(DHCP4_CLI_TASK);
+		context.req = 1;
+		wup_tsk(context.tskid);
 		return E_OK;
 		}
@@ -2061,8 +2084,10 @@
 				}
 			}
-		syscall(sig_sem(SEM_DHCP4_CLI_READY));
+		DHCP4_CLI_READY_SIGNAL((&context));
 		}
 	return E_OK;
 	}
+
+#ifdef DHCP4_CLI_TASK
 
 /*
@@ -2075,5 +2100,5 @@
 	T_DHCP4_CLI_CONTEXT	*ct;
 	ID			tskid;
-	ER			error;
+	ER			error = E_OK;
 
 	dly_tsk(1000);
@@ -2084,31 +2109,8 @@
 
 	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
-	init_context(ct, (ID)exinf);
+	init_context(ct, tskid, (ID)exinf);
+	ct->fsm = DHCP4_FSM_SLEEP;
 
 	while (true) {
-
-		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
-		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP4C_TIMER_HZ);
-
-		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
-		if ((error = init_cli_msg(ct)) == E_OK) {
-
-			/* SELECT ç¶æ
-ã«é·ç§»ããã*/
-			start_select(ct);
-
-			/* ã¡ã¤ã³ã«ã¼ã */
-			error = dispatch_event(ct);
-			}
-
-		/* å
-¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
-		cancel_all_timers(ct);
-
-		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
-		untimeout((callout_func)dhcpc_timer, ct);
-
-		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
-		rel_cli_msg (ct);
 
 		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
@@ -2116,6 +2118,8 @@
 
 			/* ä¼æ­¢ããã*/
-			if (error == E_OK)
-				syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
+			if (error == E_OK) {
+				if (ct->fsm != DHCP4_FSM_SLEEP)
+					syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
+			}
 			else {
 				syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(error));
@@ -2126,6 +2130,145 @@
 		ct->flags = 0;
 		ct->error = E_OK;
-		}
-	}
-
+
+		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP4C_TIMER_HZ);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+		if ((error = init_cli_msg(ct)) == E_OK) {
+
+			/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+			start_select(ct);
+
+			/* ã¡ã¤ã³ã«ã¼ã */
+			error = dispatch_event(ct);
+			}
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)dhcpc_timer, ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg (ct);
+		}
+	}
+
+#else
+
+T_DHCP4_CLI_CONTEXT *
+dhcp4_cli_initialize(ID tskid, ID cepid)
+{
+	T_DHCP4_CLI_CONTEXT *ct = &context;
+	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
+	init_context(ct, tskid, cepid);
+	ct->fsm = DHCP4_FSM_SLEEP;
+	ct->timer = TMO_FEVR;
+	return ct;
+	}
+
+int
+dhcp4_cli_get_timer(T_DHCP4_CLI_CONTEXT *ct)
+{
+	if (ct->fsm == DHCP4_FSM_SLEEP)
+		return TMO_FEVR;
+
+	return ct->timer;
+	}
+
+void
+dhcp4_cli_progress(T_DHCP4_CLI_CONTEXT *ct, int elapse)
+{
+	int ix;
+
+	if ((ct->fsm == DHCP4_FSM_SLEEP) || (ct->timer == TMO_FEVR))
+		return;
+
+	ct->timer -= elapse;
+	if (ct->timer > 0)
+		return;
+
+	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+	ct->timer = 1000 * 1000;
+
+	for (ix = NUM_DHCP4C_TIMERS; ix-- > 0; ) {
+		if (ct->timers[ix] != 0) {
+			ct->timers[ix] --;
+			if (ct->timers[ix] <= 0) {
+				ct->timers[ix] = 0;
+				ct->flags = (ct->flags & ~DHCP4C_FLAG_TMOUT_MASK) | DHCP4C_FLAG_TMOUT_TIMER | ix;
+				DHCP4_CLI_READY_SIGNAL(ct);
+				}
+			}
+		}
+	}
+
+void
+dhcp4_cli_wakeup(T_DHCP4_CLI_CONTEXT *ct)
+{
+	if (ct->req) {
+		ct->req = 0;
+		if (ct->snd_msg == NULL) {
+			ct->flags = 0;
+			ct->error = E_OK;
+
+			/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+			if ((ct->error = init_cli_msg(ct)) != E_OK)
+				return;
+
+			ct->timer = 1000 * 1000;
+
+			/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+			start_select(ct);
+			}
+		}
+
+	if (!ct->sig)
+		return;
+	ct->sig = 0;
+
+	if (ct->flags & DHCP4C_FLAG_RCV_MSG) {
+		while (ct->val_lst != NULL) {
+			ct->error = eval_rcv_msg(ct);
+			}
+		ct->flags &= ~DHCP4C_FLAG_RCV_MSG;
+		}
+	}
+
+void
+dhcp4_cli_timeout(T_DHCP4_CLI_CONTEXT *ct)
+{
+	if (ct->flags & DHCP4C_FLAG_TMOUT_MASK)
+		ct->error = dispatch_timeout(ct);
+
+	if (ct->error != E_OK || ct->fsm == DHCP4_FSM_SLEEP) {
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+		ct->timer = TMO_FEVR;
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg(ct);
+
+		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
+		if (!(ct->flags & DHCP4C_FLAG_RENEW)) {
+
+			/* ä¼æ­¢ããã*/
+			if (ct->error == E_OK) {
+				if (ct->fsm != DHCP4_FSM_SLEEP)
+					syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
+			}
+			else {
+				syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(ct->error));
+				ct->error = E_OK;
+				ct->fsm = DHCP4_FSM_SLEEP;
+				}
+			}
+		}
+	}
+
+#endif /* DHCP4_CLI_TASK */
 #endif	/* of #ifdef DHCP4_CLI_CFG */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.h	(revision 429)
@@ -206,14 +206,14 @@
 
 /* åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
-#define TMO_DHCP4C_OFFER	ULONG_C(120*1000)	/* OFFER ã¡ãã»ã¼ã¸	*/
-#define TMO_DHCP4C_ACK		ULONG_C(60*1000)	/* ACK/NAK ã¡ãã»ã¼ã¸	*/
+#define TMO_DHCP4C_OFFER	(ULONG_C(120)*SYSTIM_HZ)	/* OFFER ã¡ãã»ã¼ã¸	*/
+#define TMO_DHCP4C_ACK		(ULONG_C(60)*SYSTIM_HZ)	/* ACK/NAK ã¡ãã»ã¼ã¸	*/
 
 /* ãªã¼ã¹æéã®æ¢å®å¤	*/
-#define TMO_DHCP4C_DEF_LEASE	ULONG_C(12*60*60*1000)	/* æ¨æºæé	*/
-#define TMO_DHCP4C_MIN_LEASE	ULONG_C(60*1000)	/* æå°æé	*/
+#define TMO_DHCP4C_DEF_LEASE	(ULONG_C(12*60*60)*SYSTIM_HZ)	/* æ¨æºæé	*/
+#define TMO_DHCP4C_MIN_LEASE	(ULONG_C(60)*SYSTIM_HZ)	/* æå°æé	*/
 
 /* ã¡ãã»ã¼ã¸ã®éä¿¡å¨æ	*/
-#define TMO_DHCP4C_INIT_INTVL	ULONG_C(3*1000)		/* åæå¤	*/
-#define TMO_DHCP4C_MAX_BACKOFF	ULONG_C(15*1000)	/* å¶éå¤	*/
+#define TMO_DHCP4C_INIT_INTVL	(ULONG_C(3)*SYSTIM_HZ)		/* åæå¤	*/
+#define TMO_DHCP4C_MAX_BACKOFF	(ULONG_C(15)*SYSTIM_HZ)	/* å¶éå¤	*/
 
 /* DHCP ãµã¼ãã¸ã® UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
@@ -230,9 +230,4 @@
 ã¡æé	*/
 #define TMO_DHCP4C_SND_REL_WAIT	ULONG_C(1000000)	/* [us] */
-
-/* DHCP ã§ã¢ãã¬ã¹ãæ´æ°ãããæã«å¼ã³åºãã³ã¼ã«ããã¯é¢æ° */
-#ifndef DHCP4_CLI_SET_ADDR_CALLBACK
-#define DHCP4_CLI_SET_ADDR_CALLBACK NULL
-#endif
 
 #ifndef _MACRO_ONLY
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/dhcp4_cli_var.h	(revision 429)
@@ -181,5 +181,6 @@
 	RELTIM		interval;	/* éä¿¡éé			*/
 	ER_UINT		error;		/* ã¨ã©ã¼ã»ãã¼ã¿é·		*/
-	ID		cepid;		/* CEP ID			*/
+	ID			tskid;		/* ã¿ã¹ã¯ID */
+	ID			cepid;		/* CEP ID			*/
 	uint32_t	xid;		/* ãã©ã³ã¶ã¯ã·ã§ã³ ID		*/
 	uint16_t	flags;		/* åç¨®ãã©ã°			*/
@@ -188,5 +189,7 @@
 	uint8_t		fsm;		/* ç¾å¨ã®ç¶æ
 			*/
-	void (* set_addr_callback)();	/* ã¢ãã¬ã¹è¨­å®æã®ã³ã¼ã«ããã¯ */
+	uint8_t		req;
+	uint8_t		sig;
+	int timer;
 	} T_DHCP4_CLI_CONTEXT;
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/netapp_subr.c	(revision 429)
@@ -44,5 +44,6 @@
 #include <sil.h>
 #include <syssvc/serial.h>
-#include <syssvc/logtask.h>
+#include <target_syssvc.h>
+#define LOGTASK_PORTID SIO_PORTID
 #include <t_syslog.h>
 #include "kernel_cfg.h"
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.c	(revision 429)
@@ -59,5 +59,6 @@
 #include <kernel.h>
 #include <t_syslog.h>
-#include <syssvc/logtask.h>
+#include <target_syssvc.h>
+#define LOGTASK_PORTID SIO_PORTID
 #include "kernel_cfg.h"
 #include "tinet_cfg.h"
@@ -253,5 +254,5 @@
 {
 	uint_t		label_len;
-	uint8_t		*tail;
+	char		*tail;
 
 	while (*name != '\0') {
@@ -265,5 +266,5 @@
 
 		/* ã©ãã«é·ãè¨­å®ããã*/
-		label_len = tail - (uint8_t*)name;
+		label_len = tail - name;
 		if (label_len > DNS_LABEL_LENGTH) {	/* 63 ãªã¯ããããè¶
 ããã¨ã¨ã©ã¼ */
@@ -421,5 +422,5 @@
 
 			/* ãã¡ã¤ã³åãè¿½å ããã*/
-			if ((offset = add_name(msg, msg_size, offset, dns_domain_name)) < 0)
+			if ((offset = add_name(msg, msg_size, offset, (char *)dns_domain_name)) < 0)
 				return offset;
 
@@ -1075,5 +1076,5 @@
 
 	if (new == NULL)
-		strcpy(dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
+		strcpy((char *)dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
 	else {
 		dst = dns_domain_name;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/resolver.h	(revision 429)
@@ -70,6 +70,6 @@
  */
 
-#define TMO_DNS_UDP_SND		ULONG_C(1*1000)	/* [ms]ãDNS ãµã¼ãã¸ã®   UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
-#define TMO_DNS_UDP_RCV		ULONG_C(5*1000)	/* [ms]ãDNS ãµã¼ãããã® UDP åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DNS_UDP_SND		ULONG_C(1*1000*1000)	/* [us]ãDNS ãµã¼ãã¸ã®   UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DNS_UDP_RCV		ULONG_C(5*1000*1000)	/* [us]ãDNS ãµã¼ãããã® UDP åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
 #define NUM_DNS_UDP_RETRY	1		/* ãªãã©ã¤åæ°					*/
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netapp/wwws.c	(revision 429)
@@ -708,5 +708,5 @@
 	len += put_str(cepid, srbuf, response);
 	get_tim(&finish);
-	syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
+	syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [us]",
 	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
 	return E_OK;
@@ -1609,5 +1609,5 @@
 
 	get_tim(&finish);
-	syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
+	syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [us]",
 	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
 	return E_OK;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.c	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
@@ -64,5 +64,5 @@
  * SUCH DAMAGE.
  * 
- * $FreeBSD: src/sys/i386/isa/if_mbed.c,v 1.148.2.4 1999/09/25 13:08:18 nyan Exp $
+ * $FreeBSD: src/sys/i386/isa/if_ed.c,v 1.148.2.4 1999/09/25 13:08:18 nyan Exp $
  */
 
@@ -200,5 +200,4 @@
 if_mbed_setrcr(T_IF_SOFTC *ic)
 {
-	T_MBED_SOFTC	*sc = ic->sc;
 }
 
@@ -318,6 +317,4 @@
 if_mbed_init(T_IF_SOFTC *ic)
 {
-	T_MBED_SOFTC *sc = ic->sc;
-
 	/* mbed_init 本体を呼び出す。*/
 	if_mbed_init_sub(ic);
@@ -347,5 +344,5 @@
 				}
 				if (link_mode_new != NEGO_FAIL) {
-					ethernetext_set_link_mode(link_mode_new);
+					ethernetext_set_link_mode(link_mode_new | PROMISCUOUS_MODE);
 					ETHER.EESIPR0 |= EDMAC_EESIPR_INI_TRANS;
 					ether_set_link_up(ether);
@@ -373,5 +370,4 @@
 if_mbed_read(T_IF_SOFTC *ic)
 {
-	T_MBED_SOFTC *sc = ic->sc;
 	T_NET_BUF *input = NULL;
 	uint_t align;
@@ -406,5 +402,4 @@
 if_mbed_start(T_IF_SOFTC *ic, T_NET_BUF *output)
 {
-	T_MBED_SOFTC *sc = ic->sc;
 	int32_t len, res, pos;
 
@@ -429,22 +424,27 @@
 if_mbed_eth_handler(void)
 {
-    uint32_t stat_edmac;
-    uint32_t stat_etherc;
-
-    /* Clear the interrupt request flag */
-    stat_edmac = (ETHER.EESR0 & ETHER.EESIPR0);       /* Targets are restricted to allowed interrupts */
-    ETHER.EESR0 = stat_edmac;
-    /* Reception-related */
-    if (stat_edmac & EDMAC_EESIPR_INI_RECV) {
-		isig_sem(if_softc.semid_rxb_ready);
-    }
+	uint32_t stat_edmac;
+	uint32_t stat_etherc;
+	ER ret;
+	
+	/* Clear the interrupt request flag */
+	stat_edmac = (ETHER.EESR0 & ETHER.EESIPR0);       /* Targets are restricted to allowed interrupts */
+	ETHER.EESR0 = stat_edmac;
+	/* Reception-related */
+	if (stat_edmac & EDMAC_EESIPR_INI_RECV) {
+		ret = isig_sem(if_softc.semid_rxb_ready);
+		if (ret != E_OK)
+			syslog(LOG_INFO, "semid_rxb_ready %d %x", ret, stat_edmac & EDMAC_EESIPR_INI_RECV);
+	}
 	if (stat_edmac & EDMAC_EESIPR_INI_TRANS) {
-		isig_sem(if_softc.semid_txb_ready);
-	}
-    /* E-MAC-related */
-    if (stat_edmac & EDMAC_EESIPR_INI_EtherC) {
-        /* Clear the interrupt request flag */
-        stat_etherc = (ETHER.ECSR0 & ETHER.ECSIPR0);  /* Targets are restricted to allowed interrupts */
-        ETHER.ECSR0  = stat_etherc;
-    }
-}
+		ret = isig_sem(if_softc.semid_txb_ready);
+		if (ret != E_OK)
+			syslog(LOG_INFO, "semid_txb_ready %d %x", ret, stat_edmac & EDMAC_EESIPR_INI_TRANS);
+	}
+	/* E-MAC-related */
+	if (stat_edmac & EDMAC_EESIPR_INI_EtherC) {
+		/* Clear the interrupt request flag */
+		stat_etherc = (ETHER.ECSR0 & ETHER.ECSIPR0);  /* Targets are restricted to allowed interrupts */
+		ETHER.ECSR0  = stat_etherc;
+	}
+}
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.cfg	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/if_mbed.h	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic.cfg	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_asp.cfg	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_rename.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/nic_rename.h	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_config.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_config.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_config.h	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_defs.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_defs.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netdev/if_mbed/tinet_nic_defs.h	(revision 429)
@@ -4,5 +4,5 @@
  *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
  *                   Tomakomai National College of Technology, JAPAN
- *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ *  Copyright (C) 2014-2019 Cores Co., Ltd. Japan
  * 
  *  上記著作権者は，以下の(1)～(4)の条件を満たす場合に限り，本ソフトウェ
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/icmp6.h	(revision 429)
@@ -291,6 +291,6 @@
 typedef struct t_router_advert_hdr {
 	T_ICMP6_HDR	hdr;
-	uint32_t	reachable;		/* [ms] 到達可能時間	*/
-	uint32_t	retransmit;		/* [ms] 近隣要請送信間隔	*/
+	uint32_t	reachable;		/* [us] 到達可能時間	*/
+	uint32_t	retransmit;		/* [us] 近隣要請送信間隔	*/
 	/* この後にオプションが続く */
 	} __attribute__((packed, aligned(2))) T_ROUTER_ADVERT_HDR;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in4_subr.c	(revision 429)
@@ -115,4 +115,9 @@
 #include <net/if_var.h>
 
+#ifdef SUPPORT_IGMP
+#include <netinet/udp_var.h>
+#include <netinet/ip_igmp.h>
+#endif /* of #ifdef SUPPORT_IGMP */
+
 #if defined(_IP4_CFG)
 
@@ -294,6 +299,9 @@
 
 	/* IP ããããè¨­å®ããã*/
-	if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
+	if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK) {
+		syscall(rel_net_buf(*nbuf));
+		*nbuf = NULL;
 		return error;
+		}
 
 	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_itron.h	(revision 429)
@@ -62,5 +62,5 @@
 #define TFN_TCP_ALL		(0)
 
-#define TEV_TCP_RCV_OOB		(-0x201)
+#define TEV_TCP_RCV_OOB		(0x201)
 
 /* UDP 関係 */
@@ -75,5 +75,5 @@
 #define TFN_UDP_ALL		(0)
 
-#define TEV_UDP_RCV_DAT		(-0x221)
+#define TEV_UDP_RCV_DAT		(0x221)
 
 /* 一般 */
@@ -139,4 +139,7 @@
 extern ER	udp_cre_cep (ID cepid, T_UDP_CCEP *pk_ccep);
 
+extern ER	udp6_del_cep(ID cepid);
+extern ER	udp6_set_opt(ID cepid, int_t optname, void *optval, int_t optlen);
+extern ER	udp6_get_opt(ID cepid, int_t optname, void *optval, int_t optlen);
 extern ER	udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep);
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_rename.h	(revision 429)
@@ -242,5 +242,6 @@
 #define arp_get_cache		_tinet_arp_get_cache
 
-#define ether_map_ipv4_multicast	_tinet_ether_map_ipv4_multicast
+#define ether_map_ipv4_multicast	\
+								_tinet_ether_map_ipv4_multicast
 
 /* netinet6/icmp6.c */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/in_var.h	(revision 429)
@@ -141,5 +141,7 @@
 					inn_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
 #define IN_IS_ADDR_MULTICAST(addr)	inn_is_addr_multicast(addr)
-#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	(GET_IP_VER(input)==IPV6_VERSION	\
+					?IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)	\
+					:IN4_IS_ADDR_MULTICAST(ntohl(GET_IP4_HDR(input)->dst)))
 #define IN_ADDRWITHIFP(ifp,src,dst)	inn_addrwithifp(ifp,src,dst)
 #define IN_IS_ADDR_ANY(addr)		IN6_IS_ADDR_UNSPECIFIED(addr)
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip4_var.h	(revision 429)
@@ -106,4 +106,7 @@
 	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
 	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -124,4 +127,7 @@
 	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
 	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -178,4 +184,7 @@
 	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
 	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.c	(revision 429)
@@ -5,31 +5,39 @@
 *                   Tomakomai National College of Technology, JAPAN
 *
-*  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation
-*  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
-*  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
-*  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
-*  pÆÄÔj·é±Æð³Åø·éD
-*  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
-*       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
-*      XR[hÉÜÜêÄ¢é±ÆD
-*  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
-*      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
-gip
-*      Ò}j
-AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
-*      Ì³ÛØKèðfÚ·é±ÆD
-*  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
-*      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
-*    (a) ÄzzÉº¤hL
-gipÒ}j
-AÈÇjÉCãLÌ
-*        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
-*  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
-*      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+*  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
+*  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+*  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+*  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+*  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+*  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+*      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+*      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+*  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+*      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+*      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+*      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+*  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+*      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+*    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+*        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+*  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+*      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
 *
-*  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
-*  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
-*  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
-*  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+*  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+*  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+*  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+*  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
 *
 *  @(#) $Id$
@@ -88,5 +96,5 @@
 
 static bool_t igmp_send_report_v2(T_IN4_ADDR dst);
-static uint16_t igmp_get_timer(T_IGMP_ENTRY *entry);
+static int16_t igmp_get_timer(T_IGMP_ENTRY *entry);
 
 ER igmp_set_loop(T_UDP_CEP *cep, uint8_t optval)
@@ -155,5 +163,4 @@
 	T_IGMP_ENTRY *entry = NULL;
 	int		i;
-	uint16_t	min;
 	T_IFNET	*ifp = IF_GET_IFNET();
 	ER ret = E_NOMEM;
@@ -168,5 +175,5 @@
 		entry = &igmp_groups[i];
 		if (entry->timer == -1) {
-			entry->timer = igmp_get_timer(entry);
+			entry->timer = 0;
 			entry->ip_addr = optval->imr_multiaddr;
 			ret = E_OK;
@@ -184,5 +191,4 @@
 	T_IGMP_ENTRY *entry = NULL;
 	int		i;
-	uint16_t	min;
 	ER ret = E_PAR;
 	T_IFNET	*ifp = IF_GET_IFNET();
@@ -223,5 +229,4 @@
 	T_NET_BUF	*input = *inputp;
 	T_IGMPV2_HDR	*igmph;
-	T_IN4_ADDR	addr;
 	uint_t		len, align;
 	T_IP4_HDR	*ip4h;
@@ -234,5 +239,5 @@
 	NET_COUNT_IGMP(net_count_igmp.in_packets, 1);
 
-	/* ICMP wb_Ì·³ð`FbN·éB*/
+	/* ICMP ãããã®é·ãããã§ãã¯ããã*/
 	if (input->len < IF_IP4_IGMP_HDR_SIZE) {
 		NET_COUNT_IGMP(net_count_igmp.in_err_packets, 1);
@@ -243,13 +248,13 @@
 	igmph = (T_IGMPV2_HDR *)(input->buf + *offp);
 
-	/* 4 INebg«EÌf[^· */
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
 	len = input->len - *offp;
 	align = (len + 3) >> 2 << 2;
 
-	/* 4 INebg«EÜÅpfBOÅßéB*/
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
 	if (align > len)
 		memset((uint8_t*)input->buf + input->len, 0, (size_t)(align - len));
 
-	/* `FbNTðvZ·éB*/
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
 	if (in_cksum(igmph, align) != 0) {
 		NET_COUNT_IGMP(net_count_igmp.in_err_packets, 1);
@@ -257,5 +262,5 @@
 	}
 
-	/* bZ[WÌ^Éæèªò·éB*/
+	/* ã¡ãã»ã¼ã¸ã®åã«ããåå²ããã*/
 	switch (igmph->type) {
 	case IGMP_MEMBERSHIP_QUERY:
@@ -263,10 +268,10 @@
 		ret = false;
 
-		/* QÁÌO[vAhX©çÌNG[Ìê */
+		/* åå ä¸­ã®ã°ã«ã¼ãã¢ãã¬ã¹ããã®ã¯ã¨ãªã¼ã®å ´å */
 		syscall(wai_sem(SEM_IGMP_GROUP_LOCK));
 
 		for (i = 0; i < NUM_IGMP_ENTRY; i++) {
 			entry = &igmp_groups[i];
-			if ((entry->timer >= 0) && (entry->ip_addr == addr)) {
+			if ((entry->timer >= 0) && (entry->ip_addr == igmph->addr)) {
 				entry->resptime = igmph->time;
 				ret = true;
@@ -278,5 +283,5 @@
 
 		if (ret) {
-			/* o[Vbv|[gðM */
+			/* ã¡ã³ãã¼ã·ãããªãã¼ããéä¿¡ */
 			igmp_send_report_v2(ip4h->src);
 		}
@@ -293,5 +298,5 @@
 	T_IGMPV2_HDR	*igmph;
 	T_NET_BUF		*output;
-	uint_t			len, align;
+	uint_t			len = 0, align;
 
 	if (in4_get_datagram(&output, (uint_t)(IF_IP4_IGMP_HDR_SIZE + len), 0,
@@ -300,23 +305,23 @@
 		return false;
 
-	/* IGMP wb_ðÝè·éB*/
+	/* IGMP ããããè¨­å®ããã*/
 	igmph = GET_IGMPV2_HDR(output, IF_IP4_IGMP_HDR_OFFSET);
 	igmph->type = IGMP_MEMBERSHIP_REPORT_V2;
 	igmph->time = 0;
-	igmph->addr = dst;
-
-	/* 4 INebg«EÌf[^· */
+	igmph->addr = htonl(dst);
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
 	align = (len + 3) >> 2 << 2;
 
-	/* 4 INebg«EÜÅpfBOÅßéB*/
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
 	if (align > len)
-		memset((uint8_t*)GET_IGMP_SDU(output, IF_IP4_IGMP_HDR_OFFSET) + IP4_HDR_SIZE + len,
+		memset((uint8_t*)GET_IGMP_SDU(output, IF_IP4_IGMP_HDR_OFFSET) + len,
 			0, (size_t)(align - len));
 
-	/* `FbNTðvZ·éB*/
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
 	igmph->sum = 0;
-	igmph->sum = in_cksum(igmph, (uint_t)(IF_IP4_IGMP_HDR_SIZE + align));
-
-	/* M·éB*/
+	igmph->sum = in_cksum(igmph, (uint_t)(IGMP_HDR_SIZE + align));
+
+	/* éä¿¡ããã*/
 	NET_COUNT_IGMP(net_count_igmp.out_octets,
 		output->len - GET_IF_IP4_HDR_SIZE(output));
@@ -330,5 +335,6 @@
 
 /*
-*  igmp_timer -- IGMP ¤Ê^C}[
+*  igmp_timer -- IGMP å
+±éã¿ã¤ãã¼
 */
 static void igmp_timer(void *ignore)
@@ -361,10 +367,9 @@
 
 /*
-*  igmp_init -- IGMP @\ðú»·éB
+*  igmp_init -- IGMP æ©è½ãåæåããã
 */
 
 void igmp_init(void)
 {
-	T_IGMP_ENTRY *entry = NULL;
 	int i;
 
@@ -397,12 +402,12 @@
 }
 
-uint16_t igmp_get_timer(T_IGMP_ENTRY *entry)
-{
-	uint16_t time = entry->resptime;
+int16_t igmp_get_timer(T_IGMP_ENTRY *entry)
+{
+	int16_t time = entry->resptime;
 
 	if (time == 0)
-		time = 10;
-
-	return net_rand() / (0x7fffffff / time);
+		time = 590;
+
+	return (int16_t)(net_rand() % time) + 10;
 }
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.cfg	(revision 429)
@@ -5,31 +5,39 @@
  *                   Tomakomai National College of Technology, JAPAN
  *
- *  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation 
- *  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
- *  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
- *  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
- *  pÆÄÔj·é±Æð³Åø·éD
- *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
- *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
- *      XR[hÉÜÜêÄ¢é±ÆD
- *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
-gip
- *      Ò}j
-AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
- *      Ì³ÛØKèðfÚ·é±ÆD
- *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
- *    (a) ÄzzÉº¤hL
-gipÒ}j
-AÈÇjÉCãLÌ
- *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
- *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
- *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
  *
- *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
- *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
- *  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
- *  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
  * 
  *  @(#) $Id$
@@ -37,11 +45,10 @@
 
 /*
- *  IGMP RtBM
-[Vt@C
+ *  IGMP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
  */
 
 #if defined(_IP4_CFG) && defined(SUPPORT_IGMP)
 
-/* IGMP O[vXVpZ}tH */
+/* IGMP ã°ã«ã¼ãæ´æ°ç¨ã»ããã© */
 
 CRE_SEM(SEM_IGMP_GROUP_LOCK, { TA_TPRI, 1, 1 });
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/ip_igmp.h	(revision 429)
@@ -5,31 +5,39 @@
  *                   Tomakomai National College of Technology, JAPAN
  *
- *  ãLì ÒÍCÈºÌ (1)`(4) Ìð©CFree Software Foundation
- *  ÉæÁÄö\³êÄ¢é GNU General Public License Ì Version 2 ÉL
- *  q³êÄ¢éðð½·êÉÀèC{\tgEFAi{\tgEFA
- *  ðüÏµ½àÌðÜÞDÈº¯¶jðgpE¡»EüÏEÄzziÈºC
- *  pÆÄÔj·é±Æð³Åø·éD
- *  (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
- *       \¦C±Ìpð¨æÑºLÌ³ÛØKèªC»ÌÜÜÌ`Å\[
- *      XR[hÉÜÜêÄ¢é±ÆD
- *  (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«é`ÅÄzz·éêÉÍCÄzzÉº¤hL
-gip
- *      Ò}j
-AÈÇjÉCãLÌì \¦C±Ìpð¨æÑºL
- *      Ì³ÛØKèðfÚ·é±ÆD
- *  (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJ­Ég
- *      pÅ«È¢`ÅÄzz·éêÉÍCÌðð½·±ÆD
- *    (a) ÄzzÉº¤hL
-gipÒ}j
-AÈÇjÉCãLÌ
- *        ì \¦C±Ìpð¨æÑºLÌ³ÛØKèðfÚ·é±ÆD
- *  (4) {\tgEFAÌpÉæè¼ÚIÜ½ÍÔÚIÉ¶¶é¢©Èé¹
- *      Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
  *
- *  {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
- *  æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄC»ÌKpÂ\«à
- *  ÜßÄC¢©ÈéÛØàsíÈ¢DÜ½C{\tgEFAÌpÉæè¼
- *  ÚIÜ½ÍÔÚIÉ¶¶½¢©Èé¹QÉÖµÄàC»ÌÓCðíÈ¢D
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
  *
  *  @(#) $Id$
@@ -39,77 +47,65 @@
 #define _IP_IGMP_H_
 
-#define NUM_IGMP_ENTRY				5	/* }`LXgO[vÌGg */
-
-#ifdef __CA850__
-#pragma pack(1)
-#elif __RX
-#pragma pack
-#elif _MSC_VER
-#pragma pack(push, 1)
-#endif
+#define NUM_IGMP_ENTRY				5	/* ãã«ãã­ã£ã¹ãã°ã«ã¼ãã®ã¨ã³ããªæ° */
 
  /*
-  *  IGMPv1 wb_Ìè`ARFC 1112
+  *  IGMPv1 ãããã®å®ç¾©ãRFC 1112
   */
 
 typedef struct t_igmpv1_hdr
 {
-	uint8_t		type;		/* bZ[WÌ^	*/
-	uint8_t		unused;		/* ¢gp			*/
-	uint16_t	sum;		/* `FbNT		*/
-	T_IN4_ADDR	addr;		/* O[vAhX */
-} T_IGMPV1_HDR;
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		unused;		/* æªä½¿ç¨			*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	T_IN4_ADDR	addr;		/* ã°ã«ã¼ãã¢ãã¬ã¹ */
+}  __attribute__((packed)) T_IGMPV1_HDR;
 
 /*
-*  IGMPv2 wb_Ìè`ARFC 2236
+*  IGMPv2 ãããã®å®ç¾©ãRFC 2236
 */
 
 typedef struct t_igmpv2_hdr
 {
-	uint8_t		type;		/* bZ[WÌ^	*/
-	uint8_t		time;		/* ÅåÔ		*/
-	uint16_t	sum;		/* `FbNT		*/
-	T_IN4_ADDR	addr;		/* O[vAhX */
-} T_IGMPV2_HDR;
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		time;		/* æå¤§å¿ç­æé		*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	T_IN4_ADDR	addr;		/* ã°ã«ã¼ãã¢ãã¬ã¹ */
+}  __attribute__((packed)) T_IGMPV2_HDR;
 
 typedef struct t_igmpv3_query_hdr
 {
-	uint8_t		type;		/* bZ[WÌ^	*/
-	uint8_t		time;		/* ÅåÔ		*/
-	uint16_t	sum;		/* `FbNT		*/
-	T_IN4_ADDR	grpaddr;	/* O[vAhX */
-	uint8_t		sqrv;		/* StOAQuerier Robustness Value */
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		time;		/* æå¤§å¿ç­æé		*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	T_IN4_ADDR	grpaddr;	/* ã°ã«ã¼ãã¢ãã¬ã¹ */
+	uint8_t		sqrv;		/* Sãã©ã°ãQuerier Robustness Value */
 	uint8_t		qqic;		/* Qurier's Query Interval Code */
-	uint16_t	num;		/* M³Ì */
-	T_IN4_ADDR	sdraddr;	/* M³AhX */
-} T_IGMPV3Q_HDR;
+	uint16_t	num;		/* éä¿¡å
+ã®æ° */
+	T_IN4_ADDR	sdraddr;	/* éä¿¡å
+ã¢ãã¬ã¹ */
+}  __attribute__((packed)) T_IGMPV3Q_HDR;
 
 typedef struct t_igmp_group_record
 {
-	uint8_t		type;		/* bZ[WÌ^	*/
-	uint8_t		len;		/* âf[^·		*/
-	uint16_t	num;		/* M³Ì */
-	T_IN4_ADDR	grpaddr;	/* O[vAhX */
-	T_IN4_ADDR	sdraddr;	/* M³AhX	*/
-							/* âf[^		*/
-} T_IGMP_GROUP_RECORD;
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		len;		/* è£å©ãã¼ã¿é·		*/
+	uint16_t	num;		/* éä¿¡å
+ã®æ° */
+	T_IN4_ADDR	grpaddr;	/* ã°ã«ã¼ãã¢ãã¬ã¹ */
+	T_IN4_ADDR	sdraddr;	/* éä¿¡å
+ã¢ãã¬ã¹	*/
+							/* è£å©ãã¼ã¿		*/
+}  __attribute__((packed)) T_IGMP_GROUP_RECORD;
 
 typedef struct t_igmpv3_report_hdr
 {
-	uint8_t		type;		/* bZ[WÌ^	*/
-	uint8_t		rsv1;		/* \ñ				*/
-	uint16_t	sum;		/* `FbNT		*/
-	uint16_t	rsv2;		/* \ñ				*/
-	uint16_t	num;		/* O[vR[hÌ */
-	T_IGMP_GROUP_RECORD record;	/* O[vR[h */
-} T_IGMPV3R_HDR;
-
-#ifdef __CA850__
-#pragma pack(8)
-#elif __RX
-#pragma unpack
-#elif _MSC_VER
-#pragma pack(pop)
-#endif
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		rsv1;		/* äºç´				*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	uint16_t	rsv2;		/* äºç´				*/
+	uint16_t	num;		/* ã°ã«ã¼ãã¬ã³ã¼ãã®æ° */
+	T_IGMP_GROUP_RECORD record;	/* ã°ã«ã¼ãã¬ã³ã¼ã */
+}  __attribute__((packed)) T_IGMPV3R_HDR;
 
 #define IGMP_HDR_SIZE			(sizeof(T_IGMPV1_HDR))
@@ -125,15 +121,15 @@
 
 /*
-*  bZ[WÌ^
+*  ã¡ãã»ã¼ã¸ã®å
 */
 
-#define IGMP_MEMBERSHIP_QUERY		0x11	/* o[VbvNG[		*/
-#define IGMP_MEMBERSHIP_REPORT		0x12	/* o[Vbv|[g		*/
-#define IGMP_MEMBERSHIP_REPORT_V2	0x16	/* o[Vbv|[g		*/
-#define IGMP_LEAVE_GROUP			0x17	/* [uO[v				*/
-#define IGMP_MEMBERSHIP_REPORT_V3	0x22	/* o[Vbv|[g		*/
+#define IGMP_MEMBERSHIP_QUERY		0x11	/* ã¡ã³ãã¼ã·ããã¯ã¨ãªã¼		*/
+#define IGMP_MEMBERSHIP_REPORT		0x12	/* ã¡ã³ãã¼ã·ããã¬ãã¼ã		*/
+#define IGMP_MEMBERSHIP_REPORT_V2	0x16	/* ã¡ã³ãã¼ã·ããã¬ãã¼ã		*/
+#define IGMP_LEAVE_GROUP			0x17	/* ãªã¼ãã°ã«ã¼ã				*/
+#define IGMP_MEMBERSHIP_REPORT_V3	0x22	/* ã¡ã³ãã¼ã·ããã¬ãã¼ã		*/
 
 /*
-*  UDPÊM[_IvV
+*  UDPéä¿¡ç«¯ç¹ãªãã·ã§ã³
 */
 
@@ -168,12 +164,12 @@
 
 /*
- *  IGMP O[vGg
+ *  IGMP ã°ã«ã¼ãã¨ã³ããª
  */
 
 typedef struct igmp_entry
 {
-	uint16_t	timer;		/* MÜÅÌÔ[b]	*/
-	uint16_t	resptime;	/* ÅåÔ[b]	*/
-	T_IN4_ADDR	ip_addr;	/* IP AhX			*/
+	int16_t		timer;		/* éä¿¡ã¾ã§ã®æé[ç§]	*/
+	int16_t		resptime;	/* æå¤§å¿ç­æé[ç§]	*/
+	T_IN4_ADDR	ip_addr;	/* IP ã¢ãã¬ã¹			*/
 } T_IGMP_ENTRY;
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_input.c	(revision 429)
@@ -521,5 +521,19 @@
 
 				/* 相手のアドレスをコピーする。*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+				if (cep->flags & TCP_CEP_FLG_IPV4) {
+					(*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+					(*cep->p_dstaddr4).portno = cep->dstaddr.portno;
+					}
+				else
+					*cep->p_dstaddr = cep->dstaddr;
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
 				*cep->p_dstaddr = cep->dstaddr;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
 
 				if (IS_PTR_DEFINED(cep->callback)) {
@@ -847,5 +861,19 @@
 
 				/* 相手のアドレスをコピーする。*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+				if (cep->flags & TCP_CEP_FLG_IPV4) {
+					(*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+					(*cep->p_dstaddr4).portno = cep->dstaddr.portno;
+					}
+				else
+					*cep->p_dstaddr = cep->dstaddr;
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
 				*cep->p_dstaddr = cep->dstaddr;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
 
 				if (IS_PTR_DEFINED(cep->callback)) {
@@ -1363,4 +1391,8 @@
 	NTOHS(tcph->sport);
 	NTOHS(tcph->dport);
+
+	/* SDU 長 より 緊急ポインタが大きい場合 */
+	if (tcph->urp > tcph->sum)
+		goto drop;
 
 find_cep:
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_output.c	(revision 429)
@@ -369,6 +369,8 @@
 		tcph->flags |= TCP_FLG_URG;
 		}
-	else
+	else {
+		tcph->urp = 0;
 		cep->snd_up  = cep->snd_una;
+		}
 
 #endif	/* of #ifdef TCP_CFG_EXTENTIONS */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_subr.c	(revision 429)
@@ -805,5 +805,5 @@
 
 T_TCP_CEP *
-tcp_drop (T_TCP_CEP *cep, ER errno)
+tcp_drop (T_TCP_CEP *cep, ER err)
 {
 #ifdef SUPPORT_MIB
@@ -815,5 +815,5 @@
 #endif	/* of #ifdef SUPPORT_MIB */
 
-	cep->error = errno;
+	cep->error = err;
 	if (TCP_FSM_HAVE_RCVD_SYN(cep->fsm_state)) {
 		cep->fsm_state = TCP_FSM_CLOSED;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_timer.h	(revision 429)
@@ -86,8 +86,8 @@
  */
 
-#define TCP_SLOW_TMO		(ULONG_C(500)/NET_TIMER_CYCLE)	/* 500 [ms]	*/
-#define TCP_FAST_TMO		(ULONG_C(200)/NET_TIMER_CYCLE)	/* 200 [ms]	*/
+#define TCP_SLOW_TMO		(ULONG_C(500000)/NET_TIMER_CYCLE)	/* 500,000 [us]	*/
+#define TCP_FAST_TMO		(ULONG_C(200000)/NET_TIMER_CYCLE)	/* 200,000 [us]	*/
 
-#define TCP_SLOW_HZ		(ULONG_C(1000)/TCP_SLOW_TMO/NET_TIMER_CYCLE)	/* Hz	*/
+#define TCP_SLOW_HZ		(ULONG_C(1000000)/TCP_SLOW_TMO/NET_TIMER_CYCLE)	/* Hz	*/
 
 /* TCP タイマ値 */
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c	(revision 429)
@@ -897,5 +897,5 @@
 
 	/* tcp_rcv_buf の割当て長をリセットする。*/
-	cep->rcv_buf_len = 0;
+	cep->rcv_buf_len -= len;
 
 	/* 通信端点のロックを解除する。*/
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcp_var.h	(revision 429)
@@ -505,4 +505,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -817,5 +820,5 @@
 extern void tcp_init_iss (void);
 extern T_TCP_CEP *tcp_close (T_TCP_CEP *cep);
-extern T_TCP_CEP *tcp_drop  (T_TCP_CEP *cep, ER errno);
+extern T_TCP_CEP *tcp_drop  (T_TCP_CEP *cep, ER err);
 extern void tcp_respond (T_NET_BUF *nbuf, T_TCP_CEP *cep,
                          T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags);
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c	(revision 429)
@@ -689,10 +689,10 @@
 		cep->p_myaddr4    = p_myaddr;
 		cep->p_dstaddr    = NULL;
-		cep->p_myaddr     = NULL;
+		cep->p_myaddr     = NADR;
 
 #else	/* of #if API_PROTO == API_PROTO_IPV4 */
 
 		cep->p_dstaddr4   = NULL;
-		cep->p_myaddr4    = NULL;
+		cep->p_myaddr4    = NADR;
 		cep->p_dstaddr    = p_dstaddr;
 		cep->p_myaddr     = p_myaddr;
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_output.c	(revision 429)
@@ -182,5 +182,5 @@
 #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
 
-		for (ix = tmax_udp6_cepid; ix -- > 0; ) {
+		for (ix = TNUM_UDP6_CEPID - 1; ix -- > 0; ) {
 
 			if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
@@ -194,5 +194,5 @@
 #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
 
-		for (ix = tmax_udp4_cepid; ix -- > 0; ) {
+		for (ix = TNUM_UDP4_CEPID - 1; ix -- > 0; ) {
 
 			if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_subr.c	(revision 429)
@@ -146,5 +146,5 @@
 #define UDP_FIND_CEP		udp6_find_cep
 #define UDP_NOTIFY		udp6_notify
-#define TMAX_UDP_CEPID		tmax_udp6_cepid
+#define TMAX_UDP_CEPID		(TNUM_UDP6_CEPID - 1)
 #define UDP_CEP			udp6_cep
 #define T_UDP_CEP		T_UDP6_CEP
@@ -183,5 +183,5 @@
 #define UDP_FIND_CEP		udp4_find_cep
 #define UDP_NOTIFY		udp4_notify
-#define TMAX_UDP_CEPID		tmax_udp4_cepid
+#define TMAX_UDP_CEPID		(TNUM_UDP4_CEPID - 1)
 #define T_UDP_CEP		T_UDP4_CEP
 #define UDP_CEP			udp4_cep
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udp_var.h	(revision 429)
@@ -101,4 +101,14 @@
 typedef ER	(*t_udp_callback)(ID cepid, FN fncd, void *p_parblk);
 
+typedef struct t_udp_rcv_dat_para {
+	uint_t		len;
+	T_NET_BUF	*input;
+	uint_t		off;
+	union {
+		T_IPV4EP rep4;
+		T_IPV6EP rep6;
+	};
+	} T_UDP_RCV_DAT_PARA;
+
 /*
  *  UDP 通信端点
@@ -141,4 +151,10 @@
 #endif
 
+#ifdef SUPPORT_IGMP
+	bool_t igmp_loopback;
+	uint8_t igmp_ttl;
+	T_IN4_ADDR 	igmp_mcaddr;	/*  */
+#endif
+
 	} T_UDP6_CEP;
 
@@ -178,4 +194,5 @@
 	ER		error;		/* 待ち中に発生したエラー	*/
 #endif
+
 #ifdef SUPPORT_IGMP
 	bool_t igmp_loopback;
@@ -183,4 +200,5 @@
 	T_IN4_ADDR 	igmp_mcaddr;	/*  */
 #endif
+
 	} T_UDP4_CEP;
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_input.c	(revision 429)
@@ -88,8 +88,8 @@
 {
 	T_UDP_HDR	*udph;
-	uint_t		len;
+	T_UDP_RCV_DAT_PARA para;
 
 	udph = (T_UDP_HDR *)(input->buf + off);
-	len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
+	para.len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
 
 	if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
@@ -111,5 +111,5 @@
 		/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
 		memcpy(cep->rcv_data, GET_UDP_SDU(input, off),
-		       (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
+		       (size_t)(para.len < cep->rcv_len ? para.len : cep->rcv_len));
 		syscall(rel_net_buf(input));
 
@@ -117,7 +117,7 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)para.len);
 #else
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&para.len);
 #endif
 		else
@@ -134,7 +134,16 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)para.len);
 #else
-		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
+		para.input = input;
+		para.off = off;
+#if API_PROTO == API_PROTO_IPV4
+		para.rep4.portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&para.rep4.ipaddr, input);
+#else
+		para.rep6.portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&para.rep6.ipaddr, input);
+#endif
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&para.len);
 #endif
 		/*
@@ -143,6 +152,9 @@
 		 *  ãã¼ã¿ãèª­ã¿åºããªãã£ããã¨ã«ãªãã®ã§ãæ¨ã¦ãã
 		 */
-		if (cep->cb_netbuf != NULL)
-			syscall(rel_net_buf(cep->cb_netbuf));
+		if (cep->cb_netbuf != NULL) {
+			if ((input->flags & NB_FLG_NOREL_IFOUT) == 0)
+				syscall(rel_net_buf(cep->cb_netbuf));
+			cep->cb_netbuf = NULL;
+			}
 		}
 	else {
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c	(revision 429)
@@ -322,17 +322,16 @@
 		else 
 			error = UDP_ALLOC_PORT(cep, pk_ccep->myaddr.portno);
-		
-                if (error == E_OK) {
-
-			/* UDP éä¿¡ç«¯ç¹çææ
+
+			if (error == E_OK) {
+				/* UDP éä¿¡ç«¯ç¹çææ
 å ±ãã³ãã¼ããã*/
-			cep->cepatr        = pk_ccep->cepatr;			/* éä¿¡ç«¯ç¹å±æ§		*/
-			cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;		/* èªåã®ã¢ãã¬ã¹	*/
-			cep->callback      = (void*)pk_ccep->callback;		/* ã³ã¼ã«ããã¯		*/
-
-			/* UDP éä¿¡ç«¯ç¹ãçææ¸ã¿ã«ããã*/
-			cep->flags |= UDP_CEP_FLG_VALID;
-			}
-		}
+				cep->cepatr        = pk_ccep->cepatr;			/* éä¿¡ç«¯ç¹å±æ§		*/
+				cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+				cep->callback      = (void*)pk_ccep->callback;		/* ã³ã¼ã«ããã¯		*/
+
+				/* UDP éä¿¡ç«¯ç¹ãçææ¸ã¿ã«ããã*/
+				cep->flags |= UDP_CEP_FLG_VALID;
+				}
+			}
 
 	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
@@ -426,6 +425,5 @@
 		return E_NOEXS;
 #if defined(SUPPORT_INET6)
-#endif
-#if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
+#elif defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
 	switch (optname) {
 	case IP_MULTICAST_LOOP:
@@ -503,6 +501,5 @@
 		return E_NOEXS;
 #if defined(SUPPORT_INET6)
-#endif
-#if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
+#elif defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
 	switch (optname) {
 	case IP_MULTICAST_LOOP:
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c	(revision 429)
@@ -136,7 +136,7 @@
 
 #ifdef TCP_CFG_NON_BLOCKING_COMPAT14
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)error);
 #else
-			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)&error);
 #endif
 		else
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_subr.c	(revision 429)
@@ -369,6 +369,9 @@
 
 	/* IPv6 ヘッダを設定する。*/
-	if ((error = in6_set_header(*nbuf, len, dstaddr, srcaddr, next, hlim)) != E_OK)
+	if ((error = in6_set_header(*nbuf, len, dstaddr, srcaddr, next, hlim)) != E_OK) {
+		syscall(rel_net_buf(*nbuf));
+		*nbuf = NULL;
 		return error;
+		}
 
 	/* 4 オクテット境界までパディングで埋める。*/
@@ -662,5 +665,5 @@
  *  in6_rtredirect -- ルーティング表にエントリを登録する。
  *
- *    注意: 引数 tmo の単位は [ms]。
+ *    注意: 引数 tmo の単位は [us]。
  */
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/in6_var.h	(revision 429)
@@ -184,6 +184,6 @@
 	 * vltime と pltime は、追加/変更してからの相対時間
 	 */
-	uint32_t	vltime;		/* 有効時間 [ms]			*/
-	uint32_t	pltime;		/* 推奨有効時間 [ms]		*/
+	uint32_t	vltime;		/* 有効時間 [us]			*/
+	uint32_t	pltime;		/* 推奨有効時間 [us]		*/
 	} __attribute__((packed, aligned(2)))T_IN6_ADDR_LIFETIME;
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/ip6_var.h	(revision 429)
@@ -152,4 +152,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		unit;	/* インタフェース番号	*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -172,4 +175,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
@@ -224,4 +230,7 @@
 	uint8_t		idix;	/* mpfid のインデックス	*/
 	uint8_t		flags;	/* フラグ		*/
+#ifdef IF_ETHER_MULTI_NIC
+	uint8_t		conn_pos;
+#endif
 #ifdef IF_ETHER_NIC_NET_BUF_ALIGN
 	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.c	(revision 429)
@@ -353,4 +353,5 @@
 			if (nd6_cache[mix].hold != NULL) {
 				syscall(rel_net_buf(nd6_cache[mix].hold));
+				nd6_cache[mix].hold = NULL;
 				}
 			fix = mix;
@@ -562,4 +563,5 @@
 			if (ln->hold != NULL) {
 				syscall(rel_net_buf(ln->hold));
+				ln->hold = NULL;
 				}
 
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6.h	(revision 429)
@@ -81,5 +81,5 @@
 	T_NET_BUF	*hold;
 	TMO		tmout;
-	SYSTIM		expire;		/* [ms] 有効時間が切れる時刻	*/
+	SYSTIM		expire;		/* [us] 有効時間が切れる時刻	*/
 	T_IF_ADDR	ifaddr;
 	uint8_t		state;
@@ -183,6 +183,6 @@
 typedef struct t_def_router {
 	T_IN6_ADDR	addr;
-	SYSTIM		expire;		/* [ms] 有効時間が切れる時刻	*/
-	uint32_t	lifetime;	/* [ms] 有効時間			*/
+	SYSTIM		expire;		/* [us] 有効時間が切れる時刻	*/
+	uint32_t	lifetime;	/* [us] 有効時間			*/
 	uint16_t	plistmap;	/* プレフィックスマップ		*/
 	uint8_t		flags;		/* ルータ通知のフラグ		*/
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c	(revision 429)
@@ -999,9 +999,9 @@
 		return;
 
- 	/* ルータ要請ヘッダを設定する。*/
- 	rsh = GET_ROUTER_SOLICIT_HDR(output, IF_IP6_ROUTER_SOLICIT_HDR_OFFSET);
- 	rsh->hdr.type       = ND_ROUTER_SOLICIT;
- 	rsh->hdr.code       = 0;
- 	rsh->nd_rs_reserved = 0;
+	/* ルータ要請ヘッダを設定する。*/
+	rsh = GET_ROUTER_SOLICIT_HDR(output, IF_IP6_ROUTER_SOLICIT_HDR_OFFSET);
+	rsh->hdr.type       = ND_ROUTER_SOLICIT;
+	rsh->hdr.code       = 0;
+	rsh->nd_rs_reserved = 0;
 
 	/* チェックサムを計算する。*/
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tcpip_sym.def	(revision 429)
@@ -15,4 +15,5 @@
 TMO_UDP_OUTPUT
 TMO_ICMP_OUTPUT
+TMO_IGMP_OUTPUT
 TMO_ND6_NS_OUTPUT
 TMO_ND6_NA_OUTPUT
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet.trb	(revision 429)
@@ -124,4 +124,5 @@
 #include <net/ethernet.h>
 #include <net/net.h>
+#include <net/net_endian.h>
 #include <net/net_buf.h>
 #include <netinet/in.h>
@@ -142,7 +143,5 @@
 $tinetCfgC.add(" */")
 $tinetCfgC.add()
-$includeFiles.each do |file|
-  $tinetCfgC.add("#include #{file}")
-end
+GenerateIncludes($tinetCfgC)
 
 $tinetCfgC.add()
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg	(revision 331)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp.cfg	(revision 429)
@@ -73,4 +73,5 @@
 INCLUDE("netinet/if_ether.cfg");
 INCLUDE("netinet/ip.cfg");
+INCLUDE("netinet/ip_igmp.cfg");
 INCLUDE("netinet/tcp.cfg");
 INCLUDE("netinet/udp.cfg");
Index: EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp_configure
===================================================================
--- EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp_configure	(revision 429)
+++ EcnlProtoTool/trunk/asp3_dcre/tinet/tinet_asp_configure	(revision 429)
@@ -0,0 +1,514 @@
+#! /usr/bin/perl
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#  Copyright (C) 2001-2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2006-2008 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#  Copyright (C) 2001-2007 by Dep. of Computer Science and Engineering
+#                   Tomakomai National College of Technology, JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  @(#) $Id$
+# 
+
+require "getopt.pl";
+
+#  ãªãã·ã§ã³ã®å®ç¾©
+#
+#  -T <target>		ã¿ã¼ã²ããåï¼å¿
+é ï¼
+#  -A <applname>	ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã å
+#  -a <appldir>		ã¢ããªã±ã¼ã·ã§ã³ã®ãã£ã¬ã¯ããªå
+#  -U <applobjs>	ä»ã®ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ãã¡ã¤ã«
+#			ï¼.oãã¡ã¤ã«åã§æå®ï¼è¤æ°æå®å¯ï¼
+#  -L <kernel_lib>	ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.aï¼ã®ãã£ã¬ã¯ããªå
+#			ï¼çç¥ããå ´åï¼ã«ã¼ãã«ã©ã¤ãã©ãªãmakeããï¼
+#  -f			ã«ã¼ãã«ãé¢æ°åä½ã§ã³ã³ãã¤ã«ãããã©ããã®æå®
+#  -D <srcdir>		ã«ã¼ãã«ç­ã®ã½ã¼ã¹ã®ç½®ããã¦ãããã£ã¬ã¯ããª
+#  -l <srclang>		ãã­ã°ã©ãã³ã°è¨èªï¼ç¾æç¹ã§ã¯cã¨c++ã®ã¿ãµãã¼ãï¼
+#  -t <templatedir>	ãã³ãã¬ã¼ããã£ã¬ã¯ããªãæå®ï¼ããã©ã«ãã¯tinet/asp_sampleï¼
+#  -d <dbgenv>		å®è¡ç°å¢ã®åç§°
+#  -r			ãã¬ã¼ã¹ã­ã°è¨é²ã®ãµã³ãã«ã³ã¼ããä½¿ç¨ãããã©ããã®æå®
+#  -p <perl>		perlã®ãã¹åï¼æç¤ºçã«æå®ããå ´åï¼
+#  -g <cfg>		ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ï¼cfgï¼ã®ãã¹å
+#  -e <tinetdir>	TINET ã®ã½ã¼ã¹ã®ç½®ããã¦ãããã£ã¬ã¯ããª
+#  -i <net_if>		ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ï¼å¿
+é ï¼
+#			etherãpppãloop ã®ä½ãããæå®ããã
+#  -v <net_dev>		ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ã
+#  			ï¼ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã« ether ãæå®ããå ´åã¯å¿
+é ï¼
+#  -n <net_proto>	ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ï¼å¿
+é ï¼
+#			inet6ãinet4ãinet6/inet4ãinet6mãinet6m/inet4 ã®ä½ãããæå®ããã
+#  -s <trans_proto>	ãã©ã³ã¹ãã¼ãå±¤ãã­ãã³ã«ï¼å¿
+é ï¼
+#			tcpãudpãtcp/udp ã®ä½ãããæå®ããã
+#  -m <asptemplatedir>	ASPãã³ãã¬ã¼ããã£ã¬ã¯ããªãæå®ï¼ããã©ã«ãã¯sampleï¼
+
+#  ä½¿ç¨ä¾(1)
+#
+#  % ../tinet/tinet_asp_configure -T akih8_3069f_gcc -A echos4 -i ether -v if_ed -n inet4 -s tcp
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µå­ãè¿ã
+#
+sub get_objext {
+	local(@uname);
+
+	use POSIX;
+	@uname = &uname();
+	if ($uname[0] =~ /^cygwin/i) {
+		return("exe");
+	}
+	else {
+		return("");
+	}
+}
+
+#
+#  ãã­ã°ã©ã ã®å ´æãæ¤ç´¢ãã
+#
+sub get_path {
+	local($progname, @pathlist) = @_;
+	local($path);
+
+	foreach $path (@pathlist) {
+		if (-x $path."/".$progname) {
+			return($path."/".$progname);
+		}
+	}
+	return("");
+}
+
+#
+#  Makefile ãå¤æãã
+#
+sub convMakefileSub {
+	local($infile, $outfile) = @_;
+	local($line, $varname, $varval);
+
+	unless (open(INFILE, $infile)) {
+		print STDERR "tinet_asp_configure: can't open $infile\n";
+		exit(1);
+	}
+	unless (open(OUTFILE, ">> ".$outfile)) {
+		print STDERR "tinet_asp_configure: can't open $outfile\n";
+		exit(1);
+	}
+
+	while ($line = <INFILE>) {
+		chop $line;
+		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
+			$line = $1.$vartable{$2}.$3;
+		}
+		print OUTFILE $line,"\n";
+	}
+
+	close(INFILE);
+	close(OUTFILE);
+}
+
+#
+#  Makefile ãå¤æãã
+#
+sub convMakefile {
+	local($infile, $copyright, $outfile) = @_;
+	local($aspMakefile);
+
+	# Mekfile æãã°ãªãã¼ã ããã
+	print STDERR "tinet_asp_configure: Generating $outfile from $infile.\n";
+	if (-f $outfile) {
+		print STDERR "tinet_asp_configure: $outfile exists.",
+						"  Save as $outfile.bak.\n";
+		rename($outfile, $outfile.".bak");
+	}
+
+	# TINET ã®ã³ãã¼ã©ã¤ããæ¸ãè¾¼ã
+	&convMakefileSub($copyright, $outfile);
+
+	# åºåãã Makefile ããªã¼ãã³ãã
+	unless (open(OUTFILE, ">> ".$outfile)) {
+		print STDERR "tinet_asp_configure: can't open $outfile\n";
+		exit(1);
+	}
+
+	# åç
+§ãã sample/Makefile ããªã¼ãã³ããã
+	$aspMakefile = $aspsampledir."/Makefile";
+	unless (open(ASPFILE, $aspMakefile)) {
+		print STDERR "tinet_asp_configure: can't open $aspMakefile\n";
+		exit(1);
+	}
+
+	# åç
+§ãã sample/Makefile ã®ã³ãã¼ã©ã¤ããèª­ã¿é£ã°ãã
+	while ($line = <ASPFILE>) {
+		chop $line;
+		if ($line !~ /^#/) {
+			print OUTFILE $line,"\n";
+			last;
+		}
+	}
+
+	# 'APPLNAME = @(APPLNAME)' ã®è¡ã¾ã§æ¸ãè¾¼ã
+	while ($line = <ASPFILE>) {
+		chop $line;
+		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
+			$line = $1.$vartable{$2}.$3;
+		}
+		print OUTFILE $line,"\n";
+		if ($line =~ /^APPLNAME = /) {
+			last;
+		}
+	}
+
+	# '#' åã®è¡ã¾ã§æ¸ãè¾¼ã
+	while ($line = <ASPFILE>) {
+		chop $line;
+		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
+			$line = $1.$vartable{$2}.$3;
+		}
+		if ($line =~ /^#/) {
+			last;
+		}
+		print OUTFILE $line,"\n";
+	}
+
+	# ä¸åº¦åºåãã Makefile ãã¯ã­ã¼ãºããã
+	close(OUTFILE);
+
+	# TINET ã® Makefile ãæ¸ãè¾¼ã
+	&convMakefileSub($infile, $outfile);
+
+	# ããä¸åº¦åºåãã Makefile ããªã¼ãã³ãã
+	unless (open(OUTFILE, ">> ".$outfile)) {
+		print STDERR "tinet_asp_configure: can't open $outfile\n";
+		exit(1);
+	}
+
+	# åç
+§ãã sample/Makefile ã®æçµè¡ã¾ã§æ¸ãè¾¼ã
+	while ($line = <ASPFILE>) {
+		chop $line;
+		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
+			$line = $1.$vartable{$2}.$3;
+		}
+		print OUTFILE $line,"\n";
+	}
+
+	close(OUTFILE);
+	close(ASPFILE);
+}
+
+#
+#  Makefile ãçæãã
+#
+sub genMakefile {
+	local($file, $mandatory) = @_;
+	local($path, $copyright);
+
+	$path = $sampledir.$file.".".$applname;
+	$copyright = $sampledir.$file.".copyright";
+	if (-f $path) {
+		&convMakefile($path, $copyright, $file);
+		return;
+	}	
+
+	$path = $sampledir.$file;
+	if ($mandatory || -f $path) {
+		&convMakefile($path, $copyright, $file);
+	}	
+}
+
+#
+#  ãã¡ã¤ã«ãå¤æãã
+#
+sub convert {
+	local($infile, $outfile) = @_;
+	local($line, $varname, $varval);
+
+	print STDERR "tinet_asp_configure: Generating $outfile from $infile.\n";
+	if (-f $outfile) {
+		print STDERR "tinet_asp_configure: $outfile exists.",
+						"  Save as $outfile.bak.\n";
+		rename($outfile, $outfile.".bak");
+	}
+	unless (open(INFILE, $infile)) {
+		print STDERR "tinet_asp_configure: can't open $infile\n";
+		exit(1);
+	}
+	unless (open(OUTFILE, "> ".$outfile)) {
+		print STDERR "tinet_asp_configure: can't open $outfile\n";
+		exit(1);
+	}
+
+	while ($line = <INFILE>) {
+		chop $line;
+		while ($line =~ /^(.*)\@\(([A-Za-z0-9_]+)\)(.*)$/) {
+			$line = $1.$vartable{$2}.$3;
+		}
+		print OUTFILE $line,"\n";
+	}
+
+	close(INFILE);
+	close(OUTFILE);
+}
+
+#
+#  ãµã³ãã«ãè¦ã¤ãã¦ãã¡ã¤ã«ãçæãã
+#
+sub generate {
+	local($file, $mandatory) = @_;
+	local($path);
+
+	$path = $sampledir.$file.".".$applname;
+	if (-f $path) {
+		&convert($path, $file);
+		return;
+	}	
+
+	$path = $sampledir.$file;
+	if ($mandatory || -f $path) {
+		&convert($path, $file);
+	}	
+}
+
+#
+#  ã¡ã¤ã³å¦ç
+#
+#  ãªãã·ã§ã³ã®å¦ç
+#
+&Getopt("TAaULDltdpgiensv");
+
+#
+#  å¤æ°ã®åæå
+#
+$perl = $opt_p ? $opt_p : &get_path("perl", ("/usr/local/bin", "/usr/bin"));
+$target = $opt_T;
+$applname = $opt_A ? $opt_A : "";
+$appldir = $opt_a ? $opt_a : "";
+$applobjs = $opt_U ? $opt_U : "";
+$kernel_lib = $opt_L ? $opt_L : "";
+$kernel_funcobjs = $opt_f ? "true" : "";
+$srclang = $opt_l ? $opt_l : "c";
+$templatedir = $opt_t ? $opt_t : "asp_sample";
+$dbgenv = $opt_d ? "TOPPERS_".$opt_d : "";
+$enable_trace = $opt_r ? "true" : "";
+$net_if = $opt_i;
+$net_dev = $opt_v;
+$net_proto = $opt_n;
+$trans_proto = $opt_s;
+$aspsampledir = $opt_m ? $opt_m : "sample";
+$cfg = $opt_g ? $opt_g : "\$(SRCDIR)/cfg/cfg/cfg";
+$cfgfile = $opt_g ? $opt_g : $srcdir."/cfg/cfg/cfg";
+
+#
+#  ãªãã·ã§ã³ã®ç¢ºèª
+#
+unless ($opt_T) {
+	print STDERR "tinet_asp_configure: -T option is mandatory\n";
+	print STDERR "Installed targets are:\n";
+	foreach $targetname (<$srcdir/target/[a-zA-Z1-9]*>) {
+		$targetname =~ s|$srcdir/target/||;
+		print STDERR "\t$targetname\n";
+	}
+	exit(1);
+}
+unless ($opt_i) {
+	print STDERR "tinet_asp_configure: -i option is mandatory\n";
+	exit(1);
+}
+else {
+	unless ($opt_v) {
+		print STDERR "tinet_asp_configure: -v option is mandatory\n";
+		exit(1);
+	}
+}
+if ($opt_n) {
+	unless ($opt_n eq "inet6" || $opt_n eq "inet4" || $opt_n eq "inet6/inet4" || $opt_n eq "inet6m" || $opt_n eq "inet6m/inet4") {
+		print STDERR "tinet_asp_configure: inet6, inet4, inet6/inet4, inet6m or inet6m/inet4 expected in -n option\n";
+		exit(1);
+	}
+}
+else {
+	print STDERR "tinet_asp_configure: -n option is mandatory\n";
+	exit(1);
+}
+if ($opt_s) {
+	unless ($opt_s eq "tcp" || $opt_s eq "udp" || $opt_s eq "tcp/udp") {
+		print STDERR "tinet_asp_configure: tcp, udp or tcp/udp expected in -s option\n";
+		exit(1);
+	}
+}
+else {
+	print STDERR "tinet_asp_configure: -s option is mandatory\n";
+	exit(1);
+}
+
+#
+#  TINET ã®ã½ã¼ã¹ãã£ã¬ã¯ããªåãåãåºã
+#
+$pwd = `pwd`; chop $pwd;
+if ($opt_e) {
+	$tinetabsdir = $tinetdir = $opt_e;
+}
+elsif ($0 =~ /(.*)\/tinet_asp_configure/) {
+	$tinetdir = $1;
+	if ($tinetdir =~ /^\//) {
+		$tinetabsdir = $tinetdir;
+	}
+	else {
+		$tinetabsdir = $pwd."/".$tinetdir;
+	}
+}
+else {
+	$tinetabsdir = $tinetdir = $pwd;
+}
+$sampledir = $tinetdir."/".$templatedir."/";
+
+#
+#  ã½ã¼ã¹ãã£ã¬ã¯ããªåãåãåºã
+#
+$pwd = `pwd`; chop $pwd;
+if ($opt_D) {
+	$srcabsdir = $srcdir = $opt_D;
+}
+elsif ($0 =~ /(.*)\/tinet\/tinet_asp_configure/) {
+	$srcdir = $1;
+	if ($srcdir =~ /^\//) {
+		$srcabsdir = $srcdir;
+	}
+	else {
+		$srcabsdir = $pwd."/".$srcdir;
+	}
+}
+else {
+	$srcabsdir = $srcdir = $pwd;
+}
+$aspsampledir = $srcdir."/".$aspsampledir;
+
+#
+#  å¤æ°ãã¼ãã«ã®ä½æ
+#
+%vartable = ();
+$vartable{"TARGET"} = $target;
+$vartable{"APPLNAME"} = $applname;
+$vartable{"APPLDIR"} = $appldir;
+$vartable{"APPLOBJS"} = $applobjs;
+$vartable{"KERNEL_LIB"} = $kernel_lib;
+$vartable{"KERNEL_FUNCOBJS"} = $kernel_funcobjs;
+$vartable{"SRCDIR"} = $srcdir;
+$vartable{"SRCABSDIR"} = $srcabsdir;
+$vartable{"SRCLANG"} = $srclang;
+$vartable{"DBGENV"} = $dbgenv;
+$vartable{"ENABLE_TRACE"} = $enable_trace;
+$vartable{"OBJEXT"} = &get_objext();
+$vartable{"PERL"} = $perl;
+$vartable{"CFG"} = $cfg;
+$vartable{"TINETDIR"} = $tinetdir;
+$vartable{"TINETABSDIR"} = $tinetabsdir;
+$vartable{"NET_IF"} = $net_if;
+$vartable{"NET_DEV"} = $net_dev;
+
+#
+#  -n ãªãã·ã§ã³ã®å¦ç
+#
+
+$vartable{"SUPPORT_INET6"} = "#SUPPORT_INET6 = true";
+$vartable{"SUPPORT_INET4"} = "#SUPPORT_INET4 = true";
+if ($net_proto eq "inet6" || $net_proto eq "inet6/inet4" || $net_proto eq "inet6m" || $net_proto eq "inet6m/inet4") {
+	$vartable{"SUPPORT_INET6"} = "SUPPORT_INET6 = true";
+}
+if ($net_proto eq "inet4" || $net_proto eq "inet6/inet4" || $net_proto eq "inet6m/inet4") {
+	$vartable{"SUPPORT_INET4"} = "SUPPORT_INET4 = true";
+}
+
+$vartable{"API_CFG_IP4MAPPED_ADDR"} = "#API_CFG_IP4MAPPED_ADDR = true";
+if ($net_proto eq "inet6m" || $net_proto eq "inet6m/inet4") {
+	$vartable{"API_CFG_IP4MAPPED_ADDR"} = "API_CFG_IP4MAPPED_ADDR = true";
+}
+
+#
+#  -s ãªãã·ã§ã³ã®å¦ç
+#
+
+$vartable{"SUPPORT_TCP"} = "#SUPPORT_TCP = true";
+$vartable{"SUPPORT_UDP"} = "#SUPPORT_UDP = true";
+if ($trans_proto eq "tcp" || $trans_proto eq "tcp/udp") {
+	$vartable{"SUPPORT_TCP"} = "SUPPORT_TCP = true";
+}
+if ($trans_proto eq "udp" || $trans_proto eq "tcp/udp") {
+	$vartable{"SUPPORT_UDP"} = "SUPPORT_UDP = true";
+}
+
+#
+#  ã¿ã¼ã²ãããã£ã¬ã¯ããªã®ãã§ãã¯
+#
+
+if (! -d $srcdir."/target/".$target) {
+	print STDERR "tinet_asp_configure: $srcdir/target/$target not exist\n";
+	exit(1);
+}
+
+#
+#  Makefile ã¨ã¢ããªã±ã¼ã·ã§ã³ãã¡ã¤ã«ã®çæ
+#
+
+&genMakefile("Makefile", 1);
+&generate($applname.".c", 0);
+&generate($applname.".cpp", 0);
+&generate($applname.".h", 0);
+&generate($applname.".cfg", 0);
+&generate("tinet_".$applname.".cfg", 0);
+&generate("route_cfg.c", 0);
+&generate("tinet_app_config.h", 0);
+
+#
+#  cfg ãã§ãã¦ãããã®ãã§ãã¯
+#
+
+if (!(-x ($objext == "" ? $cfgfile : $cfgfile.".".$objext))) {
+	print STDERR "Please compile the configurator (cfg).\n";
+}
