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.
37 #include <Python.h> /* to get the Python version number (PY_VERSION) */
41 #include <zlib.h> /* to get the libz version number */
45 #include <pcre.h> /* to get the libpcre version number */
46 #endif /* HAVE_LIBPCRE */
50 #endif /* HAVE_LIBGCRYPT */
53 #include <gnutls/gnutls.h>
54 #endif /* HAVE_LIBGNUTLS */
56 #ifdef HAVE_SYS_UTSNAME_H
57 #include <sys/utsname.h>
60 #include "version_info.h"
61 #include "capture-pcap-util.h"
62 #include <wsutil/unicode-utils.h>
64 #include "svnversion.h"
71 #include <ares_version.h>
82 #ifdef HAVE_OS_X_FRAMEWORKS
83 #include <CoreServices/CoreServices.h>
87 # include <sys/capability.h>
91 #include <epan/geoip_db.h>
95 const char *wireshark_svnversion = " (" SVNVERSION " from " SVNPATH ")";
97 const char *wireshark_svnversion = "";
101 * If the string doesn't end with a newline, append one.
102 * Then word-wrap it to 80 columns.
105 end_string(GString *str)
110 point = strlen(str->str);
111 if (point == 0 || str->str[point - 1] != '\n')
112 g_string_append(str, "\n");
118 * Break at or before this point.
121 while (q > p && *q != ' ')
131 * Get various library compile-time versions and append them to
132 * the specified GString.
134 * "additional_info" is called at the end to append any additional
135 * information; this is required in order to, for example, put the
136 * Portaudio information at the end of the string, as we currently
137 * don't use Portaudio in TShark.
140 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
142 if (sizeof(str) == 4)
143 g_string_append(str, "(32-bit) ");
145 g_string_append(str, "(64-bit) ");
148 g_string_append(str, "with ");
149 g_string_append_printf(str,
150 #ifdef GLIB_MAJOR_VERSION
151 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
154 "GLib (version unknown)");
158 g_string_append(str, ", ");
159 get_compiled_pcap_version(str);
162 g_string_append(str, ", ");
164 g_string_append(str, "with libz ");
166 g_string_append(str, ZLIB_VERSION);
167 #else /* ZLIB_VERSION */
168 g_string_append(str, "(version unknown)");
169 #endif /* ZLIB_VERSION */
170 #else /* HAVE_LIBZ */
171 g_string_append(str, "without libz");
172 #endif /* HAVE_LIBZ */
175 g_string_append(str, ", ");
177 g_string_append(str, "with POSIX capabilities");
178 #ifdef _LINUX_CAPABILITY_VERSION
179 g_string_append(str, " (Linux)");
180 #endif /* _LINUX_CAPABILITY_VERSION */
181 #else /* HAVE_LIBCAP */
182 g_string_append(str, "without POSIX capabilities");
183 #endif /* HAVE_LIBCAP */
185 /* Additional application-dependent information */
187 (*additional_info)(str);
188 g_string_append(str, ".");
190 #if !defined(HAVE_LIBPCRE) && !GLIB_CHECK_VERSION(2,14,0)
192 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
193 g_string_append(str, ".");
194 #endif /* HAVE_LIBPCRE */
200 * Get compile-time information used only by applications that use
204 get_epan_compiled_version_info(GString *str)
207 g_string_append(str, ", ");
209 g_string_append(str, "with libpcre ");
212 g_string_append_printf(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
213 #else /* PCRE_MINOR */
214 g_string_append_printf(str, "%u", PCRE_MAJOR);
215 #endif /* PCRE_MINOR */
216 #else /* PCRE_MAJOR */
217 g_string_append(str, "(version unknown)");
218 #endif /* PCRE_MAJOR */
219 #else /* HAVE_LIBPCRE */
220 g_string_append(str, "without libpcre");
221 #endif /* HAVE_LIBPCRE */
224 g_string_append(str, ", ");
226 g_string_append(str, "with SMI " SMI_VERSION_STRING);
227 #else /* no SNMP library */
228 g_string_append(str, "without SMI");
232 g_string_append(str, ", ");
234 g_string_append(str, "with c-ares " ARES_VERSION_STR);
236 g_string_append(str, "without c-ares");
238 /* ADNS - only add if no c-ares */
239 g_string_append(str, ", ");
241 g_string_append(str, "with ADNS");
243 g_string_append(str, "without ADNS");
244 #endif /* HAVE_GNU_ADNS */
245 #endif /* HAVE_C_ARES */
248 g_string_append(str, ", ");
250 g_string_append(str, "with ");
251 g_string_append(str, LUA_VERSION);
253 g_string_append(str, "without Lua");
254 #endif /* HAVE_LUA_5_1 */
256 g_string_append(str, ", ");
258 g_string_append(str, "with Python");
260 g_string_append(str, " " PY_VERSION);
261 #endif /* PY_VERSION */
263 g_string_append(str, "without Python");
264 #endif /* HAVE_PYTHON */
267 g_string_append(str, ", ");
268 #ifdef HAVE_LIBGNUTLS
269 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
271 g_string_append(str, "without GnuTLS");
272 #endif /* HAVE_LIBGNUTLS */
275 g_string_append(str, ", ");
276 #ifdef HAVE_LIBGCRYPT
277 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
279 g_string_append(str, "without Gcrypt");
280 #endif /* HAVE_LIBGCRYPT */
283 /* XXX - I don't see how to get the version number, at least for KfW */
284 g_string_append(str, ", ");
286 #ifdef HAVE_MIT_KERBEROS
287 g_string_append(str, "with MIT Kerberos");
289 /* HAVE_HEIMDAL_KERBEROS */
290 g_string_append(str, "with Heimdal Kerberos");
293 g_string_append(str, "without Kerberos");
294 #endif /* HAVE_KERBEROS */
297 g_string_append(str, ", ");
299 g_string_append(str, "with GeoIP");
301 g_string_append(str, "without GeoIP");
302 #endif /* HAVE_GEOIP */
307 * Get various library run-time versions, and the OS version, and append
308 * them to the specified GString.
311 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
314 OSVERSIONINFOEX info;
315 SYSTEM_INFO system_info;
316 #elif defined(HAVE_SYS_UTSNAME_H)
319 #if HAVE_OS_X_FRAMEWORKS
320 SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
323 g_string_append(str, "on ");
329 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
331 * for more than you ever wanted to know about determining the
332 * flavor of Windows on which you're running. Implementing more
333 * of that is left as an exercise to the reader - who should
334 * check any copyright information about code samples on MSDN
335 * before cutting and pasting into Wireshark.
337 * They should also note that you need an OSVERSIONINFOEX structure
338 * to get some of that information, and that not only is that
339 * structure not supported on older versions of Windows, you might
340 * not even be able to compile code that *uses* that structure with
341 * older versions of the SDK.
344 memset(&info, '\0', sizeof info);
345 info.dwOSVersionInfoSize = sizeof info;
346 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
348 * XXX - get the failure reason.
350 g_string_append(str, "unknown Windows version");
354 memset(&system_info, '\0', sizeof system_info);
355 GetSystemInfo(&system_info); /* only for W2K or greater .... (which is what we support) */
357 switch (info.dwPlatformId) {
359 case VER_PLATFORM_WIN32s:
361 g_string_append_printf(str, "Windows 3.1 with Win32s");
364 case VER_PLATFORM_WIN32_WINDOWS:
366 switch (info.dwMajorVersion) {
369 /* 3 cheers for Microsoft marketing! */
370 switch (info.dwMinorVersion) {
373 g_string_append_printf(str, "Windows 95");
377 g_string_append_printf(str, "Windows 98");
381 g_string_append_printf(str, "Windows Me");
385 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
386 info.dwMajorVersion, info.dwMinorVersion);
392 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
393 info.dwMajorVersion, info.dwMinorVersion);
398 case VER_PLATFORM_WIN32_NT:
400 switch (info.dwMajorVersion) {
404 g_string_append_printf(str, "Windows NT %lu.%lu",
405 info.dwMajorVersion, info.dwMinorVersion);
409 /* 3 cheers for Microsoft marketing! */
410 switch (info.dwMinorVersion) {
413 g_string_append_printf(str, "Windows 2000");
417 g_string_append_printf(str, "Windows XP");
421 if ((info.wProductType == VER_NT_WORKSTATION) &&
422 (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
423 g_string_append_printf(str, "Windows XP Professional x64 Edition");
425 g_string_append_printf(str, "Windows Server 2003");
426 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
427 g_string_append_printf(str, " x64 Edition");
432 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
433 info.dwMajorVersion, info.dwMinorVersion);
439 gboolean is_nt_workstation;
441 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
442 g_string_append(str, "64-bit ");
443 else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
444 g_string_append(str, "32-bit ");
445 #ifndef VER_NT_WORKSTATION
446 #define VER_NT_WORKSTATION 0x01
447 is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
449 is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
451 switch (info.dwMinorVersion) {
453 g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
456 g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
459 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
460 info.dwMajorVersion, info.dwMinorVersion);
466 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
467 info.dwMajorVersion, info.dwMinorVersion);
469 } /* info.dwMajorVersion */
473 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
474 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
477 if (info.szCSDVersion[0] != '\0')
478 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
479 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
480 #elif defined(HAVE_SYS_UTSNAME_H)
482 * We have <sys/utsname.h>, so we assume we have "uname()".
484 if (uname(&name) < 0) {
485 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
490 if (strcmp(name.sysname, "AIX") == 0) {
492 * Yay, IBM! Thanks for doing something different
493 * from most of the other UNIXes out there, and
494 * making "name.version" apparently be the major
495 * version number and "name.release" be the minor
498 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
502 * XXX - get "version" on any other platforms?
504 * On Digital/Tru64 UNIX, it's something unknown.
505 * On Solaris, it's some kind of build information.
506 * On HP-UX, it appears to be some sort of subrevision
509 g_string_append_printf(str, "%s %s", name.sysname, name.release);
510 #ifdef HAVE_OS_X_FRAMEWORKS
511 Gestalt(gestaltSystemVersion, &macosx_ver);
513 /* The following functions are only available in MacOS 10.4+ */
514 if(macosx_ver >= 0x1040) {
515 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
516 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
517 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
519 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
520 (long)macosx_major_ver,
521 (long)macosx_minor_ver,
522 (long)macosx_bugfix_ver);
524 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
526 /* See Apple's Gestalt Manager Reference for meanings
527 * of the macosx_ver values. */
529 #endif /* HAVE_OS_X_FRAMEWORKS */
532 g_string_append(str, "an unknown OS");
536 g_string_append(str, ", ");
537 get_runtime_pcap_version(str);
540 #if defined(HAVE_LIBZ) && !defined(_WIN32)
541 g_string_append_printf(str, ", with libz %s", zlibVersion());
545 #ifdef HAVE_LIBGNUTLS
546 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
547 #endif /* HAVE_LIBGNUTLS */
550 #ifdef HAVE_LIBGCRYPT
551 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
552 #endif /* HAVE_LIBGCRYPT */
554 /* Additional application-dependent information */
556 (*additional_info)(str);
558 g_string_append(str, ".");
563 * See http://predef.sourceforge.net/precomp.html for
564 * information on various defined strings.
566 * GCC's __VERSION__ is a nice text string for humans to
567 * read. The page at predef.sourceforge.net largely
568 * describes numeric #defines that encode the version;
569 * if the compiler doesn't also offer a nice printable
570 * string, we should probably prettify the number somehow.
572 #if defined(__GNUC__) && defined(__VERSION__)
573 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
574 #elif defined(__HP_aCC)
575 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
576 #elif defined(__xlC__)
577 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
578 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
580 if ((__IBMC__ % 10) != 0)
581 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
582 #endif /* __IBMC__ */
583 g_string_append_printf(str, "\n");
584 #elif defined(__INTEL_COMPILER)
585 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
586 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
587 if ((__INTEL_COMPILER % 10) != 0)
588 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
589 #ifdef __INTEL_COMPILER_BUILD_DATE
590 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
591 __INTEL_COMPILER_BUILD_DATE / 10000,
592 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
593 __INTEL_COMPILER_BUILD_DATE % 100);
594 #endif /* __INTEL_COMPILER_BUILD_DATE */
595 g_string_append_printf(str, "\n");
596 #elif defined(_MSC_FULL_VER)
597 if (_MSC_FULL_VER > 99999999) {
598 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
599 (_MSC_FULL_VER / 10000000) - 6,
600 (_MSC_FULL_VER / 100000) % 100);
601 if ((_MSC_FULL_VER % 100000) != 0)
602 g_string_append_printf(str, " build %d",
603 _MSC_FULL_VER % 100000);
605 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
606 (_MSC_FULL_VER / 1000000) - 6,
607 (_MSC_FULL_VER / 10000) % 100);
608 if ((_MSC_FULL_VER % 10000) != 0)
609 g_string_append_printf(str, " build %d",
610 _MSC_FULL_VER % 10000);
612 g_string_append_printf(str, "\n");
613 #elif defined(_MSC_VER)
614 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
615 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
616 (_MSC_VER / 100) - 6, _MSC_VER % 100);
617 #elif defined(__SUNPRO_C)
618 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
619 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
620 if ((__SUNPRO_C & 0xF) != 0)
621 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
622 g_string_append_printf(str, "\n");
629 * Get copyright information.
632 get_copyright_info(void)
635 "Copyright 1998-2010 Gerald Combs <gerald@wireshark.org> and contributors.\n"
636 "This is free software; see the source for copying conditions. There is NO\n"
637 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
642 * Get the major OS version.
644 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
646 get_os_major_version()
649 info.dwOSVersionInfoSize = sizeof info;
650 if (GetVersionEx(&info)) {
651 return info.dwMajorVersion;
663 * indent-tabs-mode: t
666 * ex: set shiftwidth=8 tabstop=8 noexpandtab
667 * :indentSize=8:tabSize=8:noTabs=false: