summaryrefslogtreecommitdiff
path: root/net/net-snmp/patches/patch-ab
blob: 0195e0cd8b86fcea24a1a4aa02e7b28853b296b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
$NetBSD: patch-ab,v 1.2 2004/04/14 21:48:49 danw Exp $

--- agent/mibgroup/mibII/ipv6.c.orig	Fri May 17 12:05:12 2002
+++ agent/mibgroup/mibII/ipv6.c
@@ -11,7 +11,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/socket.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
 # if HAVE_SYS_SOCKETVAR_H
 #  include <sys/socketvar.h>
 # endif
@@ -80,7 +80,7 @@
 # include <netinet6/ip6_var.h>
 #endif
 #include <net/route.h>
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
 # if HAVE_NETINET_IN_PCB_H
 #  include <netinet/in_pcb.h>
 # endif
@@ -572,7 +572,7 @@ if_getifnet(int idx, struct ifnet *resul
             memcpy(result, &tmp, sizeof(tmp));
             return 0;
         }
-#if defined(__FreeBSD__) && 3 <= __FreeBSD__
+#if (defined(__FreeBSD__) && 3 <= __FreeBSD__) || defined(darwin)
         q = (caddr_t) TAILQ_NEXT(&tmp, if_link);
 #else
 # if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -801,7 +801,7 @@ var_ifv6Entry(register struct variable *
 
             if (if_getifnet(interface, &ifnet) < 0)
                 break;
-#if defined(__FreeBSD__) && 3 <= __FreeBSD__
+#if (defined(__FreeBSD__) && 3 <= __FreeBSD__) || defined(darwin)
             ifa = (caddr_t) TAILQ_FIRST(&ifnet.if_addrhead);
 #else
 # if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -822,7 +822,7 @@ var_ifv6Entry(register struct variable *
                     *var_len = sdl.sdl_alen;
                     return (u_char *) (sdl.sdl_data + sdl.sdl_nlen);
                 }
-#if defined(__FreeBSD__) && 3 <= __FreeBSD__
+#if (defined(__FreeBSD__) && 3 <= __FreeBSD__) || defined(darwin)
                 ifa = (caddr_t) TAILQ_NEXT(&ifaddr, ifa_link);
 #else
 # if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -1225,7 +1225,11 @@ var_udp6(register struct variable * vp,
     caddr_t         p;
     static struct in6pcb in6pcb, udb6;
     int             found, hitnext;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    struct inpcbtable udbtable;
+    caddr_t	    first;
+#endif
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
     char           *sysctl_buf;
     struct xinpgen *xig, *oxig;
 #endif                          /* defined(__FreeBSD__) && __FreeBSD__ >= 3 */
@@ -1234,7 +1238,11 @@ var_udp6(register struct variable * vp,
     DEBUGMSGOID(("mibII/ipv6", name, *length));
     DEBUGMSG(("mibII/ipv6", " %d\n", exact));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    if (!auto_nlist("udbtable", (char *) &udbtable, sizeof(udbtable)))
+        return NULL;
+    first = p = (caddr_t)udbtable.inpt_queue.cqh_first;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
     if (!auto_nlist("udb6", (char *) &udb6, sizeof(udb6)))
         return NULL;
     p = (caddr_t) udb6.in6p_next;
@@ -1260,7 +1268,9 @@ var_udp6(register struct variable * vp,
            (int) vp->namelen * sizeof(oid));
     DEBUGMSGTL(("mibII/ipv6", "start: p=%x\n", p));
     while (
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+              p &&  p != first
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
               p && (u_long) p != auto_nlist_value("udb6")
 #else
               xig->xig_len > sizeof(struct xinpgen)
@@ -1268,11 +1278,17 @@ var_udp6(register struct variable * vp,
         ) {
         DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb));
 #else
         in6pcb = ((struct xinpcb *) xig)->xi_inp;
 #endif
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	if (in6pcb.in6p_af != AF_INET6) {
+	    p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+	    continue;
+	}
+#endif
         j = (int) vp->namelen;
         for (i = 0; i < sizeof(struct in6_addr); i++)
             newname[j++] = in6pcb.in6p_laddr.s6_addr[i];
@@ -1325,13 +1341,15 @@ var_udp6(register struct variable * vp,
                 }
             }
         }
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         p = (caddr_t) in6pcb.in6p_next;
 #else
         xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
 #endif
     }
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
     free(sysctl_buf);
 #endif                          /* defined(__FreeBSD__) && __FreeBSD__ >= 3 */
     if (!found)
