summaryrefslogtreecommitdiff
path: root/src/udev/net/link-config.h
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-10-26 00:34:01 +0200
committerTom Gundersen <teg@jklm.no>2013-10-26 22:09:20 +0200
commitaf6f0d422c521374ee6a2dd92df5935a5a476ae5 (patch)
treea6042b86dc3c90c97699e354946f8d3a43b4e5c4 /src/udev/net/link-config.h
parentca5c4105733ea439f89b0199cd3f92bc2f2a0b38 (diff)
udev: add network link configuration tool
This tool applies hardware specific settings to network devices before they are announced via libudev. Settings that will probably eventually be supported are MTU, Speed, DuplexMode, WakeOnLan, MACAddress, MACAddressPolicy (e.g., 'hardware', 'synthetic' or 'random'), Name and NamePolicy (replacing our current interface naming logic). This patch only introduces support for Description, as a proof of concept. Some of these settings may later be overriden by a network management daemon/script. However, these tools should always listen and wait on libudev before touching a device (listening on netlink is not enough). This is no different from how things used to be, as we always supported changing the network interface name from udev rules, which does not work if someone has already started using it. The tool is configured by .link files in /etc/net/links/ (with the usual overriding logic in /run and /lib). The first (in lexicographical order) matching .link file is applied to a given device, and all others are ignored. The .link files contain a [Match] section with (currently) the keys MACAddress, Driver, Type (see DEVTYPE in udevadm info) and Path (this matches on the stable device path as exposed as ID_PATH, and not the unstable DEVPATH). A .link file matches a given device if all of the specified keys do. Currently the keys are treated as plain strings, but some limited globbing may later be added to the keys where it makes sense. Example: /etc/net/links/50-wireless.link [Match] MACAddress=98:f2:e4:42:c6:92 Path=pci-0000:02:00.0-bcma-0 Type=wlan [Link] Description=The wireless link
Diffstat (limited to 'src/udev/net/link-config.h')
-rw-r--r--src/udev/net/link-config.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/udev/net/link-config.h b/src/udev/net/link-config.h
new file mode 100644
index 0000000000..da5608ce4c
--- /dev/null
+++ b/src/udev/net/link-config.h
@@ -0,0 +1,55 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright (C) 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 "libudev.h"
+#include "util.h"
+#include "list.h"
+
+
+typedef struct link_config_ctx link_config_ctx;
+typedef struct link_config link_config;
+
+struct link_config {
+ char *filename;
+
+ char *match_mac;
+ char *match_path;
+ char *match_driver;
+ char *match_type;
+
+ char *description;
+
+ LIST_FIELDS(link_config, links);
+};
+
+int link_config_ctx_new(link_config_ctx **ret);
+void link_config_ctx_free(link_config_ctx *ctx);
+
+int link_config_load(link_config_ctx *ctx);
+bool link_config_should_reload(link_config_ctx *ctx);
+
+int link_config_get(link_config_ctx *ctx, struct udev_device *device, struct link_config **ret);
+int link_config_apply(link_config_ctx *ctx, struct link_config *config, struct udev_device *device);
+
+/* gperf lookup function */
+const struct ConfigPerfItem* link_config_gperf_lookup(const char *key, unsigned length);