2 * Routines to report version information for stuff used by Ethereal
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
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.
31 #endif /* HAVE_LIBPCAP */
40 #include <zlib.h> /* to get the libz version number */
44 #include <pcre.h> /* to get the libpcre version number */
45 #endif /* HAVE_LIBPCRE */
48 * This has to come after the include of <pcap.h>, as the include of
49 * <pcap.h> might cause <winsock2.h> to be included, and if we've
50 * already included <winsock.h> as a result of including <windows.h>,
51 * we get a bunch of redefinitions.
60 #include <net-snmp/version.h>
61 #endif /* HAVE_NET_SNMP */
64 #include <ucd-snmp/version.h>
65 #endif /* HAVE_UCD_SNMP */
67 #endif /* HAVE_SOME_SNMP */
69 #ifdef HAVE_SYS_UTSNAME_H
70 #include <sys/utsname.h>
73 #include "version_info.h"
74 #include "capture-pcap-util.h"
76 #include "svnversion.h"
79 const char *svnversion = " (" SVNVERSION ")";
81 const char *svnversion = "";
85 * See whether the last line in the string goes past column 80; if so,
86 * replace the blank at the specified point with a newline.
89 do_word_wrap(GString *str, gint point)
93 line_begin = strrchr(str->str, '\n');
94 if (line_begin == NULL)
95 line_begin = str->str;
98 if (strlen(line_begin) > 80) {
99 g_assert(str->str[point] == ' ');
100 str->str[point] = '\n';
105 * If the string doesn't end with a newline, append one.
108 end_string(GString *str)
112 point = strlen(str->str);
113 if (point == 0 || str->str[point - 1] != '\n')
114 g_string_append(str, "\n");
118 * Get various library compile-time versions and append them to
119 * the specified GString.
122 get_compiled_version_info(GString *str)
126 g_string_append(str, "with ");
127 g_string_sprintfa(str,
128 #ifdef GLIB_MAJOR_VERSION
129 "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
132 "GLib (version unknown),");
135 g_string_append(str, " ");
136 break_point = str->len - 1;
137 get_compiled_pcap_version(str);
138 g_string_append(str, ",");
139 do_word_wrap(str, break_point);
141 g_string_append(str, " ");
142 break_point = str->len - 1;
144 g_string_append(str, "with libz ");
146 g_string_append(str, ZLIB_VERSION);
147 #else /* ZLIB_VERSION */
148 g_string_append(str, "(version unknown)");
149 #endif /* ZLIB_VERSION */
150 #else /* HAVE_LIBZ */
151 g_string_append(str, "without libz");
152 #endif /* HAVE_LIBZ */
153 g_string_append(str, ",");
154 do_word_wrap(str, break_point);
156 g_string_append(str, " ");
157 break_point = str->len - 1;
159 g_string_append(str, "with libpcre ");
162 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
163 #else /* PCRE_MINOR */
164 g_string_sprintfa(str, "%u", PCRE_MAJOR);
165 #endif /* PCRE_MINOR */
166 #else /* PCRE_MAJOR */
167 g_string_append(str, "(version unknown)");
168 #endif /* PCRE_MAJOR */
169 #else /* HAVE_LIBPCRE */
170 g_string_append(str, "without libpcre");
171 #endif /* HAVE_LIBPCRE */
173 g_string_append(str, ",");
174 do_word_wrap(str, break_point);
176 /* Oh, this is pretty. */
177 /* Oh, ha. you think that was pretty. Try this:! --Wes */
178 g_string_append(str, " ");
179 break_point = str->len - 1;
180 #ifdef HAVE_SOME_SNMP
183 g_string_append(str, "with UCD-SNMP ");
184 g_string_append(str, VersionInfo);
185 #endif /* HAVE_UCD_SNMP */
188 g_string_append(str, "with Net-SNMP ");
189 g_string_append(str, netsnmp_get_version());
190 #endif /* HAVE_NET_SNMP */
192 #else /* no SNMP library */
193 g_string_append(str, "without UCD-SNMP or Net-SNMP");
194 #endif /* HAVE_SOME_SNMP */
195 g_string_append(str, ",");
196 do_word_wrap(str, break_point);
198 g_string_append(str, " ");
199 break_point = str->len - 1;
201 g_string_append(str, "with ADNS");
203 g_string_append(str, "without ADNS");
204 #endif /* HAVE_GNU_ADNS */
206 g_string_append(str, ".");
207 do_word_wrap(str, break_point);
210 break_point = str->len - 1;
212 "\nNOTE: this build doesn't support the \"matches\" operator for Ethereal filter"
214 do_word_wrap(str, break_point);
215 #endif /* HAVE_LIBPCRE */
221 * Get various library run-time versions, and the OS version, and append
222 * them to the specified GString.
225 get_runtime_version_info(GString *str)
229 #elif defined(HAVE_SYS_UTSNAME_H)
233 get_runtime_pcap_version(str);
235 g_string_append(str, "on ");
240 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
242 * for more than you ever wanted to know about determining the
243 * flavor of Windows on which you're running. Implementing more
244 * of that is left as an exercise to the reader - who should
245 * check any copyright information about code samples on MSDN
246 * before cutting and pasting into Ethereal.
248 * They should also note that you need an OSVERSIONINFOEX structure
249 * to get some of that information, and that not only is that
250 * structure not supported on older versions of Windows, you might
251 * not even be able to compile code that *uses* that structure with
252 * older versions of the SDK.
254 info.dwOSVersionInfoSize = sizeof info;
255 if (!GetVersionEx(&info)) {
257 * XXX - get the failure reason.
259 g_string_append(str, "unknown Windows version");
262 switch (info.dwPlatformId) {
264 case VER_PLATFORM_WIN32s:
266 g_string_sprintfa(str, "Windows 3.1 with Win32s");
269 case VER_PLATFORM_WIN32_WINDOWS:
271 switch (info.dwMajorVersion) {
274 /* 3 cheers for Microsoft marketing! */
275 switch (info.dwMinorVersion) {
278 g_string_sprintfa(str, "Windows 95");
282 g_string_sprintfa(str, "Windows 98");
286 g_string_sprintfa(str, "Windows Me");
290 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
291 info.dwMajorVersion, info.dwMinorVersion);
297 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
298 info.dwMajorVersion, info.dwMinorVersion);
303 case VER_PLATFORM_WIN32_NT:
305 switch (info.dwMajorVersion) {
309 g_string_sprintfa(str, "Windows NT %lu.%lu",
310 info.dwMajorVersion, info.dwMinorVersion);
314 /* 3 cheers for Microsoft marketing! */
315 switch (info.dwMinorVersion) {
318 g_string_sprintfa(str, "Windows 2000");
322 g_string_sprintfa(str, "Windows XP");
326 g_string_sprintfa(str, "Windows Server 2003");
330 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
331 info.dwMajorVersion, info.dwMinorVersion);
337 g_string_sprintfa(str, "Windows Vista");
341 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
342 info.dwMajorVersion, info.dwMinorVersion);
348 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
349 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
352 if (info.szCSDVersion[0] != '\0')
353 g_string_sprintfa(str, " %s", info.szCSDVersion);
354 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
355 #elif defined(HAVE_SYS_UTSNAME_H)
357 * We have <sys/utsname.h>, so we assume we have "uname()".
359 if (uname(&name) < 0) {
360 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
365 if (strcmp(name.sysname, "AIX") == 0) {
367 * Yay, IBM! Thanks for doing something different
368 * from most of the other UNIXes out there, and
369 * making "name.version" apparently be the major
370 * version number and "name.release" be the minor
373 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
377 * XXX - get "version" on any other platforms?
379 * On Digital/Tru65 UNIX, it's something unknown.
380 * On Solaris, it's some kind of build information.
381 * On HP-UX, it appears to be some sort of subrevision
384 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
387 g_string_append(str, "an unknown OS");
389 g_string_append(str, ".");
395 * Get copyright information.
398 get_copyright_info(void)
401 "Copyright 1998-2006 Gerald Combs <gerald@ethereal.com> and contributors.\n"
402 "This is free software; see the source for copying conditions. There is NO\n"
403 "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n";