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 const char *wireshark_svnversion = " (" SVNVERSION ")";
85 const char *wireshark_svnversion = "";
89 * If the string doesn't end with a newline, append one.
90 * Then word-wrap it to 80 columns.
93 end_string(GString *str)
98 point = strlen(str->str);
99 if (point == 0 || str->str[point - 1] != '\n')
100 g_string_append(str, "\n");
106 * Break at or before this point.
109 while (q > p && *q != ' ')
119 * Get various library compile-time versions and append them to
120 * the specified GString.
122 * "additional_info" is called at the end to append any additional
123 * information; this is required in order to, for example, put the
124 * Portaudio information at the end of the string, as we currently
125 * don't use Portaudio in TShark.
128 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
131 g_string_append(str, "with ");
132 g_string_sprintfa(str,
133 #ifdef GLIB_MAJOR_VERSION
134 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
137 "GLib (version unknown)");
141 g_string_append(str, ", ");
142 get_compiled_pcap_version(str);
145 g_string_append(str, ", ");
147 g_string_append(str, "with libz ");
149 g_string_append(str, ZLIB_VERSION);
150 #else /* ZLIB_VERSION */
151 g_string_append(str, "(version unknown)");
152 #endif /* ZLIB_VERSION */
153 #else /* HAVE_LIBZ */
154 g_string_append(str, "without libz");
155 #endif /* HAVE_LIBZ */
157 /* Additional application-dependent information */
159 (*additional_info)(str);
160 g_string_append(str, ".");
164 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
165 g_string_append(str, ".");
166 #endif /* HAVE_LIBPCRE */
172 * Get compile-time information used only by applications that use
176 get_epan_compiled_version_info(GString *str)
179 g_string_append(str, ", ");
181 g_string_append(str, "with libpcre ");
184 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
185 #else /* PCRE_MINOR */
186 g_string_sprintfa(str, "%u", PCRE_MAJOR);
187 #endif /* PCRE_MINOR */
188 #else /* PCRE_MAJOR */
189 g_string_append(str, "(version unknown)");
190 #endif /* PCRE_MAJOR */
191 #else /* HAVE_LIBPCRE */
192 g_string_append(str, "without libpcre");
193 #endif /* HAVE_LIBPCRE */
196 g_string_append(str, ", ");
198 g_string_append(str, "with SMI ");
199 g_string_append(str, SMI_VERSION_STRING);
200 #else /* no SNMP library */
201 g_string_append(str, "without SMI");
205 g_string_append(str, ", ");
207 g_string_append(str, "with ADNS");
209 g_string_append(str, "without ADNS");
210 #endif /* HAVE_GNU_ADNS */
213 g_string_append(str, ", ");
215 g_string_append(str, "with ");
216 g_string_append(str, LUA_VERSION);
218 g_string_append(str, "without Lua");
219 #endif /* HAVE_LUA_5_1 */
222 g_string_append(str, ", ");
223 #ifdef HAVE_LIBGNUTLS
224 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
226 g_string_append(str, "without GnuTLS");
227 #endif /* HAVE_LIBGNUTLS */
230 g_string_append(str, ", ");
231 #ifdef HAVE_LIBGCRYPT
232 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
234 g_string_append(str, "without Gcrypt");
235 #endif /* HAVE_LIBGCRYPT */
238 /* XXX - I don't see how to get the version number, at least for KfW */
239 g_string_append(str, ", ");
241 #ifdef HAVE_MIT_KERBEROS
242 g_string_append(str, "with MIT Kerberos");
244 /* HAVE_HEIMDAL_KERBEROS */
245 g_string_append(str, "with Heimdal Kerberos");
248 g_string_append(str, "without Kerberos");
249 #endif /* HAVE_KERBEROS */
253 * Get various library run-time versions, and the OS version, and append
254 * them to the specified GString.
257 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
261 #elif defined(HAVE_SYS_UTSNAME_H)
264 #if HAVE_OS_X_FRAMEWORKS
265 long macosx_ver, macosx_major_ver, macosx_minor_ver, macosx_bugfix_ver;
268 g_string_append(str, "on ");
274 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
276 * for more than you ever wanted to know about determining the
277 * flavor of Windows on which you're running. Implementing more
278 * of that is left as an exercise to the reader - who should
279 * check any copyright information about code samples on MSDN
280 * before cutting and pasting into Wireshark.
282 * They should also note that you need an OSVERSIONINFOEX structure
283 * to get some of that information, and that not only is that
284 * structure not supported on older versions of Windows, you might
285 * not even be able to compile code that *uses* that structure with
286 * older versions of the SDK.
288 info.dwOSVersionInfoSize = sizeof info;
289 if (!GetVersionEx(&info)) {
291 * XXX - get the failure reason.
293 g_string_append(str, "unknown Windows version");
296 switch (info.dwPlatformId) {
298 case VER_PLATFORM_WIN32s:
300 g_string_sprintfa(str, "Windows 3.1 with Win32s");
303 case VER_PLATFORM_WIN32_WINDOWS:
305 switch (info.dwMajorVersion) {
308 /* 3 cheers for Microsoft marketing! */
309 switch (info.dwMinorVersion) {
312 g_string_sprintfa(str, "Windows 95");
316 g_string_sprintfa(str, "Windows 98");
320 g_string_sprintfa(str, "Windows Me");
324 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
325 info.dwMajorVersion, info.dwMinorVersion);
331 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
332 info.dwMajorVersion, info.dwMinorVersion);
337 case VER_PLATFORM_WIN32_NT:
339 switch (info.dwMajorVersion) {
343 g_string_sprintfa(str, "Windows NT %lu.%lu",
344 info.dwMajorVersion, info.dwMinorVersion);
348 /* 3 cheers for Microsoft marketing! */
349 switch (info.dwMinorVersion) {
352 g_string_sprintfa(str, "Windows 2000");
356 g_string_sprintfa(str, "Windows XP");
360 g_string_sprintfa(str, "Windows Server 2003");
364 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
365 info.dwMajorVersion, info.dwMinorVersion);
371 g_string_sprintfa(str, "Windows Vista");
375 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
376 info.dwMajorVersion, info.dwMinorVersion);
382 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
383 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
386 if (info.szCSDVersion[0] != '\0')
387 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
388 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
389 #elif defined(HAVE_SYS_UTSNAME_H)
391 * We have <sys/utsname.h>, so we assume we have "uname()".
393 if (uname(&name) < 0) {
394 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
399 if (strcmp(name.sysname, "AIX") == 0) {
401 * Yay, IBM! Thanks for doing something different
402 * from most of the other UNIXes out there, and
403 * making "name.version" apparently be the major
404 * version number and "name.release" be the minor
407 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
411 * XXX - get "version" on any other platforms?
413 * On Digital/Tru65 UNIX, it's something unknown.
414 * On Solaris, it's some kind of build information.
415 * On HP-UX, it appears to be some sort of subrevision
418 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
419 #ifdef HAVE_OS_X_FRAMEWORKS
420 Gestalt(gestaltSystemVersion, &macosx_ver);
422 /* The following functions are only available in MacOS 10.4+ */
423 if(macosx_ver >= 0x1040) {
424 Gestalt(gestaltSystemVersionMajor, &macosx_major_ver);
425 Gestalt(gestaltSystemVersionMinor, &macosx_minor_ver);
426 Gestalt(gestaltSystemVersionBugFix, &macosx_bugfix_ver);
428 g_string_sprintfa(str, " (MacOS %ld.%ld.%ld)",
433 g_string_sprintfa(str, " (MacOS X < 10.4 [%lx])",
435 /* See Apple's Gestalt Manager Reference for meanings
436 * of the macosx_ver values. */
438 #endif /* HAVE_OS_X_FRAMEWORKS */
441 g_string_append(str, "an unknown OS");
445 g_string_append(str, ", ");
446 get_runtime_pcap_version(str);
448 /* Additional application-dependent information */
450 (*additional_info)(str);
452 g_string_append(str, ".");
457 * See http://predef.sourceforge.net/precomp.html for
458 * information on various defined strings.
460 * GCC's __VERSION__ is a nice text string for humans to
461 * read. The page at predef.sourceforge.net largely
462 * describes numeric #defines that encode the version;
463 * if the compiler doesn't also offer a nice printable
464 * string, we should probably prettify the number somehow.
466 #if defined(__GNUC__) && defined(__VERSION__)
467 g_string_sprintfa(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
468 #elif defined(__HP_aCC)
469 g_string_sprintfa(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
470 #elif defined(__xlC__)
471 g_string_sprintfa(str, "\n\nBuilt using IBM XL C %d.%d\n",
472 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
474 if ((__IBMC__ % 10) != 0)
475 g_string_sprintfa(str, " patch %d", __IBMC__ % 10);
476 #endif /* __IBMC__ */
477 g_string_sprintfa(str, "\n");
478 #elif defined(__INTEL_COMPILER)
479 g_string_sprintfa(str, "\n\nBuilt using Intel C %d.%d",
480 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
481 if ((__INTEL_COMPILER % 10) != 0)
482 g_string_sprintfa(str, " patch %d", __INTEL_COMPILER % 10);
483 #ifdef __INTEL_COMPILER_BUILD_DATE
484 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
485 __INTEL_COMPILER_BUILD_DATE / 10000,
486 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
487 __INTEL_COMPILER_BUILD_DATE % 100);
488 #endif /* __INTEL_COMPILER_BUILD_DATE */
489 g_string_sprintfa(str, "\n");
490 #elif defined(_MSC_FULL_VER)
491 if (_MSC_FULL_VER > 99999999) {
492 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
493 (_MSC_FULL_VER / 10000000) - 6,
494 (_MSC_FULL_VER / 100000) % 100);
495 if ((_MSC_FULL_VER % 100000) != 0)
496 g_string_sprintfa(str, " build %d",
497 _MSC_FULL_VER % 100000);
499 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
500 (_MSC_FULL_VER / 1000000) - 6,
501 (_MSC_FULL_VER / 10000) % 100);
502 if ((_MSC_FULL_VER % 10000) != 0)
503 g_string_sprintfa(str, " build %d",
504 _MSC_FULL_VER % 10000);
506 g_string_sprintfa(str, "\n");
507 #elif defined(_MSC_VER)
508 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
509 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
510 (_MSC_VER / 100) - 6, _MSC_VER % 100);
511 #elif defined(__SUNPRO_C)
512 g_string_sprintfa(str, "\n\nBuilt using Sun C %d.%d",
513 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
514 if ((__SUNPRO_C & 0xF) != 0)
515 g_string_sprintfa(str, " patch %d", __SUNPRO_C & 0xF);
516 g_string_sprintfa(str, "\n");
523 * Get copyright information.
526 get_copyright_info(void)
529 "Copyright 1998-2008 Gerald Combs <gerald@wireshark.org> and contributors.\n"
530 "This is free software; see the source for copying conditions. There is NO\n"
531 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";
536 * Get the major OS version.
538 /* XXX - Should this return the minor version as well, e.g. 0x00050002? */
540 get_os_major_version()
543 info.dwOSVersionInfoSize = sizeof info;
544 if (GetVersionEx(&info)) {
545 return info.dwMajorVersion;
557 * indent-tabs-mode: tabs
560 * ex: set shiftwidth=8 tabstop=8 noexpandtab
561 * :indentSize=8:tabSize=8:noTabs=false: