summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-ipv4ll.c
diff options
context:
space:
mode:
authorAndre Kalb <andre.kalb@sma.de>2022-06-30 10:01:34 +0200
committerAndre Kalb <andre.kalb@sma.de>2022-07-13 23:57:18 +0200
commit34b63c9e458b08e1894ea458687c8450817762b8 (patch)
tree49b586da794ba7f0bd5c08351c11af1195d51e2a /src/network/networkd-ipv4ll.c
parentMerge pull request #23931 from yuwata/systemctl-color-log (diff)
downloadsystemd-34b63c9e458b08e1894ea458687c8450817762b8.tar.xz
systemd-34b63c9e458b08e1894ea458687c8450817762b8.zip
network: Add support to select an IPv4 link-local start address
Diffstat (limited to 'src/network/networkd-ipv4ll.c')
-rw-r--r--src/network/networkd-ipv4ll.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 67eb9d2aa1..8833bee233 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -263,3 +263,44 @@ int config_parse_ipv4ll(
return 0;
}
+
+int config_parse_ipv4ll_address(
+ 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) {
+
+ union in_addr_union a;
+ struct in_addr *ipv4ll_address = ASSERT_PTR(data);
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ if (isempty(rvalue)) {
+ *ipv4ll_address = (struct in_addr) {};
+ return 0;
+ }
+
+ r = in_addr_from_string(AF_INET, rvalue, &a);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Failed to parse %s=, ignoring assignment: %s", lvalue, rvalue);
+ return 0;
+ }
+ if (!in4_addr_is_link_local(&a.in)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Not a IPv4 link local address, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ *ipv4ll_address = a.in;
+ return 0;
+}