X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuqmi.git;a=blobdiff_plain;f=commands.c;h=b1b54d70b8828eb556a612236832c013bccc2004;hp=8c06503db818de8454b28939fb895329da594339;hb=eb1dec7d0dc283a7f61aa574a443a0ab61f8793f;hpb=d7a56cad6d6ef3c2a5602fc604e31999eb9e78fa diff --git a/commands.c b/commands.c index 8c06503..b1b54d7 100644 --- a/commands.c +++ b/commands.c @@ -1,3 +1,24 @@ +/* + * uqmi -- tiny QMI support implementation + * + * Copyright (C) 2014-2015 Felix Fietkau + * + * 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 #include #include @@ -99,10 +120,47 @@ 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" #include "commands-wms.c" +#include "commands-wda.c" #define __uqmi_command(_name, _optname, _arg, _type) \ [__UQMI_COMMAND_##_name] = { \