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 <zlib.h> /* to get the libz version number */
41 #include <pcre.h> /* to get the libpcre version number */
42 #endif /* HAVE_LIBPCRE */
44 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
45 #include <winposixtype.h>
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 ")";
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, ".");
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 */
252 g_string_append(str, ", ");
253 #ifdef HAVE_LIBGNUTLS
254 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
256 g_string_append(str, "without GnuTLS");
257 #endif /* HAVE_LIBGNUTLS */
260 g_string_append(str, ", ");
261 #ifdef HAVE_LIBGCRYPT
262 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
264 g_string_append(str, "without Gcrypt");
265 #endif /* HAVE_LIBGCRYPT */
268 /* XXX - I don't see how to get the version number, at least for KfW */
269 g_string_append(str, ", ");
271 #ifdef HAVE_MIT_KERBEROS
272 g_string_append(str, "with MIT Kerberos");
274 /* HAVE_HEIMDAL_KERBEROS */
275 g_string_append(str, "with Heimdal Kerberos");
278 g_string_append(str, "without Kerberos");
279 #endif /* HAVE_KERBEROS */
282 g_string_append(str, ", ");
284 g_string_append(str, "with GeoIP");
286 g_string_append(str, "without GeoIP");
287 #endif /* HAVE_GEOIP */
292 * Get various library run-time versions, and the OS version, and append
293 * them to the specified GString.
296 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
299 OSVERSIONINFOEX info;
300 #elif defined(HAVE_SYS_UTSNAME_H)
303 #if HAVE_OS_X_FRAMEWORKS
304 SInt32 macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
307 g_string_append(str, "on ");
313 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
315 * for more than you ever wanted to know about determining the
316 * flavor of Windows on which you're running. Implementing more
317 * of that is left as an exercise to the reader - who should
318 * check any copyright information about code samples on MSDN
319 * before cutting and pasting into Wireshark.
321 * They should also note that you need an OSVERSIONINFOEX structure
322 * to get some of that information, and that not only is that
323 * structure not supported on older versions of Windows, you might
324 * not even be able to compile code that *uses* that structure with
325 * older versions of the SDK.
327 info.dwOSVersionInfoSize = sizeof info;
328 if (!GetVersionEx((OSVERSIONINFO *)&info)) {
330 * XXX - get the failure reason.
332 g_string_append(str, "unknown Windows version");
335 switch (info.dwPlatformId) {
337 case VER_PLATFORM_WIN32s:
339 g_string_append_printf(str, "Windows 3.1 with Win32s");
342 case VER_PLATFORM_WIN32_WINDOWS:
344 switch (info.dwMajorVersion) {
347 /* 3 cheers for Microsoft marketing! */
348 switch (info.dwMinorVersion) {
351 g_string_append_printf(str, "Windows 95");
355 g_string_append_printf(str, "Windows 98");
359 g_string_append_printf(str, "Windows Me");
363 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
364 info.dwMajorVersion, info.dwMinorVersion);
370 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
371 info.dwMajorVersion, info.dwMinorVersion);
376 case VER_PLATFORM_WIN32_NT:
378 switch (info.dwMajorVersion) {
382 g_string_append_printf(str, "Windows NT %lu.%lu",
383 info.dwMajorVersion, info.dwMinorVersion);
387 /* 3 cheers for Microsoft marketing! */
388 switch (info.dwMinorVersion) {
391 g_string_append_printf(str, "Windows 2000");
395 g_string_append_printf(str, "Windows XP");
399 g_string_append_printf(str, "Windows Server 2003");
403 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
404 info.dwMajorVersion, info.dwMinorVersion);
410 #ifndef VER_NT_WORKSTATION
411 #define VER_NT_WORKSTATION 0x01
412 if ((info.wReserved[1] & 0xff) == VER_NT_WORKSTATION)
414 if (info.wProductType == VER_NT_WORKSTATION)
416 g_string_append_printf(str, "Windows Vista");
418 g_string_append_printf(str, "Windows Server 2008");
422 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
423 info.dwMajorVersion, info.dwMinorVersion);
429 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
430 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
433 if (info.szCSDVersion[0] != '\0')
434 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
435 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
436 #elif defined(HAVE_SYS_UTSNAME_H)
438 * We have <sys/utsname.h>, so we assume we have "uname()".
440 if (uname(&name) < 0) {
441 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
446 if (strcmp(name.sysname, "AIX") == 0) {
448 * Yay, IBM! Thanks for doing something different
449 * from most of the other UNIXes out there, and
450 * making "name.version" apparently be the major
451 * version number and "name.release" be the minor
454 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
458 * XXX - get "version" on any other platforms?
460 * On Digital/Tru64 UNIX, it's something unknown.
461 * On Solaris, it's some kind of build information.
462 * On HP-UX, it appears to be some sort of subrevision
465 g_string_append_printf(str, "%s %s", name.sysname, name.release);
466 #ifdef HAVE_OS_X_FRAMEWORKS
467 Gestalt(gestaltSystemVersion, &macosx_ver);
469 /* The following functions are only available in MacOS 10.4+ */
470 if(macosx_ver >= 0x1040) {
471 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
472 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
473 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
475 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
476 (long)macosx_major_ver,
477 (long)macosx_minor_ver,
478 (long)macosx_bugfix_ver);
480 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
482 /* See Apple's Gestalt Manager Reference for meanings
483 * of the macosx_ver values. */
485 #endif /* HAVE_OS_X_FRAMEWORKS */
488 g_string_append(str, "an unknown OS");
492 g_string_append(str, ", ");
493 get_runtime_pcap_version(str);
496 #ifdef HAVE_LIBGNUTLS
497 g_string_append_printf(str, ", GnuTLS %s", gnutls_check_version(NULL));
498 #endif /* HAVE_LIBGNUTLS */
501 #ifdef HAVE_LIBGCRYPT
502 g_string_append_printf(str, ", Gcrypt %s", gcry_check_version(NULL));
503 #endif /* HAVE_LIBGCRYPT */
505 /* Additional application-dependent information */
507 (*additional_info)(str);
509 g_string_append(str, ".");
514 * See http://predef.sourceforge.net/precomp.html for
515 * information on various defined strings.
517 * GCC's __VERSION__ is a nice text string for humans to
518 * read. The page at predef.sourceforge.net largely
519 * describes numeric #defines that encode the version;
520 * if the compiler doesn't also offer a nice printable
521 * string, we should probably prettify the number somehow.
523 #if defined(__GNUC__) && defined(__VERSION__)
524 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
525 #elif defined(__HP_aCC)
526 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
527 #elif defined(__xlC__)
528 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
529 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
531 if ((__IBMC__ % 10) != 0)
532 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
533 #endif /* __IBMC__ */
534 g_string_append_printf(str, "\n");
535 #elif defined(__INTEL_COMPILER)
536 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
537 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
538 if ((__INTEL_COMPILER % 10) != 0)
539 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
540 #ifdef __INTEL_COMPILER_BUILD_DATE
541 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
542 __INTEL_COMPILER_BUILD_DATE / 10000,
543 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
544 __INTEL_COMPILER_BUILD_DATE % 100);
545 #endif /* __INTEL_COMPILER_BUILD_DATE */
546 g_string_append_printf(str, "\n");
547 #elif defined(_MSC_FULL_VER)
548 if (_MSC_FULL_VER > 99999999) {
549 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
550 (_MSC_FULL_VER / 10000000) - 6,
551 (_MSC_FULL_VER / 100000) % 100);
552 if ((_MSC_FULL_VER % 100000) != 0)
553 g_string_append_printf(str, " build %d",
554 _MSC_FULL_VER % 100000);
556 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
557 (_MSC_FULL_VER / 1000000) - 6,
558 (_MSC_FULL_VER / 10000) % 100);
559 if ((_MSC_FULL_VER % 10000) != 0)
560 g_string_append_printf(str, " build %d",
561 _MSC_FULL_VER % 10000);
563 g_string_append_printf(str, "\n");
564 #elif defined(_MSC_VER)
565 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
566 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
567 (_MSC_VER / 100) - 6, _MSC_VER % 100);
568 #elif defined(__SUNPRO_C)
569 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
570 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
571 if ((__SUNPRO_C & 0xF) != 0)
572 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
573 g_string_append_printf(str, "\n");
580 * Get copyright information.
583 get_copyright_info(void)
586 "Copyright 1998-2009 Gerald Combs <gerald@wireshark.org> and contributors.\n"
587 "This is free software; see the source for copying conditions. There is NO\n"
588 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
593 * Get the major OS version.
595 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
597 get_os_major_version()
600 info.dwOSVersionInfoSize = sizeof info;
601 if (GetVersionEx(&info)) {
602 return info.dwMajorVersion;
614 * indent-tabs-mode: t
617 * ex: set shiftwidth=8 tabstop=8 noexpandtab
618 * :indentSize=8:tabSize=8:noTabs=false: