313 lines
12 KiB
Text
313 lines
12 KiB
Text
$NetBSD: patch-de,v 1.1 2006/03/19 22:03:29 joerg Exp $
|
|
|
|
--- agent/mibgroup/mibII/ipv6.c.orig 2005-11-16 19:44:51.000000000 +0000
|
|
+++ 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) || defined(darwin)
|
|
+#if defined(freebsd3) || 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) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
# if HAVE_NETINET_IN_PCB_H
|
|
# include <netinet/in_pcb.h>
|
|
# endif
|
|
@@ -575,7 +575,7 @@ if_getifnet(int idx, struct ifnet *resul
|
|
memcpy(result, &tmp, sizeof(tmp));
|
|
return 0;
|
|
}
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
q = (caddr_t) TAILQ_NEXT(&tmp, if_link);
|
|
#else
|
|
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
@@ -806,7 +806,7 @@ var_ifv6Entry(register struct variable *
|
|
|
|
if (if_getifnet(interface, &ifnet) < 0)
|
|
break;
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
ifa = (caddr_t) TAILQ_FIRST(&ifnet.if_addrhead);
|
|
#else
|
|
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
@@ -827,7 +827,7 @@ var_ifv6Entry(register struct variable *
|
|
*var_len = sdl.sdl_alen;
|
|
return (u_char *) (sdl.sdl_data + sdl.sdl_nlen);
|
|
}
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
ifa = (caddr_t) TAILQ_NEXT(&ifaddr, ifa_link);
|
|
#else
|
|
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
|
@@ -1230,7 +1230,11 @@ var_udp6(register struct variable * vp,
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
struct inpcbtable udbtable;
|
|
caddr_t first;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(dragonfly)
|
|
+ char *sysctl_buf;
|
|
+ struct xinpcb *xig;
|
|
+ size_t sysctl_len;
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
char *sysctl_buf;
|
|
struct xinpgen *xig, *oxig;
|
|
#else
|
|
@@ -1245,10 +1249,31 @@ var_udp6(register struct variable * vp,
|
|
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)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
if (!auto_nlist("udb6", (char *) &udb6, sizeof(udb6)))
|
|
return NULL;
|
|
p = (caddr_t) udb6.in6p_next;
|
|
+#elif defined(dragonfly)
|
|
+ {
|
|
+ const char *udblist = "net.inet.udp.pcblist";
|
|
+ const char *pp = udblist;
|
|
+
|
|
+ if (sysctlbyname(udblist, 0, &sysctl_len, 0, 0) < 0)
|
|
+ return NULL;
|
|
+ if ((sysctl_buf = malloc(sysctl_len)) == NULL)
|
|
+ return NULL;
|
|
+ udblist = pp;
|
|
+ if (sysctlbyname(udblist, sysctl_buf, &sysctl_len, 0, 0) < 0) {
|
|
+ free(sysctl_buf);
|
|
+ return NULL;
|
|
+ }
|
|
+ xig = (struct xinpcb *) sysctl_buf;
|
|
+ if (xig->xi_len != sizeof(*xig)) {
|
|
+ free(sysctl_buf);
|
|
+ return NULL;
|
|
+ }
|
|
+ p = (caddr_t) ((char *) xig); /* silence compiler warning */
|
|
+ }
|
|
#else
|
|
{
|
|
const char *udblist = "net.inet.udp.pcblist";
|
|
@@ -1276,15 +1301,17 @@ var_udp6(register struct variable * vp,
|
|
while (
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p && p != first
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p && (u_long) p != auto_nlist_value("udb6")
|
|
+#elif defined(dragonfly)
|
|
+ (char *)xig + xig->xi_len <= sysctl_buf + sysctl_len
|
|
#else
|
|
xig->xig_len > sizeof(struct xinpgen)
|
|
#endif
|
|
) {
|
|
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
|
|
|
|
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#if !defined(freebsd3) && !defined(darwin)
|
|
if (klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
|
|
DEBUGMSGTL(("mibII/ipv6", "klookup fail for udb6 at %x\n",
|
|
p));
|
|
@@ -1297,7 +1324,7 @@ var_udp6(register struct variable * vp,
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
if (in6pcb.in6p_af != AF_INET6)
|
|
goto skip;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
if (0 == (in6pcb.inp_vflag & INP_IPV6))
|
|
goto skip;
|
|
#endif
|
|
@@ -1340,13 +1367,15 @@ var_udp6(register struct variable * vp,
|
|
skip:
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p = (caddr_t)in6pcb.in6p_queue.cqe_next;
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p = (caddr_t) in6pcb.in6p_next;
|
|
+#elif defined(__DragonFly__)
|
|
+ xig = (struct xinpcb *) ((char *) xig + xig->xi_len);
|
|
#else
|
|
xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
|
|
#endif
|
|
}
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
free(sysctl_buf);
|
|
#endif
|
|
DEBUGMSGTL(("mibII/ipv6", "found=%d\n", found));
|
|
@@ -1405,7 +1434,7 @@ var_tcp6(register struct variable * vp,
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
struct inpcbtable tcbtable;
|
|
caddr_t first;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
char *sysctl_buf;
|
|
struct xinpgen *xig, *oxig;
|
|
#else
|
|
@@ -1435,7 +1464,7 @@ var_tcp6(register struct variable * vp,
|
|
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)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
if (!auto_nlist("tcb6", (char *) &tcb6, sizeof(tcb6)))
|
|
return NULL;
|
|
p = (caddr_t) tcb6.in6p_next;
|
|
@@ -1466,7 +1495,7 @@ var_tcp6(register struct variable * vp,
|
|
while (
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p && p != first
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p && (u_long) p != auto_nlist_value("tcb6")
|
|
#else
|
|
xig->xig_len > sizeof(struct xinpgen)
|
|
@@ -1474,7 +1503,7 @@ var_tcp6(register struct variable * vp,
|
|
) {
|
|
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
|
|
|
|
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#if !defined(freebsd3) && !defined(darwin)
|
|
if (klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
|
|
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6 at %x\n",
|
|
p));
|
|
@@ -1487,7 +1516,7 @@ var_tcp6(register struct variable * vp,
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
if (in6pcb.in6p_af != AF_INET6)
|
|
goto skip;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
if (0 == (in6pcb.inp_vflag & INP_IPV6))
|
|
goto skip;
|
|
#endif
|
|
@@ -1546,13 +1575,13 @@ var_tcp6(register struct variable * vp,
|
|
skip:
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p = (caddr_t)in6pcb.in6p_queue.cqe_next;
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p = (caddr_t) in6pcb.in6p_next;
|
|
#else
|
|
xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
|
|
#endif
|
|
}
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
free(sysctl_buf);
|
|
#endif
|
|
DEBUGMSGTL(("mibII/ipv6", "found=%d\n", found));
|
|
@@ -1644,7 +1673,11 @@ var_tcp6(register struct variable * vp,
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
struct inpcbtable tcbtable;
|
|
caddr_t first;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(dragonfly)
|
|
+ char *sysctl_buf;
|
|
+ size_t sysctl_len;
|
|
+ struct xtcpcb *xtp;
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
char *sysctl_buf;
|
|
struct xinpgen *xig, *oxig;
|
|
#else
|
|
@@ -1659,10 +1692,31 @@ var_tcp6(register struct variable * vp,
|
|
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)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
if (!auto_nlist("tcb6", (char *) &tcb6, sizeof(tcb6)))
|
|
return NULL;
|
|
p = (caddr_t) tcb6.in6p_next;
|
|
+#elif defined(dragonfly)
|
|
+ {
|
|
+ const char *tcblist = "net.inet.tcp.pcblist";
|
|
+ const char *pp = tcblist;
|
|
+
|
|
+ if (sysctlbyname(tcblist, 0, &sysctl_len, 0, 0) < 0)
|
|
+ return NULL;
|
|
+ if ((sysctl_buf = malloc(sysctl_len)) == NULL)
|
|
+ return NULL;
|
|
+ tcblist = pp;
|
|
+ if (sysctlbyname(tcblist, sysctl_buf, &sysctl_len, 0, 0) < 0) {
|
|
+ free(sysctl_buf);
|
|
+ return NULL;
|
|
+ }
|
|
+ xtp = (struct xtcpcb *) sysctl_buf;
|
|
+ if (xtp->xt_len != sizeof(*xtp)) {
|
|
+ free(sysctl_buf);
|
|
+ return NULL;
|
|
+ }
|
|
+ p = (caddr_t) ((char *) xtp); /* silence compiler warning */
|
|
+ }
|
|
#else
|
|
{
|
|
const char *tcblist = "net.inet.tcp.pcblist";
|
|
@@ -1679,7 +1733,8 @@ var_tcp6(register struct variable * vp,
|
|
return NULL;
|
|
}
|
|
oxig = (struct xinpgen *) sysctl_buf;
|
|
- xig = (struct xinpgen *) ((char *) oxig + oxig->xig_len);
|
|
+ xig = (struct xinpgen *) ((char *) oxtp + oxtp->xt_len);
|
|
+ if (oxig
|
|
p = (caddr_t) ((char *) xig); /* silence compiler warning */
|
|
}
|
|
#endif
|
|
@@ -1690,28 +1745,32 @@ var_tcp6(register struct variable * vp,
|
|
while (
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p && p != first
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p && (u_long) p != auto_nlist_value("tcb6")
|
|
+#elif defined(dragonfly)
|
|
+ (char *)xtp + xtp->xt_len < sysctl_buf + sysctl_len
|
|
#else
|
|
xig->xig_len > sizeof(struct xinpgen)
|
|
#endif
|
|
) {
|
|
DEBUGMSGTL(("mibII/ipv6", "looping: p=%x\n", p));
|
|
|
|
-#if !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#if !defined(freebsd3) && !defined(darwin)
|
|
if (klookup((u_long) p, (char *) &in6pcb, sizeof(in6pcb)) < 0) {
|
|
DEBUGMSGTL(("mibII/ipv6", "klookup fail for tcb6 at %x\n",
|
|
p));
|
|
found = 0;
|
|
break;
|
|
}
|
|
+#elif defined(dragonfly)
|
|
+ in6pcb = xtp->xt_inp;
|
|
#else
|
|
in6pcb = ((struct xinpcb *) xig)->xi_inp;
|
|
#endif
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
if (in6pcb.in6p_af != AF_INET6)
|
|
goto skip;
|
|
-#elif (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#elif defined(freebsd3) || defined(darwin)
|
|
if (0 == (in6pcb.inp_vflag & INP_IPV6))
|
|
goto skip;
|
|
#endif
|
|
@@ -1769,13 +1828,15 @@ var_tcp6(register struct variable * vp,
|
|
skip:
|
|
#if defined(__NetBSD__) && __NetBSD_Version__ >= 106250000 /*1.6Y*/
|
|
p = (caddr_t)in6pcb.in6p_queue.cqe_next;
|
|
-#elif !(defined(__FreeBSD__) && __FreeBSD__ >= 3) && !defined(darwin)
|
|
+#elif !defined(freebsd3) && !defined(darwin)
|
|
p = (caddr_t) in6pcb.in6p_next;
|
|
+#elif defined(dragonfly)
|
|
+ xtp = (struct xtcpcb *) ((char *)xtp + xtp->xt_len);
|
|
#else
|
|
xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
|
|
#endif
|
|
}
|
|
-#if (defined(__FreeBSD__) && __FreeBSD__ >= 3) || defined(darwin)
|
|
+#if defined(freebsd3) || defined(darwin)
|
|
free(sysctl_buf);
|
|
#endif
|
|
DEBUGMSGTL(("mibII/ipv6", "found=%d\n", found));
|