[Automatic update for 2015-10-25]
[metze/wireshark/wip.git] / pcapio.h
1 /* pcapio.h
2  * Declarations of our own routines for writing libpcap files.
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * Derived from code in the Wiretap Library
9  * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 /* Writing pcap files */
27
28 /** Write the file header to a dump file.
29    Returns TRUE on success, FALSE on failure.
30    Sets "*err" to an error code, or 0 for a short write, on failure*/
31 extern gboolean
32 libpcap_write_file_header(FILE* pfile, int linktype, int snaplen,
33                           gboolean ts_nsecs, guint64 *bytes_written, int *err);
34
35 /** Write a record for a packet to a dump file.
36    Returns TRUE on success, FALSE on failure. */
37 extern gboolean
38 libpcap_write_packet(FILE* pfile,
39                      time_t sec, guint32 usec,
40                      guint32 caplen, guint32 len,
41                      const guint8 *pd,
42                      guint64 *bytes_written, int *err);
43
44 /* Writing pcap-ng files */
45
46 /** Write a section header block (SHB)
47  *
48  */
49 extern gboolean
50 pcapng_write_session_header_block(FILE* pfile,  /**< Write information */
51                                   const char *comment,  /**< Comment on the section, Optinon 1 opt_comment
52                                                          * A UTF-8 string containing a comment that is associated to the current block.
53                                                          */
54                                   const char *hw,       /**< HW, Optinon 2 shb_hardware
55                                                          * An UTF-8 string containing the description of the hardware  used to create this section.
56                                                          */
57                                   const char *os,       /**< Operating system name, Optinon 3 shb_os
58                                                          * An UTF-8 string containing the name of the operating system used to create this section.
59                                                          */
60                                   const char *appname,  /**< Application name, Optinon 4 shb_userappl
61                                                          * An UTF-8 string containing the name of the application  used to create this section.
62                                                          */
63                                   guint64 section_length, /**< Length of section */
64                                   guint64 *bytes_written, /**< Number of written bytes */
65                                   int *err /**< Error type */
66                                   );
67
68 extern gboolean
69 pcapng_write_interface_description_block(FILE* pfile,
70                                          const char *comment,  /* OPT_COMMENT           1 */
71                                          const char *name,     /* IDB_NAME              2 */
72                                          const char *descr,    /* IDB_DESCRIPTION       3 */
73                                          const char *filter,   /* IDB_FILTER           11 */
74                                          const char *os,       /* IDB_OS               12 */
75                                          int link_type,
76                                          int snap_len,
77                                          guint64 *bytes_written,
78                                          guint64 if_speed,     /* IDB_IF_SPEED          8 */
79                                          guint8 tsresol,       /* IDB_TSRESOL           9 */
80                                          int *err);
81
82 extern gboolean
83 pcapng_write_interface_statistics_block(FILE* pfile,
84                                         guint32 interface_id,
85                                         guint64 *bytes_written,
86                                         const char *comment,   /* OPT_COMMENT           1 */
87                                         guint64 isb_starttime, /* ISB_STARTTIME         2 */
88                                         guint64 isb_endtime,   /* ISB_ENDTIME           3 */
89                                         guint64 isb_ifrecv,    /* ISB_IFRECV            4 */
90                                         guint64 isb_ifdrop,    /* ISB_IFDROP            5 */
91                                         int *err);
92
93 extern gboolean
94 pcapng_write_enhanced_packet_block(FILE* pfile,
95                                    const char *comment,
96                                    time_t sec, guint32 usec,
97                                    guint32 caplen, guint32 len,
98                                    guint32 interface_id,
99                                    guint ts_mul,
100                                    const guint8 *pd,
101                                    guint32 flags,
102                                    guint64 *bytes_written,
103                                    int *err);
104
105 /*
106  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
107  *
108  * Local variables:
109  * c-basic-offset: 4
110  * tab-width: 8
111  * indent-tabs-mode: nil
112  * End:
113  *
114  * vi: set shiftwidth=4 tabstop=8 expandtab:
115  * :indentSize=4:tabSize=8:noTabs=true:
116  */