qmi: add metric, defaultroute and peerdns options for qmi protocol
Adds generic network options for qmi protocol dynamic interfaces as suggested by Felix in https://lists.openwrt.org/pipermail/openwrt-devel/2016-February/039794.html. IPv6-related code taken from Bruno's patch https://patchwork.ozlabs.org/patch/584816. This depends on netifd patch https://patchwork.ozlabs.org/patch/686820/. Signed-off-by: Marcin Jurkowski <marcin1j@gmail.com> Signed-off-by: Bruno Randolf <br1@einfach.org>
This commit is contained in:
parent
35129469ca
commit
85fbffd74b
1 changed files with 10 additions and 8 deletions
|
@ -19,16 +19,16 @@ proto_qmi_init_config() {
|
||||||
proto_config_add_string modes
|
proto_config_add_string modes
|
||||||
proto_config_add_boolean ipv6
|
proto_config_add_boolean ipv6
|
||||||
proto_config_add_boolean dhcp
|
proto_config_add_boolean dhcp
|
||||||
proto_config_add_int metric
|
proto_config_add_defaults
|
||||||
}
|
}
|
||||||
|
|
||||||
proto_qmi_setup() {
|
proto_qmi_setup() {
|
||||||
local interface="$1"
|
local interface="$1"
|
||||||
|
|
||||||
local device apn auth username password pincode delay modes ipv6 dhcp metric
|
local device apn auth username password pincode delay modes ipv6 dhcp $PROTO_DEFAULT_OPTIONS
|
||||||
local cid_4 pdh_4 cid_6 pdh_6 ipv4
|
local cid_4 pdh_4 cid_6 pdh_6 ipv4
|
||||||
local ip subnet gateway dns1 dns2 ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
|
local ip subnet gateway dns1 dns2 ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
|
||||||
json_get_vars device apn auth username password pincode delay modes ipv6 dhcp metric
|
json_get_vars device apn auth username password pincode delay modes ipv6 dhcp $PROTO_DEFAULT_OPTIONS
|
||||||
|
|
||||||
ipv4=1
|
ipv4=1
|
||||||
|
|
||||||
|
@ -172,9 +172,11 @@ proto_qmi_setup() {
|
||||||
proto_add_ipv6_address "$ip_6" "128"
|
proto_add_ipv6_address "$ip_6" "128"
|
||||||
proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
|
proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
|
||||||
proto_add_ipv6_route "$gateway_6" "128"
|
proto_add_ipv6_route "$gateway_6" "128"
|
||||||
proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}"
|
[ "$defaultroute" = 0 ] || proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}"
|
||||||
|
[ "$peerdns" = 0 ] || {
|
||||||
proto_add_dns_server "$dns1_6"
|
proto_add_dns_server "$dns1_6"
|
||||||
proto_add_dns_server "$dns2_6"
|
proto_add_dns_server "$dns2_6"
|
||||||
|
}
|
||||||
proto_add_data
|
proto_add_data
|
||||||
json_add_string "cid_6" "$cid_6"
|
json_add_string "cid_6" "$cid_6"
|
||||||
json_add_string "pdh_6" "$pdh_6"
|
json_add_string "pdh_6" "$pdh_6"
|
||||||
|
@ -183,7 +185,7 @@ proto_qmi_setup() {
|
||||||
json_add_string name "${interface}_6"
|
json_add_string name "${interface}_6"
|
||||||
json_add_string ifname "@$interface"
|
json_add_string ifname "@$interface"
|
||||||
json_add_string proto "dhcpv6"
|
json_add_string proto "dhcpv6"
|
||||||
json_add_int metric "$metric"
|
proto_add_dynamic_defaults
|
||||||
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
|
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
|
||||||
json_add_string extendprefix 1
|
json_add_string extendprefix 1
|
||||||
json_close_object
|
json_close_object
|
||||||
|
@ -199,7 +201,7 @@ proto_qmi_setup() {
|
||||||
json_add_string name "${interface}_4"
|
json_add_string name "${interface}_4"
|
||||||
json_add_string ifname "@$interface"
|
json_add_string ifname "@$interface"
|
||||||
json_add_string proto "dhcp"
|
json_add_string proto "dhcp"
|
||||||
json_add_int metric "$metric"
|
proto_add_dynamic_defaults
|
||||||
json_close_object
|
json_close_object
|
||||||
ubus call network add_dynamic "$(json_dump)"
|
ubus call network add_dynamic "$(json_dump)"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue