1 /* Copyright (c) 2012, The Linux Foundation. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
13 #ifndef _QMI_ENCDEC_PRIV_H_
14 #define _QMI_ENCDEC_PRIV_H_
16 #include <linux/types.h>
17 #include <linux/errno.h>
19 #include <linux/list.h>
20 #include <linux/socket.h>
21 #include <linux/gfp.h>
22 #include <linux/qmi_encdec.h>
24 #define QMI_ENCDEC_ENCODE_TLV(type, length, p_dst) do { \
26 *p_dst++ = ((uint8_t)((length) & 0xFF)); \
27 *p_dst++ = ((uint8_t)(((length) >> 8) & 0xFF)); \
30 #define QMI_ENCDEC_DECODE_TLV(p_type, p_length, p_src) do { \
31 *p_type = (uint8_t)*p_src++; \
32 *p_length = (uint8_t)*p_src++; \
33 *p_length |= ((uint8_t)*p_src) << 8; \
36 #define QMI_ENCDEC_ENCODE_N_BYTES(p_dst, p_src, size) \
38 memcpy(p_dst, p_src, size); \
39 p_dst = (uint8_t *)p_dst + size; \
40 p_src = (uint8_t *)p_src + size; \
43 #define QMI_ENCDEC_DECODE_N_BYTES(p_dst, p_src, size) \
45 memcpy(p_dst, p_src, size); \
46 p_dst = (uint8_t *)p_dst + size; \
47 p_src = (uint8_t *)p_src + size; \
50 #define UPDATE_ENCODE_VARIABLES(temp_si, buf_dst, \
51 encoded_bytes, tlv_len, encode_tlv, rc) \
53 buf_dst = (uint8_t *)buf_dst + rc; \
54 encoded_bytes += rc; \
56 temp_si = temp_si + 1; \
60 #define UPDATE_DECODE_VARIABLES(buf_src, decoded_bytes, rc) \
62 buf_src = (uint8_t *)buf_src + rc; \
63 decoded_bytes += rc; \