From fcc1bb855efb6860417ed827d3b50feba24a9a8b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Tue, 26 Feb 2013 03:20:56 +0100 Subject: 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. --- src/device_link_service.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/device_link_service.c') 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; -- cgit v1.1-32-gdbae