* [PATCH v2 0/2] gemalto: gprs context driver updates
@ 2020-12-26 20:56 Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 1/2] gemalto: gprs: support automatic context activation Sergey Matyukevich
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sergey Matyukevich @ 2020-12-26 20:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 655 bytes --]
Hi Denis and all,
This is the second version of the patches updating gemalto gprs context
driver. Major changes include support for automatic context activation
and support for gprs context authentication settings.
Regards,
Sergey
v1 -> v2
- drop patches 1, 2, 4 that has been already applied
- add detailed comment on AT^SWWAN patch
- address review comments
Sergey Matyukevich (2):
gemalto: gprs: support automatic context activation
gemalto: gprs: support authentication settings
drivers/gemaltomodem/gprs-context.c | 155 ++++++++++++++++++++--------
1 file changed, 114 insertions(+), 41 deletions(-)
--
2.29.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] gemalto: gprs: support automatic context activation
2020-12-26 20:56 [PATCH v2 0/2] gemalto: gprs context driver updates Sergey Matyukevich
@ 2020-12-26 20:56 ` Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 2/2] gemalto: gprs: support authentication settings Sergey Matyukevich
2020-12-30 16:57 ` [PATCH v2 0/2] gemalto: gprs context driver updates Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Sergey Matyukevich @ 2020-12-26 20:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6926 bytes --]
Implement read_settings function to get configuration for automatic
contexts. AT^SWWAN command activates PDP context unless it has been
already activated automatically, and then starts DHCP server in the
ME. So AT^SWWAN command should be run for automatic context as well
in order to obtain IP settings from the ME.
This commit also fixes the issue uncovered by the added support for
automatic contexts: as per modem specs, AT+CGACT context should not
be reused for AT^SWWAN. Though that worked for some reason when
automatic context was reactivated without proper deactivation.
Note that in both cases success code is reported to the core before
AT^SWWAN response. This is because the ME waits until DHCP negotiation
has finished before sending the "OK" or "ERROR" result code.
---
drivers/gemaltomodem/gprs-context.c | 116 +++++++++++++++++-----------
1 file changed, 69 insertions(+), 47 deletions(-)
diff --git a/drivers/gemaltomodem/gprs-context.c b/drivers/gemaltomodem/gprs-context.c
index 13a858d4..99cb4114 100644
--- a/drivers/gemaltomodem/gprs-context.c
+++ b/drivers/gemaltomodem/gprs-context.c
@@ -51,70 +51,63 @@ struct gprs_context_data {
void *cb_data;
};
-static void cgact_enable_cb(gboolean ok, GAtResult *result,
- gpointer user_data)
+static void set_gprs_context_interface(struct ofono_gprs_context *gc)
{
- struct ofono_gprs_context *gc = user_data;
- struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
struct ofono_modem *modem;
const char *interface;
- char buf[64];
+
+ modem = ofono_gprs_context_get_modem(gc);
+ interface = ofono_modem_get_string(modem, "NetworkInterface");
+ ofono_gprs_context_set_interface(gc, interface);
+
+ /* Use DHCP */
+ ofono_gprs_context_set_ipv4_address(gc, NULL, 0);
+}
+
+static void swwan_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_gprs_context *gc = user_data;
+ struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ struct ofono_error error;
DBG("ok %d", ok);
if (!ok) {
- struct ofono_error error;
-
+ ofono_error("Unable to activate context");
+ ofono_gprs_context_deactivated(gc, gcd->active_context);
gcd->active_context = 0;
-
decode_at_error(&error, g_at_result_final_response(result));
gcd->cb(&error, gcd->cb_data);
-
return;
}
-
- snprintf(buf, sizeof(buf), "AT^SWWAN=1,%u", gcd->active_context);
- g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
-
- modem = ofono_gprs_context_get_modem(gc);
- interface = ofono_modem_get_string(modem, "NetworkInterface");
- ofono_gprs_context_set_interface(gc, interface);
-
- /* Use DHCP */
- ofono_gprs_context_set_ipv4_address(gc, NULL, 0);
-
- CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
}
static void cgdcont_enable_cb(gboolean ok, GAtResult *result,
- gpointer user_data)
+ gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ struct ofono_error error;
char buf[64];
DBG("ok %d", ok);
if (!ok) {
- struct ofono_error error;
-
gcd->active_context = 0;
-
decode_at_error(&error, g_at_result_final_response(result));
gcd->cb(&error, gcd->cb_data);
-
return;
}
- snprintf(buf, sizeof(buf), "AT+CGACT=1,%u", gcd->active_context);
+ snprintf(buf, sizeof(buf), "AT^SWWAN=1,%u", gcd->active_context);
- if (g_at_chat_send(gcd->chat, buf, none_prefix,
- cgact_enable_cb, gc, NULL) == 0)
- goto error;
+ if (g_at_chat_send(gcd->chat, buf, none_prefix, swwan_cb, gc, NULL)) {
+ set_gprs_context_interface(gc);
- return;
+ CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+ return;
+ }
-error:
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
}
@@ -152,31 +145,27 @@ static void gemalto_gprs_activate_primary(struct ofono_gprs_context *gc,
snprintf(buf + len, sizeof(buf) - len - 3, ",\"%s\"", ctx->apn);
if (g_at_chat_send(gcd->chat, buf, none_prefix,
- cgdcont_enable_cb, gc, NULL) > 0)
+ cgdcont_enable_cb, gc, NULL))
return;
CALLBACK_WITH_FAILURE(cb, data);
}
-static void cgact_disable_cb(gboolean ok, GAtResult *result,
- gpointer user_data)
+static void deactivate_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
- char buf[64];
DBG("ok %d", ok);
+ gcd->active_context = 0;
+
if (!ok) {
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
return;
}
- snprintf(buf, sizeof(buf), "AT^SWWAN=0,%u", gcd->active_context);
- g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL);
-
- gcd->active_context = 0;
-
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
}
@@ -193,17 +182,49 @@ static void gemalto_gprs_deactivate_primary(struct ofono_gprs_context *gc,
gcd->cb = cb;
gcd->cb_data = data;
- snprintf(buf, sizeof(buf), "AT+CGACT=0,%u", cid);
+ snprintf(buf, sizeof(buf), "AT^SWWAN=0,%u", gcd->active_context);
if (g_at_chat_send(gcd->chat, buf, none_prefix,
- cgact_disable_cb, gc, NULL) == 0)
- goto error;
-
- return;
+ deactivate_cb, gc, NULL))
+ return;
-error:
CALLBACK_WITH_FAILURE(cb, data);
+}
+static void gemalto_gprs_read_settings(struct ofono_gprs_context *gc,
+ unsigned int cid,
+ ofono_gprs_context_cb_t cb, void *data)
+{
+ struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ char buf[64];
+
+ DBG("cid %u", cid);
+
+ gcd->active_context = cid;
+ gcd->cb = cb;
+ gcd->cb_data = data;
+
+ /*
+ * AT^SWWAN command activates PDP context unless it has been already
+ * activated automatically, and then starts DHCP server in the ME.
+ * So AT^SWWAN command should be run in both cases:
+ * - when activate context and then obtain IP address from the ME
+ * - when obtain IP address from the automatically activated context
+ *
+ * Note that the ME waits until DHCP negotiation has finished before
+ * sending the "OK" or "ERROR" result code. So success is reported
+ * to the core before AT^SWWAN response.
+ */
+ snprintf(buf, sizeof(buf), "AT^SWWAN=1,%u", gcd->active_context);
+
+ if (g_at_chat_send(gcd->chat, buf, none_prefix, swwan_cb, gc, NULL)) {
+ set_gprs_context_interface(gc);
+
+ CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
+ return;
+ }
+
+ CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
}
static void cgev_notify(GAtResult *result, gpointer user_data)
@@ -275,6 +296,7 @@ static const struct ofono_gprs_context_driver driver = {
.remove = gemalto_gprs_context_remove,
.activate_primary = gemalto_gprs_activate_primary,
.deactivate_primary = gemalto_gprs_deactivate_primary,
+ .read_settings = gemalto_gprs_read_settings,
};
void gemalto_gprs_context_init(void)
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] gemalto: gprs: support authentication settings
2020-12-26 20:56 [PATCH v2 0/2] gemalto: gprs context driver updates Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 1/2] gemalto: gprs: support automatic context activation Sergey Matyukevich
@ 2020-12-26 20:56 ` Sergey Matyukevich
2020-12-30 16:57 ` [PATCH v2 0/2] gemalto: gprs context driver updates Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Sergey Matyukevich @ 2020-12-26 20:56 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2907 bytes --]
Add support for gprs contexts with username, password,
and specific authentication type.
---
drivers/gemaltomodem/gprs-context.c | 53 ++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/drivers/gemaltomodem/gprs-context.c b/drivers/gemaltomodem/gprs-context.c
index 99cb4114..c0837bed 100644
--- a/drivers/gemaltomodem/gprs-context.c
+++ b/drivers/gemaltomodem/gprs-context.c
@@ -46,6 +46,9 @@ static const char *none_prefix[] = { NULL };
struct gprs_context_data {
GAtChat *chat;
unsigned int active_context;
+ char username[OFONO_GPRS_MAX_USERNAME_LENGTH + 1];
+ char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
+ int auth_type;
enum ofono_gprs_proto proto;
ofono_gprs_context_cb_t cb;
void *cb_data;
@@ -82,7 +85,7 @@ static void swwan_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
}
-static void cgdcont_enable_cb(gboolean ok, GAtResult *result,
+static void sgauth_enable_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
@@ -111,6 +114,38 @@ static void cgdcont_enable_cb(gboolean ok, GAtResult *result,
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
}
+static void cgdcont_enable_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct ofono_gprs_context *gc = user_data;
+ struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+ struct ofono_error error;
+ char buf[384];
+
+ DBG("ok %d", ok);
+
+ if (!ok) {
+ gcd->active_context = 0;
+ decode_at_error(&error, g_at_result_final_response(result));
+ gcd->cb(&error, gcd->cb_data);
+ return;
+ }
+
+ if (gcd->username[0] && gcd->password[0])
+ sprintf(buf, "AT^SGAUTH=%u,%u,\"%s\",\"%s\"",
+ gcd->active_context, gcd->auth_type,
+ gcd->username, gcd->password);
+ else
+ sprintf(buf, "AT^SGAUTH=%u,%u,\"\",\"\"",
+ gcd->active_context, gcd->auth_type);
+
+ if (g_at_chat_send(gcd->chat, buf, none_prefix,
+ sgauth_enable_cb, gc, NULL) > 0)
+ return;
+
+ CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
+}
+
static void gemalto_gprs_activate_primary(struct ofono_gprs_context *gc,
const struct ofono_gprs_primary_context *ctx,
ofono_gprs_context_cb_t cb, void *data)
@@ -125,6 +160,22 @@ static void gemalto_gprs_activate_primary(struct ofono_gprs_context *gc,
gcd->cb_data = data;
gcd->cb = cb;
+ memcpy(gcd->username, ctx->username, sizeof(ctx->username));
+ memcpy(gcd->password, ctx->password, sizeof(ctx->password));
+ gcd->proto = ctx->proto;
+
+ switch (ctx->auth_method) {
+ case OFONO_GPRS_AUTH_METHOD_PAP:
+ gcd->auth_type = 1;
+ break;
+ case OFONO_GPRS_AUTH_METHOD_CHAP:
+ gcd->auth_type = 2;
+ break;
+ case OFONO_GPRS_AUTH_METHOD_NONE:
+ default:
+ gcd->auth_type = 0;
+ break;
+ }
switch (ctx->proto) {
case OFONO_GPRS_PROTO_IP:
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] gemalto: gprs context driver updates
2020-12-26 20:56 [PATCH v2 0/2] gemalto: gprs context driver updates Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 1/2] gemalto: gprs: support automatic context activation Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 2/2] gemalto: gprs: support authentication settings Sergey Matyukevich
@ 2020-12-30 16:57 ` Denis Kenzior
2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2020-12-30 16:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 796 bytes --]
Hi Sergey,
On 12/26/20 2:56 PM, Sergey Matyukevich wrote:
> Hi Denis and all,
>
> This is the second version of the patches updating gemalto gprs context
> driver. Major changes include support for automatic context activation
> and support for gprs context authentication settings.
>
> Regards,
> Sergey
>
> v1 -> v2
>
> - drop patches 1, 2, 4 that has been already applied
> - add detailed comment on AT^SWWAN patch
> - address review comments
>
>
> Sergey Matyukevich (2):
> gemalto: gprs: support automatic context activation
> gemalto: gprs: support authentication settings
>
> drivers/gemaltomodem/gprs-context.c | 155 ++++++++++++++++++++--------
> 1 file changed, 114 insertions(+), 41 deletions(-)
>
All applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-30 16:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-26 20:56 [PATCH v2 0/2] gemalto: gprs context driver updates Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 1/2] gemalto: gprs: support automatic context activation Sergey Matyukevich
2020-12-26 20:56 ` [PATCH v2 2/2] gemalto: gprs: support authentication settings Sergey Matyukevich
2020-12-30 16:57 ` [PATCH v2 0/2] gemalto: gprs context driver updates Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox