wtap (opttypes.h): fix no newline at end of file [-Wnewline-eof]
[metze/wireshark/wip.git] / cfile.c
1 /* cfile.c
2  * capture_file GUI-independent manipulation
3  * Vassilii Khachaturov <vassilii@tarunz.org>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #include <config.h>
25
26 #include <glib.h>
27
28 #include <epan/packet.h>
29 #include <wiretap/pcapng.h>
30
31 #include "cfile.h"
32
33 const char *
34 cap_file_get_interface_name(void *data, guint32 interface_id)
35 {
36   capture_file *cf = (capture_file *) data;
37   wtapng_iface_descriptions_t *idb_info;
38   wtap_optionblock_t wtapng_if_descr = NULL;
39   char* interface_name;
40
41   idb_info = wtap_file_get_idb_info(cf->wth);
42
43   if (interface_id < idb_info->interface_data->len)
44     wtapng_if_descr = g_array_index(idb_info->interface_data, wtap_optionblock_t, interface_id);
45
46   g_free(idb_info);
47
48   if (wtapng_if_descr) {
49     wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_NAME, &interface_name);
50     if (interface_name)
51       return interface_name;
52     wtap_optionblock_get_option_string(wtapng_if_descr, OPT_IDB_DESCR, &interface_name);
53     if (interface_name)
54       return interface_name;
55   }
56   return "unknown";
57 }
58
59 void
60 cap_file_init(capture_file *cf)
61 {
62   /* Initialize the capture file struct */
63   memset(cf, 0, sizeof(capture_file));
64   cf->snap            = WTAP_MAX_PACKET_SIZE;
65 }
66
67 /*
68  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
69  *
70  * Local Variables:
71  * c-basic-offset: 2
72  * tab-width: 8
73  * indent-tabs-mode: nil
74  * End:
75  *
76  * ex: set shiftwidth=2 tabstop=8 expandtab:
77  * :indentSize=2:tabSize=8:noTabs=true:
78  */