link-config.h revision dab495dc23bf9a5ba0487a057bb594355555a0e9
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright (C) 2013 Tom Gundersen <teg@jklm.no>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "ethtool-util.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "condition.h"
50f1e641a93cacfc693b0c3d300bee5df0c8c460Tom Gundersen#include "list.h"
71d35b6b5563817dfbe757ab9e3b9f018b2db491Thomas Hindoe Paaboel Andersen#include "libudev.h"
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poettering
623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbfLennart Poetteringtypedef struct link_config_ctx link_config_ctx;
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringtypedef struct link_config link_config;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringtypedef enum MACPolicy {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MACPOLICY_PERSISTENT,
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering MACPOLICY_RANDOM,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _MACPOLICY_MAX,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering _MACPOLICY_INVALID = -1
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering} MACPolicy;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
322345fdb9865ef2477fba8e4bdde0e1183ef505Lennart Poetteringtypedef enum NamePolicy {
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek NAMEPOLICY_KERNEL,
b93312f5960b276bae915906ccde36f545bae3e0Zbigniew Jędrzejewski-Szmek NAMEPOLICY_DATABASE,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering NAMEPOLICY_ONBOARD,
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering NAMEPOLICY_SLOT,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering NAMEPOLICY_PATH,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering NAMEPOLICY_MAC,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering _NAMEPOLICY_MAX,
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering _NAMEPOLICY_INVALID = -1
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack} NamePolicy;
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mackstruct link_config {
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char *filename;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering struct ether_addr *match_mac;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char **match_path;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char **match_driver;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char **match_type;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char **match_name;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Condition *match_host;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Condition *match_virt;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Condition *match_kernel;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Condition *match_arch;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char *description;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering struct ether_addr *mac;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering MACPolicy mac_policy;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering NamePolicy *name_policy;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char *name;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering char *alias;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering size_t mtu;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering size_t speed;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering Duplex duplex;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering WakeOnLan wol;
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering LIST_FIELDS(link_config, links);
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering};
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poettering
8730bccfc59fe507bd3e0a3abcf411b497ac4f0eLennart Poetteringint link_config_ctx_new(link_config_ctx **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringvoid link_config_ctx_free(link_config_ctx *ctx);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poettering
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringint link_config_load(link_config_ctx *ctx);
faa133f3aa7a18f26563dc5d6b95898cb315c37aLennart Poetteringbool link_config_should_reload(link_config_ctx *ctx);
23502de3b0891455c8ce499a9eb61b69d060a829Daniel Mack
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device, const char **name);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poetteringint link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poetteringconst char *name_policy_to_string(NamePolicy p) _const_;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart PoetteringNamePolicy name_policy_from_string(const char *p) _pure_;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poetteringconst char *mac_policy_to_string(MACPolicy p) _const_;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart PoetteringMACPolicy mac_policy_from_string(const char *p) _pure_;
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering/* gperf lookup function */
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poetteringconst struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length);
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poettering
1b4f6e79ec51a57003896a0b605fba427b4a98d2Lennart Poetteringint config_parse_mac_policy(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);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poetteringint config_parse_name_policy(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);
2001c80560e3dae69e14fd994d3978c187af48b8Lennart Poettering