Debian Codegraph @

src/mbimcli/mbimcli-helpers.h

raw
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /*
4 * mbimcli -- Command line interface to control QMI devices
5 *
6 * Copyright (C) 2014 Aleksander Morgado <[email protected]>
7 */
8
9 #include <glib.h>
10
11 #include <libmbim-glib.h>
12
13 #ifndef __MBIMCLI_HELPERS_H__
14 #define __MBIMCLI_HELPERS_H__
15
16 gboolean mbimcli_read_uint_from_string (const gchar *str,
17 guint *out);
18 gboolean mbimcli_read_uint_from_bcd_string (const gchar *str,
19 guint *out);
20 gboolean mbimcli_read_uint8_from_bcd_string (const gchar *str,
21 guint8 *out);
22
23 gboolean mbimcli_read_boolean_from_string (const gchar *value,
24 gboolean *out);
25
26 guint8 *mbimcli_read_buffer_from_string (const gchar *hex,
27 gssize len,
28 gsize *out_len,
29 GError **error);
30
31 gboolean mbimcli_print_ip_config (MbimDevice *device,
32 MbimMessage *response,
33 GError **error);
34
35 typedef gboolean (*MbimParseKeyValueForeachFn) (const gchar *key,
36 const gchar *value,
37 GError **error,
38 gpointer user_data);
39
40 gboolean mbimcli_parse_key_value_string (const gchar *str,
41 GError **error,
42 MbimParseKeyValueForeachFn callback,
43 gpointer user_data);
44
45 gboolean mbimcli_parse_sar_config_state_array (const gchar *str,
46 GPtrArray **out,
47 GError **error);
48
49 /* Common helpers to read enums from strings */
50
51 #define MBIMCLI_ENUM_LIST \
52 MBIMCLI_ENUM_LIST_ITEM (MbimPinType, pin_type, "pin type") \
53 MBIMCLI_ENUM_LIST_ITEM (MbimContextType, context_type, "context type") \
54 MBIMCLI_ENUM_LIST_ITEM (MbimContextIpType, context_ip_type, "context ip type") \
55 MBIMCLI_ENUM_LIST_ITEM (MbimContextState, context_state, "context state") \
56 MBIMCLI_ENUM_LIST_ITEM (MbimContextRoamingControl, context_roaming_control, "context roaming control") \
57 MBIMCLI_ENUM_LIST_ITEM (MbimContextMediaType, context_media_type, "context media type") \
58 MBIMCLI_ENUM_LIST_ITEM (MbimContextSource, context_source, "context source") \
59 MBIMCLI_ENUM_LIST_ITEM (MbimContextOperation, context_operation, "context operation") \
60 MBIMCLI_ENUM_LIST_ITEM (MbimAuthProtocol, auth_protocol, "auth protocol") \
61 MBIMCLI_ENUM_LIST_ITEM (MbimCompression, compression, "compression") \
62 MBIMCLI_ENUM_LIST_ITEM (MbimSarControlMode, sar_control_mode, "sar control mode") \
63 MBIMCLI_ENUM_LIST_ITEM (MbimSarBackoffState, sar_backoff_state, "sar backoff state") \
64 MBIMCLI_ENUM_LIST_ITEM (MbimMicoMode, mico_mode, "mico mode") \
65 MBIMCLI_ENUM_LIST_ITEM (MbimDrxCycle, drx_cycle, "drx cycle") \
66 MBIMCLI_ENUM_LIST_ITEM (MbimLadnInfo, ladn_info, "ladn info") \
67 MBIMCLI_ENUM_LIST_ITEM (MbimDefaultPduActivationHint, default_pdu_activation_hint, "default pdu activation hint") \
68 MBIMCLI_ENUM_LIST_ITEM (MbimAccessMediaType, access_media_type, "access media type") \
69 MBIMCLI_ENUM_LIST_ITEM (MbimNetworkIdleHintState, network_idle_hint_state, "network idle hint state") \
70 MBIMCLI_ENUM_LIST_ITEM (MbimEmergencyModeState, emergency_mode_state, "emergency mode state") \
71 MBIMCLI_ENUM_LIST_ITEM (MbimUiccSecureMessaging, uicc_secure_messaging, "uicc secure messaging") \
72 MBIMCLI_ENUM_LIST_ITEM (MbimUiccClassByteType, uicc_class_byte_type, "uicc class byte type") \
73 MBIMCLI_ENUM_LIST_ITEM (MbimUiccPassThroughAction, uicc_pass_through_action, "uicc pass through action") \
74 MBIMCLI_ENUM_LIST_ITEM (MbimIntelBootMode, intel_boot_mode, "intel boot mode") \
75 MBIMCLI_ENUM_LIST_ITEM (MbimTraceCommand, trace_command, "trace command") \
76 MBIMCLI_ENUM_LIST_ITEM (MbimSmsFlag, sms_flag, "sms flag") \
77 MBIMCLI_ENUM_LIST_ITEM (MbimQuectelCommandType, quectel_command_type, "quectel command type") \
78 MBIMCLI_ENUM_LIST_ITEM (MbimLteAttachContextOperation, lte_attach_context_operation, "lte attach context operation") \
79 MBIMCLI_ENUM_LIST_ITEM (MbimLteAttachContextRoamingControl, lte_attach_context_roaming_control, "lte attach context roaming control") \
80 MBIMCLI_ENUM_LIST_ITEM (MbimRegisterAction, register_action, "register action")
81
82 #define MBIMCLI_ENUM_LIST_ITEM(TYPE,TYPE_UNDERSCORE,DESCR) \
83 gboolean mbimcli_read_## TYPE_UNDERSCORE ##_from_string (const gchar *str, TYPE *out, GError **error);
84 MBIMCLI_ENUM_LIST
85 #undef MBIMCLI_ENUM_LIST_ITEM
86
87 /* Common helpers to read flags from strings */
88
89 #define MBIMCLI_FLAGS_LIST \
90 MBIMCLI_FLAGS_LIST_ITEM (MbimDataClass, data_class, "data class")
91
92 #define MBIMCLI_FLAGS_LIST_ITEM(TYPE,TYPE_UNDERSCORE,DESCR) \
93 gboolean mbimcli_read_## TYPE_UNDERSCORE ##_mask_from_string (const gchar *str, TYPE *out, GError **error);
94 MBIMCLI_FLAGS_LIST
95 #undef MBIMCLI_FLAGS_LIST_ITEM
96
97 #endif /* __MBIMCLI_H__ */