summaryrefslogtreecommitdiffstats
path: root/src/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c97
1 files changed, 0 insertions, 97 deletions
diff --git a/src/service.c b/src/service.c
index e8444b8..701c8b4 100644
--- a/src/service.c
+++ b/src/service.c
@@ -52,18 +52,6 @@ static service_error_t idevice_to_service_error(idevice_error_t err)
52 return SERVICE_E_UNKNOWN_ERROR; 52 return SERVICE_E_UNKNOWN_ERROR;
53} 53}
54 54
55/**
56 * Creates a new service for the specified service descriptor.
57 *
58 * @param device The device to connect to.
59 * @param service The service descriptor returned by lockdownd_start_service.
60 * @param client Pointer that will be set to a newly allocated
61 * service_client_t upon successful return.
62 *
63 * @return SERVICE_E_SUCCESS on success,
64 * SERVICE_E_INVALID_ARG when one of the arguments is invalid,
65 * or SERVICE_E_MUX_ERROR when connecting to the device failed.
66 */
67service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client) 55service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client)
68{ 56{
69 if (!device || !service || service->port == 0 || !client || *client) 57 if (!device || !service || service->port == 0 || !client || *client)
@@ -88,21 +76,6 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto
88 return SERVICE_E_SUCCESS; 76 return SERVICE_E_SUCCESS;
89} 77}
90 78
91/**
92 * Starts a new service on the specified device with given name and
93 * connects to it.
94 *
95 * @param device The device to connect to.
96 * @param service_name The name of the service to start.
97 * @param client Pointer that will point to a newly allocated service_client_t
98 * upon successful return. Must be freed using service_client_free() after
99 * use.
100 * @param label The label to use for communication. Usually the program name.
101 * Pass NULL to disable sending the label in requests to lockdownd.
102 *
103 * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code
104 * otherwise.
105 */
106service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code) 79service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int16_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int16_t *error_code)
107{ 80{
108 *client = NULL; 81 *client = NULL;
@@ -142,15 +115,6 @@ service_error_t service_client_factory_start_service(idevice_t device, const cha
142 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR; 115 return (ec == SERVICE_E_SUCCESS) ? SERVICE_E_SUCCESS : SERVICE_E_START_SERVICE_ERROR;
143} 116}
144 117
145/**
146 * Frees a service instance.
147 *
148 * @param client The service instance to free.
149 *
150 * @return SERVICE_E_SUCCESS on success,
151 * SERVICE_E_INVALID_ARG when client is invalid, or a
152 * SERVICE_E_UNKNOWN_ERROR when another error occured.
153 */
154service_error_t service_client_free(service_client_t client) 118service_error_t service_client_free(service_client_t client)
155{ 119{
156 if (!client) 120 if (!client)
@@ -164,19 +128,6 @@ service_error_t service_client_free(service_client_t client)
164 return err; 128 return err;
165} 129}
166 130
167/**
168 * Sends data using the given service client.
169 *
170 * @param client The service client to use for sending.
171 * @param data Data to send
172 * @param size Size of the data to send
173 * @param sent Number of bytes sent (can be NULL to ignore)
174 *
175 * @return SERVICE_E_SUCCESS on success,
176 * SERVICE_E_INVALID_ARG when one or more parameters are
177 * invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified
178 * error occurs.
179 */
180service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent) 131service_error_t service_send(service_client_t client, const char* data, uint32_t size, uint32_t *sent)
181{ 132{
182 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 133 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -198,21 +149,6 @@ service_error_t service_send(service_client_t client, const char* data, uint32_t
198 return res; 149 return res;
199} 150}
200 151
201/**
202 * Receives data using the given service client with specified timeout.
203 *
204 * @param client The service client to use for receiving
205 * @param data Buffer that will be filled with the data received
206 * @param size Number of bytes to receive
207 * @param received Number of bytes received (can be NULL to ignore)
208 * @param timeout Maximum time in milliseconds to wait for data.
209 *
210 * @return SERVICE_E_SUCCESS on success,
211 * SERVICE_E_INVALID_ARG when one or more parameters are
212 * invalid, SERVICE_E_MUX_ERROR when a communication error
213 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
214 * error occurs.
215 */
216service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout) 152service_error_t service_receive_with_timeout(service_client_t client, char* data, uint32_t size, uint32_t *received, unsigned int timeout)
217{ 153{
218 service_error_t res = SERVICE_E_UNKNOWN_ERROR; 154 service_error_t res = SERVICE_E_UNKNOWN_ERROR;
@@ -233,35 +169,11 @@ service_error_t service_receive_with_timeout(service_client_t client, char* data
233 return res; 169 return res;
234} 170}
235 171
236/**
237 * Receives data using the given service client.
238 *
239 * @param client The service client to use for receiving
240 * @param data Buffer that will be filled with the data received
241 * @param size Number of bytes to receive
242 * @param received Number of bytes received (can be NULL to ignore)
243 *
244 * @return SERVICE_E_SUCCESS on success,
245 * SERVICE_E_INVALID_ARG when one or more parameters are
246 * invalid, SERVICE_E_MUX_ERROR when a communication error
247 * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified
248 * error occurs.
249 */
250service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received) 172service_error_t service_receive(service_client_t client, char* data, uint32_t size, uint32_t *received)
251{ 173{
252 return service_receive_with_timeout(client, data, size, received, 10000); 174 return service_receive_with_timeout(client, data, size, received, 10000);
253} 175}
254 176
255/**
256 * Enable SSL for the given service client.
257 *
258 * @param client The connected service client for that SSL should be enabled.
259 *
260 * @return SERVICE_E_SUCCESS on success,
261 * SERVICE_E_INVALID_ARG if client or client->connection is
262 * NULL, SERVICE_E_SSL_ERROR when SSL could not be enabled,
263 * or SERVICE_E_UNKNOWN_ERROR otherwise.
264 */
265service_error_t service_enable_ssl(service_client_t client) 177service_error_t service_enable_ssl(service_client_t client)
266{ 178{
267 if (!client || !client->connection) 179 if (!client || !client->connection)
@@ -269,15 +181,6 @@ service_error_t service_enable_ssl(service_client_t client)
269 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection)); 181 return idevice_to_service_error(idevice_connection_enable_ssl(client->connection));
270} 182}
271 183
272/**
273 * Disable SSL for the given service client.
274 *
275 * @param client The connected service client for that SSL should be disabled.
276 *
277 * @return SERVICE_E_SUCCESS on success,
278 * SERVICE_E_INVALID_ARG if client or client->connection is
279 * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise.
280 */
281service_error_t service_disable_ssl(service_client_t client) 184service_error_t service_disable_ssl(service_client_t client)
282{ 185{
283 if (!client || !client->connection) 186 if (!client || !client->connection)