summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens2024-08-13 11:09:20 +0000
committerDavid Bauer2025-05-31 20:41:00 +0000
commit6edff78b2bc3e96eaf783e7609d2cfcaef502648 (patch)
treeaa9bc4e44f7021c1f861f0c13b99ed9f1836977c
parent89033fe2eeaa1313a5de11946c8d8ec3bb83348d (diff)
downloaduqmi-6edff78b2bc3e96eaf783e7609d2cfcaef502648.tar.gz
uqmid: add support to set username, password for PDN
Some APNs require to set a username, password in the wds profile. Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
-rwxr-xr-x[-rw-r--r--]uqmid/examples/1_add.sh0
-rwxr-xr-x[-rw-r--r--]uqmid/examples/2_configure.sh2
-rwxr-xr-x[-rw-r--r--]uqmid/examples/3_remove.sh0
-rwxr-xr-x[-rw-r--r--]uqmid/examples/x_dump.sh0
-rw-r--r--uqmid/modem.h2
-rw-r--r--uqmid/modem_fsm.c3
-rw-r--r--uqmid/modem_tx.c8
-rw-r--r--uqmid/modem_tx.h2
-rw-r--r--uqmid/ubus.c18
9 files changed, 29 insertions, 6 deletions
diff --git a/uqmid/examples/1_add.sh b/uqmid/examples/1_add.sh
index e4e52f7..e4e52f7 100644..100755
--- a/uqmid/examples/1_add.sh
+++ b/uqmid/examples/1_add.sh
diff --git a/uqmid/examples/2_configure.sh b/uqmid/examples/2_configure.sh
index 75079de..ab2b948 100644..100755
--- a/uqmid/examples/2_configure.sh
+++ b/uqmid/examples/2_configure.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-CONFIG='{"apn":"internet.telekom","roaming":"true"}'
+CONFIG='{"apn":"internet.telekom","roaming":"true", "username": "telekom", "password": "tm"}'
ubus call uqmid.modem.modem1 configure "$CONFIG"
diff --git a/uqmid/examples/3_remove.sh b/uqmid/examples/3_remove.sh
index 3735f4f..3735f4f 100644..100755
--- a/uqmid/examples/3_remove.sh
+++ b/uqmid/examples/3_remove.sh
diff --git a/uqmid/examples/x_dump.sh b/uqmid/examples/x_dump.sh
index b8d44c8..b8d44c8 100644..100755
--- a/uqmid/examples/x_dump.sh
+++ b/uqmid/examples/x_dump.sh
diff --git a/uqmid/modem.h b/uqmid/modem.h
index fa4a827..144f961 100644
--- a/uqmid/modem.h
+++ b/uqmid/modem.h
@@ -34,6 +34,8 @@
struct modem_config {
bool configured;
char *apn;
+ char *username;
+ char *password;
char *pin;
bool roaming;
uint8_t pdp_type;
diff --git a/uqmid/modem_fsm.c b/uqmid/modem_fsm.c
index bc88311..8134356 100644
--- a/uqmid/modem_fsm.c
+++ b/uqmid/modem_fsm.c
@@ -721,7 +721,8 @@ static void modem_st_configure_modem(struct osmo_fsm_inst *fi, uint32_t event, v
/* failed to get profile list/generate a new profile */
} else {
tx_wds_modify_profile(modem, wds, wds_modify_profile_cb, modem->qmi->wds.profile_id,
- modem->config.apn, modem->config.pdp_type);
+ modem->config.apn, modem->config.pdp_type, modem->config.username,
+ modem->config.password);
}
break;
case MODEM_EV_RX_MODIFIED_PROFILE:
diff --git a/uqmid/modem_tx.c b/uqmid/modem_tx.c
index edec7b9..0e405f8 100644
--- a/uqmid/modem_tx.c
+++ b/uqmid/modem_tx.c
@@ -129,7 +129,7 @@ int tx_wds_get_profile_list(struct modem *modem, struct qmi_service *wds, reques
}
int tx_wds_modify_profile(struct modem *modem, struct qmi_service *wds, request_cb cb, uint8_t profile, const char *apn,
- uint8_t pdp_type)
+ uint8_t pdp_type, const char *username, const char *password)
{
struct qmi_request *req = talloc_zero(wds, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
@@ -142,7 +142,11 @@ int tx_wds_modify_profile(struct modem *modem, struct qmi_service *wds, request_
qmi_set(&profile_req, pdp_type, pdp_type);
if (apn)
- profile_req.data.apn_name = (char *) apn;
+ profile_req.data.apn_name = (char *)apn;
+ if (username)
+ profile_req.data.username = (char *)username;
+ if (password)
+ profile_req.data.password = (char *)password;
int ret = qmi_set_wds_modify_profile_request(msg, &profile_req);
if (ret) {
diff --git a/uqmid/modem_tx.h b/uqmid/modem_tx.h
index 4f58e14..9302a65 100644
--- a/uqmid/modem_tx.h
+++ b/uqmid/modem_tx.h
@@ -13,7 +13,7 @@ int tx_nas_subscribe_nas_events(struct modem *modem, struct qmi_service *nas, bo
int tx_wda_set_data_format(struct modem *modem, struct qmi_service *wda, request_cb cb);
int tx_wds_get_profile_list(struct modem *modem, struct qmi_service *wds, request_cb cb);
int tx_wds_modify_profile(struct modem *modem, struct qmi_service *wds, request_cb cb, uint8_t profile, const char *apn,
- uint8_t pdp_type);
+ uint8_t pdp_type, const char *username, const char *password);
int tx_wds_start_network(struct modem *modem, struct qmi_service *wds, request_cb cb, uint8_t profile_idx,
uint8_t ip_family);
int tx_wds_get_current_settings(struct modem *modem, struct qmi_service *wds, request_cb cb);
diff --git a/uqmid/ubus.c b/uqmid/ubus.c
index 6a69579..a177586 100644
--- a/uqmid/ubus.c
+++ b/uqmid/ubus.c
@@ -233,13 +233,15 @@ static int modem_remove(struct ubus_context *ctx, struct ubus_object *obj, struc
return UBUS_STATUS_OK;
}
-enum { CFG_APN, CFG_PIN, CFG_ROAMING, __CFG_MAX };
+enum { CFG_APN, CFG_PIN, CFG_ROAMING, CFG_USERNAME, CFG_PASSWORD, __CFG_MAX };
/** ubus call modem_configure{apn: internet, pin: 2342, roaming: false}` */
static const struct blobmsg_policy modem_configure_policy[__CFG_MAX] = {
[CFG_APN] = { .name = "apn", .type = BLOBMSG_TYPE_STRING },
[CFG_PIN] = { .name = "pin", .type = BLOBMSG_TYPE_STRING },
[CFG_ROAMING] = { .name = "roaming", .type = BLOBMSG_TYPE_BOOL },
+ [CFG_USERNAME] = { .name = "username", .type = BLOBMSG_TYPE_STRING },
+ [CFG_PASSWORD] = { .name = "password", .type = BLOBMSG_TYPE_STRING },
};
static int modem_configure(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req,
@@ -271,6 +273,20 @@ static int modem_configure(struct ubus_context *ctx, struct ubus_object *obj, st
modem->config.roaming = blobmsg_get_bool(tb[CFG_ROAMING]);
}
+ if (tb[CFG_USERNAME]) {
+ TALLOC_FREE(modem->config.username);
+ value = blobmsg_get_string(tb[CFG_USERNAME]);
+ if (value && strlen(value))
+ modem->config.username = talloc_strdup(modem, blobmsg_get_string(tb[CFG_USERNAME]));
+ }
+
+ if (tb[CFG_PASSWORD]) {
+ TALLOC_FREE(modem->config.password);
+ value = blobmsg_get_string(tb[CFG_PASSWORD]);
+ if (value && strlen(value))
+ modem->config.password = talloc_strdup(modem, blobmsg_get_string(tb[CFG_PASSWORD]));
+ }
+
modem->config.pdp_type = QMI_WDS_PDP_TYPE_IPV4;
modem->config.configured = true;