add missing license headers (LGPL v2)
[project/uqmi.git] / commands-wds.c
index ce7d715..aa57d03 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * uqmi -- tiny QMI support implementation
+ *
+ * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ */
+
 #include <stdlib.h>
 
 #include "qmi-message.h"
@@ -104,7 +125,6 @@ cmd_wds_get_packet_service_status_cb(struct qmi_dev *qmi, struct qmi_request *re
 
        qmi_parse_wds_get_packet_service_status_response(msg, &res);
        if (res.set.connection_status &&
-           res.data.connection_status >= 0 &&
            res.data.connection_status < ARRAY_SIZE(data_status))
                s = res.data.connection_status;
 
@@ -118,6 +138,31 @@ cmd_wds_get_packet_service_status_prepare(struct qmi_dev *qmi, struct qmi_reques
        return QMI_CMD_REQUEST;
 }
 
+#define cmd_wds_set_autoconnect_setting_cb no_cb
+static enum qmi_cmd_result
+cmd_wds_set_autoconnect_setting_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
+{
+       struct qmi_wds_set_autoconnect_setting_request ac_req;
+       const char *modes[] = {
+               [QMI_WDS_AUTOCONNECT_DISABLED] = "disabled",
+               [QMI_WDS_AUTOCONNECT_ENABLED] = "enabled",
+               [QMI_WDS_AUTOCONNECT_PAUSED] = "paused",
+       };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(modes); i++) {
+               if (strcasecmp(modes[i], arg) != 0)
+                       continue;
+
+               qmi_set(&ac_req, setting, i);
+               qmi_set_wds_set_autoconnect_setting_request(msg, &ac_req);
+               return QMI_CMD_DONE;
+       }
+
+       uqmi_add_error("Invalid value (valid: disabled, enabled, paused)");
+       return QMI_CMD_EXIT;
+}
+
 #define cmd_wds_reset_cb no_cb
 static enum qmi_cmd_result
 cmd_wds_reset_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)