当前位置: 首页 > 文档资料 > WinPcap 中文手册 >

WinPcap: Packet.h File Reference

优质
小牛编辑
135浏览
2023-12-01

#include "win_bpf.h"

Go to the source code of this file.

Data Structures

structpacket_file_header
Header of a libpcap dump file. More...
structsf_pkthdr
Header associated to a packet in the driver's buffer when the driver is in dump mode. Similar to the bpf_hdr structure, but simpler. More...
struct_INTERNAL_REQUEST
Stores an OID request. More...
struct_PACKET_RESERVED
Contains a NDIS packet. More...
struct_DEVICE_EXTENSION
Port device extension. More...
struct__CPU_Private_Data
Kernel buffer of each CPU. More...
struct_OPEN_INSTANCE
Contains the state of a running instance of the NPF driver. More...
structPacketHeader
Structure prepended to each packet in the kernel buffer pool. More...

Defines

#defineMAX_REQUESTS32
Maximum number of simultaneous IOCTL requests.
#definePacket_ALIGNMENTsizeof(int)
Alignment macro. Defines the alignment size.
#definePacket_WORDALIGN(x)(((x)+(Packet_ALIGNMENT-1))&~(Packet_ALIGNMENT-1))
even multiple of Packet_ALIGNMENT.
#defineKERNEL_EVENT_NAMESPACEL"\BaseNamedObjects\"
#defineBIOCSETBUFFERSIZE9592
IOCTL code: set kernel buffer size.
#defineBIOCSETF9030
IOCTL code: set packet filtering program.
#defineBIOCGSTATS9031
IOCTL code: get the capture stats.
#defineBIOCSRTIMEOUT7416
IOCTL code: set the read timeout.
#defineBIOCSMODE7412
IOCTL code: set working mode.
#defineBIOCSWRITEREP7413
IOCTL code: set number of physical repetions of every packet written by the app.
#defineBIOCSMINTOCOPY7414
IOCTL code: set minimum amount of data in the kernel buffer that unlocks a read call.
#defineBIOCSETOID2147483648
IOCTL code: set an OID value.
#defineBIOCQUERYOID2147483652
IOCTL code: get an OID value.
#defineBIOCSETDUMPFILENAME9029
IOCTL code: set the name of a the file used by kernel dump mode.
#defineBIOCGEVNAME7415
IOCTL code: get the name of the event that the driver signals when some data is present in the buffer.
#defineBIOCSENDPACKETSNOSYNC9032
IOCTL code: Send a buffer containing multiple packets to the network, ignoring the timestamps.
#defineBIOCSENDPACKETSSYNC9033
IOCTL code: Send a buffer containing multiple packets to the network, considering the timestamps.
#defineBIOCSETDUMPLIMITS9034
IOCTL code: Set the dump file limits.
#defineBIOCISDUMPENDED7411
IOCTL code: Get the status of the kernel dump process.
#defineBIOCISETLOBBEH7410
IOCTL code: set the loopback behavior.
#defineBIOCSETEVENTHANDLE7920
This IOCTL passes the read event HANDLE allocated by the user (packet.dll) to kernel level.
#defineMODE_CAPT0x0
Capture working mode.
#defineMODE_STAT0x1
Statistical working mode.
#defineMODE_MON0x2
Kernel monitoring mode.
#defineMODE_DUMP0x10
Kernel dump working mode.
#defineIMMEDIATE1
Immediate timeout. Forces a read call to return immediately.
#defineNDIS_FLAGS_SKIP_LOOPBACK_W2K0x400
This is an undocumented flag for NdisSetPacketFlags() that allows to disable loopback reception.
#defineTCPDUMP_MAGIC0xa1b2c3d4
Libpcap magic number. Used by programs like tcpdump to recognize a driver's generated dump file.
#definePCAP_VERSION_MAJOR2
Major libpcap version of the dump file. Used by programs like tcpdump to recognize a driver's generated dump file.
#definePCAP_VERSION_MINOR4
Minor libpcap version of the dump file. Used by programs like tcpdump to recognize a driver's generated dump file.
#defineNPF_DISABLE_LOOPBACK1
Tells the driver to drop the packets sent by itself. This is usefult when building applications like bridges.
#defineNPF_ENABLE_LOOPBACK2
Tells the driver to capture the packets sent by itself.
#defineRESERVED(_p)((PPACKET_RESERVED)((_p)->ProtocolReserved))
Macro to obtain a NDIS_PACKET from a PACKET_RESERVED.
#defineTRANSMIT_PACKETS256
of packets that can be transmitted at the same time or with a single call to NdisSendPackets.
#defineEXIT_SUCCESS(quantity)
Macro used in the I/O routines to return the control to user-mode with a success status.
#defineEXIT_FAILURE(quantity)
Macro used in the I/O routines to return the control to user-mode with a failure status.

Typedefs

typedef _INTERNAL_REQUESTINTERNAL_REQUEST
Stores an OID request.
typedef _INTERNAL_REQUEST *PINTERNAL_REQUEST
Stores an OID request.
typedef _PACKET_RESERVEDPACKET_RESERVED
Contains a NDIS packet.
typedef _PACKET_RESERVED *PPACKET_RESERVED
Contains a NDIS packet.
typedef _DEVICE_EXTENSIONDEVICE_EXTENSION
Port device extension.
typedef _DEVICE_EXTENSION *PDEVICE_EXTENSION
Port device extension.
typedef __CPU_Private_DataCpuPrivateData
Kernel buffer of each CPU.
typedef _OPEN_INSTANCEOPEN_INSTANCE
Contains the state of a running instance of the NPF driver.
typedef _OPEN_INSTANCE *POPEN_INSTANCE
Contains the state of a running instance of the NPF driver.

Enumerations

