浏览代码

Fix bug in tap driver introduced during unused code purge (deleted the part that acknowledges writes!), and fix bug in EthernetTap causing 0000 for etherType. Windows works now! Yay!

Adam Ierymenko 12 年之前
父节点
当前提交
8771418170

二进制
ext/bin/tap-windows/x64/zttap200.cat


+ 1 - 1
ext/bin/tap-windows/x64/zttap200.inf

@@ -4,7 +4,7 @@ Class=Net
 ClassGuid={4d36e972-e325-11ce-bfc1-08002be10318}
 Provider=%Provider%
 CatalogFile=zttap200.cat
-DriverVer=01/22/2014,22.4.22.918
+DriverVer=01/23/2014,15.19.17.816
 
 [Strings]
 DeviceDescription = "ZeroTier One Virtual Network Port"

二进制
ext/bin/tap-windows/x64/zttap200.sys


+ 2 - 2
node/EthernetTap.cpp

@@ -1385,7 +1385,8 @@ void EthernetTap::put(const MAC &from,const MAC &to,unsigned int etherType,const
 		char *d = _injectPending.back().first.data;
 		memcpy(d,to.data,6);
 		memcpy(d + 6,from.data,6);
-		*((uint16_t *)(d + 12)) = Utils::hton(etherType);
+		d[12] = (char)((etherType >> 8) & 0xff);
+		d[13] = (char)(etherType & 0xff);
 		memcpy(d + 14,data,len);
 	}
 
@@ -1475,7 +1476,6 @@ void EthernetTap::threadMain()
 					MAC from(_tapReadBuf + 6);
 					unsigned int etherType = Utils::ntoh(*((const uint16_t *)(_tapReadBuf + 12)));
 					Buffer<4096> tmp(_tapReadBuf + 14,bytesRead - 14);
-					//printf("GOT FRAME: %u bytes: %s\r\n",(unsigned int)bytesRead,Utils::hex(_tapReadBuf,bytesRead).c_str());
 					_handler(_arg,from,to,etherType,tmp);
 				}
 			}

+ 32 - 0
windows/TapDriver/tapdrvr.c

@@ -1833,6 +1833,38 @@ NTSTATUS
 				p_IRP->IoStatus.Status = l_Status = STATUS_UNSUCCESSFUL;
 				p_IRP->IoStatus.Information = 0;
 			}
+			else if ((l_IrpSp->Parameters.Write.Length) >= ETHERNET_HEADER_SIZE)
+			{
+				__try
+				{
+					p_IRP->IoStatus.Information = l_IrpSp->Parameters.Write.Length;
+
+					DUMP_PACKET ("IRP_MJ_WRITE ETH",
+						(unsigned char *) p_IRP->AssociatedIrp.SystemBuffer,
+						l_IrpSp->Parameters.Write.Length);
+
+					NdisMEthIndicateReceive
+						(l_Adapter->m_MiniportAdapterHandle,
+						(NDIS_HANDLE) l_Adapter,
+						(PCHAR)p_IRP->AssociatedIrp.SystemBuffer,
+						ETHERNET_HEADER_SIZE,
+						(unsigned char *)p_IRP->AssociatedIrp.SystemBuffer + ETHERNET_HEADER_SIZE,
+						l_IrpSp->Parameters.Write.Length - ETHERNET_HEADER_SIZE,
+						l_IrpSp->Parameters.Write.Length - ETHERNET_HEADER_SIZE);
+
+					NdisMEthIndicateReceiveComplete (l_Adapter->m_MiniportAdapterHandle);
+
+					p_IRP->IoStatus.Status = l_Status = STATUS_SUCCESS;
+				}
+				__except (EXCEPTION_EXECUTE_HANDLER)
+				{
+					DEBUGP (("[%s] NdisMEthIndicateReceive failed in IRP_MJ_WRITE\n",
+						NAME (l_Adapter)));
+					NOTE_ERROR ();
+					p_IRP->IoStatus.Status = l_Status = STATUS_UNSUCCESSFUL;
+					p_IRP->IoStatus.Information = 0;
+				}
+			}
 			else
 			{
 				DEBUGP (("[%s] Bad buffer size in IRP_MJ_WRITE, len=%d\n",