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 = "";
86 * See whether the last line in the string goes past column 80; if so,
87 * replace the blank at the specified point with a newline.
90 do_word_wrap(GString *str, gint point)
94 line_begin = strrchr(str->str, '\n');
95 if (line_begin == NULL)
96 line_begin = str->str;
99 if (strlen(line_begin) > 80) {
100 g_assert(str->str[point] == ' ');
101 str->str[point] = '\n';
106 * Get various library compile-time versions and append them to
107 * the specified GString.
110 get_compiled_version_info(GString *str)
114 g_string_append(str, "with ");
115 g_string_sprintfa(str,
116 #ifdef GLIB_MAJOR_VERSION
117 "GLib %d.%d.%d,", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
120 "GLib (version unknown),");
123 g_string_append(str, " ");
124 break_point = str->len - 1;
125 get_compiled_pcap_version(str);
126 g_string_append(str, ",");
127 do_word_wrap(str, break_point);
129 g_string_append(str, " ");
130 break_point = str->len - 1;
132 g_string_append(str, "with libz ");
134 g_string_append(str, ZLIB_VERSION);
135 #else /* ZLIB_VERSION */
136 g_string_append(str, "(version unknown)");
137 #endif /* ZLIB_VERSION */
138 #else /* HAVE_LIBZ */
139 g_string_append(str, "without libz");
140 #endif /* HAVE_LIBZ */
141 g_string_append(str, ",");
142 do_word_wrap(str, break_point);
144 g_string_append(str, " ");
145 break_point = str->len - 1;
147 g_string_append(str, "with libpcre ");
150 g_string_sprintfa(str, "%u.%u", PCRE_MAJOR, PCRE_MINOR);
151 #else /* PCRE_MINOR */
152 g_string_sprintfa(str, "%u", PCRE_MAJOR);
153 #endif /* PCRE_MINOR */
154 #else /* PCRE_MAJOR */
155 g_string_append(str, "(version unknown)");
156 #endif /* PCRE_MAJOR */
157 #else /* HAVE_LIBPCRE */
158 g_string_append(str, "without libpcre");
159 #endif /* HAVE_LIBPCRE */
161 g_string_append(str, ",");
162 do_word_wrap(str, break_point);
164 /* Oh, this is pretty. */
165 /* Oh, ha. you think that was pretty. Try this:! --Wes */
166 g_string_append(str, " ");
167 break_point = str->len - 1;
168 #ifdef HAVE_SOME_SNMP
171 g_string_append(str, "with UCD-SNMP ");
172 g_string_append(str, VersionInfo);
173 #endif /* HAVE_UCD_SNMP */
176 g_string_append(str, "with Net-SNMP ");
177 g_string_append(str, netsnmp_get_version());
178 #endif /* HAVE_NET_SNMP */
180 #else /* no SNMP library */
181 g_string_append(str, "without UCD-SNMP or Net-SNMP");
182 #endif /* HAVE_SOME_SNMP */
183 g_string_append(str, ",");
184 do_word_wrap(str, break_point);
186 g_string_append(str, " ");
187 break_point = str->len - 1;
189 g_string_append(str, "with ADNS");
191 g_string_append(str, "without ADNS");
192 #endif /* HAVE_GNU_ADNS */
194 g_string_append(str, ".");
195 do_word_wrap(str, break_point);
198 break_point = str->len - 1;
200 "\nNOTE: this build doesn't support the \"matches\" operator for Ethereal filter"
202 do_word_wrap(str, break_point);
203 #endif /* HAVE_LIBPCRE */
207 * Get various library run-time versions, and the OS version, and append
208 * them to the specified GString.
211 get_runtime_version_info(GString *str)
215 #elif defined(HAVE_SYS_UTSNAME_H)
219 get_runtime_pcap_version(str);
221 g_string_append(str, "on ");
226 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getting_the_system_version.asp
228 * for more than you ever wanted to know about determining the
229 * flavor of Windows on which you're running. Implementing more
230 * of that is left as an exercise to the reader - who should
231 * check any copyright information about code samples on MSDN
232 * before cutting and pasting into Ethereal.
234 * They should also note that you need an OSVERSIONINFOEX structure
235 * to get some of that information, and that not only is that
236 * structure not supported on older versions of Windows, you might
237 * not even be able to compile code that *uses* that structure with
238 * older versions of the SDK.
240 info.dwOSVersionInfoSize = sizeof info;
241 if (!GetVersionEx(&info)) {
243 * XXX - get the failure reason.
245 g_string_append(str, "unknown Windows version");
248 switch (info.dwPlatformId) {
250 case VER_PLATFORM_WIN32s:
252 g_string_sprintfa(str, "Windows 3.1 with Win32s");
255 case VER_PLATFORM_WIN32_WINDOWS:
257 switch (info.dwMajorVersion) {
260 /* 3 cheers for Microsoft marketing! */
261 switch (info.dwMinorVersion) {
264 g_string_sprintfa(str, "Windows 95");
268 g_string_sprintfa(str, "Windows 98");
272 g_string_sprintfa(str, "Windows Me");
276 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
277 info.dwMajorVersion, info.dwMinorVersion);
283 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
284 info.dwMajorVersion, info.dwMinorVersion);
289 case VER_PLATFORM_WIN32_NT:
291 switch (info.dwMajorVersion) {
295 g_string_sprintfa(str, "Windows NT %lu.%lu",
296 info.dwMajorVersion, info.dwMinorVersion);
300 /* 3 cheers for Microsoft marketing! */
301 switch (info.dwMinorVersion) {
304 g_string_sprintfa(str, "Windows 2000");
308 g_string_sprintfa(str, "Windows XP");
312 g_string_sprintfa(str, "Windows Server 2003");
316 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
317 info.dwMajorVersion, info.dwMinorVersion);
323 g_string_sprintfa(str, "Windows Vista");
327 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
328 info.dwMajorVersion, info.dwMinorVersion);
334 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
335 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
338 if (info.szCSDVersion[0] != '\0')
339 g_string_sprintfa(str, " %s", info.szCSDVersion);
340 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
341 #elif defined(HAVE_SYS_UTSNAME_H)
343 * We have <sys/utsname.h>, so we assume we have "uname()".
345 if (uname(&name) < 0) {
346 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
351 if (strcmp(name.sysname, "AIX") == 0) {
353 * Yay, IBM! Thanks for doing something different
354 * from most of the other UNIXes out there, and
355 * making "name.version" apparently be the major
356 * version number and "name.release" be the minor
359 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
363 * XXX - get "version" on any other platforms?
365 * On Digital/Tru65 UNIX, it's something unknown.
366 * On Solaris, it's some kind of build information.
367 * On HP-UX, it appears to be some sort of subrevision
370 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
373 g_string_append(str, "an unknown OS");
375 g_string_append(str, ".");