3-Jun-2004 Mike Slifcak

This patch fixes compiling the host hr_swrun module in order to
build Net-SNMP-5.1 or later on FreeBSD 5.x

Patch using net-snmp-5.1.1 or V5-1-patdhes branch,
Built using FreeBSD 5.2.1

--- net-snmp-5.1.1/agent/mibgroup/host/hr_swrun.c	Tue Feb 17 00:35:24 2004
+++ net-snmp/agent/mibgroup/host/hr_swrun.c	Thu Jun  3 21:48:51 2004
@@ -585,7 +585,11 @@
         string[ sizeof(string)-1 ] = 0;
 #endif
 #elif HAVE_KVM_GETPROCS
+    #if defined(freebsd5)
+        strcpy(string, proc_table[LowProcIndex].ki_comm);
+    #else
         strcpy(string, proc_table[LowProcIndex].kp_proc.p_comm);
+    #endif
 #elif defined(linux)
         sprintf(string, "/proc/%d/status", pid);
         if ((fp = fopen(string, "r")) == NULL)
@@ -690,7 +694,11 @@
         *cp1 = 0;
 #endif
 #elif HAVE_KVM_GETPROCS
+    #if defined(freebsd5)
+        strcpy(string, proc_table[LowProcIndex].ki_comm);
+    #else
         strcpy(string, proc_table[LowProcIndex].kp_proc.p_comm);
+    #endif
 #elif defined(linux)
         sprintf(string, "/proc/%d/cmdline", pid);
         if ((fp = fopen(string, "r")) == NULL)
@@ -881,7 +889,11 @@
         }
 #else
 #if HAVE_KVM_GETPROCS
+    #if defined(freebsd5)
+        switch (proc_table[LowProcIndex].ki_stat) {
+    #else
         switch (proc_table[LowProcIndex].kp_proc.p_stat) {
+    #endif
 #elif defined(dynix)
         switch (lowpsinfo.pr_state) {
 #elif defined(solaris2)
@@ -976,9 +988,13 @@
         long_return = proc_buf->p_utime * 100 + proc_buf->p_stime * 100;
 #endif
 #elif HAVE_KVM_GETPROCS
+    #if defined(freebsd5)
+        long_return = proc_table[LowProcIndex].ki_runtime / 100000;
+    #else
         long_return = proc_table[LowProcIndex].kp_proc.p_uticks +
             proc_table[LowProcIndex].kp_proc.p_sticks +
             proc_table[LowProcIndex].kp_proc.p_iticks;
+    #endif
 #elif defined(linux)
         sprintf(string, "/proc/%d/stat", pid);
         if ((fp = fopen(string, "r")) == NULL)
@@ -1049,7 +1065,11 @@
 #elif HAVE_KVM_GETPROCS
 #if defined(freebsd3) && !defined(darwin)
         long_return =
+    #if defined(freebsd5)
+            proc_table[LowProcIndex].ki_size / 1024;
+    #else
             proc_table[LowProcIndex].kp_eproc.e_vm.vm_map.size / 1024;
+    #endif
 #else
         long_return = proc_table[LowProcIndex].kp_eproc.e_vm.vm_tsize +
             proc_table[LowProcIndex].kp_eproc.e_vm.vm_ssize +
@@ -1329,8 +1349,13 @@
 #elif defined(solaris2)
         return proc_table[current_proc_entry++];
 #elif HAVE_KVM_GETPROCS
+    #if defined(freebsd5)
+        if (proc_table[current_proc_entry].ki_stat != 0)
+            return proc_table[current_proc_entry++].ki_pid;
+    #else
         if (proc_table[current_proc_entry].kp_proc.p_stat != 0)
             return proc_table[current_proc_entry++].kp_proc.p_pid;
+    #endif
 #else
         if (proc_table[current_proc_entry].p_stat != 0)
             return proc_table[current_proc_entry++].p_pid;
