- while (next != head) {
- kread((u_long)next, &inpcb, sizeof(inpcb));
- prev = next;
- next = CIRCLEQ_NEXT(&inpcb, inp_queue);
- if (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY)
+ while (next != head)
+ {
+ /* Read the pcb pointed to by `next' into `inpcb' */
+ kread ((u_long) next, &inpcb, sizeof (inpcb));
+
+ /* Advance `next' */
+ next = (struct inpcb *)CIRCLEQ_NEXT (&inpcb, inp_queue);
+
+ /* Ignore sockets, that are not connected. */
+#ifdef __NetBSD__
+ if (inpcb.inp_af == AF_INET6)
+ continue; /* XXX see netbsd/src/usr.bin/netstat/inet6.c */
+#else
+ if (!(inpcb.inp_flags & INP_IPV6)
+ && (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY))
+ continue;
+ if ((inpcb.inp_flags & INP_IPV6)
+ && IN6_IS_ADDR_UNSPECIFIED (&inpcb.inp_laddr6))