dms: add "Set FCC Authentication" request
[project/uqmi.git] / qmi-message.h
1 /*
2 * uqmi -- tiny QMI support implementation
3 *
4 * Copyright (C) 2014-2015 Felix Fietkau <nbd@openwrt.org>
5 *
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.
10 *
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.
15 *
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.
20 */
21
22 #ifndef __UQMI_MESSAGE_H
23 #define __UQMI_MESSAGE_H
24
25 #include <libubox/utils.h>
26 #include <stdbool.h>
27
28 #include "qmi-struct.h"
29 #include "qmi-enums.h"
30
31 #include "qmi-enums-private.h"
32 #include "qmi-message-ctl.h"
33
34 #include "qmi-enums-dms.h"
35 #include "qmi-flags64-dms.h"
36 #include "qmi-message-dms.h"
37
38 #include "qmi-enums-nas.h"
39 #include "qmi-flags64-nas.h"
40 #include "qmi-message-nas.h"
41
42 #include "qmi-enums-pds.h"
43 #include "qmi-message-pds.h"
44
45 #include "qmi-enums-wds.h"
46 #include "qmi-message-wds.h"
47
48 #include "qmi-enums-wms.h"
49 #include "qmi-message-wms.h"
50
51 #include "qmi-enums-wda.h"
52 #include "qmi-message-wda.h"
53
54 #define qmi_set(_data, _field, _val) \
55 do { \
56 (_data)->set._field = 1; \
57 (_data)->data._field = _val; \
58 } while (0)
59
60 #define qmi_set_ptr(_data, _field, _val) \
61 do { \
62 (_data)->data._field = _val; \
63 } while (0)
64
65 #define qmi_set_static_array(_data, _field, _val) \
66 do { \
67 (_data)->data._field##_n = ARRAY_SIZE(_val); \
68 (_data)->data._field = _val; \
69 } while (0);
70
71 #define qmi_set_array(_data, _field, _val, _n) \
72 do { \
73 (_data)->data.n_##_field = _n; \
74 (_data)->data._field = _val; \
75 } while (0);
76
77 #define QMI_INIT(_field, _val) \
78 .set._field = 1, \
79 .data._field = (_val)
80
81 #define QMI_INIT_SEQUENCE(_field, ...) \
82 .set._field = 1, \
83 .data._field = { __VA_ARGS__ }
84
85 #define QMI_INIT_PTR(_field, _val) \
86 .data._field = (_val)
87
88 #define QMI_INIT_STATIC_ARRAY(_field, _val) \
89 .data._field##_n = ARRAY_SIZE(_val), \
90 .data._field = (_val)
91
92 #define QMI_INIT_ARRAY(_field, _val, _n) \
93 .data._field##_n = (_n), \
94 .data._field = (_val)
95
96
97 enum {
98 QMI_ERROR_NO_DATA = -1,
99 QMI_ERROR_INVALID_DATA = -2,
100 QMI_ERROR_CANCELLED = -3,
101 };
102
103 #define QMI_BUFFER_LEN 2048
104
105 void __qmi_alloc_reset(void);
106 void *__qmi_alloc_static(unsigned int len);
107 char *__qmi_copy_string(void *data, unsigned int len);
108 uint8_t *__qmi_get_buf(unsigned int *ofs);
109
110 static inline int tlv_data_len(struct tlv *tlv)
111 {
112 return le16_to_cpu(tlv->len);
113 }
114
115 struct tlv *tlv_get_next(void **buf, unsigned int *buflen);
116 void tlv_new(struct qmi_msg *qm, uint8_t type, uint16_t len, void *data);
117
118 void qmi_init_request_message(struct qmi_msg *qm, QmiService service);
119 int qmi_complete_request_message(struct qmi_msg *qm);
120 int qmi_check_message_status(void *buf, unsigned int len);
121 void *qmi_msg_get_tlv_buf(struct qmi_msg *qm, int *len);
122
123 #endif