如何为 NDIS 虚拟微型端口驱动程序设置和查询多播地址?

How to set and query multicast address for NDIS Virtual miniport driver?

我想在虚拟微型端口驱动程序上添加多播支持。我有一个过滤驱动程序绑定到每个物理 NIC 上。根据微软文档
https://msdn.microsoft.com/en-us/library/windows/hardware/ff569073(v=vs.85).aspx

我开始添加支持多播地址:

这些是我的步骤: 在微型端口驱动程序中: 在 miniport initialization 期间,我在 NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES 中添加了 MaxMulticastListSize = 32 .

NDIS_MINIPORT_ADAPTER_GENERAL_ATTRIBUTES MiniportAdapterGeneralAttributes;
MiniportAdapterGeneralAttributes.MediaType = NdisMedium802_3;
MiniportAdapterGeneralAttributes.PhysicalMediumType = NdisPhysicalMediumUnspecified;
MiniportAdapterGeneralAttributes.MaxMulticastListSize = 32;

我还在 OID_802_3_MAXIMUM_LIST_SIZE OID 中更新了 32 个最大地址。 接下来我在

中更新了 PacketFilters
MiniportAdapterGeneralAttributes.SupportedPacketFilters =    NDIS_PACKET_TYPE_DIRECTED |
        NDIS_PACKET_TYPE_MULTICAST |
        NDIS_PACKET_TYPE_BROADCAST |
        NDIS_PACKET_TYPE_PROMISCUOUS |
        NDIS_PACKET_TYPE_ALL_MULTICAST;

OID_GEN_CURRENT_PACKET_FILTER OID 设置请求期间,我用 DATA.SET_INFORMATION.InformationBuffer 值更新了 PacketFilters。

并且在 OID_GEN_MAC_OPTION 期间我正在添加宏:NDIS_MAC_OPTION_NO_LOOPBACK | NDIS_MAC_OPTION_FULL_DUPLEX | NDIS_MAC_OPTION_8021P_PRIORITY ;

接下来在 OID_802_3_MULTICAST_LIST OID 设置请求中,我维护了一个多播列表

OidRequest->DATA.SET_INFORMATION.BytesNeeded = 6;
OidRequest->DATA.SET_INFORMATION.BytesRead = OidRequest->DATA.SET_INFORMATION.InformationBufferLength;

do
{

  //check multicast address invalid
  if(OidRequest->DATA.SET_INFORMATION.InformationBufferLength % 6){
   OidRequest->DATA.SET_INFORMATION.BytesRead = 0;
   status = NDIS_STATUS_INVALID_LENGTH;
   break;
   }

   //check multicast address list full
  if(OidRequest->DATA.SET_INFORMATION.InformationBufferLength > (VELAN_MAX_MCAST_LIST * 6)){
  status = NDIS_STATUS_MULTICAST_FULL;
  OidRequest->DATA.SET_INFORMATION.BytesNeeded = VELAN_MAX_MCAST_LIST * 6;
  break;
  }

 //setting new multicast address list
 NdisZeroMemory(m_ulMcList,VELAN_MAX_MCAST_LIST * MUX_MAC_ADDRESS);
 NdisMoveMemory(m_ulMcList,OidRequest->DATA.SET_INFORMATION.InformationBuffer,OidRequest->DATA.SET_INFORMATION.InformationBufferLength);
 m_ulMclistSize = OidRequest->DATA.SET_INFORMATION.InformationBufferLength / 6;
 status = NDIS_STATUS_SUCCESS;

}while(FALSE);

我用 NDISTester 测试过。它有一个将绑定到微型端口适配器的协议驱动程序。但是我在接收期间没有收到任何多播数据包。有什么东西不见了吗?我收到类似 received less than expected percentage of sent 的错误。有什么建议么 ?

我认为您需要为 OID_802_3_MAXIMUM_LIST_SIZE 提供处理程序。