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 ")";
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 #elif defined(HAVE_SYS_UTSNAME_H)
317 #if HAVE_OS_X_FRAMEWORKS
318 SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
321 g_string_append(str, "on ");
327 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
329 * for more than you ever wanted to know about determining the
330 * flavor of Windows on which you're running. Implementing more
331 * of that is left as an exercise to the reader - who should
332 * check any copyright information about code samples on MSDN
333 * before cutting and pasting into Wireshark.
335 * They should also note that you need an OSVERSIONINFOEX structure
336 * to get some of that information, and that not only is that
337 * structure not supported on older versions of Windows, you might
338 * not even be able to compile code that *uses* that structure with
339 * older versions of the SDK.
341 info.dwOSVersionInfoSize = sizeof info;
342 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
344 * XXX - get the failure reason.
346 g_string_append(str, "unknown Windows version");
349 switch (info.dwPlatformId) {
351 case VER_PLATFORM_WIN32s:
353 g_string_append_printf(str, "Windows 3.1 with Win32s");
356 case VER_PLATFORM_WIN32_WINDOWS:
358 switch (info.dwMajorVersion) {
361 /* 3 cheers for Microsoft marketing! */
362 switch (info.dwMinorVersion) {
365 g_string_append_printf(str, "Windows 95");
369 g_string_append_printf(str, "Windows 98");
373 g_string_append_printf(str, "Windows Me");
377 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
378 info.dwMajorVersion, info.dwMinorVersion);
384 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
385 info.dwMajorVersion, info.dwMinorVersion);
390 case VER_PLATFORM_WIN32_NT:
392 switch (info.dwMajorVersion) {
396 g_string_append_printf(str, "Windows NT %lu.%lu",
397 info.dwMajorVersion, info.dwMinorVersion);
401 /* 3 cheers for Microsoft marketing! */
402 switch (info.dwMinorVersion) {
405 g_string_append_printf(str, "Windows 2000");
409 g_string_append_printf(str, "Windows XP");
413 g_string_append_printf(str, "Windows Server 2003");
417 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
418 info.dwMajorVersion, info.dwMinorVersion);
424 #ifndef VER_NT_WORKSTATION
425 #define VER_NT_WORKSTATION 0x01
426 if ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION)
428 if (info.wProductType == VER_NT_WORKSTATION)
430 g_string_append_printf(str, "Windows Vista");
432 g_string_append_printf(str, "Windows Server 2008");
436 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
437 info.dwMajorVersion, info.dwMinorVersion);
443 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
444 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
447 if (info.szCSDVersion[0] != '\0')
448 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
449 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
450 #elif defined(HAVE_SYS_UTSNAME_H)
452 * We have <sys/utsname.h>, so we assume we have "uname()".
454 if (uname(&name) < 0) {
455 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
460 if (strcmp(name.sysname, "AIX") == 0) {
462 * Yay, IBM! Thanks for doing something different
463 * from most of the other UNIXes out there, and
464 * making "name.version" apparently be the major
465 * version number and "name.release" be the minor
468 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
472 * XXX - get "version" on any other platforms?
474 * On Digital/Tru64 UNIX, it's something unknown.
475 * On Solaris, it's some kind of build information.
476 * On HP-UX, it appears to be some sort of subrevision
479 g_string_append_printf(str, "%s %s", name.sysname, name.release);
480 #ifdef HAVE_OS_X_FRAMEWORKS
481 Gestalt(gestaltSystemVersion, &macosx_ver);
483 /* The following functions are only available in MacOS 10.4+ */
484 if(macosx_ver >= 0x1040) {
485 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
486 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
487 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
489 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
490 (long)macosx_major_ver,
491 (long)macosx_minor_ver,
492 (long)macosx_bugfix_ver);
494 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
496 /* See Apple's Gestalt Manager Reference for meanings
497 * of the macosx_ver values. */
499 #endif /* HAVE_OS_X_FRAMEWORKS */
502 g_string_append(str, "an unknown OS");
506 g_string_append(str, ", ");
507 get_runtime_pcap_version(str);
510 #ifdef HAVE_LIBGNUTLS
511 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
512 #endif /* HAVE_LIBGNUTLS */
515 #ifdef HAVE_LIBGCRYPT
516 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
517 #endif /* HAVE_LIBGCRYPT */
519 /* Additional application-dependent information */
521 (*additional_info)(str);
523 g_string_append(str, ".");
528 * See http://predef.sourceforge.net/precomp.html for
529 * information on various defined strings.
531 * GCC's __VERSION__ is a nice text string for humans to
532 * read. The page at predef.sourceforge.net largely
533 * describes numeric #defines that encode the version;
534 * if the compiler doesn't also offer a nice printable
535 * string, we should probably prettify the number somehow.
537 #if defined(__GNUC__) && defined(__VERSION__)
538 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
539 #elif defined(__HP_aCC)
540 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
541 #elif defined(__xlC__)
542 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
543 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
545 if ((__IBMC__ % 10) != 0)
546 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
547 #endif /* __IBMC__ */
548 g_string_append_printf(str, "\n");
549 #elif defined(__INTEL_COMPILER)
550 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
551 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
552 if ((__INTEL_COMPILER % 10) != 0)
553 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
554 #ifdef __INTEL_COMPILER_BUILD_DATE
555 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
556 __INTEL_COMPILER_BUILD_DATE / 10000,
557 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
558 __INTEL_COMPILER_BUILD_DATE % 100);
559 #endif /* __INTEL_COMPILER_BUILD_DATE */
560 g_string_append_printf(str, "\n");
561 #elif defined(_MSC_FULL_VER)
562 if (_MSC_FULL_VER > 99999999) {
563 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
564 (_MSC_FULL_VER / 10000000) - 6,
565 (_MSC_FULL_VER / 100000) % 100);
566 if ((_MSC_FULL_VER % 100000) != 0)
567 g_string_append_printf(str, " build %d",
568 _MSC_FULL_VER % 100000);
570 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
571 (_MSC_FULL_VER / 1000000) - 6,
572 (_MSC_FULL_VER / 10000) % 100);
573 if ((_MSC_FULL_VER % 10000) != 0)
574 g_string_append_printf(str, " build %d",
575 _MSC_FULL_VER % 10000);
577 g_string_append_printf(str, "\n");
578 #elif defined(_MSC_VER)
579 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
580 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
581 (_MSC_VER / 100) - 6, _MSC_VER % 100);
582 #elif defined(__SUNPRO_C)
583 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
584 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
585 if ((__SUNPRO_C & 0xF) != 0)
586 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
587 g_string_append_printf(str, "\n");
594 * Get copyright information.
597 get_copyright_info(void)
600 "Copyright 1998-2009 Gerald Combs <gerald@wireshark.org> and contributors.\n"
601 "This is free software; see the source for copying conditions. There is NO\n"
602 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
607 * Get the major OS version.
609 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
611 get_os_major_version()
614 info.dwOSVersionInfoSize = sizeof info;
615 if (GetVersionEx(&info)) {
616 return info.dwMajorVersion;
628 * indent-tabs-mode: t
631 * ex: set shiftwidth=8 tabstop=8 noexpandtab
632 * :indentSize=8:tabSize=8:noTabs=false: