pcap_dump_open Subroutine

Purpose

Opens or creates a file for writing packet capture data.

Library

pcap Library (libpcap.a)

Syntax

#include <pcap.h>

pcap_dumper_t *pcap_dump_open(pcap_t * p, char * fname);

Description

The pcap_dump_open subroutine opens or creates the packet capture data file, known as the savefile. This action is specified through the fname parameter. The subroutine then writes the required packet capture file header to the file. The pcap_dump subroutine can then be called to write the packet capture data associated with the packet capture descriptor, p, into this file. The pcap_dump_open subroutine must be called before calling the pcap_dump subroutine.

Parameters

Item Description
fname Specifies the name of the file to open. A "-" indicates that standard output should be used instead of a file.
p Specifies a packet capture descriptor returned by the pcap_open_offline or the pcap_open_live subroutine.

Return Values

Upon successful completion, the pcap_dump_open subroutine returns a pointer to a the file that was opened or created. This pointer is a pointer to a pcap_dumper_t, which is synonymous with FILE *. See the pcap_dump (pcap_dump Subroutine), pcap_dispatch (pcap_dispatch Subroutine), or the pcap_loop (pcap_loop Subroutine) subroutine for an example of how to use pcap_dumper_t. If the pcap_dump_open subroutine is unsuccessful, Null is returned. Use the pcap_geterr subroutine to obtain the specific error text.