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 *))
143 g_string_append(str, "with ");
144 g_string_append_printf(str,
145 #ifdef GLIB_MAJOR_VERSION
146 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
149 "GLib (version unknown)");
153 g_string_append(str, ", ");
154 get_compiled_pcap_version(str);
157 g_string_append(str, ", ");
159 g_string_append(str, "with libz ");
161 g_string_append(str, ZLIB_VERSION);
162 #else /* ZLIB_VERSION */
163 g_string_append(str, "(version unknown)");
164 #endif /* ZLIB_VERSION */
165 #else /* HAVE_LIBZ */
166 g_string_append(str, "without libz");
167 #endif /* HAVE_LIBZ */
170 g_string_append(str, ", ");
172 g_string_append(str, "with POSIX capabilities");
173 #ifdef _LINUX_CAPABILITY_VERSION
174 g_string_append(str, " (Linux)");
175 #endif /* _LINUX_CAPABILITY_VERSION */
176 #else /* HAVE_LIBCAP */
177 g_string_append(str, "without POSIX capabilities");
178 #endif /* HAVE_LIBCAP */
180 /* Additional application-dependent information */
182 (*additional_info)(str);
183 g_string_append(str, ".");
185 #if !defined(HAVE_LIBPCRE) && !GLIB_CHECK_VERSION(2,14,0)
187 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
188 g_string_append(str, ".");
189 #endif /* HAVE_LIBPCRE */
195 * Get compile-time information used only by applications that use
199 get_epan_compiled_version_info(GString *str)
202 g_string_append(str, ", ");
204 g_string_append(str, "with libpcre ");
207 g_string_append_printf(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
208 #else /* PCRE_MINOR */
209 g_string_append_printf(str, "%u", PCRE_MAJOR);
210 #endif /* PCRE_MINOR */
211 #else /* PCRE_MAJOR */
212 g_string_append(str, "(version unknown)");
213 #endif /* PCRE_MAJOR */
214 #else /* HAVE_LIBPCRE */
215 g_string_append(str, "without libpcre");
216 #endif /* HAVE_LIBPCRE */
219 g_string_append(str, ", ");
221 g_string_append(str, "with SMI " SMI_VERSION_STRING);
222 #else /* no SNMP library */
223 g_string_append(str, "without SMI");
227 g_string_append(str, ", ");
229 g_string_append(str, "with c-ares " ARES_VERSION_STR);
231 g_string_append(str, "without c-ares");
233 /* ADNS - only add if no c-ares */
234 g_string_append(str, ", ");
236 g_string_append(str, "with ADNS");
238 g_string_append(str, "without ADNS");
239 #endif /* HAVE_GNU_ADNS */
240 #endif /* HAVE_C_ARES */
243 g_string_append(str, ", ");
245 g_string_append(str, "with ");
246 g_string_append(str, LUA_VERSION);
248 g_string_append(str, "without Lua");
249 #endif /* HAVE_LUA_5_1 */
251 g_string_append(str, ", ");
253 g_string_append(str, "with Python");
255 g_string_append(str, " " PY_VERSION);
256 #endif /* PY_VERSION */
258 g_string_append(str, "without Python");
259 #endif /* HAVE_PYTHON */
262 g_string_append(str, ", ");
263 #ifdef HAVE_LIBGNUTLS
264 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
266 g_string_append(str, "without GnuTLS");
267 #endif /* HAVE_LIBGNUTLS */
270 g_string_append(str, ", ");
271 #ifdef HAVE_LIBGCRYPT
272 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
274 g_string_append(str, "without Gcrypt");
275 #endif /* HAVE_LIBGCRYPT */
278 /* XXX - I don't see how to get the version number, at least for KfW */
279 g_string_append(str, ", ");
281 #ifdef HAVE_MIT_KERBEROS
282 g_string_append(str, "with MIT Kerberos");
284 /* HAVE_HEIMDAL_KERBEROS */
285 g_string_append(str, "with Heimdal Kerberos");
288 g_string_append(str, "without Kerberos");
289 #endif /* HAVE_KERBEROS */
292 g_string_append(str, ", ");
294 g_string_append(str, "with GeoIP");
296 g_string_append(str, "without GeoIP");
297 #endif /* HAVE_GEOIP */
302 * Get various library run-time versions, and the OS version, and append
303 * them to the specified GString.
306 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
309 OSVERSIONINFOEX info;
310 SYSTEM_INFO system_info;
311 #elif defined(HAVE_SYS_UTSNAME_H)
314 #if HAVE_OS_X_FRAMEWORKS
315 SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
318 g_string_append(str, "on ");
324 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
326 * for more than you ever wanted to know about determining the
327 * flavor of Windows on which you're running. Implementing more
328 * of that is left as an exercise to the reader - who should
329 * check any copyright information about code samples on MSDN
330 * before cutting and pasting into Wireshark.
332 * They should also note that you need an OSVERSIONINFOEX structure
333 * to get some of that information, and that not only is that
334 * structure not supported on older versions of Windows, you might
335 * not even be able to compile code that *uses* that structure with
336 * older versions of the SDK.
339 memset(&info, '\0', sizeof info);
340 info.dwOSVersionInfoSize = sizeof info;
341 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
343 * XXX - get the failure reason.
345 g_string_append(str, "unknown Windows version");
349 memset(&system_info, '\0', sizeof system_info);
350 GetSystemInfo(&system_info); /* only for W2K or greater .... (which is what we support) */
352 switch (info.dwPlatformId) {
354 case VER_PLATFORM_WIN32s:
356 g_string_append_printf(str, "Windows 3.1 with Win32s");
359 case VER_PLATFORM_WIN32_WINDOWS:
361 switch (info.dwMajorVersion) {
364 /* 3 cheers for Microsoft marketing! */
365 switch (info.dwMinorVersion) {
368 g_string_append_printf(str, "Windows 95");
372 g_string_append_printf(str, "Windows 98");
376 g_string_append_printf(str, "Windows Me");
380 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
381 info.dwMajorVersion, info.dwMinorVersion);
387 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
388 info.dwMajorVersion, info.dwMinorVersion);
393 case VER_PLATFORM_WIN32_NT:
395 switch (info.dwMajorVersion) {
399 g_string_append_printf(str, "Windows NT %lu.%lu",
400 info.dwMajorVersion, info.dwMinorVersion);
404 /* 3 cheers for Microsoft marketing! */
405 switch (info.dwMinorVersion) {
408 g_string_append_printf(str, "Windows 2000");
412 g_string_append_printf(str, "Windows XP");
416 if ((info.wProductType == VER_NT_WORKSTATION) &&
417 (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
418 g_string_append_printf(str, "Windows XP Professional x64 Edition");
420 g_string_append_printf(str, "Windows Server 2003");
421 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
422 g_string_append_printf(str, " x64 Edition");
427 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
428 info.dwMajorVersion, info.dwMinorVersion);
434 gboolean is_nt_workstation;
436 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
437 g_string_append(str, "64-bit ");
438 else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
439 g_string_append(str, "32-bit ");
440 #ifndef VER_NT_WORKSTATION
441 #define VER_NT_WORKSTATION 0x01
442 is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
444 is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
446 switch (info.dwMinorVersion) {
448 g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
451 g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
454 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
455 info.dwMajorVersion, info.dwMinorVersion);
461 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
462 info.dwMajorVersion, info.dwMinorVersion);
464 } /* info.dwMajorVersion */
468 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
469 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
472 if (info.szCSDVersion[0] != '\0')
473 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
474 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
475 #elif defined(HAVE_SYS_UTSNAME_H)
477 * We have <sys/utsname.h>, so we assume we have "uname()".
479 if (uname(&name) < 0) {
480 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
485 if (strcmp(name.sysname, "AIX") == 0) {
487 * Yay, IBM! Thanks for doing something different
488 * from most of the other UNIXes out there, and
489 * making "name.version" apparently be the major
490 * version number and "name.release" be the minor
493 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
497 * XXX - get "version" on any other platforms?
499 * On Digital/Tru64 UNIX, it's something unknown.
500 * On Solaris, it's some kind of build information.
501 * On HP-UX, it appears to be some sort of subrevision
504 g_string_append_printf(str, "%s %s", name.sysname, name.release);
505 #ifdef HAVE_OS_X_FRAMEWORKS
506 Gestalt(gestaltSystemVersion, &macosx_ver);
508 /* The following functions are only available in MacOS 10.4+ */
509 if(macosx_ver >= 0x1040) {
510 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
511 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
512 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
514 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
515 (long)macosx_major_ver,
516 (long)macosx_minor_ver,
517 (long)macosx_bugfix_ver);
519 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
521 /* See Apple's Gestalt Manager Reference for meanings
522 * of the macosx_ver values. */
524 #endif /* HAVE_OS_X_FRAMEWORKS */
527 g_string_append(str, "an unknown OS");
531 g_string_append(str, ", ");
532 get_runtime_pcap_version(str);
536 g_string_append_printf(str, ", with libz %s", zlibVersion());
540 #ifdef HAVE_LIBGNUTLS
541 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
542 #endif /* HAVE_LIBGNUTLS */
545 #ifdef HAVE_LIBGCRYPT
546 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
547 #endif /* HAVE_LIBGCRYPT */
549 /* Additional application-dependent information */
551 (*additional_info)(str);
553 g_string_append(str, ".");
558 * See http://predef.sourceforge.net/precomp.html for
559 * information on various defined strings.
561 * GCC's __VERSION__ is a nice text string for humans to
562 * read. The page at predef.sourceforge.net largely
563 * describes numeric #defines that encode the version;
564 * if the compiler doesn't also offer a nice printable
565 * string, we should probably prettify the number somehow.
567 #if defined(__GNUC__) && defined(__VERSION__)
568 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
569 #elif defined(__HP_aCC)
570 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
571 #elif defined(__xlC__)
572 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
573 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
575 if ((__IBMC__ % 10) != 0)
576 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
577 #endif /* __IBMC__ */
578 g_string_append_printf(str, "\n");
579 #elif defined(__INTEL_COMPILER)
580 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
581 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
582 if ((__INTEL_COMPILER % 10) != 0)
583 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
584 #ifdef __INTEL_COMPILER_BUILD_DATE
585 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
586 __INTEL_COMPILER_BUILD_DATE / 10000,
587 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
588 __INTEL_COMPILER_BUILD_DATE % 100);
589 #endif /* __INTEL_COMPILER_BUILD_DATE */
590 g_string_append_printf(str, "\n");
591 #elif defined(_MSC_FULL_VER)
592 if (_MSC_FULL_VER > 99999999) {
593 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
594 (_MSC_FULL_VER / 10000000) - 6,
595 (_MSC_FULL_VER / 100000) % 100);
596 if ((_MSC_FULL_VER % 100000) != 0)
597 g_string_append_printf(str, " build %d",
598 _MSC_FULL_VER % 100000);
600 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
601 (_MSC_FULL_VER / 1000000) - 6,
602 (_MSC_FULL_VER / 10000) % 100);
603 if ((_MSC_FULL_VER % 10000) != 0)
604 g_string_append_printf(str, " build %d",
605 _MSC_FULL_VER % 10000);
607 g_string_append_printf(str, "\n");
608 #elif defined(_MSC_VER)
609 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
610 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
611 (_MSC_VER / 100) - 6, _MSC_VER % 100);
612 #elif defined(__SUNPRO_C)
613 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
614 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
615 if ((__SUNPRO_C & 0xF) != 0)
616 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
617 g_string_append_printf(str, "\n");
624 * Get copyright information.
627 get_copyright_info(void)
630 "Copyright 1998-2010 Gerald Combs <gerald@wireshark.org> and contributors.\n"
631 "This is free software; see the source for copying conditions. There is NO\n"
632 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
637 * Get the major OS version.
639 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
641 get_os_major_version()
644 info.dwOSVersionInfoSize = sizeof info;
645 if (GetVersionEx(&info)) {
646 return info.dwMajorVersion;
658 * indent-tabs-mode: t
661 * ex: set shiftwidth=8 tabstop=8 noexpandtab
662 * :indentSize=8:tabSize=8:noTabs=false: