|
device/network and tuning/ethernet had the same "/sys/class/net/"
directory traverse code with the only difference in post-actions (filling
all_tunables or nics/all_devices).
- Remove duplicate code and introduce function callback to perform mentioned
post-actions:
. netdev_callback -- (default) to fill nics and all_devices
. ethtunable_callback -- to fill all_tunables.
Signature of create_all_nics has been changed accordingly to accept
`typedef void (*callback)(const char*);' and "/sys/class/net/" traverse moved
to read_all_nics() (from original code removed unused `ifstream file', char
filename[4096] replaced with std::string later in netdev_callback).
- network::network(char*, char*) has been changed to accept const char*
parameters (T* to const T* cast is trivial), stack usage optimized by
replacing `char filename[4096]' with std::string.
Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
|