Coverage Report

Created: 2025-12-27 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/wsutil/application_flavor.c
Line
Count
Source
1
/* application_flavor.c
2
 * Application flavor routines
3
 *
4
 * Wireshark - Network traffic analyzer
5
 * By Gerald Combs <gerald@wireshark.org>
6
 * Copyright 1998 Gerald Combs
7
 *
8
 * SPDX-License-Identifier: GPL-2.0-or-later
9
 */
10
11
#include "config.h"
12
0
#define WS_LOG_DOMAIN LOG_DOMAIN_WSUTIL
13
14
#include "application_flavor.h"
15
#include "path_config.h"
16
17
static enum application_flavor_e application_flavor = APPLICATION_FLAVOR_WIRESHARK;
18
19
void set_application_flavor(enum application_flavor_e flavor)
20
0
{
21
0
    application_flavor = flavor;
22
0
}
23
24
0
const char *application_flavor_name_proper(void) {
25
0
    switch (application_flavor) {
26
0
    case APPLICATION_FLAVOR_WIRESHARK:
27
0
        return "Wireshark";
28
0
    case APPLICATION_FLAVOR_STRATOSHARK:
29
0
        return "Stratoshark";
30
0
    default:
31
0
        ws_assert_not_reached();
32
0
    }
33
0
}
34
35
0
const char *application_flavor_name_lower(void) {
36
0
    switch (application_flavor) {
37
0
    case APPLICATION_FLAVOR_WIRESHARK:
38
0
        return "wireshark";
39
0
    case APPLICATION_FLAVOR_STRATOSHARK:
40
0
        return "stratoshark";
41
0
    default:
42
0
        ws_assert_not_reached();
43
0
    }
44
0
}
45
46
const char* application_configuration_environment_prefix(void)
47
42
{
48
42
    switch (application_flavor) {
49
42
    case APPLICATION_FLAVOR_WIRESHARK:
50
42
        return "WIRESHARK";
51
0
    case APPLICATION_FLAVOR_STRATOSHARK:
52
0
        return "STRATOSHARK";
53
0
    default:
54
0
        ws_assert_not_reached();
55
42
    }
56
42
}
57
58
/*
59
 * File types that can be identified by file extensions.
60
 *
61
 * These are used in file open dialogs to offer choices of extensions
62
 * for which to filter.  Note that the first field can list more than
63
 * one type of file, because, for example, ".cap" is a popular
64
 * extension used by a number of capture file types.
65
 *
66
 * File types that *don't* have a file extension used for them should
67
 * *not* be placed here; if there's nothing to put in the last field
68
 * of the structure, don't put an entry here, not even one with an
69
 * empty string for the extensions list.
70
 *
71
 * All added file types, regardless of extension or lack thereof,
72
 * must also be added open_info_base[] below.
73
 */
74
void application_file_extensions(const struct file_extension_info** file_extensions, unsigned* num_extensions)
75
14
{
76
14
    switch (application_flavor) {
77
14
    case APPLICATION_FLAVOR_WIRESHARK:
78
14
    {
79
14
        static const struct file_extension_info wireshark_file_type_extensions_base[] = {
80
14
                { "Wireshark/tcpdump/... - pcap", true, "pcap;cap;dmp" },
81
14
                { "Wireshark/... - pcapng", true, "pcapng;ntar" },
82
14
                { "Network Monitor, Surveyor, NetScaler", true, "cap" },
83
14
                { "Sun snoop", true, "snoop" },
84
14
                { "InfoVista 5View capture", true, "5vw" },
85
14
                { "Sniffer (DOS)", true, "cap;enc;trc;fdc;syc" },
86
14
                { "Cinco NetXRay, Sniffer (Windows)", true, "cap;caz" },
87
14
                { "Endace ERF capture", true, "erf" },
88
14
                { "EyeSDN USB S0/E1 ISDN trace format", true, "trc" },
89
14
                { "HP-UX nettl trace", true, "trc0;trc1" },
90
14
                { "Viavi Observer", true, "bfr" },
91
14
                { "Colasoft Capsa", true, "cscpkt" },
92
14
                { "Novell LANalyzer", true, "tr1" },
93
14
                { "Tektronix K12xx 32-bit .rf5 format", true, "rf5" },
94
14
                { "Savvius *Peek", true, "pkt;tpc;apc;wpz" },
95
14
                { "Catapult DCT2000 trace (.out format)", true, "out" },
96
14
                { "Micropross mplog", true, "mplog" },
97
14
                { "TamoSoft CommView NCF", true, "ncf" },
98
14
                { "TamoSoft CommView NCFX", true, "ncfx" },
99
14
                { "Symbian OS btsnoop", true, "log" },
100
14
                { "XML files (including Gammu DCT3 traces)", true, "xml" },
101
14
                { "macOS PacketLogger", true, "pklg" },
102
14
                { "Daintree SNA", true, "dcf" },
103
14
                { "IPFIX File Format", true, "pfx;ipfix" },
104
14
                { "Aethra .aps file", true, "aps" },
105
14
                { "MPEG2 transport stream", true, "mp2t;ts;m2ts;mpg" },
106
14
                { "Ixia IxVeriWave .vwr Raw 802.11 Capture", true, "vwr" },
107
14
                { "CAM Inspector file", true, "camins" },
108
14
                { "BLF file", true, "blf" },
109
14
                { "AUTOSAR DLT file", true, "dlt" },
110
14
                { "TTL file", true, "ttl" },
111
14
                { "MPEG files", false, "mpeg;mpg;mp3" },
112
14
                { "Transport-Neutral Encapsulation Format", false, "tnef" },
113
14
                { "JPEG/JFIF files", false, "jpg;jpeg;jfif" },
114
14
                { "NetLog file", true, "json" },
115
14
                { "JavaScript Object Notation file", false, "json" },
116
14
                { "JSON Log", true, "json;jsonl;log" },
117
14
                { "MP4 file", false, "mp4" },
118
14
                { "RTPDump file", false, "rtp;rtpdump" },
119
14
                { "EMS file", false, "ems" },
120
14
                { "ASN.1 Basic Encoding Rules", false, "cer;crl;csr;p10;p12;p772;p7c;p7s;p7m;p8;pfx;tsq;tsr" },
121
14
                { "RFC 7468 files", false, "crt;pem" },
122
14
                { "PEAK CAN TRC log", true, "trc" },
123
14
        };
124
125
14
        *file_extensions = wireshark_file_type_extensions_base;
126
14
        *num_extensions = array_length(wireshark_file_type_extensions_base);
127
14
        break;
128
0
    }
129
0
    case APPLICATION_FLAVOR_STRATOSHARK:
130
0
    {
131
0
        static const struct file_extension_info stratoshark_file_type_extensions_base[] = {
132
0
                { "Stratoshark/... - scap", true, "scap"},
133
0
                { "JSON Log", true, "json;jsonl;log" },
134
0
                {"MS Procmon", true, "pml"},
135
0
        };
136
137
0
        *file_extensions = stratoshark_file_type_extensions_base;
138
0
        *num_extensions = array_length(stratoshark_file_type_extensions_base);
139
0
        break;
140
0
    }
141
0
    default:
142
0
        ws_assert_not_reached();
143
14
    }
144
14
}
145
146
const char** application_columns(void)
147
14
{
148
14
    switch (application_flavor) {
149
14
    case APPLICATION_FLAVOR_WIRESHARK:
150
14
    {
151
14
        static const char* col_fmt_packets[] = {
152
14
            "No.",         "%m",
153
14
            "Time",        "%t",
154
14
            "Source",      "%s",
155
14
            "Destination", "%d",
156
14
            "Protocol",    "%p",
157
14
            "Length",      "%L",
158
14
            "Info",        "%i"
159
14
        };
160
14
        return col_fmt_packets;
161
0
    }
162
0
    case APPLICATION_FLAVOR_STRATOSHARK:
163
0
    {
164
0
        static const char* col_fmt_logs[] = {
165
0
            "No.",              "%m",
166
0
            "Time",             "%t",
167
0
            "Event name",       "%Cus:sysdig.event_name:0:R",
168
0
            "Proc Name",        "%Cus:proc.name:0:R",
169
0
            "PID",              "%Cus:proc.pid:0:R",
170
0
            "TID",              "%Cus:thread.tid:0:R",
171
0
            "FD",               "%Cus:fd.num:0:R",
172
0
            "FD Name",          "%Cus:fd.name:0:R",
173
0
            "Container Name",   "%Cus:container.name:0:R",
174
0
            "Arguments",        "%Cus:evt.args:0:R",
175
0
            "Info",             "%i"
176
0
        };
177
178
0
        return col_fmt_logs;
179
0
    }
180
0
    default:
181
0
        ws_assert_not_reached();
182
14
    }
183
14
}
184
185
unsigned application_num_columns(void)
186
14
{
187
14
    switch (application_flavor) {
188
14
    case APPLICATION_FLAVOR_WIRESHARK:
189
14
        return 7;
190
0
    case APPLICATION_FLAVOR_STRATOSHARK:
191
0
        return 11;
192
0
    default:
193
0
        ws_assert_not_reached();
194
14
    }
195
14
}
196
197
bool application_flavor_is_wireshark(void)
198
14
{
199
14
    return (application_flavor == APPLICATION_FLAVOR_WIRESHARK);
200
14
}
201
202
/*
203
 * Editor modelines
204
 *
205
 * Local Variables:
206
 * c-basic-offset: 4
207
 * tab-width: 8
208
 * indent-tabs-mode: nil
209
 * End:
210
 *
211
 * ex: set shiftwidth=4 tabstop=8 expandtab:
212
 * :indentSize=4:tabSize=8:noTabs=true:
213
 */