c++ - C++/C 中以太网 ip 中的 eth_dr 是什么?

标签 c++ c windows driver mobile-broadband-api

我想在驱动程序模块内编写一行代码以获得对移动宽带的支持。这是代码:

   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/

相关文章:

c++ - 如何在 C++ Builder 中将注册表导出到 *.reg 文件?

android - 无法在 Windows 上安装适用于 IntelliJ 的 Android 模拟器,可能是由于路径错误

c++ - 当列数固定时,Eigen::无法将 Block<Derived> 转换为 Ref<Derived>

c++ - 为什么第二次初始化工作而第一次初始化因为 "element type does not match"而失败?

c++ - 按 vector 中的对象属性合并排序

c - C 程序中的 wpa_supplicant 用法

c++ - 如果进程被 SIGKILLed,操作系统(POSIX)是否刷新内存映射文件?

c - 请解释以下 C 代码的输出

c - C-第二半中的星形图案未打印

c++ - 无法在我的代码中计算出 char* 字符串