Discussion:
[PATCH 3/5] src/gprs: support for NONE auth
Denis Kenzior
2018-10-09 17:37:18 UTC
Permalink
Hi Giacinto,
---
src/gprs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/gprs.c b/src/gprs.c
index 79fafdbc..235c8884 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -261,6 +261,10 @@ static const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth)
return "chap";
return "pap";
+ return "none";
+ return NULL;
I dropped this default statement for reasons outlined in our earlier
discussions.
};
return NULL;
@@ -275,6 +279,9 @@ static gboolean gprs_auth_method_from_string(const char *str,
} else if (g_str_equal(str, "pap")) {
*auth = OFONO_GPRS_AUTH_METHOD_PAP;
return TRUE;
+ } else if (g_str_equal(str, "none")) {
+ *auth = OFONO_GPRS_AUTH_METHOD_NONE;
+ return TRUE;
}
return FALSE;
Regards,
-Denis
Denis Kenzior
2018-10-09 17:37:39 UTC
Permalink
Hi Giacinto,
---
doc/connman-api.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Patch 1 & 2 applied, thanks.

Regards,
-Denis
Denis Kenzior
2018-10-09 17:38:31 UTC
Permalink
Hi Giacinto,
the default authentication method is set to NONE
the default method remains CHAP, but it is overridden by NONE after
parsing the entire key for the apn and detecting no username/password
---
plugins/file-provision.c | 7 +++++--
plugins/mbpi.c | 6 ++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/plugins/file-provision.c b/plugins/file-provision.c
index d4846a65..3a1a5a68 100644
--- a/plugins/file-provision.c
+++ b/plugins/file-provision.c
@@ -93,18 +93,21 @@ static int config_file_provision_get_settings(const char *mcc,
if (value != NULL)
(*settings)[0].password = value;
- (*settings)[0].auth_method = OFONO_GPRS_AUTH_METHOD_CHAP;
+ /* select default authentication method */
+ (*settings)[0].auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
+
value = g_key_file_get_string(key_file, setting_group,
"internet.AuthenticationMethod", NULL);
if (value != NULL) {
+
This part was dropped
if (g_strcmp0(value, "chap") == 0)
(*settings)[0].auth_method =
OFONO_GPRS_AUTH_METHOD_CHAP;
else if (g_strcmp0(value, "pap") == 0)
(*settings)[0].auth_method =
OFONO_GPRS_AUTH_METHOD_PAP;
- else
+ else if (g_strcmp0(value, "none") != 0)
DBG("Unknown auth method: %s", value);
g_free(value);
diff --git a/plugins/mbpi.c b/plugins/mbpi.c
index ae92c762..433f1b55 100644
--- a/plugins/mbpi.c
+++ b/plugins/mbpi.c
@@ -325,6 +325,8 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
ap->apn = g_strdup(apn);
ap->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET;
ap->proto = OFONO_GPRS_PROTO_IP;
+
+ /* pre-select default authentication method */
ap->auth_method = OFONO_GPRS_AUTH_METHOD_CHAP;
g_markup_parse_context_push(context, &apn_parser, ap);
@@ -395,6 +397,10 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
if (ap == NULL)
return;
+ /* select authentication method NONE if fit */
+ if (!ap->username || !ap->password)
+ ap->auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
+
if (gsm->allow_duplicates == FALSE) {
GSList *l;
Regards,
-Denis
Denis Kenzior
2018-10-09 17:41:48 UTC
Permalink
Hi Giacinto,
diff --git a/drivers/mbimmodem/gprs-context.c b/drivers/mbimmodem/gprs-context.c
index 79793c92..be256e43 100644
--- a/drivers/mbimmodem/gprs-context.c
+++ b/drivers/mbimmodem/gprs-context.c
@@ -75,9 +75,11 @@ static uint32_t auth_method_to_auth_protocol(enum ofono_gprs_auth_method method)
return 2; /* MBIMAuthProtocolChap */
return 1; /* MBIMAuthProtocolPap */
+ return 0; /* MBIMAUthProtocolNone */
}
- return 0;
+ return 0; /* MBIMAUthProtocolNone */
}
static void mbim_deactivate_cb(struct mbim_message *message, void *user)
@@ -345,6 +347,8 @@ static void mbim_gprs_activate_primary(struct ofono_gprs_context *gc,
{
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
struct mbim_message *message;
+ const char username = NULL;
+ const char password = NULL;
These were changed to const char *
DBG("cid %u", ctx->cid);
@@ -354,6 +358,12 @@ static void mbim_gprs_activate_primary(struct ofono_gprs_context *gc,
gcd->active_context = ctx->cid;
gcd->proto = ctx->proto;
+ if (ctx->auth_method != OFONO_GPRS_AUTH_METHOD_NONE && ctx->username[0])
+ username = ctx->username;
+
+ if (ctx->auth_method != OFONO_GPRS_AUTH_METHOD_NONE && ctx->password[0])
+ password = ctx->password;
+
message = mbim_message_new(mbim_uuid_basic_connect,
MBIM_CID_CONNECT,
MBIM_COMMAND_TYPE_SET);
@@ -361,8 +371,8 @@ static void mbim_gprs_activate_primary(struct ofono_gprs_context *gc,
ctx->cid,
1, /* MBIMActivationCommandActivate */
ctx->apn,
- ctx->username[0] ? ctx->username : NULL,
- ctx->password[0] ? ctx->password : NULL,
+ username,
+ password,
0, /*MBIMCompressionNone */
auth_method_to_auth_protocol(ctx->auth_method),
proto_to_context_ip_type(ctx->proto),
diff --git a/drivers/mbmmodem/gprs-context.c b/drivers/mbmmodem/gprs-context.c
index e961afa1..fa8b44b6 100644
--- a/drivers/mbmmodem/gprs-context.c
+++ b/drivers/mbmmodem/gprs-context.c
@@ -394,11 +394,12 @@ static void mbm_gprs_activate_primary(struct ofono_gprs_context *gc,
* Set username and password, this should be done after CGDCONT
* or an error can occur. We don't bother with error checking
* here
- * */
- snprintf(buf, sizeof(buf), "AT*EIAAUW=%d,1,\"%s\",\"%s\"",
- ctx->cid, ctx->username, ctx->password);
-
- g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ */
+ if (ctx->auth_method != OFONO_GPRS_AUTH_METHOD_NONE) {
+ snprintf(buf, sizeof(buf), "AT*EIAAUW=%d,1,\"%s\",\"%s\"",
+ ctx->cid, ctx->username, ctx->password);
+ g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ }
return;
I dropped this part entirely. The reason is that we can have profiles
with username/password & without operating on the same CID. Since the
setting is permanent on the modem, we need to set it/clear it even when
AUTH_METHOD_NONE is used.

If you disagree, please send a follow up series.
diff --git a/drivers/stemodem/gprs-context.c b/drivers/stemodem/gprs-context.c
index 18b2bfa4..32facd8c 100644
--- a/drivers/stemodem/gprs-context.c
+++ b/drivers/stemodem/gprs-context.c
@@ -307,10 +307,11 @@ static void ste_gprs_activate_primary(struct ofono_gprs_context *gc,
* or an error can occur. We don't bother with error checking
* here
*/
- snprintf(buf, sizeof(buf), "AT*EIAAUW=%d,1,\"%s\",\"%s\"",
- ctx->cid, ctx->username, ctx->password);
-
- g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ if (ctx->auth_method != OFONO_GPRS_AUTH_METHOD_NONE) {
+ snprintf(buf, sizeof(buf), "AT*EIAAUW=%d,1,\"%s\",\"%s\"",
+ ctx->cid, ctx->username, ctx->password);
+ g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
+ }
return;
Dropped for the same reason as above

Regards,
-Denis

Loading...