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

# Pcap-win32.c File Reference

`#include <pcap-int.h>`
`#include <packet32.h>`
`#include <Ntddndis.h>`

Go to the source code of this file.

## Defines
#define | PcapBufSize 256000
#define | SIZE_BUF 1000000
#define | bhp ((struct bpf_hdr *)bp)
## Functions
int | wsockinit ()
int | pcap_stats (pcap_t *p, struct pcap_stat *ps)
| Discouraged, Use pcap_stats_ex() instead. Returns statistics on current capture.
int | pcap_read (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
pcap_t * | pcap_open_live (const char *device, int snaplen, int promisc, int to_ms, char *ebuf)
int | pcap_setfilter (pcap_t *p, struct bpf_program *fp)
| Associates a filter to a capture.
int | pcap_setmode (pcap_t *p, int mode)
| Win32 Specific. Sets the working mode of the interface p to mode.
int | pcap_sendpacket (pcap_t *p, u_char *buf, int size)
| Win32 Specific. Sends a raw packet.
int | pcap_setbuff (pcap_t *p, int dim)
| Win32 Specific. Sets the size of the kernel buffer associated with an adapter.
int | pcap_setmintocopy (pcap_t *p, int size)
| Win32 Specific. Sets the minumum amount of data received by the kernel in a single call.
int | pcap_set_datalink_platform (pcap_t *p, int dlt)
## Variables
const char | rcsid []

## Define Documentation

#define bhp ((struct bpf_hdr *)bp)

#define PcapBufSize 256000

| Definition at line 39 of file Pcap-win32.c. Referenced by pcap_open_live().

#define SIZE_BUF 1000000

| Definition at line 40 of file Pcap-win32.c.

## Function Documentation

pcap_t* pcap_open_live | ( | const char * | device,
|  | int | snaplen,
|  | int | promisc,
|  | int | to_ms,
|  | char * | ebuf
| ) |

| Definition at line 144 of file Pcap-win32.c. References host, NetType::LinkType, PacketAllocatePacket(), PacketCloseAdapter(), PacketGetNetType(), PacketInitPacket(), PacketOpenAdapter(), PacketSetBuff(), PacketSetHwFilter(), PacketSetMinToCopy(), PacketSetReadTimeout(), PCAP_BUF_SIZE, PCAP_OPENFLAG_PROMISCUOUS, pcap_opensource_remote(), pcap_parsesrcstr(), PCAP_SRC_IFREMOTE, pcap_strerror(), pcap_t, pcap_win32strerror(), PcapBufSize, port, snprintf, and wsockinit(). Referenced by add_or_find_if(), main(), and pcap_open().

int pcap_read | ( | pcap_t * | p,
|  | int | cnt,
|  | pcap_handler | callback,
|  | u_char * | user
| ) |

| Definition at line 79 of file Pcap-win32.c. References n, PacketReceivePacket(), pcap_read_remote(), pcap_startcapture_remote(), and snprintf. Referenced by pcap_dispatch(), pcap_loop(), and pcap_next_ex().

int pcap_sendpacket | ( | pcap_t * | p,
|  | u_char * | buf,
|  | int | size
| ) |

| Win32 Specific. Sends a raw packet. This function allows to send a raw packet to the network. p is the interface that will be used to send the packet, buf contains the data of the packet to send (including the various protocol headers), size is the dimension of the buffer pointed by buf, i.e. the size of the packet to send. The MAC CRC doesn't need to be included, because it is transparently calculated and added by the network interface driver. The return value is 0 if the packet is succesfully sent, -1 otherwise. See also: pcap_open_live() Definition at line 337 of file Pcap-win32.c. References PacketAllocatePacket(), PacketFreePacket(), PacketInitPacket(), PacketSendPacket(), and snprintf.

int pcap_set_datalink_platform | ( | pcap_t * | p,
|  | int | dlt
| ) |

| Definition at line 394 of file Pcap-win32.c. Referenced by pcap_set_datalink().

int pcap_setbuff | ( | pcap_t * | p,
|  | int | dim
| ) |

| Win32 Specific. Sets the size of the kernel buffer associated with an adapter. dim specifies the size of the buffer in bytes. The return value is 0 when the call succeeds, -1 otherwise. If an old buffer was already created with a previous call to pcap_setbuff(), it is deleted and its content is discarded. pcap_open_live() creates a 1 MByte buffer by default. See also: pcap_open_live(), pcap_loop(), pcap_dispatch() Definition at line 359 of file Pcap-win32.c. References PacketSetBuff(), and snprintf.

int pcap_setfilter | ( | pcap_t * | p,
|  | struct bpf_program * | fp
| ) |

| Associates a filter to a capture. pcap_setfilter() is used to specify a filter program. fp is a pointer to a bpf_program struct, usually the result of a call to pcap_compile(). -1 is returned on failure, in which case pcap_geterr() may be used to display the error text; 0 is returned on success. See also: pcap_compile(), pcap_compile_nopcap() Definition at line 292 of file Pcap-win32.c. References PacketSetBpf(), pcap_setfilter_remote(), pcap_win32strerror(), and snprintf. Referenced by daemon_unpackapplyfilter(), and main().

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

| Win32 Specific. Sets the minumum amount of data received by the kernel in a single call. pcap_setmintocopy() changes the minimum amount of data in the kernel buffer that causes a read from the application to return (unless the timeout expires). If the value of size is large, the kernel is forced to wait the arrival of several packets before copying the data to the user. This guarantees a low number of system calls, i.e. low processor usage, and is a good setting for applications like packet-sniffers and protocol analyzers. Vice versa, in presence of a small value for this variable, the kernel will copy the packets as soon as the application is ready to receive them. This is useful for real time applications that need the best responsiveness from the kernel. See also: pcap_open_live(), pcap_loop(), pcap_dispatch() Definition at line 377 of file Pcap-win32.c. References PacketSetMinToCopy(), and snprintf.

int pcap_setmode | ( | pcap_t * | p,
|  | int | mode
| ) |

| Win32 Specific. Sets the working mode of the interface p to mode. Valid values for mode are MODE_CAPT (default capture mode) and MODE_STAT (statistical mode). See the tutorial "Gathering Statistics on the network traffic " for details about statistical mode. Definition at line 318 of file Pcap-win32.c. References PacketSetMode(), and snprintf.

int pcap_stats | ( | pcap_t * | p,
|  | struct pcap_stat * | ps
| ) |

| Discouraged, Use pcap_stats_ex() instead. Returns statistics on current capture. pcap_stats() returns 0 and fills in a pcap_stat struct. The values represent packet statistics from the start of the run to the time of the call. If there is an error or the underlying packet capture doesn't support packet statistics, -1 is returned and the error text can be obtained with pcap_perror() or pcap_geterr(). pcap_stats() 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_ex(), pcap_open_live() Definition at line 60 of file Pcap-win32.c. References PacketGetStats(), pcap_stats_remote(), pcap_win32strerror(), and snprintf. Referenced by daemon_getstats(), and daemon_serviceloop().

int wsockinit | ( |  | ) |

| Definition at line 44 of file Pcap-win32.c. Referenced by pcap_open_live().

## Variable Documentation

const char rcsid[]`[static]`

| Initial value:
        "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.6 2003/01/23 09:40:09 guy Exp $ (LBL)"
Definition at line 23 of file Pcap-win32.c.

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