Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH] qmimodem: send authentication credentials
@ 2017-01-25 11:19 Piotr Haber
  2017-01-25 16:10 ` Denis Kenzior
  0 siblings, 1 reply; 5+ messages in thread
From: Piotr Haber @ 2017-01-25 11:19 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]

Pass authentication method, user and password
to QMI WDS service.
---
 drivers/qmimodem/gprs-context.c | 24 ++++++++++++++++++++++++
 drivers/qmimodem/wds.h          |  7 +++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/qmimodem/gprs-context.c b/drivers/qmimodem/gprs-context.c
index a39db5e8..2250eef9 100644
--- a/drivers/qmimodem/gprs-context.c
+++ b/drivers/qmimodem/gprs-context.c
@@ -151,6 +151,7 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,
 	struct cb_data *cbd = cb_data_new(cb, user_data);
 	struct qmi_param *param;
 	uint8_t ip_family;
+	uint8_t auth;
 
 	DBG("cid %u", ctx->cid);
 
@@ -178,6 +179,29 @@ static void qmi_activate_primary(struct ofono_gprs_context *gc,
 
 	qmi_param_append_uint8(param, QMI_WDS_PARAM_IP_FAMILY, ip_family);
 
+	switch (ctx->auth_method) {
+	case OFONO_GPRS_AUTH_METHOD_CHAP:
+		auth = QMI_WDS_AUTHENTICATION_CHAP;
+		break;
+	case OFONO_GPRS_AUTH_METHOD_PAP:
+		auth = QMI_WDS_AUTHENTICATION_PAP;
+		break;
+	default:
+		auth = QMI_WDS_AUTHENTICATION_NONE;
+		break;
+	}
+	qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE,
+					auth);
+
+	if (ctx->username && strlen(ctx->username)) {
+		qmi_param_append(param, QMI_WDS_PARAM_USERNAME,
+					strlen(ctx->username), ctx->username);
+        }
+
+	if (ctx->password && strlen(ctx->password))
+		qmi_param_append(param, QMI_WDS_PARAM_PASSWORD,
+					strlen(ctx->password), ctx->password);
+
 	if (qmi_service_send(data->wds, QMI_WDS_START_NET, param,
 					start_net_cb, cbd, NULL) > 0)
 		return;
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index 0da34ab9..4843f925 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -30,6 +30,13 @@
 /* Start WDS network interface */
 #define QMI_WDS_PARAM_APN			0x14	/* string */
 #define QMI_WDS_PARAM_IP_FAMILY			0x19	/* uint8 */
+#define QMI_WDS_PARAM_USERNAME			0x17	/* string */
+#define QMI_WDS_PARAM_PASSWORD			0x18	/* string */
+#define QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE	0x16	/* uint8 */
+
+#define QMI_WDS_AUTHENTICATION_NONE		0x0
+#define QMI_WDS_AUTHENTICATION_PAP		0x1
+#define QMI_WDS_AUTHENTICATION_CHAP		0x2
 
 #define QMI_WDS_RESULT_PKT_HANDLE		0x01	/* uint32 */
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-26 15:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 11:19 [PATCH] qmimodem: send authentication credentials Piotr Haber
2017-01-25 16:10 ` Denis Kenzior
2017-01-26  7:49   ` Piotr Haber
2017-01-26  7:57   ` [PATCH v2] " Piotr Haber
2017-01-26 15:21     ` Denis Kenzior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox