comgt-ncm: Add possibility to choose PDP context type
authorSteven Barth <cyrus@openwrt.org>
Fri, 11 Sep 2015 06:46:42 +0000 (06:46 +0000)
committerSteven Barth <cyrus@openwrt.org>
Fri, 11 Sep 2015 06:46:42 +0000 (06:46 +0000)
By setting the option pdptype to IP, IPV6 or IPV4V6 the user can
choose the context type between IPv4, IPv6 and dual stack,
respectively. The default setting is dual stack, except if option
ipv6=0 is specified, in which case IPv4 context is the default.
This allows for an out-of-the-box IPv6 support with modems
utilizing NCM-like protocols.

While we are at it, also add commands for Sierra DirectIP modems
(currently untested), which will allow us to drop the separate
comgt-directip package (once tested and verified working).

Signed-off-by: Matti Laakso <malaakso@elisanet.fi>
SVN-Revision: 46844

package/network/utils/comgt/Makefile
package/network/utils/comgt/files/ncm.json
package/network/utils/comgt/files/ncm.sh

index 18085a6..716bbbf 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=comgt
 PKG_VERSION:=0.32
-PKG_RELEASE:=25
+PKG_RELEASE:=26
 
 PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
 PKG_SOURCE_URL:=@SF/comgt
index ea4f984..d1f8699 100644 (file)
@@ -6,7 +6,8 @@
                        "ATQ0",
                        "ATV1",
                        "ATE1",
-                       "ATS0=0"
+                       "ATS0=0",
+                       "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
                ],
                "modes": {
                        "preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,",
@@ -25,7 +26,7 @@
                        "AT+CGREG=2",
                        "AT+CFUN=5",
                        "AT+MODESELECT=3",
-                       "AT+CGDCONT=1,\\\"IP\\\",\\\"${apn}\\\""
+                       "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
                ],
                "modes": {
                        "umts": "AT+CHANGEALLPATH=1"
                "connect": "AT+CGATT=1",
                "disconnect": "AT+CGATT=0"
        },
-       "sony": {
+       "sierra wireless, incorporated": {
                "initialize": [
                        "AT+CFUN=1",
-                       "AT+CGDCONT=1,\\\"IP\\\",\\\"${apn}\\\"",
+                       "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"",
+                       "AT$QCPDPP=1${auth:+,$auth}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}"
+               ],
+               "modes": {
+                       "preferlte": "AT!SELRAT=07",
+                       "preferumts": "AT!SELRAT=05",
+                       "lte": "AT!SELRAT=06",
+                       "umts": "AT!SELRAT=01",
+                       "gsm": "AT!SELRAT=02",
+                       "auto": "AT!SELRAT=00"
+               },
+               "connect": "AT!SCACT=1,1",
+               "disconnect": "AT!SCACT=0,1"
+       },
+       "sony ericsson": {
+               "initialize": [
+                       "AT+CFUN=1",
+                       "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"",
                        "AT*EIAAUW=1,1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}"
                ],
                "modes": {
index ffe5615..571cfaa 100644 (file)
@@ -17,6 +17,8 @@ proto_ncm_init_config() {
        proto_config_add_string pincode
        proto_config_add_string delay
        proto_config_add_string mode
+       proto_config_add_string pdptype
+       proto_config_add_boolean ipv6
 }
 
 proto_ncm_setup() {
@@ -24,8 +26,22 @@ proto_ncm_setup() {
 
        local manufacturer initialize setmode connect ifname devname devpath
 
-       local device apn auth username password pincode delay mode
-       json_get_vars device apn auth username password pincode delay mode
+       local device apn auth username password pincode delay mode pdptype ipv6
+       json_get_vars device apn auth username password pincode delay mode pdptype ipv6
+       
+       if [ "$ipv6" = 0 ]; then
+               ipv6=""
+       else
+               ipv6=1
+       fi
+       
+       [ -z "$pdptype" ] && {
+               if [ -n "$ipv6" ]; then
+                       pdptype="IPV4V6"
+               else
+                       pdptype="IP"
+               fi
+       }
 
        [ -n "$ctl_device" ] && device=$ctl_device
 
@@ -116,7 +132,7 @@ proto_ncm_setup() {
                return 1
        }
 
-       echo "Connected, starting DHCP"
+       echo "Connected, starting DHCP on $ifname"
        
        proto_init_update "$ifname" 1
        proto_send_update "$interface"
@@ -127,12 +143,14 @@ proto_ncm_setup() {
        json_add_string proto "dhcp"
        ubus call network add_dynamic "$(json_dump)"
 
-       json_init
-       json_add_string name "${interface}_6"
-       json_add_string ifname "@$interface"
-       json_add_string proto "dhcpv6"
-       json_add_string extendprefix 1
-       ubus call network add_dynamic "$(json_dump)"
+       [ -n "$ipv6" ] && {
+               json_init
+               json_add_string name "${interface}_6"
+               json_add_string ifname "@$interface"
+               json_add_string proto "dhcpv6"
+               json_add_string extendprefix 1
+               ubus call network add_dynamic "$(json_dump)"
+       }
 }
 
 proto_ncm_teardown() {