#include <linux/if.h>
#include <linux/if_arp.h>
-#include "escape.h"
#include "alloc-util.h"
#include "dhcp-client-internal.h"
#include "hostname-setup.h"
#include "string-table.h"
#include "strv.h"
#include "sysctl-util.h"
-#include "web-util.h"
static int dhcp4_request_address_and_routes(Link *link, bool announce);
static int dhcp4_remove_all(Link *link);
void *data,
void *userdata) {
- _cleanup_free_ char *unescaped = NULL;
Network *network = data;
- ssize_t l;
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- if (isempty(rvalue)) {
- network->dhcp_mudurl = mfree(network->dhcp_mudurl);
- return 0;
- }
-
- l = cunescape(rvalue, 0, &unescaped);
- if (l < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, l,
- "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
- return 0;
- }
-
- if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) {
- log_syntax(unit, LOG_WARNING, filename, line, 0,
- "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
-
- return 0;
- }
+ assert(network);
- return free_and_strdup_warn(&network->dhcp_mudurl, unescaped);
+ 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,
#include "sd-dhcp6-client.h"
-#include "escape.h"
#include "hashmap.h"
#include "hostname-setup.h"
#include "hostname-util.h"
#include "string-table.h"
#include "string-util.h"
#include "radv-internal.h"
-#include "web-util.h"
bool link_dhcp6_with_address_enabled(Link *link) {
if (!link_dhcp6_enabled(link))
void *data,
void *userdata) {
- _cleanup_free_ char *unescaped = NULL;
Network *network = data;
- ssize_t l;
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- if (isempty(rvalue)) {
- network->dhcp6_mudurl = mfree(network->dhcp6_mudurl);
- return 0;
- }
-
- l = cunescape(rvalue, 0, &unescaped);
- if (l < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, l,
- "Failed to Failed to unescape MUD URL, ignoring: %s", rvalue);
- return 0;
- }
-
- if (!http_url_is_valid(unescaped) || strlen(unescaped) > UINT8_MAX) {
- log_syntax(unit, LOG_WARNING, filename, line, 0,
- "Failed to parse MUD URL '%s', ignoring: %m", rvalue);
- return 0;
- }
+ assert(network);
- return free_and_replace(network->dhcp6_mudurl, unescaped);
+ 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,
#include "alloc-util.h"
#include "env-file.h"
-#include "escape.h"
#include "fd-util.h"
#include "hostname-util.h"
#include "missing_network.h"
#include "string-util.h"
#include "strv.h"
#include "unaligned.h"
-#include "web-util.h"
/* The LLDP spec calls this "txFastInit", see 9.2.5.19 */
#define LLDP_TX_FAST_INIT 4U
void *data,
void *userdata) {
- _cleanup_free_ char *unescaped = NULL;
- Network *n = data;
- ssize_t l;
-
- assert(filename);
- assert(lvalue);
- assert(rvalue);
-
- l = cunescape(rvalue, 0, &unescaped);
- if (l < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, l,
- "Failed to Failed to unescape LLDP MUD URL, ignoring: %s", rvalue);
- return 0;
- }
-
- if (!http_url_is_valid(unescaped) || strlen(unescaped) > 255) {
- log_syntax(unit, LOG_WARNING, filename, line, 0,
- "Failed to parse LLDP MUD URL '%s', ignoring: %m", rvalue);
+ Network *network = data;
- return 0;
- }
+ assert(network);
- return free_and_replace(n->lldp_mud, unescaped);
+ 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] = {
#include "condition.h"
#include "conf-parser.h"
+#include "escape.h"
#include "networkd-link.h"
#include "networkd-util.h"
#include "parse-util.h"
#include "string-table.h"
#include "string-util.h"
-#include "util.h"
+#include "web-util.h"
static const char* const address_family_table[_ADDRESS_FAMILY_MAX] = {
[ADDRESS_FAMILY_NO] = "no",
return 0;
}
+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) {
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(ret);
+
+ _cleanup_free_ char *unescaped = NULL;
+ ssize_t l;
+
+ l = cunescape(rvalue, 0, &unescaped);
+ if (l < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, l,
+ "Failed to unescape MUD URL, ignoring: %s", rvalue);
+ return 0;
+ }
+
+ if (l > UINT8_MAX || !http_url_is_valid(unescaped)) {
+ log_syntax(unit, LOG_WARNING, filename, line, 0,
+ "Invalid MUD URL, ignoring: %s", rvalue);
+ return 0;
+ }
+
+ return free_and_replace(*ret, unescaped);
+}
+
/* Router lifetime can be set with netlink interface since kernel >= 4.5
* so for the supported kernel we don't need to expire routes in userspace */
int kernel_route_expiration_supported(void) {
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);
+
const char *address_family_to_string(AddressFamily b) _const_;
AddressFamily address_family_from_string(const char *s) _pure_;