Main Page Modules Data Structures File List Data Fields Globals Related Pages

# Win32-Extensions.h File Reference

Go to the source code of this file.

## Data Structures
struct | pcap_send_queue
| A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit(). More...
## Defines
#define | BPF_MEM_EX_IMM 0xc0
#define | BPF_MEM_EX_IND 0xe0
#define | BPF_MEM_EX 0xc0
#define | BPF_TME 0x08
#define | BPF_LOOKUP 0x90
#define | BPF_EXECUTE 0xa0
#define | BPF_INIT 0xb0
#define | BPF_VALIDATE 0xc0
#define | BPF_SET_ACTIVE 0xd0
#define | BPF_RESET 0xe0
#define | BPF_SET_MEMORY 0x80
#define | BPF_GET_REGISTER_VALUE 0x70
#define | BPF_SET_REGISTER_VALUE 0x60
#define | BPF_SET_WORKING 0x50
#define | BPF_SET_ACTIVE_READ 0x40
#define | BPF_SET_AUTODELETION 0x30
#define | BPF_SEPARATION 0xff
## Typedefs
typedef pcap_send_queue | pcap_send_queue
## Functions
pcap_send_queue * | pcap_sendqueue_alloc (u_int memsize)
| Win32 Specific. Allocate a send queue.
void | pcap_sendqueue_destroy (pcap_send_queue *queue)
| Win32 Specific. Destroy a send queue.
int | pcap_sendqueue_queue (pcap_send_queue *queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data)
| Win32 Specific. Add a packet to a send queue.
u_int | pcap_sendqueue_transmit (pcap_t *p, pcap_send_queue *queue, int sync)
| Win32 Specific. Sends a queue of raw packets to the network.
HANDLE | pcap_getevent (pcap_t *p)
| Win32 Specific. Returns the handle of the event associated with the interface p.
pcap_stat * | pcap_stats_ex (pcap_t *p)
int | pcap_setuserbuffer (pcap_t *p, int size)
int | pcap_live_dump (pcap_t *p, char *filename, int maxsize, int maxpacks)
| Win32 Specific. Saves a capture to file.
int | pcap_live_dump_ended (pcap_t *p, int sync)
| Win32 Specific. Returns the status of the kernel dump process, i.e. tells if one of the limits defined with pcap_live_dump() has been reached.

## Define Documentation

#define BPF_EXECUTE 0xa0

| Definition at line 43 of file Win32-Extensions.h.

#define BPF_GET_REGISTER_VALUE 0x70

| Definition at line 49 of file Win32-Extensions.h.

#define BPF_INIT 0xb0

| Definition at line 44 of file Win32-Extensions.h.

#define BPF_LOOKUP 0x90

| Definition at line 42 of file Win32-Extensions.h.

#define BPF_MEM_EX 0xc0

| Definition at line 39 of file Win32-Extensions.h.

#define BPF_MEM_EX_IMM 0xc0

| Definition at line 35 of file Win32-Extensions.h.

#define BPF_MEM_EX_IND 0xe0

| Definition at line 36 of file Win32-Extensions.h.

#define BPF_RESET 0xe0

| Definition at line 47 of file Win32-Extensions.h.

#define BPF_SEPARATION 0xff

| Definition at line 54 of file Win32-Extensions.h. Referenced by NPF_IoControl().

#define BPF_SET_ACTIVE 0xd0

| Definition at line 46 of file Win32-Extensions.h.

#define BPF_SET_ACTIVE_READ 0x40

| Definition at line 52 of file Win32-Extensions.h.

#define BPF_SET_AUTODELETION 0x30

| Definition at line 53 of file Win32-Extensions.h.

#define BPF_SET_MEMORY 0x80

| Definition at line 48 of file Win32-Extensions.h.

#define BPF_SET_REGISTER_VALUE 0x60

| Definition at line 50 of file Win32-Extensions.h.

#define BPF_SET_WORKING 0x50

| Definition at line 51 of file Win32-Extensions.h.

#define BPF_TME 0x08

| Definition at line 40 of file Win32-Extensions.h.

#define BPF_VALIDATE 0xc0

| Definition at line 45 of file Win32-Extensions.h.

## Typedef Documentation

typedef struct pcap_send_queue pcap_send_queue

| Definition at line 33 of file Win32-Extensions.h.

## Function Documentation

HANDLE pcap_getevent | ( | pcap_t * | p | ) |

| Win32 Specific. Returns the handle of the event associated with the interface p. This event can be passed to functions like WaitForSingleObject() or WaitForMultipleObjects() to wait until the driver's buffer contains some data without performing a read. See also: pcap_open_live() Definition at line 31 of file Win32-Extensions.c. References PacketGetReadEvent().

int pcap_live_dump | ( | pcap_t * | p,
|  | char * | filename,
|  | int | maxsize,
|  | int | maxpacks
| ) |

