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 const char *wireshark_svnversion = " (" SVNVERSION ")";
93 const char *wireshark_svnversion = "";
97 * If the string doesn't end with a newline, append one.
98 * Then word-wrap it to 80 columns.
101 end_string(GString *str)
106 point = strlen(str->str);
107 if (point == 0 || str->str[point - 1] != '\n')
108 g_string_append(str, "\n");
114 * Break at or before this point.
117 while (q > p && *q != ' ')
127 * Get various library compile-time versions and append them to
128 * the specified GString.
130 * "additional_info" is called at the end to append any additional
131 * information; this is required in order to, for example, put the
132 * Portaudio information at the end of the string, as we currently
133 * don't use Portaudio in TShark.
136 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
139 g_string_append(str, "with ");
140 g_string_append_printf(str,
141 #ifdef GLIB_MAJOR_VERSION
142 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
145 "GLib (version unknown)");
149 g_string_append(str, ", ");
150 get_compiled_pcap_version(str);
153 g_string_append(str, ", ");
155 g_string_append(str, "with libz ");
157 g_string_append(str, ZLIB_VERSION);
158 #else /* ZLIB_VERSION */
159 g_string_append(str, "(version unknown)");
160 #endif /* ZLIB_VERSION */
161 #else /* HAVE_LIBZ */
162 g_string_append(str, "without libz");
163 #endif /* HAVE_LIBZ */
166 g_string_append(str, ", ");
168 g_string_append(str, "with POSIX capabilities");
169 #ifdef _LINUX_CAPABILITY_VERSION
170 g_string_append(str, " (Linux)");
171 #endif /* _LINUX_CAPABILITY_VERSION */
172 #else /* HAVE_LIBCAP */
173 g_string_append(str, "without POSIX capabilities");
174 #endif /* HAVE_LIBCAP */
176 /* Additional application-dependent information */
178 (*additional_info)(str);
179 g_string_append(str, ".");
183 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
184 g_string_append(str, ".");
185 #endif /* HAVE_LIBPCRE */
191 * Get compile-time information used only by applications that use
195 get_epan_compiled_version_info(GString *str)
198 g_string_append(str, ", ");
200 g_string_append(str, "with libpcre ");
203 g_string_append_printf(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
204 #else /* PCRE_MINOR */
205 g_string_append_printf(str, "%u", PCRE_MAJOR);
206 #endif /* PCRE_MINOR */
207 #else /* PCRE_MAJOR */
208 g_string_append(str, "(version unknown)");
209 #endif /* PCRE_MAJOR */
210 #else /* HAVE_LIBPCRE */
211 g_string_append(str, "without libpcre");
212 #endif /* HAVE_LIBPCRE */
215 g_string_append(str, ", ");
217 g_string_append(str, "with SMI ");
218 g_string_append(str, SMI_VERSION_STRING);
219 #else /* no SNMP library */
220 g_string_append(str, "without SMI");
224 g_string_append(str, ", ");
226 g_string_append(str, "with c-ares ");
227 g_string_append(str, ARES_VERSION_STR);
229 g_string_append(str, "without c-ares");
230 #endif /* HAVE_C_ARES */
233 g_string_append(str, ", ");
235 g_string_append(str, "with ADNS");
237 g_string_append(str, "without ADNS");
238 #endif /* HAVE_GNU_ADNS */
241 g_string_append(str, ", ");
243 g_string_append(str, "with ");
244 g_string_append(str, LUA_VERSION);
246 g_string_append(str, "without Lua");
247 #endif /* HAVE_LUA_5_1 */
250 g_string_append(str, ", ");
251 #ifdef HAVE_LIBGNUTLS
252 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
254 g_string_append(str, "without GnuTLS");
255 #endif /* HAVE_LIBGNUTLS */
258 g_string_append(str, ", ");
259 #ifdef HAVE_LIBGCRYPT
260 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
262 g_string_append(str, "without Gcrypt");
263 #endif /* HAVE_LIBGCRYPT */
266 /* XXX - I don't see how to get the version number, at least for KfW */
267 g_string_append(str, ", ");
269 #ifdef HAVE_MIT_KERBEROS
270 g_string_append(str, "with MIT Kerberos");
272 /* HAVE_HEIMDAL_KERBEROS */
273 g_string_append(str, "with Heimdal Kerberos");
276 g_string_append(str, "without Kerberos");
277 #endif /* HAVE_KERBEROS */
281 * Get various library run-time versions, and the OS version, and append
282 * them to the specified GString.
285 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
289 #elif defined(HAVE_SYS_UTSNAME_H)
292 #if HAVE_OS_X_FRAMEWORKS
293 long macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
296 g_string_append(str, "on ");
302 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
304 * for more than you ever wanted to know about determining the
305 * flavor of Windows on which you're running. Implementing more
306 * of that is left as an exercise to the reader - who should
307 * check any copyright information about code samples on MSDN
308 * before cutting and pasting into Wireshark.
310 * They should also note that you need an OSVERSIONINFOEX structure
311 * to get some of that information, and that not only is that
312 * structure not supported on older versions of Windows, you might
313 * not even be able to compile code that *uses* that structure with
314 * older versions of the SDK.
316 info.dwOSVersionInfoSize = sizeof info;
317 if (!GetVersionEx(&info)) {
319 * XXX - get the failure reason.
321 g_string_append(str, "unknown Windows version");
324 switch (info.dwPlatformId) {
326 case VER_PLATFORM_WIN32s:
328 g_string_append_printf(str, "Windows 3.1 with Win32s");
331 case VER_PLATFORM_WIN32_WINDOWS:
333 switch (info.dwMajorVersion) {
336 /* 3 cheers for Microsoft marketing! */
337 switch (info.dwMinorVersion) {
340 g_string_append_printf(str, "Windows 95");
344 g_string_append_printf(str, "Windows 98");
348 g_string_append_printf(str, "Windows Me");
352 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
353 info.dwMajorVersion, info.dwMinorVersion);
359 g_string_append_printf(str, "Windows OT, unknown version %lu.%lu",
360 info.dwMajorVersion, info.dwMinorVersion);
365 case VER_PLATFORM_WIN32_NT:
367 switch (info.dwMajorVersion) {
371 g_string_append_printf(str, "Windows NT %lu.%lu",
372 info.dwMajorVersion, info.dwMinorVersion);
376 /* 3 cheers for Microsoft marketing! */
377 switch (info.dwMinorVersion) {
380 g_string_append_printf(str, "Windows 2000");
384 g_string_append_printf(str, "Windows XP");
388 g_string_append_printf(str, "Windows Server 2003");
392 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
393 info.dwMajorVersion, info.dwMinorVersion);
399 g_string_append_printf(str, "Windows Vista");
403 g_string_append_printf(str, "Windows NT, unknown version %lu.%lu",
404 info.dwMajorVersion, info.dwMinorVersion);
410 g_string_append_printf(str, "Unknown Windows platform %lu version %lu.%lu",
411 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
414 if (info.szCSDVersion[0] != '\0')
415 g_string_append_printf(str, " %s", utf_16to8(info.szCSDVersion));
416 g_string_append_printf(str, ", build %lu", info.dwBuildNumber);
417 #elif defined(HAVE_SYS_UTSNAME_H)
419 * We have <sys/utsname.h>, so we assume we have "uname()".
421 if (uname(&name) < 0) {
422 g_string_append_printf(str, "unknown OS version (uname failed - %s)",
427 if (strcmp(name.sysname, "AIX") == 0) {
429 * Yay, IBM! Thanks for doing something different
430 * from most of the other UNIXes out there, and
431 * making "name.version" apparently be the major
432 * version number and "name.release" be the minor
435 g_string_append_printf(str, "%s %s.%s", name.sysname, name.version,
439 * XXX - get "version" on any other platforms?
441 * On Digital/Tru64 UNIX, it's something unknown.
442 * On Solaris, it's some kind of build information.
443 * On HP-UX, it appears to be some sort of subrevision
446 g_string_append_printf(str, "%s %s", name.sysname, name.release);
447 #ifdef HAVE_OS_X_FRAMEWORKS
448 Gestalt(gestaltSystemVersion, &macosx_ver);
450 /* The following functions are only available in MacOS 10.4+ */
451 if(macosx_ver >= 0x1040) {
452 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
453 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
454 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
456 g_string_append_printf(str, " (MacOS %ld.%ld.%ld)",
461 g_string_append_printf(str, " (MacOS X < 10.4 [%lx])",
463 /* See Apple's Gestalt Manager Reference for meanings
464 * of the macosx_ver values. */
466 #endif /* HAVE_OS_X_FRAMEWORKS */
469 g_string_append(str, "an unknown OS");
473 g_string_append(str, ", ");
474 get_runtime_pcap_version(str);
476 /* Additional application-dependent information */
478 (*additional_info)(str);
480 g_string_append(str, ".");
485 * See http://predef.sourceforge.net/precomp.html for
486 * information on various defined strings.
488 * GCC's __VERSION__ is a nice text string for humans to
489 * read. The page at predef.sourceforge.net largely
490 * describes numeric #defines that encode the version;
491 * if the compiler doesn't also offer a nice printable
492 * string, we should probably prettify the number somehow.
494 #if defined(__GNUC__) && defined(__VERSION__)
495 g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
496 #elif defined(__HP_aCC)
497 g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
498 #elif defined(__xlC__)
499 g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
500 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
502 if ((__IBMC__ % 10) != 0)
503 g_string_append_printf(str, " patch %d", __IBMC__ % 10);
504 #endif /* __IBMC__ */
505 g_string_append_printf(str, "\n");
506 #elif defined(__INTEL_COMPILER)
507 g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
508 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
509 if ((__INTEL_COMPILER % 10) != 0)
510 g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
511 #ifdef __INTEL_COMPILER_BUILD_DATE
512 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
513 __INTEL_COMPILER_BUILD_DATE / 10000,
514 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
515 __INTEL_COMPILER_BUILD_DATE % 100);
516 #endif /* __INTEL_COMPILER_BUILD_DATE */
517 g_string_append_printf(str, "\n");
518 #elif defined(_MSC_FULL_VER)
519 if (_MSC_FULL_VER > 99999999) {
520 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
521 (_MSC_FULL_VER / 10000000) - 6,
522 (_MSC_FULL_VER / 100000) % 100);
523 if ((_MSC_FULL_VER % 100000) != 0)
524 g_string_append_printf(str, " build %d",
525 _MSC_FULL_VER % 100000);
527 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
528 (_MSC_FULL_VER / 1000000) - 6,
529 (_MSC_FULL_VER / 10000) % 100);
530 if ((_MSC_FULL_VER % 10000) != 0)
531 g_string_append_printf(str, " build %d",
532 _MSC_FULL_VER % 10000);
534 g_string_append_printf(str, "\n");
535 #elif defined(_MSC_VER)
536 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
537 g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
538 (_MSC_VER / 100) - 6, _MSC_VER % 100);
539 #elif defined(__SUNPRO_C)
540 g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
541 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
542 if ((__SUNPRO_C & 0xF) != 0)
543 g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
544 g_string_append_printf(str, "\n");
551 * Get copyright information.
554 get_copyright_info(void)
557 "Copyright 1998-2008 Gerald Combs <gerald@wireshark.org> and contributors.\n"
558 "This is free software; see the source for copying conditions. There is NO\n"
559 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
564 * Get the major OS version.
566 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
568 get_os_major_version()
571 info.dwOSVersionInfoSize = sizeof info;
572 if (GetVersionEx(&info)) {
573 return info.dwMajorVersion;
585 * indent-tabs-mode: tabs
588 * ex: set shiftwidth=8 tabstop=8 noexpandtab
589 * :indentSize=8:tabSize=8:noTabs=false: