diff mbox series

[3/6] qmi: lte: Support additional attributes

Message ID 20240429155726.51479-3-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 901835d0f2650451473c5f3ae3b58fd350faa35b
Headers show
Series [1/6] qmi: lte: Remove magic number use | expand

Commit Message

Denis Kenzior April 29, 2024, 3:56 p.m. UTC
Add support for setting APN Type (IPV4, IPV6 or Dual), Username and
Password attributes of the profile used for the default bearer.
---
 drivers/qmimodem/lte.c | 21 +++++++++++++++++----
 drivers/qmimodem/wds.c | 14 ++++++++++++++
 drivers/qmimodem/wds.h |  1 +
 3 files changed, 32 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/qmimodem/lte.c b/drivers/qmimodem/lte.c
index 7633572b39ef..70efaf04c8f5 100644
--- a/drivers/qmimodem/lte.c
+++ b/drivers/qmimodem/lte.c
@@ -66,6 +66,10 @@  static void qmimodem_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)
 {
+	static const uint8_t PARAM_PDP_TYPE = 0x11;
+	static const uint8_t PARAM_USERNAME = 0x1B;
+	static const uint8_t PARAM_PASSWORD = 0x1C;
+	static const uint8_t PARAM_AUTHENTICATION_PREFERENCE = 0x1D;
 	struct lte_data *ldd = ofono_lte_get_data(lte);
 	struct cb_data *cbd = cb_data_new(cb, data);
 	struct qmi_param* param;
@@ -76,19 +80,28 @@  static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
 		.type = QMI_WDS_PROFILE_TYPE_3GPP,
 		.index = ldd->default_profile,
 	};
+	uint8_t auth = qmi_wds_auth_from_ofono(info->auth_method);
 
 	DBG("");
 
 	param = qmi_param_new();
 
-	/* Profile selector */
 	qmi_param_append(param, QMI_WDS_PARAM_PROFILE_TYPE, sizeof(p), &p);
-
-	/* WDS APN Name */
+	qmi_param_append_uint8(param, PARAM_PDP_TYPE,
+				qmi_wds_pdp_type_from_ofono(info->proto));
 	qmi_param_append(param, QMI_WDS_PARAM_APN,
 				strlen(info->apn), info->apn);
 
-	/* Modify profile */
+	qmi_param_append_uint8(param, PARAM_AUTHENTICATION_PREFERENCE, auth);
+
+	if (auth && info->username[0])
+		qmi_param_append(param, PARAM_USERNAME,
+					strlen(info->username), info->username);
+
+	if (auth && info->password[0])
+		qmi_param_append(param, PARAM_PASSWORD,
+					strlen(info->password), info->password);
+
 	if (qmi_service_send(ldd->wds, QMI_WDS_MODIFY_PROFILE, param,
 					modify_profile_cb, cbd, l_free) > 0)
 		return;
diff --git a/drivers/qmimodem/wds.c b/drivers/qmimodem/wds.c
index 748ad867c2cc..d126f4712921 100644
--- a/drivers/qmimodem/wds.c
+++ b/drivers/qmimodem/wds.c
@@ -23,3 +23,17 @@  int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method)
 
 	return -ENOENT;
 }
+
+int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto)
+{
+	switch (proto) {
+	case OFONO_GPRS_PROTO_IP:
+		return QMI_WDS_PDP_TYPE_IPV4;
+	case OFONO_GPRS_PROTO_IPV6:
+		return QMI_WDS_PDP_TYPE_IPV6;
+	case OFONO_GPRS_PROTO_IPV4V6:
+		return QMI_WDS_PDP_TYPE_IPV4V6;
+	}
+
+	return -ENOENT;
+}
diff --git a/drivers/qmimodem/wds.h b/drivers/qmimodem/wds.h
index c8aeefe430bb..d896fd8cc535 100644
--- a/drivers/qmimodem/wds.h
+++ b/drivers/qmimodem/wds.h
@@ -110,3 +110,4 @@  enum qmi_wds_command {
 };
 
 int qmi_wds_auth_from_ofono(enum ofono_gprs_auth_method method);
+int qmi_wds_pdp_type_from_ofono(enum ofono_gprs_proto proto);