Reputation: 11
I am getting packets from NDIS filter SendnetBufferList routine . Inside that I am accepting the buffer after filtering that buffer .
In case of NdisMedium802_3 medium , getting packet with Ethernet header (Ethernet frames) . So i can easily analyze ipv4 & ipv6 using Ethernet header .
PPF_ETHERNET_HEADER pEthHeader = (PPF_ETHERNET_HEADER) pBuffer;
filter.nEthProto = pEthHeader->nProto;
System::MCopyMemory(&filter.aSrcMac, &pEthHeader->aSrcMac,
sizeof(ETH_MAC_ADDRESS));
System::MCopyMemory(&filter.aDstMac, &pEthHeader->aDstMac,
sizeof(ETH_MAC_ADDRESS));
if (filter.nEthProto == ETH_PROTO_IPV4) {
PPF_IPV4_HEADER pIpHeader = (PPF_IPV4_HEADER) (pBuffer +
sizeof(PF_ETHERNET_HEADER));
/* IPV4 operations */
}
else if (filter.nEthProto == ETH_PROTO_IPV6)
{
PPF_IPV6_HEADER pIpHeader = (PPF_IPV6_HEADER) (pBuffer +
sizeof(PF_ETHERNET_HEADER));
/* IPV6 operations */
}
This is working fine . Next i am attaching NdisMediumWirelessWan / NdisMediumIP medium . This is sending RAW IP frames with out Ethernet header .
My questions is how can i check NDIS buffer contain ipv4 or ipv6 with out Ethernet header ? and also how can i set Mac address ?
Upvotes: 0
Views: 640
Reputation: 359
You can easily obtain protocol information from the NET_BUFFER_LIST:
filter.nEthProto = (USHORT)NET_BUFFER_LIST_INFO(pNBList, NetBufferListFrameType);
Upvotes: 0