summaryrefslogtreecommitdiffstats
path: root/src/afc.c
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/afc.c
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/afc.c')
-rw-r--r--src/afc.c12
1 files changed, 8 insertions, 4 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);