summaryrefslogtreecommitdiffstats
path: root/src/property_list_service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/property_list_service.c')
-rw-r--r--src/property_list_service.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/property_list_service.c b/src/property_list_service.c
index 1cb8dc9..2fca4e7 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -58,7 +58,7 @@ static property_list_service_error_t service_to_property_list_service_error(serv
return PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
+property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
{
if (!device || !service || service->port == 0 || !client || *client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
@@ -78,7 +78,7 @@ LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_
return PROPERTY_LIST_SERVICE_E_SUCCESS;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_free(property_list_service_client_t client)
+property_list_service_error_t property_list_service_client_free(property_list_service_client_t client)
{
if (!client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
@@ -152,12 +152,12 @@ static property_list_service_error_t internal_plist_send(property_list_service_c
return res;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist)
+property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist)
{
return internal_plist_send(client, plist, 0);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist)
+property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist)
{
return internal_plist_send(client, plist, 1);
}
@@ -197,6 +197,11 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
return service_to_property_list_service_error(serr);
}
+ if (bytes == 0) {
+ /* success but 0 bytes length, assume timeout */
+ return PROPERTY_LIST_SERVICE_E_RECEIVE_TIMEOUT;
+ }
+
debug_info("initial read=%i", bytes);
uint32_t curlen = 0;
@@ -219,6 +224,7 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
debug_info("received %d bytes", bytes);
curlen += bytes;
}
+
if (curlen < pktlen) {
debug_info("received incomplete packet (%d of %d bytes)", curlen, pktlen);
if (curlen > 0) {
@@ -228,6 +234,7 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
free(content);
return res;
}
+
if ((pktlen > 8) && !memcmp(content, "bplist00", 8)) {
plist_from_bin(content, pktlen, plist);
} else if ((pktlen > 5) && !memcmp(content, "<?xml", 5)) {
@@ -241,39 +248,48 @@ static property_list_service_error_t internal_plist_receive_timeout(property_lis
debug_info("WARNING: received unexpected non-plist content");
debug_buffer(content, pktlen);
}
+
if (*plist) {
debug_plist(*plist);
res = PROPERTY_LIST_SERVICE_E_SUCCESS;
} else {
res = PROPERTY_LIST_SERVICE_E_PLIST_ERROR;
}
+
free(content);
content = NULL;
-
+
return res;
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout)
+property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout)
{
return internal_plist_receive_timeout(client, plist, timeout);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist)
+property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist)
{
- return internal_plist_receive_timeout(client, plist, 10000);
+ return internal_plist_receive_timeout(client, plist, 30000);
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client)
+property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client)
{
if (!client || !client->parent)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
return service_to_property_list_service_error(service_enable_ssl(client->parent));
}
-LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client)
+property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client)
{
if (!client || !client->parent)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
return service_to_property_list_service_error(service_disable_ssl(client->parent));
}
+property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client)
+{
+ if (!client || !client->parent || !service_client)
+ return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
+ *service_client = client->parent;
+ return PROPERTY_LIST_SERVICE_E_SUCCESS;
+}