[LEDE-DEV] [LEDE-DEV, netifd] proto-shell: add helpers for generic options in proto handlers

Marcin Jurkowski marcin1j at gmail.com
Tue Oct 25 18:04:01 PDT 2016


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 <marcin1j at gmail.com>
---
 scripts/netifd-proto.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

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\""
-- 
2.7.3




More information about the Lede-dev mailing list