summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2013-02-26 03:20:56 +0100
committerGravatar Martin Szulecki2013-02-26 03:20:56 +0100
commitfcc1bb855efb6860417ed827d3b50feba24a9a8b (patch)
tree47d3c7d6a985dc647f7962329014c8116d657cc9 /src
parent3b54aac30447bc02fafd721a63a752968628e7e0 (diff)
downloadlibimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.gz
libimobiledevice-fcc1bb855efb6860417ed827d3b50feba24a9a8b.tar.bz2
Refactor port number use into service descriptor to enable SSL for services
This is a major change which breaks API but is required in order to support SSL communication for services as used by network connections.
Diffstat (limited to 'src')
-rw-r--r--src/afc.c12
-rw-r--r--src/device_link_service.c12
-rw-r--r--src/device_link_service.h2
-rw-r--r--src/diagnostics_relay.c8
-rw-r--r--src/file_relay.c8
-rw-r--r--src/house_arrest.c6
-rw-r--r--src/installation_proxy.c6
-rw-r--r--src/lockdown.c58
-rw-r--r--src/misagent.c6
-rw-r--r--src/mobile_image_mounter.c6
-rw-r--r--src/mobilebackup.c8
-rw-r--r--src/mobilebackup2.c8
-rw-r--r--src/mobilesync.c8
-rw-r--r--src/notification_proxy.c6
-rw-r--r--src/property_list_service.c15
-rw-r--r--src/property_list_service.h3
-rw-r--r--src/restore.c7
-rw-r--r--src/sbservices.c6
-rw-r--r--src/screenshotr.c8
-rw-r--r--src/webinspector.c27
20 files changed, 138 insertions, 82 deletions
diff --git a/src/afc.c b/src/afc.c
index b405d52..b5228aa 100644
--- a/src/afc.c
+++ b/src/afc.c
@@ -119,7 +119,7 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
* @see afc_client_new_from_connection
*
* @param device The device to connect to.
- * @param port The destination port.
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated afc_client_t
* upon successful return.
*
@@ -127,17 +127,21 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
* invalid, AFC_E_MUX_ERROR if the connection cannot be established,
* or AFC_E_NO_MEM if there is a memory allocation problem.
*/
-afc_error_t afc_client_new(idevice_t device, uint16_t port, afc_client_t * client)
+afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
{
- if (!device || port==0)
+ if (!device || service->port == 0)
return AFC_E_INVALID_ARG;
/* attempt connection */
idevice_connection_t connection = NULL;
- if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) {
+ if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
return AFC_E_MUX_ERROR;
}
+ /* enable SSL if requested */
+ if (service->ssl_enabled)
+ idevice_connection_enable_ssl(connection);
+
afc_error_t err = afc_client_new_from_connection(connection, client);
if (err != AFC_E_SUCCESS) {
idevice_disconnect(connection);
diff --git a/src/device_link_service.c b/src/device_link_service.c
index 5825f0c..ac89211 100644
--- a/src/device_link_service.c
+++ b/src/device_link_service.c
@@ -74,7 +74,7 @@ static int device_link_service_get_message(plist_t dl_msg, char **message)
* Creates a new device link service client.
*
* @param device The device to connect to.
- * @param port Port on device to connect to.
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Reference that will point to a newly allocated
* device_link_service_client_t upon successful return.
*
@@ -82,14 +82,14 @@ static int device_link_service_get_message(plist_t dl_msg, char **message)
* DEVICE_LINK_SERVICE_E_INVALID_ARG when one of the parameters is invalid,
* or DEVICE_LINK_SERVICE_E_MUX_ERROR when the connection failed.
*/
-device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client)
+device_link_service_error_t device_link_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, device_link_service_client_t *client)
{
- if (!device || port == 0 || !client || *client) {
+ if (!device || service->port == 0 || !client || *client) {
return DEVICE_LINK_SERVICE_E_INVALID_ARG;
}
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return DEVICE_LINK_SERVICE_E_MUX_ERROR;
}
@@ -97,6 +97,10 @@ device_link_service_error_t device_link_service_client_new(idevice_t device, uin
device_link_service_client_t client_loc = (device_link_service_client_t) malloc(sizeof(struct device_link_service_client_private));
client_loc->parent = plistclient;
+ /* enable SSL if requested */
+ if (service->ssl_enabled)
+ property_list_service_enable_ssl(client_loc->parent);
+
/* all done, return success */
*client = client_loc;
return DEVICE_LINK_SERVICE_E_SUCCESS;
diff --git a/src/device_link_service.h b/src/device_link_service.h
index 8589428..d625341 100644
--- a/src/device_link_service.h
+++ b/src/device_link_service.h
@@ -41,7 +41,7 @@ struct device_link_service_client_private {
typedef struct device_link_service_client_private *device_link_service_client_t;
-device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client);
+device_link_service_error_t device_link_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, device_link_service_client_t *client);
device_link_service_error_t device_link_service_client_free(device_link_service_client_t client);
device_link_service_error_t device_link_service_version_exchange(device_link_service_client_t client, uint64_t version_major, uint64_t version_minor);
device_link_service_error_t device_link_service_send_ping(device_link_service_client_t client, const char *message);
diff --git a/src/diagnostics_relay.c b/src/diagnostics_relay.c
index 7178952..3469ae4 100644
--- a/src/diagnostics_relay.c
+++ b/src/diagnostics_relay.c
@@ -73,7 +73,7 @@ static int diagnostics_relay_check_result(plist_t dict)
* Connects to the diagnostics_relay service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Reference that will point to a newly allocated
* diagnostics_relay_client_t upon successful return.
*
@@ -81,14 +81,14 @@ static int diagnostics_relay_check_result(plist_t dict)
* DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
* or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
*/
-diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, uint16_t port, diagnostics_relay_client_t *client)
+diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
{
- if (!device || port == 0 || !client || *client) {
+ if (!device || service->port == 0 || !client || *client) {
return DIAGNOSTICS_RELAY_E_INVALID_ARG;
}
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return DIAGNOSTICS_RELAY_E_MUX_ERROR;
}
diff --git a/src/file_relay.c b/src/file_relay.c
index 680e28d..e72be66 100644
--- a/src/file_relay.c
+++ b/src/file_relay.c
@@ -28,7 +28,7 @@
* Connects to the file_relay service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Reference that will point to a newly allocated
* file_relay_client_t upon successful return.
*
@@ -36,14 +36,14 @@
* FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
* or FILE_RELAY_E_MUX_ERROR when the connection failed.
*/
-file_relay_error_t file_relay_client_new(idevice_t device, uint16_t port, file_relay_client_t *client)
+file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
{
- if (!device || port == 0 || !client || *client) {
+ if (!device || service->port == 0 || !client || *client) {
return FILE_RELAY_E_INVALID_ARG;
}
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return FILE_RELAY_E_MUX_ERROR;
}
diff --git a/src/house_arrest.c b/src/house_arrest.c
index 5baa76e..e0d7771 100644
--- a/src/house_arrest.c
+++ b/src/house_arrest.c
@@ -59,20 +59,20 @@ static house_arrest_error_t house_arrest_error(property_list_service_error_t err
* Connects to the house_arrest service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will point to a newly allocated
* housearrest_client_t upon successful return.
*
* @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
* client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
*/
-house_arrest_error_t house_arrest_client_new(idevice_t device, uint16_t port, house_arrest_client_t *client)
+house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
{
if (!device)
return HOUSE_ARREST_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- house_arrest_error_t err = house_arrest_error(property_list_service_client_new(device, port, &plistclient));
+ house_arrest_error_t err = house_arrest_error(property_list_service_client_new(device, service, &plistclient));
if (err != HOUSE_ARREST_E_SUCCESS) {
return err;
}
diff --git a/src/installation_proxy.c b/src/installation_proxy.c
index bab6ab2..eacab9d 100644
--- a/src/installation_proxy.c
+++ b/src/installation_proxy.c
@@ -95,20 +95,20 @@ static instproxy_error_t instproxy_error(property_list_service_error_t err)
* Connects to the installation_proxy service on the specified device.
*
* @param device The device to connect to
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* instproxy_client_t upon successful return.
*
* @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
* when an error occured.
*/
-instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client)
+instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
{
if (!device)
return INSTPROXY_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return INSTPROXY_E_CONN_FAILED;
}
diff --git a/src/lockdown.c b/src/lockdown.c
index e899baa..df1f60f 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -646,8 +646,13 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli
if (!client)
return LOCKDOWN_E_INVALID_ARG;
+ static struct lockdownd_service_descriptor service = {
+ .port = 0xf27e,
+ .ssl_enabled = 0
+ };
+
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
debug_info("could not connect to lockdownd (device %s)", device->udid);
return LOCKDOWN_E_MUX_ERROR;
}
@@ -1494,17 +1499,17 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
* Requests to start a service and retrieve it's port on success.
*
* @param client The lockdownd client
- * @param service The name of the service to start
- * @param port The port number the service was started on
+ * @param identifier The identifier of the service to start
+ * @param descriptor The service descriptor on success or NULL on failure
* @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
* is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
* by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
* started by the device
*/
-lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *service, uint16_t *port)
+lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
{
- if (!client || !service || !port)
+ if (!client || !identifier || !service)
return LOCKDOWN_E_INVALID_ARG;
char *host_id = NULL;
@@ -1524,7 +1529,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
dict = plist_new_dict();
plist_dict_add_label(dict, client->label);
plist_dict_insert_item(dict,"Request", plist_new_string("StartService"));
- plist_dict_insert_item(dict,"Service", plist_new_string(service));
+ plist_dict_insert_item(dict,"Service", plist_new_string(identifier));
/* send to device */
ret = lockdownd_send(client, dict);
@@ -1542,20 +1547,34 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
if (!dict)
return LOCKDOWN_E_PLIST_ERROR;
+ if (*service == NULL)
+ *service = (lockdownd_service_descriptor_t)malloc(sizeof(struct lockdownd_service_descriptor));
+ (*service)->port = 0;
+ (*service)->ssl_enabled = 0;
+
ret = LOCKDOWN_E_UNKNOWN_ERROR;
if (lockdown_check_result(dict, "StartService") == RESULT_SUCCESS) {
- plist_t port_value_node = plist_dict_get_item(dict, "Port");
-
- if (port_value_node && (plist_get_node_type(port_value_node) == PLIST_UINT)) {
+ /* read service port number */
+ plist_t node = plist_dict_get_item(dict, "Port");
+ if (node && (plist_get_node_type(node) == PLIST_UINT)) {
uint64_t port_value = 0;
- plist_get_uint_val(port_value_node, &port_value);
+ plist_get_uint_val(node, &port_value);
if (port_value) {
port_loc = port_value;
ret = LOCKDOWN_E_SUCCESS;
}
- if (port && ret == LOCKDOWN_E_SUCCESS)
- *port = port_loc;
+ if (port_loc && ret == LOCKDOWN_E_SUCCESS) {
+ (*service)->port = port_loc;
+ }
+ }
+
+ /* check if the service requires SSL */
+ node = plist_dict_get_item(dict, "EnableServiceSSL");
+ if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) {
+ uint8_t b = 0;
+ plist_get_bool_val(node, &b);
+ (*service)->ssl_enabled = b;
}
} else {
ret = LOCKDOWN_E_START_SERVICE_FAILED;
@@ -1785,3 +1804,18 @@ lockdownd_error_t lockdownd_data_classes_free(char **classes)
}
return LOCKDOWN_E_SUCCESS;
}
+
+/**
+ * Frees memory of a service descriptor as returned by lockdownd_start_service()
+ *
+ * @param sevice A service descriptor instance to free.
+ *
+ * @return LOCKDOWN_E_SUCCESS on success
+ */
+lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
+{
+ if (service)
+ free(service);
+
+ return LOCKDOWN_E_SUCCESS;
+}
diff --git a/src/misagent.c b/src/misagent.c
index 45f1391..c624603 100644
--- a/src/misagent.c
+++ b/src/misagent.c
@@ -91,20 +91,20 @@ static misagent_error_t misagent_check_result(plist_t response, int* status_code
* Connects to the misagent service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will point to a newly allocated
* misagent_client_t upon successful return.
*
* @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
* client is NULL, or an MISAGENT_E_* error code otherwise.
*/
-misagent_error_t misagent_client_new(idevice_t device, uint16_t port, misagent_client_t *client)
+misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
{
if (!device)
return MISAGENT_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- misagent_error_t err = misagent_error(property_list_service_client_new(device, port, &plistclient));
+ misagent_error_t err = misagent_error(property_list_service_client_new(device, service, &plistclient));
if (err != MISAGENT_E_SUCCESS) {
return err;
}
diff --git a/src/mobile_image_mounter.c b/src/mobile_image_mounter.c
index 557fbda..3e31ef4 100644
--- a/src/mobile_image_mounter.c
+++ b/src/mobile_image_mounter.c
@@ -87,7 +87,7 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
* Connects to the mobile_image_mounter service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* mobile_image_mounter_client_t upon successful return.
*
@@ -96,13 +96,13 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
* or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
* device could not be established.
*/
-mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t port, mobile_image_mounter_client_t *client)
+mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
{
if (!device)
return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return MOBILE_IMAGE_MOUNTER_E_CONN_FAILED;
}
diff --git a/src/mobilebackup.c b/src/mobilebackup.c
index 78f9a5c..ab4dec0 100644
--- a/src/mobilebackup.c
+++ b/src/mobilebackup.c
@@ -64,7 +64,7 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
* Connects to the mobilebackup service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* mobilebackup_client_t upon successful return.
*
@@ -72,14 +72,14 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
* or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
* the mobilebackup version on the device is newer.
*/
-mobilebackup_error_t mobilebackup_client_new(idevice_t device, uint16_t port,
+mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service,
mobilebackup_client_t * client)
{
- if (!device || port == 0 || !client || *client)
+ if (!device || service->port == 0 || !client || *client)
return MOBILEBACKUP_E_INVALID_ARG;
device_link_service_client_t dlclient = NULL;
- mobilebackup_error_t ret = mobilebackup_error(device_link_service_client_new(device, port, &dlclient));
+ mobilebackup_error_t ret = mobilebackup_error(device_link_service_client_new(device, service, &dlclient));
if (ret != MOBILEBACKUP_E_SUCCESS) {
return ret;
}
diff --git a/src/mobilebackup2.c b/src/mobilebackup2.c
index 2089c87..bcf5944 100644
--- a/src/mobilebackup2.c
+++ b/src/mobilebackup2.c
@@ -65,7 +65,7 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
* Connects to the mobilebackup2 service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* mobilebackup2_client_t upon successful return.
*
@@ -73,14 +73,14 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
* if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
* if the mobilebackup2 version on the device is newer.
*/
-mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, uint16_t port,
+mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
mobilebackup2_client_t * client)
{
- if (!device || port == 0 || !client || *client)
+ if (!device || service->port == 0 || !client || *client)
return MOBILEBACKUP2_E_INVALID_ARG;
device_link_service_client_t dlclient = NULL;
- mobilebackup2_error_t ret = mobilebackup2_error(device_link_service_client_new(device, port, &dlclient));
+ mobilebackup2_error_t ret = mobilebackup2_error(device_link_service_client_new(device, service, &dlclient));
if (ret != MOBILEBACKUP2_E_SUCCESS) {
return ret;
}
diff --git a/src/mobilesync.c b/src/mobilesync.c
index 39b1da8..4fe24b2 100644
--- a/src/mobilesync.c
+++ b/src/mobilesync.c
@@ -69,7 +69,7 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
* Connects to the mobilesync service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service()).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* #mobilesync_client_t upon successful return.
*
@@ -78,14 +78,14 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
* @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
* the device is newer.
*/
-mobilesync_error_t mobilesync_client_new(idevice_t device, uint16_t port,
+mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
mobilesync_client_t * client)
{
- if (!device || port == 0 || !client || *client)
+ if (!device || service->port == 0 || !client || *client)
return MOBILESYNC_E_INVALID_ARG;
device_link_service_client_t dlclient = NULL;
- mobilesync_error_t ret = mobilesync_error(device_link_service_client_new(device, port, &dlclient));
+ mobilesync_error_t ret = mobilesync_error(device_link_service_client_new(device, service, &dlclient));
if (ret != MOBILESYNC_E_SUCCESS) {
return ret;
}
diff --git a/src/notification_proxy.c b/src/notification_proxy.c
index 6e09840..8fb9ad0 100644
--- a/src/notification_proxy.c
+++ b/src/notification_proxy.c
@@ -98,7 +98,7 @@ static np_error_t np_error(property_list_service_error_t err)
* Connects to the notification_proxy on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated np_client_t
* upon successful return.
*
@@ -106,13 +106,13 @@ static np_error_t np_error(property_list_service_error_t err)
* or NP_E_CONN_FAILED when the connection to the device could not be
* established.
*/
-np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client)
+np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
{
if (!device)
return NP_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
return NP_E_CONN_FAILED;
}
diff --git a/src/property_list_service.c b/src/property_list_service.c
index c9a8edf..15adbc8 100644
--- a/src/property_list_service.c
+++ b/src/property_list_service.c
@@ -57,8 +57,7 @@ static property_list_service_error_t idevice_to_property_list_service_error(idev
* Creates a new property list service for the specified port.
*
* @param device The device to connect to.
- * @param port The port on the device to connect to, usually opened by a call to
- * lockdownd_start_service.
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* property_list_service_client_t upon successful return.
*
@@ -66,14 +65,14 @@ static property_list_service_error_t idevice_to_property_list_service_error(idev
* PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
* or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
*/
-property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, 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 || port == 0 || !client || *client)
+ if (!device || (service->port == 0) || !client || *client)
return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
/* Attempt connection */
idevice_connection_t connection = NULL;
- if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) {
+ if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
return PROPERTY_LIST_SERVICE_E_MUX_ERROR;
}
@@ -81,8 +80,12 @@ property_list_service_error_t property_list_service_client_new(idevice_t device,
property_list_service_client_t client_loc = (property_list_service_client_t)malloc(sizeof(struct property_list_service_client_private));
client_loc->connection = connection;
- *client = client_loc;
+ /* enable SSL if requested */
+ if (service->ssl_enabled == 1)
+ property_list_service_enable_ssl(client_loc);
+ /* all done, return success */
+ *client = client_loc;
return PROPERTY_LIST_SERVICE_E_SUCCESS;
}
diff --git a/src/property_list_service.h b/src/property_list_service.h
index 037f9aa..db1c09d 100644
--- a/src/property_list_service.h
+++ b/src/property_list_service.h
@@ -21,6 +21,7 @@
#ifndef PROPERTY_LIST_SERVICE_H
#define PROPERTY_LIST_SERVICE_H
+#include <libimobiledevice/lockdown.h>
#include "idevice.h"
/* Error Codes */
@@ -41,7 +42,7 @@ typedef struct property_list_service_client_private *property_list_service_clien
typedef int16_t property_list_service_error_t;
/* creation and destruction */
-property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, 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);
property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
/* sending */
diff --git a/src/restore.c b/src/restore.c
index 3474091..1b2ff78 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -368,8 +368,13 @@ restored_error_t restored_client_new(idevice_t device, restored_client_t *client
restored_error_t ret = RESTORE_E_SUCCESS;
+ static struct lockdownd_service_descriptor service = {
+ .port = 0xf27e,
+ .ssl_enabled = 0
+ };
+
property_list_service_client_t plistclient = NULL;
- if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
+ if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
debug_info("could not connect to restored (device %s)", device->udid);
return RESTORE_E_MUX_ERROR;
}
diff --git a/src/sbservices.c b/src/sbservices.c
index 2c17d8c..6b1a4d1 100644
--- a/src/sbservices.c
+++ b/src/sbservices.c
@@ -88,20 +88,20 @@ static sbservices_error_t sbservices_error(property_list_service_error_t err)
* Connects to the springboardservices service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will point to a newly allocated
* sbservices_client_t upon successful return.
*
* @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
* client is NULL, or an SBSERVICES_E_* error code otherwise.
*/
-sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client)
+sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
{
if (!device)
return SBSERVICES_E_INVALID_ARG;
property_list_service_client_t plistclient = NULL;
- sbservices_error_t err = sbservices_error(property_list_service_client_new(device, port, &plistclient));
+ sbservices_error_t err = sbservices_error(property_list_service_client_new(device, service, &plistclient));
if (err != SBSERVICES_E_SUCCESS) {
return err;
}
diff --git a/src/screenshotr.c b/src/screenshotr.c
index 063d282..e2bc979 100644
--- a/src/screenshotr.c
+++ b/src/screenshotr.c
@@ -62,7 +62,7 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
* Connects to the screenshotr service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will be set to a newly allocated
* screenshotr_client_t upon successful return.
*
@@ -73,14 +73,14 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
* or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
* connection to the device could not be established.
*/
-screenshotr_error_t screenshotr_client_new(idevice_t device, uint16_t port,
+screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
screenshotr_client_t * client)
{
- if (!device || port == 0 || !client || *client)
+ if (!device || service->port == 0 || !client || *client)
return SCREENSHOTR_E_INVALID_ARG;
device_link_service_client_t dlclient = NULL;
- screenshotr_error_t ret = screenshotr_error(device_link_service_client_new(device, port, &dlclient));
+ screenshotr_error_t ret = screenshotr_error(device_link_service_client_new(device, service, &dlclient));
if (ret != SCREENSHOTR_E_SUCCESS) {
return ret;
}
diff --git a/src/webinspector.c b/src/webinspector.c
index c3d57cc..eb12d4d 100644
--- a/src/webinspector.c
+++ b/src/webinspector.c
@@ -62,7 +62,7 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
* Connects to the webinspector service on the specified device.
*
* @param device The device to connect to.
- * @param port Destination port (usually given by lockdownd_start_service).
+ * @param service The service descriptor returned by lockdownd_start_service.
* @param client Pointer that will point to a newly allocated
* webinspector_client_t upon successful return. Must be freed using
* webinspector_client_free() after use.
@@ -70,19 +70,19 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
* @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
* client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
*/
-webinspector_error_t webinspector_client_new(idevice_t device, uint16_t port, webinspector_client_t * client)
+webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
{
*client = NULL;
- debug_info("Creating webinspector_client, port = %d.", port);
+ debug_info("Creating webinspector_client, port = %d.", service->port);
- if (!device || port == 0 || !client || *client) {
+ if (!device || service->port == 0 || !client || *client) {
debug_info("Incorrect parameter passed to webinspector_client_new.");
return WEBINSPECTOR_E_INVALID_ARG;
}
property_list_service_client_t plclient = NULL;
- webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, port, &plclient));
+ webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, service, &plclient));
if (ret != WEBINSPECTOR_E_SUCCESS) {
debug_info("Creating a property list client failed. Error: %i", ret);
return ret;
@@ -118,22 +118,27 @@ webinspector_error_t webinspector_start_service(idevice_t device, webinspector_c
debug_info("Could not create a lockdown client.");
return WEBINSPECTOR_E_UNKNOWN_ERROR;
}
-
- uint16_t port = 0;
- lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &port);
+
+ lockdownd_service_descriptor_t service = NULL;
+ lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &service);
lockdownd_client_free(lckd);
- if (port <= 0) {
+ if (service->port <= 0) {
debug_info("Could not start webinspector service!");
return WEBINSPECTOR_E_UNKNOWN_ERROR;
}
- webinspector_error_t res = webinspector_client_new(device, port, client);
+ webinspector_error_t res = webinspector_client_new(device, service, client);
if (res != WEBINSPECTOR_E_SUCCESS) {
- debug_info("Could not connect to webinspector! Port: %i, error: %i", port, res);
+ debug_info("Could not connect to webinspector! Port: %i, error: %i", service->port, res);
return res;
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
return WEBINSPECTOR_E_SUCCESS;
}