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 "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 info.dwOSVersionInfoSize = sizeof info;
235 if (!GetVersionEx(&info)) {
237 * XXX - get the failure reason.
239 g_string_append(str, "unknown Windows version");
242 switch (info.dwPlatformId) {
244 case VER_PLATFORM_WIN32s:
246 g_string_sprintfa(str, "Windows 3.1 with Win32s");
249 case VER_PLATFORM_WIN32_WINDOWS:
251 switch (info.dwMajorVersion) {
254 /* 3 cheers for Microsoft marketing! */
255 switch (info.dwMinorVersion) {
258 g_string_sprintfa(str, "Windows 95");
262 g_string_sprintfa(str, "Windows 98");
266 g_string_sprintfa(str, "Windows Me");
270 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
271 info.dwMajorVersion, info.dwMinorVersion);
277 g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu",
278 info.dwMajorVersion, info.dwMinorVersion);
283 case VER_PLATFORM_WIN32_NT:
285 switch (info.dwMajorVersion) {
289 g_string_sprintfa(str, "Windows NT %lu.%lu",
290 info.dwMajorVersion, info.dwMinorVersion);
294 /* 3 cheers for Microsoft marketing! */
295 switch (info.dwMinorVersion) {
298 g_string_sprintfa(str, "Windows 2000");
302 g_string_sprintfa(str, "Windows XP");
307 * The 64-bit version of XP is, I guess,
308 * built on the NT 5.2 code base.
310 if (info.wProductType == VER_NT_WORKSTATION)
311 g_string_sprintfa(str, "Windows XP");
313 g_string_sprintfa(str, "Windows Server 2003");
317 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
318 info.dwMajorVersion, info.dwMinorVersion);
324 if (info.wProductType == VER_NT_WORKSTATION)
325 g_string_sprintfa(str, "Windows Vista");
327 g_string_sprintfa(str, "Windows Server \"Longhorn\"");
331 g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu",
332 info.dwMajorVersion, info.dwMinorVersion);
338 g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu",
339 info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion);
342 if (info.szCSDVersion[0] != '\0')
343 g_string_sprintfa(str, " %s", info.szCSDVersion);
344 g_string_sprintfa(str, ", build %lu", info.dwBuildNumber);
345 #elif defined(HAVE_SYS_UTSNAME_H)
347 * We have <sys/utsname.h>, so we assume we have "uname()".
349 if (uname(&name) < 0) {
350 g_string_sprintfa(str, "unknown OS version (uname failed - %s)",
355 if (strcmp(name.sysname, "AIX") == 0) {
357 * Yay, IBM! Thanks for doing something different
358 * from most of the other UNIXes out there, and
359 * making "name.version" apparently be the major
360 * version number and "name.release" be the minor
363 g_string_sprintfa(str, "%s %s.%s", name.sysname, name.version,
367 * XXX - get "version" on any other platforms?
369 * On Digital/Tru65 UNIX, it's something unknown.
370 * On Solaris, it's some kind of build information.
371 * On HP-UX, it appears to be some sort of subrevision
374 g_string_sprintfa(str, "%s %s", name.sysname, name.release);
377 g_string_append(str, "an unknown OS");
379 g_string_append(str, ".");