fix: do not proceed with DHCP if no network device with an active link is present
This commit is contained in:
1 parent
24f88ec4c6
commit
41de95b277
2 files changed
+18
-1
No files matched your search
@@ -12,4 +12,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define MONTAUK_BUILD_NUMBER 276
|
||||
#define MONTAUK_BUILD_NUMBER 278
|
||||
@@ -250,6 +250,23 @@ extern "C" void _start() {
|
||||
|
||||
montauk::service_log("MontaukOS DHCP Client");
|
||||
|
||||
// 0. Check if any device with an up link even exists.
|
||||
montauk::abi::NetIfInfo ifs[4];
|
||||
int n = montauk::net_interfaces(ifs, 4);
|
||||
|
||||
bool link = false;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (ifs[i].linkUp == true) {
|
||||
link = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (link == false) {
|
||||
montauk::service_log("Unable to locate a network device with an active link.\n");
|
||||
montauk::exit(montauk::StatusCodes::NoDevice);
|
||||
}
|
||||
|
||||
// 1. Get MAC address
|
||||
montauk::abi::NetCfg origCfg;
|
||||
montauk::get_netcfg(&origCfg);
|
||||
|
||||
Reference in new issue
Block a user