summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AFC.c2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/iphone.c26
-rw-r--r--src/lockdown.c16
-rw-r--r--src/lockdown.h3
-rw-r--r--src/utils.c1
6 files changed, 29 insertions, 21 deletions
diff --git a/src/AFC.c b/src/AFC.c
index a1f7a08..67d37f3 100644
--- a/src/AFC.c
+++ b/src/AFC.c
@@ -227,7 +227,7 @@ static int receive_AFC_data(iphone_afc_client_t client, char **dump_here)
227 iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4, &bytes); 227 iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4, &bytes);
228 if (bytes <= 0) { 228 if (bytes <= 0) {
229 free(buffer); 229 free(buffer);
230 fprintf(stderr, "Just didn't get enough.\n"); 230 log_debug_msg("Just didn't get enough.\n");
231 *dump_here = NULL; 231 *dump_here = NULL;
232 return -1; 232 return -1;
233 } 233 }
diff --git a/src/Makefile.am b/src/Makefile.am
index 2e92fd1..1b97f45 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
1INCLUDES = -I$(top_srcdir)/include 1INCLUDES = -I$(top_srcdir)/include
2 2
3AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g 3AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g -Wall
4AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) $(libplist_LIBS) 4AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) $(libplist_LIBS)
5 5
6bin_PROGRAMS = libiphone-initconf 6bin_PROGRAMS = libiphone-initconf
diff --git a/src/iphone.c b/src/iphone.c
index 1f68180..6eb56f7 100644
--- a/src/iphone.c
+++ b/src/iphone.c
@@ -38,6 +38,8 @@
38static void iphone_config_usb_device(iphone_device_t phone) 38static void iphone_config_usb_device(iphone_device_t phone)
39{ 39{
40 int ret; 40 int ret;
41 int bytes;
42 unsigned char buf[512];
41 43
42 log_debug_msg("setting configuration... "); 44 log_debug_msg("setting configuration... ");
43 ret = usb_set_configuration(phone->device, 3); 45 ret = usb_set_configuration(phone->device, 3);
@@ -70,6 +72,14 @@ static void iphone_config_usb_device(iphone_device_t phone)
70 } else { 72 } else {
71 log_debug_msg("done.\n"); 73 log_debug_msg("done.\n");
72 } 74 }
75
76 do {
77 bytes = usb_bulk_read(phone->device, BULKIN, (void *) &buf, 512, 800);
78 if (bytes > 0) {
79 log_debug_msg("iphone_config_usb_device: initial read returned %d bytes of data.\n", bytes);
80 log_debug_buffer(buf, bytes);
81 }
82 } while (bytes > 0);
73} 83}
74 84
75/** 85/**
@@ -151,7 +161,7 @@ static iphone_error_t iphone_get_specific_device(unsigned int bus_n, int dev_n,
151 // Check for correct version 161 // Check for correct version
152 if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) { 162 if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) {
153 // We're all ready to roll. 163 // We're all ready to roll.
154 fprintf(stderr, "get_iPhone() success\n"); 164 log_debug_msg("get_iPhone() success\n");
155 free(version); 165 free(version);
156 *device = phone; 166 *device = phone;
157 return IPHONE_E_SUCCESS; 167 return IPHONE_E_SUCCESS;
@@ -219,12 +229,14 @@ iphone_error_t iphone_free_device(iphone_device_t device)
219 int bytes; 229 int bytes;
220 unsigned char buf[512]; 230 unsigned char buf[512];
221 231
222 // read final package 232 // read final package(s)
223 bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 1000); 233 do {
224 if (bytes > 0) { 234 bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800);
225 log_debug_msg("iphone_free_device: final read returned\n"); 235 if (bytes > 0) {
226 log_debug_buffer(buf, bytes); 236 log_debug_msg("iphone_free_device: final read returned\n");
227 } 237 log_debug_buffer(buf, bytes);
238 }
239 } while (bytes > 0);
228 240
229 if (device->buffer) { 241 if (device->buffer) {
230 free(device->buffer); 242 free(device->buffer);
diff --git a/src/lockdown.c b/src/lockdown.c
index b83b8cf..a02e6a8 100644
--- a/src/lockdown.c
+++ b/src/lockdown.c
@@ -77,7 +77,6 @@ static void iphone_lckd_stop_session(iphone_lckd_client_t control)
77 if (!control) 77 if (!control)
78 return; //IPHONE_E_INVALID_ARG; 78 return; //IPHONE_E_INVALID_ARG;
79 79
80 int bytes = 0, i = 0;
81 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; 80 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
82 81
83 plist_t dict = plist_new_dict(); 82 plist_t dict = plist_new_dict();
@@ -128,7 +127,6 @@ static void iphone_lckd_stop_session(iphone_lckd_client_t control)
128 return; // ret; 127 return; // ret;
129} 128}
130 129
131
132/** 130/**
133 * Shuts down the SSL session by first calling iphone_lckd_stop_session 131 * Shuts down the SSL session by first calling iphone_lckd_stop_session
134 * to cleanly close the lockdownd communication session, and then 132 * to cleanly close the lockdownd communication session, and then
@@ -159,7 +157,6 @@ static void iphone_lckd_stop_SSL_session(iphone_lckd_client_t client)
159 return; 157 return;
160} 158}
161 159
162
163/** Closes the lockdownd client and does the necessary housekeeping. 160/** Closes the lockdownd client and does the necessary housekeeping.
164 * 161 *
165 * @param control The lockdown client 162 * @param control The lockdown client
@@ -471,7 +468,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
471 468
472 iphone_lckd_client_t client_loc = new_lockdownd_client(device); 469 iphone_lckd_client_t client_loc = new_lockdownd_client(device);
473 if (IPHONE_E_SUCCESS != lockdownd_hello(client_loc)) { 470 if (IPHONE_E_SUCCESS != lockdownd_hello(client_loc)) {
474 fprintf(stderr, "Hello failed in the lockdownd client.\n"); 471 log_debug_msg("Hello failed in the lockdownd client.\n");
475 ret = IPHONE_E_NOT_ENOUGH_DATA; 472 ret = IPHONE_E_NOT_ENOUGH_DATA;
476 } 473 }
477 474
@@ -479,12 +476,12 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
479 char *uid = NULL; 476 char *uid = NULL;
480 ret = lockdownd_get_device_uid(client_loc, &uid); 477 ret = lockdownd_get_device_uid(client_loc, &uid);
481 if (IPHONE_E_SUCCESS != ret) { 478 if (IPHONE_E_SUCCESS != ret) {
482 fprintf(stderr, "Device refused to send uid.\n"); 479 log_debug_msg("Device refused to send uid.\n");
483 } 480 }
484 481
485 host_id = get_host_id(); 482 host_id = get_host_id();
486 if (IPHONE_E_SUCCESS == ret && !host_id) { 483 if (IPHONE_E_SUCCESS == ret && !host_id) {
487 fprintf(stderr, "No HostID found, run libiphone-initconf.\n"); 484 log_debug_msg("No HostID found, run libiphone-initconf.\n");
488 ret = IPHONE_E_INVALID_CONF; 485 ret = IPHONE_E_INVALID_CONF;
489 } 486 }
490 487
@@ -499,7 +496,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
499 ret = lockdownd_start_SSL_session(client_loc, host_id); 496 ret = lockdownd_start_SSL_session(client_loc, host_id);
500 if (IPHONE_E_SUCCESS != ret) { 497 if (IPHONE_E_SUCCESS != ret) {
501 ret = IPHONE_E_SSL_ERROR; 498 ret = IPHONE_E_SSL_ERROR;
502 fprintf(stderr, "SSL Session opening failed.\n"); 499 log_debug_msg("SSL Session opening failed.\n");
503 } 500 }
504 501
505 if (host_id) { 502 if (host_id) {
@@ -532,7 +529,7 @@ iphone_error_t lockdownd_pair_device(iphone_lckd_client_t control, char *uid, ch
532 529
533 ret = lockdownd_get_device_public_key(control, &public_key); 530 ret = lockdownd_get_device_public_key(control, &public_key);
534 if (ret != IPHONE_E_SUCCESS) { 531 if (ret != IPHONE_E_SUCCESS) {
535 fprintf(stderr, "Device refused to send public key.\n"); 532 log_debug_msg("Device refused to send public key.\n");
536 return ret; 533 return ret;
537 } 534 }
538 535
@@ -804,8 +801,7 @@ iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t
804iphone_error_t lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID) 801iphone_error_t lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID)
805{ 802{
806 plist_t dict = NULL; 803 plist_t dict = NULL;
807 char *XML_content = NULL; 804 uint32_t return_me = 0;
808 uint32_t length = 0, bytes = 0, return_me = 0;
809 805
810 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; 806 iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
811 control->session_id[0] = '\0'; 807 control->session_id[0] = '\0';
diff --git a/src/lockdown.h b/src/lockdown.h
index cdc46b8..2f2a4b9 100644
--- a/src/lockdown.h
+++ b/src/lockdown.h
@@ -42,9 +42,10 @@ struct iphone_lckd_client_int {
42 42
43iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone); 43iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone);
44iphone_error_t lockdownd_hello(iphone_lckd_client_t control); 44iphone_error_t lockdownd_hello(iphone_lckd_client_t control);
45
45iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string, 46iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string,
46 gnutls_datum_t * value); 47 gnutls_datum_t * value);
47iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid); 48
48iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key); 49iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key);
49 50
50iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t * device_cert, 51iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t * device_cert,
diff --git a/src/utils.c b/src/utils.c
index 988cb03..5b0872d 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -66,7 +66,6 @@ void log_debug_msg(const char *format, ...)
66void log_dbg_msg(uint16_t id, const char *format, ...) 66void log_dbg_msg(uint16_t id, const char *format, ...)
67{ 67{
68#ifndef STRIP_DEBUG_CODE 68#ifndef STRIP_DEBUG_CODE
69
70 if (id & dbg_mask) { 69 if (id & dbg_mask) {
71 va_list args; 70 va_list args;
72 /* run the real fprintf */ 71 /* run the real fprintf */