diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/iphone_id.c | 16 | ||||
| -rw-r--r-- | tools/iphoneinfo.c | 4 | ||||
| -rw-r--r-- | tools/iphonesyslog.c | 17 |
3 files changed, 17 insertions, 20 deletions
diff --git a/tools/iphone_id.c b/tools/iphone_id.c index 835e214..80f22e1 100644 --- a/tools/iphone_id.c +++ b/tools/iphone_id.c | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
| 4 | #include <libiphone/libiphone.h> | 4 | #include <libiphone/libiphone.h> |
| 5 | #include <libiphone/lockdown.h> | 5 | #include <libiphone/lockdown.h> |
| 6 | #include <usbmuxd.h> | ||
| 7 | 6 | ||
| 8 | #define MODE_NONE 0 | 7 | #define MODE_NONE 0 |
| 9 | #define MODE_SHOW_ID 1 | 8 | #define MODE_SHOW_ID 1 |
| @@ -18,7 +17,7 @@ static void print_usage(int argc, char **argv) | |||
| 18 | printf("Prints device name or a list of attached iPhone/iPod Touch devices.\n\n"); | 17 | printf("Prints device name or a list of attached iPhone/iPod Touch devices.\n\n"); |
| 19 | printf(" The UUID is a 40-digit hexadecimal number of the device\n"); | 18 | printf(" The UUID is a 40-digit hexadecimal number of the device\n"); |
| 20 | printf(" for which the name should be retrieved.\n\n"); | 19 | printf(" for which the name should be retrieved.\n\n"); |
| 21 | printf(" -l, --list\t\tlist all attached devices\n"); | 20 | printf(" -l, --list\t\tlist UUID of all attached devices\n"); |
| 22 | printf(" -d, --debug\t\tenable communication debugging\n"); | 21 | printf(" -d, --debug\t\tenable communication debugging\n"); |
| 23 | printf(" -h, --help\t\tprints usage information\n"); | 22 | printf(" -h, --help\t\tprints usage information\n"); |
| 24 | printf("\n"); | 23 | printf("\n"); |
| @@ -28,7 +27,7 @@ int main(int argc, char **argv) | |||
| 28 | { | 27 | { |
| 29 | iphone_device_t phone = NULL; | 28 | iphone_device_t phone = NULL; |
| 30 | lockdownd_client_t client = NULL; | 29 | lockdownd_client_t client = NULL; |
| 31 | usbmuxd_scan_result *dev_list; | 30 | char **dev_list = NULL; |
| 32 | char *devname = NULL; | 31 | char *devname = NULL; |
| 33 | int ret = 0; | 32 | int ret = 0; |
| 34 | int i; | 33 | int i; |
| @@ -65,7 +64,7 @@ int main(int argc, char **argv) | |||
| 65 | 64 | ||
| 66 | switch (mode) { | 65 | switch (mode) { |
| 67 | case MODE_SHOW_ID: | 66 | case MODE_SHOW_ID: |
| 68 | iphone_get_device_by_uuid(&phone, uuid); | 67 | iphone_device_new(&phone, uuid); |
| 69 | if (!phone) { | 68 | if (!phone) { |
| 70 | fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", uuid); | 69 | fprintf(stderr, "ERROR: No device with UUID=%s attached.\n", uuid); |
| 71 | return -2; | 70 | return -2; |
| @@ -96,13 +95,14 @@ int main(int argc, char **argv) | |||
| 96 | return ret; | 95 | return ret; |
| 97 | case MODE_LIST_DEVICES: | 96 | case MODE_LIST_DEVICES: |
| 98 | default: | 97 | default: |
| 99 | if (usbmuxd_scan(&dev_list) < 0) { | 98 | if (iphone_get_device_list(&dev_list, &i) < 0) { |
| 100 | fprintf(stderr, "ERROR: usbmuxd is not running!\n"); | 99 | fprintf(stderr, "ERROR: Unable to retrieve device list!\n"); |
| 101 | return -1; | 100 | return -1; |
| 102 | } | 101 | } |
| 103 | for (i = 0; dev_list[i].handle > 0; i++) { | 102 | for (i = 0; dev_list[i] != NULL; i++) { |
| 104 | printf("handle=%d product_id=%04x uuid=%s\n", dev_list[i].handle, dev_list[i].product_id, dev_list[i].serial_number); | 103 | printf("%s\n", dev_list[i]); |
| 105 | } | 104 | } |
| 105 | iphone_device_list_free(dev_list); | ||
| 106 | return 0; | 106 | return 0; |
| 107 | } | 107 | } |
| 108 | } | 108 | } |
diff --git a/tools/iphoneinfo.c b/tools/iphoneinfo.c index 09ba3e3..4d6da31 100644 --- a/tools/iphoneinfo.c +++ b/tools/iphoneinfo.c | |||
| @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) | |||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | if (uuid[0] != 0) { | 123 | if (uuid[0] != 0) { |
| 124 | ret = iphone_get_device_by_uuid(&phone, uuid); | 124 | ret = iphone_device_new(&phone, uuid); |
| 125 | if (ret != IPHONE_E_SUCCESS) { | 125 | if (ret != IPHONE_E_SUCCESS) { |
| 126 | printf("No device found with uuid %s, is it plugged in?\n", uuid); | 126 | printf("No device found with uuid %s, is it plugged in?\n", uuid); |
| 127 | return -1; | 127 | return -1; |
| @@ -129,7 +129,7 @@ int main(int argc, char *argv[]) | |||
| 129 | } | 129 | } |
| 130 | else | 130 | else |
| 131 | { | 131 | { |
| 132 | ret = iphone_get_device(&phone); | 132 | ret = iphone_device_new(&phone, NULL); |
| 133 | if (ret != IPHONE_E_SUCCESS) { | 133 | if (ret != IPHONE_E_SUCCESS) { |
| 134 | printf("No device found, is it plugged in?\n"); | 134 | printf("No device found, is it plugged in?\n"); |
| 135 | return -1; | 135 | return -1; |
diff --git a/tools/iphonesyslog.c b/tools/iphonesyslog.c index a096101..8fa3b04 100644 --- a/tools/iphonesyslog.c +++ b/tools/iphonesyslog.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | 28 | ||
| 29 | #include <libiphone/libiphone.h> | 29 | #include <libiphone/libiphone.h> |
| 30 | #include <libiphone/lockdown.h> | 30 | #include <libiphone/lockdown.h> |
| 31 | #include <usbmuxd.h> | ||
| 32 | 31 | ||
| 33 | static int quit_flag = 0; | 32 | static int quit_flag = 0; |
| 34 | 33 | ||
| @@ -52,7 +51,6 @@ int main(int argc, char *argv[]) | |||
| 52 | char uuid[41]; | 51 | char uuid[41]; |
| 53 | int port = 0; | 52 | int port = 0; |
| 54 | uuid[0] = 0; | 53 | uuid[0] = 0; |
| 55 | uint32_t handle = 0; | ||
| 56 | 54 | ||
| 57 | signal(SIGINT, clean_exit); | 55 | signal(SIGINT, clean_exit); |
| 58 | signal(SIGQUIT, clean_exit); | 56 | signal(SIGQUIT, clean_exit); |
| @@ -86,7 +84,7 @@ int main(int argc, char *argv[]) | |||
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | if (uuid[0] != 0) { | 86 | if (uuid[0] != 0) { |
| 89 | ret = iphone_get_device_by_uuid(&phone, uuid); | 87 | ret = iphone_device_new(&phone, uuid); |
| 90 | if (ret != IPHONE_E_SUCCESS) { | 88 | if (ret != IPHONE_E_SUCCESS) { |
| 91 | printf("No device found with uuid %s, is it plugged in?\n", uuid); | 89 | printf("No device found with uuid %s, is it plugged in?\n", uuid); |
| 92 | return -1; | 90 | return -1; |
| @@ -94,7 +92,7 @@ int main(int argc, char *argv[]) | |||
| 94 | } | 92 | } |
| 95 | else | 93 | else |
| 96 | { | 94 | { |
| 97 | ret = iphone_get_device(&phone); | 95 | ret = iphone_device_new(&phone, NULL); |
| 98 | if (ret != IPHONE_E_SUCCESS) { | 96 | if (ret != IPHONE_E_SUCCESS) { |
| 99 | printf("No device found, is it plugged in?\n"); | 97 | printf("No device found, is it plugged in?\n"); |
| 100 | return -1; | 98 | return -1; |
| @@ -112,16 +110,15 @@ int main(int argc, char *argv[]) | |||
| 112 | lockdownd_client_free(client); | 110 | lockdownd_client_free(client); |
| 113 | 111 | ||
| 114 | /* connect to socket relay messages */ | 112 | /* connect to socket relay messages */ |
| 115 | iphone_device_get_handle(phone, &handle); | 113 | iphone_connection_t conn = NULL; |
| 116 | int sfd = usbmuxd_connect(handle, port); | 114 | if ((iphone_device_connect(phone, port, &conn) != IPHONE_E_SUCCESS) || !conn) { |
| 117 | if (sfd < 0) { | ||
| 118 | printf("ERROR: Could not open usbmux connection.\n"); | 115 | printf("ERROR: Could not open usbmux connection.\n"); |
| 119 | } else { | 116 | } else { |
| 120 | while (!quit_flag) { | 117 | while (!quit_flag) { |
| 121 | char *receive = NULL; | 118 | char *receive = NULL; |
| 122 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; | 119 | uint32_t datalen = 0, bytes = 0, recv_bytes = 0; |
| 123 | 120 | ||
| 124 | ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); | 121 | ret = iphone_device_recv(conn, (char *) &datalen, sizeof(datalen), &bytes); |
| 125 | datalen = ntohl(datalen); | 122 | datalen = ntohl(datalen); |
| 126 | 123 | ||
| 127 | if (datalen == 0) | 124 | if (datalen == 0) |
| @@ -131,7 +128,7 @@ int main(int argc, char *argv[]) | |||
| 131 | receive = (char *) malloc(sizeof(char) * datalen); | 128 | receive = (char *) malloc(sizeof(char) * datalen); |
| 132 | 129 | ||
| 133 | while (!quit_flag && (recv_bytes <= datalen)) { | 130 | while (!quit_flag && (recv_bytes <= datalen)) { |
| 134 | ret = usbmuxd_recv(sfd, receive, datalen, &bytes); | 131 | ret = iphone_device_recv(conn, receive, datalen, &bytes); |
| 135 | 132 | ||
| 136 | if (bytes == 0) | 133 | if (bytes == 0) |
| 137 | break; | 134 | break; |
| @@ -144,7 +141,7 @@ int main(int argc, char *argv[]) | |||
| 144 | free(receive); | 141 | free(receive); |
| 145 | } | 142 | } |
| 146 | } | 143 | } |
| 147 | usbmuxd_disconnect(sfd); | 144 | iphone_device_disconnect(conn); |
| 148 | } else { | 145 | } else { |
| 149 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); | 146 | printf("ERROR: Could not start service com.apple.syslog_relay.\n"); |
| 150 | } | 147 | } |
