summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/diagnostics_relay.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/diagnostics_relay.h')
-rw-r--r--include/libimobiledevice/diagnostics_relay.h228
1 files changed, 228 insertions, 0 deletions
diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h
new file mode 100644
index 0000000..6ab47a9
--- /dev/null
+++ b/include/libimobiledevice/diagnostics_relay.h
@@ -0,0 +1,228 @@
1/**
2 * @file libimobiledevice/diagnostics_relay.h
3 * @brief Request iOS diagnostic information from device.
4 * \internal
5 *
6 * Copyright (c) 2012-2014 Martin Szulecki, All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef IDIAGNOSTICS_RELAY_H
24#define IDIAGNOSTICS_RELAY_H
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include <libimobiledevice/libimobiledevice.h>
31#include <libimobiledevice/lockdown.h>
32
33/** Service identifier passed to lockdownd_start_service() to start the diagnostics relay service */
34#define DIAGNOSTICS_RELAY_SERVICE_NAME "com.apple.mobile.diagnostics_relay"
35
36/** Error Codes */
37typedef enum {
38 DIAGNOSTICS_RELAY_E_SUCCESS = 0,
39 DIAGNOSTICS_RELAY_E_INVALID_ARG = -1,
40 DIAGNOSTICS_RELAY_E_PLIST_ERROR = -2,
41 DIAGNOSTICS_RELAY_E_MUX_ERROR = -3,
42 DIAGNOSTICS_RELAY_E_UNKNOWN_REQUEST = -4,
43 DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR = -256
44} diagnostics_relay_error_t;
45
46/** Action type for #diagnostics_relay_restart and #diagnostics_relay_shutdown */
47typedef enum {
48 DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT = 1 << 1,
49 DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS = 1 << 2,
50 DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL = 1 << 3
51} diagnostics_relay_action_t;
52
53#define DIAGNOSTICS_RELAY_REQUEST_TYPE_ALL "All" /**< Query all available diagnostics */
54#define DIAGNOSTICS_RELAY_REQUEST_TYPE_WIFI "WiFi" /**< Query WiFi diagnostics */
55#define DIAGNOSTICS_RELAY_REQUEST_TYPE_GAS_GAUGE "GasGauge" /**< Query GasGauge diagnostics */
56#define DIAGNOSTICS_RELAY_REQUEST_TYPE_NAND "NAND" /**< Query NAND diagnostics */
57
58typedef struct diagnostics_relay_client_private diagnostics_relay_client_private; /**< \private */
59typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The client handle. */
60
61/**
62 * Connects to the diagnostics_relay service on the specified device.
63 *
64 * @param device The device to connect to.
65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Reference that will point to a newly allocated
67 * diagnostics_relay_client_t upon successful return.
68 *
69 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
70 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
71 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
72 */
73LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client);
74
75/**
76 * Starts a new diagnostics_relay service on the specified device and connects to it.
77 *
78 * @param device The device to connect to.
79 * @param client Pointer that will point to a newly allocated
80 * diagnostics_relay_client_t upon successful return. Must be freed using
81 * diagnostics_relay_client_free() after use.
82 * @param label The label to use for communication. Usually the program name.
83 * Pass NULL to disable sending the label in requests to lockdownd.
84 *
85 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error
86 * code otherwise.
87 */
88LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label);
89
90/**
91 * Disconnects a diagnostics_relay client from the device and frees up the
92 * diagnostics_relay client data.
93 *
94 * @param client The diagnostics_relay client to disconnect and free.
95 *
96 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
97 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of client or client->parent
98 * is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an
99 * error freeing the parent property_list_service client.
100 */
101LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client);
102
103
104/**
105 * Sends the Goodbye request signaling the end of communication.
106 *
107 * @param client The diagnostics_relay client
108 *
109 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
110 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
111 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
112 * request
113 */
114LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client);
115
116/**
117 * Puts the device into deep sleep mode and disconnects from host.
118 *
119 * @param client The diagnostics_relay client
120 *
121 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
122 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
123 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
124 * request
125 */
126LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client);
127
128/**
129 * Restart the device and optionally show a user notification.
130 *
131 * @param client The diagnostics_relay client
132 * @param flags A binary flag combination of
133 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
134 * diagnostics_relay_client_free() disconnects before execution and
135 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
136 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
137 *
138 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
139 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
140 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
141 * request
142 */
143LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
144
145/**
146 * Shutdown of the device and optionally show a user notification.
147 *
148 * @param client The diagnostics_relay client
149 * @param flags A binary flag combination of
150 * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until
151 * diagnostics_relay_client_free() disconnects before execution and
152 * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog
153 * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog
154 *
155 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
156 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
157 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
158 * request
159 */
160LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags);
161
162/**
163 * Request diagnostics information for a given type.
164 *
165 * @param client The diagnostics_relay client
166 * @param type The type or domain to query for diagnostics. Some known values
167 * are "All", "WiFi", "GasGauge", and "NAND".
168 * @param diagnostics A pointer to plist_t that will receive the diagnostics information.
169 * The consumer has to free the allocated memory with plist_free() when no longer needed.
170 *
171 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
172 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
173 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
174 * request
175 */
176LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics);
177
178/**
179 * Query one or multiple MobileGestalt keys.
180 *
181 * @param client The diagnostics_relay client
182 * @param keys A PLIST_ARRAY with the keys to query.
183 * @param result A pointer to plist_t that will receive the result. The consumer
184 * has to free the allocated memory with plist_free() when no longer needed.
185 *
186 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
187 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
188 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
189 * request
190 */
191LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result);
192
193/**
194 * Query an IORegistry entry of a given class.
195 *
196 * @param client The diagnostics_relay client
197 * @param entry_name The IORegistry entry name to query.
198 * @param entry_class The IORegistry class to query.
199 * @param result A pointer to plist_t that will receive the result. The consumer
200 * has to free the allocated memory with plist_free() when no longer needed.
201 *
202 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
203 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
204 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
205 * request
206 */
207LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result);
208
209/**
210 * Query an IORegistry plane.
211 *
212 * @param client The diagnostics_relay client
213 * @param plane The IORegistry plane name to query.
214 * @param result A pointer to plist_t that will receive the result. The consumer
215 * has to free the allocated memory with plist_free() when no longer needed.
216 *
217 * @return DIAGNOSTICS_RELAY_E_SUCCESS on success,
218 * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL,
219 * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the
220 * request
221 */
222LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result);
223
224#ifdef __cplusplus
225}
226#endif
227
228#endif