summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-01-29 18:02:04 +0100
committerGravatar Jonathan Beck2009-01-29 18:02:04 +0100
commitc1b2004461aaf2912af749620e7504345bf409ba (patch)
tree2c238a2d8c1598265a07a2fd52beec0939d08a73 /src
parent0934d1ac021dfb7907e4b580b38aa4a938cf2180 (diff)
parentf7fbac7803c5cb5934aab58925babc70af4ab848 (diff)
downloadlibimobiledevice-c1b2004461aaf2912af749620e7504345bf409ba.tar.gz
libimobiledevice-c1b2004461aaf2912af749620e7504345bf409ba.tar.bz2
Merge branch 'master' into contact_sync
Conflicts: src/Makefile.am src/iphone.c src/lockdown.c src/lockdown.h src/utils.c
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)
iphone_mux_recv(client->connection, buffer, sizeof(AFCPacket) * 4, &bytes);
if (bytes <= 0) {
free(buffer);
- fprintf(stderr, "Just didn't get enough.\n");
+ log_debug_msg("Just didn't get enough.\n");
*dump_here = NULL;
return -1;
}
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 @@
INCLUDES = -I$(top_srcdir)/include
-AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g
+AM_CFLAGS = $(libxml2_CFLAGS) $(libusb_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(libplist_CFLAGS) -g -Wall
AM_LDFLAGS = $(libxml2_LIBS) $(libusb_LIBS) $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) $(libplist_LIBS)
bin_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 @@
static void iphone_config_usb_device(iphone_device_t phone)
{
int ret;
+ int bytes;
+ unsigned char buf[512];
log_debug_msg("setting configuration... ");
ret = usb_set_configuration(phone->device, 3);
@@ -70,6 +72,14 @@ static void iphone_config_usb_device(iphone_device_t phone)
} else {
log_debug_msg("done.\n");
}
+
+ do {
+ bytes = usb_bulk_read(phone->device, BULKIN, (void *) &buf, 512, 800);
+ if (bytes > 0) {
+ log_debug_msg("iphone_config_usb_device: initial read returned %d bytes of data.\n", bytes);
+ log_debug_buffer(buf, bytes);
+ }
+ } while (bytes > 0);
}
/**
@@ -151,7 +161,7 @@ static iphone_error_t iphone_get_specific_device(unsigned int bus_n, int dev_n,
// Check for correct version
if (ntohl(version->major) == 1 && ntohl(version->minor) == 0) {
// We're all ready to roll.
- fprintf(stderr, "get_iPhone() success\n");
+ log_debug_msg("get_iPhone() success\n");
free(version);
*device = phone;
return IPHONE_E_SUCCESS;
@@ -219,12 +229,14 @@ iphone_error_t iphone_free_device(iphone_device_t device)
int bytes;
unsigned char buf[512];
- // read final package
- bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 1000);
- if (bytes > 0) {
- log_debug_msg("iphone_free_device: final read returned\n");
- log_debug_buffer(buf, bytes);
- }
+ // read final package(s)
+ do {
+ bytes = usb_bulk_read(device->device, BULKIN, (void *) &buf, 512, 800);
+ if (bytes > 0) {
+ log_debug_msg("iphone_free_device: final read returned\n");
+ log_debug_buffer(buf, bytes);
+ }
+ } while (bytes > 0);
if (device->buffer) {
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)
if (!control)
return; //IPHONE_E_INVALID_ARG;
- int bytes = 0, i = 0;
iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
plist_t dict = plist_new_dict();
@@ -128,7 +127,6 @@ static void iphone_lckd_stop_session(iphone_lckd_client_t control)
return; // ret;
}
-
/**
* Shuts down the SSL session by first calling iphone_lckd_stop_session
* 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)
return;
}
-
/** Closes the lockdownd client and does the necessary housekeeping.
*
* @param control The lockdown client
@@ -471,7 +468,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
iphone_lckd_client_t client_loc = new_lockdownd_client(device);
if (IPHONE_E_SUCCESS != lockdownd_hello(client_loc)) {
- fprintf(stderr, "Hello failed in the lockdownd client.\n");
+ log_debug_msg("Hello failed in the lockdownd client.\n");
ret = IPHONE_E_NOT_ENOUGH_DATA;
}
@@ -479,12 +476,12 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
char *uid = NULL;
ret = lockdownd_get_device_uid(client_loc, &uid);
if (IPHONE_E_SUCCESS != ret) {
- fprintf(stderr, "Device refused to send uid.\n");
+ log_debug_msg("Device refused to send uid.\n");
}
host_id = get_host_id();
if (IPHONE_E_SUCCESS == ret && !host_id) {
- fprintf(stderr, "No HostID found, run libiphone-initconf.\n");
+ log_debug_msg("No HostID found, run libiphone-initconf.\n");
ret = IPHONE_E_INVALID_CONF;
}
@@ -499,7 +496,7 @@ iphone_error_t iphone_lckd_new_client(iphone_device_t device, iphone_lckd_client
ret = lockdownd_start_SSL_session(client_loc, host_id);
if (IPHONE_E_SUCCESS != ret) {
ret = IPHONE_E_SSL_ERROR;
- fprintf(stderr, "SSL Session opening failed.\n");
+ log_debug_msg("SSL Session opening failed.\n");
}
if (host_id) {
@@ -532,7 +529,7 @@ iphone_error_t lockdownd_pair_device(iphone_lckd_client_t control, char *uid, ch
ret = lockdownd_get_device_public_key(control, &public_key);
if (ret != IPHONE_E_SUCCESS) {
- fprintf(stderr, "Device refused to send public key.\n");
+ log_debug_msg("Device refused to send public key.\n");
return ret;
}
@@ -804,8 +801,7 @@ iphone_error_t lockdownd_gen_pair_cert(gnutls_datum_t public_key, gnutls_datum_t
iphone_error_t lockdownd_start_SSL_session(iphone_lckd_client_t control, const char *HostID)
{
plist_t dict = NULL;
- char *XML_content = NULL;
- uint32_t length = 0, bytes = 0, return_me = 0;
+ uint32_t return_me = 0;
iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR;
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 {
iphone_lckd_client_t new_lockdownd_client(iphone_device_t phone);
iphone_error_t lockdownd_hello(iphone_lckd_client_t control);
+
iphone_error_t lockdownd_generic_get_value(iphone_lckd_client_t control, const char *req_key, char *req_string,
gnutls_datum_t * value);
-iphone_error_t lockdownd_get_device_uid(iphone_lckd_client_t control, char **uid);
+
iphone_error_t lockdownd_get_device_public_key(iphone_lckd_client_t control, gnutls_datum_t * public_key);
iphone_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, ...)
void log_dbg_msg(uint16_t id, const char *format, ...)
{
#ifndef STRIP_DEBUG_CODE
-
if (id & dbg_mask) {
va_list args;
/* run the real fprintf */