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
