$NetBSD: patch-dr,v 1.2 2008/09/08 12:58:09 adam Exp $

--- agent/mibgroup/mibII/tcpTable.c.orig	2007-10-14 14:12:58.000000000 +0200
+++ agent/mibgroup/mibII/tcpTable.c
@@ -719,7 +719,11 @@ tcpTable_load(netsnmp_cache *cache, void
     size_t   len;
     int      sname[] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_PCBLIST };
     char     *tcpcb_buf = NULL;
+#if defined(dragonfly)
+    struct xtcpcb *xig = NULL;
+#else
     struct xinpgen *xig = NULL;
+#endif
     netsnmp_inpcb  *nnew;
     int      StateMap[] = { 1, 2, 3, 4, 5, 8, 6, 10, 9, 7, 11 };
 
@@ -741,10 +745,18 @@ tcpTable_load(netsnmp_cache *cache, void
      *  Unpick this into the constituent 'xinpgen' structures, and extract
      *     the 'inpcb' elements into a linked list (built in reverse)
      */
+#if defined(dragonfly)
+    xig = (struct xtcpcb *) tcpcb_buf;
+#else
     xig = (struct xinpgen *) tcpcb_buf;
     xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
+#endif
 
+#if defined(dragonfly)
+    while (xig && ((char *)xig + xig->xt_len < tcpcb_buf + len)) {
+#else
     while (xig && (xig->xig_len > sizeof(struct xinpgen))) {
+#endif
         nnew = SNMP_MALLOC_TYPEDEF(netsnmp_inpcb);
         if (!nnew)
             break;
@@ -757,7 +769,11 @@ tcpTable_load(netsnmp_cache *cache, void
 
 	nnew->inp_next = tcp_head;
 	tcp_head   = nnew;
+#if defined(dragonfly)
+        xig = (struct xtcpcb *) ((char *) xig + xig->xt_len);
+#else
         xig = (struct xinpgen *) ((char *) xig + xig->xig_len);
+#endif
     }
 
     free(tcpcb_buf);
