X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=blobdiff_plain;f=src%2Fhooks%2Fports%2Fvlan;fp=src%2Fhooks%2Fports%2Fvlan;h=af563eed4bfa7b3ce9df31dd2c555411dba4de4b;hp=7f99dbcdcf421a89b684515fd3b884baeb7b215d;hb=2eb7011cb5447f9568c8136940f59a047e1b8dae;hpb=9532462fe04658d728ecbf263b586111f73fe2b2 diff --git a/src/hooks/ports/vlan b/src/hooks/ports/vlan index 7f99dbcd..af563eed 100644 --- a/src/hooks/ports/vlan +++ b/src/hooks/ports/vlan @@ -25,14 +25,21 @@ HOOK_SETTINGS=( "ADDRESS" "ID" "PARENT_PORT" + "PROTOCOL" ) +# Set the default to 802.1Q +DEFAULT_PROTOCOL="${VLAN_SUPPORTED_PROTOCOLS[0]}" + PORT_PARENTS_VAR="PARENT_PORT" hook_check_settings() { assert ismac ADDRESS assert isset PARENT_PORT + assert isset PROTOCOL + assert vlan_supported_protocol "${PROTOCOL}" + assert isinteger ID assert vlan_valid_id "${ID}" } @@ -74,6 +81,16 @@ hook_parse_cmdline() { return ${EXIT_CONF_ERROR} fi ;; + --protocol=*) + PROTOCOL="$(cli_get_val "${1}")" + + # Check if PROTOCOL is supported + if ! vlan_supported_protocol "${PROTOCOL}"; then + error "Protocol '${PROTOCOL}' is not supported" + error "Choose one of ${VLAN_SUPPORTED_PROTOCOLS[*]}" + return ${EXIT_CONF_ERROR} + fi + ;; *) error "Unknown argument '${1}'" return ${EXIT_CONF_ERROR} @@ -114,8 +131,9 @@ hook_create() { # Create the VLAN device if ! vlan_create "${port}" \ --address="${ADDRESS}" \ - --id="${id}" \ - --parent="${PARENT_PORT}"; then + --id="${ID}" \ + --parent="${PARENT_PORT}" \ + --protocol="${PROTOCOL}"; then error "Could not create port: ${port}" return ${EXIT_ERROR} fi