networkd.h revision 9505d3c6deda0452c22ab2ed47bca74b98d87a17
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen This file is part of systemd.
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen Copyright 2013 Tom Gundersen <teg@jklm.no>
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 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 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/>.
aba496a58acf9d9c61314de71353550e579f85eeUmut Tezduyar Lindskog#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
52433f6b65eccd1c54606dde999610640f3458acTom Gundersentypedef struct netdev_enslave_callback netdev_enslave_callback;
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen LIST_FIELDS(netdev_enslave_callback, callbacks);
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom Gundersen NETDEV_MACVLAN_MODE_PRIVATE = MACVLAN_MODE_PRIVATE,
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom Gundersen NETDEV_MACVLAN_MODE_BRIDGE = MACVLAN_MODE_BRIDGE,
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom Gundersen NETDEV_MACVLAN_MODE_PASSTHRU = MACVLAN_MODE_PASSTHRU,
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen LIST_HEAD(netdev_enslave_callback, callbacks);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen unsigned char family;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen unsigned char prefixlen;
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen unsigned char family;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmekextern const char* const network_dirs[];
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#define _cleanup_manager_free_ _cleanup_(manager_freep)
2dcf7ec6ec0c28297311108acba119cd6e055e64Tom Gundersenconst struct ConfigPerfItem* networkd_gperf_lookup(const char *key, unsigned length);
2dcf7ec6ec0c28297311108acba119cd6e055e64Tom Gundersenint config_parse_dnsv(const char *unit, const char *filename, unsigned line,
2dcf7ec6ec0c28297311108acba119cd6e055e64Tom Gundersen const char *section, unsigned section_line, const char *lvalue,
2dcf7ec6ec0c28297311108acba119cd6e055e64Tom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
14b746f72132324e637c4e39694bd474f85e19f7Tom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
14b746f72132324e637c4e39694bd474f85e19f7Tom Gundersen#define _cleanup_netdev_unref_ _cleanup_(netdev_unrefp)
1a436809498faf6486815baa0338fb6b8e5def07Tom Gundersenint netdev_get(Manager *manager, const char *name, NetDev **ret);
d39edfc72f9296078a18014627bf0a2543b60627Tom Gundersenint netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink);
1a436809498faf6486815baa0338fb6b8e5def07Tom Gundersenint netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb);
7951dea20911969287878e6897b3eca348721adeSusant Sahaniint netdev_create_tunnel(Link *link, sd_rtnl_message_handler_t callback);
1a436809498faf6486815baa0338fb6b8e5def07Tom Gundersenconst char *netdev_kind_to_string(NetDevKind d) _const_;
1a436809498faf6486815baa0338fb6b8e5def07Tom GundersenNetDevKind netdev_kind_from_string(const char *d) _pure_;
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom Gundersenconst char *macvlan_mode_to_string(MacVlanMode d) _const_;
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom GundersenMacVlanMode macvlan_mode_from_string(const char *d) _pure_;
52433f6b65eccd1c54606dde999610640f3458acTom Gundersenint config_parse_netdev_kind(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
fe6b2d55bcb379d01664ed28cea40634cb6b52e3Tom Gundersenint config_parse_macvlan_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
c0dda18697e0994272c0c9616d36f6777b60e2c7Tom Gundersenconst struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#define _cleanup_network_free_ _cleanup_(network_freep)
505f8da7325591defe5f751f328bd26915267602Tom Gundersenint network_get(Manager *manager, struct udev_device *device,
505f8da7325591defe5f751f328bd26915267602Tom Gundersen const char *ifname, const struct ether_addr *mac,
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenint network_apply(Manager *manager, Network *network, Link *link);
69a93e7db47addc4495a6ec9dc0fc74092a6ebeeTom Gundersenint config_parse_netdev(const char *unit, const char *filename, unsigned line,
02b59d57e0c08231645120077f651151f5bb2babTom Gundersen const char *section, unsigned section_line, const char *lvalue,
02b59d57e0c08231645120077f651151f5bb2babTom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
7951dea20911969287878e6897b3eca348721adeSusant Sahaniint config_parse_tunnel_address(const char *unit,
c0dda18697e0994272c0c9616d36f6777b60e2c7Tom Gundersenconst struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
f048a16b464295a4e0a4f4c1210f06343ad31231Tom Gundersenint route_new_static(Network *network, unsigned section, Route **ret);
f882c247ad59776c3a7753bb963c1f8e2386cb79Tom Gundersenint route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback);
5c1d3fc93d91384bbac29adf01074fa4375317eaUmut Tezduyar Lindskogint route_drop(Route *route, Link *link, sd_rtnl_message_handler_t callback);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#define _cleanup_route_free_ _cleanup_(route_freep)
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenint config_parse_gateway(const char *unit, const char *filename, unsigned line,
71a6151083d842b2f5bf04e50239f0bf85d34d2eTom Gundersen const char *section, unsigned section_line, const char *lvalue,
71a6151083d842b2f5bf04e50239f0bf85d34d2eTom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersenint config_parse_destination(const char *unit, const char *filename, unsigned line,
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersen const char *section, unsigned section_line, const char *lvalue,
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
f048a16b464295a4e0a4f4c1210f06343ad31231Tom Gundersenint address_new_static(Network *network, unsigned section, Address **ret);
f882c247ad59776c3a7753bb963c1f8e2386cb79Tom Gundersenint address_configure(Address *address, Link *link, sd_rtnl_message_handler_t callback);
aba496a58acf9d9c61314de71353550e579f85eeUmut Tezduyar Lindskogint address_update(Address *address, Link *link, sd_rtnl_message_handler_t callback);
407fe036a24834203aca6c1eec7d74d9ad3e9ee0Tom Gundersenint address_drop(Address *address, Link *link, sd_rtnl_message_handler_t callback);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersen#define _cleanup_address_free_ _cleanup_(address_freep)
3bef724f7e7f7eaca69881548b06e221b77d7031Tom Gundersenint config_parse_dns(const char *unit, const char *filename, unsigned line,
3bef724f7e7f7eaca69881548b06e221b77d7031Tom Gundersen const char *section, unsigned section_line, const char *lvalue,
3bef724f7e7f7eaca69881548b06e221b77d7031Tom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
f579559b3a14c1f1ef96c372e7626c4733e6ef7dTom Gundersenint config_parse_address(const char *unit, const char *filename, unsigned line,
71a6151083d842b2f5bf04e50239f0bf85d34d2eTom Gundersen const char *section, unsigned section_line, const char *lvalue,
71a6151083d842b2f5bf04e50239f0bf85d34d2eTom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
eb0ea358b688a6f83ff305c6b825c61f12b6dcb8Tom Gundersenint config_parse_broadcast(const char *unit, const char *filename, unsigned line,
eb0ea358b688a6f83ff305c6b825c61f12b6dcb8Tom Gundersen const char *section, unsigned section_line, const char *lvalue,
eb0ea358b688a6f83ff305c6b825c61f12b6dcb8Tom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersenint config_parse_label(const char *unit, const char *filename, unsigned line,
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersen const char *section, unsigned section_line, const char *lvalue,
6ae115c1fe95611b39d2f20cfcea3d385429f59eTom Gundersen int ltype, const char *rvalue, void *data, void *userdata);
11a7f22939d21558df919cab44b8fbe36ab5dae0Tom Gundersenint link_get(Manager *m, int ifindex, Link **ret);
505f8da7325591defe5f751f328bd26915267602Tom Gundersenint link_add(Manager *manager, sd_rtnl_message *message, Link **ret);
22936833e177d9e477e059ec2b4f4fa9213b4e19Tom Gundersenint link_update(Link *link, sd_rtnl_message *message);
fbbeb65a93e2f90f6576001b69def877cd98722dTom Gundersenint link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message, void *userdata);
505f8da7325591defe5f751f328bd26915267602Tom Gundersenint link_initialized(Link *link, struct udev_device *device);
bbf7c04821a71fec67eaf0e7a34d17afc5913c13Tom Gundersenbool link_has_carrier(unsigned flags, uint8_t operstate);
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom Gundersenconst char* link_state_to_string(LinkState s) _const_;
fe8db0c5ee3365a2fc80ee7ebffa238f9a0a2ae2Tom GundersenLinkState link_state_from_string(const char *s) _pure_;
14b746f72132324e637c4e39694bd474f85e19f7Tom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
14b746f72132324e637c4e39694bd474f85e19f7Tom Gundersen#define _cleanup_link_unref_ _cleanup_(link_unrefp)
3333d748facc15f49935b6b793490ba0824976e6Zbigniew Jędrzejewski-Szmek/* Macros which append INTERFACE= to the message */
987efa17dd5c9be156d8f49ddd942df20a72dcb1Tom Gundersen#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
39032b87779323a244dd89f4832949d462b2ac68Zbigniew Jędrzejewski-Szmek#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
39032b87779323a244dd89f4832949d462b2ac68Zbigniew Jędrzejewski-Szmek#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
39032b87779323a244dd89f4832949d462b2ac68Zbigniew Jędrzejewski-Szmek#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
39032b87779323a244dd89f4832949d462b2ac68Zbigniew Jędrzejewski-Szmek#define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
39032b87779323a244dd89f4832949d462b2ac68Zbigniew Jędrzejewski-Szmek#define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__)
3333d748facc15f49935b6b793490ba0824976e6Zbigniew Jędrzejewski-Szmek#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
3333d748facc15f49935b6b793490ba0824976e6Zbigniew Jędrzejewski-Szmek/* More macros which append INTERFACE= to the message */
987efa17dd5c9be156d8f49ddd942df20a72dcb1Tom Gundersen#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen#define log_warning_netdev(netdev, ...) log_full_netdev(LOG_WARNING, netdev,## __VA_ARGS__)
52433f6b65eccd1c54606dde999610640f3458acTom Gundersen#define log_error_netdev(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__)
af4e9e2c563047d524b207e0e3d6816385693a16Tom Gundersen#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__)
af4e9e2c563047d524b207e0e3d6816385693a16Tom Gundersen#define NETDEV(netdev) "INTERFACE=%s", netdev->ifname
628706137efbca8aaf753ccd063e5abf7e31aed5Zbigniew Jędrzejewski-Szmek#define ADDRESS_FMT_VAL(address) \
628706137efbca8aaf753ccd063e5abf7e31aed5Zbigniew Jędrzejewski-Szmek ((address).s_addr >> 8) & 0xFF, \
628706137efbca8aaf753ccd063e5abf7e31aed5Zbigniew Jędrzejewski-Szmek ((address).s_addr >> 16) & 0xFF, \