diff options
author | Martin Szulecki | 2010-01-12 17:06:53 +0100 |
---|---|---|
committer | Martin Szulecki | 2010-01-12 17:06:53 +0100 |
commit | 9de537f6963e4e9770ee0aabfeb6982e3d422e69 (patch) | |
tree | 95e456eef72f85bb906326b6231d1ceb24fad38f | |
parent | d07e1052c13ee472a34e90a4d87fbc3ddd2ad63f (diff) | |
download | libimobiledevice-9de537f6963e4e9770ee0aabfeb6982e3d422e69.tar.gz libimobiledevice-9de537f6963e4e9770ee0aabfeb6982e3d422e69.tar.bz2 |
Allow lockdown client creation without performing full handshake
The lockdown constructor was doing more than needed. Pairing and session
negotiation is now handled by lockdownd_client_new_with_handshake().
-rw-r--r-- | dev/afccheck.c | 2 | ||||
-rw-r--r-- | dev/iphoneclient.c | 2 | ||||
-rw-r--r-- | dev/iphoneenterrecovery.c | 2 | ||||
-rw-r--r-- | dev/lckdclient.c | 2 | ||||
-rw-r--r-- | dev/msyncclient.c | 2 | ||||
-rw-r--r-- | include/libiphone/lockdown.h | 1 | ||||
-rw-r--r-- | src/lockdown.c | 40 | ||||
-rw-r--r-- | swig/iphone.i | 2 | ||||
-rw-r--r-- | tools/iphoneinfo.c | 2 | ||||
-rw-r--r-- | tools/iphonesyslog.c | 2 |
10 files changed, 45 insertions, 12 deletions
diff --git a/dev/afccheck.c b/dev/afccheck.c index 00c0f52..7a17a31 100644 --- a/dev/afccheck.c +++ b/dev/afccheck.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) return 1; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "afccheck")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "afccheck")) { iphone_device_free(phone); return 1; } diff --git a/dev/iphoneclient.c b/dev/iphoneclient.c index 685f6ef..5bd0e6b 100644 --- a/dev/iphoneclient.c +++ b/dev/iphoneclient.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) if (uuid) free(uuid); - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneclient")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneclient")) { iphone_device_free(phone); printf("Exiting.\n"); return -1; diff --git a/dev/iphoneenterrecovery.c b/dev/iphoneenterrecovery.c index 126941c..cab41f8 100644 --- a/dev/iphoneenterrecovery.c +++ b/dev/iphoneenterrecovery.c @@ -74,7 +74,7 @@ int main(int argc, char *argv[]) return -1; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneenterrecovery")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneenterrecovery")) { iphone_device_free(phone); return -1; } diff --git a/dev/lckdclient.c b/dev/lckdclient.c index c8d717c..adf0aaa 100644 --- a/dev/lckdclient.c +++ b/dev/lckdclient.c @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) if (uuid) free(uuid); - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "lckdclient")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "lckdclient")) { iphone_device_free(phone); return -1; } diff --git a/dev/msyncclient.c b/dev/msyncclient.c index dfe2a2b..6e40390 100644 --- a/dev/msyncclient.c +++ b/dev/msyncclient.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) return -1; } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "msyncclient")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "msyncclient")) { iphone_device_free(phone); return -1; } diff --git a/include/libiphone/lockdown.h b/include/libiphone/lockdown.h index 4a82258..08431aa 100644 --- a/include/libiphone/lockdown.h +++ b/include/libiphone/lockdown.h @@ -56,6 +56,7 @@ typedef struct lockdownd_client_int *lockdownd_client_t; /* Interface */ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label); +lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lockdownd_client_t *client, const char *label); lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); void lockdownd_client_set_label(lockdownd_client_t client, const char *label); lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); diff --git a/src/lockdown.c b/src/lockdown.c index 5717e52..69ccf34 100644 --- a/src/lockdown.c +++ b/src/lockdown.c @@ -618,9 +618,9 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de return ret; } -/** Creates a lockdownd client for the give iPhone +/** Creates a lockdownd client for the device. * - * @param phone The iPhone to create a lockdownd client for + * @param phone The device to create a lockdownd client for * @param client The pointer to the location of the new lockdownd_client * @param label The label to use for communication. Usually the program name * @@ -630,9 +630,8 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_ { if (!client) return LOCKDOWN_E_INVALID_ARG; + lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; - char *host_id = NULL; - char *type = NULL; property_list_service_client_t plistclient = NULL; if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { @@ -651,6 +650,39 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_ if (label != NULL) strdup(label); + if (LOCKDOWN_E_SUCCESS == ret) { + *client = client_loc; + } else { + lockdownd_client_free(client_loc); + } + + return ret; +} + +/** Creates a lockdownd client for the device and starts initial handshake. + * The handshake consists of query_type, validate_pair, pair and + * start_session calls. + * + * @param phone The device to create a lockdownd client for + * @param client The pointer to the location of the new lockdownd_client + * @param label The label to use for communication. Usually the program name + * + * @return an error code (LOCKDOWN_E_SUCCESS on success) + */ +lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lockdownd_client_t *client, const char *label) +{ + if (!client) + return LOCKDOWN_E_INVALID_ARG; + + lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; + lockdownd_client_t client_loc = NULL; + char *host_id = NULL; + char *type = NULL; + + + ret = lockdownd_client_new(device, &client_loc, label); + + /* perform handshake */ if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) { log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); ret = LOCKDOWN_E_NOT_ENOUGH_DATA; diff --git a/swig/iphone.i b/swig/iphone.i index 6e1849e..6b8ef3f 100644 --- a/swig/iphone.i +++ b/swig/iphone.i @@ -71,7 +71,7 @@ Lockdownd* my_new_Lockdownd(iPhone* phone) { Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd)); client->dev = phone; client->client = NULL; - if (LOCKDOWN_E_SUCCESS == lockdownd_client_new(phone->dev , &(client->client), NULL)) { + if (LOCKDOWN_E_SUCCESS == lockdownd_client_new_with_handshake(phone->dev , &(client->client), NULL)) { return client; } else { diff --git a/tools/iphoneinfo.c b/tools/iphoneinfo.c index e1417a5..a8fba5f 100644 --- a/tools/iphoneinfo.c +++ b/tools/iphoneinfo.c @@ -142,7 +142,7 @@ int main(int argc, char *argv[]) } } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneinfo")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneinfo")) { iphone_device_free(phone); return -1; } diff --git a/tools/iphonesyslog.c b/tools/iphonesyslog.c index 5d4f564..14a8223 100644 --- a/tools/iphonesyslog.c +++ b/tools/iphonesyslog.c @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) } } - if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphonesyslog")) { + if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphonesyslog")) { iphone_device_free(phone); return -1; } |