diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-07-14 08:47:40 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2021-07-14 18:41:00 +0200 |
commit | 77976a6877d9b115814ddff19cd4cdbf8ca91848 (patch) | |
tree | c18e3b97ceb8538136a8c6f50efe047e7795ab70 /src | |
parent | man/systemd.network: Fix duplicate Xfrm description (diff) | |
download | systemd-77976a6877d9b115814ddff19cd4cdbf8ca91848.tar.xz systemd-77976a6877d9b115814ddff19cd4cdbf8ca91848.zip |
network: further unification of MUD url parsers
Follow-up for 89fa9a6b7b2505aa2ce18febf1e28e79510dfec2.
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-dhcp4.c | 20 | ||||
-rw-r--r-- | src/network/networkd-dhcp6.c | 20 | ||||
-rw-r--r-- | src/network/networkd-lldp-tx.c | 20 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 6 | ||||
-rw-r--r-- | src/network/networkd-util.c | 17 | ||||
-rw-r--r-- | src/network/networkd-util.h | 12 |
6 files changed, 16 insertions, 79 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 8609a63b83..511e4b1bdf 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -1719,26 +1719,6 @@ int config_parse_dhcp_ip_service_type( return 0; } -int config_parse_dhcp_mud_url( - 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) { - - Network *network = data; - - assert(network); - - return config_parse_mud_url(unit, filename, line, section, section_line, lvalue, ltype, rvalue, - &network->dhcp_mudurl); -} - int config_parse_dhcp_fallback_lease_lifetime(const char *unit, const char *filename, unsigned line, diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index ccf2ec5b3f..2445acbe07 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -1788,26 +1788,6 @@ int config_parse_dhcp6_pd_hint( return 0; } -int config_parse_dhcp6_mud_url( - 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) { - - Network *network = data; - - assert(network); - - return config_parse_mud_url(unit, filename, line, section, section_line, lvalue, ltype, rvalue, - &network->dhcp6_mudurl); -} - DEFINE_CONFIG_PARSE_ENUM(config_parse_dhcp6_client_start_mode, dhcp6_client_start_mode, DHCP6ClientStartMode, "Failed to parse WithoutRA= setting"); diff --git a/src/network/networkd-lldp-tx.c b/src/network/networkd-lldp-tx.c index e6e0b5ee54..061059558e 100644 --- a/src/network/networkd-lldp-tx.c +++ b/src/network/networkd-lldp-tx.c @@ -414,26 +414,6 @@ void link_lldp_emit_stop(Link *link) { link->lldp_emit_event_source = sd_event_source_unref(link->lldp_emit_event_source); } -int config_parse_lldp_mud( - 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) { - - Network *network = data; - - assert(network); - - return config_parse_mud_url(unit, filename, line, section, section_line, lvalue, ltype, rvalue, - &network->lldp_mud); -} - static const char * const lldp_emit_table[_LLDP_EMIT_MAX] = { [LLDP_EMIT_NO] = "no", [LLDP_EMIT_NEAREST_BRIDGE] = "nearest-bridge", diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index e3ced5a45c..de4120c47e 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -214,7 +214,7 @@ DHCPv4.SendHostname, config_parse_bool, DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname) DHCPv4.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast) DHCPv4.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier) -DHCPv4.MUDURL, config_parse_dhcp_mud_url, 0, 0 +DHCPv4.MUDURL, config_parse_mud_url, 0, offsetof(Network, dhcp_mudurl) DHCPv4.MaxAttempts, config_parse_dhcp_max_attempts, 0, 0 DHCPv4.UserClass, config_parse_dhcp_user_or_vendor_class, AF_INET, offsetof(Network, dhcp_user_class) DHCPv4.IAID, config_parse_iaid, AF_INET, 0 @@ -239,7 +239,7 @@ DHCPv6.UseHostname, config_parse_bool, DHCPv6.UseDomains, config_parse_dhcp_use_domains, 0, 0 DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0 DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit) -DHCPv6.MUDURL, config_parse_dhcp6_mud_url, 0, 0 +DHCPv6.MUDURL, config_parse_mud_url, 0, offsetof(Network, dhcp6_mudurl) DHCPv6.RequestOptions, config_parse_dhcp_request_options, AF_INET6, 0 DHCPv6.UserClass, config_parse_dhcp_user_or_vendor_class, AF_INET6, offsetof(Network, dhcp6_user_class) DHCPv6.VendorClass, config_parse_dhcp_user_or_vendor_class, AF_INET6, offsetof(Network, dhcp6_vendor_class) @@ -342,7 +342,7 @@ IPv6Prefix.Assign, config_parse_prefix_assign, IPv6Prefix.RouteMetric, config_parse_prefix_metric, 0, 0 IPv6RoutePrefix.Route, config_parse_route_prefix, 0, 0 IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime, 0, 0 -LLDP.MUDURL, config_parse_lldp_mud, 0, 0 +LLDP.MUDURL, config_parse_mud_url, 0, offsetof(Network, lldp_mud) CAN.BitRate, config_parse_can_bitrate, 0, offsetof(Network, can_bitrate) CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point) CAN.DataBitRate, config_parse_can_bitrate, 0, offsetof(Network, can_data_bitrate) diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c index a6b9a7f8b6..d7906e0cb5 100644 --- a/src/network/networkd-util.c +++ b/src/network/networkd-util.c @@ -171,15 +171,22 @@ int config_parse_mud_url( const char *lvalue, int ltype, const char *rvalue, - char **ret) { + void *data, + void *userdata) { + + _cleanup_free_ char *unescaped = NULL; + char **url = data; + ssize_t l; assert(filename); assert(lvalue); assert(rvalue); - assert(ret); + assert(url); - _cleanup_free_ char *unescaped = NULL; - ssize_t l; + if (isempty(rvalue)) { + *url = mfree(*url); + return 0; + } l = cunescape(rvalue, 0, &unescaped); if (l < 0) { @@ -194,7 +201,7 @@ int config_parse_mud_url( return 0; } - return free_and_replace(*ret, unescaped); + return free_and_replace(*url, unescaped); } /* Router lifetime can be set with netlink interface since kernel >= 4.5 diff --git a/src/network/networkd-util.h b/src/network/networkd-util.h index 7471f18970..997bcee4b4 100644 --- a/src/network/networkd-util.h +++ b/src/network/networkd-util.h @@ -22,17 +22,7 @@ typedef struct NetworkConfigSection { CONFIG_PARSER_PROTOTYPE(config_parse_link_local_address_family); CONFIG_PARSER_PROTOTYPE(config_parse_address_family_with_kernel); CONFIG_PARSER_PROTOTYPE(config_parse_ip_masquerade); - -int config_parse_mud_url( - const char *unit, - const char *filename, - unsigned line, - const char *section, - unsigned section_line, - const char *lvalue, - int ltype, - const char *rvalue, - char **ret); +CONFIG_PARSER_PROTOTYPE(config_parse_mud_url); const char *address_family_to_string(AddressFamily b) _const_; AddressFamily address_family_from_string(const char *s) _pure_; |