@@ -1383,7 +1401,11 @@ var_tcp6(register struct variable * vp,
     int             found, hitnext;
     static int      tcp6statemap[TCP6_NSTATES];
     static int      initialized = 0;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    struct inpcbtable tcbtable;
+    caddr_t	    first;
+#endif
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
     char           *sysctl_buf;
     struct xinpgen *xig, *oxig;
 #endif                          /* defined(__FreeBSD__) && __FreeBSD__ >= 3 */
@@ -1407,7 +1429,11 @@ var_tcp6(register struct variable * vp,
     DEBUGMSGOID(("mibII/ipv6", name, *length));
     DEBUGMSG(("mibII/ipv6", " %d\n", exact));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    if (!auto_nlist("tcbtable", (char *) &tcbtable, sizeof(tcbtable)))
+        return NULL;
+    first = p = (caddr_t)udbtable.inpt_queue.cqh_first;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
     if (!auto_nlist("tcb6", (char *) &tcb6, sizeof(tcb6)))
         return NULL;
     p = (caddr_t) tcb6.in6p_next;
@@ -1433,7 +1459,9 @@ var_tcp6(register struct variable * vp,
     memcpy((char *) newname, (char *) vp->name,
            (int) vp->namelen * sizeof(oid));
     while (
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+              p &&  p != first
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
               p && (u_long) p != auto_nlist_value("tcb6")
 #else
               xig->xig_len > sizeof(struct xinpgen)
@@ -1441,7 +1469,7 @@ var_tcp6(register struct variable * vp,
         ) {
         DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         if (klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
             DEBUGMSGTL(("mibII/ipv6", "klookup fail for in6pcb at %x\n",
                         p));
@@ -1450,6 +1478,12 @@ var_tcp6(register struct variable * vp,
 #else
         in6pcb = ((struct xinpcb *) xig)->xi_inp;
 #endif
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	if (in6pcb.in6p_af != AF_INET6) {
+	    p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+	    continue;
+	}
+#endif
         if (klookup
             ((u_long) in6pcb.in6p_ppcb, (char *) &tcp6cb, sizeof(tcp6cb))
             < 0) {
@@ -1520,13 +1554,15 @@ var_tcp6(register struct variable * vp,
         }
 
       skip:
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         p = (caddr_t) in6pcb.in6p_next;
 #else
         xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
 #endif
     }
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
     free(sysctl_buf);
 #endif
     DEBUGMSGTL(("mibII/ipv6", "found=%d\n", found));
@@ -1587,7 +1623,11 @@ var_tcp6(register struct variable * vp,
     int             found, hitnext;
     static int      tcpstatemap[TCP_NSTATES];
     static int      initialized = 0;
-#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    struct inpcbtable tcbtable;
+    caddr_t	    first;
+#endif
+#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
     char           *sysctl_buf;
     struct xinpgen *xig, *oxig;
 #endif                          /* defined(__FreeBSD__) && __FreeBSD__ >= 3 */
@@ -1611,7 +1651,11 @@ var_tcp6(register struct variable * vp,
     DEBUGMSGOID(("mibII/ipv6", name, *length));
     DEBUGMSG(("mibII/ipv6", " %d\n", exact));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+    if (!auto_nlist("tcbtable", (char *) &tcbtable, sizeof(tcbtable)))
+        return NULL;
+    first = p = (caddr_t)tcbtable.inpt_queue.cqh_first;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
     if (!auto_nlist("tcb6", (char *) &tcb6, sizeof(tcb6)))
         return NULL;
     p = (caddr_t) tcb6.in6p_next;
@@ -1637,7 +1681,9 @@ var_tcp6(register struct variable * vp,
     memcpy((char *) newname, (char *) vp->name,
            (int) vp->namelen * sizeof(oid));
     while (
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	      p && p != first
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
               p && (u_long) p != auto_nlist_value("tcb6")
 #else
               xig->xig_len > sizeof(struct xinpgen)
@@ -1645,16 +1691,22 @@ var_tcp6(register struct variable * vp,
         ) {
         DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
 
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         if (klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb)) < 0)
-#else
-        in6pcb = ((struct xinpcb *) xig)->xi_inp;
-#endif
         {
             DEBUGMSGTL(("mibII/ipv6", "klookup fail for in6pcb at %x\n",
                         p));
             break;
         }
+#else
+        in6pcb = ((struct xinpcb *) xig)->xi_inp;
+#endif
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	if (in6pcb.in6p_af != AF_INET6) {
+	    p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+	    continue;
+	}
+#endif
         if (klookup
             ((u_long) in6pcb.in6p_ppcb, (char *) &tcpcb, sizeof(tcpcb))
             < 0) {
@@ -1725,7 +1777,9 @@ var_tcp6(register struct variable * vp,
         }
 
       skip:
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3)
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	p = (caddr_t)in6pcb.in6p_queue.cqe_next;
+#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
         p = (caddr_t) in6pcb.in6p_next;
 #else
         xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
Index: agent/mibgroup/mibII/tcpTable.c
===================================================================
RCS file: /cvsroot/apps/net-snmp/agent/mibgroup/mibII/tcpTable.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- agent/mibgroup/mibII/tcpTable.c	12 Sep 2003 23:10:08 -0000	1.1.1.1
+++ agent/mibgroup/mibII/tcpTable.c	13 Sep 2003 05:36:50 -0000	1.2
@@ -499,6 +499,10 @@
             snmp_log_perror("TCP_Count_Connections - inpcb");
             break;
         }
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	if (inpcb.inp_af != AF_INET)
+	    continue;
+#endif
 #if !(defined(freebsd2) || defined(netbsd1) || defined(openbsd2))
         if (inpcb.INP_PREV_SYMBOL != prev) {    /* ??? */
             sleep(1);
Index: agent/mibgroup/mibII/udpTable.c
===================================================================
RCS file: /cvsroot/apps/net-snmp/agent/mibgroup/mibII/udpTable.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- agent/mibgroup/mibII/udpTable.c	12 Sep 2003 23:10:08 -0000	1.1.1.1
+++ agent/mibgroup/mibII/udpTable.c	13 Sep 2003 05:36:50 -0000	1.2
@@ -178,6 +178,16 @@
     LowState = -1;              /* UDP doesn't have 'State', but it's a useful flag */
     UDP_Scan_Init();
     for (;;) {
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000	/*1.6Y*/
+	if (inpcb.inp_af != AF_INET) {
+	    if ((i = UDP_Scan_Next(&inpcb)) < 0)
+		goto Again;
+	    if (i == 0)
+		break;              /* Done */
+	    cp = (u_char *) & inpcb.inp_laddr.s_addr;
+	    continue;
+	}
+#endif
 #ifdef hpux11
         if ((i = UDP_Scan_Next(&udp)) == 0)
             break;              /* Done */