summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannik Schönartz2021-02-02 15:11:35 +0100
committerJannik Schönartz2021-02-02 15:11:35 +0100
commit0c0765e3e3b8893761773d3bd792b47871b62f0d (patch)
tree3d84d8adc05a19d11760a635b3238ffdfb1003f6
parent[server/pci] Add lib for downloading and parsing the current pci id file (diff)
downloadbas-0c0765e3e3b8893761773d3bd792b47871b62f0d.tar.gz
bas-0c0765e3e3b8893761773d3bd792b47871b62f0d.tar.xz
bas-0c0765e3e3b8893761773d3bd792b47871b62f0d.zip
[server/pci] Restructure parseIds output & small bug fixes
-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)) {