diff options
| author | 2013-02-26 03:20:56 +0100 | |
|---|---|---|
| committer | 2013-02-26 03:20:56 +0100 | |
| commit | fcc1bb855efb6860417ed827d3b50feba24a9a8b (patch) | |
| tree | 47d3c7d6a985dc647f7962329014c8116d657cc9 /dev | |
| parent | 3b54aac30447bc02fafd721a63a752968628e7e0 (diff) | |
| download | libimobiledevice-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 'dev')
| -rw-r--r-- | dev/afccheck.c | 11 | ||||
| -rw-r--r-- | dev/filerelaytest.c | 11 | ||||
| -rw-r--r-- | dev/housearresttest.c | 11 | ||||
| -rw-r--r-- | dev/ideviceclient.c | 43 | ||||
| -rw-r--r-- | dev/lckdclient.c | 10 |
5 files changed, 62 insertions, 24 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index 2dab6db..ead0ca0 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c | |||
| @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) | |||
| 92 | { | 92 | { |
| 93 | lockdownd_client_t client = NULL; | 93 | lockdownd_client_t client = NULL; |
| 94 | idevice_t phone = NULL; | 94 | idevice_t phone = NULL; |
| 95 | uint16_t port = 0; | 95 | lockdownd_service_descriptor_t service = NULL; |
| 96 | afc_client_t afc = NULL; | 96 | afc_client_t afc = NULL; |
| 97 | 97 | ||
| 98 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { | 98 | if (argc > 1 && !strcasecmp(argv[1], "--debug")) { |
| @@ -111,14 +111,19 @@ int main(int argc, char *argv[]) | |||
| 111 | return 1; | 111 | return 1; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &port) && !port) { | 114 | if (LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, "com.apple.afc", &service) && !service->port) { |
| 115 | lockdownd_client_free(client); | 115 | lockdownd_client_free(client); |
| 116 | idevice_free(phone); | 116 | idevice_free(phone); |
| 117 | fprintf(stderr, "Something went wrong when starting AFC."); | 117 | fprintf(stderr, "Something went wrong when starting AFC."); |
| 118 | return 1; | 118 | return 1; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | afc_client_new(phone, port, &afc); | 121 | afc_client_new(phone, service, &afc); |
| 122 | |||
| 123 | if (service) { | ||
| 124 | lockdownd_service_descriptor_free(service); | ||
| 125 | service = NULL; | ||
| 126 | } | ||
| 122 | 127 | ||
| 123 | pthread_t threads[NB_THREADS]; | 128 | pthread_t threads[NB_THREADS]; |
| 124 | param data[NB_THREADS]; | 129 | param data[NB_THREADS]; |
diff --git a/dev/filerelaytest.c b/dev/filerelaytest.c index 8c9514b..9094130 100644 --- a/dev/filerelaytest.c +++ b/dev/filerelaytest.c | |||
| @@ -27,6 +27,7 @@ int main(int argc, char **argv) | |||
| 27 | { | 27 | { |
| 28 | idevice_t dev = NULL; | 28 | idevice_t dev = NULL; |
| 29 | lockdownd_client_t client = NULL; | 29 | lockdownd_client_t client = NULL; |
| 30 | lockdownd_service_descriptor_t service = NULL; | ||
| 30 | file_relay_client_t frc = NULL; | 31 | file_relay_client_t frc = NULL; |
| 31 | 32 | ||
| 32 | if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) { | 33 | if (idevice_new(&dev, NULL) != IDEVICE_E_SUCCESS) { |
| @@ -40,8 +41,7 @@ int main(int argc, char **argv) | |||
| 40 | goto leave_cleanup; | 41 | goto leave_cleanup; |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | uint16_t port = 0; | 44 | if (lockdownd_start_service(client, "com.apple.mobile.file_relay", &service) != LOCKDOWN_E_SUCCESS) { |
| 44 | if (lockdownd_start_service(client, "com.apple.mobile.file_relay", &port) != LOCKDOWN_E_SUCCESS) { | ||
| 45 | printf("could not start file_relay service!\n"); | 45 | printf("could not start file_relay service!\n"); |
| 46 | goto leave_cleanup; | 46 | goto leave_cleanup; |
| 47 | } | 47 | } |
| @@ -51,11 +51,16 @@ int main(int argc, char **argv) | |||
| 51 | client = NULL; | 51 | client = NULL; |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | if (file_relay_client_new(dev, port, &frc) != FILE_RELAY_E_SUCCESS) { | 54 | if (file_relay_client_new(dev, service, &frc) != FILE_RELAY_E_SUCCESS) { |
| 55 | printf("could not connect to file_relay service!\n"); | 55 | printf("could not connect to file_relay service!\n"); |
| 56 | goto leave_cleanup; | 56 | goto leave_cleanup; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | if (service) { | ||
| 60 | lockdownd_service_descriptor_free(service); | ||
| 61 | service = NULL; | ||
| 62 | } | ||
| 63 | |||
| 59 | idevice_connection_t dump = NULL; | 64 | idevice_connection_t dump = NULL; |
| 60 | const char *sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL}; | 65 | const char *sources[] = {"AppleSupport", "Network", "VPN", "WiFi", "UserDatabases", "CrashReporter", "tmp", "SystemConfiguration", NULL}; |
| 61 | 66 | ||
diff --git a/dev/housearresttest.c b/dev/housearresttest.c index 951ebe4..2e24670 100644 --- a/dev/housearresttest.c +++ b/dev/housearresttest.c | |||
| @@ -96,8 +96,8 @@ int main(int argc, char **argv) | |||
| 96 | goto leave_cleanup; | 96 | goto leave_cleanup; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | uint16_t port = 0; | 99 | lockdownd_service_descriptor_t service = NULL; |
| 100 | if (lockdownd_start_service(client, "com.apple.mobile.house_arrest", &port) != LOCKDOWN_E_SUCCESS) { | 100 | if (lockdownd_start_service(client, "com.apple.mobile.house_arrest", &service) != LOCKDOWN_E_SUCCESS) { |
| 101 | printf("could not start house_arrest service!\n"); | 101 | printf("could not start house_arrest service!\n"); |
| 102 | goto leave_cleanup; | 102 | goto leave_cleanup; |
| 103 | } | 103 | } |
| @@ -107,11 +107,16 @@ int main(int argc, char **argv) | |||
| 107 | client = NULL; | 107 | client = NULL; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | if (house_arrest_client_new(dev, port, &hac) != HOUSE_ARREST_E_SUCCESS) { | 110 | if (house_arrest_client_new(dev, service, &hac) != HOUSE_ARREST_E_SUCCESS) { |
| 111 | printf("could not connect to house_arrest service!\n"); | 111 | printf("could not connect to house_arrest service!\n"); |
| 112 | goto leave_cleanup; | 112 | goto leave_cleanup; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if (service) { | ||
| 116 | lockdownd_service_descriptor_free(service); | ||
| 117 | service = NULL; | ||
| 118 | } | ||
| 119 | |||
| 115 | res = house_arrest_send_command(hac, "VendDocuments", appid); | 120 | res = house_arrest_send_command(hac, "VendDocuments", appid); |
| 116 | if (res != HOUSE_ARREST_E_SUCCESS) { | 121 | if (res != HOUSE_ARREST_E_SUCCESS) { |
| 117 | printf("error %d when trying to get VendDocuments\n", res); | 122 | printf("error %d when trying to get VendDocuments\n", res); |
diff --git a/dev/ideviceclient.c b/dev/ideviceclient.c index d467ee8..c8635d8 100644 --- a/dev/ideviceclient.c +++ b/dev/ideviceclient.c | |||
| @@ -45,13 +45,13 @@ static void notifier(const char *notification, void *userdata) | |||
| 45 | 45 | ||
| 46 | static void perform_notification(idevice_t phone, lockdownd_client_t client, const char *notification) | 46 | static void perform_notification(idevice_t phone, lockdownd_client_t client, const char *notification) |
| 47 | { | 47 | { |
| 48 | uint16_t nport = 0; | 48 | lockdownd_service_descriptor_t service = NULL; |
| 49 | np_client_t np; | 49 | np_client_t np; |
| 50 | 50 | ||
| 51 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &nport); | 51 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); |
| 52 | if (nport) { | 52 | if (service->port) { |
| 53 | printf("::::::::::::::: np was started ::::::::::::\n"); | 53 | printf("::::::::::::::: np was started ::::::::::::\n"); |
| 54 | np_client_new(phone, nport, &np); | 54 | np_client_new(phone, service, &np); |
| 55 | if (np) { | 55 | if (np) { |
| 56 | printf("::::::::: PostNotification %s\n", notification); | 56 | printf("::::::::: PostNotification %s\n", notification); |
| 57 | np_post_notification(np, notification); | 57 | np_post_notification(np, notification); |
| @@ -60,13 +60,18 @@ static void perform_notification(idevice_t phone, lockdownd_client_t client, con | |||
| 60 | } else { | 60 | } else { |
| 61 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); | 61 | printf("::::::::::::::: np was NOT started ::::::::::::\n"); |
| 62 | } | 62 | } |
| 63 | |||
| 64 | if (service) { | ||
| 65 | lockdownd_service_descriptor_free(service); | ||
| 66 | service = NULL; | ||
| 67 | } | ||
| 63 | } | 68 | } |
| 64 | 69 | ||
| 65 | int main(int argc, char *argv[]) | 70 | int main(int argc, char *argv[]) |
| 66 | { | 71 | { |
| 67 | unsigned int bytes = 0; | 72 | unsigned int bytes = 0; |
| 68 | uint16_t port = 0, i = 0; | 73 | uint16_t i = 0; |
| 69 | uint16_t npp; | 74 | lockdownd_service_descriptor_t service = NULL; |
| 70 | lockdownd_client_t client = NULL; | 75 | lockdownd_client_t client = NULL; |
| 71 | idevice_t phone = NULL; | 76 | idevice_t phone = NULL; |
| 72 | uint64_t lockfile = 0; | 77 | uint64_t lockfile = 0; |
| @@ -102,19 +107,33 @@ int main(int argc, char *argv[]) | |||
| 102 | free(nnn); | 107 | free(nnn); |
| 103 | } | 108 | } |
| 104 | 109 | ||
| 105 | lockdownd_start_service(client, "com.apple.afc", &port); | 110 | lockdownd_start_service(client, "com.apple.afc", &service); |
| 106 | 111 | ||
| 107 | if (port) { | 112 | if (service->port) { |
| 108 | afc_client_t afc = NULL; | 113 | afc_client_t afc = NULL; |
| 109 | afc_client_new(phone, port, &afc); | 114 | afc_client_new(phone, service, &afc); |
| 115 | |||
| 116 | if (service) { | ||
| 117 | lockdownd_service_descriptor_free(service); | ||
| 118 | service = NULL; | ||
| 119 | } | ||
| 120 | |||
| 110 | if (afc) { | 121 | if (afc) { |
| 111 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &npp); | 122 | service->port = 0; |
| 112 | if (npp) { | 123 | service->ssl_enabled = 0; |
| 124 | lockdownd_start_service(client, "com.apple.mobile.notification_proxy", &service); | ||
| 125 | if (service->port) { | ||
| 113 | printf("Notification Proxy started.\n"); | 126 | printf("Notification Proxy started.\n"); |
| 114 | np_client_new(phone, npp, &gnp); | 127 | np_client_new(phone, service, &gnp); |
| 115 | } else { | 128 | } else { |
| 116 | printf("ERROR: Notification proxy could not be started.\n"); | 129 | printf("ERROR: Notification proxy could not be started.\n"); |
| 117 | } | 130 | } |
| 131 | |||
| 132 | if (service) { | ||
| 133 | lockdownd_service_descriptor_free(service); | ||
| 134 | service = NULL; | ||
| 135 | } | ||
| 136 | |||
| 118 | if (gnp) { | 137 | if (gnp) { |
| 119 | const char *nspec[5] = { | 138 | const char *nspec[5] = { |
| 120 | NP_SYNC_CANCEL_REQUEST, | 139 | NP_SYNC_CANCEL_REQUEST, |
diff --git a/dev/lckdclient.c b/dev/lckdclient.c index cc89634..b9be4de 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c | |||
| @@ -136,9 +136,13 @@ int main(int argc, char *argv[]) | |||
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | if (!strcmp(*args, "start") && len == 2) { | 138 | if (!strcmp(*args, "start") && len == 2) { |
| 139 | uint16_t port = 0; | 139 | lockdownd_service_descriptor_t service = NULL; |
| 140 | if(LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, *(args + 1), &port)) { | 140 | if(LOCKDOWN_E_SUCCESS == lockdownd_start_service(client, *(args + 1), &service)) { |
| 141 | printf("started service %s on port %i\n", *(args + 1), port); | 141 | printf("started service %s on port %i\n", *(args + 1), service->port); |
| 142 | if (service) { | ||
| 143 | lockdownd_service_descriptor_free(service); | ||
| 144 | service = NULL; | ||
| 145 | } | ||
| 142 | } | 146 | } |
| 143 | else | 147 | else |
| 144 | { | 148 | { |
