[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


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


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.

Related Information

The pcap_dispatch (pcap_dispatch Subroutine) subroutine, pcap_dump (pcap_dump Subroutine) subroutine, pcap_dump_close (pcap_dump_close Subroutine) subroutine, pcap_dump_open (pcap_dump_open Subroutine) subroutine, pcap_loop (pcap_loop Subroutine) subroutine, pcap_open_live (pcap_open_live Subroutine) subroutine, pcap_open_offline (pcap_open_offline Subroutine) subroutine.

The tcpdump command.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]