| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
|---|---|
| 2 | |
| 3 | #include "proto/net-networkd.service.h" |
| 4 | |
| 5 | #include <iostream> |
| 6 | #include <librpc/rpc.h> |
| 7 | #include <libsm.h> |
| 8 | #include <memory> |
| 9 | |
| 10 | constexpr auto NETWORKD_SERVICE_NAME = "mos.networkd"; |
| 11 | |
| 12 | class NetworkDaemonImpl : public INetworkManagerService |
| 13 | { |
| 14 | public: |
| 15 | explicit NetworkDaemonImpl() : INetworkManagerService(NETWORKD_SERVICE_NAME) |
| 16 | { |
| 17 | std::cout << program_invocation_name << ": "<< "NetworkDaemonImpl constructor"<< std::endl; |
| 18 | } |
| 19 | |
| 20 | public: |
| 21 | rpc_result_code_t register_network_device(rpc_context_t *, RegisterNetworkDeviceRequest *request, RegisterNetworkDeviceResponse *response) override |
| 22 | { |
| 23 | std::cerr << "Registering network device: "<< request->device_name << " with server: "<< request->rpc_server_name << std::endl; |
| 24 | response->result.success = true; |
| 25 | response->result.error = nullptr; |
| 26 | return RPC_RESULT_OK; |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | const auto NetworkDaemon = std::make_shared<NetworkDaemonImpl>(); |
| 31 | |
| 32 | int main(int, char **) |
| 33 | { |
| 34 | std::cout << program_invocation_name << ": "<< "Starting networkd"<< std::endl; |
| 35 | ReportServiceState(status: UnitStatus::Started, message: "started networkd"); |
| 36 | NetworkDaemon->run(); |
| 37 | |
| 38 | ReportServiceState(status: UnitStatus::Stopping, message: "stopping networkd"); |
| 39 | |
| 40 | ReportServiceState(status: UnitStatus::Stopped, message: "stopping networkd"); |
| 41 | return 0; |
| 42 | } |
| 43 |