2013-10-17 03:18:36 +02:00
|
|
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
|
|
|
|
|
|
|
/***
|
|
|
|
This file is part of systemd.
|
|
|
|
|
|
|
|
Copyright 2013 Tom Gundersen <teg@jklm.no>
|
|
|
|
|
|
|
|
systemd is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
systemd is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
***/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#include "sd-event.h"
|
|
|
|
#include "sd-rtnl.h"
|
2014-01-13 23:48:28 +01:00
|
|
|
#include "sd-bus.h"
|
2014-01-01 15:16:34 +01:00
|
|
|
#include "sd-dhcp-client.h"
|
2014-02-28 16:10:20 +01:00
|
|
|
#include "sd-ipv4ll.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
#include "udev.h"
|
|
|
|
|
|
|
|
#include "rtnl-util.h"
|
|
|
|
#include "hashmap.h"
|
|
|
|
#include "list.h"
|
2014-03-13 20:46:45 +01:00
|
|
|
#include "set.h"
|
2014-02-20 19:39:49 +01:00
|
|
|
#include "condition-util.h"
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2014-04-02 21:31:12 +02:00
|
|
|
#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
|
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
typedef struct NetDev NetDev;
|
2013-10-17 03:18:36 +02:00
|
|
|
typedef struct Network Network;
|
|
|
|
typedef struct Link Link;
|
|
|
|
typedef struct Address Address;
|
|
|
|
typedef struct Route Route;
|
|
|
|
typedef struct Manager Manager;
|
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
typedef struct netdev_enslave_callback netdev_enslave_callback;
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
struct netdev_enslave_callback {
|
2013-11-24 23:37:56 +01:00
|
|
|
sd_rtnl_message_handler_t callback;
|
|
|
|
Link *link;
|
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
LIST_FIELDS(netdev_enslave_callback, callbacks);
|
2013-11-24 23:37:56 +01:00
|
|
|
};
|
|
|
|
|
2014-02-25 21:16:17 +01:00
|
|
|
typedef enum MacVlanMode {
|
|
|
|
NETDEV_MACVLAN_MODE_PRIVATE = MACVLAN_MODE_PRIVATE,
|
|
|
|
NETDEV_MACVLAN_MODE_VEPA = MACVLAN_MODE_VEPA,
|
|
|
|
NETDEV_MACVLAN_MODE_BRIDGE = MACVLAN_MODE_BRIDGE,
|
|
|
|
NETDEV_MACVLAN_MODE_PASSTHRU = MACVLAN_MODE_PASSTHRU,
|
|
|
|
_NETDEV_MACVLAN_MODE_MAX,
|
|
|
|
_NETDEV_MACVLAN_MODE_INVALID = -1
|
|
|
|
} MacVlanMode;
|
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
typedef enum NetDevKind {
|
2014-01-21 21:58:08 +01:00
|
|
|
NETDEV_KIND_BRIDGE,
|
|
|
|
NETDEV_KIND_BOND,
|
2014-01-22 14:49:24 +01:00
|
|
|
NETDEV_KIND_VLAN,
|
2014-02-25 21:16:17 +01:00
|
|
|
NETDEV_KIND_MACVLAN,
|
2014-01-21 21:58:08 +01:00
|
|
|
_NETDEV_KIND_MAX,
|
|
|
|
_NETDEV_KIND_INVALID = -1
|
2014-02-07 17:03:23 +01:00
|
|
|
} NetDevKind;
|
2014-01-21 21:58:08 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
typedef enum NetDevState {
|
2014-01-21 21:58:08 +01:00
|
|
|
NETDEV_STATE_FAILED,
|
|
|
|
NETDEV_STATE_CREATING,
|
|
|
|
NETDEV_STATE_READY,
|
|
|
|
_NETDEV_STATE_MAX,
|
|
|
|
_NETDEV_STATE_INVALID = -1,
|
2014-02-07 17:03:23 +01:00
|
|
|
} NetDevState;
|
2014-01-21 21:58:08 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
struct NetDev {
|
2013-11-24 23:37:56 +01:00
|
|
|
Manager *manager;
|
|
|
|
|
|
|
|
char *filename;
|
|
|
|
|
2014-02-21 14:51:19 +01:00
|
|
|
Condition *match_host;
|
|
|
|
Condition *match_virt;
|
|
|
|
Condition *match_kernel;
|
|
|
|
Condition *match_arch;
|
2014-02-20 19:56:50 +01:00
|
|
|
|
2013-11-24 23:37:56 +01:00
|
|
|
char *description;
|
|
|
|
char *name;
|
2014-02-07 17:03:23 +01:00
|
|
|
NetDevKind kind;
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-10 18:41:54 +01:00
|
|
|
uint64_t vlanid;
|
2014-02-25 21:16:17 +01:00
|
|
|
int32_t macvlan_mode;
|
2014-01-22 14:49:24 +01:00
|
|
|
|
2014-01-29 21:24:44 +01:00
|
|
|
int ifindex;
|
2014-02-07 17:03:23 +01:00
|
|
|
NetDevState state;
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
LIST_HEAD(netdev_enslave_callback, callbacks);
|
2013-11-24 23:37:56 +01:00
|
|
|
};
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
struct Network {
|
|
|
|
Manager *manager;
|
|
|
|
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
struct ether_addr *match_mac;
|
|
|
|
char *match_path;
|
|
|
|
char *match_driver;
|
|
|
|
char *match_type;
|
|
|
|
char *match_name;
|
2014-02-20 19:39:49 +01:00
|
|
|
Condition *match_host;
|
|
|
|
Condition *match_virt;
|
|
|
|
Condition *match_kernel;
|
2014-02-21 14:51:19 +01:00
|
|
|
Condition *match_arch;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
char *description;
|
2014-02-07 17:03:23 +01:00
|
|
|
NetDev *bridge;
|
|
|
|
NetDev *bond;
|
2014-02-10 18:41:54 +01:00
|
|
|
Hashmap *vlans;
|
2014-02-25 21:16:17 +01:00
|
|
|
Hashmap *macvlans;
|
2014-01-01 15:16:34 +01:00
|
|
|
bool dhcp;
|
2014-01-13 21:28:53 +01:00
|
|
|
bool dhcp_dns;
|
2014-01-13 23:07:59 +01:00
|
|
|
bool dhcp_mtu;
|
2014-01-13 23:48:28 +01:00
|
|
|
bool dhcp_hostname;
|
2014-01-18 15:47:57 +01:00
|
|
|
bool dhcp_domainname;
|
2014-01-27 20:52:07 +01:00
|
|
|
bool dhcp_critical;
|
2014-02-28 16:10:20 +01:00
|
|
|
bool ipv4ll;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2014-01-01 15:16:10 +01:00
|
|
|
LIST_HEAD(Address, static_addresses);
|
|
|
|
LIST_HEAD(Route, static_routes);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2013-11-19 16:54:42 +01:00
|
|
|
Hashmap *addresses_by_section;
|
|
|
|
Hashmap *routes_by_section;
|
|
|
|
|
2014-03-13 20:46:45 +01:00
|
|
|
Set *dns;
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
LIST_FIELDS(Network, networks);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Address {
|
|
|
|
Network *network;
|
2013-11-19 16:54:42 +01:00
|
|
|
uint64_t section;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
unsigned char family;
|
|
|
|
unsigned char prefixlen;
|
2014-02-28 16:10:20 +01:00
|
|
|
unsigned char scope;
|
2013-10-17 03:18:36 +02:00
|
|
|
char *label;
|
|
|
|
|
2014-01-28 20:01:37 +01:00
|
|
|
struct in_addr broadcast;
|
2014-04-02 21:31:12 +02:00
|
|
|
struct ifa_cacheinfo cinfo;
|
2013-11-17 21:01:20 +01:00
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
union {
|
|
|
|
struct in_addr in;
|
|
|
|
struct in6_addr in6;
|
|
|
|
} in_addr;
|
|
|
|
|
2014-01-01 15:16:10 +01:00
|
|
|
LIST_FIELDS(Address, static_addresses);
|
2013-10-17 03:18:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Route {
|
|
|
|
Network *network;
|
2013-11-19 16:54:42 +01:00
|
|
|
uint64_t section;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
unsigned char family;
|
2013-11-19 16:54:42 +01:00
|
|
|
unsigned char dst_prefixlen;
|
2014-02-28 16:10:20 +01:00
|
|
|
unsigned char scope;
|
|
|
|
uint32_t metrics;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct in_addr in;
|
|
|
|
struct in6_addr in6;
|
|
|
|
} in_addr;
|
|
|
|
|
2013-11-19 16:54:42 +01:00
|
|
|
union {
|
|
|
|
struct in_addr in;
|
|
|
|
struct in6_addr in6;
|
|
|
|
} dst_addr;
|
|
|
|
|
2014-01-01 15:16:10 +01:00
|
|
|
LIST_FIELDS(Route, static_routes);
|
2013-10-17 03:18:36 +02:00
|
|
|
};
|
|
|
|
|
2013-11-14 16:22:51 +01:00
|
|
|
typedef enum LinkState {
|
2014-04-15 14:21:44 +02:00
|
|
|
LINK_STATE_INITIALIZING,
|
2014-01-21 21:58:08 +01:00
|
|
|
LINK_STATE_ENSLAVING,
|
2013-12-14 19:09:04 +01:00
|
|
|
LINK_STATE_SETTING_ADDRESSES,
|
|
|
|
LINK_STATE_SETTING_ROUTES,
|
2013-11-14 16:22:51 +01:00
|
|
|
LINK_STATE_CONFIGURED,
|
2014-04-20 19:49:00 +02:00
|
|
|
LINK_STATE_UNMANAGED,
|
2013-11-14 16:22:51 +01:00
|
|
|
LINK_STATE_FAILED,
|
|
|
|
_LINK_STATE_MAX,
|
|
|
|
_LINK_STATE_INVALID = -1
|
|
|
|
} LinkState;
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
struct Link {
|
|
|
|
Manager *manager;
|
|
|
|
|
2013-11-18 11:54:09 +01:00
|
|
|
uint64_t ifindex;
|
2013-11-24 23:36:58 +01:00
|
|
|
char *ifname;
|
2014-02-27 01:24:05 +01:00
|
|
|
char *state_file;
|
2013-11-17 21:01:20 +01:00
|
|
|
struct ether_addr mac;
|
2014-03-21 19:23:35 +01:00
|
|
|
struct udev_device *udev_device;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
unsigned flags;
|
2014-04-22 19:40:05 +02:00
|
|
|
uint8_t operstate;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
Network *network;
|
2013-11-14 16:22:51 +01:00
|
|
|
|
|
|
|
LinkState state;
|
|
|
|
|
2014-01-01 15:16:34 +01:00
|
|
|
unsigned addr_messages;
|
|
|
|
unsigned route_messages;
|
2014-01-21 21:58:08 +01:00
|
|
|
unsigned enslaving;
|
2014-01-01 15:16:34 +01:00
|
|
|
|
2014-02-04 23:13:52 +01:00
|
|
|
sd_dhcp_client *dhcp_client;
|
|
|
|
sd_dhcp_lease *dhcp_lease;
|
|
|
|
uint16_t original_mtu;
|
2014-02-28 16:10:20 +01:00
|
|
|
sd_ipv4ll *ipv4ll;
|
2013-10-17 03:18:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Manager {
|
|
|
|
sd_rtnl *rtnl;
|
|
|
|
sd_event *event;
|
2014-01-13 23:48:28 +01:00
|
|
|
sd_bus *bus;
|
2013-10-17 03:18:36 +02:00
|
|
|
struct udev *udev;
|
|
|
|
struct udev_monitor *udev_monitor;
|
|
|
|
sd_event_source *udev_event_source;
|
2014-02-22 20:19:49 +01:00
|
|
|
sd_event_source *sigterm_event_source;
|
|
|
|
sd_event_source *sigint_event_source;
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
Hashmap *links;
|
2014-01-21 21:58:08 +01:00
|
|
|
Hashmap *netdevs;
|
2013-10-17 03:18:36 +02:00
|
|
|
LIST_HEAD(Network, networks);
|
|
|
|
|
|
|
|
usec_t network_dirs_ts_usec;
|
|
|
|
};
|
|
|
|
|
2014-01-08 23:41:41 +01:00
|
|
|
extern const char* const network_dirs[];
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
/* Manager */
|
|
|
|
|
|
|
|
int manager_new(Manager **ret);
|
|
|
|
void manager_free(Manager *m);
|
|
|
|
|
2013-11-24 23:37:56 +01:00
|
|
|
int manager_load_config(Manager *m);
|
|
|
|
bool manager_should_reload(Manager *m);
|
|
|
|
|
2014-04-15 14:21:44 +02:00
|
|
|
int manager_rtnl_enumerate_links(Manager *m);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2013-11-14 16:22:51 +01:00
|
|
|
int manager_rtnl_listen(Manager *m);
|
2014-04-15 14:21:44 +02:00
|
|
|
int manager_udev_listen(Manager *m);
|
2014-01-13 23:48:28 +01:00
|
|
|
int manager_bus_listen(Manager *m);
|
2013-11-14 16:22:51 +01:00
|
|
|
|
2014-01-05 23:01:10 +01:00
|
|
|
int manager_update_resolv_conf(Manager *m);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
|
|
|
|
#define _cleanup_manager_free_ _cleanup_(manager_freep)
|
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
/* NetDev */
|
2014-01-21 21:58:08 +01:00
|
|
|
|
|
|
|
int netdev_load(Manager *manager);
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
void netdev_free(NetDev *netdev);
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_free);
|
2014-01-21 21:58:08 +01:00
|
|
|
#define _cleanup_netdev_free_ _cleanup_(netdev_freep)
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
int netdev_get(Manager *manager, const char *name, NetDev **ret);
|
2014-03-24 00:07:46 +01:00
|
|
|
int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *newlink);
|
2014-02-07 17:03:23 +01:00
|
|
|
int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t cb);
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-07 17:03:23 +01:00
|
|
|
const char *netdev_kind_to_string(NetDevKind d) _const_;
|
|
|
|
NetDevKind netdev_kind_from_string(const char *d) _pure_;
|
2014-01-21 21:58:08 +01:00
|
|
|
|
2014-02-25 21:16:17 +01:00
|
|
|
const char *macvlan_mode_to_string(MacVlanMode d) _const_;
|
|
|
|
MacVlanMode macvlan_mode_from_string(const char *d) _pure_;
|
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
int 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);
|
2013-11-24 23:37:56 +01:00
|
|
|
|
2014-02-25 21:16:17 +01:00
|
|
|
int 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);
|
|
|
|
|
2014-02-20 19:56:50 +01:00
|
|
|
/* gperf */
|
|
|
|
const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsigned length);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
/* Network */
|
|
|
|
|
|
|
|
int network_load(Manager *manager);
|
|
|
|
|
|
|
|
void network_free(Network *network);
|
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free);
|
|
|
|
#define _cleanup_network_free_ _cleanup_(network_freep)
|
|
|
|
|
2014-04-15 14:21:44 +02:00
|
|
|
int network_get(Manager *manager, struct udev_device *device,
|
|
|
|
const char *ifname, const struct ether_addr *mac,
|
|
|
|
Network **ret);
|
2013-10-17 03:18:36 +02:00
|
|
|
int network_apply(Manager *manager, Network *network, Link *link);
|
|
|
|
|
2013-11-24 23:37:56 +01:00
|
|
|
int config_parse_bridge(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);
|
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
int config_parse_bond(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);
|
|
|
|
|
2014-01-22 14:49:24 +01:00
|
|
|
int config_parse_vlan(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);
|
|
|
|
|
2014-02-25 21:16:17 +01:00
|
|
|
int config_parse_macvlan(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);
|
|
|
|
|
2013-11-24 23:37:56 +01:00
|
|
|
/* gperf */
|
2014-02-20 19:56:50 +01:00
|
|
|
const struct ConfigPerfItem* network_network_gperf_lookup(const char *key, unsigned length);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
/* Route */
|
2014-01-01 15:16:10 +01:00
|
|
|
int route_new_static(Network *network, unsigned section, Route **ret);
|
|
|
|
int route_new_dynamic(Route **ret);
|
2013-10-17 03:18:36 +02:00
|
|
|
void route_free(Route *route);
|
2013-11-14 16:22:51 +01:00
|
|
|
int route_configure(Route *route, Link *link, sd_rtnl_message_handler_t callback);
|
2014-02-28 16:10:20 +01:00
|
|
|
int route_drop(Route *route, Link *link, sd_rtnl_message_handler_t callback);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free);
|
|
|
|
#define _cleanup_route_free_ _cleanup_(route_freep)
|
|
|
|
|
|
|
|
int config_parse_gateway(const char *unit, const char *filename, unsigned line,
|
2013-11-19 16:17:55 +01:00
|
|
|
const char *section, unsigned section_line, const char *lvalue,
|
|
|
|
int ltype, const char *rvalue, void *data, void *userdata);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2013-11-19 16:54:42 +01:00
|
|
|
int config_parse_destination(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);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
/* Address */
|
2014-01-01 15:16:10 +01:00
|
|
|
int address_new_static(Network *network, unsigned section, Address **ret);
|
|
|
|
int address_new_dynamic(Address **ret);
|
2013-10-17 03:18:36 +02:00
|
|
|
void address_free(Address *address);
|
2013-11-14 16:22:51 +01:00
|
|
|
int address_configure(Address *address, Link *link, sd_rtnl_message_handler_t callback);
|
2014-04-02 21:31:12 +02:00
|
|
|
int address_update(Address *address, Link *link, sd_rtnl_message_handler_t callback);
|
2013-12-31 17:31:50 +01:00
|
|
|
int address_drop(Address *address, Link *link, sd_rtnl_message_handler_t callback);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
|
|
|
|
#define _cleanup_address_free_ _cleanup_(address_freep)
|
|
|
|
|
2014-01-05 23:01:10 +01:00
|
|
|
int config_parse_dns(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);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
int config_parse_address(const char *unit, const char *filename, unsigned line,
|
2013-11-19 16:17:55 +01:00
|
|
|
const char *section, unsigned section_line, const char *lvalue,
|
|
|
|
int ltype, const char *rvalue, void *data, void *userdata);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2014-01-28 20:01:37 +01:00
|
|
|
int config_parse_broadcast(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);
|
|
|
|
|
2013-11-19 16:54:42 +01:00
|
|
|
int config_parse_label(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);
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
/* Link */
|
|
|
|
|
|
|
|
void link_free(Link *link);
|
2014-02-18 21:42:05 +01:00
|
|
|
int link_get(Manager *m, int ifindex, Link **ret);
|
2014-04-15 14:21:44 +02:00
|
|
|
int link_add(Manager *manager, sd_rtnl_message *message, Link **ret);
|
2013-10-17 03:18:36 +02:00
|
|
|
|
2013-12-17 18:36:09 +01:00
|
|
|
int link_update(Link *link, sd_rtnl_message *message);
|
2013-12-03 18:48:20 +01:00
|
|
|
|
2014-04-15 14:21:44 +02:00
|
|
|
int link_initialized(Link *link, struct udev_device *device);
|
|
|
|
|
2014-02-27 01:24:05 +01:00
|
|
|
int link_save(Link *link);
|
|
|
|
|
|
|
|
const char* link_state_to_string(LinkState s) _const_;
|
|
|
|
LinkState link_state_from_string(const char *s) _pure_;
|
|
|
|
|
2013-10-17 03:18:36 +02:00
|
|
|
DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_free);
|
|
|
|
#define _cleanup_link_free_ _cleanup_(link_freep)
|
2014-01-09 02:42:38 +01:00
|
|
|
|
|
|
|
/* Macros which append INTERFACE= to the message */
|
|
|
|
|
2014-01-11 15:42:55 +01:00
|
|
|
#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%s: " fmt, link->ifname, ##__VA_ARGS__)
|
|
|
|
#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
|
|
|
|
#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
|
|
|
|
#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
|
|
|
|
#define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
|
|
|
|
#define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__)
|
2014-01-09 02:42:38 +01:00
|
|
|
|
|
|
|
#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
|
|
|
|
|
|
|
|
/* More macros which append INTERFACE= to the message */
|
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->name, "%s: " fmt, netdev->name, ##__VA_ARGS__)
|
|
|
|
#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
|
|
|
|
#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
|
|
|
|
#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
|
|
|
|
#define log_warning_netdev(netdev, ...) log_full_netdev(LOG_WARNING, netdev,## __VA_ARGS__)
|
|
|
|
#define log_error_netdev(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__)
|
2014-01-09 02:42:38 +01:00
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->name, __VA_ARGS__)
|
2014-01-09 02:42:38 +01:00
|
|
|
|
2014-01-21 21:58:08 +01:00
|
|
|
#define NETDEV(netdev) "INTERFACE=%s", netdev->name
|
2014-01-09 04:04:26 +01:00
|
|
|
#define ADDRESS_FMT_VAL(address) \
|
|
|
|
(address).s_addr & 0xFF, \
|
|
|
|
((address).s_addr >> 8) & 0xFF, \
|
|
|
|
((address).s_addr >> 16) & 0xFF, \
|
|
|
|
(address).s_addr >> 24
|