As suggested by multipleinterfaces in http://ask.wireshark.org/questions/9194/can...
[obnox/wireshark/wip.git] / pcapio.h
1 /* pcapio.h
2  * Declarations of our own routins for writing libpcap files.
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * Derived from code in the Wiretap Library
11  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 /** Returns a FILE * to write to on success, NULL on failure */
29 extern FILE *
30 libpcap_fdopen(int fd, int *err);
31
32 /** Write the file header to a dump file.
33    Returns TRUE on success, FALSE on failure.
34    Sets "*err" to an error code, or 0 for a short write, on failure*/
35 extern gboolean
36 libpcap_write_file_header(FILE *fp, int linktype, int snaplen, long *bytes_written, int *err);
37
38 /** Write a record for a packet to a dump file.
39    Returns TRUE on success, FALSE on failure. */
40 extern gboolean
41 libpcap_write_packet(FILE *fp, const struct pcap_pkthdr *phdr, const u_char *pd,
42     long *bytes_written, int *err);
43
44 /** Write a section header block (SHB)
45  *
46  */
47 extern gboolean
48 libpcap_write_session_header_block(FILE *fp,             /**< File pointer */
49                                    const char *comment,  /**< Comment on the section, Optinon 1 opt_comment
50                                                           * A UTF-8 string containing a comment that is associated to the current block.
51                                                           */
52                                    const char *hw,       /**< HW, Optinon 2 shb_hardware 
53                                                           * An UTF-8 string containing the description of the hardware  used to create this section.
54                                                           */
55                                    const char *os,       /**< Operating system name, Optinon 3 shb_os 
56                                                           * An UTF-8 string containing the name of the operating system used to create this section.
57                                                           */
58                                    const char *appname,  /**< Application name, Optinon 4 shb_userappl 
59                                                           * An UTF-8 string containing the name of the application  used to create this section.
60                                                           */
61                                    guint64 section_length,
62                                    long *bytes_written,
63                                    int *err);
64
65 extern gboolean
66 libpcap_write_interface_description_block(FILE *fp,
67                                           const char *comment,  /* OPT_COMMENT           1 */
68                                           const char *name,     /* IDB_NAME                          2 */
69                                           const char *descr,    /* IDB_DESCRIPTION       3 */
70                                           const char *filter,   /* IDB_FILTER           11 */
71                                           const char *os,       /* IDB_OS               12 */
72                                           int link_type,
73                                           int snap_len,
74                                           long *bytes_written,
75                                           guint64 if_speed,     /* IDB_IF_SPEED          8 */
76                                           guint8 tsresol,       /* IDB_TSRESOL           9 */
77                                           int *err);
78
79 extern gboolean
80 libpcap_write_interface_statistics_block(FILE *fp,
81                                          guint32 interface_id,
82                                          pcap_t *pd,
83                                          long *bytes_written,
84                                          const char *comment,   /* OPT_COMMENT           1 */
85                                          guint64 isb_starttime, /* ISB_STARTTIME         2 */
86                                          guint64 isb_endtime,   /* ISB_ENDTIME           3 */
87                                          int *err);
88
89 extern gboolean
90 libpcap_write_enhanced_packet_block(FILE *fp,
91                                     const struct pcap_pkthdr *phdr,
92                                     guint32 interface_id,
93                                     const u_char *pd,
94                                     long *bytes_written,
95                                     int *err);
96
97 extern gboolean
98 libpcap_dump_flush(FILE *pd, int *err);
99
100 extern gboolean
101 libpcap_dump_close(FILE *pd, int *err);