Merge remote-tracking branch 'cros/upstream' into 'cros/master'

Change-Id: I1db111261c2bea3e6e11a7726a0f3b980fb820a5
diff --git a/.gitignore b/.gitignore
index b1a050d..6b5064d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -58,6 +58,8 @@
 /docs/man/mbimcli.1
 /docs/man/mbim-network.1
 
+/src/common/test/test-common
+
 /src/libmbim-glib/.deps
 /src/libmbim-glib/.libs
 /src/libmbim-glib/mbim-version.h
diff --git a/AUTHORS b/AUTHORS
index 81a6de0..f31ceab 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,11 +7,18 @@
   Greg Suarez
   Bjørn Mork
   Roshan Pius
+  Emil Ljungdahl
   Prathmesh Prabhu
-  Yunlian Jiang
   Shawn J. Goff
-  Scott Lee
-  Raju
-  Marius B. Kotsbak
-  Boris Egorov
   Arnaud Desmier
+  Boris Egorov
+  Carlo Lobrano
+  Collin McMillan
+  David Ward
+  Jaroslav Stepanek
+  Marius B. Kotsbak
+  Philip Withnall
+  Raju
+  Scott Lee
+  Shih-Yuan Lee (FourDollars)
+  Yunlian Jiang
\ No newline at end of file
diff --git a/NEWS b/NEWS
index b451aa5..2c3663e 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,46 @@
 
+Overview of changes in libmbim 1.16
+----------------------------------------
+
+* Build now requires GLib 2.36.
+
+* All the code base was ported to use the GTask based asynchronous operations
+  support instead of the deprecated GSimpleAsyncResult.
+
+* New AT&T Device Service support, that includes operator-specific commands to
+  query signal info or cell location.
+
+* New Intel Firmware Update Service support, that includes commands to request
+  the Intel-based module to reboot in firmware download mode.
+
+* libmbim-glib:
+  ** Added MBIM_STATUS_ERROR_CONTEXT_NOT_SUPPORTED to MbimStatusError.
+  ** Avoid using iconv() directly for the UTF-16BE conversions, which makes it
+     possible to use libmbim on systems with a stub iconv() implementation.
+  ** Added support to detect already open MBIM channels on the Sierra Wireless
+     EM7345.
+
+* mbimcli:
+  ** New '--query-ip-packet-filters' action.
+  ** New '--query-pin-list' action.
+  ** New '--atds-query-signal' and '--atds-query-location' actions.
+  ** New '--intel-modem-reboot' action.
+
+* Several other minor improvements and fixes.
+
+The following features which were backported to 1.14.x releases are also present
+in libmbim 1.16.0:
+
+* libmbim-glib:
+  ** Prefer realpath() to canonicalize_file_name().
+  ** Added MBIM_READY_INFO_FLAG_NONE to MbimReadyInfoFlag.
+
+* mbim-proxy:
+  ** Avoid receiving signals from the parent process.
+
+* mbimcli:
+  ** Add cancellability to the query-ip-configuration action.
+
 Overview of changes in libmbim 1.14
 ----------------------------------------
 
diff --git a/configure.ac b/configure.ac
index c61f67b..f2aa35d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@
 
 dnl The libmbim version number
 m4_define([mbim_major_version], [1])
-m4_define([mbim_minor_version], [15])
+m4_define([mbim_minor_version], [17])
 m4_define([mbim_micro_version], [0])
 m4_define([mbim_version],
           [mbim_major_version.mbim_minor_version.mbim_micro_version])
@@ -16,9 +16,9 @@
 dnl            with old code), increment a.
 dnl        If the interface has changed in an incompatible way (that is,
 dnl            functions have changed or been removed), then zero a.
-m4_define([mbim_glib_lt_current],  [6])
+m4_define([mbim_glib_lt_current],  [7])
 m4_define([mbim_glib_lt_revision], [0])
-m4_define([mbim_glib_lt_age],      [2])
+m4_define([mbim_glib_lt_age],      [3])
 
 
 AC_INIT([libmbim], [mbim_version], [libmbim-devel@lists.freedesktop.org])
