diff options
| author | 2009-08-01 18:54:59 +0200 | |
|---|---|---|
| committer | 2009-08-01 18:54:59 +0200 | |
| commit | 5844d66be35d300ffb47dd03917a921900963fd5 (patch) | |
| tree | d69b94d19b656a7ae6f630d064da0fcfaad85b35 /dev | |
| parent | 14868dc30c7e59f9838a6b67e2e15673f0f1557b (diff) | |
| download | libimobiledevice-5844d66be35d300ffb47dd03917a921900963fd5.tar.gz libimobiledevice-5844d66be35d300ffb47dd03917a921900963fd5.tar.bz2 | |
Add new iphoneenterrecovery dev tool to make a device enter recovery mode
Diffstat (limited to 'dev')
| -rw-r--r-- | dev/Makefile.am | 7 | ||||
| -rw-r--r-- | dev/iphoneenterrecovery.c | 94 |
2 files changed, 100 insertions, 1 deletions
diff --git a/dev/Makefile.am b/dev/Makefile.am index 70cd52b..c41b663 100644 --- a/dev/Makefile.am +++ b/dev/Makefile.am | |||
| @@ -3,7 +3,7 @@ INCLUDES = -I$(top_srcdir)/include | |||
| 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) | 3 | AM_CFLAGS = $(GLOBAL_CFLAGS) $(libglib2_CFLAGS) $(libgnutls_CFLAGS) $(libtasn1_CFLAGS) $(libgthread2_CFLAGS) $(LFS_CFLAGS) |
| 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) | 4 | AM_LDFLAGS = $(libglib2_LIBS) $(libgnutls_LIBS) $(libtasn1_LIBS) $(libgthread2_LIBS) |
| 5 | 5 | ||
| 6 | noinst_PROGRAMS = iphoneclient lckd-client afccheck msyncclient | 6 | noinst_PROGRAMS = iphoneclient lckd-client afccheck msyncclient iphoneenterrecovery |
| 7 | 7 | ||
| 8 | iphoneclient_SOURCES = iphoneclient.c | 8 | iphoneclient_SOURCES = iphoneclient.c |
| 9 | iphoneclient_LDADD = ../src/libiphone.la | 9 | iphoneclient_LDADD = ../src/libiphone.la |
| @@ -22,3 +22,8 @@ msyncclient_SOURCES = msyncclient.c | |||
| 22 | msyncclient_CFLAGS = $(AM_CFLAGS) | 22 | msyncclient_CFLAGS = $(AM_CFLAGS) |
| 23 | msyncclient_LDFLAGS = $(AM_LDFLAGS) | 23 | msyncclient_LDFLAGS = $(AM_LDFLAGS) |
| 24 | msyncclient_LDADD = ../src/libiphone.la | 24 | msyncclient_LDADD = ../src/libiphone.la |
| 25 | |||
| 26 | iphoneenterrecovery_SOURCES = iphoneenterrecovery.c | ||
| 27 | iphoneenterrecovery_CFLAGS = $(AM_CFLAGS) | ||
| 28 | iphoneenterrecovery_LDFLAGS = $(AM_LDFLAGS) | ||
| 29 | iphoneenterrecovery_LDADD = ../src/libiphone.la | ||
diff --git a/dev/iphoneenterrecovery.c b/dev/iphoneenterrecovery.c new file mode 100644 index 0000000..2f7891c --- /dev/null +++ b/dev/iphoneenterrecovery.c | |||
| @@ -0,0 +1,94 @@ | |||
| 1 | /* | ||
| 2 | * iphoneenterrecovery.c | ||
| 3 | * Simple utility to make a device in normal mode enter recovery mode. | ||
| 4 | * | ||
| 5 | * Copyright (c) 2009 Martin Szulecki All Rights Reserved. | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <stdio.h> | ||
| 23 | #include <string.h> | ||
| 24 | #include <errno.h> | ||
| 25 | #include <stdlib.h> | ||
| 26 | |||
| 27 | #include <libiphone/libiphone.h> | ||
| 28 | #include <libiphone/lockdown.h> | ||
| 29 | |||
| 30 | static void print_usage(int argc, char **argv) | ||
| 31 | { | ||
| 32 | char *name = NULL; | ||
| 33 | |||
| 34 | name = strrchr(argv[0], '/'); | ||
| 35 | printf("Usage: %s [OPTIONS] UUID\n", (name ? name + 1: argv[0])); | ||
| 36 | printf("Makes a device with the supplied 40-digit UUID enter recovery mode immediately.\n\n"); | ||
| 37 | printf(" -d, --debug\t\tenable communication debugging\n"); | ||
| 38 | printf(" -h, --help\t\tprints usage information\n"); | ||
| 39 | printf("\n"); | ||
| 40 | } | ||
| 41 | |||
| 42 | int main(int argc, char *argv[]) | ||
| 43 | { | ||
| 44 | lockdownd_client_t client = NULL; | ||
| 45 | iphone_device_t phone = NULL; | ||
| 46 | iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; | ||
| 47 | int i; | ||
| 48 | char uuid[41]; | ||
| 49 | uuid[0] = 0; | ||
| 50 | |||
| 51 | /* parse cmdline args */ | ||
| 52 | for (i = 1; i < argc; i++) { | ||
| 53 | if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug")) { | ||
| 54 | iphone_set_debug_mask(DBGMASK_ALL); | ||
| 55 | iphone_set_debug_level(1); | ||
| 56 | continue; | ||
| 57 | } | ||
| 58 | else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { | ||
| 59 | print_usage(argc, argv); | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | } | ||
| 63 | |||
| 64 | i--; | ||
| 65 | if (!argv[i] || (strlen(argv[i]) != 40)) { | ||
| 66 | print_usage(argc, argv); | ||
| 67 | return 0; | ||
| 68 | } | ||
| 69 | strcpy(uuid, argv[i]); | ||
| 70 | |||
| 71 | ret = iphone_get_device_by_uuid(&phone, uuid); | ||
| 72 | if (ret != IPHONE_E_SUCCESS) { | ||
| 73 | printf("No device found with uuid %s, is it plugged in?\n", uuid); | ||
| 74 | return -1; | ||
| 75 | } | ||
| 76 | |||
| 77 | if (LOCKDOWN_E_SUCCESS != lockdownd_client_new(phone, &client)) { | ||
| 78 | iphone_device_free(phone); | ||
| 79 | return -1; | ||
| 80 | } | ||
| 81 | |||
| 82 | /* run query and output information */ | ||
| 83 | printf("Telling device with uuid %s to enter recovery mode.}\n", uuid); | ||
| 84 | if(lockdownd_enter_recovery(client) != LOCKDOWN_E_SUCCESS) | ||
| 85 | { | ||
| 86 | printf("Failed to enter recovery mode.\n"); | ||
| 87 | } | ||
| 88 | printf("Device is successfully switching to recovery mode.\n"); | ||
| 89 | |||
| 90 | lockdownd_client_free(client); | ||
| 91 | iphone_device_free(phone); | ||
| 92 | |||
| 93 | return 0; | ||
| 94 | } | ||
