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

时间:2017-03-25 09:13:48

标签: windows filter wdk ndis miniport

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

我盯着添加支持多播地址:

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

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

我还在OID_802_3_MAXIMUM_LIST_SIZE OID中更新了32个最大地址。 接下来我更新了<{p>中的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。有什么建议 ?

1 个答案:

答案 0 :(得分:1)

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