2006-03-04 22:33:04 +00:00
|
|
|
/* pcapio.h
|
|
|
|
* Declarations of our own routins for writing libpcap files.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2006-03-04 22:33:04 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* Derived from code in the Wiretap Library
|
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2012-02-14 17:07:52 +00:00
|
|
|
/** Returns a FILE * to write to on success, NULL on failure */
|
2006-03-04 22:33:04 +00:00
|
|
|
extern FILE *
|
2009-04-26 15:51:25 +00:00
|
|
|
libpcap_fdopen(int fd, int *err);
|
|
|
|
|
2012-02-14 17:07:52 +00:00
|
|
|
/** Write the file header to a dump file.
|
2009-04-26 15:51:25 +00:00
|
|
|
Returns TRUE on success, FALSE on failure.
|
|
|
|
Sets "*err" to an error code, or 0 for a short write, on failure*/
|
|
|
|
extern gboolean
|
2012-03-10 00:24:42 +00:00
|
|
|
libpcap_write_file_header(FILE *fp, int linktype, int snaplen, gboolean ts_nsecs, long *bytes_written, int *err);
|
2006-03-04 22:33:04 +00:00
|
|
|
|
2012-02-14 17:07:52 +00:00
|
|
|
/** Write a record for a packet to a dump file.
|
2006-03-04 22:33:04 +00:00
|
|
|
Returns TRUE on success, FALSE on failure. */
|
|
|
|
extern gboolean
|
|
|
|
libpcap_write_packet(FILE *fp, const struct pcap_pkthdr *phdr, const u_char *pd,
|
|
|
|
long *bytes_written, int *err);
|
|
|
|
|
2012-02-14 17:07:52 +00:00
|
|
|
/** Write a section header block (SHB)
|
|
|
|
*
|
|
|
|
*/
|
2009-04-26 18:40:40 +00:00
|
|
|
extern gboolean
|
2012-02-14 17:07:52 +00:00
|
|
|
libpcap_write_session_header_block(FILE *fp, /**< File pointer */
|
|
|
|
const char *comment, /**< Comment on the section, Optinon 1 opt_comment
|
|
|
|
* A UTF-8 string containing a comment that is associated to the current block.
|
|
|
|
*/
|
2012-03-10 00:24:42 +00:00
|
|
|
const char *hw, /**< HW, Optinon 2 shb_hardware
|
2012-02-14 17:07:52 +00:00
|
|
|
* An UTF-8 string containing the description of the hardware used to create this section.
|
|
|
|
*/
|
2012-03-10 00:24:42 +00:00
|
|
|
const char *os, /**< Operating system name, Optinon 3 shb_os
|
2012-02-14 17:07:52 +00:00
|
|
|
* An UTF-8 string containing the name of the operating system used to create this section.
|
|
|
|
*/
|
2012-03-10 00:24:42 +00:00
|
|
|
const char *appname, /**< Application name, Optinon 4 shb_userappl
|
2012-02-14 17:07:52 +00:00
|
|
|
* An UTF-8 string containing the name of the application used to create this section.
|
|
|
|
*/
|
|
|
|
guint64 section_length,
|
2009-04-26 18:40:40 +00:00
|
|
|
long *bytes_written,
|
|
|
|
int *err);
|
|
|
|
|
|
|
|
extern gboolean
|
|
|
|
libpcap_write_interface_description_block(FILE *fp,
|
2012-02-21 15:16:45 +00:00
|
|
|
const char *comment, /* OPT_COMMENT 1 */
|
2012-02-22 14:41:02 +00:00
|
|
|
const char *name, /* IDB_NAME 2 */
|
2012-02-21 15:16:45 +00:00
|
|
|
const char *descr, /* IDB_DESCRIPTION 3 */
|
|
|
|
const char *filter, /* IDB_FILTER 11 */
|
|
|
|
const char *os, /* IDB_OS 12 */
|
2009-04-26 18:40:40 +00:00
|
|
|
int link_type,
|
|
|
|
int snap_len,
|
|
|
|
long *bytes_written,
|
2012-02-21 15:16:45 +00:00
|
|
|
guint64 if_speed, /* IDB_IF_SPEED 8 */
|
|
|
|
guint8 tsresol, /* IDB_TSRESOL 9 */
|
2009-04-26 18:40:40 +00:00
|
|
|
int *err);
|
|
|
|
|
|
|
|
extern gboolean
|
|
|
|
libpcap_write_interface_statistics_block(FILE *fp,
|
|
|
|
guint32 interface_id,
|
|
|
|
pcap_t *pd,
|
|
|
|
long *bytes_written,
|
2012-02-22 10:01:16 +00:00
|
|
|
const char *comment, /* OPT_COMMENT 1 */
|
|
|
|
guint64 isb_starttime, /* ISB_STARTTIME 2 */
|
|
|
|
guint64 isb_endtime, /* ISB_ENDTIME 3 */
|
2009-04-26 18:40:40 +00:00
|
|
|
int *err);
|
|
|
|
|
|
|
|
extern gboolean
|
|
|
|
libpcap_write_enhanced_packet_block(FILE *fp,
|
2009-04-26 19:24:36 +00:00
|
|
|
const struct pcap_pkthdr *phdr,
|
2009-04-26 18:40:40 +00:00
|
|
|
guint32 interface_id,
|
2012-03-10 00:24:42 +00:00
|
|
|
guint ts_mul,
|
2009-04-26 19:24:36 +00:00
|
|
|
const u_char *pd,
|
2009-04-26 18:40:40 +00:00
|
|
|
long *bytes_written,
|
|
|
|
int *err);
|
|
|
|
|
2006-03-04 22:33:04 +00:00
|
|
|
extern gboolean
|
|
|
|
libpcap_dump_flush(FILE *pd, int *err);
|
|
|
|
|
|
|
|
extern gboolean
|
|
|
|
libpcap_dump_close(FILE *pd, int *err);
|