From 76e3f71c1aa7d54b2653073a32ae42c8088ca72a Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 20 Nov 2013 17:00:35 +0100 Subject: dfu: Implement dfu_get_ecid() to fix connectivity issues from DFU mode --- src/dfu.c | 19 +++++++++++++++++++ src/dfu.h | 1 + src/idevicerestore.c | 6 ++++++ 3 files changed, 26 insertions(+) (limited to 'src') diff --git a/src/dfu.c b/src/dfu.c index c580c72..3bdd419 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -253,6 +253,25 @@ int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid) { return 0; } +int dfu_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) { + irecv_error_t recovery_error = IRECV_E_SUCCESS; + + if(client->dfu == NULL) { + if (dfu_client_new(client) < 0) { + return -1; + } + } + + const struct irecv_device_info *device_info = irecv_get_device_info(client->dfu->client); + if (!device_info) { + return -1; + } + + *ecid = device_info->ecid; + + return 0; +} + int dfu_is_image4_supported(struct idevicerestore_client_t* client) { if(client->dfu == NULL) { diff --git a/src/dfu.h b/src/dfu.h index 427754a..1d297bb 100644 --- a/src/dfu.h +++ b/src/dfu.h @@ -44,6 +44,7 @@ const char* dfu_check_product_type(struct idevicerestore_client_t* client); int dfu_send_buffer(struct idevicerestore_client_t* client, unsigned char* buffer, unsigned int size); int dfu_send_component(struct idevicerestore_client_t* client, plist_t build_identity, const char* component); int dfu_get_cpid(struct idevicerestore_client_t* client, unsigned int* cpid); +int dfu_get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid); int dfu_is_image4_supported(struct idevicerestore_client_t* client); int dfu_get_ap_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size); int dfu_get_sep_nonce(struct idevicerestore_client_t* client, unsigned char** nonce, int* nonce_size); diff --git a/src/idevicerestore.c b/src/idevicerestore.c index dcd538e..d1db628 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -754,6 +754,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client) // if the device is in DFU mode, place device into recovery mode if (client->mode->index == MODE_DFU) { + dfu_client_free(client); recovery_client_free(client); if ((client->flags & FLAG_CUSTOM) && limera1n_is_supported(client->device)) { info("connecting to DFU\n"); @@ -1225,6 +1226,11 @@ int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) { break; case MODE_DFU: + if (dfu_get_ecid(client, ecid) < 0) { + *ecid = 0; + return -1; + } + break; case MODE_RECOVERY: if (recovery_get_ecid(client, ecid) < 0) { *ecid = 0; -- cgit v1.1-32-gdbae