| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 3 |
/* |
| 4 |
* libmbim-glib -- GLib/GIO based library to control MBIM devices |
| 5 |
* |
| 6 |
* Copyright (C) 2021 Aleksander Morgado <[email protected]> |
| 7 |
* Copyright (C) 2021 Intel Corporation |
| 8 |
* |
| 9 |
* This is a private non-installed header |
| 10 |
*/ |
| 11 |
|
| 12 |
#ifndef _LIBMBIM_GLIB_MBIM_TLV_PRIVATE_H_ |
| 13 |
#define _LIBMBIM_GLIB_MBIM_TLV_PRIVATE_H_ |
| 14 |
|
| 15 |
#if !defined (LIBMBIM_GLIB_COMPILATION) |
| 16 |
#error "This is a private header!!" |
| 17 |
#endif |
| 18 |
|
| 19 |
#include <glib.h> |
| 20 |
|
| 21 |
#include "mbim-tlv.h" |
| 22 |
|
| 23 |
G_BEGIN_DECLS |
| 24 |
|
| 25 |
/*****************************************************************************/ |
| 26 |
/* The MbimTlv */ |
| 27 |
|
| 28 |
/* Defined in the same way as GByteArray */ |
| 29 |
struct _MbimTlv { |
| 30 |
/*< private >*/ |
| 31 |
guint8 *data; |
| 32 |
guint len; |
| 33 |
}; |
| 34 |
|
| 35 |
struct tlv { |
| 36 |
guint16 type; |
| 37 |
guint8 reserved; |
| 38 |
guint8 padding_length; |
| 39 |
guint32 data_length; |
| 40 |
guint8 data[]; |
| 41 |
} __attribute__((packed)); |
| 42 |
|
| 43 |
#define MBIM_TLV_HEADER(self) ((struct tlv *)(((MbimTlv *)self)->data)) |
| 44 |
|
| 45 |
#define MBIM_TLV_FIELD_TYPE(self) MBIM_TLV_HEADER (self)->type |
| 46 |
#define MBIM_TLV_FIELD_RESERVED(self) MBIM_TLV_HEADER (self)->reserved |
| 47 |
#define MBIM_TLV_FIELD_PADDING_LENGTH(self) MBIM_TLV_HEADER (self)->padding_length |
| 48 |
#define MBIM_TLV_FIELD_DATA_LENGTH(self) MBIM_TLV_HEADER (self)->data_length |
| 49 |
#define MBIM_TLV_FIELD_DATA(self) MBIM_TLV_HEADER (self)->data |
| 50 |
|
| 51 |
#define MBIM_TLV_GET_TLV_TYPE(self) (MbimTlvType) GUINT16_FROM_LE (MBIM_TLV_FIELD_TYPE (self)) |
| 52 |
#define MBIM_TLV_GET_DATA_LENGTH(self) GUINT32_FROM_LE (MBIM_TLV_FIELD_DATA_LENGTH (self)) |
| 53 |
|
| 54 |
/*****************************************************************************/ |
| 55 |
/* Print support */ |
| 56 |
|
| 57 |
gchar *_mbim_tlv_print (const MbimTlv *tlv, |
| 58 |
const gchar *line_prefix); |
| 59 |
|
| 60 |
/*****************************************************************************/ |
| 61 |
/* Parsing support */ |
| 62 |
|
| 63 |
MbimTlv *_mbim_tlv_new_from_raw (const guint8 *raw, |
| 64 |
guint32 raw_length, |
| 65 |
guint32 *bytes_read, |
| 66 |
GError **error); |
| 67 |
|
| 68 |
G_END_DECLS |
| 69 |
|
| 70 |
#endif /* _LIBMBIM_GLIB_MBIM_TLV_PRIVATE_H_ */ |