diff --git a/src/lib/hardware/pci.lua b/src/lib/hardware/pci.lua index 8b5cc5f79c..6f51838ab2 100644 --- a/src/lib/hardware/pci.lua +++ b/src/lib/hardware/pci.lua @@ -98,24 +98,6 @@ function set_bus_master (device, enable) assert(C.pwrite(fd, value, 2, 0x4) == 2) end ---- ### Open a device ---- ---- Load a device driver for a devie. A fresh copy of the device ---- driver's Lua module is loaded for each device and the module is ---- told at load-time the PCI address of the device it is controlling. ---- This makes the driver source code short because it can assume that ---- it's always talking to the same device. ---- ---- This is achieved with our own require()-like function that loads a ---- fresh copy and passes the PCI address as an argument. - -open_devices = {} - --- Load a new instance of the 'driver' module for 'pciaddress'. -function open_device(pciaddress, driver) - return require(driver).new(pciaddress) -end - --- ### Selftest --- --- PCI selftest scans for available devices and performs our driver's @@ -123,6 +105,7 @@ end function selftest () print("selftest: pci") + scan_devices() print_device_summary() end diff --git a/src/lib/pcap/pcap.lua b/src/lib/pcap/pcap.lua index f0b96943bc..6cc76d5d08 100644 --- a/src/lib/pcap/pcap.lua +++ b/src/lib/pcap/pcap.lua @@ -22,13 +22,6 @@ struct pcap_record { uint32_t incl_len; /* number of octets of packet saved in file */ uint32_t orig_len; /* actual length of packet */ }; - -struct pcap_record_extra { - /* Extra metadata that we append to the pcap record, after the payload. */ - uint32_t port_id; /* port the packet is captured on */ - uint32_t flags; /* bit 0 set means input, bit 0 clear means output */ - uint64_t reserved0, reserved1, reserved2, reserved3; -}; ]] function write_file_header(file) @@ -42,9 +35,6 @@ function write_file_header(file) file:flush() end -local pcap_extra = ffi.new("struct pcap_record_extra") -ffi.fill(pcap_extra, ffi.sizeof(pcap_extra), 0) - function write_record (file, ffi_buffer, length) write_record_header(file, length) file:write(ffi.string(ffi_buffer, length)) @@ -73,11 +63,7 @@ function records (filename) if record == nil then return nil end local datalen = math.min(record.orig_len, record.incl_len) local packet = file:read(datalen) - local extra = nil - if record.incl_len == #packet + ffi.sizeof("struct pcap_record_extra") then - extra = readc(file, "struct pcap_record_extra") - end - return packet, record, extra + return packet, record end return pcap_records_it, true, true end @@ -90,6 +76,6 @@ function readc(file, type) error("short read of " .. type .. " from " .. tostring(file)) end local obj = ffi.new(type) - ffi.copy(obj, string) + ffi.copy(obj, string, ffi.sizeof(type)) return obj end