2020-04-04 08:19:30 -03:00
|
|
|
/*
|
2021-04-28 17:46:44 -03:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2020-04-04 08:19:30 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-04 08:19:30 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "DHCPv4Client.h"
|
2022-05-07 09:59:34 -03:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2020-04-04 08:19:30 -03:00
|
|
|
#include <LibCore/EventLoop.h>
|
2021-11-29 17:35:04 -03:00
|
|
|
#include <LibCore/System.h>
|
|
|
|
|
#include <LibMain/Main.h>
|
2020-04-04 08:19:30 -03:00
|
|
|
|
2022-05-07 09:59:34 -03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments args)
|
2020-04-04 08:19:30 -03:00
|
|
|
{
|
2022-05-07 09:59:34 -03:00
|
|
|
Vector<String> interfaces;
|
|
|
|
|
|
|
|
|
|
Core::ArgsParser parser;
|
|
|
|
|
parser.add_positional_argument(interfaces, "Interfaces to run DHCP server on", "interfaces");
|
|
|
|
|
parser.parse(args);
|
|
|
|
|
|
2021-11-29 17:35:04 -03:00
|
|
|
TRY(Core::System::pledge("stdio unix inet cpath rpath"));
|
2020-04-04 08:19:30 -03:00
|
|
|
Core::EventLoop event_loop;
|
|
|
|
|
|
2021-11-29 17:35:04 -03:00
|
|
|
TRY(Core::System::unveil("/proc/net/", "r"));
|
|
|
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
2020-04-04 08:19:30 -03:00
|
|
|
|
2022-05-07 09:59:34 -03:00
|
|
|
auto client = TRY(DHCPv4Client::try_create(interfaces));
|
2020-04-04 08:19:30 -03:00
|
|
|
|
2021-11-29 17:35:04 -03:00
|
|
|
TRY(Core::System::pledge("stdio inet cpath rpath"));
|
2020-04-04 08:19:30 -03:00
|
|
|
return event_loop.exec();
|
|
|
|
|
}
|