This function checks if an mtu is valid for a given IP protocol.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.util | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/src/functions/functions.util b/src/functions/functions.util index 4b6f956..b7e35c9 100644 --- a/src/functions/functions.util +++ b/src/functions/functions.util @@ -321,6 +321,24 @@ isipaddress() { ip_is_valid ${addr} }
+mtu_is_valid() { + local proto=${1} + local mtu=${2} + + case ${proto} in + ipv4) + [ ${mtu} -ge 576 ] && [ ${mtu} -le 9000 ] + ;; + ipv6) + [ ${mtu} -ge 1280 ] && [ ${mtu} -le 9000 ] + ;; + *) + error "${proto} is not a valid proto" + return ${EXIT_ERROR} + ;; + esac +} + backtrace() { local start=1