diff --git a/docs/reference/libmbim-glib/libmbim-glib-docs.xml b/docs/reference/libmbim-glib/libmbim-glib-docs.xml
index 30c489e..08d79be 100644
--- a/docs/reference/libmbim-glib/libmbim-glib-docs.xml
+++ b/docs/reference/libmbim-glib/libmbim-glib-docs.xml
@@ -16,6 +16,7 @@
       <year>2015</year>
       <year>2016</year>
       <year>2017</year>
+      <year>2018</year>
       <holder>The libmbim-glib authors</holder>
     </copyright>
 
diff --git a/src/mbim-proxy/mbim-proxy.c b/src/mbim-proxy/mbim-proxy.c
index 46f023e..d2cd77f 100644
--- a/src/mbim-proxy/mbim-proxy.c
+++ b/src/mbim-proxy/mbim-proxy.c
@@ -125,8 +125,8 @@
 {
     g_print ("\n"
              PROGRAM_NAME " " PROGRAM_VERSION "\n"
-             "Copyright (C) 2013 Aleksander Morgado\n"
-             "Copyright (C) 2014 Greg Suarez\n"
+             "Copyright (C) 2013-2018 Aleksander Morgado\n"
+             "Copyright (C) 2014-2018 Greg Suarez\n"
              "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\n"
              "This is free software: you are free to change and redistribute it.\n"
              "There is NO WARRANTY, to the extent permitted by law.\n"
diff --git a/src/mbimcli/mbimcli-basic-connect.c b/src/mbimcli/mbimcli-basic-connect.c
index b27e179..3b0d5ef 100644
--- a/src/mbimcli/mbimcli-basic-connect.c
+++ b/src/mbimcli/mbimcli-basic-connect.c
@@ -181,7 +181,7 @@
       "[SessionID]"
     },
     { "connect", 0, 0, G_OPTION_ARG_STRING, &set_connect_activate_str,
-      "Connect (allowed keys: session-id, apn, auth (PAP|CHAP|MSCHAPV2), username, password)",
+      "Connect (allowed keys: session-id, apn, ip-type (ipv4|ipv6|ipv4v6), auth (PAP|CHAP|MSCHAPV2), username, password)",
       "[\"key=value,...\"]"
     },
     { "query-ip-configuration", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, G_CALLBACK (query_ip_configuration_arg_parse),
@@ -1055,6 +1055,24 @@
 }
 
 static gboolean
+mbim_context_ip_type_from_string (const gchar       *str,
+                                  MbimContextIpType *ip_type)
+{
+    if (g_ascii_strcasecmp (str, "ipv4") == 0) {
+        *ip_type = MBIM_CONTEXT_IP_TYPE_IPV4;
+        return TRUE;
+    } else if (g_ascii_strcasecmp (str, "ipv6") == 0) {
+        *ip_type = MBIM_CONTEXT_IP_TYPE_IPV6;
+        return TRUE;
+    } else if (g_ascii_strcasecmp (str, "ipv4v6") == 0) {
+        *ip_type = MBIM_CONTEXT_IP_TYPE_IPV4V6;
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+static gboolean
 connect_session_id_parse (const gchar  *str,
                           gboolean      allow_empty,
                           guint32      *session_id,
@@ -1094,11 +1112,12 @@
 }
 
 typedef struct {
-    guint32           session_id;
-    gchar            *apn;
-    MbimAuthProtocol  auth_protocol;
-    gchar            *username;
-    gchar            *password;
+    guint32            session_id;
+    gchar             *apn;
+    MbimAuthProtocol   auth_protocol;
+    gchar             *username;
+    gchar             *password;
+    MbimContextIpType  ip_type;
 } ConnectActivateProperties;
 
 static gboolean connect_activate_properties_handle (const gchar  *key,
@@ -1136,6 +1155,15 @@
         props->username = g_strdup (value);
     } else if (g_ascii_strcasecmp (key, "password") == 0 && !props->password) {
         props->password = g_strdup (value);
+    } else if (g_ascii_strcasecmp (key, "ip-type") == 0) {
+        if (!mbim_context_ip_type_from_string (value, &props->ip_type)) {
+            g_set_error (error,
+                         MBIM_CORE_ERROR,
+                         MBIM_CORE_ERROR_FAILED,
+                         "unknown ip type '%s'",
+                         value);
+            return FALSE;
+        }
     } else {
             g_set_error (error,
                          MBIM_CORE_ERROR,
@@ -1149,19 +1177,21 @@
 }
 
 static gboolean
-set_connect_activate_parse (const gchar       *str,
-                            guint32           *session_id,
-                            gchar            **apn,
-                            MbimAuthProtocol  *auth_protocol,
-                            gchar            **username,
-                            gchar            **password)
+set_connect_activate_parse (const gchar        *str,
+                            guint32            *session_id,
+                            gchar             **apn,
+                            MbimAuthProtocol   *auth_protocol,
+                            gchar             **username,
+                            gchar             **password,
+                            MbimContextIpType  *ip_type)
 {
     ConnectActivateProperties props = {
         .session_id    = 0,
         .apn           = NULL,
         .auth_protocol = MBIM_AUTH_PROTOCOL_NONE,
         .username      = NULL,
-        .password      = NULL
+        .password      = NULL,
+        .ip_type       = MBIM_CONTEXT_IP_TYPE_DEFAULT
     };
     gchar **split = NULL;
 
@@ -1170,6 +1200,7 @@
     g_assert (auth_protocol != NULL);
     g_assert (username != NULL);
     g_assert (password != NULL);
+    g_assert (ip_type != NULL);
 
     if (strchr (str, '=')) {
         GError *error = NULL;
@@ -1231,6 +1262,7 @@
     *auth_protocol = props.auth_protocol;
     *username = props.username;
     *password = props.password;
+    *ip_type = props.ip_type;
 
     if (split)
         g_strfreev (split);
@@ -2139,13 +2171,15 @@
         MbimAuthProtocol auth_protocol;
         gchar *username = NULL;
         gchar *password = NULL;
+        MbimContextIpType ip_type = MBIM_CONTEXT_IP_TYPE_DEFAULT;
 
         if (!set_connect_activate_parse (set_connect_activate_str,
                                          &session_id,
                                          &apn,
                                          &auth_protocol,
                                          &username,
-                                         &password)) {
+                                         &password,
+                                         &ip_type)) {
             shutdown (FALSE);
             return;
         }
@@ -2157,7 +2191,7 @@
                                                 password,
                                                 MBIM_COMPRESSION_NONE,
                                                 auth_protocol,
-                                                MBIM_CONTEXT_IP_TYPE_DEFAULT,
+                                                ip_type,
                                                 mbim_uuid_from_context_type (MBIM_CONTEXT_TYPE_INTERNET),
                                                 &error);
         g_free (apn);
diff --git a/src/mbimcli/mbimcli.c b/src/mbimcli/mbimcli.c
index c97c6dd..7ee1716 100644
--- a/src/mbimcli/mbimcli.c
+++ b/src/mbimcli/mbimcli.c
@@ -172,7 +172,7 @@
 {
     g_print ("\n"
              PROGRAM_NAME " " PROGRAM_VERSION "\n"
-             "Copyright (2013-2014) Aleksander Morgado\n"
+             "Copyright (C) 2013-2018 Aleksander Morgado\n"
              "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\n"
              "This is free software: you are free to change and redistribute it.\n"
              "There is NO WARRANTY, to the extent permitted by law.\n"
diff --git a/utils/mbim-network.in b/utils/mbim-network.in
index f4b0ffb..cb8db19 100755
--- a/utils/mbim-network.in
+++ b/utils/mbim-network.in
@@ -79,7 +79,7 @@
 version ()
 {
     echo "mbim-network @VERSION@"
-    echo "Copyright (2013-2015) Aleksander Morgado"
+    echo "Copyright (C) 2013-2018 Aleksander Morgado"
     echo "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>"
     echo "This is free software: you are free to change and redistribute it."
     echo "There is NO WARRANTY, to the extent permitted by law."