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.

## Data Structures
struct | bpf_hdr
| Packet header. More...
## Defines
#define | PcapBufSize 256000
#define | SIZE_BUF 1000000
#define | SWAPS(_X) ((_X & 0xff) << 8) | (_X >> 8)
#define | bhp ((struct bpf_hdr *)bp)
## Functions
int | pcap_setfilter_win32_npf (pcap_t *, struct bpf_program *)
int | pcap_setfilter_win32_dag (pcap_t *, struct bpf_program *)
int | pcap_getnonblock_win32 (pcap_t *, char *)
int | pcap_setnonblock_win32 (pcap_t *, int, char *)
int | wsockinit ()
int | pcap_stats_win32 (pcap_t *p, struct pcap_stat *ps)
int | pcap_read_win32_npf (pcap_t *p, int cnt, pcap_handler callback, u_char *user)
void | pcap_close_win32 (pcap_t *p)
pcap_t * | pcap_open_live (const char *device, int snaplen, int promisc, int to_ms, char *ebuf)
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.
## Variables
const char rcsid[] | _U_

## Define Documentation

#define bhp ((struct bpf_hdr *)bp)

#define PcapBufSize 256000

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

#define SIZE_BUF 1000000

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

#define SWAPS | ( | _X |  | ) | ((_X & 0xff) << 8) | (_X >> 8)

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

## Function Documentation

void pcap_close_win32 | ( | pcap_t * | p | ) | `[static]`

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

int pcap_getnonblock_win32 | ( | pcap_t * | ,
|  | char * |
| ) | `[static]`

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

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

| Definition at line 406 of file Pcap-win32.c. References host, INFO_FLAG_DAG_CARD, NetType::LinkType, NdisMediumCHDLC, NdisMediumNull, NdisMediumPPPSerial, PacketAllocatePacket(), PacketCloseAdapter(), PacketFreePacket(), PacketGetNetType(), PacketInitPacket(), PacketOpenAdapter(), PacketSetBuff(), PacketSetHwFilter(), PacketSetMinToCopy(), PacketSetReadTimeout(), PacketSetSnapLen(), PCAP_BUF_SIZE, pcap_close_win32(), pcap_getnonblock_win32(), PCAP_OPENFLAG_PROMISCUOUS, pcap_opensource_remote(), pcap_parsesrcstr(), pcap_read_win32_npf(), pcap_setfilter_win32_dag(), pcap_setfilter_win32_npf(), pcap_setnonblock_win32(), PCAP_SRC_IFREMOTE, pcap_stats_win32(), pcap_strerror(), pcap_t, pcap_win32strerror(), PcapBufSize, port, snprintf, and wsockinit(). Referenced by pcap_open().

int pcap_read_win32_npf | ( | pcap_t * | p,
|  | int | cnt,
|  | pcap_handler | callback,
|  | u_char * | user
| ) | `[static]`

| Definition at line 109 of file Pcap-win32.c. References n, PacketReceivePacket(), PCAP_SAMP_1_EVERY_N, PCAP_SAMP_FIRST_AFTER_N_MS, snprintf, and pcap_pkthdr::ts. Referenced by pcap_open_live().

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 768 of file Pcap-win32.c. References PacketAllocatePacket(), PacketFreePacket(), PacketInitPacket(), PacketSendPacket(), and snprintf.

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 790 of file Pcap-win32.c. References PacketSetBuff(), and snprintf.

int pcap_setfilter_win32_dag | ( | pcap_t * | ,
|  | struct bpf_program * |
| ) | `[static]`

| Definition at line 688 of file Pcap-win32.c. References pcap_strerror(), and snprintf. Referenced by pcap_open_live().

int pcap_setfilter_win32_npf | ( | pcap_t * | ,
|  | struct bpf_program * |
| ) | `[static]`

| Definition at line 674 of file Pcap-win32.c. References PacketSetBpf(), pcap_win32strerror(), and snprintf. Referenced by pcap_open_live().

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 816 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 749 of file Pcap-win32.c. References PacketSetMode(), and snprintf.

int pcap_setnonblock_win32 | ( | pcap_t * | ,
|  | int | ,
|  | char * |
| ) | `[static]`

| Definition at line 721 of file Pcap-win32.c. References PacketSetReadTimeout(), pcap_win32strerror(), and snprintf. Referenced by pcap_open_live().

int pcap_stats_win32 | ( | pcap_t * | p,
|  | struct pcap_stat * | ps
| ) | `[static]`

| Definition at line 96 of file Pcap-win32.c. References PacketGetStats(), pcap_win32strerror(), and snprintf. Referenced by pcap_open_live().

int wsockinit | ( |  | ) |

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

## Variable Documentation

const char rcsid [] _U_`[static]`

| Initial value:
        "@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.19 2003/12/18 23:32:33 guy Exp $ (LBL)"
Definition at line 34 of file Pcap-win32.c.

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