summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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_
119 * @see afc_client_new_from_connection 119 * @see afc_client_new_from_connection
120 * 120 *
121 * @param device The device to connect to. 121 * @param device The device to connect to.
122 * @param port The destination port. 122 * @param service The service descriptor returned by lockdownd_start_service.
123 * @param client Pointer that will be set to a newly allocated afc_client_t 123 * @param client Pointer that will be set to a newly allocated afc_client_t
124 * upon successful return. 124 * upon successful return.
125 * 125 *
@@ -127,17 +127,21 @@ afc_error_t afc_client_new_from_connection(idevice_connection_t connection, afc_
127 * invalid, AFC_E_MUX_ERROR if the connection cannot be established, 127 * invalid, AFC_E_MUX_ERROR if the connection cannot be established,
128 * or AFC_E_NO_MEM if there is a memory allocation problem. 128 * or AFC_E_NO_MEM if there is a memory allocation problem.
129 */ 129 */
130afc_error_t afc_client_new(idevice_t device, uint16_t port, afc_client_t * client) 130afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t * client)
131{ 131{
132 if (!device || port==0) 132 if (!device || service->port == 0)
133 return AFC_E_INVALID_ARG; 133 return AFC_E_INVALID_ARG;
134 134
135 /* attempt connection */ 135 /* attempt connection */
136 idevice_connection_t connection = NULL; 136 idevice_connection_t connection = NULL;
137 if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) { 137 if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
138 return AFC_E_MUX_ERROR; 138 return AFC_E_MUX_ERROR;
139 } 139 }
140 140
141 /* enable SSL if requested */
142 if (service->ssl_enabled)
143 idevice_connection_enable_ssl(connection);
144
141 afc_error_t err = afc_client_new_from_connection(connection, client); 145 afc_error_t err = afc_client_new_from_connection(connection, client);
142 if (err != AFC_E_SUCCESS) { 146 if (err != AFC_E_SUCCESS) {
143 idevice_disconnect(connection); 147 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)
74 * Creates a new device link service client. 74 * Creates a new device link service client.
75 * 75 *
76 * @param device The device to connect to. 76 * @param device The device to connect to.
77 * @param port Port on device to connect to. 77 * @param service The service descriptor returned by lockdownd_start_service.
78 * @param client Reference that will point to a newly allocated 78 * @param client Reference that will point to a newly allocated
79 * device_link_service_client_t upon successful return. 79 * device_link_service_client_t upon successful return.
80 * 80 *
@@ -82,14 +82,14 @@ static int device_link_service_get_message(plist_t dl_msg, char **message)
82 * DEVICE_LINK_SERVICE_E_INVALID_ARG when one of the parameters is invalid, 82 * DEVICE_LINK_SERVICE_E_INVALID_ARG when one of the parameters is invalid,
83 * or DEVICE_LINK_SERVICE_E_MUX_ERROR when the connection failed. 83 * or DEVICE_LINK_SERVICE_E_MUX_ERROR when the connection failed.
84 */ 84 */
85device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client) 85device_link_service_error_t device_link_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, device_link_service_client_t *client)
86{ 86{
87 if (!device || port == 0 || !client || *client) { 87 if (!device || service->port == 0 || !client || *client) {
88 return DEVICE_LINK_SERVICE_E_INVALID_ARG; 88 return DEVICE_LINK_SERVICE_E_INVALID_ARG;
89 } 89 }
90 90
91 property_list_service_client_t plistclient = NULL; 91 property_list_service_client_t plistclient = NULL;
92 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 92 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
93 return DEVICE_LINK_SERVICE_E_MUX_ERROR; 93 return DEVICE_LINK_SERVICE_E_MUX_ERROR;
94 } 94 }
95 95
@@ -97,6 +97,10 @@ device_link_service_error_t device_link_service_client_new(idevice_t device, uin
97 device_link_service_client_t client_loc = (device_link_service_client_t) malloc(sizeof(struct device_link_service_client_private)); 97 device_link_service_client_t client_loc = (device_link_service_client_t) malloc(sizeof(struct device_link_service_client_private));
98 client_loc->parent = plistclient; 98 client_loc->parent = plistclient;
99 99
100 /* enable SSL if requested */
101 if (service->ssl_enabled)
102 property_list_service_enable_ssl(client_loc->parent);
103
100 /* all done, return success */ 104 /* all done, return success */
101 *client = client_loc; 105 *client = client_loc;
102 return DEVICE_LINK_SERVICE_E_SUCCESS; 106 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 {
41 41
42typedef struct device_link_service_client_private *device_link_service_client_t; 42typedef struct device_link_service_client_private *device_link_service_client_t;
43 43
44device_link_service_error_t device_link_service_client_new(idevice_t device, uint16_t port, device_link_service_client_t *client); 44device_link_service_error_t device_link_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, device_link_service_client_t *client);
45device_link_service_error_t device_link_service_client_free(device_link_service_client_t client); 45device_link_service_error_t device_link_service_client_free(device_link_service_client_t client);
46device_link_service_error_t device_link_service_version_exchange(device_link_service_client_t client, uint64_t version_major, uint64_t version_minor); 46device_link_service_error_t device_link_service_version_exchange(device_link_service_client_t client, uint64_t version_major, uint64_t version_minor);
47device_link_service_error_t device_link_service_send_ping(device_link_service_client_t client, const char *message); 47device_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)
73 * Connects to the diagnostics_relay service on the specified device. 73 * Connects to the diagnostics_relay service on the specified device.
74 * 74 *
75 * @param device The device to connect to. 75 * @param device The device to connect to.
76 * @param port Destination port (usually given by lockdownd_start_service). 76 * @param service The service descriptor returned by lockdownd_start_service.
77 * @param client Reference that will point to a newly allocated 77 * @param client Reference that will point to a newly allocated
78 * diagnostics_relay_client_t upon successful return. 78 * diagnostics_relay_client_t upon successful return.
79 * 79 *
@@ -81,14 +81,14 @@ static int diagnostics_relay_check_result(plist_t dict)
81 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid, 81 * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid,
82 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed. 82 * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed.
83 */ 83 */
84diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, uint16_t port, diagnostics_relay_client_t *client) 84diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client)
85{ 85{
86 if (!device || port == 0 || !client || *client) { 86 if (!device || service->port == 0 || !client || *client) {
87 return DIAGNOSTICS_RELAY_E_INVALID_ARG; 87 return DIAGNOSTICS_RELAY_E_INVALID_ARG;
88 } 88 }
89 89
90 property_list_service_client_t plistclient = NULL; 90 property_list_service_client_t plistclient = NULL;
91 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 91 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
92 return DIAGNOSTICS_RELAY_E_MUX_ERROR; 92 return DIAGNOSTICS_RELAY_E_MUX_ERROR;
93 } 93 }
94 94
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 @@
28 * Connects to the file_relay service on the specified device. 28 * Connects to the file_relay service on the specified device.
29 * 29 *
30 * @param device The device to connect to. 30 * @param device The device to connect to.
31 * @param port Destination port (usually given by lockdownd_start_service). 31 * @param service The service descriptor returned by lockdownd_start_service.
32 * @param client Reference that will point to a newly allocated 32 * @param client Reference that will point to a newly allocated
33 * file_relay_client_t upon successful return. 33 * file_relay_client_t upon successful return.
34 * 34 *
@@ -36,14 +36,14 @@
36 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid, 36 * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid,
37 * or FILE_RELAY_E_MUX_ERROR when the connection failed. 37 * or FILE_RELAY_E_MUX_ERROR when the connection failed.
38 */ 38 */
39file_relay_error_t file_relay_client_new(idevice_t device, uint16_t port, file_relay_client_t *client) 39file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client)
40{ 40{
41 if (!device || port == 0 || !client || *client) { 41 if (!device || service->port == 0 || !client || *client) {
42 return FILE_RELAY_E_INVALID_ARG; 42 return FILE_RELAY_E_INVALID_ARG;
43 } 43 }
44 44
45 property_list_service_client_t plistclient = NULL; 45 property_list_service_client_t plistclient = NULL;
46 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 46 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
47 return FILE_RELAY_E_MUX_ERROR; 47 return FILE_RELAY_E_MUX_ERROR;
48 } 48 }
49 49
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
59 * Connects to the house_arrest service on the specified device. 59 * Connects to the house_arrest service on the specified device.
60 * 60 *
61 * @param device The device to connect to. 61 * @param device The device to connect to.
62 * @param port Destination port (usually given by lockdownd_start_service). 62 * @param service The service descriptor returned by lockdownd_start_service.
63 * @param client Pointer that will point to a newly allocated 63 * @param client Pointer that will point to a newly allocated
64 * housearrest_client_t upon successful return. 64 * housearrest_client_t upon successful return.
65 * 65 *
66 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when 66 * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when
67 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise. 67 * client is NULL, or an HOUSE_ARREST_E_* error code otherwise.
68 */ 68 */
69house_arrest_error_t house_arrest_client_new(idevice_t device, uint16_t port, house_arrest_client_t *client) 69house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client)
70{ 70{
71 if (!device) 71 if (!device)
72 return HOUSE_ARREST_E_INVALID_ARG; 72 return HOUSE_ARREST_E_INVALID_ARG;
73 73
74 property_list_service_client_t plistclient = NULL; 74 property_list_service_client_t plistclient = NULL;
75 house_arrest_error_t err = house_arrest_error(property_list_service_client_new(device, port, &plistclient)); 75 house_arrest_error_t err = house_arrest_error(property_list_service_client_new(device, service, &plistclient));
76 if (err != HOUSE_ARREST_E_SUCCESS) { 76 if (err != HOUSE_ARREST_E_SUCCESS) {
77 return err; 77 return err;
78 } 78 }
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)
95 * Connects to the installation_proxy service on the specified device. 95 * Connects to the installation_proxy service on the specified device.
96 * 96 *
97 * @param device The device to connect to 97 * @param device The device to connect to
98 * @param port Destination port (usually given by lockdownd_start_service). 98 * @param service The service descriptor returned by lockdownd_start_service.
99 * @param client Pointer that will be set to a newly allocated 99 * @param client Pointer that will be set to a newly allocated
100 * instproxy_client_t upon successful return. 100 * instproxy_client_t upon successful return.
101 * 101 *
102 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value 102 * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value
103 * when an error occured. 103 * when an error occured.
104 */ 104 */
105instproxy_error_t instproxy_client_new(idevice_t device, uint16_t port, instproxy_client_t *client) 105instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client)
106{ 106{
107 if (!device) 107 if (!device)
108 return INSTPROXY_E_INVALID_ARG; 108 return INSTPROXY_E_INVALID_ARG;
109 109
110 property_list_service_client_t plistclient = NULL; 110 property_list_service_client_t plistclient = NULL;
111 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 111 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
112 return INSTPROXY_E_CONN_FAILED; 112 return INSTPROXY_E_CONN_FAILED;
113 } 113 }
114 114
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
646 if (!client) 646 if (!client)
647 return LOCKDOWN_E_INVALID_ARG; 647 return LOCKDOWN_E_INVALID_ARG;
648 648
649 static struct lockdownd_service_descriptor service = {
650 .port = 0xf27e,
651 .ssl_enabled = 0
652 };
653
649 property_list_service_client_t plistclient = NULL; 654 property_list_service_client_t plistclient = NULL;
650 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 655 if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
651 debug_info("could not connect to lockdownd (device %s)", device->udid); 656 debug_info("could not connect to lockdownd (device %s)", device->udid);
652 return LOCKDOWN_E_MUX_ERROR; 657 return LOCKDOWN_E_MUX_ERROR;
653 } 658 }
@@ -1494,17 +1499,17 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char
1494 * Requests to start a service and retrieve it's port on success. 1499 * Requests to start a service and retrieve it's port on success.
1495 * 1500 *
1496 * @param client The lockdownd client 1501 * @param client The lockdownd client
1497 * @param service The name of the service to start 1502 * @param identifier The identifier of the service to start
1498 * @param port The port number the service was started on 1503 * @param descriptor The service descriptor on success or NULL on failure
1499 1504
1500 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter 1505 * @return LOCKDOWN_E_SUCCESS on success, NP_E_INVALID_ARG if a parameter
1501 * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known 1506 * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known
1502 * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because 1507 * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not because
1503 * started by the device 1508 * started by the device
1504 */ 1509 */
1505lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *service, uint16_t *port) 1510lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service)
1506{ 1511{
1507 if (!client || !service || !port) 1512 if (!client || !identifier || !service)
1508 return LOCKDOWN_E_INVALID_ARG; 1513 return LOCKDOWN_E_INVALID_ARG;
1509 1514
1510 char *host_id = NULL; 1515 char *host_id = NULL;
@@ -1524,7 +1529,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
1524 dict = plist_new_dict(); 1529 dict = plist_new_dict();
1525 plist_dict_add_label(dict, client->label); 1530 plist_dict_add_label(dict, client->label);
1526 plist_dict_insert_item(dict,"Request", plist_new_string("StartService")); 1531 plist_dict_insert_item(dict,"Request", plist_new_string("StartService"));
1527 plist_dict_insert_item(dict,"Service", plist_new_string(service)); 1532 plist_dict_insert_item(dict,"Service", plist_new_string(identifier));
1528 1533
1529 /* send to device */ 1534 /* send to device */
1530 ret = lockdownd_send(client, dict); 1535 ret = lockdownd_send(client, dict);
@@ -1542,20 +1547,34 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char
1542 if (!dict) 1547 if (!dict)
1543 return LOCKDOWN_E_PLIST_ERROR; 1548 return LOCKDOWN_E_PLIST_ERROR;
1544 1549
1550 if (*service == NULL)
1551 *service = (lockdownd_service_descriptor_t)malloc(sizeof(struct lockdownd_service_descriptor));
1552 (*service)->port = 0;
1553 (*service)->ssl_enabled = 0;
1554
1545 ret = LOCKDOWN_E_UNKNOWN_ERROR; 1555 ret = LOCKDOWN_E_UNKNOWN_ERROR;
1546 if (lockdown_check_result(dict, "StartService") == RESULT_SUCCESS) { 1556 if (lockdown_check_result(dict, "StartService") == RESULT_SUCCESS) {
1547 plist_t port_value_node = plist_dict_get_item(dict, "Port"); 1557 /* read service port number */
1548 1558 plist_t node = plist_dict_get_item(dict, "Port");
1549 if (port_value_node && (plist_get_node_type(port_value_node) == PLIST_UINT)) { 1559 if (node && (plist_get_node_type(node) == PLIST_UINT)) {
1550 uint64_t port_value = 0; 1560 uint64_t port_value = 0;
1551 plist_get_uint_val(port_value_node, &port_value); 1561 plist_get_uint_val(node, &port_value);
1552 1562
1553 if (port_value) { 1563 if (port_value) {
1554 port_loc = port_value; 1564 port_loc = port_value;
1555 ret = LOCKDOWN_E_SUCCESS; 1565 ret = LOCKDOWN_E_SUCCESS;
1556 } 1566 }
1557 if (port && ret == LOCKDOWN_E_SUCCESS) 1567 if (port_loc && ret == LOCKDOWN_E_SUCCESS) {
1558 *port = port_loc; 1568 (*service)->port = port_loc;
1569 }
1570 }
1571
1572 /* check if the service requires SSL */
1573 node = plist_dict_get_item(dict, "EnableServiceSSL");
1574 if (node && (plist_get_node_type(node) == PLIST_BOOLEAN)) {
1575 uint8_t b = 0;
1576 plist_get_bool_val(node, &b);
1577 (*service)->ssl_enabled = b;
1559 } 1578 }
1560 } else { 1579 } else {
1561 ret = LOCKDOWN_E_START_SERVICE_FAILED; 1580 ret = LOCKDOWN_E_START_SERVICE_FAILED;
@@ -1785,3 +1804,18 @@ lockdownd_error_t lockdownd_data_classes_free(char **classes)
1785 } 1804 }
1786 return LOCKDOWN_E_SUCCESS; 1805 return LOCKDOWN_E_SUCCESS;
1787} 1806}
1807
1808/**
1809 * Frees memory of a service descriptor as returned by lockdownd_start_service()
1810 *
1811 * @param sevice A service descriptor instance to free.
1812 *
1813 * @return LOCKDOWN_E_SUCCESS on success
1814 */
1815lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service)
1816{
1817 if (service)
1818 free(service);
1819
1820 return LOCKDOWN_E_SUCCESS;
1821}
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
91 * Connects to the misagent service on the specified device. 91 * Connects to the misagent service on the specified device.
92 * 92 *
93 * @param device The device to connect to. 93 * @param device The device to connect to.
94 * @param port Destination port (usually given by lockdownd_start_service). 94 * @param service The service descriptor returned by lockdownd_start_service.
95 * @param client Pointer that will point to a newly allocated 95 * @param client Pointer that will point to a newly allocated
96 * misagent_client_t upon successful return. 96 * misagent_client_t upon successful return.
97 * 97 *
98 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when 98 * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when
99 * client is NULL, or an MISAGENT_E_* error code otherwise. 99 * client is NULL, or an MISAGENT_E_* error code otherwise.
100 */ 100 */
101misagent_error_t misagent_client_new(idevice_t device, uint16_t port, misagent_client_t *client) 101misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client)
102{ 102{
103 if (!device) 103 if (!device)
104 return MISAGENT_E_INVALID_ARG; 104 return MISAGENT_E_INVALID_ARG;
105 105
106 property_list_service_client_t plistclient = NULL; 106 property_list_service_client_t plistclient = NULL;
107 misagent_error_t err = misagent_error(property_list_service_client_new(device, port, &plistclient)); 107 misagent_error_t err = misagent_error(property_list_service_client_new(device, service, &plistclient));
108 if (err != MISAGENT_E_SUCCESS) { 108 if (err != MISAGENT_E_SUCCESS) {
109 return err; 109 return err;
110 } 110 }
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
87 * Connects to the mobile_image_mounter service on the specified device. 87 * Connects to the mobile_image_mounter service on the specified device.
88 * 88 *
89 * @param device The device to connect to. 89 * @param device The device to connect to.
90 * @param port Destination port (usually given by lockdownd_start_service). 90 * @param service The service descriptor returned by lockdownd_start_service.
91 * @param client Pointer that will be set to a newly allocated 91 * @param client Pointer that will be set to a newly allocated
92 * mobile_image_mounter_client_t upon successful return. 92 * mobile_image_mounter_client_t upon successful return.
93 * 93 *
@@ -96,13 +96,13 @@ static mobile_image_mounter_error_t mobile_image_mounter_error(property_list_ser
96 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the 96 * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the
97 * device could not be established. 97 * device could not be established.
98 */ 98 */
99mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, uint16_t port, mobile_image_mounter_client_t *client) 99mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client)
100{ 100{
101 if (!device) 101 if (!device)
102 return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG; 102 return MOBILE_IMAGE_MOUNTER_E_INVALID_ARG;
103 103
104 property_list_service_client_t plistclient = NULL; 104 property_list_service_client_t plistclient = NULL;
105 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 105 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
106 return MOBILE_IMAGE_MOUNTER_E_CONN_FAILED; 106 return MOBILE_IMAGE_MOUNTER_E_CONN_FAILED;
107 } 107 }
108 108
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)
64 * Connects to the mobilebackup service on the specified device. 64 * Connects to the mobilebackup service on the specified device.
65 * 65 *
66 * @param device The device to connect to. 66 * @param device The device to connect to.
67 * @param port Destination port (usually given by lockdownd_start_service). 67 * @param service The service descriptor returned by lockdownd_start_service.
68 * @param client Pointer that will be set to a newly allocated 68 * @param client Pointer that will be set to a newly allocated
69 * mobilebackup_client_t upon successful return. 69 * mobilebackup_client_t upon successful return.
70 * 70 *
@@ -72,14 +72,14 @@ static mobilebackup_error_t mobilebackup_error(device_link_service_error_t err)
72 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if 72 * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if
73 * the mobilebackup version on the device is newer. 73 * the mobilebackup version on the device is newer.
74 */ 74 */
75mobilebackup_error_t mobilebackup_client_new(idevice_t device, uint16_t port, 75mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service,
76 mobilebackup_client_t * client) 76 mobilebackup_client_t * client)
77{ 77{
78 if (!device || port == 0 || !client || *client) 78 if (!device || service->port == 0 || !client || *client)
79 return MOBILEBACKUP_E_INVALID_ARG; 79 return MOBILEBACKUP_E_INVALID_ARG;
80 80
81 device_link_service_client_t dlclient = NULL; 81 device_link_service_client_t dlclient = NULL;
82 mobilebackup_error_t ret = mobilebackup_error(device_link_service_client_new(device, port, &dlclient)); 82 mobilebackup_error_t ret = mobilebackup_error(device_link_service_client_new(device, service, &dlclient));
83 if (ret != MOBILEBACKUP_E_SUCCESS) { 83 if (ret != MOBILEBACKUP_E_SUCCESS) {
84 return ret; 84 return ret;
85 } 85 }
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
65 * Connects to the mobilebackup2 service on the specified device. 65 * Connects to the mobilebackup2 service on the specified device.
66 * 66 *
67 * @param device The device to connect to. 67 * @param device The device to connect to.
68 * @param port Destination port (usually given by lockdownd_start_service). 68 * @param service The service descriptor returned by lockdownd_start_service.
69 * @param client Pointer that will be set to a newly allocated 69 * @param client Pointer that will be set to a newly allocated
70 * mobilebackup2_client_t upon successful return. 70 * mobilebackup2_client_t upon successful return.
71 * 71 *
@@ -73,14 +73,14 @@ static mobilebackup2_error_t mobilebackup2_error(device_link_service_error_t err
73 * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION 73 * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION
74 * if the mobilebackup2 version on the device is newer. 74 * if the mobilebackup2 version on the device is newer.
75 */ 75 */
76mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, uint16_t port, 76mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 mobilebackup2_client_t * client) 77 mobilebackup2_client_t * client)
78{ 78{
79 if (!device || port == 0 || !client || *client) 79 if (!device || service->port == 0 || !client || *client)
80 return MOBILEBACKUP2_E_INVALID_ARG; 80 return MOBILEBACKUP2_E_INVALID_ARG;
81 81
82 device_link_service_client_t dlclient = NULL; 82 device_link_service_client_t dlclient = NULL;
83 mobilebackup2_error_t ret = mobilebackup2_error(device_link_service_client_new(device, port, &dlclient)); 83 mobilebackup2_error_t ret = mobilebackup2_error(device_link_service_client_new(device, service, &dlclient));
84 if (ret != MOBILEBACKUP2_E_SUCCESS) { 84 if (ret != MOBILEBACKUP2_E_SUCCESS) {
85 return ret; 85 return ret;
86 } 86 }
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)
69 * Connects to the mobilesync service on the specified device. 69 * Connects to the mobilesync service on the specified device.
70 * 70 *
71 * @param device The device to connect to. 71 * @param device The device to connect to.
72 * @param port Destination port (usually given by lockdownd_start_service()). 72 * @param service The service descriptor returned by lockdownd_start_service.
73 * @param client Pointer that will be set to a newly allocated 73 * @param client Pointer that will be set to a newly allocated
74 * #mobilesync_client_t upon successful return. 74 * #mobilesync_client_t upon successful return.
75 * 75 *
@@ -78,14 +78,14 @@ static mobilesync_error_t mobilesync_error(device_link_service_error_t err)
78 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on 78 * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on
79 * the device is newer. 79 * the device is newer.
80 */ 80 */
81mobilesync_error_t mobilesync_client_new(idevice_t device, uint16_t port, 81mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service,
82 mobilesync_client_t * client) 82 mobilesync_client_t * client)
83{ 83{
84 if (!device || port == 0 || !client || *client) 84 if (!device || service->port == 0 || !client || *client)
85 return MOBILESYNC_E_INVALID_ARG; 85 return MOBILESYNC_E_INVALID_ARG;
86 86
87 device_link_service_client_t dlclient = NULL; 87 device_link_service_client_t dlclient = NULL;
88 mobilesync_error_t ret = mobilesync_error(device_link_service_client_new(device, port, &dlclient)); 88 mobilesync_error_t ret = mobilesync_error(device_link_service_client_new(device, service, &dlclient));
89 if (ret != MOBILESYNC_E_SUCCESS) { 89 if (ret != MOBILESYNC_E_SUCCESS) {
90 return ret; 90 return ret;
91 } 91 }
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)
98 * Connects to the notification_proxy on the specified device. 98 * Connects to the notification_proxy on the specified device.
99 * 99 *
100 * @param device The device to connect to. 100 * @param device The device to connect to.
101 * @param port Destination port (usually given by lockdownd_start_service). 101 * @param service The service descriptor returned by lockdownd_start_service.
102 * @param client Pointer that will be set to a newly allocated np_client_t 102 * @param client Pointer that will be set to a newly allocated np_client_t
103 * upon successful return. 103 * upon successful return.
104 * 104 *
@@ -106,13 +106,13 @@ static np_error_t np_error(property_list_service_error_t err)
106 * or NP_E_CONN_FAILED when the connection to the device could not be 106 * or NP_E_CONN_FAILED when the connection to the device could not be
107 * established. 107 * established.
108 */ 108 */
109np_error_t np_client_new(idevice_t device, uint16_t port, np_client_t *client) 109np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client)
110{ 110{
111 if (!device) 111 if (!device)
112 return NP_E_INVALID_ARG; 112 return NP_E_INVALID_ARG;
113 113
114 property_list_service_client_t plistclient = NULL; 114 property_list_service_client_t plistclient = NULL;
115 if (property_list_service_client_new(device, port, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 115 if (property_list_service_client_new(device, service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
116 return NP_E_CONN_FAILED; 116 return NP_E_CONN_FAILED;
117 } 117 }
118 118
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
57 * Creates a new property list service for the specified port. 57 * Creates a new property list service for the specified port.
58 * 58 *
59 * @param device The device to connect to. 59 * @param device The device to connect to.
60 * @param port The port on the device to connect to, usually opened by a call to 60 * @param service The service descriptor returned by lockdownd_start_service.
61 * lockdownd_start_service.
62 * @param client Pointer that will be set to a newly allocated 61 * @param client Pointer that will be set to a newly allocated
63 * property_list_service_client_t upon successful return. 62 * property_list_service_client_t upon successful return.
64 * 63 *
@@ -66,14 +65,14 @@ static property_list_service_error_t idevice_to_property_list_service_error(idev
66 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid, 65 * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid,
67 * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed. 66 * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed.
68 */ 67 */
69property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, property_list_service_client_t *client) 68property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client)
70{ 69{
71 if (!device || port == 0 || !client || *client) 70 if (!device || (service->port == 0) || !client || *client)
72 return PROPERTY_LIST_SERVICE_E_INVALID_ARG; 71 return PROPERTY_LIST_SERVICE_E_INVALID_ARG;
73 72
74 /* Attempt connection */ 73 /* Attempt connection */
75 idevice_connection_t connection = NULL; 74 idevice_connection_t connection = NULL;
76 if (idevice_connect(device, port, &connection) != IDEVICE_E_SUCCESS) { 75 if (idevice_connect(device, service->port, &connection) != IDEVICE_E_SUCCESS) {
77 return PROPERTY_LIST_SERVICE_E_MUX_ERROR; 76 return PROPERTY_LIST_SERVICE_E_MUX_ERROR;
78 } 77 }
79 78
@@ -81,8 +80,12 @@ property_list_service_error_t property_list_service_client_new(idevice_t device,
81 property_list_service_client_t client_loc = (property_list_service_client_t)malloc(sizeof(struct property_list_service_client_private)); 80 property_list_service_client_t client_loc = (property_list_service_client_t)malloc(sizeof(struct property_list_service_client_private));
82 client_loc->connection = connection; 81 client_loc->connection = connection;
83 82
84 *client = client_loc; 83 /* enable SSL if requested */
84 if (service->ssl_enabled == 1)
85 property_list_service_enable_ssl(client_loc);
85 86
87 /* all done, return success */
88 *client = client_loc;
86 return PROPERTY_LIST_SERVICE_E_SUCCESS; 89 return PROPERTY_LIST_SERVICE_E_SUCCESS;
87} 90}
88 91
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 @@
21#ifndef PROPERTY_LIST_SERVICE_H 21#ifndef PROPERTY_LIST_SERVICE_H
22#define PROPERTY_LIST_SERVICE_H 22#define PROPERTY_LIST_SERVICE_H
23 23
24#include <libimobiledevice/lockdown.h>
24#include "idevice.h" 25#include "idevice.h"
25 26
26/* Error Codes */ 27/* Error Codes */
@@ -41,7 +42,7 @@ typedef struct property_list_service_client_private *property_list_service_clien
41typedef int16_t property_list_service_error_t; 42typedef int16_t property_list_service_error_t;
42 43
43/* creation and destruction */ 44/* creation and destruction */
44property_list_service_error_t property_list_service_client_new(idevice_t device, uint16_t port, property_list_service_client_t *client); 45property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client);
45property_list_service_error_t property_list_service_client_free(property_list_service_client_t client); 46property_list_service_error_t property_list_service_client_free(property_list_service_client_t client);
46 47
47/* sending */ 48/* 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
368 368
369 restored_error_t ret = RESTORE_E_SUCCESS; 369 restored_error_t ret = RESTORE_E_SUCCESS;
370 370
371 static struct lockdownd_service_descriptor service = {
372 .port = 0xf27e,
373 .ssl_enabled = 0
374 };
375
371 property_list_service_client_t plistclient = NULL; 376 property_list_service_client_t plistclient = NULL;
372 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 377 if (property_list_service_client_new(device, (lockdownd_service_descriptor_t)&service, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) {
373 debug_info("could not connect to restored (device %s)", device->udid); 378 debug_info("could not connect to restored (device %s)", device->udid);
374 return RESTORE_E_MUX_ERROR; 379 return RESTORE_E_MUX_ERROR;
375 } 380 }
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)
88 * Connects to the springboardservices service on the specified device. 88 * Connects to the springboardservices service on the specified device.
89 * 89 *
90 * @param device The device to connect to. 90 * @param device The device to connect to.
91 * @param port Destination port (usually given by lockdownd_start_service). 91 * @param service The service descriptor returned by lockdownd_start_service.
92 * @param client Pointer that will point to a newly allocated 92 * @param client Pointer that will point to a newly allocated
93 * sbservices_client_t upon successful return. 93 * sbservices_client_t upon successful return.
94 * 94 *
95 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when 95 * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when
96 * client is NULL, or an SBSERVICES_E_* error code otherwise. 96 * client is NULL, or an SBSERVICES_E_* error code otherwise.
97 */ 97 */
98sbservices_error_t sbservices_client_new(idevice_t device, uint16_t port, sbservices_client_t *client) 98sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client)
99{ 99{
100 if (!device) 100 if (!device)
101 return SBSERVICES_E_INVALID_ARG; 101 return SBSERVICES_E_INVALID_ARG;
102 102
103 property_list_service_client_t plistclient = NULL; 103 property_list_service_client_t plistclient = NULL;
104 sbservices_error_t err = sbservices_error(property_list_service_client_new(device, port, &plistclient)); 104 sbservices_error_t err = sbservices_error(property_list_service_client_new(device, service, &plistclient));
105 if (err != SBSERVICES_E_SUCCESS) { 105 if (err != SBSERVICES_E_SUCCESS) {
106 return err; 106 return err;
107 } 107 }
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)
62 * Connects to the screenshotr service on the specified device. 62 * Connects to the screenshotr service on the specified device.
63 * 63 *
64 * @param device The device to connect to. 64 * @param device The device to connect to.
65 * @param port Destination port (usually given by lockdownd_start_service). 65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will be set to a newly allocated 66 * @param client Pointer that will be set to a newly allocated
67 * screenshotr_client_t upon successful return. 67 * screenshotr_client_t upon successful return.
68 * 68 *
@@ -73,14 +73,14 @@ static screenshotr_error_t screenshotr_error(device_link_service_error_t err)
73 * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the 73 * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the
74 * connection to the device could not be established. 74 * connection to the device could not be established.
75 */ 75 */
76screenshotr_error_t screenshotr_client_new(idevice_t device, uint16_t port, 76screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service,
77 screenshotr_client_t * client) 77 screenshotr_client_t * client)
78{ 78{
79 if (!device || port == 0 || !client || *client) 79 if (!device || service->port == 0 || !client || *client)
80 return SCREENSHOTR_E_INVALID_ARG; 80 return SCREENSHOTR_E_INVALID_ARG;
81 81
82 device_link_service_client_t dlclient = NULL; 82 device_link_service_client_t dlclient = NULL;
83 screenshotr_error_t ret = screenshotr_error(device_link_service_client_new(device, port, &dlclient)); 83 screenshotr_error_t ret = screenshotr_error(device_link_service_client_new(device, service, &dlclient));
84 if (ret != SCREENSHOTR_E_SUCCESS) { 84 if (ret != SCREENSHOTR_E_SUCCESS) {
85 return ret; 85 return ret;
86 } 86 }
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
62 * Connects to the webinspector service on the specified device. 62 * Connects to the webinspector service on the specified device.
63 * 63 *
64 * @param device The device to connect to. 64 * @param device The device to connect to.
65 * @param port Destination port (usually given by lockdownd_start_service). 65 * @param service The service descriptor returned by lockdownd_start_service.
66 * @param client Pointer that will point to a newly allocated 66 * @param client Pointer that will point to a newly allocated
67 * webinspector_client_t upon successful return. Must be freed using 67 * webinspector_client_t upon successful return. Must be freed using
68 * webinspector_client_free() after use. 68 * webinspector_client_free() after use.
@@ -70,19 +70,19 @@ static webinspector_error_t webinspector_error(property_list_service_error_t err
70 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when 70 * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when
71 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise. 71 * client is NULL, or an WEBINSPECTOR_E_* error code otherwise.
72 */ 72 */
73webinspector_error_t webinspector_client_new(idevice_t device, uint16_t port, webinspector_client_t * client) 73webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client)
74{ 74{
75 *client = NULL; 75 *client = NULL;
76 76
77 debug_info("Creating webinspector_client, port = %d.", port); 77 debug_info("Creating webinspector_client, port = %d.", service->port);
78 78
79 if (!device || port == 0 || !client || *client) { 79 if (!device || service->port == 0 || !client || *client) {
80 debug_info("Incorrect parameter passed to webinspector_client_new."); 80 debug_info("Incorrect parameter passed to webinspector_client_new.");
81 return WEBINSPECTOR_E_INVALID_ARG; 81 return WEBINSPECTOR_E_INVALID_ARG;
82 } 82 }
83 83
84 property_list_service_client_t plclient = NULL; 84 property_list_service_client_t plclient = NULL;
85 webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, port, &plclient)); 85 webinspector_error_t ret = webinspector_error(property_list_service_client_new(device, service, &plclient));
86 if (ret != WEBINSPECTOR_E_SUCCESS) { 86 if (ret != WEBINSPECTOR_E_SUCCESS) {
87 debug_info("Creating a property list client failed. Error: %i", ret); 87 debug_info("Creating a property list client failed. Error: %i", ret);
88 return ret; 88 return ret;
@@ -118,22 +118,27 @@ webinspector_error_t webinspector_start_service(idevice_t device, webinspector_c
118 debug_info("Could not create a lockdown client."); 118 debug_info("Could not create a lockdown client.");
119 return WEBINSPECTOR_E_UNKNOWN_ERROR; 119 return WEBINSPECTOR_E_UNKNOWN_ERROR;
120 } 120 }
121 121
122 uint16_t port = 0; 122 lockdownd_service_descriptor_t service = NULL;
123 lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &port); 123 lockdownd_start_service(lckd, WEBINSPECTOR_SERVICE_NAME, &service);
124 lockdownd_client_free(lckd); 124 lockdownd_client_free(lckd);
125 125
126 if (port <= 0) { 126 if (service->port <= 0) {
127 debug_info("Could not start webinspector service!"); 127 debug_info("Could not start webinspector service!");
128 return WEBINSPECTOR_E_UNKNOWN_ERROR; 128 return WEBINSPECTOR_E_UNKNOWN_ERROR;
129 } 129 }
130 130
131 webinspector_error_t res = webinspector_client_new(device, port, client); 131 webinspector_error_t res = webinspector_client_new(device, service, client);
132 if (res != WEBINSPECTOR_E_SUCCESS) { 132 if (res != WEBINSPECTOR_E_SUCCESS) {
133 debug_info("Could not connect to webinspector! Port: %i, error: %i", port, res); 133 debug_info("Could not connect to webinspector! Port: %i, error: %i", service->port, res);
134 return res; 134 return res;
135 } 135 }
136 136
137 if (service) {
138 lockdownd_service_descriptor_free(service);
139 service = NULL;
140 }
141
137 return WEBINSPECTOR_E_SUCCESS; 142 return WEBINSPECTOR_E_SUCCESS;
138} 143}
139 144