networkd.c revision a553fd32d14739b746a05ae502b8acc38e5f9a50
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering/***
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering This file is part of systemd.
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering Copyright 2013 Tom Gundersen <teg@jklm.no>
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering systemd is free software; you can redistribute it and/or modify it
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering under the terms of the GNU Lesser General Public License as published by
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering the Free Software Foundation; either version 2.1 of the License, or
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering (at your option) any later version.
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering systemd is distributed in the hope that it will be useful, but
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering Lesser General Public License for more details.
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering You should have received a copy of the GNU Lesser General Public License
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering***/
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering#include "sd-event.h"
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering#include "sd-daemon.h"
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering#include "networkd.h"
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poetteringint main(int argc, char *argv[]) {
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering _cleanup_manager_free_ Manager *m;
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering int r;
72667f0890372a952a7c5b8cc498ec3cf9440973Lennart Poettering
2b442ac87838be7c326c984d8751c96dee7258abLennart Poettering log_set_target(LOG_TARGET_AUTO);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering log_parse_environment();
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering log_open();
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen umask(0022);
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen if (argc != 1) {
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen log_error("This program takes no arguments.");
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen r = -EINVAL;
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen goto out;
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen }
111befce5514d590e9b334a547559bd0ecf8df8dThomas Hindoe Paaboel Andersen
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering r = manager_new(&m);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering if (r < 0)
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering goto out;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering r = manager_udev_listen(m);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering if (r < 0)
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering goto out;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering r = manager_udev_enumerate_links(m);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering if (r < 0)
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering goto out;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering r = manager_rtnl_listen(m);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering if (r < 0)
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering goto out;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering sd_notify(false,
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering "READY=1\n"
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering "STATUS=Processing requests...");
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering r = sd_event_loop(m->event);
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering if (r < 0)
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering goto out;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poetteringout:
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering sd_notify(false,
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering "STATUS=Shutting down...");
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering}
a3db237b8f1b97867395e1419f39b8ba5749b777Lennart Poettering