fix 7bit character conversion
[project/uqmi.git] / commands-wds.c
1 #include "qmi-message.h"
2
3 static struct qmi_wds_start_network_request wds_sn_req = {
4         QMI_INIT(authentication_preference,
5                  QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP),
6 };
7
8 #define cmd_wds_set_auth_cb no_cb
9 static enum qmi_cmd_result
10 cmd_wds_set_auth_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
11 {
12         static const struct {
13                 const char *name;
14                 QmiWdsAuthentication auth;
15         } modes[] = {
16                 { "pap", QMI_WDS_AUTHENTICATION_PAP },
17                 { "chap", QMI_WDS_AUTHENTICATION_CHAP },
18                 { "both", QMI_WDS_AUTHENTICATION_PAP | QMI_WDS_AUTHENTICATION_CHAP },
19                 { "none", QMI_WDS_AUTHENTICATION_NONE },
20         };
21         int i;
22
23         for (i = 0; i < ARRAY_SIZE(modes); i++) {
24                 if (strcasecmp(modes[i].name, arg) != 0)
25                         continue;
26
27                 qmi_set(&wds_sn_req, authentication_preference, modes[i].auth);
28                 return QMI_CMD_DONE;
29         }
30
31         blobmsg_add_string(&status, "error", "Invalid auth mode (valid: pap, chap, both, none)");
32         return QMI_CMD_EXIT;
33 }
34
35 #define cmd_wds_set_username_cb no_cb
36 static enum qmi_cmd_result
37 cmd_wds_set_username_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
38 {
39         qmi_set_ptr(&wds_sn_req, username, arg);
40         return QMI_CMD_DONE;
41 }
42
43 #define cmd_wds_set_password_cb no_cb
44 static enum qmi_cmd_result
45 cmd_wds_set_password_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
46 {
47         qmi_set_ptr(&wds_sn_req, password, arg);
48         return QMI_CMD_DONE;
49 }
50
51 static void
52 cmd_wds_start_network_cb(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg)
53 {
54         struct qmi_wds_start_network_response res;
55
56         qmi_parse_wds_start_network_response(msg, &res);
57         if (res.set.packet_data_handle)
58                 blobmsg_add_u32(&status, "handle", res.data.packet_data_handle);
59 }
60
61 static enum qmi_cmd_result
62 cmd_wds_start_network_prepare(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg, char *arg)
63 {
64         qmi_set_ptr(&wds_sn_req, apn, arg);
65         qmi_set_wds_start_network_request(msg, &wds_sn_req);
66         return QMI_CMD_REQUEST;
67 }