c++/C 中以太网 ip 中的 eth_dr 是什么?
What is eth_dr in ethernet ip in c++/C?
我想在驱动程序模块中编写一行代码以获得对移动宽带的支持。这是代码:
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
是什么?我包括哪个头文件?所以我应该将这个结构定义为我自己的?
正在 google returns 上稍微搜索一下 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 Dest,MAC source 和 Ethertype。
您应该注意到这段代码是直接从 bootkit(即 Caberp)中提取的,其中包括在内核网络驱动程序中注入网络驱动程序堆。我不认为这种代码是了解应该如何制作 NDIS 驱动程序的良好开端。
WDK 上有足够好的 NDIS 驱动程序示例,可以作为开始。
我想在驱动程序模块中编写一行代码以获得对移动宽带的支持。这是代码:
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
是什么?我包括哪个头文件?所以我应该将这个结构定义为我自己的?
正在 google returns 上稍微搜索一下 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 Dest,MAC source 和 Ethertype。
您应该注意到这段代码是直接从 bootkit(即 Caberp)中提取的,其中包括在内核网络驱动程序中注入网络驱动程序堆。我不认为这种代码是了解应该如何制作 NDIS 驱动程序的良好开端。
WDK 上有足够好的 NDIS 驱动程序示例,可以作为开始。