mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:27:35 +00:00
Kernel+Userland: Expose list of network adapters through /proc/netadapters.
Added a simple /bin/ifconfig program that just pretty-prints that file. :^)
This commit is contained in:
parent
264890bfc3
commit
9e0f7acfe5
6 changed files with 69 additions and 0 deletions
30
Userland/ifconfig.cpp
Normal file
30
Userland/ifconfig.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <LibCore/CFile.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
UNUSED_PARAM(argc);
|
||||
UNUSED_PARAM(argv);
|
||||
|
||||
CFile file("/proc/netadapters");
|
||||
if (!file.open(CIODevice::ReadOnly)) {
|
||||
fprintf(stderr, "Error: %s\n", file.error_string());
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
auto line = file.read_line(1024);
|
||||
if (line.is_null())
|
||||
break;
|
||||
auto parts = String::copy(line, Chomp).split(',');
|
||||
if (parts.size() < 4)
|
||||
continue;
|
||||
printf("%s:\n", parts[0].characters());
|
||||
printf(" mac: %s\n", parts[2].characters());
|
||||
printf(" ipv4: %s\n", parts[3].characters());
|
||||
printf(" class: %s\n", parts[1].characters());
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue