From: Giacinto Cifelli <gciofono@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 5/6] atmodem/lte: proto and authentication handling
Date: Wed, 10 Oct 2018 08:54:52 +0200 [thread overview]
Message-ID: <20181010065454.15232-4-gciofono@gmail.com> (raw)
In-Reply-To: <20181010065454.15232-1-gciofono@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3858 bytes --]
---
drivers/atmodem/lte.c | 79 +++++++++++++++++++++++++++----------------
1 file changed, 50 insertions(+), 29 deletions(-)
diff --git a/drivers/atmodem/lte.c b/drivers/atmodem/lte.c
index efa4e5fe..1d097c68 100644
--- a/drivers/atmodem/lte.c
+++ b/drivers/atmodem/lte.c
@@ -3,6 +3,7 @@
* oFono - Open Source Telephony
*
* Copyright (C) 2017 Intel Corporation. All rights reserved.
+ * Copyright (C) 2018 Gemalto M2M
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -45,48 +46,67 @@ struct lte_driver_data {
GAtChat *chat;
};
-static void at_lte_set_default_attach_info_cb(gboolean ok, GAtResult *result,
- gpointer user_data)
+static void at_set_reg_info(const struct ofono_lte *lte,
+ const struct ofono_lte_default_attach_info *info)
{
- struct cb_data *cbd = user_data;
- ofono_lte_cb_t cb = cbd->cb;
- struct ofono_error error;
+ struct lte_driver_data *ldd = ofono_lte_get_data(lte);
+ char buf_cgdcont[32 + OFONO_GPRS_MAX_APN_LENGTH +1];
+ char buf_cgauth[32 + OFONO_GPRS_MAX_USERNAME_LENGTH +
+ OFONO_GPRS_MAX_PASSWORD_LENGTH +1];
+ guint buflen = sizeof(buf_cgauth);
+ enum ofono_gprs_auth_method auth_method;
- DBG("ok %d", ok);
+ if (strlen(info->apn) > 0)
+ snprintf(buf_cgdcont, sizeof(buf_cgdcont),
+ "AT+CGDCONT=0,\"IP\",\"%s\"", info->apn);
+ else
+ snprintf(buf_cgdcont, sizeof(buf_cgdcont),
+ "AT+CGDCONT=0,\"IP\"");
- decode_at_error(&error, g_at_result_final_response(result));
- cb(&error, cbd->data);
+ if (g_at_chat_send(ldd->chat, buf_cgdcont, NULL, NULL, NULL, NULL) == 0)
+ return;
+
+ snprintf(buf_cgauth, buflen, "AT+CGAUTH=0,");
+ buflen -= strlen(buf_cgauth);
+
+ auth_method = info->auth_method;
+
+ /*
+ * change the authentication method if the parameters are invalid
+ * for behavior compatibility
+ */
+ if(!*info->username || !*info->password)
+ auth_method = OFONO_GPRS_AUTH_METHOD_NONE;
+
+ switch(auth_method) {
+ case OFONO_GPRS_AUTH_METHOD_PAP:
+ snprintf(buf_cgauth+strlen(buf_cgauth),
+ buflen, "1,\"%s\",\"%s\"",
+ info->username, info->password);
+ break;
+ case OFONO_GPRS_AUTH_METHOD_CHAP:
+ snprintf(buf_cgauth+strlen(buf_cgauth),
+ buflen, "2,\"%s\",\"%s\"",
+ info->username, info->password);
+ break;
+ case OFONO_GPRS_AUTH_METHOD_NONE:
+ snprintf(buf_cgauth+strlen(buf_cgauth), buflen, "0");
+ break;
+ }
+
+ g_at_chat_send(ldd->chat, buf_cgauth, NULL, NULL, NULL, NULL);
}
static void at_lte_set_default_attach_info(const struct ofono_lte *lte,
const struct ofono_lte_default_attach_info *info,
ofono_lte_cb_t cb, void *data)
{
- struct lte_driver_data *ldd = ofono_lte_get_data(lte);
- char buf[32 + OFONO_GPRS_MAX_APN_LENGTH + 1];
- struct cb_data *cbd = cb_data_new(cb, data);
-
- DBG("LTE config with APN: %s", info->apn);
-
- if (strlen(info->apn) > 0)
- snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\",\"%s\"",
- info->apn);
- else
- snprintf(buf, sizeof(buf), "AT+CGDCONT=0,\"IP\"");
-
- /* We can't do much in case of failure so don't check response. */
- if (g_at_chat_send(ldd->chat, buf, NULL,
- at_lte_set_default_attach_info_cb, cbd, g_free) > 0)
- return;
-
- CALLBACK_WITH_FAILURE(cb, data);
+ CALLBACK_WITH_SUCCESS(cb, data);
}
static gboolean lte_delayed_register(gpointer user_data)
{
- struct ofono_lte *lte = user_data;
-
- ofono_lte_register(lte);
+ ofono_lte_register(user_data);
return FALSE;
}
@@ -129,6 +149,7 @@ static struct ofono_lte_driver driver = {
.probe = at_lte_probe,
.remove = at_lte_remove,
.set_default_attach_info = at_lte_set_default_attach_info,
+ .set_reg_info = at_set_reg_info,
};
void at_lte_init(void)
--
2.17.1
next prev parent reply other threads:[~2018-10-10 6:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-10 6:54 [PATCH 1/6] lte-api: protocol and authentication properties Giacinto Cifelli
2018-10-10 6:54 ` [PATCH 2/6] lte.h: added proto and authentication handling Giacinto Cifelli
2018-10-10 6:54 ` [PATCH 3/6] src/lte: " Giacinto Cifelli
2018-10-11 20:07 ` Jonas Bonn
2018-10-12 2:57 ` Giacinto Cifelli
2018-10-12 3:43 ` Denis Kenzior
2018-10-12 6:36 ` Giacinto Cifelli
2018-10-12 17:47 ` Denis Kenzior
2018-10-10 6:54 ` Giacinto Cifelli [this message]
2018-10-11 19:51 ` [PATCH 5/6] atmodem/lte: " Jonas Bonn
2018-10-12 2:54 ` Giacinto Cifelli
2018-10-12 3:56 ` Denis Kenzior
2018-10-12 4:56 ` Giacinto Cifelli
2018-10-10 6:54 ` [PATCH 4/6] src/modem: notify lte driver before going online Giacinto Cifelli
2018-10-11 20:19 ` Jonas Bonn
2018-10-12 3:04 ` Giacinto Cifelli
2018-10-12 6:17 ` Jonas Bonn
2018-10-12 6:19 ` Giacinto Cifelli
2018-10-10 6:54 ` [PATCH 6/6] Gemalto contributors Giacinto Cifelli
2018-10-12 4:10 ` Denis Kenzior
2018-10-12 4:15 ` Giacinto Cifelli
2018-10-11 19:07 ` [PATCH 1/6] lte-api: protocol and authentication properties Jonas Bonn
2018-10-12 2:41 ` Giacinto Cifelli
2018-10-12 4:06 ` Denis Kenzior
2018-10-12 4:13 ` Giacinto Cifelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181010065454.15232-4-gciofono@gmail.com \
--to=gciofono@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox