summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2010-01-12 17:06:53 +0100
committerGravatar Martin Szulecki2010-01-12 17:06:53 +0100
commit9de537f6963e4e9770ee0aabfeb6982e3d422e69 (patch)
tree95e456eef72f85bb906326b6231d1ceb24fad38f
parentd07e1052c13ee472a34e90a4d87fbc3ddd2ad63f (diff)
downloadlibimobiledevice-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.c2
-rw-r--r--dev/iphoneclient.c2
-rw-r--r--dev/iphoneenterrecovery.c2
-rw-r--r--dev/lckdclient.c2
-rw-r--r--dev/msyncclient.c2
-rw-r--r--include/libiphone/lockdown.h1
-rw-r--r--src/lockdown.c40
-rw-r--r--swig/iphone.i2
-rw-r--r--tools/iphoneinfo.c2
-rw-r--r--tools/iphonesyslog.c2
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[])
109 return 1; 109 return 1;
110 } 110 }
111 111
112 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "afccheck")) { 112 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "afccheck")) {
113 iphone_device_free(phone); 113 iphone_device_free(phone);
114 return 1; 114 return 1;
115 } 115 }
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[])
87 if (uuid) 87 if (uuid)
88 free(uuid); 88 free(uuid);
89 89
90 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneclient")) { 90 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneclient")) {
91 iphone_device_free(phone); 91 iphone_device_free(phone);
92 printf("Exiting.\n"); 92 printf("Exiting.\n");
93 return -1; 93 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[])
74 return -1; 74 return -1;
75 } 75 }
76 76
77 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneenterrecovery")) { 77 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneenterrecovery")) {
78 iphone_device_free(phone); 78 iphone_device_free(phone);
79 return -1; 79 return -1;
80 } 80 }
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[])
48 if (uuid) 48 if (uuid)
49 free(uuid); 49 free(uuid);
50 50
51 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "lckdclient")) { 51 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "lckdclient")) {
52 iphone_device_free(phone); 52 iphone_device_free(phone);
53 return -1; 53 return -1;
54 } 54 }
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[])
153 return -1; 153 return -1;
154 } 154 }
155 155
156 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "msyncclient")) { 156 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "msyncclient")) {
157 iphone_device_free(phone); 157 iphone_device_free(phone);
158 return -1; 158 return -1;
159 } 159 }
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;
56 56
57/* Interface */ 57/* Interface */
58lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label); 58lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_t *client, const char *label);
59lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lockdownd_client_t *client, const char *label);
59lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); 60lockdownd_error_t lockdownd_client_free(lockdownd_client_t client);
60void lockdownd_client_set_label(lockdownd_client_t client, const char *label); 61void lockdownd_client_set_label(lockdownd_client_t client, const char *label);
61lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); 62lockdownd_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
618 return ret; 618 return ret;
619} 619}
620 620
621/** Creates a lockdownd client for the give iPhone 621/** Creates a lockdownd client for the device.
622 * 622 *
623 * @param phone The iPhone to create a lockdownd client for 623 * @param phone The device to create a lockdownd client for
624 * @param client The pointer to the location of the new lockdownd_client 624 * @param client The pointer to the location of the new lockdownd_client
625 * @param label The label to use for communication. Usually the program name 625 * @param label The label to use for communication. Usually the program name
626 * 626 *
@@ -630,9 +630,8 @@ lockdownd_error_t lockdownd_client_new(iphone_device_t device, lockdownd_client_
630{ 630{
631 if (!client) 631 if (!client)
632 return LOCKDOWN_E_INVALID_ARG; 632 return LOCKDOWN_E_INVALID_ARG;
633
633 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS; 634 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
634 char *host_id = NULL;
635 char *type = NULL;
636 635
637 property_list_service_client_t plistclient = NULL; 636 property_list_service_client_t plistclient = NULL;
638 if (property_list_service_client_new(device, 0xf27e, &plistclient) != PROPERTY_LIST_SERVICE_E_SUCCESS) { 637 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_
651 if (label != NULL) 650 if (label != NULL)
652 strdup(label); 651 strdup(label);
653 652
653 if (LOCKDOWN_E_SUCCESS == ret) {
654 *client = client_loc;
655 } else {
656 lockdownd_client_free(client_loc);
657 }
658
659 return ret;
660}
661
662/** Creates a lockdownd client for the device and starts initial handshake.
663 * The handshake consists of query_type, validate_pair, pair and
664 * start_session calls.
665 *
666 * @param phone The device to create a lockdownd client for
667 * @param client The pointer to the location of the new lockdownd_client
668 * @param label The label to use for communication. Usually the program name
669 *
670 * @return an error code (LOCKDOWN_E_SUCCESS on success)
671 */
672lockdownd_error_t lockdownd_client_new_with_handshake(iphone_device_t device, lockdownd_client_t *client, const char *label)
673{
674 if (!client)
675 return LOCKDOWN_E_INVALID_ARG;
676
677 lockdownd_error_t ret = LOCKDOWN_E_SUCCESS;
678 lockdownd_client_t client_loc = NULL;
679 char *host_id = NULL;
680 char *type = NULL;
681
682
683 ret = lockdownd_client_new(device, &client_loc, label);
684
685 /* perform handshake */
654 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) { 686 if (LOCKDOWN_E_SUCCESS != lockdownd_query_type(client_loc, &type)) {
655 log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__); 687 log_debug_msg("%s: QueryType failed in the lockdownd client.\n", __func__);
656 ret = LOCKDOWN_E_NOT_ENOUGH_DATA; 688 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) {
71 Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd)); 71 Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd));
72 client->dev = phone; 72 client->dev = phone;
73 client->client = NULL; 73 client->client = NULL;
74 if (LOCKDOWN_E_SUCCESS == lockdownd_client_new(phone->dev , &(client->client), NULL)) { 74 if (LOCKDOWN_E_SUCCESS == lockdownd_client_new_with_handshake(phone->dev , &(client->client), NULL)) {
75 return client; 75 return client;
76 } 76 }
77 else { 77 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[])
142 } 142 }
143 } 143 }
144 144
145 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphoneinfo")) { 145 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphoneinfo")) {
146 iphone_device_free(phone); 146 iphone_device_free(phone);
147 return -1; 147 return -1;
148 } 148 }
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[])
99 } 99 }
100 } 100 }
101 101
102 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client, "iphonesyslog")) { 102 if (LOCKDOWN_E_SUCCESS != lockdownd_client_new_with_handshake(phone, &client, "iphonesyslog")) {
103 iphone_device_free(phone); 103 iphone_device_free(phone);
104 return -1; 104 return -1;
105 } 105 }