diff options
Diffstat (limited to 'libirecovery.c')
-rw-r--r-- | libirecovery.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/libirecovery.c b/libirecovery.c index 278a529..1a6d58f 100644 --- a/libirecovery.c +++ b/libirecovery.c @@ -33,6 +33,8 @@ #include "libirecovery.h" +#define USB_TIMEOUT 5000 + #define BUFFER_SIZE 0x1000 #define debug(...) if(libirecovery_debug) fprintf(stderr, __VA_ARGS__) @@ -291,7 +293,7 @@ int irecv_get_string_descriptor_ascii(irecv_client_t client, uint8_t desc_index, memset(data, 0, sizeof(data)); memset(buffer, 0, size); - ret = irecv_control_transfer(client, 0x80, 0x06, (0x03 << 8) | desc_index, langid, data, sizeof(data), 1000); + ret = irecv_control_transfer(client, 0x80, 0x06, (0x03 << 8) | desc_index, langid, data, sizeof(data), USB_TIMEOUT); if (ret < 0) return ret; if (data[1] != 0x03) return IRECV_E_UNKNOWN_ERROR; @@ -581,7 +583,7 @@ static irecv_error_t irecv_send_command_raw(irecv_client_t client, char* command } if (length > 0) { - int ret = irecv_control_transfer(client, 0x40, 0, 0, 0, (unsigned char*) command, length + 1, 1000); + int ret = irecv_control_transfer(client, 0x40, 0, 0, 0, (unsigned char*) command, length + 1, USB_TIMEOUT); } return IRECV_E_SUCCESS; @@ -664,7 +666,7 @@ irecv_error_t irecv_get_status(irecv_client_t client, unsigned int* status) { unsigned char buffer[6]; memset(buffer, '\0', 6); - if (irecv_control_transfer(client, 0xA1, 3, 0, 0, buffer, 6, 1000) != 6) { + if (irecv_control_transfer(client, 0xA1, 3, 0, 0, buffer, 6, USB_TIMEOUT) != 6) { *status = 0; return IRECV_E_USB_STATUS; } @@ -689,9 +691,9 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un /* initiate transfer */ if (recovery_mode) { - error = irecv_control_transfer(client, 0x41, 0, 0, 0, NULL, 0, 1000); + error = irecv_control_transfer(client, 0x41, 0, 0, 0, NULL, 0, USB_TIMEOUT); } else { - error = irecv_control_transfer(client, 0x21, 4, 0, 0, NULL, 0, 1000); + error = irecv_control_transfer(client, 0x21, 4, 0, 0, NULL, 0, USB_TIMEOUT); } if (error != IRECV_E_SUCCESS) { return error; @@ -707,9 +709,9 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un /* Use bulk transfer for recovery mode and control transfer for DFU and WTF mode */ if (recovery_mode) { - error = irecv_bulk_transfer(client, 0x04, &buffer[i * packet_size], size, &bytes, 1000); + error = irecv_bulk_transfer(client, 0x04, &buffer[i * packet_size], size, &bytes, USB_TIMEOUT); } else { - bytes = irecv_control_transfer(client, 0x21, 1, 0, 0, &buffer[i * packet_size], size, 1000); + bytes = irecv_control_transfer(client, 0x21, 1, 0, 0, &buffer[i * packet_size], size, USB_TIMEOUT); } if (bytes != size) { @@ -742,7 +744,7 @@ irecv_error_t irecv_send_buffer(irecv_client_t client, unsigned char* buffer, un } if (dfuNotifyFinished && !recovery_mode) { - irecv_control_transfer(client, 0x21, 1, 0, 0, (unsigned char*) buffer, 0, 1000); + irecv_control_transfer(client, 0x21, 1, 0, 0, (unsigned char*) buffer, 0, USB_TIMEOUT); for (i = 0; i < 3; i++) { error = irecv_get_status(client, &status); @@ -806,7 +808,7 @@ irecv_error_t irecv_getenv(irecv_client_t client, const char* variable, char** v } memset(response, '\0', 256); - ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, 1000); + ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT); *value = response; return IRECV_E_SUCCESS; @@ -823,7 +825,7 @@ irecv_error_t irecv_getret(irecv_client_t client, unsigned int* value) { } memset(response, '\0', 256); - ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, 1000); + ret = irecv_control_transfer(client, 0xC0, 0, 0, 0, (unsigned char*) response, 255, USB_TIMEOUT); *value = (unsigned int) *response; return IRECV_E_SUCCESS; @@ -909,7 +911,7 @@ irecv_error_t irecv_get_imei(irecv_client_t client, unsigned char* imei) { irecv_error_t irecv_send_exploit(irecv_client_t client) { if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; - irecv_control_transfer(client, 0x21, 2, 0, 0, NULL, 0, 1000); + irecv_control_transfer(client, 0x21, 2, 0, 0, NULL, 0, USB_TIMEOUT); return IRECV_E_SUCCESS; } @@ -1078,7 +1080,7 @@ int irecv_read_file(const char* filename, char** data, uint32_t* size) { irecv_error_t irecv_reset_counters(irecv_client_t client) { if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; if (client->mode == kDfuMode) { - irecv_control_transfer(client, 0x21, 4, 0, 0, 0, 0, 1000); + irecv_control_transfer(client, 0x21, 4, 0, 0, 0, 0, USB_TIMEOUT); } return IRECV_E_SUCCESS; } @@ -1105,7 +1107,7 @@ irecv_error_t irecv_recv_buffer(irecv_client_t client, char* buffer, unsigned lo unsigned int status = 0; for (i = 0; i < packets; i++) { unsigned short size = (i+1) < packets ? packet_size : last; - bytes = irecv_control_transfer(client, 0xA1, 2, 0, 0, &buffer[i * packet_size], size, 1000); + bytes = irecv_control_transfer(client, 0xA1, 2, 0, 0, &buffer[i * packet_size], size, USB_TIMEOUT); if (bytes != size) { return IRECV_E_USB_UPLOAD; @@ -1133,7 +1135,7 @@ irecv_error_t irecv_finish_transfer(irecv_client_t client) { if (check_context(client) != IRECV_E_SUCCESS) return IRECV_E_NO_DEVICE; - irecv_control_transfer(client, 0x21, 1, 0, 0, 0, 0, 1000); + irecv_control_transfer(client, 0x21, 1, 0, 0, 0, 0, USB_TIMEOUT); for(i = 0; i < 3; i++){ irecv_get_status(client, &status); @@ -1231,19 +1233,19 @@ irecv_error_t irecv_get_device(irecv_client_t client, irecv_device_t* device) { } switch (bdid) { - case BDID_IPAD21 + case BDID_IPAD21: device_id = DEVICE_IPAD21; break; - case BDID_IPAD22 + case BDID_IPAD22: device_id = DEVICE_IPAD22; break; - case BDID_IPAD23 + case BDID_IPAD23: device_id = DEVICE_IPAD23; break; - case BDID_IPHONE4S + case BDID_IPHONE4S: device_id = DEVICE_IPHONE4S; break; |