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 #ifdef HAVE_LIBPORTAUDIO
72 #include <portaudio.h>
73 #endif /* HAVE_LIBPORTAUDIO */
75 #include "version_info.h"
76 #include "capture-pcap-util.h"
77 #include "epan/strutil.h"
79 #include "svnversion.h"
90 const char *svnversion = " (" SVNVERSION ")";
92 const char *svnversion = "";
96 * See whether the last line in the string goes past column 80; if so,
97 * replace the blank at the specified point with a newline.
100 do_word_wrap(GString *str, gint point)
104 line_begin = strrchr(str->str, '\n');
105 if (line_begin == NULL)
106 line_begin = str->str;
109 if (strlen(line_begin) > 80) {
110 g_assert(str->str[point] == ' ');
111 str->str[point] = '\n';
116 * If the string doesn't end with a newline, append one.
119 end_string(GString *str)
123 point = strlen(str->str);
124 if (point == 0 || str->str[point - 1] != '\n')
125 g_string_append(str, "\n");
129 * Get various library compile-time versions and append them to
130 * the specified GString.
133 get_compiled_version_info(GString *str)
138 g_string_append(str, "with ");
139 g_string_sprintfa(str,
140 #ifdef GLIB_MAJOR_VERSION
141 "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
144 "GLib (version unknown),");
147 g_string_append(str, " ");
148 break_point = str->len - 1;
149 get_compiled_pcap_version(str);
150 g_string_append(str, ",");
151 do_word_wrap(str, break_point);
154 g_string_append(str, " ");
155 break_point = str->len - 1;
157 g_string_append(str, "with libz ");
159 g_string_append(str, ZLIB_VERSION);
160 #else /* ZLIB_VERSION */
161 g_string_append(str, "(version unknown)");
162 #endif /* ZLIB_VERSION */
163 #else /* HAVE_LIBZ */
164 g_string_append(str, "without libz");
165 #endif /* HAVE_LIBZ */
166 g_string_append(str, ",");
167 do_word_wrap(str, break_point);
170 g_string_append(str, " ");
171 break_point = str->len - 1;
173 g_string_append(str, "with libpcre ");
176 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
177 #else /* PCRE_MINOR */
178 g_string_sprintfa(str, "%u", PCRE_MAJOR);
179 #endif /* PCRE_MINOR */
180 #else /* PCRE_MAJOR */
181 g_string_append(str, "(version unknown)");
182 #endif /* PCRE_MAJOR */
183 #else /* HAVE_LIBPCRE */
184 g_string_append(str, "without libpcre");
185 #endif /* HAVE_LIBPCRE */
187 g_string_append(str, ",");
188 do_word_wrap(str, break_point);
191 /* Oh, this is pretty. */
192 /* Oh, ha. you think that was pretty. Try this:! --Wes */
193 g_string_append(str, " ");
194 break_point = str->len - 1;
195 #ifdef HAVE_SOME_SNMP
198 g_string_append(str, "with UCD-SNMP ");
199 g_string_append(str, VersionInfo);
200 #endif /* HAVE_UCD_SNMP */
203 g_string_append(str, "with Net-SNMP ");
204 g_string_append(str, netsnmp_get_version());
205 #endif /* HAVE_NET_SNMP */
207 #else /* no SNMP library */
208 g_string_append(str, "without UCD-SNMP or Net-SNMP");
209 #endif /* HAVE_SOME_SNMP */
210 g_string_append(str, ",");
211 do_word_wrap(str, break_point);
214 g_string_append(str, " ");
215 break_point = str->len - 1;
217 g_string_append(str, "with ADNS");
219 g_string_append(str, "without ADNS");
220 #endif /* HAVE_GNU_ADNS */
221 g_string_append(str, ",");
222 do_word_wrap(str, break_point);
225 g_string_append(str, " ");
226 break_point = str->len - 1;
228 g_string_append(str, "with ");
229 g_string_append(str, LUA_VERSION);
231 g_string_append(str, "without Lua");
232 #endif /* HAVE_LUA */
233 g_string_append(str, ",");
234 do_word_wrap(str, break_point);
237 g_string_append(str, " ");
238 break_point = str->len - 1;
239 #ifdef HAVE_LIBGNUTLS
240 g_string_append(str, "with GnuTLS " LIBGNUTLS_VERSION);
242 g_string_append(str, "without GnuTLS");
243 #endif /* HAVE_LIBGNUTLS */
244 g_string_append(str, ",");
245 do_word_wrap(str, break_point);
248 g_string_append(str, " ");
249 break_point = str->len - 1;
250 #ifdef HAVE_LIBGCRYPT
251 g_string_append(str, "with Gcrypt " GCRYPT_VERSION);
253 g_string_append(str, "without Gcrypt");
254 #endif /* HAVE_LIBGCRYPT */
255 g_string_append(str, ",");
256 do_word_wrap(str, break_point);
259 /* XXX - I don't see how to get the version number, at least for KfW */
260 g_string_append(str, " ");
261 break_point = str->len - 1;
263 #ifdef HAVE_MIT_KERBEROS
264 g_string_append(str, "with MIT Kerberos");
266 /* HAVE_HEIMDAL_KERBEROS */
267 g_string_append(str, "with Heimdal Kerberos");
270 g_string_append(str, "without Kerberos");
271 #endif /* HAVE_KERBEROS */
272 g_string_append(str, ",");
273 do_word_wrap(str, break_point);
276 g_string_append(str, " ");
277 break_point = str->len - 1;
278 #ifdef HAVE_LIBPORTAUDIO
279 #ifdef PORTAUDIO_API_1
280 g_string_append(str, "with PortAudio <= V18");
282 g_string_append(str, "with PortAudio ");
283 g_string_append(str, Pa_GetVersionText());
286 g_string_append(str, "without PortAudio");
287 #endif /* HAVE_LIBPORTAUDIO */
290 g_string_append(str, ".");
291 do_word_wrap(str, break_point);
294 break_point = str->len - 1;
296 "\nNOTE: this build doesn't support the \"matches\" operator for Wireshark filter"
298 do_word_wrap(str, break_point);
299 #endif /* HAVE_LIBPCRE */
305 * Get various library run-time versions, and the OS version, and append
306 * them to the specified GString.
309 get_runtime_version_info(GString *str)
313 #elif defined(HAVE_SYS_UTSNAME_H)
317 get_runtime_pcap_version(str);
319 g_string_append(str, "on ");
324 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
326 * for more than you ever wanted to know about determining the
327 * flavor of Windows on which you're running. Implementing more
328 * of that is left as an exercise to the reader - who should
329 * check any copyright information about code samples on MSDN
330 * before cutting and pasting into Wireshark.
332 * They should also note that you need an OSVERSIONINFOEX structure
333 * to get some of that information, and that not only is that
334 * structure not supported on older versions of Windows, you might
335 * not even be able to compile code that *uses* that structure with
336 * older versions of the SDK.
338 info.dwOSVersionInfoSize = sizeof info;
339 if (!GetVersionEx(&info)) {
341 * XXX - get the failure reason.
343 g_string_append(str, "unknown Windows version");
346 switch (info.dwPlatformId) {
348 case VER_PLATFORM_WIN32s:
350 g_string_sprintfa(str, "Windows 3.1 with Win32s");
353 case VER_PLATFORM_WIN32_WINDOWS:
355 switch (info.dwMajorVersion) {
358 /* 3 cheers for Microsoft marketing! */
359 switch (info.dwMinorVersion) {
362 g_string_sprintfa(str, "Windows 95");
366 g_string_sprintfa(str, "Windows 98");
370 g_string_sprintfa(str, "Windows Me");
374 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
375 info.dwMajorVersion, info.dwMinorVersion);
381 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
382 info.dwMajorVersion, info.dwMinorVersion);
387 case VER_PLATFORM_WIN32_NT:
389 switch (info.dwMajorVersion) {
393 g_string_sprintfa(str, "Windows NT %lu.%lu",
394 info.dwMajorVersion, info.dwMinorVersion);
398 /* 3 cheers for Microsoft marketing! */
399 switch (info.dwMinorVersion) {
402 g_string_sprintfa(str, "Windows 2000");
406 g_string_sprintfa(str, "Windows XP");
410 g_string_sprintfa(str, "Windows Server 2003");
414 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
415 info.dwMajorVersion, info.dwMinorVersion);
421 g_string_sprintfa(str, "Windows Vista");
425 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
426 info.dwMajorVersion, info.dwMinorVersion);
432 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
433 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
436 if (info.szCSDVersion[0] != '\0')
437 g_string_sprintfa(str, " %s", utf_16to8(info.szCSDVersion));
438 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
439 #elif defined(HAVE_SYS_UTSNAME_H)
441 * We have <sys/utsname.h>, so we assume we have "uname()".
443 if (uname(&name) < 0) {
444 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
449 if (strcmp(name.sysname, "AIX") == 0) {
451 * Yay, IBM! Thanks for doing something different
452 * from most of the other UNIXes out there, and
453 * making "name.version" apparently be the major
454 * version number and "name.release" be the minor
457 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
461 * XXX - get "version" on any other platforms?
463 * On Digital/Tru65 UNIX, it's something unknown.
464 * On Solaris, it's some kind of build information.
465 * On HP-UX, it appears to be some sort of subrevision
468 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
471 g_string_append(str, "an unknown OS");
473 g_string_append(str, ".");
479 * Get copyright information.
482 get_copyright_info(void)
485 "Copyright 1998-2006 Gerald Combs <gerald@wireshark.org> and contributors.\n"
486 "This is free software; see the source for copying conditions. There is NO\n"
487 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";