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 "epan/unicode-utils.h"
64 #include "svnversion.h"
78 #ifdef HAVE_OS_X_FRAMEWORKS
79 #include <CoreServices/CoreServices.h>
83 # include <sys/capability.h>
87 const char *wireshark_svnversion = " (" SVNVERSION ")";
89 const char *wireshark_svnversion = "";
93 * If the string doesn't end with a newline, append one.
94 * Then word-wrap it to 80 columns.
97 end_string(GString *str)
102 point = strlen(str->str);
103 if (point == 0 || str->str[point - 1] != '\n')
104 g_string_append(str, "\n");
110 * Break at or before this point.
113 while (q > p && *q != ' ')
123 * Get various library compile-time versions and append them to
124 * the specified GString.
126 * "additional_info" is called at the end to append any additional
127 * information; this is required in order to, for example, put the
128 * Portaudio information at the end of the string, as we currently
129 * don't use Portaudio in TShark.
132 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
135 g_string_append(str, "with ");
136 g_string_append_printf(str,
137 #ifdef GLIB_MAJOR_VERSION
138 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
141 "GLib (version unknown)");
145 g_string_append(str, ", ");
146 get_compiled_pcap_version(str);
149 g_string_append(str, ", ");
151 g_string_append(str, "with libz ");
153 g_string_append(str, ZLIB_VERSION);
154 #else /* ZLIB_VERSION */
155 g_string_append(str, "(version unknown)");
156 #endif /* ZLIB_VERSION */
157 #else /* HAVE_LIBZ */
158 g_string_append(str, "without libz");
159 #endif /* HAVE_LIBZ */
162 g_string_append(str, ", ");
164 g_string_append(str, "with POSIX capabilities");
165 #ifdef _LINUX_CAPABILITY_VERSION
166 g_string_append(str, " (Linux)");
167 #endif /* _LINUX_CAPABILITY_VERSION */
168 #else /* HAVE_LIBCAP */
169 g_string_append(str, "without POSIX capabilities");
170 #endif /* HAVE_LIBCAP */
172 /* Additional application-dependent information */
174 (*additional_info)(str);
175 g_string_append(str, ".");
179 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
180 g_string_append(str, ".");
181 #endif /* HAVE_LIBPCRE */
187 * Get compile-time information used only by applications that use
191 get_epan_compiled_version_info(GString *str)
194 g_string_append(str, ", ");
196 g_string_append(str, "with libpcre ");
199 g_string_append_printf(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
200 #else /* PCRE_MINOR */
201 g_string_append_printf(str, "%u", PCRE_MAJOR);
202 #endif /* PCRE_MINOR */
203 #else /* PCRE_MAJOR */
204 g_string_append(str, "(version unknown)");
205 #endif /* PCRE_MAJOR */
206 #else /* HAVE_LIBPCRE */
207 g_string_append(str, "without libpcre");
208 #endif /* HAVE_LIBPCRE */
211 g_string_append(str, ", ");
213 g_string_append(str, "with SMI ");
214 g_string_append(str, SMI_VERSION_STRING);
215 #else /* no SNMP library */
216 g_string_append(str, "without SMI");
220 g_string_append(str, ", ");
222 g_string_append(str, "with ADNS");
224 g_string_append(str, "without ADNS");
225 #endif /* HAVE_GNU_ADNS */
228 g_string_append(str, ", ");
230 g_string_append(str, "with ");
231 g_string_append(str, LUA_VERSION);
233 g_string_append(str, "without Lua");
234 #endif /* HAVE_LUA_5_1 */
237 g_string_append(str, ", ");
238 #ifdef HAVE_LIBGNUTLS
239 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
241 g_string_append(str, "without GnuTLS");
242 #endif /* HAVE_LIBGNUTLS */
245 g_string_append(str, ", ");
246 #ifdef HAVE_LIBGCRYPT
247 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
249 g_string_append(str, "without Gcrypt");
250 #endif /* HAVE_LIBGCRYPT */
253 /* XXX - I don't see how to get the version number, at least for KfW */
254 g_string_append(str, ", ");
256 #ifdef HAVE_MIT_KERBEROS
257 g_string_append(str, "with MIT Kerberos");
259 /* HAVE_HEIMDAL_KERBEROS */
260 g_string_append(str, "with Heimdal Kerberos");
263 g_string_append(str, "without Kerberos");
264 #endif /* HAVE_KERBEROS */
268 * Get various library run-time versions, and the OS version, and append
269 * them to the specified GString.
272 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
276 #elif defined(HAVE_SYS_UTSNAME_H)
279 #if HAVE_OS_X_FRAMEWORKS
280 long macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
283 g_string_append(str, "on ");
289 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
291 * for more than you ever wanted to know about determining the
292 * flavor of Windows on which you're running. Implementing more
293 * of that is left as an exercise to the reader - who should
294 * check any copyright information about code samples on MSDN
295 * before cutting and pasting into Wireshark.
297 * They should also note that you need an OSVERSIONINFOEX structure
298 * to get some of that information, and that not only is that
299 * structure not supported on older versions of Windows, you might
300 * not even be able to compile code that *uses* that structure with
301 * older versions of the SDK.
303 info.dwOSVersionInfoSize = sizeof info;
304 if (!GetVersionEx(&info)) {
306 * XXX - get the failure reason.
308 g_string_append(str, "unknown Windows version");
311 switch (info.dwPlatformId) {
313 case VER_PLATFORM_WIN32s:
315 g_string_append_printf(str, "Windows 3.1 with Win32s");
318 case VER_PLATFORM_WIN32_WINDOWS:
320 switch (info.dwMajorVersion) {
323 /* 3 cheers for Microsoft marketing! */
324 switch (info.dwMinorVersion) {
327 g_string_append_printf(str, "Windows 95");
331 g_string_append_printf(str, "Windows 98");
335 g_string_append_printf(str, "Windows Me");
339 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
340 info.dwMajorVersion, info.dwMinorVersion);
346 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
347 info.dwMajorVersion, info.dwMinorVersion);
352 case VER_PLATFORM_WIN32_NT:
354 switch (info.dwMajorVersion) {
358 g_string_append_printf(str, "Windows NT %lu.%lu",
359 info.dwMajorVersion, info.dwMinorVersion);
363 /* 3 cheers for Microsoft marketing! */
364 switch (info.dwMinorVersion) {
367 g_string_append_printf(str, "Windows 2000");
371 g_string_append_printf(str, "Windows XP");
375 g_string_append_printf(str, "Windows Server 2003");
379 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
380 info.dwMajorVersion, info.dwMinorVersion);
386 g_string_append_printf(str, "Windows Vista");
390 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
391 info.dwMajorVersion, info.dwMinorVersion);
397 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
398 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
401 if (info.szCSDVersion[0] != '\0')
402 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
403 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
404 #elif defined(HAVE_SYS_UTSNAME_H)
406 * We have <sys/utsname.h>, so we assume we have "uname()".
408 if (uname(&name) < 0) {
409 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
414 if (strcmp(name.sysname, "AIX") == 0) {
416 * Yay, IBM! Thanks for doing something different
417 * from most of the other UNIXes out there, and
418 * making "name.version" apparently be the major
419 * version number and "name.release" be the minor
422 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
426 * XXX - get "version" on any other platforms?
428 * On Digital/Tru65 UNIX, it's something unknown.
429 * On Solaris, it's some kind of build information.
430 * On HP-UX, it appears to be some sort of subrevision
433 g_string_append_printf(str, "%s %s", name.sysname, name.release);
434 #ifdef HAVE_OS_X_FRAMEWORKS
435 Gestalt(gestaltSystemVersion, &macosx_ver);
437 /* The following functions are only available in MacOS 10.4+ */
438 if(macosx_ver >= 0x1040) {
439 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
440 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
441 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
443 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
448 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
450 /* See Apple's Gestalt Manager Reference for meanings
451 * of the macosx_ver values. */
453 #endif /* HAVE_OS_X_FRAMEWORKS */
456 g_string_append(str, "an unknown OS");
460 g_string_append(str, ", ");
461 get_runtime_pcap_version(str);
463 /* Additional application-dependent information */
465 (*additional_info)(str);
467 g_string_append(str, ".");
472 * See http://predef.sourceforge.net/precomp.html for
473 * information on various defined strings.
475 * GCC's __VERSION__ is a nice text string for humans to
476 * read. The page at predef.sourceforge.net largely
477 * describes numeric #defines that encode the version;
478 * if the compiler doesn't also offer a nice printable
479 * string, we should probably prettify the number somehow.
481 #if defined(__GNUC__) && defined(__VERSION__)
482 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
483 #elif defined(__HP_aCC)
484 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
485 #elif defined(__xlC__)
486 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
487 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
489 if ((__IBMC__ % 10) != 0)
490 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
491 #endif /* __IBMC__ */
492 g_string_append_printf(str, "\n");
493 #elif defined(__INTEL_COMPILER)
494 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
495 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
496 if ((__INTEL_COMPILER % 10) != 0)
497 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
498 #ifdef __INTEL_COMPILER_BUILD_DATE
499 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
500 __INTEL_COMPILER_BUILD_DATE / 10000,
501 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
502 __INTEL_COMPILER_BUILD_DATE % 100);
503 #endif /* __INTEL_COMPILER_BUILD_DATE */
504 g_string_append_printf(str, "\n");
505 #elif defined(_MSC_FULL_VER)
506 if (_MSC_FULL_VER > 99999999) {
507 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
508 (_MSC_FULL_VER / 10000000) - 6,
509 (_MSC_FULL_VER / 100000) % 100);
510 if ((_MSC_FULL_VER % 100000) != 0)
511 g_string_append_printf(str, " build %d",
512 _MSC_FULL_VER % 100000);
514 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
515 (_MSC_FULL_VER / 1000000) - 6,
516 (_MSC_FULL_VER / 10000) % 100);
517 if ((_MSC_FULL_VER % 10000) != 0)
518 g_string_append_printf(str, " build %d",
519 _MSC_FULL_VER % 10000);
521 g_string_append_printf(str, "\n");
522 #elif defined(_MSC_VER)
523 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
524 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
525 (_MSC_VER / 100) - 6, _MSC_VER % 100);
526 #elif defined(__SUNPRO_C)
527 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
528 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
529 if ((__SUNPRO_C & 0xF) != 0)
530 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
531 g_string_append_printf(str, "\n");
538 * Get copyright information.
541 get_copyright_info(void)
544 "Copyright 1998-2008 Gerald Combs <gerald@wireshark.org> and contributors.\n"
545 "This is free software; see the source for copying conditions. There is NO\n"
546 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
551 * Get the major OS version.
553 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
555 get_os_major_version()
558 info.dwOSVersionInfoSize = sizeof info;
559 if (GetVersionEx(&info)) {
560 return info.dwMajorVersion;
572 * indent-tabs-mode: tabs
575 * ex: set shiftwidth=8 tabstop=8 noexpandtab
576 * :indentSize=8:tabSize=8:noTabs=false: