summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.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 /tools/idevicebackup2.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 'tools/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index a0e732d..0353c9b 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -479,7 +479,7 @@ static int mb2_status_check_snapshot_state(const char *path, const char *udid, c
static void do_post_notification(idevice_t device, const char *notification)
{
- uint16_t nport = 0;
+ lockdownd_service_descriptor_t service = NULL;
np_client_t np;
lockdownd_client_t lockdown = NULL;
@@ -488,9 +488,9 @@ static void do_post_notification(idevice_t device, const char *notification)
return;
}
- lockdownd_start_service(lockdown, NP_SERVICE_NAME, &nport);
- if (nport) {
- np_client_new(device, nport, &np);
+ lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
+ if (service->port) {
+ np_client_new(device, service, &np);
if (np) {
np_post_notification(np, notification);
np_client_free(np);
@@ -498,6 +498,11 @@ static void do_post_notification(idevice_t device, const char *notification)
} else {
printf("Could not start %s\n", NP_SERVICE_NAME);
}
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
}
static void print_progress_real(double progress, int flush)
@@ -1277,7 +1282,7 @@ int main(int argc, char *argv[])
int i;
char* udid = NULL;
char* source_udid = NULL;
- uint16_t port = 0;
+ lockdownd_service_descriptor_t service = NULL;
int cmd = -1;
int cmd_flags = 0;
int is_full_backup = 0;
@@ -1551,9 +1556,9 @@ int main(int argc, char *argv[])
/* start notification_proxy */
np_client_t np = NULL;
- ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- np_client_new(device, port, &np);
+ ret = lockdownd_start_service(lockdown, NP_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ np_client_new(device, service, &np);
np_set_notify_callback(np, notify_cb, NULL);
const char *noties[5] = {
NP_SYNC_CANCEL_REQUEST,
@@ -1567,23 +1572,38 @@ int main(int argc, char *argv[])
printf("ERROR: Could not start service %s.\n", NP_SERVICE_NAME);
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
afc_client_t afc = NULL;
if (cmd == CMD_BACKUP) {
/* start AFC, we need this for the lock file */
- port = 0;
- ret = lockdownd_start_service(lockdown, "com.apple.afc", &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- afc_client_new(device, port, &afc);
+ service->port = 0;
+ service->ssl_enabled = 0;
+ ret = lockdownd_start_service(lockdown, "com.apple.afc", &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ afc_client_new(device, service, &afc);
}
}
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
+
/* start mobilebackup service and retrieve port */
mobilebackup2_client_t mobilebackup2 = NULL;
- port = 0;
- ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &port);
- if ((ret == LOCKDOWN_E_SUCCESS) && port) {
- PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, port);
- mobilebackup2_client_new(device, port, &mobilebackup2);
+ ret = lockdownd_start_service(lockdown, MOBILEBACKUP2_SERVICE_NAME, &service);
+ if ((ret == LOCKDOWN_E_SUCCESS) && service->port) {
+ PRINT_VERBOSE(1, "Started \"%s\" service on port %d.\n", MOBILEBACKUP2_SERVICE_NAME, service->port);
+ mobilebackup2_client_new(device, service, &mobilebackup2);
+
+ if (service) {
+ lockdownd_service_descriptor_free(service);
+ service = NULL;
+ }
/* send Hello message */
double local_versions[2] = {2.0, 2.1};