• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/uqmi/common/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 #include "qmi-enums-uim.h"
 55 #include "qmi-message-uim.h"
 56 
 57 #define qmi_set(_data, _field, _val) \
 58         do { \
 59                 (_data)->set._field = 1; \
 60                 (_data)->data._field = _val; \
 61         } while (0)
 62 
 63 #define qmi_set_ptr(_data, _field, _val) \
 64         do { \
 65                 (_data)->data._field = _val; \
 66         } while (0)
 67 
 68 #define qmi_set_static_array(_data, _field, _val) \
 69         do { \
 70                 (_data)->data._field##_n = ARRAY_SIZE(_val); \
 71                 (_data)->data._field = _val; \
 72         } while (0);
 73 
 74 #define qmi_set_array(_data, _field, _val, _n) \
 75         do { \
 76                 (_data)->data.n_##_field = _n; \
 77                 (_data)->data._field = _val; \
 78         } while (0);
 79 
 80 #define QMI_INIT(_field, _val) \
 81         .set._field = 1, \
 82         .data._field = (_val)
 83 
 84 #define QMI_INIT_SEQUENCE(_field, ...) \
 85         .set._field = 1, \
 86         .data._field = { __VA_ARGS__ }
 87 
 88 #define QMI_INIT_PTR(_field, _val) \
 89         .data._field = (_val)
 90 
 91 #define QMI_INIT_STATIC_ARRAY(_field, _val) \
 92         .data._field##_n = ARRAY_SIZE(_val), \
 93         .data._field = (_val)
 94 
 95 #define QMI_INIT_ARRAY(_field, _val, _n) \
 96         .data._field##_n = (_n), \
 97         .data._field = (_val)
 98 
 99 
100 enum {
101         QMI_ERROR_NO_DATA = -1,
102         QMI_ERROR_INVALID_DATA = -2,
103         QMI_ERROR_CANCELLED = -3,
104 };
105 
106 #define QMI_BUFFER_LEN 2048
107 
108 void __qmi_alloc_reset(void);
109 void *__qmi_alloc_static(unsigned int len);
110 char *__qmi_copy_string(void *data, unsigned int len);
111 uint8_t *__qmi_get_buf(unsigned int *ofs);
112 
113 static inline int tlv_data_len(struct tlv *tlv)
114 {
115         return le16_to_cpu(tlv->len);
116 }
117 
118 struct tlv *tlv_get_next(void **buf, unsigned int *buflen);
119 void tlv_new(struct qmi_msg *qm, uint8_t type, uint16_t len, void *data);
120 
121 void qmi_init_request_message(struct qmi_msg *qm, QmiService service);
122 int qmi_complete_request_message(struct qmi_msg *qm);
123 int qmi_check_message_status(void *buf, unsigned int len);
124 void *qmi_msg_get_tlv_buf(struct qmi_msg *qm, int *len);
125 
126 #endif
127 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt