diff --git a/packetWin7/npf/npf/Read.c b/packetWin7/npf/npf/Read.c index 6d7169e7..4ba8a868 100644 --- a/packetWin7/npf/npf/Read.c +++ b/packetWin7/npf/npf/Read.c @@ -877,6 +877,7 @@ NPF_TapExForEachOpen( if (withVlanTag) { + // Insert a tag in the case of IEEE802.1Q packet pHeaderBuffer = ExAllocatePoolWithTag(NonPagedPool, fres + 4, 'NPCA'); NdisMoveMappedMemory(pHeaderBuffer, HeaderBuffer, 12); pHeaderBuffer[12] = 0x81; diff --git a/packetWin7/npf/npf/Write.c b/packetWin7/npf/npf/Write.c index 7e7b6daf..82642584 100644 --- a/packetWin7/npf/npf/Write.c +++ b/packetWin7/npf/npf/Write.c @@ -248,6 +248,47 @@ NPF_Write( NPFSetNBLChildOpen(pNetBufferList, Open); //save the child open object in the packets //SendFlags |= NDIS_SEND_FLAGS_CHECK_FOR_LOOPBACK; + // Recognize IEEE802.1Q tagged packet, as no many adapters support VLAN tag packet sending, no much use for end users, + // and this code examines the data which lacks efficiency, so I left it commented, the sending part is also unfinished. + // This code refers to Win10Pcap at https://github.com/SoftEtherVPN/Win10Pcap. +// if (Open->Loopback == FALSE) +// { +// PUCHAR pHeaderBuffer; +// UINT iFres; +// +// BOOLEAN withVlanTag = FALSE; +// UINT VlanID = 0; +// UINT VlanUserPriority = 0; +// UINT VlanCanFormatID = 0; +// +// NdisQueryMdl( +// Irp->MdlAddress, +// &pHeaderBuffer, +// &iFres, +// NormalPagePriority); +// +// // Determine if the packet is IEEE802.1Q tagged packet. +// if (iFres >= 18) +// { +// if (pHeaderBuffer[12] == 0x81 && pHeaderBuffer[13] == 0x00) +// { +// USHORT pTmpVlanTag = 0; +// +// ((UCHAR *)(&pTmpVlanTag))[0] = pHeaderBuffer[15]; +// ((UCHAR *)(&pTmpVlanTag))[1] = pHeaderBuffer[14]; +// +// VlanID = pTmpVlanTag & 0x0FFF; +// VlanUserPriority = (pTmpVlanTag >> 13) & 0x07; +// VlanCanFormatID = (pTmpVlanTag >> 12) & 0x01; +// +// if (VlanID != 0) +// { +// withVlanTag = TRUE; +// } +// } +// } +// } + // // Call the MAC //