networkd.h revision 1c8e710c2b479129c3ad06a0e8e2d21ae4aefd38
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen/***
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen This file is part of systemd.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Copyright 2013 Tom Gundersen <teg@jklm.no>
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen systemd is free software; you can redistribute it and/or modify it
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen under the terms of the GNU Lesser General Public License as published by
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen the Free Software Foundation; either version 2.1 of the License, or
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen (at your option) any later version.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen systemd is distributed in the hope that it will be useful, but
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Lesser General Public License for more details.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen You should have received a copy of the GNU Lesser General Public License
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen***/
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#pragma once
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#include <arpa/inet.h>
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#include "sd-event.h"
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen#include "sd-netlink.h"
1346b1f0388f4100bb3c2a2bb23bc881769c020cTom Gundersen#include "sd-bus.h"
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#include "udev.h"
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#include "hashmap.h"
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#include "list.h"
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersentypedef struct Manager Manager;
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersen
fc2f9534d07db2b185c02b1961428b53daf1986eLennart Poettering#include "networkd-network.h"
fc2f9534d07db2b185c02b1961428b53daf1986eLennart Poettering#include "networkd-address-pool.h"
fc2f9534d07db2b185c02b1961428b53daf1986eLennart Poettering#include "networkd-link.h"
fc2f9534d07db2b185c02b1961428b53daf1986eLennart Poettering#include "networkd-util.h"
11bf3cced13c885ca215c108cb0bdb7a148520d6Lennart Poettering
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenstruct Manager {
1c4baffc1895809bae9ac36b670af90a4cb9cd7dTom Gundersen sd_netlink *rtnl;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen sd_event *event;
9c0a72f961e00b0447767973e7117e131bea5b5dTom Gundersen sd_event_source *bus_retry_event_source;
1346b1f0388f4100bb3c2a2bb23bc881769c020cTom Gundersen sd_bus *bus;
9c0a72f961e00b0447767973e7117e131bea5b5dTom Gundersen sd_bus_slot *prepare_for_sleep_slot;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen struct udev *udev;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen struct udev_monitor *udev_monitor;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen sd_event_source *udev_event_source;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
84de38c56915e14c148f558c6acc489a00755696Tom Gundersen bool enumerating:1;
84de38c56915e14c148f558c6acc489a00755696Tom Gundersen bool dirty:1;
84de38c56915e14c148f558c6acc489a00755696Tom Gundersen
84de38c56915e14c148f558c6acc489a00755696Tom Gundersen Set *dirty_links;
6a24f1484fcc1f59f89617afbe4282667a358eabTom Gundersen
bbf7c04821a71fec67eaf0e7a34d17afc5913c13Tom Gundersen char *state_file;
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen LinkOperationalState operational_state;
bbf7c04821a71fec67eaf0e7a34d17afc5913c13Tom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Hashmap *links;
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen Hashmap *netdevs;
dbffab87f1504abc9f189dd253111693c99fbd9aTom Gundersen Hashmap *networks_by_name;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen LIST_HEAD(Network, networks);
11bf3cced13c885ca215c108cb0bdb7a148520d6Lennart Poettering LIST_HEAD(AddressPool, address_pools);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen usec_t network_dirs_ts_usec;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen};
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmekextern const char* const network_dirs[];
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen/* Manager */
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersenextern const sd_bus_vtable manager_vtable[];
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersen
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenint manager_new(Manager **ret);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenvoid manager_free(Manager *m);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
8f203c166ecb24f904a068f2d8f0c636c1511a8fTom Gundersenint manager_connect_bus(Manager *m);
a97dcc12e486ecff531809802930a26c4da827f2Tom Gundersenint manager_run(Manager *m);
a97dcc12e486ecff531809802930a26c4da827f2Tom Gundersen
02b59d57e0c08231645120077f651151f5bb2babTom Gundersenint manager_load_config(Manager *m);
02b59d57e0c08231645120077f651151f5bb2babTom Gundersenbool manager_should_reload(Manager *m);
02b59d57e0c08231645120077f651151f5bb2babTom Gundersen
505f8da7325591defe5f751f328bd26915267602Tom Gundersenint manager_rtnl_enumerate_links(Manager *m);
45af44d47da6933b260c734ad9ff721f63f80a4dTom Gundersenint manager_rtnl_enumerate_addresses(Manager *m);
1c8e710c2b479129c3ad06a0e8e2d21ae4aefd38Tom Gundersenint manager_rtnl_enumerate_routes(Manager *m);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen
200a0868fcdf7b95f3d8d1fda3aa2aef48d84fddTom Gundersenint manager_rtnl_process_address(sd_netlink *nl, sd_netlink_message *message, void *userdata);
1c8e710c2b479129c3ad06a0e8e2d21ae4aefd38Tom Gundersenint manager_rtnl_process_route(sd_netlink *nl, sd_netlink_message *message, void *userdata);
200a0868fcdf7b95f3d8d1fda3aa2aef48d84fddTom Gundersen
e331e24649213f2e093e16e4d3d64ee823dfc375Tom Gundersenint manager_send_changed(Manager *m, const char *property, ...) _sentinel_;
84de38c56915e14c148f558c6acc489a00755696Tom Gundersenvoid manager_dirty(Manager *m);
3bef724f7e7f7eaca69881548b06e221b77d7031Tom Gundersen
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poetteringint manager_address_pool_acquire(Manager *m, int family, unsigned prefixlen, union in_addr_union *found);
11bf3cced13c885ca215c108cb0bdb7a148520d6Lennart Poettering
4f5f911e81ae6377ab925c1dd133013c640ab32eLennart PoetteringLink* manager_find_uplink(Manager *m, Link *exclude);
4f5f911e81ae6377ab925c1dd133013c640ab32eLennart Poettering
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#define _cleanup_manager_free_ _cleanup_(manager_freep)