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 */
44 #include <net-snmp/version.h>
45 #endif /* HAVE_NET_SNMP */
47 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
48 #include <winposixtype.h>
53 #endif /* HAVE_LIBGCRYPT */
56 #include <gnutls/gnutls.h>
57 #endif /* HAVE_LIBGNUTLS */
59 #ifdef HAVE_SYS_UTSNAME_H
60 #include <sys/utsname.h>
63 #include "version_info.h"
64 #include "capture-pcap-util.h"
65 #include "epan/unicode-utils.h"
67 #include "svnversion.h"
82 const char *wireshark_svnversion = " (" SVNVERSION ")";
84 const char *wireshark_svnversion = "";
88 * If the string doesn't end with a newline, append one.
89 * Then word-wrap it to 80 columns.
92 end_string(GString *str)
97 point = strlen(str->str);
98 if (point == 0 || str->str[point - 1] != '\n')
99 g_string_append(str, "\n");
105 * Break at or before this point.
108 while (q > p && *q != ' ')
118 * Get various library compile-time versions and append them to
119 * the specified GString.
121 * "additional_info" is called at the end to append any additional
122 * information; this is required in order to, for example, put the
123 * Portaudio information at the end of the string, as we currently
124 * don't use Portaudio in TShark.
127 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
130 g_string_append(str, "with ");
131 g_string_sprintfa(str,
132 #ifdef GLIB_MAJOR_VERSION
133 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
136 "GLib (version unknown)");
140 g_string_append(str, ", ");
141 get_compiled_pcap_version(str);
144 g_string_append(str, ", ");
146 g_string_append(str, "with libz ");
148 g_string_append(str, ZLIB_VERSION);
149 #else /* ZLIB_VERSION */
150 g_string_append(str, "(version unknown)");
151 #endif /* ZLIB_VERSION */
152 #else /* HAVE_LIBZ */
153 g_string_append(str, "without libz");
154 #endif /* HAVE_LIBZ */
156 /* Additional application-dependent information */
158 (*additional_info)(str);
159 g_string_append(str, ".");
163 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
164 g_string_append(str, ".");
165 #endif /* HAVE_LIBPCRE */
171 * Get compile-time information used only by applications that use
175 get_epan_compiled_version_info(GString *str)
178 g_string_append(str, ", ");
180 g_string_append(str, "with libpcre ");
183 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
184 #else /* PCRE_MINOR */
185 g_string_sprintfa(str, "%u", PCRE_MAJOR);
186 #endif /* PCRE_MINOR */
187 #else /* PCRE_MAJOR */
188 g_string_append(str, "(version unknown)");
189 #endif /* PCRE_MAJOR */
190 #else /* HAVE_LIBPCRE */
191 g_string_append(str, "without libpcre");
192 #endif /* HAVE_LIBPCRE */
195 g_string_append(str, ", ");
197 g_string_append(str, "with SMI ");
198 g_string_append(str, SMI_VERSION_STRING);
199 #else /* no SNMP library */
200 g_string_append(str, "without SMI");
204 g_string_append(str, ", ");
206 g_string_append(str, "with ADNS");
208 g_string_append(str, "without ADNS");
209 #endif /* HAVE_GNU_ADNS */
212 g_string_append(str, ", ");
214 g_string_append(str, "with ");
215 g_string_append(str, LUA_VERSION);
217 g_string_append(str, "without Lua");
218 #endif /* HAVE_LUA_5_1 */
221 g_string_append(str, ", ");
222 #ifdef HAVE_LIBGNUTLS
223 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
225 g_string_append(str, "without GnuTLS");
226 #endif /* HAVE_LIBGNUTLS */
229 g_string_append(str, ", ");
230 #ifdef HAVE_LIBGCRYPT
231 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
233 g_string_append(str, "without Gcrypt");
234 #endif /* HAVE_LIBGCRYPT */
237 /* XXX - I don't see how to get the version number, at least for KfW */
238 g_string_append(str, ", ");
240 #ifdef HAVE_MIT_KERBEROS
241 g_string_append(str, "with MIT Kerberos");
243 /* HAVE_HEIMDAL_KERBEROS */
244 g_string_append(str, "with Heimdal Kerberos");
247 g_string_append(str, "without Kerberos");
248 #endif /* HAVE_KERBEROS */
252 * Get various library run-time versions, and the OS version, and append
253 * them to the specified GString.
256 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
260 #elif defined(HAVE_SYS_UTSNAME_H)
264 g_string_append(str, "on ");
270 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
272 * for more than you ever wanted to know about determining the
273 * flavor of Windows on which you're running. Implementing more
274 * of that is left as an exercise to the reader - who should
275 * check any copyright information about code samples on MSDN
276 * before cutting and pasting into Wireshark.
278 * They should also note that you need an OSVERSIONINFOEX structure
279 * to get some of that information, and that not only is that
280 * structure not supported on older versions of Windows, you might
281 * not even be able to compile code that *uses* that structure with
282 * older versions of the SDK.
284 info.dwOSVersionInfoSize = sizeof info;
285 if (!GetVersionEx(&info)) {
287 * XXX - get the failure reason.
289 g_string_append(str, "unknown Windows version");
292 switch (info.dwPlatformId) {
294 case VER_PLATFORM_WIN32s:
296 g_string_sprintfa(str, "Windows 3.1 with Win32s");
299 case VER_PLATFORM_WIN32_WINDOWS:
301 switch (info.dwMajorVersion) {
304 /* 3 cheers for Microsoft marketing! */
305 switch (info.dwMinorVersion) {
308 g_string_sprintfa(str, "Windows 95");
312 g_string_sprintfa(str, "Windows 98");
316 g_string_sprintfa(str, "Windows Me");
320 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
321 info.dwMajorVersion, info.dwMinorVersion);
327 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
328 info.dwMajorVersion, info.dwMinorVersion);
333 case VER_PLATFORM_WIN32_NT:
335 switch (info.dwMajorVersion) {
339 g_string_sprintfa(str, "Windows NT %lu.%lu",
340 info.dwMajorVersion, info.dwMinorVersion);
344 /* 3 cheers for Microsoft marketing! */
345 switch (info.dwMinorVersion) {
348 g_string_sprintfa(str, "Windows 2000");
352 g_string_sprintfa(str, "Windows XP");
356 g_string_sprintfa(str, "Windows Server 2003");
360 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
361 info.dwMajorVersion, info.dwMinorVersion);
367 g_string_sprintfa(str, "Windows Vista");
371 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
372 info.dwMajorVersion, info.dwMinorVersion);
378 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
379 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
382 if (info.szCSDVersion[0] != '\0')
383 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
384 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
385 #elif defined(HAVE_SYS_UTSNAME_H)
387 * We have <sys/utsname.h>, so we assume we have "uname()".
389 if (uname(&name) < 0) {
390 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
395 if (strcmp(name.sysname, "AIX") == 0) {
397 * Yay, IBM! Thanks for doing something different
398 * from most of the other UNIXes out there, and
399 * making "name.version" apparently be the major
400 * version number and "name.release" be the minor
403 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
407 * XXX - get "version" on any other platforms?
409 * On Digital/Tru65 UNIX, it's something unknown.
410 * On Solaris, it's some kind of build information.
411 * On HP-UX, it appears to be some sort of subrevision
414 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
417 g_string_append(str, "an unknown OS");
421 g_string_append(str, ", ");
422 get_runtime_pcap_version(str);
424 /* Additional application-dependent information */
426 (*additional_info)(str);
428 g_string_append(str, ".");
433 * See http://predef.sourceforge.net/precomp.html for
434 * information on various defined strings.
436 * GCC's __VERSION__ is a nice text string for humans to
437 * read. The page at predef.sourceforge.net largely
438 * describes numeric #defines that encode the version;
439 * if the compiler doesn't also offer a nice printable
440 * string, we should probably prettify the number somehow.
442 #if defined(__GNUC__) && defined(__VERSION__)
443 g_string_sprintfa(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
444 #elif defined(__HP_aCC)
445 g_string_sprintfa(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
446 #elif defined(__xlC__)
447 g_string_sprintfa(str, "\n\nBuilt using IBM XL C %d.%d\n",
448 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
450 if ((__IBMC__ % 10) != 0)
451 g_string_sprintfa(str, " patch %d", __IBMC__ % 10);
452 #endif /* __IBMC__ */
453 g_string_sprintfa(str, "\n");
454 #elif defined(__INTEL_COMPILER)
455 g_string_sprintfa(str, "\n\nBuilt using Intel C %d.%d",
456 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
457 if ((__INTEL_COMPILER % 10) != 0)
458 g_string_sprintfa(str, " patch %d", __INTEL_COMPILER % 10);
459 #ifdef __INTEL_COMPILER_BUILD_DATE
460 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
461 __INTEL_COMPILER_BUILD_DATE / 10000,
462 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
463 __INTEL_COMPILER_BUILD_DATE % 100);
464 #endif /* __INTEL_COMPILER_BUILD_DATE */
465 g_string_sprintfa(str, "\n");
466 #elif defined(_MSC_FULL_VER)
467 if (_MSC_FULL_VER > 99999999) {
468 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
469 (_MSC_FULL_VER / 10000000) - 6,
470 (_MSC_FULL_VER / 100000) % 100);
471 if ((_MSC_FULL_VER % 100000) != 0)
472 g_string_sprintfa(str, " build %d",
473 _MSC_FULL_VER % 100000);
475 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
476 (_MSC_FULL_VER / 1000000) - 6,
477 (_MSC_FULL_VER / 10000) % 100);
478 if ((_MSC_FULL_VER % 10000) != 0)
479 g_string_sprintfa(str, " build %d",
480 _MSC_FULL_VER % 10000);
482 g_string_sprintfa(str, "\n");
483 #elif defined(_MSC_VER)
484 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
485 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
486 (_MSC_VER / 100) - 6, _MSC_VER % 100);
487 #elif defined(__SUNPRO_C)
488 g_string_sprintfa(str, "\n\nBuilt using Sun C %d.%d",
489 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
490 if ((__SUNPRO_C & 0xF) != 0)
491 g_string_sprintfa(str, " patch %d", __SUNPRO_C & 0xF);
492 g_string_sprintfa(str, "\n");
499 * Get copyright information.
502 get_copyright_info(void)
505 "Copyright 1998-2007 Gerald Combs <gerald@wireshark.org> and contributors.\n"
506 "This is free software; see the source for copying conditions. There is NO\n"
507 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";