qmicli and IPv4 / IPv6

Andre Valentin avalentin at marcant.net
Sun May 22 18:27:57 UTC 2016


Hi !

I analyzed the original firmware yesterday evening and also found this. I extended qmicli with a IP family patch
to add this this to the start-network command.

I tried to implement it like it is done with uqmi (the original openwrt qmi client) like this:
------------
CID1=$(qmicli -p -d /dev/cdc-wdm0 --wds-noop --client-no-release-cid|grep CID|cut -d\' -f2)
qmicli -v -p -d /dev/cdc-wdm0 --wds-start-network=apn=internet.t-mobile,family=4 --client-cid=$CID1 --client-no-release-cid

CID2=$(qmicli -p -d /dev/cdc-wdm0 --wds-noop --client-no-release-cid|grep CID|cut -d\' -f2)
qmicli -v -p -d /dev/cdc-wdm0 --wds-start-network=apn=internet.t-mobile,family=6 --client-cid=$CID2 --client-no-release-cid
------------
But qmicli gives me a POLICY MISMATCH error where uqmi works. I traced the writes to the the qmi device and
saw the following differences:

uqmi
3304  write(4, "\1$\0\0\1\10\0\2\0 \0\30\0\24\21\0internet.t-mobile\26\1\0\3", 37) = 37
qmicli
3415  write(5, "\1$\0\0\1\n\0\1\0 \0\30\0\31\1\0\4\24\21\0internet.t-mobile", 37) = 37

But I was not able to translate that back to the original commands. Do you have an idea?

I'll append the full log of it.

Here's my alpha patch of familiy support for qmicli:
--- libqmi-1.14.2.orig/src/qmicli/qmicli-wds.c	2016-05-21 23:33:27.028333300 +0200
+++ libqmi-1.14.2/src/qmicli/qmicli-wds.c	2016-05-21 23:56:08.404499137 +0200
@@ -67,7 +67,7 @@ static gboolean noop_flag;

 static GOptionEntry entries[] = {
     { "wds-start-network", 0, 0, G_OPTION_ARG_STRING, &start_network_str,
-      "Start network (allowed keys: apn, 3gpp-profile, 3gpp2-profile, auth (PAP|CHAP|BOTH), username, password, autoconnect=yes)",
+      "Start network (allowed keys: apn, 3gpp-profile, 3gpp2-profile, auth (PAP|CHAP|BOTH), username, password, autoconnect=yes, family=0|4|6)",
       "[\"key=value,...\"]"
     },
     { "wds-follow-network", 0, 0, G_OPTION_ARG_NONE, &follow_network_flag,
@@ -340,6 +340,7 @@ typedef struct {
     gchar                *password;
     gboolean              autoconnect;
     gboolean              autoconnect_set;
+    guint8                family;
 } StartNetworkProperties;

 static gboolean
@@ -397,6 +398,11 @@ start_network_properties_handle (const g
         return TRUE;
     }

+    if (g_ascii_strcasecmp (key, "family") == 0 && !props->family) {
+        props->family = atoi (value);
+        return TRUE;
+    }
+
     if (g_ascii_strcasecmp (key, "autoconnect") == 0 && !props->autoconnect_set) {
         if (!qmicli_read_yes_no_from_string (value, &(props->autoconnect))) {
             g_set_error (error,
@@ -432,6 +438,7 @@ start_network_input_create (const gchar
         .auth_set            = FALSE,
         .username            = NULL,
         .password            = NULL,
+        .family              = 0,
     };


@@ -502,18 +509,25 @@ start_network_input_create (const gchar
     if (props.password && props.password[0])
         qmi_message_wds_start_network_input_set_password (input, props.password, NULL);

+    if (props.family == 4) {
+            qmi_message_wds_start_network_input_set_ip_family_preference(input,4 , NULL);
+    } else if (props.family == 6) {
+            qmi_message_wds_start_network_input_set_ip_family_preference(input,6 , NULL);
+    }
+
     /* Set autoconnect */
     if (props.autoconnect_set)
         qmi_message_wds_start_network_input_set_enable_autoconnect (input, props.autoconnect, NULL);

-    g_debug ("Network start parameters set (apn: '%s', 3gpp_profile: '%u', 3gpp2_profile: '%u', auth: '%s', username: '%s', password: '%s', autoconnect: '%s')",
+    g_debug ("Network start parameters set (apn: '%s', 3gpp_profile: '%u', 3gpp2_profile: '%u', auth: '%s', username: '%s', password: '%s', autoconnect: '%s', family: '%u')",
              props.apn                             ? props.apn                          : "unspecified",
              props.profile_index_3gpp,
              props.profile_index_3gpp2,
              aux_auth_str                          ? aux_auth_str                       : "unspecified",
              (props.username && props.username[0]) ? props.username                     : "unspecified",
              (props.password && props.password[0]) ? props.password                     : "unspecified",
-             props.autoconnect_set                 ? (props.autoconnect ? "yes" : "no") : "unspecified");
+             props.autoconnect_set                 ? (props.autoconnect ? "yes" : "no") : "unspecified",
+             props.family);

 out:
     g_strfreev (split);


If you have an idea why this policy mismatch happens I would appreciate it. I prefer qmicli over uqmi
because it is still improved and has the proxy integrated.

Kind regards,

André



Am 22.05.2016 um 19:24 schrieb Bjørn Mork:
> You need to create two qmi wds sessions on the same cdc-wdm device, using the same apn for both. I am not sure about this, but I think this apn must be preconfigured as ipv4v6 in the list of confured contexts. Which you probably already did since you can connect it as both ipv4 and ipv6.
> 
> The missing trick is probably using the same cdc-wdm device.
> 
> Note that the double session is merely a qmi mapping. The modem will use a single dual stack connection to the network. The double qmi sessions give you two wds client id handles which you can use to retrieve the ipv4 and ipv6 configuration.
> 
> 
> Bjørn
> 
> On May 21, 2016 12:53:09 AM CEST, Andre Valentin <avalentin at marcant.net> wrote:
>> Hi!
>>
>> I'm currently trying to setup ZyXEL LTE3303 with openwrt. The device
>> has an integrated LTE modem,
>> it's a 1435:d181 Wistron NeWeb. It offers 3 qmi devices and 3 wwan
>> interfaces.
>>
>> I testet the original firmware and it enables a dualstack interface
>> with both address types. Now I
>> would like to enable the same in openwrt.
>>
>> If I just run:
>> qmicli -v -p -d /dev/cdc-wdm1 
>> --wds-start-network=apn=internet.t-mobile --client-cid=2
>> --client-no-release-cid
>> I will only get an IPv4 address.
>> Status:
>> qmicli -d /dev/cdc-wdm0 -p    --wds-get-current-settings
>> [/dev/cdc-wdm0] Current settings retrieved:
>>           IP Family: IPv4
>>        IPv4 address: 10.80.81.211
>>    IPv4 subnet mask: 255.255.255.248
>> IPv4 gateway address: 10.80.81.212
>>    IPv4 primary DNS: 10.74.210.210
>>  IPv4 secondary DNS: 10.74.210.211
>>                 MTU: 1500
>>             Domains: none
>>
>> I do not get an IPv6 Address. If I patch qmicli like this:
>> ------------------------------------------------------------------------------------------------------
>> --- libqmi-1.14.2/src/qmicli/qmicli-wds.c       2016-05-14
>> 13:19:20.000000000 +0200
>> +++ libqmi-1.14.2.patched/src/qmicli/qmicli-wds.c       2016-05-19
>> 20:50:17.792832166 +0200
>> @@ -434,6 +434,9 @@ start_network_input_create (const gchar
>>         .password            = NULL,
>>     };
>>
>> +
>> +    QmiWdsIpFamily ip_family = 6;
>> +
>>     /* An empty string is totally valid (i.e. no TLVs) */
>>     if (!str[0])
>>         return NULL;
>> @@ -501,6 +504,8 @@ start_network_input_create (const gchar
>>     if (props.password && props.password[0])
>> qmi_message_wds_start_network_input_set_password (input,
>> props.password, NULL);
>>
>> +   
>> qmi_message_wds_start_network_input_set_ip_family_preference(input,
>> ip_family, NULL);
>> +
>>     /* Set autoconnect */
>>     if (props.autoconnect_set)
>> qmi_message_wds_start_network_input_set_enable_autoconnect (input,
>> props.autoconnect, NULL);
>> ------------------------------------------------------------------------------------------------------
>> I will receive an IPv6 address, but only that. No IPv4. Also setting
>> ip_family to unspecified (8)
>> only leads to a working IPv4 connection.
>>
>> I tried to create 2 simultaneous connections over cdc-wdm0 and
>> cdc-wdm1, this works.
>> But that cannot be the solution!?
>>
>> Also if I take a look at my android devices both address types or
>> configured on a single interface.
>>
>> Do you have a hint how to solve this problems?
>>
>> Kind regards,
>>
>> André
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> libqmi-devel mailing list
>> libqmi-devel at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/libqmi-devel
> 
> _______________________________________________
> libqmi-devel mailing list
> libqmi-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/libqmi-devel
> 

-------------- next part --------------
root at OpenWrt:~# sh -x ./x.sh 
+ + cut -d'+ grep -f2 CID

qmicli -p -d /dev/cdc-wdm0 --wds-noop --client-no-release-cid
+ CID1=12
+ qmicli -v -p -d /dev/cdc-wdm0 --wds-start-network=apn=internet.t-mobile,family=4 --client-cid=12 --client-no-release-cid
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Opening device with flags 'proxy'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<<   length = 28
<<<<<<   data   = 01:1B:00:00:00:00:00:01:00:FF:10:00:01:0D:00:2F:64:65:76:2F:63:64:63:2D:77:64:6D:30

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<<   length  = 27
<<<<<<   flags   = 0x00
<<<<<<   service = "ctl"
<<<<<<   client  = 0
<<<<<< QMI:
<<<<<<   flags       = "none"
<<<<<<   transaction = 1
<<<<<<   tlv_length  = 16
<<<<<<   message     = "Internal Proxy Open" (0xFF00)
<<<<<< TLV:
<<<<<<   type       = "Device Path" (0x01)
<<<<<<   length     = 13
<<<<<<   value      = 2F:64:65:76:2F:63:64:63:2D:77:64:6D:30
<<<<<<   translated = /dev/cdc-wdm0

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>>   length = 19
>>>>>>   data   = 01:12:00:00:00:00:01:01:00:FF:07:00:02:04:00:00:00:00:00

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>>   length  = 18
>>>>>>   flags   = 0x00
>>>>>>   service = "ctl"
>>>>>>   client  = 0
>>>>>> QMI:
>>>>>>   flags       = "response"
>>>>>>   transaction = 1
>>>>>>   tlv_length  = 7
>>>>>>   message     = "Internal Proxy Open" (0xFF00)
>>>>>> TLV:
>>>>>>   type       = "Result" (0x02)
>>>>>>   length     = 4
>>>>>>   value      = 00:00:00:00
>>>>>>   translated = SUCCESS

[21 May 2016, 23:22:44] [Debug] QMI Device at '/dev/cdc-wdm0' ready
[21 May 2016, 23:22:44] [Debug] Reusing CID '12'
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Assuming service 'wds' is supported...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Reusing client CID '12'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Registered 'wds' (version unknown) client with ID '12'
[21 May 2016, 23:22:44] [Debug] Network start parameters set (apn: 'internet.t-mobile', 3gpp_profile: '0', 3gpp2_profile: '0', auth: 'unspecified', username: 'unspecified', password: 'unspecified', autoconnect: 'unspecified', family: '4')
[21 May 2016, 23:22:44] [Debug] Asynchronously starting network...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<<   length = 37
<<<<<<   data   = 01:24:00:00:01:0C:00:01:00:20:00:18:00:19:01:00:04:14:11:00:69:6E:74:65:72:6E:65:74:2E:74:2D:6D:6F:62:69:6C:65

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<<   length  = 36
<<<<<<   flags   = 0x00
<<<<<<   service = "wds"
<<<<<<   client  = 12
<<<<<< QMI:
<<<<<<   flags       = "none"
<<<<<<   transaction = 1
<<<<<<   tlv_length  = 24
<<<<<<   message     = "Start Network" (0x0020)
<<<<<< TLV:
<<<<<<   type       = "IP Family Preference" (0x19)
<<<<<<   length     = 1
<<<<<<   value      = 04
<<<<<<   translated = ipv4
<<<<<< TLV:
<<<<<<   type       = "APN" (0x14)
<<<<<<   length     = 17
<<<<<<   value      = 69:6E:74:65:72:6E:65:74:2E:74:2D:6D:6F:62:69:6C:65
<<<<<<   translated = internet.t-mobile

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>>   length = 27
>>>>>>   data   = 01:1A:00:80:01:0C:02:01:00:20:00:0E:00:02:04:00:00:00:00:00:01:04:00:B0:9A:A6:00

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>>   length  = 26
>>>>>>   flags   = 0x80
>>>>>>   service = "wds"
>>>>>>   client  = 12
>>>>>> QMI:
>>>>>>   flags       = "response"
>>>>>>   transaction = 1
>>>>>>   tlv_length  = 14
>>>>>>   message     = "Start Network" (0x0020)
>>>>>> TLV:
>>>>>>   type       = "Result" (0x02)
>>>>>>   length     = 4
>>>>>>   value      = 00:00:00:00
>>>>>>   translated = SUCCESS
>>>>>> TLV:
>>>>>>   type       = "Packet Data Handle" (0x01)
>>>>>>   length     = 4
>>>>>>   value      = B0:9A:A6:00
>>>>>>   translated = 10918576

[/dev/cdc-wdm0] Network started
	Packet data handle: '10918576'
[/dev/cdc-wdm0] Client ID not released:
	Service: 'wds'
	    CID: '12'
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Releasing 'wds' client with flags 'none'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Unregistered 'wds' client with ID '12'
[21 May 2016, 23:22:44] [Debug] Client released
+ + cut -d' -f2+ 
grep CID
qmicli -p -d /dev/cdc-wdm0 --wds-noop --client-no-release-cid
+ CID2=13
+ qmicli -v -p -d /dev/cdc-wdm0 --wds-start-network=apn=internet.t-mobile,family=6 --client-cid=13 --client-no-release-cid
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Opening device with flags 'proxy'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<<   length = 28
<<<<<<   data   = 01:1B:00:00:00:00:00:01:00:FF:10:00:01:0D:00:2F:64:65:76:2F:63:64:63:2D:77:64:6D:30

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<<   length  = 27
<<<<<<   flags   = 0x00
<<<<<<   service = "ctl"
<<<<<<   client  = 0
<<<<<< QMI:
<<<<<<   flags       = "none"
<<<<<<   transaction = 1
<<<<<<   tlv_length  = 16
<<<<<<   message     = "Internal Proxy Open" (0xFF00)
<<<<<< TLV:
<<<<<<   type       = "Device Path" (0x01)
<<<<<<   length     = 13
<<<<<<   value      = 2F:64:65:76:2F:63:64:63:2D:77:64:6D:30
<<<<<<   translated = /dev/cdc-wdm0

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>>   length = 19
>>>>>>   data   = 01:12:00:00:00:00:01:01:00:FF:07:00:02:04:00:00:00:00:00

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>>   length  = 18
>>>>>>   flags   = 0x00
>>>>>>   service = "ctl"
>>>>>>   client  = 0
>>>>>> QMI:
>>>>>>   flags       = "response"
>>>>>>   transaction = 1
>>>>>>   tlv_length  = 7
>>>>>>   message     = "Internal Proxy Open" (0xFF00)
>>>>>> TLV:
>>>>>>   type       = "Result" (0x02)
>>>>>>   length     = 4
>>>>>>   value      = 00:00:00:00
>>>>>>   translated = SUCCESS

[21 May 2016, 23:22:44] [Debug] QMI Device at '/dev/cdc-wdm0' ready
[21 May 2016, 23:22:44] [Debug] Reusing CID '13'
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Assuming service 'wds' is supported...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Reusing client CID '13'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Registered 'wds' (version unknown) client with ID '13'
[21 May 2016, 23:22:44] [Debug] Network start parameters set (apn: 'internet.t-mobile', 3gpp_profile: '0', 3gpp2_profile: '0', auth: 'unspecified', username: 'unspecified', password: 'unspecified', autoconnect: 'unspecified', family: '6')
[21 May 2016, 23:22:44] [Debug] Asynchronously starting network...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<<   length = 37
<<<<<<   data   = 01:24:00:00:01:0D:00:01:00:20:00:18:00:19:01:00:06:14:11:00:69:6E:74:65:72:6E:65:74:2E:74:2D:6D:6F:62:69:6C:65

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Sent message (translated)...
<<<<<< QMUX:
<<<<<<   length  = 36
<<<<<<   flags   = 0x00
<<<<<<   service = "wds"
<<<<<<   client  = 13
<<<<<< QMI:
<<<<<<   flags       = "none"
<<<<<<   transaction = 1
<<<<<<   tlv_length  = 24
<<<<<<   message     = "Start Network" (0x0020)
<<<<<< TLV:
<<<<<<   type       = "IP Family Preference" (0x19)
<<<<<<   length     = 1
<<<<<<   value      = 06
<<<<<<   translated = ipv6
<<<<<< TLV:
<<<<<<   type       = "APN" (0x14)
<<<<<<   length     = 17
<<<<<<   value      = 69:6E:74:65:72:6E:65:74:2E:74:2D:6D:6F:62:69:6C:65
<<<<<<   translated = internet.t-mobile

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message...
>>>>>> RAW:
>>>>>>   length = 20
>>>>>>   data   = 01:13:00:80:01:0D:02:01:00:20:00:07:00:02:04:00:01:00:4F:00

[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Received message (translated)...
>>>>>> QMUX:
>>>>>>   length  = 19
>>>>>>   flags   = 0x80
>>>>>>   service = "wds"
>>>>>>   client  = 13
>>>>>> QMI:
>>>>>>   flags       = "response"
>>>>>>   transaction = 1
>>>>>>   tlv_length  = 7
>>>>>>   message     = "Start Network" (0x0020)
>>>>>> TLV:
>>>>>>   type       = "Result" (0x02)
>>>>>>   length     = 4
>>>>>>   value      = 01:00:4F:00
>>>>>>   translated = FAILURE: PolicyMismatch

error: couldn't start network: QMI protocol error (79): 'PolicyMismatch'
[/dev/cdc-wdm0] Client ID not released:
	Service: 'wds'
	    CID: '13'
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Releasing 'wds' client with flags 'none'...
[21 May 2016, 23:22:44] [Debug] [/dev/cdc-wdm0] Unregistered 'wds' client with ID '13'
[21 May 2016, 23:22:44] [Debug] Client released

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3711 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.freedesktop.org/archives/libqmi-devel/attachments/20160522/53049286/attachment-0001.bin>


More information about the libqmi-devel mailing list