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
|
$NetBSD: patch-ac,v 1.4 2005/02/24 15:49:26 tron Exp $
--- src/kernel/netbsd.c.orig 2003-02-12 02:15:59.000000000 +0000
+++ src/kernel/netbsd.c 2005-02-24 15:40:54.000000000 +0000
@@ -29,6 +29,7 @@
#include <errno.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/param.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <netinet/in.h>
@@ -99,7 +100,11 @@
kinfo->nl[N_TCB].n_name = "_tcbtable";
#ifdef WANT_IPV6
+#if __NetBSD_Version__ >= 106250000 /* 1.6Y */
+ kinfo->nl[N_TCB6].n_name = "_tcbtable";
+#else
kinfo->nl[N_TCB6].n_name = "_tcb6";
+#endif
#else
kinfo->nl[N_TCB6].n_name = "_oidentd_nonexistent";
#endif
@@ -162,7 +167,7 @@
if (tcbtablep == NULL)
return (NULL);
- kpcbp = tcbtablep->inpt_queue.cqh_first;
+ kpcbp = (struct inpcb *) tcbtablep->inpt_queue.cqh_first;
while (kpcbp != (struct inpcb *) ktcbtablep) {
if (getbuf((u_long) kpcbp, &pcb, sizeof(struct inpcb)) == -1)
break;
@@ -185,7 +190,7 @@
return (pcb.inp_socket);
}
- kpcbp = pcb.inp_queue.cqe_next;
+ kpcbp = (struct inpcb *) pcb.inp_queue.cqe_next;
}
return (NULL);
@@ -327,12 +332,38 @@
** Returns NULL if no match.
*/
+#if __NetBSD_Version__ >= 106250000
+static struct socket *getlist6( struct inpcbtable *tcbtablep,
+ struct inpcbtable *ktcbtablep,
+#else
static struct socket *getlist6( struct in6pcb *tcb6,
+#endif
in_port_t lport,
in_port_t fport,
const struct in6_addr *laddr,
const struct in6_addr *faddr)
{
+#if __NetBSD_Version__ >= 106250000
+ struct in6pcb *kpcbp, pcb;
+
+ if (tcbtablep == NULL)
+ return (NULL);
+
+ kpcbp = (struct in6pcb *) tcbtablep->inpt_queue.cqh_first;
+ while (kpcbp != (struct in6pcb *) ktcbtablep) {
+ if (getbuf((u_long) kpcbp, &pcb, sizeof(struct in6pcb)) == -1)
+ break;
+ if (pcb.in6p_fport == fport &&
+ pcb.in6p_lport == lport &&
+ IN6_ARE_ADDR_EQUAL(&pcb.in6p_laddr, laddr) &&
+ IN6_ARE_ADDR_EQUAL(&pcb.in6p_faddr, faddr))
+ {
+ return (pcb.in6p_socket);
+ }
+
+ kpcbp = (struct in6pcb *) pcb.in6p_queue.cqe_next;
+ }
+#else
struct in6pcb *tcb6_cur, tcb6_temp;
if (tcb6 == NULL)
@@ -355,7 +386,7 @@
if (getbuf((u_long) tcb6_cur, &tcb6_temp, sizeof(tcb6_temp)) == -1)
break;
} while ((u_long) tcb6_cur != kinfo->nl[N_TCB6].n_value);
-
+#endif
return (NULL);
}
@@ -368,6 +399,19 @@
struct sockaddr_storage *laddr,
struct sockaddr_storage *faddr)
{
+#if __NetBSD_Version__ >= 106250000 /* 1.6Y */
+ struct socket *sockp, sock;
+ struct inpcbtable tcbtable;
+ int ret;
+
+ ret = getbuf(kinfo->nl[N_TCB6].n_value, &tcbtable, sizeof(tcbtable));
+ if (ret == -1)
+ return (-1);
+
+ sockp = getlist6(&tcbtable,
+ (struct inpcbtable *) kinfo->nl[N_TCB6].n_value,
+ lport, fport, &SIN6(laddr)->sin6_addr, &SIN6(faddr)->sin6_addr);
+#else
struct socket *sockp, sock;
struct in6pcb tcb6;
int ret;
@@ -378,6 +422,7 @@
sockp = getlist6(&tcb6, lport, fport,
&SIN6(laddr)->sin6_addr, &SIN6(faddr)->sin6_addr);
+#endif
if (sockp == NULL)
return (-1);
|