summaryrefslogtreecommitdiffstats
path: root/include/libimobiledevice/file_relay.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/libimobiledevice/file_relay.h')
-rw-r--r--include/libimobiledevice/file_relay.h141
1 files changed, 124 insertions, 17 deletions
diff --git a/include/libimobiledevice/file_relay.h b/include/libimobiledevice/file_relay.h
index 52d4758..00773b8 100644
--- a/include/libimobiledevice/file_relay.h
+++ b/include/libimobiledevice/file_relay.h
@@ -3,6 +3,8 @@
3 * @brief Retrieve compressed CPIO archives. 3 * @brief Retrieve compressed CPIO archives.
4 * \internal 4 * \internal
5 * 5 *
6 * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved.
7 * Copyright (c) 2014 Aaron Burghardt All Rights Reserved.
6 * Copyright (c) 2010 Nikias Bassen All Rights Reserved. 8 * Copyright (c) 2010 Nikias Bassen All Rights Reserved.
7 * 9 *
8 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
@@ -28,29 +30,134 @@ extern "C" {
28#endif 30#endif
29 31
30#include <libimobiledevice/libimobiledevice.h> 32#include <libimobiledevice/libimobiledevice.h>
33#include <libimobiledevice/lockdown.h>
31 34
32/** @name Error Codes */ 35/** Service identifier passed to lockdownd_start_service() to start the file relay service */
33/*@{*/ 36#define FILE_RELAY_SERVICE_NAME "com.apple.mobile.file_relay"
34#define FILE_RELAY_E_SUCCESS 0
35#define FILE_RELAY_E_INVALID_ARG -1
36#define FILE_RELAY_E_PLIST_ERROR -2
37#define FILE_RELAY_E_MUX_ERROR -3
38#define FILE_RELAY_E_INVALID_SOURCE -4
39#define FILE_RELAY_E_STAGING_EMPTY -5
40 37
41#define FILE_RELAY_E_UNKNOWN_ERROR -256 38/** Error Codes */
42/*@}*/ 39typedef enum {
40 FILE_RELAY_E_SUCCESS = 0,
41 FILE_RELAY_E_INVALID_ARG = -1,
42 FILE_RELAY_E_PLIST_ERROR = -2,
43 FILE_RELAY_E_MUX_ERROR = -3,
44 FILE_RELAY_E_INVALID_SOURCE = -4,
45 FILE_RELAY_E_STAGING_EMPTY = -5,
46 FILE_RELAY_E_PERMISSION_DENIED = -6,
47 FILE_RELAY_E_UNKNOWN_ERROR = -256
48} file_relay_error_t;
43 49
44/** Represents an error code. */ 50typedef struct file_relay_client_private file_relay_client_private; /**< \private */
45typedef int16_t file_relay_error_t;
46
47typedef struct file_relay_client_private file_relay_client_private;
48typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */ 51typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */
49 52
50file_relay_error_t file_relay_client_new(idevice_t device, uint16_t port, file_relay_client_t *client); 53/**
51file_relay_error_t file_relay_client_free(file_relay_client_t client); 54 * Connects to the file_relay service on the specified device.
55 *
56 * @param device The device to connect to.
57 * @param service The service descriptor returned by lockdownd_start_service.
58 * @param client Reference that will point to a newly allocated
59 * file_relay_client_t upon successful return.
60 *
61 * @return FILE_RELAY_E_SUCCESS on success,
62 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
63 * or FILE_RELAY_E_MUX_ERROR when the connection failed.
64 */
65LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client);
66
67/**
68 * Starts a new file_relay service on the specified device and connects to it.
69 *
70 * @param device The device to connect to.
71 * @param client Pointer that will point to a newly allocated
72 * file_relay_client_t upon successful return. Must be freed using
73 * file_relay_client_free() after use.
74 * @param label The label to use for communication. Usually the program name.
75 * Pass NULL to disable sending the label in requests to lockdownd.
76 *
77 * @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error
78 * code otherwise.
79 */
80LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label);
81
82/**
83 * Disconnects a file_relay client from the device and frees up the file_relay
84 * client data.
85 *
86 * @param client The file_relay client to disconnect and free.
87 *
88 * @return FILE_RELAY_E_SUCCESS on success,
89 * FILE_RELAY_E_INVALID_ARG when one of client or client->parent
90 * is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error
91 * freeing the parent property_list_service client.
92 */
93LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_free(file_relay_client_t client);
94
52 95
53file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection); 96/**
97 * Request data for the given sources.
98 *
99 * @param client The connected file_relay client.
100 * @param sources A NULL-terminated list of sources to retrieve.
101 * Valid sources are:
102 * - AppleSupport
103 * - Network
104 * - VPN
105 * - WiFi
106 * - UserDatabases
107 * - CrashReporter
108 * - tmp
109 * - SystemConfiguration
110 * @param connection The connection that has to be used for receiving the
111 * data using idevice_connection_receive(). The connection will be closed
112 * automatically by the device, but use file_relay_client_free() to clean
113 * up properly.
114 *
115 * @note WARNING: Don't call this function without reading the data afterwards.
116 * A directory mobile_file_relay.XXXX used for creating the archive will
117 * remain in the /tmp directory otherwise.
118 *
119 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
120 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
121 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
122 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
123 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
124 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
125 */
126LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection);
127
128/**
129 * Request data for the given sources. Calls file_relay_request_sources_timeout() with
130 * a timeout of 60000 milliseconds (60 seconds).
131 *
132 * @param client The connected file_relay client.
133 * @param sources A NULL-terminated list of sources to retrieve.
134 * Valid sources are:
135 * - AppleSupport
136 * - Network
137 * - VPN
138 * - WiFi
139 * - UserDatabases
140 * - CrashReporter
141 * - tmp
142 * - SystemConfiguration
143 * @param connection The connection that has to be used for receiving the
144 * data using idevice_connection_receive(). The connection will be closed
145 * automatically by the device, but use file_relay_client_free() to clean
146 * up properly.
147 * @param timeout Maximum time in milliseconds to wait for data.
148 *
149 * @note WARNING: Don't call this function without reading the data afterwards.
150 * A directory mobile_file_relay.XXXX used for creating the archive will
151 * remain in the /tmp directory otherwise.
152 *
153 * @return FILE_RELAY_E_SUCCESS on succes, FILE_RELAY_E_INVALID_ARG when one or
154 * more parameters are invalid, FILE_RELAY_E_MUX_ERROR if a communication
155 * error occurs, FILE_RELAY_E_PLIST_ERROR when the received result is NULL
156 * or is not a valid plist, FILE_RELAY_E_INVALID_SOURCE if one or more
157 * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available
158 * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise.
159 */
160LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout);
54 161
55#ifdef __cplusplus 162#ifdef __cplusplus
56} 163}