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/strutil.h"
75 #include "svnversion.h"
86 const char *svnversion = " (" SVNVERSION ")";
88 const char *svnversion = "";
92 * See whether the last line in the string goes past column 80; if so,
93 * replace the blank at the specified point with a newline.
96 do_word_wrap(GString *str, gint point)
100 line_begin = strrchr(str->str, '\n');
101 if (line_begin == NULL)
102 line_begin = str->str;
105 if (strlen(line_begin) > 80) {
106 g_assert(str->str[point] == ' ');
107 str->str[point] = '\n';
112 * If the string doesn't end with a newline, append one.
115 end_string(GString *str)
119 point = strlen(str->str);
120 if (point == 0 || str->str[point - 1] != '\n')
121 g_string_append(str, "\n");
125 * Get various library compile-time versions and append them to
126 * the specified GString.
129 get_compiled_version_info(GString *str)
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),");
143 g_string_append(str, " ");
144 break_point = str->len - 1;
145 get_compiled_pcap_version(str);
146 g_string_append(str, ",");
147 do_word_wrap(str, break_point);
150 g_string_append(str, " ");
151 break_point = str->len - 1;
153 g_string_append(str, "with libz ");
155 g_string_append(str, ZLIB_VERSION);
156 #else /* ZLIB_VERSION */
157 g_string_append(str, "(version unknown)");
158 #endif /* ZLIB_VERSION */
159 #else /* HAVE_LIBZ */
160 g_string_append(str, "without libz");
161 #endif /* HAVE_LIBZ */
162 g_string_append(str, ",");
163 do_word_wrap(str, break_point);
166 g_string_append(str, " ");
167 break_point = str->len - 1;
169 g_string_append(str, "with libpcre ");
172 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
173 #else /* PCRE_MINOR */
174 g_string_sprintfa(str, "%u", PCRE_MAJOR);
175 #endif /* PCRE_MINOR */
176 #else /* PCRE_MAJOR */
177 g_string_append(str, "(version unknown)");
178 #endif /* PCRE_MAJOR */
179 #else /* HAVE_LIBPCRE */
180 g_string_append(str, "without libpcre");
181 #endif /* HAVE_LIBPCRE */
183 g_string_append(str, ",");
184 do_word_wrap(str, break_point);
187 /* Oh, this is pretty. */
188 /* Oh, ha. you think that was pretty. Try this:! --Wes */
189 g_string_append(str, " ");
190 break_point = str->len - 1;
191 #ifdef HAVE_SOME_SNMP
194 g_string_append(str, "with UCD-SNMP ");
195 g_string_append(str, VersionInfo);
196 #endif /* HAVE_UCD_SNMP */
199 g_string_append(str, "with Net-SNMP ");
200 g_string_append(str, netsnmp_get_version());
201 #endif /* HAVE_NET_SNMP */
203 #else /* no SNMP library */
204 g_string_append(str, "without UCD-SNMP or Net-SNMP");
205 #endif /* HAVE_SOME_SNMP */
206 g_string_append(str, ",");
207 do_word_wrap(str, break_point);
210 g_string_append(str, " ");
211 break_point = str->len - 1;
213 g_string_append(str, "with ADNS");
215 g_string_append(str, "without ADNS");
216 #endif /* HAVE_GNU_ADNS */
217 g_string_append(str, ",");
218 do_word_wrap(str, break_point);
221 g_string_append(str, " ");
222 break_point = str->len - 1;
224 g_string_append(str, "with ");
225 g_string_append(str, LUA_VERSION);
227 g_string_append(str, "without Lua");
228 #endif /* HAVE_LUA */
229 g_string_append(str, ",");
230 do_word_wrap(str, break_point);
233 g_string_append(str, " ");
234 break_point = str->len - 1;
235 #ifdef HAVE_LIBGNUTLS
236 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
238 g_string_append(str, "without GnuTLS");
239 #endif /* HAVE_LIBGNUTLS */
240 g_string_append(str, ",");
241 do_word_wrap(str, break_point);
244 g_string_append(str, " ");
245 break_point = str->len - 1;
246 #ifdef HAVE_LIBGCRYPT
247 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
249 g_string_append(str, "without Gcrypt");
250 #endif /* HAVE_LIBGCRYPT */
251 g_string_append(str, ",");
252 do_word_wrap(str, break_point);
255 /* XXX - I don't see how to get the version number, at least for KfW */
256 g_string_append(str, " ");
257 break_point = str->len - 1;
259 #ifdef HAVE_MIT_KERBEROS
260 g_string_append(str, "with MIT Kerberos");
262 /* HAVE_HEIMDAL_KERBEROS */
263 g_string_append(str, "with Heimdal Kerberos");
266 g_string_append(str, "without Kerberos");
267 #endif /* HAVE_KERBEROS */
268 g_string_append(str, ".");
269 do_word_wrap(str, break_point);
272 break_point = str->len - 1;
274 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter"
276 do_word_wrap(str, break_point);
277 #endif /* HAVE_LIBPCRE */
283 * Get various library run-time versions, and the OS version, and append
284 * them to the specified GString.
287 get_runtime_version_info(GString *str)
291 #elif defined(HAVE_SYS_UTSNAME_H)
295 get_runtime_pcap_version(str);
297 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_sprintfa(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_sprintfa(str, "Windows 95");
344 g_string_sprintfa(str, "Windows 98");
348 g_string_sprintfa(str, "Windows Me");
352 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
353 info.dwMajorVersion, info.dwMinorVersion);
359 g_string_sprintfa(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_sprintfa(str, "Windows NT %lu.%lu",
372 info.dwMajorVersion, info.dwMinorVersion);
376 /* 3 cheers for Microsoft marketing! */
377 switch (info.dwMinorVersion) {
380 g_string_sprintfa(str, "Windows 2000");
384 g_string_sprintfa(str, "Windows XP");
388 g_string_sprintfa(str, "Windows Server 2003");
392 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
393 info.dwMajorVersion, info.dwMinorVersion);
399 g_string_sprintfa(str, "Windows Vista");
403 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
404 info.dwMajorVersion, info.dwMinorVersion);
410 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
411 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
414 if (info.szCSDVersion[0] != '\0')
415 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
416 g_string_sprintfa(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_sprintfa(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_sprintfa(str, "%s %s.%s", name.sysname, name.version,
439 * XXX - get "version" on any other platforms?
441 * On Digital/Tru65 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_sprintfa(str, "%s %s", name.sysname, name.release);
449 g_string_append(str, "an unknown OS");
451 g_string_append(str, ".");
457 * Get copyright information.
460 get_copyright_info(void)
463 "Copyright 1998-2006 Gerald Combs <gerald@wireshark.org> and contributors.\n"
464 "This is free software; see the source for copying conditions. There is NO\n"
465 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";