From: Marcin Jurkowski Date: Wed, 26 Oct 2016 01:04:01 +0000 (+0200) Subject: proto-shell: add helpers for generic options in proto handlers X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1615fc93b878eb28af434a7093631109197c7197;p=project%2Fnetifd.git proto-shell: add helpers for generic options in proto handlers Adding helpers for virtual interfaces generic options in ncm, qmi, mbim and directip protocols as suggested by Felix in https://lists.openwrt.org/pipermail/openwrt-devel/2016-February/039794.html Signed-off-by: Marcin Jurkowski --- diff --git a/scripts/netifd-proto.sh b/scripts/netifd-proto.sh index 64b3cab..cc7031a 100644 --- a/scripts/netifd-proto.sh +++ b/scripts/netifd-proto.sh @@ -1,4 +1,5 @@ NETIFD_MAIN_DIR="${NETIFD_MAIN_DIR:-/lib/netifd}" +PROTO_DEFAULT_OPTIONS="defaultroute peerdns metric" . /usr/share/libubox/jshn.sh . $NETIFD_MAIN_DIR/utils.sh @@ -15,6 +16,18 @@ proto_config_add_boolean() { config_add_boolean "$@" } +proto_config_add_defaults() { + proto_config_add_boolean "defaultroute" + proto_config_add_boolean "peerdns" + proto_config_add_int "metric" +} + +proto_add_dynamic_defaults() { + [ -n "$defaultroute" ] && json_add_boolean defaultroute "$defaultroute" + [ -n "$peerdns" ] && json_add_boolean peerdns "$peerdns" + [ -n "$metric" ] && json_add_int metric "$metric" +} + _proto_do_teardown() { json_load "$data" eval "proto_$1_teardown \"$interface\" \"$ifname\""