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_stat_size)
| Win32 Specific. Returns statistics on current capture.
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.
int | pcap_offline_filter (struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data)
| Win32 Specific. It returns if a given filter applies to an offline packet.

## Define Documentation

#define BPF_EXECUTE 0xa0

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

#define BPF_GET_REGISTER_VALUE 0x70

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

#define BPF_INIT 0xb0

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

#define BPF_LOOKUP 0x90

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

#define BPF_MEM_EX 0xc0

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

#define BPF_MEM_EX_IMM 0xc0

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

#define BPF_MEM_EX_IND 0xe0

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

#define BPF_RESET 0xe0

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

#define BPF_SEPARATION 0xff

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

#define BPF_SET_ACTIVE 0xd0

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

#define BPF_SET_ACTIVE_READ 0x40

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

#define BPF_SET_AUTODELETION 0x30

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

#define BPF_SET_MEMORY 0x80

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

#define BPF_SET_REGISTER_VALUE 0x60

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

#define BPF_SET_WORKING 0x50

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

#define BPF_TME 0x08

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

#define BPF_VALIDATE 0xc0

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

## Typedef Documentation

typedef struct pcap_send_queue pcap_send_queue

| Definition at line 44 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. We disourage the use of this function because it is not portable. See also: pcap_open_live() Definition at line 42 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 311 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 342 of file Win32-Extensions.c. References PacketIsDumpEnded().

int pcap_offline_filter | ( | struct bpf_program * | prog,
|  | const struct pcap_pkthdr * | header,
|  | const u_char * | pkt_data
| ) |

  | Win32 Specific. It returns if a given filter applies to an offline packet. This function is used to apply a filter to a packet that is currently in memory. This process does not need to open an adapter; we need just to create the proper filter (by settings parameters like the snapshot length, or the link-layer type) by means of the pcap_compile_nopcap(). The current API of libpcap does not allow to receive a packet and to filter the packet after it has been received. However, this can be useful in case you want to filter packets in the application, instead of into the receiving process. This function allows you to do the job. Parameters:
  prog: | bpf program (created with the pcap_compile_nopcap() )
  header: | header of the packet that has to be filtered
  pkt_data: | buffer containing the packet, in network-byte order.
Returns: the length of the bytes that are currently available into the packet if the packet satisfies the filter, 0 otherwise. Definition at line 355 of file Win32-Extensions.c. References bpf_program::bf_insns, pcap_pkthdr::caplen, and pcap_pkthdr::len.

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 82 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 107 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 114 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 133 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 274 of file Win32-Extensions.c. References PacketInitPacket(), and size.

struct pcap_stat* pcap_stats_ex | ( | pcap_t * | p,
|  | int * | pcap_stat_size
| ) |

  | Win32 Specific. Returns statistics on current capture. pcap_stats_ex() extends the pcap_stats() allowing to return more statistical parameters than the old call. One of the advantages of this new call is that the pcap_stat structure is not allocated by the user; instead, it is returned back by the system. This allow to extend the pcap_stat structure without affecting backward compatibility on older applications. These will simply check at the values of the members at the beginning of the structure, while only newest applications are able to read new statistical values, which are appended in tail. To be sure not to read a piece of mamory which has not been allocated by the system, the variable pcap_stat_size will return back the size of the structure pcap_stat allocated by the system. Parameters:
  p: | pointer to the pcap_t currently in use.
  pcap_stat_size: | pointer to an integer that will contain (when the function returns back) the size of the structure pcap_stat as it has been allocated by the system.
Returns: : a pointer to a pcap_stat structure, that will contain the statistics related to the current device. The return value is NULL in case of errors, and the error text can be obtained with pcap_perror() or pcap_geterr(). Warning: pcap_stats_ex() is supported only on live captures, not on "savefiles"; no statistics are stored in "savefiles", so no statistics are available when reading from a "savefile". See also: pcap_stats() Definition at line 62 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.