我想在驱动程序模块内编写一行代码以获得对移动宽带的支持。这是代码:
PUCHAR pCurrData;
struct eth_hdr *pEthHeader = (struct eth_hdr*)pCurrData;
NET_BUFFER_LIST_INFO(pNBL, NetBufferListFrameType) = (PVOID)(ULONG_PTR)pEthHeader->type;
switch( pEthHeader->type ){
case PP_HTONS(ETHTYPE_IP):
NdisSetNblFlag(pNBL, 0x00000200 /*NDIS_NBL_FLAGS_IS_IPV4*/);
break;
}
所以我怀疑,什么是struct eth_hdr
?我包含哪个头文件?所以我应该将这个结构定义为我自己的结构?
最佳答案
在谷歌上搜索一下会返回这些 precise lines from a repo on GitHub .
在存储库上使用 GitHub 搜索功能 returns those lines :
/** Ethernet header */
struct eth_hdr {
#if ETH_PAD_SIZE
PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]);
#endif
PACK_STRUCT_FIELD(struct eth_addr dest);
PACK_STRUCT_FIELD(struct eth_addr src);
PACK_STRUCT_FIELD(u16_t type);
} PACK_STRUCT_STRUCT;
PACK_STRUCT_END
#ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/epstruct.h"
#endif
这似乎只描述了 ethernet frame 的一部分带有 MAC 目标、MAC 源和以太网类型。
您应该注意到,此代码是直接从 bootkit (即 Caberp )中提取的,其中,它在内核网络驱动程序堆栈中注入(inject)了一个网络驱动程序。我不认为这种代码是了解如何制作 NDIS 驱动程序的良好开端。
WDK 上有足够好的 NDIS 驱动程序示例可供开始使用。
关于c++ - C++/C 中以太网 ip 中的 eth_dr 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33854930/