简体   繁体   English

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

[英]What is eth_dr in ethernet ip in c++/C?

i want to write a line of code inside a driver module to get support on Mobile broadband .我想在驱动程序模块中编写一行代码以获得对移动宽带的支持。 This is the code :这是代码:

   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;

            }

so my doubt , what is struct eth_hdr ?所以我怀疑,什么是struct eth_hdr which header file i include ?我包含哪个头文件? so i should define this structure as my own ?所以我应该把这个结构定义为我自己的?

Searching a little bit on google returns these precise lines from a repo on GitHub .在 google 上稍微搜索一下就会从 GitHub 上的 repo返回这些精确的行

Using the GitHub search feature on the repo returns those lines :使用 repo 上的 GitHub 搜索功能返回这些行

/** 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

This seems to describe only a part of an ethernet frame with MAC Dest, MAC source and Ethertype.这似乎仅描述了具有 MAC 目标、MAC 源和以太网类型的以太网帧的一部分。

You should notice that this code is extracted directly from a bootkit (namely Caberp ) which, among other things, inject a network driver in the kernel network driver stack.您应该注意到该代码是直接从bootkit (即Caberp )中提取的,它在内核网络驱动程序堆栈中注入了一个网络驱动程序。 I don't think this kind of code is a good start for getting an idea on how a NDIS driver should be made.我不认为这种代码是了解如何制作 NDIS 驱动程序的良好开端。

There are enough good NDIS driver samples on the WDK to start with. WDK 上有足够多的优秀 NDIS 驱动程序示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM