summaryrefslogtreecommitdiff
path: root/Userland/Services/DHCPClient/main.cpp
blob: 70055f8c14b20265f38e098f3a681d1b12d0c4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include "DHCPv4Client.h"
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
#include <LibCore/EventLoop.h>
#include <LibCore/LocalServer.h>
#include <stdio.h>
#include <unistd.h>

int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
    if (pledge("stdio unix inet cpath rpath", nullptr) < 0) {
        perror("pledge");
        return 1;
    }

    Core::EventLoop event_loop;

    if (unveil("/proc/net/", "r") < 0) {
        perror("unveil");
        return 1;
    }

    unveil(nullptr, nullptr);

    auto client = DHCPv4Client::construct();

    if (pledge("stdio inet cpath rpath", nullptr) < 0) {
        perror("pledge");
        return 1;
    }

    return event_loop.exec();
}