summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-wwan.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-06-13 20:22:35 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-13 20:22:35 +0200
commit1eb6aee88f411127175fdab031d896af1e1adbc3 (patch)
tree9b8f236e56106576e6c1a869ee5d8c1ce3452925 /src/conf_mode/interfaces-wwan.py
parentc667a45a8fb06cb76c907348c4f1e3ec708b6e03 (diff)
downloadvyos-1x-1eb6aee88f411127175fdab031d896af1e1adbc3.tar.gz
vyos-1x-1eb6aee88f411127175fdab031d896af1e1adbc3.zip
wwan: T3620: auto detect IP protocol based on requested addresses
Diffstat (limited to 'src/conf_mode/interfaces-wwan.py')
-rwxr-xr-xsrc/conf_mode/interfaces-wwan.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/conf_mode/interfaces-wwan.py b/src/conf_mode/interfaces-wwan.py
index a477163b9..31c599145 100755
--- a/src/conf_mode/interfaces-wwan.py
+++ b/src/conf_mode/interfaces-wwan.py
@@ -25,6 +25,7 @@ from vyos.configverify import verify_interface_exists
from vyos.configverify import verify_vrf
from vyos.ifconfig import WWANIf
from vyos.util import cmd
+from vyos.util import dict_search
from vyos.template import render
from vyos import ConfigError
from vyos import airbag
@@ -65,14 +66,25 @@ def apply(wwan):
# we only need the modem number. wwan0 -> 0, wwan1 -> 1
modem = wwan['ifname'].lstrip('wwan')
base_cmd = f'mmcli --modem {modem}'
+ # Number of bearers is limited - always disconnect first
+ cmd(f'{base_cmd} --simple-disconnect')
w = WWANIf(wwan['ifname'])
if 'deleted' in wwan or 'disable' in wwan:
w.remove()
- cmd(f'{base_cmd} --simple-disconnect')
return None
- options = 'apn=' + wwan['apn']
+ ip_type = 'ipv4'
+ slaac = dict_search('ipv6.address.autoconf', wwan) != None
+ if 'address' in wwan:
+ if 'dhcp' in wwan['address'] and ('dhcpv6' in wwan['address'] or slaac):
+ ip_type = 'ipv4v6'
+ elif 'dhcpv6' in wwan['address'] or slaac:
+ ip_type = 'ipv6'
+ elif 'dhcp' in wwan['address']:
+ ip_type = 'ipv4'
+
+ options = f'ip-type={ip_type},apn=' + wwan['apn']
if 'authentication' in wwan:
options += ',user={user},password={password}'.format(**wwan['authentication'])