uqmid: add support to set username, password for PDN
authorAlexander Couzens <[email protected]>
Tue, 13 Aug 2024 11:09:20 +0000 (13:09 +0200)
committerDavid Bauer <[email protected]>
Sat, 31 May 2025 20:41:00 +0000 (22:41 +0200)
Some APNs require to set a username, password in the wds profile.

Signed-off-by: Alexander Couzens <[email protected]>
uqmid/examples/1_add.sh [changed mode: 0644->0755]
uqmid/examples/2_configure.sh [changed mode: 0644->0755]
uqmid/examples/3_remove.sh [changed mode: 0644->0755]
uqmid/examples/x_dump.sh [changed mode: 0644->0755]
uqmid/modem.h
uqmid/modem_fsm.c
uqmid/modem_tx.c
uqmid/modem_tx.h
uqmid/ubus.c

old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 75079de..ab2b948
@@ -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"
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index fa4a827a9f91470b4374019703a178c344eb5543..144f9614f2604bbf4c290754a1712249ac5c50fe 100644 (file)
@@ -34,6 +34,8 @@
 struct modem_config {
        bool configured;
        char *apn;
+       char *username;
+       char *password;
        char *pin;
        bool roaming;
        uint8_t pdp_type;
index bc88311b3ac77d7dbd1915d16146589874176cf1..81343560975be262d30cb19d9b5b38679e84c2e2 100644 (file)
@@ -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:
index edec7b95665c800233a0128f7c132b1d2150a74e..0e405f8e1966187ed1bac7b88bd4c98ba8dac196 100644 (file)
@@ -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) {
index 4f58e14f95c8f54cfdc1dc3738c2d0e6272e4572..9302a65eb32f4a4b944a7864f523b508add9f9bc 100644 (file)
@@ -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);
index 6a69579525b66ed8a9d8cde53b8bd99cdbf7cecc..a1775869707ef2531b68140c225625a2b52e741f 100644 (file)
@@ -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;