| Win32 Specific. Saves a capture to file. pcap_live_dump() dumps the network traffic from an interface to a file. Using this function the dump is performed at kernel level, therefore it is more efficient than using pcap_dump(). The parameters of this function are an interface descriptor (obtained with pcap_open_live()), a string with the name of the dump file, the maximum size of the file (in bytes) and the maximum number of packets that the file will contain. Setting maxsize or maxpacks to 0 means no limit. When maxsize or maxpacks are reached, the dump ends. pcap_live_dump() is non-blocking, threfore it returns immediately. pcap_live_dump_ended() can be used to check the status of the dump process or to wait until it is finished. pcap_close() can instead be used to end the dump process. Note that when one of the two limits is reached, the dump is stopped, but the file remains opened. In order to correctly flush the data and put the file in a consistent state, the adapter must be closed with pcap_close(). See also: pcap_live_dump_ended(), pcap_open_live(), pcap_close(), pcap_dump_open(), pcap_dump() Definition at line 298 of file Win32-Extensions.c. References PacketSetDumpLimits(), PacketSetDumpName(), and PacketSetMode().

int pcap_live_dump_ended | ( | pcap_t * | p,
|  | int | sync
| ) |

| Win32 Specific. Returns the status of the kernel dump process, i.e. tells if one of the limits defined with pcap_live_dump() has been reached. pcap_live_dump_ended() informs the user about the limits that were set with a previous call to pcap_live_dump() on the interface pointed by p: if the return value is nonzero, one of the limits has been reched and the dump process is currently stopped. If sync is nonzero, the function blocks until the dump is finished, otherwise it returns immediately. Warning: if the dump process has no limits (i.e. if the maxsize and maxpacks arguments of pcap_live_dump() were both 0), the dump process will never stop, therefore setting sync to TRUE will block the application on this call forever. See also: pcap_live_dump() Definition at line 329 of file Win32-Extensions.c. References PacketIsDumpEnded().

pcap_send_queue* pcap_sendqueue_alloc | ( | u_int | memsize | ) |

| Win32 Specific. Allocate a send queue. This function allocates a send queue, i.e. a buffer containing a set of raw packets that will be transimtted on the network with pcap_sendqueue_transmit(). memsize is the size, in bytes, of the queue, therefore it determines the maximum amount of data that the queue will contain. Use pcap_sendqueue_queue() to insert packets in the queue. See also: pcap_sendqueue_queue(), pcap_sendqueue_transmit(), pcap_sendqueue_destroy() Definition at line 69 of file Win32-Extensions.c. References pcap_send_queue::buffer, pcap_send_queue::len, and pcap_send_queue::maxlen.

void pcap_sendqueue_destroy | ( | pcap_send_queue * | queue | ) |

| Win32 Specific. Destroy a send queue. Deletes a send queue and frees all the memory associated with it. See also: pcap_sendqueue_alloc(), pcap_sendqueue_queue(), pcap_sendqueue_transmit() Definition at line 94 of file Win32-Extensions.c. References pcap_send_queue::buffer.

int pcap_sendqueue_queue | ( | pcap_send_queue * | queue,
|  | const struct pcap_pkthdr * | pkt_header,
|  | const u_char * | pkt_data
| ) |

| Win32 Specific. Add a packet to a send queue. pcap_sendqueue_queue() adds a packet at the end of the send queue pointed by the queue parameter. pkt_header points to a pcap_pkthdr structure with the timestamp and the length of the packet, pkt_data points to a buffer with the data of the packet. The pcap_pkthdr structure is the same used by WinPcap and libpcap to store the packets in a file, therefore sending a capture file is straightforward. 'Raw packet' means that the sending application will have to include the protocol headers, since every packet is sent to the network 'as is'. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface. See also: pcap_sendqueue_alloc(), pcap_sendqueue_transmit(), pcap_sendqueue_destroy() Definition at line 101 of file Win32-Extensions.c. References pcap_pkthdr::caplen, pcap_pkthdr::len, and pcap_send_queue::len.

u_int pcap_sendqueue_transmit | ( | pcap_t * | p,
|  | pcap_send_queue * | queue,
|  | int | sync
| ) |

| Win32 Specific. Sends a queue of raw packets to the network. This function transmits the content of a queue to the wire. p is a pointer to the adapter on which the packets will be sent, queue points to a pcap_send_queue structure containing the packets to send (see pcap_sendqueue_alloc() and pcap_sendqueue_queue()), sync determines if the send operation must be synchronized: if it is non-zero, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible. The return value is the amount of bytes actually sent. If it is smaller than the size parameter, an error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send queue. Note: Using this function is more efficient than issuing a series of pcap_sendpacket(), because the packets are buffered in the kernel driver, so the number of context switches is reduced. Therefore, expect a better throughput when using pcap_sendqueue_transmit. When Sync is set to TRUE, the packets are synchronized in the kernel with a high precision timestamp. This requires a non-negligible amount of CPU, but allows normally to send the packets with a precision of some microseconds (depending on the accuracy of the performance counter of the machine). Such a precision cannot be reached sending the packets with pcap_sendpacket(). See also: pcap_sendqueue_alloc(), pcap_sendqueue_queue(), pcap_sendqueue_destroy() Definition at line 120 of file Win32-Extensions.c. References pcap_send_queue::buffer, pcap_send_queue::len, PacketSendPackets(), and snprintf.

int pcap_setuserbuffer | ( | pcap_t * | p,
|  | int | size
| ) |

| Definition at line 261 of file Win32-Extensions.c. References PacketInitPacket(), and size.

struct pcap_stat* pcap_stats_ex | ( | pcap_t * | p | ) |

| Definition at line 51 of file Win32-Extensions.c. References PacketGetStatsEx(), pcap_stats_ex(), pcap_stats_ex_remote(), pcap_t, pcap_win32strerror(), and snprintf.

documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.