From patchwork Mon Sep 5 20:07:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Ginstmark X-Patchwork-Id: 1674437 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=bCqe/cZw; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=megamailservers.eu header.i=@megamailservers.eu header.a=rsa-sha256 header.s=maildub header.b=aPQ4zYXJ; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MM0QL3t5zz1yhd for ; Tue, 6 Sep 2022 06:25:46 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=WWfo3r8tYqNQq8qrF1RrhgPoUHu+oEy6ur5HAWKc5EY=; b=bCqe/cZwQ7Hi4b kbFtRdSe/2eKnrJWK2ZBFWIFAd0Ref8jkSyxYMs6WqiKYIctn/1HafbdXFVg3HjIyzjA+dafN1AoJ /gAEfRQx/eylNZRYH8Qofd2oQKFAXkg43ZfRkVfkJbOYlGybpzJtAMXb5tzi/wXuy17BavKrdclYO blyqExhbYGdjSaqs2gLJHu/eezJCgnoUQrRUCcY3pVLJRNsB4qTpnkyTdGg1AVxdTMnFwFjCi/ILm LyHazl0UlIKdoWgGVXItZ1Zu9Iw/VV5q1vsevZUTtCd5J2OW50HKRjVm4aOhfpNfHPqFVeuqQm6D0 BxSMlinlxbc88GGcsaHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVIZ7-00AFyA-4t; Mon, 05 Sep 2022 20:19:29 +0000 Received: from mail234c50.megamailservers.eu ([91.136.10.244] helo=mail37c50.megamailservers.eu) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVIP1-009yp6-FU for openwrt-devel@lists.openwrt.org; Mon, 05 Sep 2022 20:09:08 +0000 X-Authenticated-User: henrik.ginstmark@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1662408532; bh=YlWkqNWT55uHqCRVSBcWOSOZV94JWAbO1Mm0v5YhFKA=; h=From:To:Cc:Subject:Date:From; b=aPQ4zYXJNBNpFYhdSTZVjf3BiJtdtxuMqGomFis+LLmK4rEjPgWv73ooFV40FKcIL oYujLlZFR+geuNI/UCi9hRK0s0reVk3WiLRvZzYoqPlrcvk2B/qbHHYpehgEEZ1DV2 00twUOoACVIpBPme84+dMQRuCB7pvSriIoJ0GxWM= Feedback-ID: henrik@ginstmar Received: from archie.lan (ua-85-227-244-184.bbcust.telenor.se [85.227.244.184]) (authenticated bits=0) by mail37c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 285K8n9X035307; Mon, 5 Sep 2022 20:08:51 +0000 From: Henrik Ginstmark To: openwrt-devel@lists.openwrt.org Cc: daniel@makrotopia.org, oskari@lemmela.net, ryazanov.s.a@gmail.com, Henrik Ginstmark Subject: [PATCH] uqmi: add APN profile commands Date: Mon, 5 Sep 2022 22:07:52 +0200 Message-Id: <20220905200751.998416-1-henrik@ginstmark.se> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-CTCH-RefID: str=0001.0A782F26.63165754.003E,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Rules: X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-Origin-Country: SE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220905_130904_126274_96C897A8 X-CRM114-Status: GOOD ( 14.79 ) X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add commands to create and modify default APN profile --get-default-profile-number --get-profile-settings --create-profile --modify-profile Signed-off-by: Henrik Ginstmark --- uqmi/src/commands-wds.c | 346 +++++++++++++++++++++++++++++++++------- uqmi/src/commands-wds.h | 22 +++ 2 files changed, 312 insertions(+), 56 [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add commands to create and modify default APN profile --get-default-profile-number --get-profile-settings --create-profile --modify-profile Signed-off-by: Henrik Ginstmark --- uqmi/src/commands-wds.c | 346 +++++++++++++++++++++++++++++++++------- uqmi/src/commands-wds.h | 22 +++ 2 files changed, 312 insertions(+), 56 deletions(-) diff --git a/uqmi/src/commands-wds.c b/uqmi/src/commands-wds.c index 3aecefd..3d0f524 100644 --- a/uqmi/src/commands-wds.c +++ b/uqmi/src/commands-wds.c @@ -24,17 +24,70 @@ #include "qmi-message.h" +static const struct { + const char *auth_name; + QmiWdsAuthentication auth; +} auth_modes[] = { + { "none", QMI_WDS_AUTHENTICATION_NONE }, + { "pap", QMI_WDS_AUTHENTICATION_PAP }, + { "chap", QMI_WDS_AUTHENTICATION_CHAP }, + { "both", QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP }, +}; + +static const struct { + const char *ipfam_name; + const QmiWdsIpFamily mode; +} ipfam_modes[] = { + { "ipv4", QMI_WDS_IP_FAMILY_IPV4 }, + { "ipv6", QMI_WDS_IP_FAMILY_IPV6 }, + { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED }, +}; + +static const struct { + const char *pdp_name; + const QmiWdsPdpType type; +} pdp_types[] = { + { "ipv4", QMI_WDS_PDP_TYPE_IPV4 }, + { "ppp", QMI_WDS_PDP_TYPE_PPP }, + { "ipv6", QMI_WDS_PDP_TYPE_IPV6 }, + { "ipv4v6", QMI_WDS_PDP_TYPE_IPV4_OR_IPV6 }, +}; + +static const struct { + const char *profile_name; + const QmiWdsProfileType profile; +} profile_types[] = { + { "3gpp", QMI_WDS_PROFILE_TYPE_3GPP }, + { "3gpp2", QMI_WDS_PROFILE_TYPE_3GPP2 }, +}; + static struct qmi_wds_start_network_request wds_sn_req = { QMI_INIT(authentication_preference, QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP), }; + static struct qmi_wds_stop_network_request wds_stn_req; +static struct qmi_wds_modify_profile_request wds_mp_req = { + QMI_INIT_SEQUENCE(profile_identifier, + .profile_type = QMI_WDS_PROFILE_TYPE_3GPP, + .profile_index = 1, + ), + QMI_INIT(apn_disabled_flag, false), +}; + +static struct qmi_wds_create_profile_request wds_cp_req = { + QMI_INIT(profile_type,QMI_WDS_PROFILE_TYPE_3GPP), + QMI_INIT(apn_disabled_flag, false), +}; + #define cmd_wds_set_apn_cb no_cb static enum qmi_cmd_result cmd_wds_set_apn_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { qmi_set_ptr(&wds_sn_req, apn, arg); + qmi_set_ptr(&wds_mp_req, apn_name, arg); + qmi_set_ptr(&wds_cp_req, apn_name, arg); return QMI_CMD_DONE; } @@ -42,22 +95,14 @@ cmd_wds_set_apn_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi static enum qmi_cmd_result cmd_wds_set_auth_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { - static const struct { - const char *name; - QmiWdsAuthentication auth; - } modes[] = { - { "pap", QMI_WDS_AUTHENTICATION_PAP }, - { "chap", QMI_WDS_AUTHENTICATION_CHAP }, - { "both", QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP }, - { "none", QMI_WDS_AUTHENTICATION_NONE }, - }; int i; - - for (i = 0; i < ARRAY_SIZE(modes); i++) { - if (strcasecmp(modes[i].name, arg) != 0) + for (i = 0; i < ARRAY_SIZE(auth_modes); i++) { + if (strcasecmp(auth_modes[i].auth_name, arg) != 0) continue; - qmi_set(&wds_sn_req, authentication_preference, modes[i].auth); + qmi_set(&wds_sn_req, authentication_preference, auth_modes[i].auth); + qmi_set(&wds_mp_req, authentication, auth_modes[i].auth); + qmi_set(&wds_cp_req, authentication, auth_modes[i].auth); return QMI_CMD_DONE; } @@ -70,6 +115,8 @@ static enum qmi_cmd_result cmd_wds_set_username_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { qmi_set_ptr(&wds_sn_req, username, arg); + qmi_set_ptr(&wds_mp_req, username, arg); + qmi_set_ptr(&wds_cp_req, username, arg); return QMI_CMD_DONE; } @@ -78,6 +125,8 @@ static enum qmi_cmd_result cmd_wds_set_password_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { qmi_set_ptr(&wds_sn_req, password, arg); + qmi_set_ptr(&wds_mp_req, password, arg); + qmi_set_ptr(&wds_cp_req, password, arg); return QMI_CMD_DONE; } @@ -94,21 +143,12 @@ cmd_wds_set_autoconnect_prepare(struct qmi_dev *qmi, struct qmi_request *req, st static enum qmi_cmd_result cmd_wds_set_ip_family_pref_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { - static const struct { - const char *name; - const QmiWdsIpFamily mode; - } modes[] = { - { "ipv4", QMI_WDS_IP_FAMILY_IPV4 }, - { "ipv6", QMI_WDS_IP_FAMILY_IPV6 }, - { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED }, - }; int i; - - for (i = 0; i < ARRAY_SIZE(modes); i++) { - if (strcasecmp(modes[i].name, arg) != 0) + for (i = 0; i < ARRAY_SIZE(ipfam_modes); i++) { + if (strcasecmp(ipfam_modes[i].ipfam_name, arg) != 0) continue; - qmi_set(&wds_sn_req, ip_family_preference, modes[i].mode); + qmi_set(&wds_sn_req, ip_family_preference, ipfam_modes[i].mode); return QMI_CMD_DONE; } @@ -116,6 +156,42 @@ cmd_wds_set_ip_family_pref_prepare(struct qmi_dev *qmi, struct qmi_request *req, return QMI_CMD_EXIT; } +#define cmd_wds_set_pdp_type_cb no_cb +static enum qmi_cmd_result +cmd_wds_set_pdp_type_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(pdp_types); i++) { + if (strcasecmp(pdp_types[i].pdp_name, arg) != 0) + continue; + + qmi_set(&wds_mp_req, pdp_type, pdp_types[i].type); + qmi_set(&wds_cp_req, pdp_type, pdp_types[i].type); + return QMI_CMD_DONE; + } + + uqmi_add_error("Invalid value (valid: ipv4, ipv6, ipv4v6)"); + return QMI_CMD_EXIT; +} + +#define cmd_wds_no_roaming_cb no_cb +static enum qmi_cmd_result +cmd_wds_no_roaming_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + if (strcmp(arg, "true") == 0) { + qmi_set(&wds_mp_req, roaming_disallowed_flag, true); + qmi_set(&wds_cp_req, roaming_disallowed_flag, true); + } else if (strcmp(arg, "false") == 0) { + qmi_set(&wds_mp_req, roaming_disallowed_flag, false); + qmi_set(&wds_cp_req, roaming_disallowed_flag, false); + } else { + uqmi_add_error("Invalid value (true or false)"); + return QMI_CMD_EXIT; + } + return QMI_CMD_DONE; +} + #define cmd_wds_set_profile_cb no_cb static enum qmi_cmd_result cmd_wds_set_profile_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) @@ -154,6 +230,84 @@ cmd_wds_stop_network_prepare(struct qmi_dev *qmi, struct qmi_request *req, struc return QMI_CMD_REQUEST; } +static void +cmd_wds_modify_profile_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) +{ + struct qmi_wds_modify_profile_response res; + qmi_parse_wds_modify_profile_response(msg, &res); +} + +static enum qmi_cmd_result +cmd_wds_modify_profile_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + int id; + char *s; + char *p_type; + + s = strchr(arg, ','); + if (!s) { + fprintf(stderr, "Invalid argument\n"); + return QMI_CMD_EXIT; + } + *s = 0; + s++; + + id = strtoul(s, &s, 0); + if (s && *s) { + fprintf(stderr, "Invalid argument\n"); + return QMI_CMD_EXIT; + } + + p_type = strtok(arg, ","); + + int i; + for (i = 0; i < ARRAY_SIZE(profile_types); i++) { + if (strcasecmp(profile_types[i].profile_name, p_type) != 0) + continue; + + qmi_set_ptr(&wds_mp_req, profile_identifier.profile_type, profile_types[i].profile); + qmi_set_ptr(&wds_mp_req, profile_identifier.profile_index, id); + qmi_set_wds_modify_profile_request(msg, &wds_mp_req); + return QMI_CMD_REQUEST; + } + + uqmi_add_error("Invalid value (valid: 3gpp or 3gpp2)"); + return QMI_CMD_EXIT; +} + +static void +cmd_wds_create_profile_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) +{ + struct qmi_wds_create_profile_response res; + void *p; + + qmi_parse_wds_create_profile_response(msg, &res); + + if (res.set.profile_identifier) { + p = blobmsg_open_table(&status, NULL); + blobmsg_add_u32(&status, "created-profile", res.data.profile_identifier.profile_index); + blobmsg_close_table(&status, p); + } +} + +static enum qmi_cmd_result +cmd_wds_create_profile_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + int i; + for (i = 0; i < ARRAY_SIZE(profile_types); i++) { + if (strcasecmp(profile_types[i].profile_name, arg) != 0) + continue; + + qmi_set_ptr(&wds_cp_req, profile_type, profile_types[i].profile); + + qmi_set_wds_create_profile_request(msg, &wds_cp_req); + return QMI_CMD_REQUEST; + } + + uqmi_add_error("Invalid value (valid: 3gpp or 3gpp2)"); + return QMI_CMD_EXIT; +} + static void cmd_wds_get_packet_service_status_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) { @@ -220,21 +374,13 @@ static enum qmi_cmd_result cmd_wds_set_ip_family_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) { struct qmi_wds_set_ip_family_request ipf_req; - const struct ip_modes { - const char *name; - const QmiWdsIpFamily mode; - } modes[] = { - { "ipv4", QMI_WDS_IP_FAMILY_IPV4 }, - { "ipv6", QMI_WDS_IP_FAMILY_IPV6 }, - { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED }, - }; - int i; - for (i = 0; i < ARRAY_SIZE(modes); i++) { - if (strcasecmp(modes[i].name, arg) != 0) + int i; + for (i = 0; i < ARRAY_SIZE(ipfam_modes); i++) { + if (strcasecmp(ipfam_modes[i].ipfam_name, arg) != 0) continue; - qmi_set(&ipf_req, preference, modes[i].mode); + qmi_set(&ipf_req, preference, ipfam_modes[i].mode); qmi_set_wds_set_ip_family_request(msg, &ipf_req); return QMI_CMD_REQUEST; } @@ -264,39 +410,90 @@ static void wds_to_ipv6(const char *name, const uint16_t *addr) blobmsg_add_string(&status, name, inet_ntop(AF_INET6, &ip_addr, buf, sizeof(buf))); } +static enum qmi_cmd_result +cmd_wds_get_profile_settings_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + int id; + char *s; + char *p_type; + + s = strchr(arg, ','); + if (!s) { + fprintf(stderr, "Invalid argument\n"); + return QMI_CMD_EXIT; + } + *s = 0; + s++; + + id = strtoul(s, &s, 0); + if (s && *s) { + fprintf(stderr, "Invalid argument\n"); + return QMI_CMD_EXIT; + } + + p_type = strtok(arg, ","); + + int i; + for (i = 0; i < ARRAY_SIZE(profile_types); i++) { + if (strcasecmp(profile_types[i].profile_name, p_type) != 0) + continue; + + struct qmi_wds_get_profile_settings_request p_num = { + QMI_INIT_SEQUENCE(profile_id, + .profile_type = profile_types[i].profile, + .profile_index = id, + ) + }; + qmi_set_wds_get_profile_settings_request(msg, &p_num); + return QMI_CMD_REQUEST; + } + + uqmi_add_error("Invalid value (valid: 3gpp or 3gpp2)"); + return QMI_CMD_EXIT; +} + +static void +cmd_wds_get_profile_settings_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) +{ + struct qmi_wds_get_profile_settings_response res; + + void *p; + + qmi_parse_wds_get_profile_settings_response(msg, &res); + + p = blobmsg_open_table(&status, NULL); + + blobmsg_add_string(&status, "apn", res.data.apn_name); + if (res.set.pdp_type && (int) res.data.pdp_type < ARRAY_SIZE(pdp_types)) + blobmsg_add_string(&status, "pdp-type", pdp_types[res.data.pdp_type].pdp_name); + blobmsg_add_string(&status, "username", res.data.username); + blobmsg_add_string(&status, "password", res.data.password); + if (res.set.authentication && (int) res.data.authentication < ARRAY_SIZE(auth_modes)) + blobmsg_add_string(&status, "auth", auth_modes[res.data.authentication].auth_name); + blobmsg_add_u8(&status, "no-roaming", res.data.roaming_disallowed_flag); + blobmsg_add_u8(&status, "apn-disabled", res.data.apn_disabled_flag); + blobmsg_close_table(&status, p); +} + static void cmd_wds_get_current_settings_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) { void *v4, *v6, *d, *t; struct qmi_wds_get_current_settings_response res; - const char *pdptypes[] = { - [QMI_WDS_PDP_TYPE_IPV4] = "ipv4", - [QMI_WDS_PDP_TYPE_PPP] = "ppp", - [QMI_WDS_PDP_TYPE_IPV6] = "ipv6", - [QMI_WDS_PDP_TYPE_IPV4_OR_IPV6] = "ipv4-or-ipv6", - }; - const struct ip_modes { - const char *name; - const QmiWdsIpFamily mode; - } modes[] = { - { "ipv4", QMI_WDS_IP_FAMILY_IPV4 }, - { "ipv6", QMI_WDS_IP_FAMILY_IPV6 }, - { "unspecified", QMI_WDS_IP_FAMILY_UNSPECIFIED }, - }; int i; qmi_parse_wds_get_current_settings_response(msg, &res); t = blobmsg_open_table(&status, NULL); - if (res.set.pdp_type && (int) res.data.pdp_type < ARRAY_SIZE(pdptypes)) - blobmsg_add_string(&status, "pdp-type", pdptypes[res.data.pdp_type]); + if (res.set.pdp_type && (int) res.data.pdp_type < ARRAY_SIZE(pdp_types)) + blobmsg_add_string(&status, "pdp-type", pdp_types[res.data.pdp_type].pdp_name); if (res.set.ip_family) { - for (i = 0; i < ARRAY_SIZE(modes); i++) { - if (modes[i].mode != res.data.ip_family) + for (i = 0; i < ARRAY_SIZE(ipfam_modes); i++) { + if (ipfam_modes[i].mode != res.data.ip_family) continue; - blobmsg_add_string(&status, "ip-family", modes[i].name); + blobmsg_add_string(&status, "ip-family", ipfam_modes[i].ipfam_name); break; } } @@ -363,3 +560,40 @@ cmd_wds_get_current_settings_prepare(struct qmi_dev *qmi, struct qmi_request *re qmi_set_wds_get_current_settings_request(msg, &gcs_req); return QMI_CMD_REQUEST; } + +static enum qmi_cmd_result +cmd_wds_get_default_profile_number_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg) +{ + int i; + for (i = 0; i < ARRAY_SIZE(profile_types); i++) { + if (strcasecmp(profile_types[i].profile_name, arg) != 0) + continue; + + struct qmi_wds_get_default_profile_number_request type_family = { + QMI_INIT_SEQUENCE(profile_type, + .type = profile_types[i].profile, + .family = QMI_WDS_PROFILE_FAMILY_TETHERED, + ) + }; + + qmi_set_wds_get_default_profile_number_request(msg, &type_family); + return QMI_CMD_REQUEST; + } + + uqmi_add_error("Invalid value (valid: 3gpp or 3gpp2)"); + return QMI_CMD_EXIT; +} + +static void +cmd_wds_get_default_profile_number_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) +{ + struct qmi_wds_get_default_profile_number_response res; + void *p; + qmi_parse_wds_get_default_profile_number_response(msg, &res); + + p = blobmsg_open_table(&status, NULL); + + blobmsg_add_u32(&status, "default-profile", res.data.index); + + blobmsg_close_table(&status, p); +} diff --git a/uqmi/src/commands-wds.h b/uqmi/src/commands-wds.h index 5aa7ea8..099bab8 100644 --- a/uqmi/src/commands-wds.h +++ b/uqmi/src/commands-wds.h @@ -33,6 +33,12 @@ __uqmi_command(wds_set_ip_family, set-ip-family, required, QMI_SERVICE_WDS), \ __uqmi_command(wds_set_autoconnect_settings, set-autoconnect, required, QMI_SERVICE_WDS), \ __uqmi_command(wds_reset, reset-wds, no, QMI_SERVICE_WDS), \ + __uqmi_command(wds_get_profile_settings, get-profile-settings, required, QMI_SERVICE_WDS), \ + __uqmi_command(wds_get_default_profile_number, get-default-profile-number, required, QMI_SERVICE_WDS), \ + __uqmi_command(wds_create_profile, create-profile, required, QMI_SERVICE_WDS), \ + __uqmi_command(wds_modify_profile, modify-profile, required, QMI_SERVICE_WDS), \ + __uqmi_command(wds_set_pdp_type, pdp-type, required, CMD_TYPE_OPTION), \ + __uqmi_command(wds_no_roaming, no-roaming, required, CMD_TYPE_OPTION), \ __uqmi_command(wds_get_current_settings, get-current-settings, no, QMI_SERVICE_WDS) \ @@ -50,5 +56,21 @@ " --get-data-status: Get current data access status\n" \ " --set-ip-family : Set ip-family (ipv4, ipv6, unspecified)\n" \ " --set-autoconnect : Set automatic connect/reconnect (disabled, enabled, paused)\n" \ + " --get-profile-settings : Get APN profile settings (3gpp, 3gpp2),#\n" \ + " --get-default-profile-number : Get default profile number (3gpp, 3gpp2)\n" \ + " --create-profile Create profile (3gpp, 3gpp2)\n" \ + " --apn : Use APN\n" \ + " --pdp-type ipv4|ipv6|ipv4v6>: Use pdp-type for the connection\n" \ + " --username : Use network username\n" \ + " --password : Use network password\n" \ + " --auth-type pap|chap|both|none: Use network authentication type\n" \ + " --no-roaming false|true To allow roaming, set to false\n" \ + " --modify-profile ,# Modify profile number (3gpp, 3gpp2)\n" \ + " --apn : Use APN\n" \ + " --pdp-type ipv4|ipv6|ipv4v6>: Use pdp-type for the connection\n" \ + " --username : Use network username\n" \ + " --password : Use network password\n" \ + " --auth-type pap|chap|both|none: Use network authentication type\n" \ + " --no-roaming false|true To allow roaming, set to false\n" \ " --get-current-settings: Get current connection settings\n" \