enumADAPTER_BINDING_STATUS { ADAPTER_UNBOUND,
ADAPTER_BOUND,
ADAPTER_UNBINDING
}

Functions

NTSTATUSDriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
The initialization routine of the driver.
PWCHARgetAdaptersList (VOID)
Returns the list of the MACs available on the system.
PKEY_VALUE_PARTIAL_INFORMATIONgetTcpBindings (VOID)
Returns the MACs that bind to TCP/IP.
BOOLEANcreateDevice (IN OUT PDRIVER_OBJECT adriverObjectP, IN PUNICODE_STRING amacNameP, NDIS_HANDLE aProtoHandle)
Creates a device for a given MAC.
NTSTATUSNPF_Open (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Opens a new instance of the driver.
VOIDNPF_OpenAdapterComplete (IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status, IN NDIS_STATUS OpenErrorStatus)
Ends the opening of an adapter.
NTSTATUSNPF_Cleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Closes an instance of the driver.
NTSTATUSNPF_Close (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOIDNPF_CloseAdapterComplete (IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status)
Ends the closing of an adapter.
NDIS_STATUSNPF_tap (IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, IN UINT HeaderBufferSize, IN PVOID LookAheadBuffer, IN UINT LookaheadBufferSize, IN UINT PacketSize)
Callback invoked by NDIS when a packet arrives from the network.
VOIDNPF_TransferDataComplete (IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET Packet, IN NDIS_STATUS Status, IN UINT BytesTransferred)
Ends the transfer of a packet.
VOIDNPF_ReceiveComplete (IN NDIS_HANDLE ProtocolBindingContext)
Callback function that signals the end of a packet reception.
NTSTATUSNPF_IoControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Handles the IOCTL calls.
VOIDNPF_RequestComplete (IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_REQUEST pRequest, IN NDIS_STATUS Status)
Ends an OID request.
NTSTATUSNPF_Write (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Writes a raw packet to the network.
INTNPF_BufferedWrite (IN PIRP Irp, IN PCHAR UserBuff, IN ULONG UserBuffSize, BOOLEAN sync)
Writes a buffer of raw packets to the network.
VOIDNPF_WaitEndOfBufferedWrite (POPEN_INSTANCE Open)
Waits the completion of all the sends performed by NPF_BufferedWrite.
VOIDNPF_SendComplete (IN NDIS_HANDLE ProtocolBindingContext, IN PNDIS_PACKET pPacket, IN NDIS_STATUS Status)
Ends a send operation.
VOIDNPF_ResetComplete (IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status)
Ends a reset of the adapter.
VOIDNPF_Status (IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_STATUS Status, IN PVOID StatusBuffer, IN UINT StatusBufferSize)
Callback for NDIS StatusHandler. Not used by NPF.
VOIDNPF_StatusComplete (IN NDIS_HANDLE ProtocolBindingContext)
Callback for NDIS StatusCompleteHandler. Not used by NPF.
VOIDNPF_Unload (IN PDRIVER_OBJECT DriverObject)
Function called by the OS when NPF is unloaded.
NTSTATUSNPF_Read (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Function that serves the user's reads.
NTSTATUSNPF_ReadRegistry (IN PWSTR *MacDriverName, IN PWSTR *PacketDriverName, IN PUNICODE_STRING RegistryPath)
Reads the registry keys associated woth NPF if the driver is manually installed via the control panel.
NTSTATUSNPF_QueryRegistryRoutine (IN PWSTR ValueName, IN ULONG ValueType, IN PVOID ValueData, IN ULONG ValueLength, IN PVOID Context, IN PVOID EntryContext)
Function used by NPF_ReadRegistry() to quesry the registry keys associated woth NPF if the driver is manually installed via the control panel.
VOIDNPF_BindAdapter (OUT PNDIS_STATUS Status, IN NDIS_HANDLE BindContext, IN PNDIS_STRING DeviceName, IN PVOID SystemSpecific1, IN PVOID SystemSpecific2)
Callback for NDIS BindAdapterHandler. Not used by NPF.
VOIDNPF_UnbindAdapter (OUT PNDIS_STATUS Status, IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE UnbindContext)
Callback for NDIS UnbindAdapterHandler.
NTSTATUSNPF_OpenDumpFile (POPEN_INSTANCE Open, PUNICODE_STRING fileName, BOOLEAN append)
Creates the file that will receive the packets when the driver is in dump mode.
NTSTATUSNPF_StartDump (POPEN_INSTANCE Open)
Starts dump to file.
VOIDNPF_DumpThread (PVOID Open)
The dump thread.
NTSTATUSNPF_SaveCurrentBuffer (POPEN_INSTANCE Open)
Saves the content of the packet buffer to the file associated with current instance.
VOIDNPF_WriteDumpFile (PFILE_OBJECT FileObject, PLARGE_INTEGER Offset, ULONG Length, PMDL Mdl, PIO_STATUS_BLOCK IoStatusBlock)
Writes a block of packets on the dump file.
NTSTATUSNPF_CloseDumpFile (POPEN_INSTANCE Open)
Closes the dump file associated with an instance of the driver.
VOIDNPF_CloseOpenInstance (POPEN_INSTANCE pOpen)
BOOLEANNPF_StartUsingBinding (IN POPEN_INSTANCE pOpen)
VOIDNPF_StopUsingBinding (IN POPEN_INSTANCE pOpen)
VOIDNPF_CloseBinding (IN POPEN_INSTANCE pOpen)
NTSTATUSNPF_GetDeviceMTU (IN POPEN_INSTANCE pOpen, IN PIRP pIrp, OUT PUINT pMtu)
UINTGetBuffOccupation (POPEN_INSTANCE Open)
Returns the amount of bytes present in the packet buffer.

Variables

ULONGNCpu