1650
|
1 |
diff -urN wine-1.1.13.orig/configure.ac wine-1.1.13/configure.ac
|
|
2 |
--- wine-1.1.13.orig/configure.ac 2009-01-16 17:28:07.000000000 +0100
|
|
3 |
+++ wine-1.1.13/configure.ac 2009-01-24 18:49:24.000000000 +0100
|
|
4 |
@@ -272,9 +272,11 @@
|
1026
|
5 |
getopt.h \
|
1650
|
6 |
grp.h \
|
1026
|
7 |
ieeefp.h \
|
|
8 |
+ inet/ip.h \
|
991
|
9 |
io.h \
|
|
10 |
jack/jack.h \
|
|
11 |
jpeglib.h \
|
|
12 |
+ kstat.h \
|
|
13 |
lber.h \
|
|
14 |
lcms.h \
|
|
15 |
lcms/lcms.h \
|
1650
|
16 |
@@ -319,6 +321,7 @@
|
1026
|
17 |
soundcard.h \
|
|
18 |
stdint.h \
|
|
19 |
strings.h \
|
|
20 |
+ stropts.h \
|
|
21 |
sys/asoundlib.h \
|
|
22 |
sys/cdio.h \
|
|
23 |
sys/elf32.h \
|
1650
|
24 |
@@ -350,10 +353,13 @@
|
991
|
25 |
sys/sockio.h \
|
|
26 |
sys/soundcard.h \
|
|
27 |
sys/statvfs.h \
|
|
28 |
+ sys/stream.h \
|
|
29 |
sys/strtio.h \
|
|
30 |
sys/syscall.h \
|
|
31 |
+ sys/tihdr.h \
|
|
32 |
sys/time.h \
|
|
33 |
sys/times.h \
|
1026
|
34 |
+ sys/tiuser.h \
|
991
|
35 |
sys/uio.h \
|
1026
|
36 |
sys/un.h \
|
1650
|
37 |
sys/utsname.h \
|
|
38 |
@@ -1040,6 +1046,39 @@
|
|
39 |
LIBS="$ac_save_LIBS"
|
991
|
40 |
fi
|
|
41 |
|
1026
|
42 |
+dnl **** Check for Solaris kstat library ***
|
991
|
43 |
+AC_SUBST(KSTATLIBS,"")
|
|
44 |
+if test "$ac_cv_header_kstat_h" = "yes"
|
|
45 |
+then
|
|
46 |
+ AC_CHECK_LIB(kstat, kstat_open,
|
1026
|
47 |
+ [AC_DEFINE(HAVE_KSTAT, 1, [Define if you have the Solaris kstat library and header])
|
991
|
48 |
+ KSTATLIBS="-lkstat"])
|
|
49 |
+fi
|
|
50 |
+
|
1026
|
51 |
+dnl **** Check for STREAMS Transport Provider Interface (TPI) ***
|
|
52 |
+if test "$ac_cv_header_stropts_h" = "yes" -a "$ac_cv_header_sys_stream_h" = "yes" -a \
|
|
53 |
+ "$ac_cv_header_sys_tihdr_h" = "yes" -a "$ac_cv_header_sys_tiuser_h" = "yes" -a \
|
|
54 |
+ "$ac_cv_header_inet_ip_h" = "yes"
|
|
55 |
+then
|
|
56 |
+ AC_CACHE_CHECK([for the STREAMS Transport Provider Interface (TPI)],
|
|
57 |
+ ac_cv_c_streams_tpi,
|
|
58 |
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
59 |
+#include <stropts.h>
|
|
60 |
+#include <sys/stream.h>
|
|
61 |
+#include <sys/tihdr.h>
|
|
62 |
+#include <sys/tiuser.h>
|
|
63 |
+#include <inet/ip.h>
|
|
64 |
+struct T_optmgmt_req *tor = (struct T_optmgmt_req *)NULL;
|
|
65 |
+ ]], [[ioctl(1, I_PUSH, NULL)]])], [ac_cv_c_streams_tpi=yes],[ac_cv_c_streams_tpi=no])
|
|
66 |
+ )
|
|
67 |
+
|
|
68 |
+ if test "$ac_cv_c_streams_tpi" = "yes"
|
|
69 |
+ then
|
|
70 |
+ AC_DEFINE(HAVE_STREAMS_TPI, 1,
|
|
71 |
+ [Define if you have the STREAMS Transport Provider Interface (TPI)])
|
|
72 |
+ fi
|
|
73 |
+fi
|
|
74 |
+
|
991
|
75 |
dnl **** Check for LittleCMS ***
|
|
76 |
AC_SUBST(LCMSLIBS,"")
|
|
77 |
if test "$ac_cv_header_lcms_h" = "yes" -o "$ac_cv_header_lcms_lcms_h" = "yes"
|
1650
|
78 |
diff -urN wine-1.1.13.orig/dlls/iphlpapi/Makefile.in wine-1.1.13/dlls/iphlpapi/Makefile.in
|
|
79 |
--- wine-1.1.13.orig/dlls/iphlpapi/Makefile.in 2009-01-16 17:28:07.000000000 +0100
|
|
80 |
+++ wine-1.1.13/dlls/iphlpapi/Makefile.in 2009-01-24 18:50:35.000000000 +0100
|
991
|
81 |
@@ -5,7 +5,7 @@
|
|
82 |
MODULE = iphlpapi.dll
|
|
83 |
IMPORTLIB = iphlpapi
|
|
84 |
IMPORTS = advapi32 kernel32
|
|
85 |
-EXTRALIBS = @RESOLVLIBS@
|
|
86 |
+EXTRALIBS = @RESOLVLIBS@ @KSTATLIBS@
|
|
87 |
|
|
88 |
C_SRCS = \
|
1288
|
89 |
icmp.c \
|
1650
|
90 |
diff -urN wine-1.1.13.orig/dlls/iphlpapi/ipstats.c wine-1.1.13/dlls/iphlpapi/ipstats.c
|
|
91 |
--- wine-1.1.13.orig/dlls/iphlpapi/ipstats.c 2009-01-16 17:28:07.000000000 +0100
|
|
92 |
+++ wine-1.1.13/dlls/iphlpapi/ipstats.c 2009-01-24 22:01:41.756459359 +0100
|
1265
|
93 |
@@ -1,5 +1,21 @@
|
991
|
94 |
/* Copyright (C) 2003,2006 Juan Lang
|
|
95 |
* Copyright (C) 2007 TransGaming Technologies Inc.
|
|
96 |
+ * Copyright (c) 2008 Albert Lee <[email protected]>
|
|
97 |
+ * Portions derived from netstat.c with the following copyright:
|
|
98 |
+ * Copyright (c) Sun Microsystems, Inc. 1994. All rights reserved.
|
1265
|
99 |
+ *
|
991
|
100 |
+ * License is granted to copy, to use, and to make and to use derivative works
|
|
101 |
+ * for research and evaluation purposes, provided that Sun Microsystems is
|
|
102 |
+ * acknowledged in all documentation pertaining to any such copy or
|
|
103 |
+ * derivative work. Sun Microsystems grants no other licenses expressed or
|
|
104 |
+ * implied. The Sun Microsystems trade name should not be used in any
|
|
105 |
+ * advertising without its written permission.
|
|
106 |
+ *
|
|
107 |
+ * SUN MICROSYSTEMS MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS
|
|
108 |
+ * SOFTWARE FOR ANY PARTICULAR PURPOSE. The software is provided "as is"
|
|
109 |
+ * without express or implied warranty of any kind.
|
|
110 |
+ *
|
|
111 |
+ * These notices must be retained in any copies of any part of this software.
|
1265
|
112 |
*
|
991
|
113 |
* This library is free software; you can redistribute it and/or
|
|
114 |
* modify it under the terms of the GNU Lesser General Public
|
1650
|
115 |
@@ -16,7 +32,7 @@
|
991
|
116 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
117 |
*
|
|
118 |
* This file implements statistics getting using the /proc filesystem exported
|
|
119 |
- * by Linux, and maybe other OSes.
|
1026
|
120 |
+ * by Linux, BSD sysctls, Solaris libkstat, and TPI on platforms with STREAMS.
|
991
|
121 |
*/
|
|
122 |
|
|
123 |
#include "config.h"
|
1650
|
124 |
@@ -102,6 +118,32 @@
|
991
|
125 |
#include <sys/sysctl.h>
|
|
126 |
#endif
|
|
127 |
|
1026
|
128 |
+#ifdef HAVE_KSTAT_H
|
991
|
129 |
+#include <kstat.h>
|
|
130 |
+#endif
|
|
131 |
+
|
1026
|
132 |
+#ifdef HAVE_STROPTS_H
|
|
133 |
+#include <stropts.h>
|
|
134 |
+#ifdef HAVE_SYS_STREAM_H
|
|
135 |
+#include <sys/stream.h>
|
|
136 |
+#endif
|
|
137 |
+#ifdef HAVE_SYS_TIHDR_H
|
|
138 |
+#include <sys/tihdr.h>
|
|
139 |
+#endif
|
|
140 |
+#ifdef HAVE_SYS_TIUSER_H
|
|
141 |
+#include <sys/tiuser.h>
|
|
142 |
+#endif
|
|
143 |
+#ifdef HAVE_INET_IP_H
|
|
144 |
+#include <inet/ip.h>
|
|
145 |
+#ifndef IRE_CACHETABLE
|
|
146 |
+#define IRE_CACHETABLE (IRE_CACHE|IRE_BROADCAST|IRE_LOCAL|IRE_LOOPBACK)
|
|
147 |
+#endif
|
|
148 |
+/* To work around redefined ERR macro */
|
|
149 |
+#undef ERR
|
|
150 |
+#define ERR WINE_ERR
|
|
151 |
+#endif
|
|
152 |
+#endif
|
|
153 |
+
|
991
|
154 |
#ifndef ROUNDUP
|
|
155 |
#define ROUNDUP(a) \
|
|
156 |
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
|
1650
|
157 |
@@ -136,6 +178,180 @@
|
991
|
158 |
|
|
159 |
WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
|
160 |
|
|
161 |
+#ifdef HAVE_KSTAT
|
|
162 |
+struct kstat_mib_map {
|
|
163 |
+ const char *name;
|
|
164 |
+ unsigned int offset;
|
|
165 |
+};
|
|
166 |
+#endif
|
|
167 |
+
|
1026
|
168 |
+#ifdef HAVE_STREAMS_TPI
|
991
|
169 |
+typedef struct mib_item_s {
|
|
170 |
+ struct mib_item_s *next_item;
|
|
171 |
+ long group;
|
|
172 |
+ long mib_id;
|
|
173 |
+ long length;
|
|
174 |
+ char *valp;
|
|
175 |
+} mib_item_t;
|
|
176 |
+
|
|
177 |
+static int mibopen(void);
|
|
178 |
+static mib_item_t *mibget(int sd);
|
|
179 |
+static void mibfree(mib_item_t *);
|
|
180 |
+
|
|
181 |
+static const char mib_dev[] = "/dev/arp";
|
|
182 |
+
|
|
183 |
+static int mibopen(void)
|
|
184 |
+{
|
|
185 |
+ int sd;
|
1026
|
186 |
+ if ((sd = open(mib_dev, O_RDWR)) < 0)
|
|
187 |
+ {
|
991
|
188 |
+ return -1;
|
|
189 |
+ }
|
|
190 |
+
|
|
191 |
+ if ((ioctl(sd, I_PUSH, "tcp") < 0) ||
|
|
192 |
+ (ioctl(sd, I_PUSH, "udp") < 0) ||
|
|
193 |
+ (ioctl(sd, I_PUSH, "icmp") < 0)) {
|
|
194 |
+ close(sd);
|
|
195 |
+ return -1;
|
|
196 |
+ }
|
|
197 |
+
|
|
198 |
+ return sd;
|
|
199 |
+}
|
|
200 |
+
|
|
201 |
+static mib_item_t *
|
1026
|
202 |
+mibget(int sd)
|
991
|
203 |
+{
|
|
204 |
+ char buf[512];
|
|
205 |
+ int flags;
|
|
206 |
+ int j, getcode;
|
|
207 |
+ struct strbuf ctlbuf, databuf;
|
|
208 |
+ struct T_optmgmt_req *tor = (struct T_optmgmt_req *)buf;
|
|
209 |
+ struct T_optmgmt_ack *toa = (struct T_optmgmt_ack *)buf;
|
|
210 |
+ struct T_error_ack *tea = (struct T_error_ack *)buf;
|
|
211 |
+ struct opthdr *req;
|
|
212 |
+ mib_item_t *first_item = NULL;
|
|
213 |
+ mib_item_t *last_item = NULL;
|
|
214 |
+ mib_item_t *temp;
|
|
215 |
+
|
1026
|
216 |
+#ifdef T_SVR4_OPTMGMT_REQ
|
|
217 |
+ tor->PRIM_type = T_SVR4_OPTMGMT_REQ;
|
|
218 |
+#else
|
991
|
219 |
+ tor->PRIM_type = T_OPTMGMT_REQ;
|
1026
|
220 |
+#endif
|
991
|
221 |
+ tor->OPT_offset = sizeof(struct T_optmgmt_req);
|
|
222 |
+ tor->OPT_length = sizeof(struct opthdr);
|
|
223 |
+ tor->MGMT_flags = T_CURRENT;
|
1026
|
224 |
+
|
|
225 |
+ req = (struct opthdr *)(tor + 1);
|
|
226 |
+ req->level = MIB2_IP;
|
|
227 |
+ req->name = req->len = 0;
|
991
|
228 |
+
|
|
229 |
+ ctlbuf.buf = buf;
|
1026
|
230 |
+ ctlbuf.maxlen = sizeof(buf);
|
991
|
231 |
+ ctlbuf.len = tor->OPT_length + tor->OPT_offset;
|
|
232 |
+ flags = 0;
|
1026
|
233 |
+ if (putmsg(sd, &ctlbuf, (struct strbuf *)NULL, flags) == -1)
|
|
234 |
+ {
|
|
235 |
+ ERR ("mibget putmsg(ctl) failed\n");
|
991
|
236 |
+ goto error_exit;
|
|
237 |
+ }
|
1026
|
238 |
+
|
|
239 |
+ req = (struct opthdr *)(toa + 1);
|
|
240 |
+ for (j=1; ; j++)
|
|
241 |
+ {
|
991
|
242 |
+ flags = 0;
|
|
243 |
+ getcode = getmsg(sd, &ctlbuf, (struct strbuf *)NULL, &flags);
|
1026
|
244 |
+ if (getcode == -1)
|
|
245 |
+ {
|
991
|
246 |
+ ERR ("mibget getmsg(ctl) failed\n");
|
|
247 |
+ goto error_exit;
|
|
248 |
+ }
|
|
249 |
+ if (getcode == 0
|
1026
|
250 |
+ && ctlbuf.len >= sizeof(struct T_optmgmt_ack)
|
|
251 |
+ && toa->PRIM_type == T_OPTMGMT_ACK
|
|
252 |
+ && toa->MGMT_flags == T_SUCCESS
|
|
253 |
+ && req->len == 0) {
|
991
|
254 |
+ return first_item; /* this is EOD msg */
|
|
255 |
+ }
|
|
256 |
+
|
|
257 |
+ if (ctlbuf.len >= sizeof(struct T_error_ack)
|
|
258 |
+ && tea->PRIM_type == T_ERROR_ACK) {
|
|
259 |
+ ERR (
|
|
260 |
+ "mibget %d gives (%d) T_ERROR_ACK: TLI_error = 0x%lx, UNIX_error = 0x%lx\n",
|
|
261 |
+ j, getcode, tea->TLI_error, tea->UNIX_error);
|
|
262 |
+ goto error_exit;
|
|
263 |
+ }
|
|
264 |
+
|
|
265 |
+ if (getcode != MOREDATA
|
1026
|
266 |
+ || ctlbuf.len < sizeof(struct T_optmgmt_ack)
|
|
267 |
+ || toa->PRIM_type != T_OPTMGMT_ACK
|
|
268 |
+ || toa->MGMT_flags != T_SUCCESS)
|
|
269 |
+ {
|
991
|
270 |
+ ERR (
|
|
271 |
+ "mibget getmsg(ctl) %d returned %d, ctlbuf.len = %d, PRIM_type = %ld\n",
|
|
272 |
+ j, getcode, ctlbuf.len, toa->PRIM_type);
|
|
273 |
+ if (toa->PRIM_type == T_OPTMGMT_ACK)
|
|
274 |
+ ERR (
|
|
275 |
+ "T_OPTMGMT_ACK: MGMT_flags = 0x%lx, req->len = %ld\n",
|
|
276 |
+ toa->MGMT_flags, req->len);
|
|
277 |
+ goto error_exit;
|
|
278 |
+ }
|
|
279 |
+
|
|
280 |
+ temp = (mib_item_t *)HeapAlloc(GetProcessHeap(), 0, sizeof(mib_item_t));
|
1026
|
281 |
+ if (!temp)
|
|
282 |
+ {
|
991
|
283 |
+ ERR ("mibget malloc failed\n");
|
|
284 |
+ goto error_exit;
|
|
285 |
+ }
|
|
286 |
+ if (last_item)
|
|
287 |
+ last_item->next_item = temp;
|
|
288 |
+ else
|
|
289 |
+ first_item = temp;
|
|
290 |
+ last_item = temp;
|
|
291 |
+ last_item->next_item = NULL;
|
|
292 |
+ last_item->group = req->level;
|
|
293 |
+ last_item->mib_id = req->name;
|
|
294 |
+ last_item->length = req->len;
|
|
295 |
+ last_item->valp = (char *)HeapAlloc(GetProcessHeap(), 0, req->len);
|
|
296 |
+
|
|
297 |
+ databuf.maxlen = last_item->length;
|
|
298 |
+ databuf.buf = last_item->valp;
|
|
299 |
+ databuf.len = 0;
|
|
300 |
+ flags = 0;
|
|
301 |
+ getcode = getmsg(sd, (struct strbuf *)NULL, &databuf, &flags);
|
1026
|
302 |
+ if (getcode == -1)
|
|
303 |
+ {
|
991
|
304 |
+ ERR ("mibget getmsg(data) failed\n");
|
|
305 |
+ goto error_exit;
|
1026
|
306 |
+ } else if (getcode != 0)
|
|
307 |
+ {
|
991
|
308 |
+ ERR (
|
|
309 |
+ "mibget getmsg(data) returned %d, databuf.maxlen = %d, databuf.len = %d\n",
|
|
310 |
+ getcode, databuf.maxlen, databuf.len);
|
|
311 |
+ goto error_exit;
|
|
312 |
+ }
|
|
313 |
+ }
|
|
314 |
+
|
|
315 |
+error_exit:;
|
|
316 |
+ mibfree(first_item);
|
|
317 |
+ return NULL;
|
|
318 |
+}
|
|
319 |
+
|
|
320 |
+static void
|
|
321 |
+mibfree(mib_item_t * first_item)
|
|
322 |
+{
|
|
323 |
+ mib_item_t *last_item;
|
|
324 |
+
|
|
325 |
+ while (first_item) {
|
|
326 |
+ last_item = first_item;
|
|
327 |
+ first_item = first_item->next_item;
|
|
328 |
+ if (last_item->valp)
|
|
329 |
+ HeapFree(GetProcessHeap(), 0, last_item->valp);
|
|
330 |
+ HeapFree(GetProcessHeap(), 0, last_item);
|
|
331 |
+ }
|
|
332 |
+}
|
|
333 |
+#endif
|
|
334 |
+
|
|
335 |
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
|
|
336 |
{
|
1265
|
337 |
#if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_IFLIST)
|
1650
|
338 |
@@ -185,7 +401,73 @@
|
1265
|
339 |
}
|
|
340 |
HeapFree (GetProcessHeap (), 0, buf);
|
|
341 |
return ERROR_NOT_SUPPORTED;
|
|
342 |
-#else
|
|
343 |
+#elif defined(HAVE_KSTAT)
|
1026
|
344 |
+ static const struct kstat_mib_map ifrow_map[] =
|
|
345 |
+ {
|
|
346 |
+ { "rbytes", offsetof(MIB_IFROW, dwInOctets) },
|
|
347 |
+ { "norcvbuf", offsetof(MIB_IFROW, dwInDiscards) },
|
|
348 |
+ { "ierrors", offsetof(MIB_IFROW, dwInErrors) },
|
|
349 |
+ { "unknowns", offsetof(MIB_IFROW, dwInUnknownProtos) },
|
|
350 |
+ { "obytes", offsetof(MIB_IFROW, dwOutOctets) },
|
|
351 |
+ { "noxmtbuf", offsetof(MIB_IFROW, dwOutDiscards) },
|
|
352 |
+ { "oerrors", offsetof(MIB_IFROW, dwOutErrors) },
|
|
353 |
+ { NULL, 0 },
|
|
354 |
+ };
|
1265
|
355 |
+
|
991
|
356 |
+ kstat_ctl_t *kc;
|
|
357 |
+ kstat_t *ksp, *mac_ksp;
|
|
358 |
+ kstat_named_t *knp;
|
1265
|
359 |
+
|
|
360 |
+ if (!name || !entry)
|
|
361 |
+ return ERROR_INVALID_PARAMETER;
|
|
362 |
+
|
991
|
363 |
+ /* get interface stats from driver or mac module
|
|
364 |
+ no outQLen */
|
|
365 |
+ kc = kstat_open();
|
|
366 |
+ ksp = kstat_lookup(kc, NULL, -1, (char *)name);
|
1026
|
367 |
+ if (ksp)
|
|
368 |
+ { /* Check if the interface has a MAC, and use that instead */
|
|
369 |
+ int i;
|
991
|
370 |
+ if ((mac_ksp = kstat_lookup(kc, ksp->ks_module, ksp->ks_instance, (char *)"mac")) != NULL)
|
|
371 |
+ ksp = mac_ksp;
|
|
372 |
+ kstat_read(kc, ksp, NULL);
|
1026
|
373 |
+ for (i = 0; ifrow_map[i].name != NULL; i++)
|
|
374 |
+ {
|
|
375 |
+ if ((knp = kstat_data_lookup(ksp, (char *)ifrow_map[i].name)) != NULL)
|
|
376 |
+ *(DWORD *)((char *)entry + ifrow_map[i].offset) = knp->value.ui32;
|
|
377 |
+ }
|
|
378 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"ifspeed")) != NULL)
|
|
379 |
+ {
|
991
|
380 |
+ entry->dwSpeed = knp->value.ui64;
|
|
381 |
+ /* Windows doesn't believe in 10G Ethernet */
|
|
382 |
+ if (knp->value.ui64 >= ((unsigned long)-1))
|
|
383 |
+ entry->dwSpeed = ((unsigned long)-1);
|
|
384 |
+ }
|
|
385 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"link_up")) != NULL)
|
|
386 |
+ entry->dwOperStatus = knp->value.ui32 ?
|
|
387 |
+ MIB_IF_OPER_STATUS_OPERATIONAL : MIB_IF_OPER_STATUS_DISCONNECTED;
|
|
388 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"multircv")) != NULL)
|
|
389 |
+ entry->dwInNUcastPkts = knp->value.ui32;
|
|
390 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"brdcstrcv")) != NULL)
|
|
391 |
+ entry->dwInNUcastPkts += knp->value.ui32;
|
|
392 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"ipackets")) != NULL)
|
|
393 |
+ entry->dwInUcastPkts = knp->value.ui32 - entry->dwInNUcastPkts;
|
|
394 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"multixmt")) != NULL)
|
|
395 |
+ entry->dwOutNUcastPkts = knp->value.ui32;
|
|
396 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"brdcstxmt")) != NULL)
|
|
397 |
+ entry->dwOutNUcastPkts += knp->value.ui32;
|
|
398 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"opackets")) != NULL)
|
|
399 |
+ entry->dwOutUcastPkts = knp->value.ui32 - entry->dwOutNUcastPkts;
|
|
400 |
+ kstat_close(kc);
|
|
401 |
+ }
|
|
402 |
+ else
|
1265
|
403 |
+ {
|
|
404 |
+ kstat_close(kc);
|
|
405 |
+ return ERROR_NOT_SUPPORTED;
|
|
406 |
+ }
|
|
407 |
+
|
|
408 |
+ return NO_ERROR;
|
991
|
409 |
+#elif defined(__linux__)
|
|
410 |
/* get interface stats from /proc/net/dev, no error if can't
|
|
411 |
no inUnknownProtos, outNUcastPkts, outQLen */
|
1265
|
412 |
FILE *fp;
|
1650
|
413 |
@@ -332,7 +614,68 @@
|
1265
|
414 |
stats->stats.icmpOutStats.dwAddrMaskReps = icmp_stat.icps_outhist[ICMP_MASKREPLY];
|
991
|
415 |
|
1265
|
416 |
return NO_ERROR;
|
|
417 |
-#else
|
|
418 |
+#elif defined(HAVE_KSTAT)
|
1026
|
419 |
+ static const struct kstat_mib_map icmp_map[] =
|
|
420 |
+ {
|
|
421 |
+ { "inMsgs", offsetof(MIB_ICMP, stats.icmpInStats.dwMsgs) },
|
|
422 |
+ { "inErrors", offsetof(MIB_ICMP, stats.icmpInStats.dwErrors) },
|
|
423 |
+ { "inDestUnreachs", offsetof(MIB_ICMP, stats.icmpInStats.dwDestUnreachs) },
|
|
424 |
+ { "inTimeExcds", offsetof(MIB_ICMP, stats.icmpInStats.dwTimeExcds) },
|
|
425 |
+ { "inParmProbs", offsetof(MIB_ICMP, stats.icmpInStats.dwParmProbs) },
|
|
426 |
+ { "inSrcQuenchs", offsetof(MIB_ICMP, stats.icmpInStats.dwSrcQuenchs) },
|
|
427 |
+ { "inRedirects", offsetof(MIB_ICMP, stats.icmpInStats.dwRedirects) },
|
|
428 |
+ { "inEchos", offsetof(MIB_ICMP, stats.icmpInStats.dwEchos) },
|
|
429 |
+ { "inEchoReps", offsetof(MIB_ICMP, stats.icmpInStats.dwEchoReps) },
|
|
430 |
+ { "inTimestamps", offsetof(MIB_ICMP, stats.icmpInStats.dwTimestamps) },
|
|
431 |
+ { "inTimestampReps", offsetof(MIB_ICMP, stats.icmpInStats.dwTimestampReps) },
|
|
432 |
+ { "inAddrMasks", offsetof(MIB_ICMP, stats.icmpInStats.dwAddrMasks) },
|
|
433 |
+ { "inAddrMaskReps", offsetof(MIB_ICMP, stats.icmpInStats.dwAddrMaskReps) },
|
|
434 |
+ { "outMsgs", offsetof(MIB_ICMP, stats.icmpOutStats.dwMsgs) },
|
|
435 |
+ { "outErrors", offsetof(MIB_ICMP, stats.icmpOutStats.dwErrors) },
|
|
436 |
+ { "outDestUnreachs", offsetof(MIB_ICMP, stats.icmpOutStats.dwDestUnreachs) },
|
|
437 |
+ { "outTimeExcds", offsetof(MIB_ICMP, stats.icmpOutStats.dwTimeExcds) },
|
|
438 |
+ { "outParmProbs", offsetof(MIB_ICMP, stats.icmpOutStats.dwParmProbs) },
|
|
439 |
+ { "outSrcQuenchs", offsetof(MIB_ICMP, stats.icmpOutStats.dwSrcQuenchs) },
|
|
440 |
+ { "outRedirects", offsetof(MIB_ICMP, stats.icmpOutStats.dwRedirects) },
|
|
441 |
+ { "outEchos", offsetof(MIB_ICMP, stats.icmpOutStats.dwEchos) },
|
|
442 |
+ { "outEchoReps", offsetof(MIB_ICMP, stats.icmpOutStats.dwEchoReps) },
|
|
443 |
+ { "outTimestamps", offsetof(MIB_ICMP, stats.icmpOutStats.dwTimestamps) },
|
|
444 |
+ { "outTimestampReps", offsetof(MIB_ICMP, stats.icmpOutStats.dwTimestampReps) },
|
|
445 |
+ { "outAddrMasks", offsetof(MIB_ICMP, stats.icmpOutStats.dwAddrMasks) },
|
|
446 |
+ { "outAddrMaskReps", offsetof(MIB_ICMP, stats.icmpOutStats.dwAddrMaskReps) },
|
|
447 |
+ { NULL, 0 }
|
|
448 |
+ };
|
1265
|
449 |
+
|
991
|
450 |
+ kstat_ctl_t *kc;
|
|
451 |
+ kstat_t *ksp;
|
|
452 |
+ kstat_named_t *knp;
|
|
453 |
+ int i;
|
1265
|
454 |
+
|
|
455 |
+ if (!stats)
|
|
456 |
+ return ERROR_INVALID_PARAMETER;
|
|
457 |
+
|
|
458 |
+ memset(stats, 0, sizeof(MIB_ICMP));
|
|
459 |
+
|
991
|
460 |
+ kc = kstat_open();
|
|
461 |
+ ksp = kstat_lookup(kc, (char *)"ip", 0, (char *)"icmp");
|
1026
|
462 |
+ if (ksp)
|
|
463 |
+ {
|
991
|
464 |
+ kstat_read(kc, ksp, NULL);
|
1026
|
465 |
+ for (i = 0; icmp_map[i].name != NULL; i++)
|
|
466 |
+ {
|
991
|
467 |
+ if ((knp = kstat_data_lookup(ksp, (char *)icmp_map[i].name)) != NULL)
|
|
468 |
+ *(DWORD *)((char *)stats + icmp_map[i].offset) = knp->value.ui32;
|
|
469 |
+ }
|
|
470 |
+ kstat_close(kc);
|
|
471 |
+ }
|
|
472 |
+ else
|
1265
|
473 |
+ {
|
|
474 |
+ kstat_close(kc);
|
|
475 |
+ return ERROR_NOT_SUPPORTED;
|
|
476 |
+ }
|
|
477 |
+
|
|
478 |
+ return NO_ERROR;
|
991
|
479 |
+#elif defined(__linux__)
|
1265
|
480 |
FILE *fp;
|
991
|
481 |
|
1265
|
482 |
if (!stats)
|
1650
|
483 |
@@ -517,7 +860,62 @@
|
1265
|
484 |
stats->dwReasmReqds = ip_stat.ips_fragments;
|
|
485 |
|
|
486 |
return NO_ERROR;
|
|
487 |
-#else
|
|
488 |
+#elif defined(HAVE_KSTAT)
|
1026
|
489 |
+ static const struct kstat_mib_map ipstats_map[] =
|
|
490 |
+ {
|
|
491 |
+ { "forwarding", offsetof(MIB_IPSTATS, dwForwarding) },
|
|
492 |
+ { "defaultTTL", offsetof(MIB_IPSTATS, dwDefaultTTL) },
|
|
493 |
+ { "inReceives", offsetof(MIB_IPSTATS, dwInReceives) },
|
|
494 |
+ { "inHdrErrors", offsetof(MIB_IPSTATS, dwInHdrErrors) },
|
|
495 |
+ { "inAddrErrors", offsetof(MIB_IPSTATS, dwInAddrErrors) },
|
|
496 |
+ { "forwDatagrams", offsetof(MIB_IPSTATS, dwForwDatagrams) },
|
|
497 |
+ { "inUnknownProtos", offsetof(MIB_IPSTATS, dwInUnknownProtos) },
|
|
498 |
+ { "inDiscards", offsetof(MIB_IPSTATS, dwInDiscards) },
|
|
499 |
+ { "inDelivers", offsetof(MIB_IPSTATS, dwInDelivers) },
|
|
500 |
+ { "outRequests", offsetof(MIB_IPSTATS, dwOutRequests) },
|
|
501 |
+ { "routingDiscards", offsetof(MIB_IPSTATS, dwRoutingDiscards) },
|
|
502 |
+ { "outDiscards", offsetof(MIB_IPSTATS, dwOutDiscards) },
|
|
503 |
+ { "outNoRoutes", offsetof(MIB_IPSTATS, dwOutNoRoutes) },
|
|
504 |
+ { "reasmTimeout", offsetof(MIB_IPSTATS, dwReasmTimeout) },
|
|
505 |
+ { "reasmReqds", offsetof(MIB_IPSTATS, dwReasmReqds) },
|
|
506 |
+ { "reasmOks", offsetof(MIB_IPSTATS, dwReasmOks) },
|
|
507 |
+ { "reasmFails", offsetof(MIB_IPSTATS, dwReasmFails) },
|
|
508 |
+ { "fragOks", offsetof(MIB_IPSTATS, dwFragOks) },
|
|
509 |
+ { "fragFails", offsetof(MIB_IPSTATS, dwFragFails) },
|
|
510 |
+ { "fragCreates", offsetof(MIB_IPSTATS, dwFragCreates) },
|
|
511 |
+ { NULL, 0 }
|
|
512 |
+ };
|
1265
|
513 |
+
|
991
|
514 |
+ kstat_ctl_t *kc;
|
|
515 |
+ kstat_t *ksp;
|
|
516 |
+ kstat_named_t *knp;
|
|
517 |
+ int i;
|
1265
|
518 |
+
|
|
519 |
+ if (!stats)
|
|
520 |
+ return ERROR_INVALID_PARAMETER;
|
|
521 |
+
|
|
522 |
+ memset(stats, 0, sizeof(MIB_IPSTATS));
|
|
523 |
+
|
991
|
524 |
+ kc = kstat_open();
|
|
525 |
+ ksp = kstat_lookup(kc, (char *)"ip", 0, (char *)"ip");
|
1026
|
526 |
+ if (ksp)
|
|
527 |
+ {
|
991
|
528 |
+ kstat_read(kc, ksp, NULL);
|
1026
|
529 |
+ for (i = 0; ipstats_map[i].name != NULL; i++)
|
|
530 |
+ {
|
991
|
531 |
+ if ((knp = kstat_data_lookup(ksp, (char *)ipstats_map[i].name)) != NULL)
|
|
532 |
+ *(DWORD *)((char *)stats + ipstats_map[i].offset) = knp->value.ui32;
|
|
533 |
+ }
|
|
534 |
+ kstat_close(kc);
|
|
535 |
+ }
|
|
536 |
+ else
|
1265
|
537 |
+ {
|
|
538 |
+ kstat_close(kc);
|
|
539 |
+ return ERROR_NOT_SUPPORTED;
|
|
540 |
+ }
|
|
541 |
+
|
|
542 |
+ return NO_ERROR;
|
991
|
543 |
+#elif defined(__linux__)
|
1265
|
544 |
FILE *fp;
|
|
545 |
|
|
546 |
if (!stats)
|
1650
|
547 |
@@ -675,7 +1073,55 @@
|
991
|
548 |
|
1265
|
549 |
return NO_ERROR;
|
|
550 |
|
|
551 |
-#else
|
|
552 |
+#elif defined(HAVE_KSTAT)
|
1026
|
553 |
+ static const struct kstat_mib_map tcpstats_map[] =
|
|
554 |
+ {
|
|
555 |
+ { "rtoAlgorithm", offsetof(MIB_TCPSTATS, dwRtoAlgorithm) },
|
|
556 |
+ { "rtoMin", offsetof(MIB_TCPSTATS, dwRtoMin) },
|
|
557 |
+ { "rtoMax", offsetof(MIB_TCPSTATS, dwRtoMax) },
|
|
558 |
+ { "maxConn", offsetof(MIB_TCPSTATS, dwMaxConn) },
|
|
559 |
+ { "activeOpens", offsetof(MIB_TCPSTATS, dwActiveOpens) },
|
|
560 |
+ { "passiveOpens", offsetof(MIB_TCPSTATS, dwPassiveOpens) },
|
|
561 |
+ { "attemptFails", offsetof(MIB_TCPSTATS, dwAttemptFails) },
|
|
562 |
+ { "estabResets", offsetof(MIB_TCPSTATS, dwEstabResets) },
|
|
563 |
+ { "currEstab", offsetof(MIB_TCPSTATS, dwCurrEstab) },
|
|
564 |
+ { "inSegs", offsetof(MIB_TCPSTATS, dwInSegs) },
|
|
565 |
+ { "outSegs", offsetof(MIB_TCPSTATS, dwOutSegs) },
|
|
566 |
+ { "retransSegs", offsetof(MIB_TCPSTATS, dwRetransSegs) },
|
|
567 |
+ { "inErrs", offsetof(MIB_TCPSTATS, dwInErrs) },
|
|
568 |
+ { "outRsts", offsetof(MIB_TCPSTATS, dwOutRsts) },
|
|
569 |
+ { NULL, 0 }
|
|
570 |
+ };
|
991
|
571 |
+ kstat_ctl_t *kc;
|
|
572 |
+ kstat_t *ksp;
|
|
573 |
+ kstat_named_t *knp;
|
|
574 |
+ int i;
|
1265
|
575 |
+
|
|
576 |
+ if (!stats)
|
|
577 |
+ return ERROR_INVALID_PARAMETER;
|
|
578 |
+
|
|
579 |
+ memset(stats, 0, sizeof(MIB_TCPSTATS));
|
|
580 |
+
|
991
|
581 |
+ kc = kstat_open();
|
|
582 |
+ ksp = kstat_lookup(kc, (char *)"tcp", 0, (char *)"tcp");
|
1026
|
583 |
+ if (ksp)
|
|
584 |
+ {
|
991
|
585 |
+ kstat_read(kc, ksp, NULL);
|
1026
|
586 |
+ for (i = 0; tcpstats_map[i].name != NULL; i++)
|
|
587 |
+ {
|
991
|
588 |
+ if ((knp = kstat_data_lookup(ksp, (char *)tcpstats_map[i].name)) != NULL)
|
|
589 |
+ *(DWORD *)((char *)stats + tcpstats_map[i].offset) = knp->value.ui32;
|
|
590 |
+ }
|
|
591 |
+ kstat_close(kc);
|
|
592 |
+ }
|
|
593 |
+ else
|
1265
|
594 |
+ {
|
|
595 |
+ kstat_close(kc);
|
|
596 |
+ return ERROR_NOT_SUPPORTED;
|
|
597 |
+ }
|
|
598 |
+
|
|
599 |
+ return NO_ERROR;
|
991
|
600 |
+#elif defined(__linux__)
|
1265
|
601 |
FILE *fp;
|
991
|
602 |
|
1265
|
603 |
if (!stats)
|
1650
|
604 |
@@ -796,7 +1242,37 @@
|
1265
|
605 |
stats->dwNumAddrs = getNumUdpEntries();
|
|
606 |
|
|
607 |
return NO_ERROR;
|
|
608 |
-#else
|
|
609 |
+#elif defined(HAVE_KSTAT)
|
991
|
610 |
+ kstat_ctl_t *kc;
|
|
611 |
+ kstat_t *ksp;
|
|
612 |
+ kstat_named_t *knp;
|
1265
|
613 |
+
|
|
614 |
+ if (!stats)
|
|
615 |
+ return ERROR_INVALID_PARAMETER;
|
|
616 |
+
|
|
617 |
+ memset(stats, 0, sizeof(MIB_UDPSTATS));
|
|
618 |
+
|
991
|
619 |
+ kc = kstat_open();
|
|
620 |
+ ksp = kstat_lookup(kc, (char *)"udp", 0, (char *)"udp");
|
1026
|
621 |
+ if (ksp)
|
|
622 |
+ {
|
991
|
623 |
+ kstat_read(kc, ksp, NULL);
|
|
624 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"inDatagrams")) != NULL)
|
|
625 |
+ stats->dwInDatagrams = knp->value.ui32;
|
|
626 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"inErrors")) != NULL)
|
|
627 |
+ stats->dwInErrors = knp->value.ui32;
|
|
628 |
+ if ((knp = kstat_data_lookup(ksp, (char *)"outDatagrams")) != NULL)
|
|
629 |
+ stats->dwOutDatagrams = knp->value.ui32;
|
|
630 |
+ kstat_close(kc);
|
|
631 |
+ }
|
|
632 |
+ else
|
1265
|
633 |
+ {
|
|
634 |
+ kstat_close(kc);
|
|
635 |
+ return ERROR_NOT_SUPPORTED;
|
|
636 |
+ }
|
|
637 |
+
|
|
638 |
+ return NO_ERROR;
|
991
|
639 |
+#elif defined(__linux__)
|
1265
|
640 |
FILE *fp;
|
|
641 |
|
|
642 |
if (!stats)
|
1650
|
643 |
@@ -855,6 +1331,7 @@
|
1265
|
644 |
#endif
|
991
|
645 |
}
|
|
646 |
|
|
647 |
+#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_NETINET_IN_PCB_H) || defined(__linux__)
|
|
648 |
static DWORD getNumWithOneHeader(const char *filename)
|
|
649 |
{
|
|
650 |
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_NETINET_IN_PCB_H)
|
1650
|
651 |
@@ -975,6 +1452,7 @@
|
991
|
652 |
return ret;
|
|
653 |
#endif
|
|
654 |
}
|
|
655 |
+#endif
|
|
656 |
|
|
657 |
DWORD getNumRoutes(void)
|
|
658 |
{
|
1650
|
659 |
@@ -1023,8 +1501,46 @@
|
991
|
660 |
|
|
661 |
HeapFree (GetProcessHeap (), 0, buf);
|
|
662 |
return RouteCount;
|
|
663 |
-#else
|
1026
|
664 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
665 |
+ DWORD RouteCount = 0;
|
|
666 |
+ int sd;
|
|
667 |
+ mib_item_t *head, *item;
|
|
668 |
+ mib2_ipRouteEntry_t *rp;
|
|
669 |
+
|
1026
|
670 |
+ if ((sd = mibopen()) < 0)
|
|
671 |
+ {
|
991
|
672 |
+ ERR ("Unable to open %s to count routes!\n", mib_dev);
|
|
673 |
+ return 0;
|
|
674 |
+ }
|
|
675 |
+
|
1026
|
676 |
+ if ((head = mibget(sd)) == NULL)
|
|
677 |
+ {
|
991
|
678 |
+ close(sd);
|
|
679 |
+ return 0;
|
|
680 |
+ }
|
|
681 |
+
|
1026
|
682 |
+ for (item = head; item; item = item->next_item)
|
|
683 |
+ {
|
991
|
684 |
+ if ((item->group != MIB2_IP) || (item->mib_id != MIB2_IP_21))
|
|
685 |
+ continue;
|
|
686 |
+
|
1026
|
687 |
+ for (rp = (mib2_ipRouteEntry_t *)item->valp;
|
|
688 |
+ (char *)rp < (char *)item->valp + item->length; rp++)
|
|
689 |
+ {
|
|
690 |
+ if ((rp->ipRouteInfo.re_ire_type & IRE_CACHETABLE) != 0)
|
991
|
691 |
+ continue;
|
|
692 |
+
|
|
693 |
+ RouteCount++;
|
|
694 |
+ }
|
|
695 |
+ }
|
|
696 |
+
|
|
697 |
+ mibfree(head);
|
|
698 |
+ close(sd);
|
|
699 |
+ return RouteCount;
|
|
700 |
+#elif defined(__linux__)
|
|
701 |
return getNumWithOneHeader("/proc/net/route");
|
|
702 |
+#else
|
|
703 |
+ return 0;
|
|
704 |
#endif
|
|
705 |
}
|
|
706 |
|
1650
|
707 |
@@ -1053,21 +1569,21 @@
|
991
|
708 |
if (sysctl (mib, 6, NULL, &needed, NULL, 0) < 0)
|
|
709 |
{
|
|
710 |
ERR ("sysctl 1 failed!\n");
|
|
711 |
- HeapFree (GetProcessHeap (), 0, table);
|
|
712 |
+ HeapFree (heap, 0, table);
|
|
713 |
return NO_ERROR;
|
|
714 |
}
|
|
715 |
|
|
716 |
buf = HeapAlloc (GetProcessHeap (), 0, needed);
|
|
717 |
if (!buf)
|
|
718 |
{
|
|
719 |
- HeapFree (GetProcessHeap (), 0, table);
|
|
720 |
+ HeapFree (heap, 0, table);
|
|
721 |
return ERROR_OUTOFMEMORY;
|
|
722 |
}
|
|
723 |
|
|
724 |
if (sysctl (mib, 6, buf, &needed, NULL, 0) < 0)
|
|
725 |
{
|
|
726 |
ERR ("sysctl 2 failed!\n");
|
|
727 |
- HeapFree (GetProcessHeap (), 0, table);
|
|
728 |
+ HeapFree (heap, 0, table);
|
|
729 |
HeapFree (GetProcessHeap (), 0, buf);
|
|
730 |
return NO_ERROR;
|
|
731 |
}
|
1650
|
732 |
@@ -1158,7 +1674,76 @@
|
991
|
733 |
|
|
734 |
HeapFree (GetProcessHeap (), 0, buf);
|
|
735 |
ret = NO_ERROR;
|
|
736 |
-#else
|
1026
|
737 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
738 |
+ DWORD RouteCount = 0;
|
|
739 |
+ int sd;
|
|
740 |
+ mib_item_t *head, *item;
|
|
741 |
+ mib2_ipRouteEntry_t *rp;
|
|
742 |
+
|
1026
|
743 |
+ if ((sd = mibopen()) < 0)
|
|
744 |
+ {
|
991
|
745 |
+ ERR ("Unable to open %s to list routes!\n", mib_dev);
|
|
746 |
+ HeapFree(heap, 0, table);
|
|
747 |
+ return ERROR_NOT_SUPPORTED;
|
|
748 |
+ }
|
|
749 |
+
|
1026
|
750 |
+ if ((head = mibget(sd)) == NULL)
|
|
751 |
+ {
|
991
|
752 |
+ HeapFree(heap, 0, table);
|
|
753 |
+ close(sd);
|
|
754 |
+ return ERROR_NOT_SUPPORTED;
|
|
755 |
+ }
|
|
756 |
+
|
1026
|
757 |
+ for (item = head; item; item = item->next_item)
|
|
758 |
+ {
|
991
|
759 |
+ if ((item->group != MIB2_IP) || (item->mib_id != MIB2_IP_21))
|
|
760 |
+ continue;
|
|
761 |
+
|
|
762 |
+ for (rp = (mib2_ipRouteEntry_t *)item->valp;
|
|
763 |
+ (char *)rp < (char *)item->valp + item->length; rp++) {
|
|
764 |
+ char name[IF_NAMESIZE];
|
|
765 |
+ int len;
|
|
766 |
+ DWORD index;
|
|
767 |
+
|
|
768 |
+ if (RouteCount == numRoutes) /* in case of race */
|
|
769 |
+ break;
|
|
770 |
+
|
1026
|
771 |
+ if ((rp->ipRouteInfo.re_ire_type & IRE_CACHETABLE) != 0)
|
991
|
772 |
+ continue;
|
|
773 |
+
|
|
774 |
+ memset(&table->table[RouteCount], 0, sizeof(MIB_IPFORWARDROW));
|
|
775 |
+
|
|
776 |
+ table->table[RouteCount].dwForwardDest = rp->ipRouteDest;
|
|
777 |
+ table->table[RouteCount].dwForwardMask = rp->ipRouteMask;
|
|
778 |
+ table->table[RouteCount].dwForwardNextHop = rp->ipRouteNextHop;
|
|
779 |
+
|
|
780 |
+ len = rp->ipRouteIfIndex.o_length;
|
|
781 |
+ if (len > IF_NAMESIZE - 1)
|
|
782 |
+ len = IF_NAMESIZE - 1;
|
|
783 |
+ memcpy(name, rp->ipRouteIfIndex.o_bytes, len);
|
|
784 |
+ name[len] = '\0';
|
|
785 |
+ if (getInterfaceIndexByName(name, &index) == NO_ERROR)
|
|
786 |
+ table->table[RouteCount].dwForwardIfIndex = index;
|
|
787 |
+
|
|
788 |
+ table->table[RouteCount].dwForwardType = rp->ipRouteType;
|
|
789 |
+ table->table[RouteCount].dwForwardProto = rp->ipRouteProto;
|
|
790 |
+ table->table[RouteCount].dwForwardAge = rp->ipRouteAge;
|
|
791 |
+ table->table[RouteCount].dwForwardMetric1 = rp->ipRouteMetric1;
|
|
792 |
+ table->table[RouteCount].dwForwardMetric2 = rp->ipRouteMetric2;
|
|
793 |
+ table->table[RouteCount].dwForwardMetric3 = rp->ipRouteMetric3;
|
|
794 |
+ table->table[RouteCount].dwForwardMetric4 = rp->ipRouteMetric4;
|
|
795 |
+ table->table[RouteCount].dwForwardMetric5 = rp->ipRouteMetric5;
|
|
796 |
+
|
|
797 |
+ RouteCount++;
|
|
798 |
+ }
|
|
799 |
+ }
|
|
800 |
+
|
|
801 |
+ *ppIpForwardTable = table;
|
|
802 |
+ table->dwNumEntries = RouteCount;
|
|
803 |
+ ret = NO_ERROR;
|
|
804 |
+ mibfree(head);
|
|
805 |
+ close(sd);
|
|
806 |
+#elif defined(__linux__)
|
|
807 |
FILE *fp;
|
|
808 |
|
|
809 |
ret = NO_ERROR;
|
1650
|
810 |
@@ -1243,6 +1828,9 @@
|
991
|
811 |
ERR ("unimplemented!\n");
|
|
812 |
return ERROR_NOT_SUPPORTED;
|
|
813 |
}
|
|
814 |
+#else
|
|
815 |
+ ERR ("unimplemented!\n");
|
|
816 |
+ return ERROR_NOT_SUPPORTED;
|
|
817 |
#endif
|
|
818 |
}
|
|
819 |
else
|
1650
|
820 |
@@ -1292,8 +1880,42 @@
|
1265
|
821 |
}
|
|
822 |
HeapFree (GetProcessHeap (), 0, buf);
|
|
823 |
return arpEntries;
|
|
824 |
-#endif
|
|
825 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
826 |
+ DWORD ArpCount = 0;
|
|
827 |
+ int sd;
|
|
828 |
+ mib_item_t *head, *item;
|
|
829 |
+ mib2_ipNetToMediaEntry_t *np;
|
|
830 |
+
|
1026
|
831 |
+ if ((sd = mibopen()) < 0)
|
|
832 |
+ {
|
991
|
833 |
+ ERR ("Unable to open %s to count ARP entries!\n", mib_dev);
|
|
834 |
+ return 0;
|
|
835 |
+ }
|
|
836 |
+
|
|
837 |
+ if ((head = mibget(sd)) == NULL) {
|
|
838 |
+ close(sd);
|
|
839 |
+ return 0;
|
|
840 |
+ }
|
|
841 |
+
|
1026
|
842 |
+ for (item = head; item; item = item->next_item)
|
|
843 |
+ {
|
991
|
844 |
+ if ((item->group != MIB2_IP) || (item->mib_id != MIB2_IP_MEDIA))
|
|
845 |
+ continue;
|
|
846 |
+
|
|
847 |
+ for (np = (mib2_ipNetToMediaEntry_t *)item->valp;
|
1026
|
848 |
+ (char *)np < (char *)item->valp + item->length; np++)
|
991
|
849 |
+ ArpCount++;
|
|
850 |
+ }
|
|
851 |
+
|
|
852 |
+ mibfree(head);
|
|
853 |
+ close(sd);
|
|
854 |
+ return ArpCount;
|
|
855 |
+#elif defined(__linux__)
|
|
856 |
return getNumWithOneHeader("/proc/net/arp");
|
|
857 |
+#else
|
1265
|
858 |
+ ERR ("unimplemented!\n");
|
|
859 |
+ return ERROR_NOT_SUPPORTED;
|
991
|
860 |
+#endif
|
|
861 |
}
|
|
862 |
|
|
863 |
DWORD getArpTable(PMIB_IPNETTABLE *ppIpNetTable, HANDLE heap, DWORD flags)
|
1650
|
864 |
@@ -1375,7 +1997,76 @@
|
1265
|
865 |
else
|
|
866 |
ret = ERROR_OUTOFMEMORY;
|
|
867 |
return ret;
|
991
|
868 |
-#endif
|
1265
|
869 |
+#elif defined(HAVE_STREAMS_TPI)
|
1026
|
870 |
+ if (table)
|
|
871 |
+ {
|
991
|
872 |
+ DWORD ArpCount = 0;
|
|
873 |
+ int sd;
|
|
874 |
+ mib_item_t *head, *item;
|
|
875 |
+ mib2_ipNetToMediaEntry_t *np;
|
1650
|
876 |
+
|
1026
|
877 |
+ if ((sd = mibopen()) < 0)
|
|
878 |
+ {
|
991
|
879 |
+ ERR ("Unable to open %s to count ARP entries!\n", mib_dev);
|
|
880 |
+ HeapFree(heap, 0, table);
|
|
881 |
+ return ERROR_NOT_SUPPORTED;
|
|
882 |
+ }
|
|
883 |
+
|
1026
|
884 |
+ if ((head = mibget(sd)) == NULL)
|
|
885 |
+ {
|
991
|
886 |
+ HeapFree(heap, 0, table);
|
|
887 |
+ close(sd);
|
|
888 |
+ return ERROR_NOT_SUPPORTED;
|
|
889 |
+ }
|
|
890 |
+
|
1026
|
891 |
+ for (item = head; item; item = item->next_item)
|
|
892 |
+ {
|
991
|
893 |
+ if ((item->group != MIB2_IP) || (item->mib_id != MIB2_IP_MEDIA))
|
|
894 |
+ continue;
|
|
895 |
+
|
|
896 |
+ for (np = (mib2_ipNetToMediaEntry_t *)item->valp;
|
|
897 |
+ (char *)np < (char *)item->valp + item->length; np++) {
|
|
898 |
+ char name[IF_NAMESIZE];
|
|
899 |
+ int len;
|
|
900 |
+ DWORD index;
|
|
901 |
+
|
|
902 |
+ if (ArpCount == numEntries) /* in case of race */
|
|
903 |
+ break;
|
|
904 |
+
|
|
905 |
+ memset(&table->table[ArpCount], 0, sizeof(MIB_IPNETROW));
|
|
906 |
+
|
|
907 |
+ len = np->ipNetToMediaIfIndex.o_length;
|
|
908 |
+ if (len > IF_NAMESIZE - 1)
|
|
909 |
+ len = IF_NAMESIZE - 1;
|
|
910 |
+ memcpy(name, np->ipNetToMediaIfIndex.o_bytes, len);
|
|
911 |
+ name[len] = '\0';
|
|
912 |
+ if (getInterfaceIndexByName(name, &index) == NO_ERROR)
|
|
913 |
+ table->table[ArpCount].dwIndex = index;
|
|
914 |
+
|
|
915 |
+ len = np->ipNetToMediaPhysAddress.o_length;
|
|
916 |
+ if (len > MAXLEN_PHYSADDR)
|
|
917 |
+ len = MAXLEN_PHYSADDR;
|
|
918 |
+ table->table[ArpCount].dwPhysAddrLen = len;
|
|
919 |
+ memcpy(table->table[ArpCount].bPhysAddr, np->ipNetToMediaPhysAddress.o_bytes, len);
|
|
920 |
+
|
|
921 |
+ table->table[ArpCount].dwAddr = np->ipNetToMediaNetAddress;
|
|
922 |
+ table->table[ArpCount].dwType = np->ipNetToMediaType;
|
|
923 |
+
|
|
924 |
+ ArpCount++;
|
|
925 |
+ }
|
|
926 |
+ }
|
|
927 |
+
|
|
928 |
+ *ppIpNetTable = table;
|
|
929 |
+ table->dwNumEntries = ArpCount;
|
|
930 |
+ ret = NO_ERROR;
|
|
931 |
+ mibfree(head);
|
|
932 |
+ close(sd);
|
|
933 |
+ }
|
|
934 |
+ else
|
|
935 |
+ ret = ERROR_OUTOFMEMORY;
|
|
936 |
+ }
|
|
937 |
+ return ret;
|
|
938 |
+#elif defined(__linux__)
|
1650
|
939 |
|
1265
|
940 |
if (table) {
|
|
941 |
FILE *fp;
|
1650
|
942 |
@@ -1452,14 +2143,52 @@
|
991
|
943 |
ret = ERROR_OUTOFMEMORY;
|
|
944 |
}
|
|
945 |
return ret;
|
|
946 |
+#else
|
|
947 |
+ ERR ("unimplemented!\n");
|
|
948 |
+ return ERROR_NOT_SUPPORTED;
|
|
949 |
+#endif
|
|
950 |
}
|
|
951 |
|
|
952 |
DWORD getNumUdpEntries(void)
|
|
953 |
{
|
1265
|
954 |
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_NETINET_IN_PCB_H)
|
|
955 |
return getNumWithOneHeader ("net.inet.udp.pcblist");
|
|
956 |
-#else
|
1026
|
957 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
958 |
+ DWORD UdpCount = 0;
|
|
959 |
+ int sd;
|
|
960 |
+ mib_item_t *head, *item;
|
|
961 |
+ mib2_udpEntry_t *ude;
|
|
962 |
+
|
1026
|
963 |
+ if ((sd = mibopen()) < 0)
|
|
964 |
+ {
|
991
|
965 |
+ ERR ("Unable to open %s to count UDP entries!\n", mib_dev);
|
|
966 |
+ return 0;
|
|
967 |
+ }
|
|
968 |
+
|
1026
|
969 |
+ if ((head = mibget(sd)) == NULL)
|
|
970 |
+ {
|
991
|
971 |
+ close(sd);
|
|
972 |
+ return 0;
|
|
973 |
+ }
|
|
974 |
+
|
1026
|
975 |
+ for (item = head; item; item = item->next_item)
|
|
976 |
+ {
|
991
|
977 |
+ if ((item->group != MIB2_UDP) || (item->mib_id != MIB2_UDP_ENTRY))
|
|
978 |
+ continue;
|
|
979 |
+
|
|
980 |
+ for (ude = (mib2_udpEntry_t *)item->valp;
|
|
981 |
+ (char *)ude < (char *)item->valp + item->length; ude++) {
|
|
982 |
+ UdpCount++;
|
|
983 |
+ }
|
|
984 |
+ }
|
|
985 |
+
|
|
986 |
+ mibfree(head);
|
|
987 |
+ close(sd);
|
|
988 |
+ return UdpCount;
|
|
989 |
+#elif defined(__linux__)
|
1265
|
990 |
return getNumWithOneHeader("/proc/net/udp");
|
991
|
991 |
+#else
|
1265
|
992 |
+ return 0;
|
|
993 |
#endif
|
991
|
994 |
}
|
|
995 |
|
1650
|
996 |
@@ -1467,10 +2196,70 @@
|
991
|
997 |
{
|
|
998 |
DWORD ret;
|
|
999 |
|
|
1000 |
-#if defined(HAVE_SYS_SYSCTL_H) && defined(NET_RT_DUMP)
|
|
1001 |
- ERR ("unimplemented!\n");
|
|
1002 |
- return ERROR_NOT_SUPPORTED;
|
|
1003 |
-#endif
|
1026
|
1004 |
+#ifdef HAVE_STREAMS_TPI
|
991
|
1005 |
+ if (!ppUdpTable)
|
|
1006 |
+ ret = ERROR_INVALID_PARAMETER;
|
|
1007 |
+ else {
|
|
1008 |
+ DWORD numEntries = getNumUdpEntries();
|
|
1009 |
+ DWORD size = sizeof(MIB_UDPTABLE);
|
|
1010 |
+ PMIB_UDPTABLE table;
|
1265
|
1011 |
+
|
991
|
1012 |
+ if (numEntries > 1)
|
|
1013 |
+ size += (numEntries - 1) * sizeof(MIB_IPNETROW);
|
|
1014 |
+ table = HeapAlloc(heap, flags, size);
|
1026
|
1015 |
+ if (table)
|
|
1016 |
+ {
|
991
|
1017 |
+ DWORD UdpCount = 0;
|
|
1018 |
+ int sd;
|
|
1019 |
+ mib_item_t *head, *item;
|
|
1020 |
+ mib2_udpEntry_t *ude;
|
|
1021 |
+
|
1026
|
1022 |
+ if ((sd = mibopen()) < 0)
|
|
1023 |
+ {
|
991
|
1024 |
+ ERR ("Unable to open %s to list UDP entries!\n", mib_dev);
|
|
1025 |
+ HeapFree(heap, 0, table);
|
|
1026 |
+ return ERROR_NOT_SUPPORTED;
|
|
1027 |
+ }
|
|
1028 |
+
|
1026
|
1029 |
+ if ((head = mibget(sd)) == NULL)
|
|
1030 |
+ {
|
991
|
1031 |
+ HeapFree(heap, 0, table);
|
|
1032 |
+ close(sd);
|
|
1033 |
+ return ERROR_NOT_SUPPORTED;
|
|
1034 |
+ }
|
|
1035 |
+
|
1026
|
1036 |
+ for (item = head; item; item = item->next_item)
|
|
1037 |
+ {
|
991
|
1038 |
+ if ((item->group != MIB2_UDP) || (item->mib_id != MIB2_UDP_ENTRY))
|
|
1039 |
+ continue;
|
|
1040 |
+
|
|
1041 |
+ for (ude = (mib2_udpEntry_t *)item->valp;
|
1026
|
1042 |
+ (char *)ude < (char *)item->valp + item->length; ude++)
|
|
1043 |
+ {
|
991
|
1044 |
+
|
|
1045 |
+ if (UdpCount == numEntries) /* in case of race */
|
|
1046 |
+ break;
|
|
1047 |
+
|
|
1048 |
+ memset(&table->table[UdpCount], 0, sizeof(MIB_UDPROW));
|
|
1049 |
+
|
|
1050 |
+ table->table[UdpCount].dwLocalAddr = ude->udpLocalAddress;
|
|
1051 |
+ table->table[UdpCount].dwLocalPort = ude->udpLocalPort;
|
|
1052 |
+
|
|
1053 |
+ UdpCount++;
|
|
1054 |
+ }
|
|
1055 |
+ }
|
|
1056 |
+
|
|
1057 |
+ *ppUdpTable = table;
|
|
1058 |
+ table->dwNumEntries = UdpCount;
|
|
1059 |
+ ret = NO_ERROR;
|
|
1060 |
+ mibfree(head);
|
|
1061 |
+ close(sd);
|
|
1062 |
+ }
|
|
1063 |
+ else
|
|
1064 |
+ ret = ERROR_OUTOFMEMORY;
|
|
1065 |
+ }
|
|
1066 |
+ return ret;
|
|
1067 |
+#elif defined(__linux__)
|
1265
|
1068 |
|
991
|
1069 |
if (!ppUdpTable)
|
|
1070 |
ret = ERROR_INVALID_PARAMETER;
|
1650
|
1071 |
@@ -1529,6 +2318,10 @@
|
991
|
1072 |
ret = ERROR_OUTOFMEMORY;
|
|
1073 |
}
|
|
1074 |
return ret;
|
|
1075 |
+#else
|
|
1076 |
+ ERR ("unimplemented!\n");
|
|
1077 |
+ return ERROR_NOT_SUPPORTED;
|
|
1078 |
+#endif
|
|
1079 |
}
|
|
1080 |
|
|
1081 |
|
1650
|
1082 |
@@ -1536,14 +2329,48 @@
|
991
|
1083 |
{
|
|
1084 |
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_NETINET_IN_PCB_H)
|
|
1085 |
return getNumWithOneHeader ("net.inet.tcp.pcblist");
|
|
1086 |
-#else
|
1026
|
1087 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
1088 |
+ DWORD TcpCount = 0;
|
|
1089 |
+ int sd;
|
|
1090 |
+ mib_item_t *head, *item;
|
|
1091 |
+ mib2_tcpConnEntry_t *tp;
|
|
1092 |
+
|
1026
|
1093 |
+ if ((sd = mibopen()) < 0)
|
|
1094 |
+ {
|
991
|
1095 |
+ ERR ("Unable to open %s to count TCP entries!\n", mib_dev);
|
|
1096 |
+ return 0;
|
|
1097 |
+ }
|
|
1098 |
+
|
1026
|
1099 |
+ if ((head = mibget(sd)) == NULL)
|
|
1100 |
+ {
|
991
|
1101 |
+ close(sd);
|
|
1102 |
+ return 0;
|
|
1103 |
+ }
|
|
1104 |
+
|
1026
|
1105 |
+ for (item = head; item; item = item->next_item)
|
|
1106 |
+ {
|
991
|
1107 |
+ if ((item->group != MIB2_TCP) || (item->mib_id != MIB2_TCP_CONN))
|
|
1108 |
+ continue;
|
|
1109 |
+
|
|
1110 |
+ for (tp = (mib2_tcpConnEntry_t *)item->valp;
|
1026
|
1111 |
+ (char *)tp < (char *)item->valp + item->length; tp++)
|
991
|
1112 |
+ TcpCount++;
|
|
1113 |
+ }
|
|
1114 |
+
|
|
1115 |
+ mibfree(head);
|
|
1116 |
+ close(sd);
|
|
1117 |
+ return TcpCount;
|
|
1118 |
+#elif defined(__linux__)
|
|
1119 |
return getNumWithOneHeader ("/proc/net/tcp");
|
|
1120 |
+#else
|
|
1121 |
+ return 0;
|
|
1122 |
#endif
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
|
|
1126 |
/* Why not a lookup table? Because the TCPS_* constants are different
|
|
1127 |
on different platforms */
|
|
1128 |
+#if (defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_NETINET_IN_PCB_H)) || defined(__linux__)
|
|
1129 |
static DWORD TCPStateToMIBState (int state)
|
|
1130 |
{
|
|
1131 |
switch (state)
|
1650
|
1132 |
@@ -1562,6 +2389,7 @@
|
991
|
1133 |
case TCPS_CLOSED: return MIB_TCP_STATE_CLOSED;
|
|
1134 |
}
|
|
1135 |
}
|
|
1136 |
+#endif
|
|
1137 |
|
|
1138 |
|
|
1139 |
DWORD getTcpTable(PMIB_TCPTABLE *ppTcpTable, DWORD maxEntries, HANDLE heap,
|
1650
|
1140 |
@@ -1573,7 +2401,12 @@
|
991
|
1141 |
size_t Len = 0;
|
|
1142 |
char *Buf;
|
|
1143 |
struct xinpgen *pXIG, *pOrigXIG;
|
|
1144 |
-#else
|
1026
|
1145 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
1146 |
+ DWORD TcpCount = 0;
|
|
1147 |
+ int sd;
|
|
1148 |
+ mib_item_t *head, *item;
|
|
1149 |
+ mib2_tcpConnEntry_t *tp;
|
|
1150 |
+#elif defined(__linux__)
|
|
1151 |
FILE *fp;
|
|
1152 |
char buf[512] = { 0 }, *ptr;
|
|
1153 |
#endif
|
1650
|
1154 |
@@ -1684,7 +2517,47 @@
|
991
|
1155 |
}
|
|
1156 |
|
|
1157 |
HeapFree (GetProcessHeap (), 0, Buf);
|
|
1158 |
-#else
|
1026
|
1159 |
+#elif defined(HAVE_STREAMS_TPI)
|
991
|
1160 |
+
|
1026
|
1161 |
+ if ((sd = mibopen()) < 0)
|
|
1162 |
+ {
|
991
|
1163 |
+ ERR ("Unable to open %s to list TCP entries!\n", mib_dev);
|
|
1164 |
+ return ERROR_NOT_SUPPORTED;
|
|
1165 |
+ }
|
|
1166 |
+
|
1026
|
1167 |
+ if ((head = mibget(sd)) == NULL)
|
|
1168 |
+ {
|
991
|
1169 |
+ close(sd);
|
|
1170 |
+ return ERROR_NOT_SUPPORTED;
|
|
1171 |
+ }
|
|
1172 |
+
|
1026
|
1173 |
+ for (item = head; item; item = item->next_item)
|
|
1174 |
+ {
|
991
|
1175 |
+ if ((item->group != MIB2_TCP) || (item->mib_id != MIB2_TCP_CONN))
|
|
1176 |
+ continue;
|
|
1177 |
+
|
|
1178 |
+ for (tp = (mib2_tcpConnEntry_t *)item->valp;
|
|
1179 |
+ (char *)tp < (char *)item->valp + item->length; tp++) {
|
|
1180 |
+
|
|
1181 |
+ if (TcpCount == numEntries) /* in case of race */
|
|
1182 |
+ break;
|
|
1183 |
+
|
|
1184 |
+ memset(&table->table[TcpCount], 0, sizeof(MIB_TCPROW));
|
|
1185 |
+
|
|
1186 |
+ table->table[TcpCount].dwState = tp->tcpConnState;
|
|
1187 |
+ table->table[TcpCount].dwLocalAddr = tp->tcpConnLocalAddress;
|
|
1188 |
+ table->table[TcpCount].dwLocalPort = tp->tcpConnLocalPort;
|
|
1189 |
+ table->table[TcpCount].dwRemoteAddr = tp->tcpConnRemAddress;
|
|
1190 |
+ table->table[TcpCount].dwRemotePort = tp->tcpConnRemPort;
|
|
1191 |
+
|
|
1192 |
+ TcpCount++;
|
|
1193 |
+ }
|
|
1194 |
+ }
|
|
1195 |
+
|
|
1196 |
+ table->dwNumEntries = TcpCount;
|
|
1197 |
+ mibfree(head);
|
|
1198 |
+ close(sd);
|
|
1199 |
+#elif defined(__linux__)
|
|
1200 |
/* get from /proc/net/tcp, no error if can't */
|
|
1201 |
fp = fopen("/proc/net/tcp", "r");
|
|
1202 |
if (!fp)
|
1650
|
1203 |
@@ -1735,6 +2608,9 @@
|
991
|
1204 |
}
|
|
1205 |
}
|
|
1206 |
fclose(fp);
|
|
1207 |
+#else
|
|
1208 |
+ ERR ("unimplemented!\n");
|
|
1209 |
+ return ERROR_NOT_SUPPORTED;
|
|
1210 |
#endif
|
|
1211 |
|
|
1212 |
return NO_ERROR;
|