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 */
48 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
49 #include <winposixtype.h>
54 #endif /* HAVE_LIBGCRYPT */
57 #include <gnutls/gnutls.h>
58 #endif /* HAVE_LIBGNUTLS */
60 #ifdef HAVE_SYS_UTSNAME_H
61 #include <sys/utsname.h>
64 #include "version_info.h"
65 #include "capture-pcap-util.h"
66 #include <wsutil/unicode-utils.h>
68 #include "svnversion.h"
75 #include <ares_version.h>
86 #ifdef HAVE_OS_X_FRAMEWORKS
87 #include <CoreServices/CoreServices.h>
91 # include <sys/capability.h>
95 #include <epan/geoip_db.h>
99 const char *wireshark_svnversion = " (" SVNVERSION " from " SVNPATH ")";
101 const char *wireshark_svnversion = "";
105 * If the string doesn't end with a newline, append one.
106 * Then word-wrap it to 80 columns.
109 end_string(GString *str)
114 point = strlen(str->str);
115 if (point == 0 || str->str[point - 1] != '\n')
116 g_string_append(str, "\n");
122 * Break at or before this point.
125 while (q > p && *q != ' ')
135 * Get various library compile-time versions and append them to
136 * the specified GString.
138 * "additional_info" is called at the end to append any additional
139 * information; this is required in order to, for example, put the
140 * Portaudio information at the end of the string, as we currently
141 * don't use Portaudio in TShark.
144 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
147 g_string_append(str, "with ");
148 g_string_append_printf(str,
149 #ifdef GLIB_MAJOR_VERSION
150 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
153 "GLib (version unknown)");
157 g_string_append(str, ", ");
158 get_compiled_pcap_version(str);
161 g_string_append(str, ", ");
163 g_string_append(str, "with libz ");
165 g_string_append(str, ZLIB_VERSION);
166 #else /* ZLIB_VERSION */
167 g_string_append(str, "(version unknown)");
168 #endif /* ZLIB_VERSION */
169 #else /* HAVE_LIBZ */
170 g_string_append(str, "without libz");
171 #endif /* HAVE_LIBZ */
174 g_string_append(str, ", ");
176 g_string_append(str, "with POSIX capabilities");
177 #ifdef _LINUX_CAPABILITY_VERSION
178 g_string_append(str, " (Linux)");
179 #endif /* _LINUX_CAPABILITY_VERSION */
180 #else /* HAVE_LIBCAP */
181 g_string_append(str, "without POSIX capabilities");
182 #endif /* HAVE_LIBCAP */
184 /* Additional application-dependent information */
186 (*additional_info)(str);
187 g_string_append(str, ".");
191 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
192 g_string_append(str, ".");
193 #endif /* HAVE_LIBPCRE */
199 * Get compile-time information used only by applications that use
203 get_epan_compiled_version_info(GString *str)
206 g_string_append(str, ", ");
208 g_string_append(str, "with libpcre ");
211 g_string_append_printf(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
212 #else /* PCRE_MINOR */
213 g_string_append_printf(str, "%u", PCRE_MAJOR);
214 #endif /* PCRE_MINOR */
215 #else /* PCRE_MAJOR */
216 g_string_append(str, "(version unknown)");
217 #endif /* PCRE_MAJOR */
218 #else /* HAVE_LIBPCRE */
219 g_string_append(str, "without libpcre");
220 #endif /* HAVE_LIBPCRE */
223 g_string_append(str, ", ");
225 g_string_append(str, "with SMI " SMI_VERSION_STRING);
226 #else /* no SNMP library */
227 g_string_append(str, "without SMI");
231 g_string_append(str, ", ");
233 g_string_append(str, "with c-ares " ARES_VERSION_STR);
235 g_string_append(str, "without c-ares");
237 /* ADNS - only add if no c-ares */
238 g_string_append(str, ", ");
240 g_string_append(str, "with ADNS");
242 g_string_append(str, "without ADNS");
243 #endif /* HAVE_GNU_ADNS */
244 #endif /* HAVE_C_ARES */
247 g_string_append(str, ", ");
249 g_string_append(str, "with ");
250 g_string_append(str, LUA_VERSION);
252 g_string_append(str, "without Lua");
253 #endif /* HAVE_LUA_5_1 */
255 g_string_append(str, ", ");
257 g_string_append(str, "with Python");
259 g_string_append(str, " " PY_VERSION);
260 #endif /* PY_VERSION */
262 g_string_append(str, "without Python");
263 #endif /* HAVE_PYTHON */
266 g_string_append(str, ", ");
267 #ifdef HAVE_LIBGNUTLS
268 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
270 g_string_append(str, "without GnuTLS");
271 #endif /* HAVE_LIBGNUTLS */
274 g_string_append(str, ", ");
275 #ifdef HAVE_LIBGCRYPT
276 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
278 g_string_append(str, "without Gcrypt");
279 #endif /* HAVE_LIBGCRYPT */
282 /* XXX - I don't see how to get the version number, at least for KfW */
283 g_string_append(str, ", ");
285 #ifdef HAVE_MIT_KERBEROS
286 g_string_append(str, "with MIT Kerberos");
288 /* HAVE_HEIMDAL_KERBEROS */
289 g_string_append(str, "with Heimdal Kerberos");
292 g_string_append(str, "without Kerberos");
293 #endif /* HAVE_KERBEROS */
296 g_string_append(str, ", ");
298 g_string_append(str, "with GeoIP");
300 g_string_append(str, "without GeoIP");
301 #endif /* HAVE_GEOIP */
306 * Get various library run-time versions, and the OS version, and append
307 * them to the specified GString.
310 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
313 OSVERSIONINFOEX info;
314 SYSTEM_INFO system_info;
315 #elif defined(HAVE_SYS_UTSNAME_H)
318 #if HAVE_OS_X_FRAMEWORKS
319 SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
322 g_string_append(str, "on ");
328 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
330 * for more than you ever wanted to know about determining the
331 * flavor of Windows on which you're running. Implementing more
332 * of that is left as an exercise to the reader - who should
333 * check any copyright information about code samples on MSDN
334 * before cutting and pasting into Wireshark.
336 * They should also note that you need an OSVERSIONINFOEX structure
337 * to get some of that information, and that not only is that
338 * structure not supported on older versions of Windows, you might
339 * not even be able to compile code that *uses* that structure with
340 * older versions of the SDK.
343 memset(&info, '\0', sizeof info);
344 info.dwOSVersionInfoSize = sizeof info;
345 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
347 * XXX - get the failure reason.
349 g_string_append(str, "unknown Windows version");
353 memset(&system_info, '\0', sizeof system_info);
354 GetSystemInfo(&system_info); /* only for W2K or greater .... (which is what we support) */
356 switch (info.dwPlatformId) {
358 case VER_PLATFORM_WIN32s:
360 g_string_append_printf(str, "Windows 3.1 with Win32s");
363 case VER_PLATFORM_WIN32_WINDOWS:
365 switch (info.dwMajorVersion) {
368 /* 3 cheers for Microsoft marketing! */
369 switch (info.dwMinorVersion) {
372 g_string_append_printf(str, "Windows 95");
376 g_string_append_printf(str, "Windows 98");
380 g_string_append_printf(str, "Windows Me");
384 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
385 info.dwMajorVersion, info.dwMinorVersion);
391 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
392 info.dwMajorVersion, info.dwMinorVersion);
397 case VER_PLATFORM_WIN32_NT:
399 switch (info.dwMajorVersion) {
403 g_string_append_printf(str, "Windows NT %lu.%lu",
404 info.dwMajorVersion, info.dwMinorVersion);
408 /* 3 cheers for Microsoft marketing! */
409 switch (info.dwMinorVersion) {
412 g_string_append_printf(str, "Windows 2000");
416 g_string_append_printf(str, "Windows XP");
420 if ((info.wProductType == VER_NT_WORKSTATION) &&
421 (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)) {
422 g_string_append_printf(str, "Windows XP Professional x64 Edition");
424 g_string_append_printf(str, "Windows Server 2003");
425 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
426 g_string_append_printf(str, " x64 Edition");
431 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
432 info.dwMajorVersion, info.dwMinorVersion);
438 gboolean is_nt_workstation;
440 if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
441 g_string_append(str, "64-bit ");
442 else if (system_info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
443 g_string_append(str, "32-bit ");
444 #ifndef VER_NT_WORKSTATION
445 #define VER_NT_WORKSTATION 0x01
446 is_nt_workstation = ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION);
448 is_nt_workstation = (info.wProductType == VER_NT_WORKSTATION);
450 switch (info.dwMinorVersion) {
452 g_string_append_printf(str, is_nt_workstation ? "Windows Vista" : "Windows Server 2008");
455 g_string_append_printf(str, is_nt_workstation ? "Windows 7" : "Windows Server 2008 R2");
458 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
459 info.dwMajorVersion, info.dwMinorVersion);
465 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
466 info.dwMajorVersion, info.dwMinorVersion);
468 } /* info.dwMajorVersion */
472 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
473 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
476 if (info.szCSDVersion[0] != '\0')
477 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
478 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
479 #elif defined(HAVE_SYS_UTSNAME_H)
481 * We have <sys/utsname.h>, so we assume we have "uname()".
483 if (uname(&name) < 0) {
484 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
489 if (strcmp(name.sysname, "AIX") == 0) {
491 * Yay, IBM! Thanks for doing something different
492 * from most of the other UNIXes out there, and
493 * making "name.version" apparently be the major
494 * version number and "name.release" be the minor
497 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
501 * XXX - get "version" on any other platforms?
503 * On Digital/Tru64 UNIX, it's something unknown.
504 * On Solaris, it's some kind of build information.
505 * On HP-UX, it appears to be some sort of subrevision
508 g_string_append_printf(str, "%s %s", name.sysname, name.release);
509 #ifdef HAVE_OS_X_FRAMEWORKS
510 Gestalt(gestaltSystemVersion, &macosx_ver);
512 /* The following functions are only available in MacOS 10.4+ */
513 if(macosx_ver >= 0x1040) {
514 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
515 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
516 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
518 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
519 (long)macosx_major_ver,
520 (long)macosx_minor_ver,
521 (long)macosx_bugfix_ver);
523 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
525 /* See Apple's Gestalt Manager Reference for meanings
526 * of the macosx_ver values. */
528 #endif /* HAVE_OS_X_FRAMEWORKS */
531 g_string_append(str, "an unknown OS");
535 g_string_append(str, ", ");
536 get_runtime_pcap_version(str);
539 #ifdef HAVE_LIBGNUTLS
540 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
541 #endif /* HAVE_LIBGNUTLS */
544 #ifdef HAVE_LIBGCRYPT
545 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
546 #endif /* HAVE_LIBGCRYPT */
548 /* Additional application-dependent information */
550 (*additional_info)(str);
552 g_string_append(str, ".");
557 * See http://predef.sourceforge.net/precomp.html for
558 * information on various defined strings.
560 * GCC's __VERSION__ is a nice text string for humans to
561 * read. The page at predef.sourceforge.net largely
562 * describes numeric #defines that encode the version;
563 * if the compiler doesn't also offer a nice printable
564 * string, we should probably prettify the number somehow.
566 #if defined(__GNUC__) && defined(__VERSION__)
567 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
568 #elif defined(__HP_aCC)
569 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
570 #elif defined(__xlC__)
571 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
572 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
574 if ((__IBMC__ % 10) != 0)
575 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
576 #endif /* __IBMC__ */
577 g_string_append_printf(str, "\n");
578 #elif defined(__INTEL_COMPILER)
579 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
580 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
581 if ((__INTEL_COMPILER % 10) != 0)
582 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
583 #ifdef __INTEL_COMPILER_BUILD_DATE
584 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
585 __INTEL_COMPILER_BUILD_DATE / 10000,
586 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
587 __INTEL_COMPILER_BUILD_DATE % 100);
588 #endif /* __INTEL_COMPILER_BUILD_DATE */
589 g_string_append_printf(str, "\n");
590 #elif defined(_MSC_FULL_VER)
591 if (_MSC_FULL_VER > 99999999) {
592 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
593 (_MSC_FULL_VER / 10000000) - 6,
594 (_MSC_FULL_VER / 100000) % 100);
595 if ((_MSC_FULL_VER % 100000) != 0)
596 g_string_append_printf(str, " build %d",
597 _MSC_FULL_VER % 100000);
599 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
600 (_MSC_FULL_VER / 1000000) - 6,
601 (_MSC_FULL_VER / 10000) % 100);
602 if ((_MSC_FULL_VER % 10000) != 0)
603 g_string_append_printf(str, " build %d",
604 _MSC_FULL_VER % 10000);
606 g_string_append_printf(str, "\n");
607 #elif defined(_MSC_VER)
608 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
609 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
610 (_MSC_VER / 100) - 6, _MSC_VER % 100);
611 #elif defined(__SUNPRO_C)
612 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
613 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
614 if ((__SUNPRO_C & 0xF) != 0)
615 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
616 g_string_append_printf(str, "\n");
623 * Get copyright information.
626 get_copyright_info(void)
629 "Copyright 1998-2009 Gerald Combs <gerald@wireshark.org> and contributors.\n"
630 "This is free software; see the source for copying conditions. There is NO\n"
631 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
636 * Get the major OS version.
638 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
640 get_os_major_version()
643 info.dwOSVersionInfoSize = sizeof info;
644 if (GetVersionEx(&info)) {
645 return info.dwMajorVersion;
657 * indent-tabs-mode: t
660 * ex: set shiftwidth=8 tabstop=8 noexpandtab
661 * :indentSize=8:tabSize=8:noTabs=false: