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.
36 #include <zlib.h> /* to get the libz version number */
40 #include <pcre.h> /* to get the libpcre version number */
41 #endif /* HAVE_LIBPCRE */
46 #include <net-snmp/version.h>
47 #endif /* HAVE_NET_SNMP */
50 #include <ucd-snmp/version.h>
51 #endif /* HAVE_UCD_SNMP */
53 #endif /* HAVE_SOME_SNMP */
55 #if (defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBGNUTLS)) && defined(_WIN32)
56 #include <winposixtype.h>
61 #endif /* HAVE_LIBGCRYPT */
64 #include <gnutls/gnutls.h>
65 #endif /* HAVE_LIBGNUTLS */
67 #ifdef HAVE_SYS_UTSNAME_H
68 #include <sys/utsname.h>
71 #include "version_info.h"
72 #include "capture-pcap-util.h"
73 #include "epan/unicode-utils.h"
75 #include "svnversion.h"
86 const char *svnversion = " (" SVNVERSION ")";
88 const char *svnversion = "";
92 * If the string doesn't end with a newline, append one.
93 * Then word-wrap it to 80 columns.
96 end_string(GString *str)
101 point = strlen(str->str);
102 if (point == 0 || str->str[point - 1] != '\n')
103 g_string_append(str, "\n");
109 * Break at or before this point.
112 while (q > p && *q != ' ')
122 * Get various library compile-time versions and append them to
123 * the specified GString.
125 * "additional_info" is called at the end to append any additional
126 * information; this is required in order to, for example, put the
127 * Portaudio information at the end of the string, as we currently
128 * don't use Portaudio in TShark.
131 get_compiled_version_info(GString *str, void (*additional_info)(GString *))
134 g_string_append(str, "with ");
135 g_string_sprintfa(str,
136 #ifdef GLIB_MAJOR_VERSION
137 "GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
140 "GLib (version unknown)");
144 g_string_append(str, ", ");
145 get_compiled_pcap_version(str);
148 g_string_append(str, ", ");
150 g_string_append(str, "with libz ");
152 g_string_append(str, ZLIB_VERSION);
153 #else /* ZLIB_VERSION */
154 g_string_append(str, "(version unknown)");
155 #endif /* ZLIB_VERSION */
156 #else /* HAVE_LIBZ */
157 g_string_append(str, "without libz");
158 #endif /* HAVE_LIBZ */
160 /* Additional application-dependent information */
162 (*additional_info)(str);
163 g_string_append(str, ".");
167 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter syntax");
168 g_string_append(str, ".");
169 #endif /* HAVE_LIBPCRE */
175 * Get compile-time information used only by applications that use
179 get_epan_compiled_version_info(GString *str)
182 g_string_append(str, ", ");
184 g_string_append(str, "with libpcre ");
187 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
188 #else /* PCRE_MINOR */
189 g_string_sprintfa(str, "%u", PCRE_MAJOR);
190 #endif /* PCRE_MINOR */
191 #else /* PCRE_MAJOR */
192 g_string_append(str, "(version unknown)");
193 #endif /* PCRE_MAJOR */
194 #else /* HAVE_LIBPCRE */
195 g_string_append(str, "without libpcre");
196 #endif /* HAVE_LIBPCRE */
199 g_string_append(str, ", ");
200 /* Oh, this is pretty. */
201 /* Oh, ha. you think that was pretty. Try this:! --Wes */
202 #ifdef HAVE_SOME_SNMP
205 g_string_append(str, "with UCD-SNMP ");
206 g_string_append(str, VersionInfo);
207 #endif /* HAVE_UCD_SNMP */
210 g_string_append(str, "with Net-SNMP ");
211 g_string_append(str, netsnmp_get_version());
212 #endif /* HAVE_NET_SNMP */
214 #else /* no SNMP library */
215 g_string_append(str, "without UCD-SNMP or Net-SNMP");
216 #endif /* HAVE_SOME_SNMP */
219 g_string_append(str, ", ");
221 g_string_append(str, "with ADNS");
223 g_string_append(str, "without ADNS");
224 #endif /* HAVE_GNU_ADNS */
227 g_string_append(str, ", ");
229 g_string_append(str, "with ");
230 g_string_append(str, LUA_VERSION);
232 g_string_append(str, "without Lua");
233 #endif /* HAVE_LUA */
236 g_string_append(str, ", ");
237 #ifdef HAVE_LIBGNUTLS
238 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
240 g_string_append(str, "without GnuTLS");
241 #endif /* HAVE_LIBGNUTLS */
244 g_string_append(str, ", ");
245 #ifdef HAVE_LIBGCRYPT
246 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
248 g_string_append(str, "without Gcrypt");
249 #endif /* HAVE_LIBGCRYPT */
252 /* XXX - I don't see how to get the version number, at least for KfW */
253 g_string_append(str, ", ");
255 #ifdef HAVE_MIT_KERBEROS
256 g_string_append(str, "with MIT Kerberos");
258 /* HAVE_HEIMDAL_KERBEROS */
259 g_string_append(str, "with Heimdal Kerberos");
262 g_string_append(str, "without Kerberos");
263 #endif /* HAVE_KERBEROS */
267 * Get various library run-time versions, and the OS version, and append
268 * them to the specified GString.
271 get_runtime_version_info(GString *str, void (*additional_info)(GString *))
275 #elif defined(HAVE_SYS_UTSNAME_H)
279 g_string_append(str, "on ");
285 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
287 * for more than you ever wanted to know about determining the
288 * flavor of Windows on which you're running. Implementing more
289 * of that is left as an exercise to the reader - who should
290 * check any copyright information about code samples on MSDN
291 * before cutting and pasting into Wireshark.
293 * They should also note that you need an OSVERSIONINFOEX structure
294 * to get some of that information, and that not only is that
295 * structure not supported on older versions of Windows, you might
296 * not even be able to compile code that *uses* that structure with
297 * older versions of the SDK.
299 info.dwOSVersionInfoSize = sizeof info;
300 if (!GetVersionEx(&info)) {
302 * XXX - get the failure reason.
304 g_string_append(str, "unknown Windows version");
307 switch (info.dwPlatformId) {
309 case VER_PLATFORM_WIN32s:
311 g_string_sprintfa(str, "Windows 3.1 with Win32s");
314 case VER_PLATFORM_WIN32_WINDOWS:
316 switch (info.dwMajorVersion) {
319 /* 3 cheers for Microsoft marketing! */
320 switch (info.dwMinorVersion) {
323 g_string_sprintfa(str, "Windows 95");
327 g_string_sprintfa(str, "Windows 98");
331 g_string_sprintfa(str, "Windows Me");
335 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
336 info.dwMajorVersion, info.dwMinorVersion);
342 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
343 info.dwMajorVersion, info.dwMinorVersion);
348 case VER_PLATFORM_WIN32_NT:
350 switch (info.dwMajorVersion) {
354 g_string_sprintfa(str, "Windows NT %lu.%lu",
355 info.dwMajorVersion, info.dwMinorVersion);
359 /* 3 cheers for Microsoft marketing! */
360 switch (info.dwMinorVersion) {
363 g_string_sprintfa(str, "Windows 2000");
367 g_string_sprintfa(str, "Windows XP");
371 g_string_sprintfa(str, "Windows Server 2003");
375 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
376 info.dwMajorVersion, info.dwMinorVersion);
382 g_string_sprintfa(str, "Windows Vista");
386 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
387 info.dwMajorVersion, info.dwMinorVersion);
393 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
394 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
397 if (info.szCSDVersion[0] != '\0')
398 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
399 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
400 #elif defined(HAVE_SYS_UTSNAME_H)
402 * We have <sys/utsname.h>, so we assume we have "uname()".
404 if (uname(&name) < 0) {
405 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
410 if (strcmp(name.sysname, "AIX") == 0) {
412 * Yay, IBM! Thanks for doing something different
413 * from most of the other UNIXes out there, and
414 * making "name.version" apparently be the major
415 * version number and "name.release" be the minor
418 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
422 * XXX - get "version" on any other platforms?
424 * On Digital/Tru65 UNIX, it's something unknown.
425 * On Solaris, it's some kind of build information.
426 * On HP-UX, it appears to be some sort of subrevision
429 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
432 g_string_append(str, "an unknown OS");
436 g_string_append(str, ", ");
437 get_runtime_pcap_version(str);
439 /* Additional application-dependent information */
441 (*additional_info)(str);
443 g_string_append(str, ".");
448 * See http://predef.sourceforge.net/precomp.html for
449 * information on various defined strings.
451 * GCC's __VERSION__ is a nice text string for humans to
452 * read. The page at predef.sourceforge.net largely
453 * describes numeric #defines that encode the version;
454 * if the compiler doesn't also offer a nice printable
455 * string, we should probably prettify the number somehow.
457 #if defined(__GNUC__) && defined(__VERSION__)
458 g_string_sprintfa(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
459 #elif defined(__HP_aCC)
460 g_string_sprintfa(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
461 #elif defined(__xlC__)
462 g_string_sprintfa(str, "\n\nBuilt using IBM XL C %d.%d\n",
463 (__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
465 if ((__IBMC__ % 10) != 0)
466 g_string_sprintfa(str, " patch %d", __IBMC__ % 10);
467 #endif /* __IBMC__ */
468 g_string_sprintfa(str, "\n");
469 #elif defined(__INTEL_COMPILER)
470 g_string_sprintfa(str, "\n\nBuilt using Intel C %d.%d",
471 __INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
472 if ((__INTEL_COMPILER % 10) != 0)
473 g_string_sprintfa(str, " patch %d", __INTEL_COMPILER % 10);
474 #ifdef __INTEL_COMPILER_BUILD_DATE
475 g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
476 __INTEL_COMPILER_BUILD_DATE / 10000,
477 (__INTEL_COMPILER_BUILD_DATE / 100) % 100,
478 __INTEL_COMPILER_BUILD_DATE % 100);
479 #endif /* __INTEL_COMPILER_BUILD_DATE */
480 g_string_sprintfa(str, "\n");
481 #elif defined(_MSC_FULL_VER)
482 if (_MSC_FULL_VER > 99999999) {
483 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
484 (_MSC_FULL_VER / 10000000) - 6,
485 (_MSC_FULL_VER / 100000) % 100);
486 if ((_MSC_FULL_VER % 100000) != 0)
487 g_string_sprintfa(str, " build %d",
488 _MSC_FULL_VER % 100000);
490 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
491 (_MSC_FULL_VER / 1000000) - 6,
492 (_MSC_FULL_VER / 10000) % 100);
493 if ((_MSC_FULL_VER % 10000) != 0)
494 g_string_sprintfa(str, " build %d",
495 _MSC_FULL_VER % 10000);
497 g_string_sprintfa(str, "\n");
498 #elif defined(_MSC_VER)
499 /* _MSC_FULL_VER not defined, but _MSC_VER defined */
500 g_string_sprintfa(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
501 (_MSC_VER / 100) - 6, _MSC_VER % 100);
502 #elif defined(__SUNPRO_C)
503 g_string_sprintfa(str, "\n\nBuilt using Sun C %d.%d",
504 (__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
505 if ((__SUNPRO_C & 0xF) != 0)
506 g_string_sprintfa(str, " patch %d", __SUNPRO_C & 0xF);
507 g_string_sprintfa(str, "\n");
514 * Get copyright information.
517 get_copyright_info(void)
520 "Copyright 1998-2006 Gerald Combs <gerald@wireshark.org> and contributors.\n"
521 "This is free software; see the source for copying conditions. There is NO\n"
522 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";