2 * Routines to report version information for stuff used by Wireshark
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <zlib.h> /* to get the libz version number */
40 #include <pcre.h> /* to get the libpcre version number */
41 #endif /* HAVE_LIBPCRE */
46 #include <net-snmp/version.h>
47 #endif /* HAVE_NET_SNMP */
50 #include <ucd-snmp/version.h>
51 #endif /* HAVE_UCD_SNMP */
53 #endif /* HAVE_SOME_SNMP */
55 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
56 #include <winposixtype.h>
61 #endif /* HAVE_LIBGCRYPT */
64 #include <gnutls/gnutls.h>
65 #endif /* HAVE_LIBGNUTLS */
67 #ifdef HAVE_SYS_UTSNAME_H
68 #include <sys/utsname.h>
71 #include "version_info.h"
72 #include "capture-pcap-util.h"
73 #include "epan/strutil.h"
75 #include "svnversion.h"
86 const char *svnversion = " (" SVNVERSION ")";
88 const char *svnversion = "";
92 * See whether the last line in the string goes past column 80; if so,
93 * replace the blank at the specified point with a newline.
96 do_word_wrap(GString *str, gint point)
100 line_begin = strrchr(str->str, '\n');
101 if (line_begin == NULL)
102 line_begin = str->str;
105 if (strlen(line_begin) > 80) {
106 g_assert(str->str[point] == ' ');
107 str->str[point] = '\n';
112 * If the string doesn't end with a newline, append one.
115 end_string(GString *str)
119 point = strlen(str->str);
120 if (point == 0 || str->str[point - 1] != '\n')
121 g_string_append(str, "\n");
125 * Get various library compile-time versions and append them to
126 * the specified GString.
129 get_compiled_version_info(GString *str)
134 g_string_append(str, "with ");
135 g_string_sprintfa(str,
136 #ifdef GLIB_MAJOR_VERSION
137 "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
140 "GLib (version unknown),");
143 g_string_append(str, " ");
144 break_point = str->len - 1;
145 get_compiled_pcap_version(str);
146 g_string_append(str, ",");
147 do_word_wrap(str, break_point);
150 g_string_append(str, " ");
151 break_point = str->len - 1;
153 g_string_append(str, "with libz ");
155 g_string_append(str, ZLIB_VERSION);
156 #else /* ZLIB_VERSION */
157 g_string_append(str, "(version unknown)");
158 #endif /* ZLIB_VERSION */
159 #else /* HAVE_LIBZ */
160 g_string_append(str, "without libz");
161 #endif /* HAVE_LIBZ */
162 g_string_append(str, ",");
163 do_word_wrap(str, break_point);
166 g_string_append(str, " ");
167 break_point = str->len - 1;
169 g_string_append(str, "with libpcre ");
172 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
173 #else /* PCRE_MINOR */
174 g_string_sprintfa(str, "%u", PCRE_MAJOR);
175 #endif /* PCRE_MINOR */
176 #else /* PCRE_MAJOR */
177 g_string_append(str, "(version unknown)");
178 #endif /* PCRE_MAJOR */
179 #else /* HAVE_LIBPCRE */
180 g_string_append(str, "without libpcre");
181 #endif /* HAVE_LIBPCRE */
183 g_string_append(str, ",");
184 do_word_wrap(str, break_point);
187 /* Oh, this is pretty. */
188 /* Oh, ha. you think that was pretty. Try this:! --Wes */
189 g_string_append(str, " ");
190 break_point = str->len - 1;
191 #ifdef HAVE_SOME_SNMP
194 g_string_append(str, "with UCD-SNMP ");
195 g_string_append(str, VersionInfo);
196 #endif /* HAVE_UCD_SNMP */
199 g_string_append(str, "with Net-SNMP ");
200 g_string_append(str, netsnmp_get_version());
201 #endif /* HAVE_NET_SNMP */
203 #else /* no SNMP library */
204 g_string_append(str, "without UCD-SNMP or Net-SNMP");
205 #endif /* HAVE_SOME_SNMP */
206 g_string_append(str, ",");
207 do_word_wrap(str, break_point);
210 g_string_append(str, " ");
211 break_point = str->len - 1;
213 g_string_append(str, "with ADNS");
215 g_string_append(str, "without ADNS");
216 #endif /* HAVE_GNU_ADNS */
217 g_string_append(str, ",");
220 g_string_append(str, " ");
221 break_point = str->len - 1;
223 g_string_append(str, "with ");
224 g_string_append(str, LUA_VERSION);
226 g_string_append(str, "without Lua");
227 #endif /* HAVE_LUA */
230 g_string_append(str, " ");
231 break_point = str->len - 1;
232 #ifdef HAVE_LIBGNUTLS
233 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
235 g_string_append(str, "without GnuTLS");
236 #endif /* HAVE_LIBGNUTLS */
239 g_string_append(str, " ");
240 break_point = str->len - 1;
241 #ifdef HAVE_LIBGCRYPT
242 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
244 g_string_append(str, "without Gcrypt");
245 #endif /* HAVE_LIBGCRYPT */
248 /* XXX - I don't see how to get the version number, at least for KfW */
249 g_string_append(str, " ");
250 break_point = str->len - 1;
252 #ifdef HAVE_MIT_KERBEROS
253 g_string_append(str, "with MIT Kerberos");
255 /* HAVE_HEIMDAL_KERBEROS */
256 g_string_append(str, "with Heimdal Kerberos");
259 g_string_append(str, "without Kerberos");
260 #endif /* HAVE_KERBEROS */
263 g_string_append(str, " ");
264 break_point = str->len - 1;
265 #ifdef HAVE_PORTAUDIO
266 #ifdef PORTAUDIO_API_1
267 g_string_append(str, "with PortAudio <= V18");
269 g_string_append(str, "with PortAudio ");
270 /* XXX - is this correct? Will need an #include - but I can't test it */
271 g_string_append(str, Pa_GetVersionText());
274 g_string_append(str, "without PortAudio");
275 #endif /* HAVE_PORTAUDIO */
278 g_string_append(str, ".");
279 do_word_wrap(str, break_point);
282 break_point = str->len - 1;
284 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter"
286 do_word_wrap(str, break_point);
287 #endif /* HAVE_LIBPCRE */
293 * Get various library run-time versions, and the OS version, and append
294 * them to the specified GString.
297 get_runtime_version_info(GString *str)
301 #elif defined(HAVE_SYS_UTSNAME_H)
305 get_runtime_pcap_version(str);
307 g_string_append(str, "on ");
312 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
314 * for more than you ever wanted to know about determining the
315 * flavor of Windows on which you're running. Implementing more
316 * of that is left as an exercise to the reader - who should
317 * check any copyright information about code samples on MSDN
318 * before cutting and pasting into Wireshark.
320 * They should also note that you need an OSVERSIONINFOEX structure
321 * to get some of that information, and that not only is that
322 * structure not supported on older versions of Windows, you might
323 * not even be able to compile code that *uses* that structure with
324 * older versions of the SDK.
326 info.dwOSVersionInfoSize = sizeof info;
327 if (!GetVersionEx(&info)) {
329 * XXX - get the failure reason.
331 g_string_append(str, "unknown Windows version");
334 switch (info.dwPlatformId) {
336 case VER_PLATFORM_WIN32s:
338 g_string_sprintfa(str, "Windows 3.1 with Win32s");
341 case VER_PLATFORM_WIN32_WINDOWS:
343 switch (info.dwMajorVersion) {
346 /* 3 cheers for Microsoft marketing! */
347 switch (info.dwMinorVersion) {
350 g_string_sprintfa(str, "Windows 95");
354 g_string_sprintfa(str, "Windows 98");
358 g_string_sprintfa(str, "Windows Me");
362 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
363 info.dwMajorVersion, info.dwMinorVersion);
369 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
370 info.dwMajorVersion, info.dwMinorVersion);
375 case VER_PLATFORM_WIN32_NT:
377 switch (info.dwMajorVersion) {
381 g_string_sprintfa(str, "Windows NT %lu.%lu",
382 info.dwMajorVersion, info.dwMinorVersion);
386 /* 3 cheers for Microsoft marketing! */
387 switch (info.dwMinorVersion) {
390 g_string_sprintfa(str, "Windows 2000");
394 g_string_sprintfa(str, "Windows XP");
398 g_string_sprintfa(str, "Windows Server 2003");
402 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
403 info.dwMajorVersion, info.dwMinorVersion);
409 g_string_sprintfa(str, "Windows Vista");
413 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
414 info.dwMajorVersion, info.dwMinorVersion);
420 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
421 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
424 if (info.szCSDVersion[0] != '\0')
425 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
426 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
427 #elif defined(HAVE_SYS_UTSNAME_H)
429 * We have <sys/utsname.h>, so we assume we have "uname()".
431 if (uname(&name) < 0) {
432 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
437 if (strcmp(name.sysname, "AIX") == 0) {
439 * Yay, IBM! Thanks for doing something different
440 * from most of the other UNIXes out there, and
441 * making "name.version" apparently be the major
442 * version number and "name.release" be the minor
445 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
449 * XXX - get "version" on any other platforms?
451 * On Digital/Tru65 UNIX, it's something unknown.
452 * On Solaris, it's some kind of build information.
453 * On HP-UX, it appears to be some sort of subrevision
456 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
459 g_string_append(str, "an unknown OS");
461 g_string_append(str, ".");
467 * Get copyright information.
470 get_copyright_info(void)
473 "Copyright 1998-2006 Gerald Combs <gerald@wireshark.org> and contributors.\n"
474 "This is free software; see the source for copying conditions. There is NO\n"
475 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";