networkd.h revision 5be4d38e31281727b6f45ae869136bb01a1f7790
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek This file is part of systemd.
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek Copyright 2013 Tom Gundersen <teg@jklm.no>
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek (at your option) any later version.
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmektypedef struct bridge_join_callback bridge_join_callback;
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmek sd_rtnl_message_handler_t callback;
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmek LIST_FIELDS(bridge_join_callback, callbacks);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmek LIST_HEAD(bridge_join_callback, callbacks);
722b6795655149a68277b3cffeba711e1d440e5aZbigniew Jędrzejewski-Szmek LIST_HEAD(Address, static_addresses);
722b6795655149a68277b3cffeba711e1d440e5aZbigniew Jędrzejewski-Szmek LIST_HEAD(Route, static_routes);
722b6795655149a68277b3cffeba711e1d440e5aZbigniew Jędrzejewski-Szmek LIST_FIELDS(Address, static_addresses);
722b6795655149a68277b3cffeba711e1d440e5aZbigniew Jędrzejewski-Szmek LIST_FIELDS(Route, static_routes);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek struct udev_monitor *udev_monitor;
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek sd_event_source *udev_event_source;
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekextern const char* const network_dirs[];
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekint manager_load_config(Manager *m);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekbool manager_should_reload(Manager *m);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekint manager_udev_enumerate_links(Manager *m);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekint manager_udev_listen(Manager *m);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint manager_rtnl_listen(Manager *m);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint manager_update_resolv_conf(Manager *m);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define _cleanup_manager_free_ _cleanup_(manager_freep)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint bridge_load(Manager *manager);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekvoid bridge_free(Bridge *bridge);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Bridge*, bridge_free);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define _cleanup_bridge_free_ _cleanup_(bridge_freep)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint bridge_get(Manager *manager, const char *name, Bridge **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint bridge_set_link(Manager *m, Link *link);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekint bridge_join(Bridge *bridge, Link *link, sd_rtnl_message_handler_t cb);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekint network_load(Manager *manager);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekvoid network_free(Network *network);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmek#define _cleanup_network_free_ _cleanup_(network_freep)
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekint network_get(Manager *manager, struct udev_device *device, Network **ret);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekint network_apply(Manager *manager, Network *network, Link *link);
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmekint config_parse_bridge(const char *unit, const char *filename, unsigned line,
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
7449bc1f34c206e3ff8e274cd74e2db950d492a1Zbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekconst struct ConfigPerfItem* network_gperf_lookup(const char *key, unsigned length);
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmekint route_new_static(Network *network, unsigned section, Route **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint route_new_dynamic(Route **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define _cleanup_route_free_ _cleanup_(route_freep)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint config_parse_gateway(const char *unit, const char *filename, unsigned line,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint config_parse_destination(const char *unit, const char *filename, unsigned line,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint address_new_static(Network *network, unsigned section, Address **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint address_new_dynamic(Address **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekvoid address_free(Address *address);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint address_configure(Address *address, Link *link, sd_rtnl_message_handler_t callback);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint address_drop(Address *address, Link *link, sd_rtnl_message_handler_t callback);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define _cleanup_address_free_ _cleanup_(address_freep)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint config_parse_dns(const char *unit, const char *filename, unsigned line,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint config_parse_address(const char *unit, const char *filename, unsigned line,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint config_parse_label(const char *unit, const char *filename, unsigned line,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek const char *section, unsigned section_line, const char *lvalue,
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek int ltype, const char *rvalue, void *data, void *userdata);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint link_new(Manager *manager, struct udev_device *device, Link **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint link_add(Manager *manager, struct udev_device *device, Link **ret);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmekint link_update(Link *link, sd_rtnl_message *message);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-SzmekDEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define _cleanup_link_free_ _cleanup_(link_freep)
eacbb4d33e2bb5c54311544851140efe3dd0f774Zbigniew Jędrzejewski-Szmek/* Macros which append INTERFACE= to the message */
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%s: " fmt, link->ifname, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek/* More macros which append INTERFACE= to the message */
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_full_bridge(level, bridge, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", bridge->name, "%s: " fmt, bridge->name, ##__VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_debug_bridge(bridge, ...) log_full_bridge(LOG_DEBUG, bridge, ##__VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_info_bridge(bridge, ...) log_full_bridge(LOG_INFO, bridge, ##__VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_notice_bridge(bridge, ...) log_full_bridge(LOG_NOTICE, bridge, ##__VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_warning_bridge(bridge, ...) log_full_bridge(LOG_WARNING, bridge,## __VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_error_bridge(bridge, ...) log_full_bridge(LOG_ERR, bridge, ##__VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define log_struct_bridge(level, bridge, ...) log_struct(level, "INTERFACE=%s", bridge->name, __VA_ARGS__)
8201af08fa09c2bd0f005fbe262f27e2c5bd2d86Zbigniew Jędrzejewski-Szmek#define BRIDGE(bridge) "INTERFACE=%s", bridge->name
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek#define ADDRESS_FMT_VAL(address) \
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek ((address).s_addr >> 8) & 0xFF, \
3d090cc6f34e5970765dd1e7ee5e648a056d180dZbigniew Jędrzejewski-Szmek ((address).s_addr >> 16) & 0xFF, \