summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/lib/pci/index.js34
1 files changed, 22 insertions, 12 deletions
diff --git a/server/lib/pci/index.js b/server/lib/pci/index.js
index 5a7d468..282ad1f 100644
--- a/server/lib/pci/index.js
+++ b/server/lib/pci/index.js
@@ -18,16 +18,26 @@ module.exports = {
if (Object.keys(parsedPciList).length === 0) await parsePciList()
let pciInformation = {
- 'vendorId': vendorId,
- 'vendor': vendorId ? parsedPciList[vendorId].name : undefined,
- 'deviceId': deviceId,
- 'device': deviceId ? parsedPciList[vendorId].devices[deviceId].name : undefined,
- 'subvendorId': subvendorId,
- 'subvendor': (subvendorId && subdeviceId) ? parsedPciList[vendorId].devices[deviceId].subsystems[subvendorId][subdeviceId].name : undefined,
- 'classId': classId,
- 'class': classId ? parsedDeviceClasses[classId].name : undefined,
- 'subclassId': subclassId,
- 'subclass': subclassId ? parsedDeviceClasses[classId].subclasses[subclassId].name : undefined
+ 'vendor': vendorId && vendorId.length === 4 ? {
+ 'id': vendorId,
+ 'name': parsedPciList[vendorId].name,
+ 'device': deviceId && deviceId.length === 4 ? {
+ 'id': deviceId,
+ 'name': deviceId ? parsedPciList[vendorId].devices[deviceId].name : undefined,
+ 'subvendor': subvendorId && subdeviceId && subvendorId.length === 4 && subdeviceId.length === 4 ? {
+ 'id': subvendorId,
+ 'name': parsedPciList[vendorId].devices[deviceId].subsystems[subvendorId][subdeviceId].name
+ } : undefined
+ } : undefined
+ } : undefined,
+ 'class': classId && classId.length === 2 ? {
+ 'id': classId,
+ 'name': parsedDeviceClasses[classId].name,
+ 'subclass': subclassId && subclassId.length === 2 ? {
+ 'id': subclassId,
+ 'name': parsedDeviceClasses[classId].subclasses[subclassId].name
+ } : undefined
+ } : undefined
}
return pciInformation
@@ -165,8 +175,8 @@ function parsePciList () {
const subdevice = line.substring(7, 11)
const subsystem = line.substring(13)
- if (result[lastVendorId].devices[lastDeviceId].subsystems[subvendor] === undefined) result[lastVendorId].devices[lastDeviceId][subvendor] = {}
- result[lastVendorId].devices[lastDeviceId][subvendor][subdevice] = {
+ if (result[lastVendorId].devices[lastDeviceId].subsystems[subvendor] === undefined) result[lastVendorId].devices[lastDeviceId].subsystems[subvendor] = {}
+ result[lastVendorId].devices[lastDeviceId].subsystems[subvendor][subdevice] = {
'name': subsystem
}
} else if (line.match(regexClass)) {