[LEDE-DEV] [PATCH][uqmi 2/5] wds: add a separate --set-ip-family option

Matti Laakso malaakso at elisanet.fi
Sun Nov 20 13:27:31 PST 2016


Change the current ip-family option to set the IP Family Preference
TLV in the Start Network command, and add a separate set-ip-family
option for the Set IP Family command. This is done to match how
the autoconnect and set-autoconnect options work.

Older modems don't support the Set IP Family command, and they
should use the IP Family Preference TLV. On the other hand, newer
modems, e.g., from Huawei, don't respect that TLV, and require the
use of the separate Set IP Family command.

Signed-off-by: Matti Laakso <malaakso at elisanet.fi>
---
 commands-wds.c | 26 ++++++++++++++++++++++++++
 commands-wds.h |  4 +++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/commands-wds.c b/commands-wds.c
index 0615a7a..7bb75da 100644
--- a/commands-wds.c
+++ b/commands-wds.c
@@ -82,6 +82,32 @@ cmd_wds_set_autoconnect_prepare(struct qmi_dev *qmi, struct qmi_request *req, st
 	return QMI_CMD_DONE;
 }
 
+#define cmd_wds_set_ip_family_pref_cb no_cb
+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)
+			continue;
+
+		qmi_set(&wds_sn_req, ip_family_preference, modes[i].mode);
+		return QMI_CMD_DONE;
+	}
+
+	uqmi_add_error("Invalid value (valid: ipv4, ipv6, unspecified)");
+	return QMI_CMD_EXIT;
+}
+
 static void
 cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
 {
diff --git a/commands-wds.h b/commands-wds.h
index ba67df9..c603f79 100644
--- a/commands-wds.h
+++ b/commands-wds.h
@@ -24,10 +24,11 @@
 	__uqmi_command(wds_set_auth, auth-type, required, CMD_TYPE_OPTION), \
 	__uqmi_command(wds_set_username, username, required, CMD_TYPE_OPTION), \
 	__uqmi_command(wds_set_password, password, required, CMD_TYPE_OPTION), \
-	__uqmi_command(wds_set_ip_family, ip-family, required, CMD_TYPE_OPTION), \
+	__uqmi_command(wds_set_ip_family_pref, ip-family, required, CMD_TYPE_OPTION), \
 	__uqmi_command(wds_set_autoconnect, autoconnect, no, CMD_TYPE_OPTION), \
 	__uqmi_command(wds_stop_network, stop-network, required, QMI_SERVICE_WDS), \
 	__uqmi_command(wds_get_packet_service_status, get-data-status, no, QMI_SERVICE_WDS), \
+	__uqmi_command(wds_set_ip_family, set-ip-family, required, QMI_SERVICE_WDS), \
 	__uqmi_command(wds_set_autoconnect_setting, set-autoconnect, required, QMI_SERVICE_WDS), \
 	__uqmi_command(wds_reset, reset-wds, no, QMI_SERVICE_WDS), \
 	__uqmi_command(wds_get_current_settings, get-current-settings, no, QMI_SERVICE_WDS) \
@@ -43,6 +44,7 @@
 		"  --stop-network <pdh>:             Stop network connection (use with option below)\n" \
 		"    --autoconnect:                  Disable automatic connect/reconnect\n" \
 		"  --get-data-status:                Get current data access status\n" \
+		"  --set-ip-family <val>:            Set ip-family (ipv4, ipv6, unspecified)\n" \
 		"  --set-autoconnect <val>:          Set automatic connect/reconnect (disabled, enabled, paused)\n" \
 		"  --get-current-settings:           Get current connection settings\n" \
 
-- 
2.7.4




More information about the Lede-dev mailing list