add a command for setting the interface data format
authorFelix Fietkau <nbd@openwrt.org>
Thu, 2 Oct 2014 12:08:31 +0000 (14:08 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 2 Oct 2014 12:09:19 +0000 (14:09 +0200)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
commands.c
commands.h

index 8c06503db818de8454b28939fb895329da594339..198b6abacd1c0637d4cd9ce1b81c20d370f5a1e5 100644 (file)
@@ -99,6 +99,42 @@ cmd_set_client_id_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct q
        return QMI_CMD_DONE;
 }
 
+static int
+qmi_get_array_idx(const char **array, int size, const char *str)
+{
+       int i;
+
+       for (i = 0; i < size; i++) {
+               if (!array[i])
+                       continue;
+
+               if (!strcmp(array[i], str))
+                       return i;
+       }
+
+       return -1;
+}
+
+#define cmd_ctl_set_data_format_cb no_cb
+static enum qmi_cmd_result
+cmd_ctl_set_data_format_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       struct qmi_ctl_set_data_format_request sreq = {};
+       const char *modes[] = {
+               [QMI_CTL_DATA_LINK_PROTOCOL_802_3] = "802.3",
+               [QMI_CTL_DATA_LINK_PROTOCOL_RAW_IP] = "raw-ip",
+       };
+       int mode = qmi_get_array_idx(modes, ARRAY_SIZE(modes), arg);
+
+       if (mode < 0) {
+               uqmi_add_error("Invalid mode (modes: 802.3, raw-ip)");
+               return QMI_CMD_EXIT;
+       }
+
+       qmi_set_ctl_set_data_format_request(msg, &sreq);
+       return QMI_CMD_DONE;
+}
+
 #include "commands-wds.c"
 #include "commands-dms.c"
 #include "commands-nas.c"
index 7560dbdbdeac0dd44812d6ce8b77dfe0bdeb33d4..9d492e712aab039897d924a32a51d6051465703c 100644 (file)
@@ -34,6 +34,7 @@ struct uqmi_cmd {
        __uqmi_command(version, get-versions, no, QMI_SERVICE_CTL), \
        __uqmi_command(set_client_id, set-client-id, required, CMD_TYPE_OPTION), \
        __uqmi_command(get_client_id, get-client-id, required, QMI_SERVICE_CTL), \
+       __uqmi_command(ctl_set_data_format, set-data-format, required, QMI_SERVICE_CTL), \
        __uqmi_wds_commands, \
        __uqmi_dms_commands, \
        __uqmi_nas_commands, \