Index: include/discover/discover.h
===================================================================
--- include/discover/discover.h	(revisjon 1150)
+++ include/discover/discover.h	(arbeidskopi)
@@ -148,13 +148,14 @@
     PCI,
     PCMCIA,
     SCSI,
-    USB
+    USB,
+    DMI
 } discover_bus_t;
 
 /**
  * Number of buses we support
  * */
-#define BUS_COUNT 5
+#define BUS_COUNT 6
 
 /**
  * Enumerate the types of data files: vendor, busclass, and device.
Index: include/discover/sysdep.h
===================================================================
--- include/discover/sysdep.h	(revisjon 1150)
+++ include/discover/sysdep.h	(arbeidskopi)
@@ -76,6 +76,7 @@
 discover_sysdep_data_t *_discover_get_usb_raw(void);
 discover_sysdep_data_t *_discover_get_pcmcia_raw(void);
 discover_sysdep_data_t *_discover_get_scsi_raw(void);
+discover_sysdep_data_t *_discover_get_dmi_raw(void);
 
 #ifdef __cplusplus
     }
Index: sysdeps/linux/Makefile.in
===================================================================
--- sysdeps/linux/Makefile.in	(revisjon 1150)
+++ sysdeps/linux/Makefile.in	(arbeidskopi)
@@ -7,8 +7,8 @@
 ###############################################################################
 # Build
 
-SOURCES=		ata.c pci.c pcmcia.c usb.c scsi.c
-OBJS=			ata.lo pci.lo pcmcia.lo usb.lo scsi.lo
+SOURCES=		ata.c pci.c pcmcia.c usb.c scsi.c dmi.c
+OBJS=			ata.lo pci.lo pcmcia.lo usb.lo scsi.lo dmi.lo
 
 libsysdeps.la: ${OBJS}
 	${LTLINK} -o $@ ${OBJS}
Index: sysdeps/linux/dmi.c
===================================================================
--- sysdeps/linux/dmi.c	(revisjon 0)
+++ sysdeps/linux/dmi.c	(revisjon 0)
@@ -0,0 +1,144 @@
+/* dmi.c -- Scan the DMI "bus"
+ *
+ * AUTHORS: Petter Reinholdtsen <pere@hungry.com>
+ *
+ * Copyright 2006 Petter Reinholdtsen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <discover/sysdep.h>
+#include <discover/utils.h>
+
+/*
+ * This function is specific to each sysdep.
+ */
+static void
+_discover_sysdep_init(discover_sysdep_data_t *node)
+{
+    node->busclass = _discover_xmalloc(200);
+    node->vendor = _discover_xmalloc(200);
+    node->model = _discover_xmalloc(200);
+}
+
+#define PATH_DMIDECODE "/usr/sbin/dmidecode"
+
+/*
+
+Example entry
+
+Handle 0x0003, DMI type 3, 17 bytes
+Chassis Information
+        Manufacturer: IBM
+        Type: Notebook
+        Lock: Not Present
+        Version: Not Available
+        Serial Number: Not Available
+        Asset Tag: No Asset Information
+        Boot-up State: Unknown
+        Power Supply State: Unknown
+        Thermal State: Unknown
+        Security Status: Unknown
+        OEM Information: 0x00000000
+
+*/
+discover_sysdep_data_t *
+_discover_get_dmi_raw(void)
+{
+    FILE *f;
+    char *line = NULL;
+    size_t len = 0;
+    discover_sysdep_data_t *head = NULL, *node, *last = NULL;
+    unsigned int id;
+    char key[200], value[200];
+
+    if ((f = popen(PATH_DMIDECODE, "r"))) {
+        while (getline(&line, &len, f) >= 0) {
+
+            if (strstr(line, "Handle 0x")) {
+
+	        node = _discover_sysdep_data_new();
+		_discover_sysdep_init(node);
+
+                sscanf(line, "Handle 0x%*[^,], DMI type %[^,], %*s bytes\n",
+                       node->busclass);
+		/* printf("B: '%s'\n", node->busclass); */
+		if (0 > getline(&line, &len, f)) /* Skip next line */
+		    break;
+
+		const char *vendorkey = NULL;
+		const char *modelkey = NULL;
+		switch (atoi(node->busclass)) /* DMI type */{
+		    case 1: {/* System */
+		        vendorkey = "Manufacturer";
+		        modelkey = "Version";
+			break;
+		    }
+		    case 4: {/* Processor */
+		        vendorkey = "Manufacturer";
+		        modelkey = "Family";
+			break;
+		    }
+		    case 38: {/* IPMI */
+		        vendorkey = "Interface Type";
+		        modelkey = "Specification Version";
+			break;
+		    }
+		    default:
+		        break;
+		}
+		if (!vendorkey) { /* Unhandled bus class, skip it */
+		    free(node->busclass);
+		    free(node->vendor);
+		    free(node->model);
+		    free(node);
+		    continue;
+		}
+                while (getline(&line, &len, f) >= 0){
+                    if(strstr(line, "\t") && !strstr(line, "\t\t")) {
+                        sscanf(line, "\t%[^:]: %[^\n]\n", key, value);
+			if (0 == strcmp(key, vendorkey))
+			    snprintf(node->vendor, 200, "%s", value);
+			if (0 == strcmp(key, modelkey))
+			    snprintf(node->model, 200, "%s", value);
+
+                    } else {
+                        break;
+		    }
+                }
+		printf("Loaded bus '%s' vendor '%s' model '%s'\n",
+		       node->busclass, node->vendor, node->model);
+
+                if (head == NULL) {
+                    head = node;
+                    last = head;
+                } else {
+                    last->next = node;
+                    last = node;
+                }
+            }
+        }
+        pclose(f);
+        free(line);
+    }
+
+    return head;
+}
Index: sysdeps/stub/stubs.c
===================================================================
--- sysdeps/stub/stubs.c	(revisjon 1150)
+++ sysdeps/stub/stubs.c	(arbeidskopi)
@@ -54,6 +54,15 @@
 }
 
 /**
+ * Get the list of DMI entries, scanning the bus if necessary.
+ */
+discover_sysdep_data_t *
+_discover_get_dmi_raw(void)
+{
+    return NULL;
+}
+
+/**
  * Get the list of PCI devices, scanning the bus if necessary.
  */
 discover_sysdep_data_t *
Index: lib/sysdep.c
===================================================================
--- lib/sysdep.c	(revisjon 1150)
+++ lib/sysdep.c	(arbeidskopi)
@@ -53,7 +53,8 @@
     _discover_get_pci_raw,
     _discover_get_pcmcia_raw,
     _discover_get_scsi_raw,
-    _discover_get_usb_raw
+    _discover_get_usb_raw,
+    _discover_get_dmi_raw
 };
 
 
Index: lib/conf.c
===================================================================
--- lib/conf.c	(revisjon 1150)
+++ lib/conf.c	(arbeidskopi)
@@ -73,6 +73,7 @@
     { "pcmcia", 0, 0, NULL },
     { "scsi", 0, 0, NULL },
     { "usb", 0, 0, NULL },
+    { "dmi", 0, 0, NULL },
     { NULL }
 };
 
