Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.AlternativeCombinator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.PreferValidAlternativeCombinator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.BOOLEAN
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.deprecatedBoolean
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.EOF
Expand Down Expand Up @@ -75,8 +75,10 @@ class ConfigParseAddressSectionDadOptionValue : SimpleGrammarOptionValues(
"yes means none and no means both. Please use 'both', 'ipv4', 'ipv6' or 'none' instead."

// The family names come first: a boolean terminal matches a prefix of the value, so it would
// otherwise take the leading "no" out of "none" and strand "ne".
val DAD = AlternativeCombinator(
// otherwise take the leading "no" out of "none" and strand "ne". PreferValidAlternativeCombinator stops the
// four-character names' lenient shape from taking "fals" out of "false". The family names are a
// case-sensitive table lookup; the boolean (parse_boolean) ignores case.
val DAD = PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("none", "both", "ipv4", "ipv6"),
deprecatedBoolean(HISTORICAL),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for CAKE.UseRawPacketSize
* C Function: config_parse_cake_tristate(QDISC_KIND_CAKE)
* Used by Options: CAKE.UseRawPacketSize
*
* Accepts tristate boolean values: yes/no/true/false/on/off/1/0
* Validator for CAKE.UseRawPacketSize (and AutoRateIngress=, NAT=, Wash=, SplitGSO=)
* C Function: config_parse_cake_tristate(QDISC_KIND_CAKE), src/network/tc/cake.c
*
* Reads the value with parse_tristate() -> parse_tristate_full() -> parse_boolean(), so it is a
* plain boolean in any casing (the empty value is handled by the framework).
*/
class ConfigParseCakeTristateOptionValue : SimpleGrammarOptionValues(
"config_parse_cake_tristate",
SequenceCombinator(
FlexibleLiteralChoiceTerminal("1", "yes", "y", "true", "t", "on", "0", "no", "n", "false", "f", "off"),
BOOLEAN,
EOF()
)
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for VXLAN.IPDoNotFragment
* C Function: config_parse_df(0)
* Used by Options: VXLAN.IPDoNotFragment
*
* Validates the IPv4 Do not Fragment (DF) bit setting.
* Accepts boolean values (yes/no/1/0/true/false/on/off/y/n/t/f) or "inherit".
* C Function: config_parse_df(0), src/network/netdev/vxlan.c
*
* DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(df, ...) over df_table (no, yes, inherit).
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseDfOptionValue : SimpleGrammarOptionValues(
"config_parse_df",
SequenceCombinator(
FlexibleLiteralChoiceTerminal("1", "yes", "y", "true", "t", "on", "0", "no", "n", "false", "f", "off", "inherit"),
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("inherit"),
BOOLEAN,
),
EOF()
)
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for Network.DHCP
* C Function: config_parse_dhcp(0)
* Used by Options: Network.DHCP
*
* Enables DHCPv4 and/or DHCPv6 client support.
* Accepts: yes, no, ipv4, or ipv6
* C Function: config_parse_dhcp(0), src/network/networkd-dhcp-common.c
*
* address_family_from_string first — DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN over address_family_table
* (no, yes, ipv4, ipv6) in src/network/networkd-util.c, so any boolean in any casing — then the
* case-sensitive dhcp_deprecated_address_family_table (none, both, v4, v6), which is accepted with a
* "DHCP=%s is deprecated" warning.
*/
class ConfigParseDhcpOptionValue : SimpleGrammarOptionValues(
"config_parse_dhcp",
SequenceCombinator(
FlexibleLiteralChoiceTerminal("yes", "no", "ipv4", "ipv6"),
// One names terminal (not two alternatives) so `none` is tried before `no` — the choices are
// matched longest first.
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("ipv4", "ipv6", "none", "both", "v4", "v6").deprecating(
mapOf(
"none" to "DHCP=none is deprecated, please use DHCP=no instead.",
"both" to "DHCP=both is deprecated, please use DHCP=yes instead.",
"v4" to "DHCP=v4 is deprecated, please use DHCP=ipv4 instead.",
"v6" to "DHCP=v6 is deprecated, please use DHCP=ipv6 instead.",
)
),
BOOLEAN,
),
EOF()
)
)
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for DHCPServer.PersistLeases
* C Function: config_parse_dhcp_server_persist_leases(0)
* Used by Options: DHCPServer.PersistLeases
* C Function: config_parse_dhcp_server_persist_leases(0), src/network/networkd-dhcp-server.c
*
* DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN over
* dhcp_server_persist_leases_table (no, yes, runtime).
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseDhcpServerPersistLeasesOptionValue : SimpleGrammarOptionValues(
"config_parse_dhcp_server_persist_leases",
SequenceCombinator(
FlexibleLiteralChoiceTerminal("runtime", "1", "yes", "y", "true", "t", "on", "0", "no", "n", "false", "f", "off"),
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("runtime"),
BOOLEAN,
),
EOF()
)
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.AlternativeCombinator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.BOOLEAN
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.EOF
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.FlexibleLiteralChoiceTerminal
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.SequenceCombinator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.PreferValidAlternativeCombinator

/**
* Validator for Network.DNSSEC (.network) and Resolve.DNSSEC (.conf via resolved.conf).
Expand All @@ -18,9 +18,10 @@ import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.gram
class ConfigParseDnssecModeOptionValue : SimpleGrammarOptionValues(
"config_parse_dnssec_mode",
SequenceCombinator(
AlternativeCombinator(
FlexibleLiteralChoiceTerminal("allow-downgrade"),
BOOLEAN
// dnssec_mode_table: the names are case-sensitive, the boolean half (parse_boolean) is not.
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("allow-downgrade"),
BOOLEAN,
),
EOF()
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for Swap.RuntimeDirectoryPreserve
* C Function: config_parse_exec_preserve_mode(0)
* Used by Options: Swap.RuntimeDirectoryPreserve
*
* Validates the preserve mode for runtime directories:
* - no: directories always removed when service stops
* - restart: directories preserved on automatic and manual restart
* - yes: directories not removed when service stops
* Validator for RuntimeDirectoryPreserve= (Service/Socket/Mount/Swap)
* C Function: config_parse_exec_preserve_mode(0), src/core/load-fragment.c
*
* DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN over exec_preserve_mode_table
* (no, yes, restart, on-success) in src/core/execute.c.
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseExecPreserveModeOptionValue : SimpleGrammarOptionValues(
"config_parse_exec_preserve_mode",
SequenceCombinator(
FlexibleLiteralChoiceTerminal("no", "restart", "yes"),
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("restart", "on-success"),
BOOLEAN,
),
EOF()
)
)
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for GENEVE.IPDoNotFragment
* C Function: config_parse_geneve_df(0)
* Used by Options: GENEVE.IPDoNotFragment
*
* Validates the IPDoNotFragment setting for GENEVE tunnels.
* Accepts: "no", "yes", "inherit" and standard boolean values.
* The DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN macro allows boolean aliases
* in addition to the enumerated values.
* C Function: config_parse_geneve_df(0), src/network/netdev/geneve.c
*
* DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(geneve_df, ...) over geneve_df_table (no, yes, inherit).
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseGeneveDfOptionValue : SimpleGrammarOptionValues(
"config_parse_geneve_df",
SequenceCombinator(
FlexibleLiteralChoiceTerminal(
"no", "yes", "inherit",
"1", "y", "true", "t", "on",
"0", "n", "false", "f", "off"
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("inherit"),
BOOLEAN,
),
EOF()
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for Network.IPMasquerade
* C Function: config_parse_ip_masquerade(0)
* Used by Options: Network.IPMasquerade
*
* Accepts: ipv4, ipv6, both, no, and deprecated boolean values
* (yes/true/on/1 map to ipv4, no/false/off/0 map to no)
* C Function: config_parse_ip_masquerade(0), src/network/networkd-util.c
*
* Calls parse_boolean() first (case-insensitive; yes/true/on/1 map to ipv4, no/false/off/0 to no),
* then ip_masquerade_address_family_from_string, a plain case-sensitive lookup over
* ip_masquerade_address_family_table (no, both, ipv4, ipv6).
*/
class ConfigParseIpMasqueradeOptionValue : SimpleGrammarOptionValues(
"config_parse_ip_masquerade",
SequenceCombinator(
FlexibleLiteralChoiceTerminal(
// Primary values
"ipv4", "ipv6", "both", "no",
// Deprecated boolean true values (map to ipv4)
"1", "yes", "y", "true", "t", "on",
// Deprecated boolean false values (map to no)
"0", "n", "false", "f", "off"
).deprecating(
// systemd.network(5): the boolean forms "are now deprecated. Please use one of the
// values above" (ipv4/ipv6/both/no). Still accepted; the truthy forms map to ipv4.
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("ipv4", "ipv6", "both"),
DEPRECATED_BOOLEAN
),
EOF()
)
) {
private companion object {
// systemd.network(5): the boolean forms "are now deprecated. Please use one of the values
// above" (ipv4/ipv6/both/no). Still accepted; the truthy forms map to ipv4.
val DEPRECATED_BOOLEAN = FlexibleLiteralChoiceTerminal(*BOOLEAN_SPELLINGS, ignoreCase = true).deprecating(
buildMap {
for (t in listOf("1", "yes", "y", "true", "t", "on")) {
put(t, "Boolean values for IPMasquerade= are deprecated; use \"ipv4\" (or \"ipv6\"/\"both\") instead.")
Expand All @@ -33,7 +33,6 @@ class ConfigParseIpMasqueradeOptionValue : SimpleGrammarOptionValues(
put(f, "Boolean values for IPMasquerade= are deprecated; use \"no\" instead.")
}
}
),
EOF()
)
)
)
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for Network.IPv6PrivacyExtensions
* C Function: config_parse_ipv6_privacy_extensions(0)
* Used by Options: Network.IPv6PrivacyExtensions
*
* Accepts boolean values (yes/no/true/false/on/off/1/0/y/n/t/f) or the special values
* "prefer-public" and "kernel".
* C Function: config_parse_ipv6_privacy_extensions(0), src/network/networkd-sysctl.c
*
* DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN over ipv6_privacy_extensions_table
* (no, prefer-public, yes, kernel).
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseIpv6PrivacyExtensionsOptionValue : SimpleGrammarOptionValues(
"config_parse_ipv6_privacy_extensions",
SequenceCombinator(
FlexibleLiteralChoiceTerminal(
// Boolean values
"1", "yes", "y", "true", "t", "on",
"0", "no", "n", "false", "f", "off",
// Special values
"prefer-public", "kernel"
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("prefer-public", "kernel"),
BOOLEAN,
),
EOF()
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
package net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.ai

import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.Validator
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.grammar.*
import net.sjrx.intellij.plugins.systemdunitfiles.semanticdata.optionvalues.SimpleGrammarOptionValues

/**
* Validator for Network.KeepConfiguration
* C Function: config_parse_keep_configuration(0)
* Used by Options: Network.KeepConfiguration
*
* Accepts:
* - Boolean values: 1, yes, y, true, t, on, 0, no, n, false, f, off
* - Specific values: static, dynamic-on-stop, dynamic
* - Backward compatibility: dhcp, dhcp-on-stop
* C Function: config_parse_keep_configuration(0), src/network/networkd-network.c
*
* First the backward-compatibility names `dhcp` and `dhcp-on-stop` (streq, case-sensitive), then
* keep_configuration_from_string: DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN over
* keep_configuration_table (no, dynamic-on-stop, dynamic, static, yes).
* string_table_lookup_from_string_with_boolean tries parse_boolean() (case-insensitive) first,
* then a case-sensitive lookup in the table, so only the boolean half ignores case.
*/
class ConfigParseKeepConfigurationOptionValue : SimpleGrammarOptionValues(
"config_parse_keep_configuration",
SequenceCombinator(
FlexibleLiteralChoiceTerminal(
// Boolean values (map to yes/no)
"1", "yes", "y", "true", "t", "on",
"0", "no", "n", "false", "f", "off",
// Explicit enum values
"static", "dynamic-on-stop", "dynamic",
// Backward compatibility
"dhcp", "dhcp-on-stop"
PreferValidAlternativeCombinator(
FlexibleLiteralChoiceTerminal("dynamic-on-stop", "dynamic", "static", "dhcp", "dhcp-on-stop"),
BOOLEAN,
),
EOF()
)
Expand Down
Loading
Loading