2 * uqmi -- tiny QMI support implementation
4 * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA.
24 #include "qmi-message.h"
28 QmiWdaLinkLayerProtocol val
;
30 { "802.3", QMI_WDA_LINK_LAYER_PROTOCOL_802_3
},
31 { "raw-ip", QMI_WDA_LINK_LAYER_PROTOCOL_RAW_IP
},
34 #define cmd_wda_set_data_format_cb no_cb
36 static enum qmi_cmd_result
37 cmd_wda_set_data_format_prepare(struct qmi_dev
*qmi
, struct qmi_request
*req
, struct qmi_msg
*msg
, char *arg
)
39 struct qmi_wda_set_data_format_request data_req
= {};
42 for (i
= 0; i
< ARRAY_SIZE(link_modes
); i
++) {
43 if (strcasecmp(link_modes
[i
].name
, arg
) != 0)
46 qmi_set(&data_req
, link_layer_protocol
, link_modes
[i
].val
);
47 qmi_set_wda_set_data_format_request(msg
, &data_req
);
48 return QMI_CMD_REQUEST
;
51 uqmi_add_error("Invalid auth mode (valid: 802.3, raw-ip)");
56 cmd_wda_get_data_format_cb(struct qmi_dev
*qmi
, struct qmi_request
*req
, struct qmi_msg
*msg
)
58 struct qmi_wda_get_data_format_response res
;
59 const char *name
= "unknown";
62 qmi_parse_wda_get_data_format_response(msg
, &res
);
63 for (i
= 0; i
< ARRAY_SIZE(link_modes
); i
++) {
64 if (link_modes
[i
].val
!= res
.data
.link_layer_protocol
)
67 name
= link_modes
[i
].name
;
71 blobmsg_add_string(&status
, NULL
, name
);
74 static enum qmi_cmd_result
75 cmd_wda_get_data_format_prepare(struct qmi_dev
*qmi
, struct qmi_request
*req
, struct qmi_msg
*msg
, char *arg
)
77 qmi_set_wda_get_data_format_request(msg
);
78 return QMI_CMD_REQUEST
;