support non default ip-types
authorBjørn Mork <bjorn@mork.no>
Wed, 8 Apr 2015 13:31:24 +0000 (15:31 +0200)
committerJohn Crispin <blogic@openwrt.org>
Fri, 3 Apr 2015 08:33:38 +0000 (10:33 +0200)
Signed-off-by: Bjørn Mork <bjorn@mork.no>
cli.c

diff --git a/cli.c b/cli.c
index d1f3e88dc5ccbdadd6b46035113f605c2991503c..15ca5b4e4a3133f92e491cbc6f3e3452d8912172 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -324,6 +324,7 @@ mbim_detach_request(void)
 static int
 mbim_connect_request(void)
 {
+       char *apn;
        struct mbim_basic_connect_connect_s *c =
                (struct mbim_basic_connect_connect_s *) mbim_setup_command_msg(basic_connect,
                        MBIM_MESSAGE_COMMAND_TYPE_SET, MBIM_CMD_BASIC_CONNECT_CONNECT,
@@ -332,8 +333,22 @@ mbim_connect_request(void)
        c->activationcommand = htole32(MBIM_ACTIVATION_COMMAND_ACTIVATE);
        c->iptype = htole32(MBIM_CONTEXT_IP_TYPE_DEFAULT);
        memcpy(c->contexttype, uuid_context_type_internet, 16);
-       if (_argc > 0)
-               mbim_encode_string(&c->accessstring, *_argv);
+       if (_argc > 0) {
+               apn = index(*_argv, ':');
+               if (!apn) {
+                       apn = *_argv;
+               } else {
+                       apn[0] = 0;
+                       apn++;
+                       if (!strcmp(*_argv, "ipv4"))
+                               c->iptype = htole32(MBIM_CONTEXT_IP_TYPE_IPV4);
+                       else if (!strcmp(*_argv, "ipv6"))
+                               c->iptype = htole32(MBIM_CONTEXT_IP_TYPE_IPV6);
+                       else if (!strcmp(*_argv, "ipv4v6"))
+                               c->iptype = htole32(MBIM_CONTEXT_IP_TYPE_IPV4V6);
+               }
+               mbim_encode_string(&c->accessstring, apn);
+       }
        if (_argc > 3) {
                if (!strcmp(_argv[1], "pap"))
                        c->authprotocol = htole32(MBIM_AUTH_PROTOCOL_PAP);