pcap_next Subroutine

Purpose

Obtains the next packet from the packet capture device.

Library

pcap Library (libpcap.a)

Syntax

#include <pcap.h>

u_char *pcap_next(pcap_t * p, struct pcap_pkthdr * h);

Description

The pcap_next subroutine returns a u_char pointer to the next packet from the packet capture device. The packet capture device can be a network device or a savefile that contains packet capture data. The data has the same format as used by tcpdump.

Parameters

Item Description
h Points to the packet header of the packet that is returned. This is filled in upon return by this routine.
p Points to the packet capture descriptor to use as returned by the pcap_open_live or the pcap_open_offline subroutine.

Return Values

Upon successful completion, the pcap_next subroutine returns a pointer to a buffer containing the next packet and fills in the h, which points to the packet header of the returned packet. If the pcap_next subroutine is unsuccessful, Null is returned.