From 8eaac0513bfb238edec22d46320669f5c9c76542 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 18 May 2009 22:29:39 +0200 Subject: Make use of usbmuxd and remove libusb dependencies Signed-off-by: Matt Colyer --- dev/syslog_relay.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'dev/syslog_relay.c') diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 56cf56c..35c684a 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -27,6 +27,7 @@ #include #include +#include static int quit_flag = 0; @@ -78,7 +79,7 @@ int main(int argc, char *argv[]) } } - if (bus_n != -1) { +/* if (bus_n != -1) { ret = iphone_get_specific_device(bus_n, dev_n, &phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); @@ -86,13 +87,13 @@ int main(int argc, char *argv[]) } } else - { + {*/ ret = iphone_get_device(&phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found, is it plugged in?\n"); return -1; } - } +/* }*/ if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { iphone_free_device(phone); @@ -103,15 +104,19 @@ int main(int argc, char *argv[]) ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); if ((ret == IPHONE_E_SUCCESS) && port) { /* connect to socket relay messages */ - iphone_umux_client_t syslog_client = NULL; + //iphone_umux_client_t syslog_client = NULL; - ret = iphone_mux_new_client(phone, 514, port, &syslog_client); - if (ret == IPHONE_E_SUCCESS) { + //ret = iphone_mux_new_client(phone, 514, port, &syslog_client); + int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); + //if (ret == IPHONE_E_SUCCESS) { + if (sfd < 0) { + printf("ERROR: Could not open usbmux connection.\n"); + } else { while (!quit_flag) { char *receive = NULL; uint32_t datalen = 0, bytes = 0, recv_bytes = 0; - ret = iphone_mux_recv(syslog_client, (char *) &datalen, sizeof(datalen), &bytes); + ret = usbmuxd_recv(sfd, (char *) &datalen, sizeof(datalen), &bytes); datalen = ntohl(datalen); if (datalen == 0) @@ -121,7 +126,7 @@ int main(int argc, char *argv[]) receive = (char *) malloc(sizeof(char) * datalen); while (!quit_flag && (recv_bytes <= datalen)) { - ret = iphone_mux_recv(syslog_client, receive, datalen, &bytes); + ret = usbmuxd_recv(sfd, receive, datalen, &bytes); if (bytes == 0) break; @@ -133,10 +138,8 @@ int main(int argc, char *argv[]) free(receive); } - } else { - printf("ERROR: Could not open usbmux connection.\n"); } - iphone_mux_free_client(syslog_client); + usbmuxd_disconnect(sfd); //iphone_mux_free_client(syslog_client); } else { printf("ERROR: Could not start service com.apple.syslog_relay.\n"); } -- cgit v1.1-32-gdbae From 34b8e4d575876ace41b91fb6e25a5fa9f9290608 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 19 May 2009 12:44:19 +0200 Subject: lockdown: Check for gnutls errors and silence compiler warnings. general: Removed some commented-out code. [#39 state:resolved] Signed-off-by: Matt Colyer --- dev/syslog_relay.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'dev/syslog_relay.c') diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 35c684a..6fc981b 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -104,11 +104,8 @@ int main(int argc, char *argv[]) ret = iphone_lckd_start_service(control, "com.apple.syslog_relay", &port); if ((ret == IPHONE_E_SUCCESS) && port) { /* connect to socket relay messages */ - //iphone_umux_client_t syslog_client = NULL; - //ret = iphone_mux_new_client(phone, 514, port, &syslog_client); int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port); - //if (ret == IPHONE_E_SUCCESS) { if (sfd < 0) { printf("ERROR: Could not open usbmux connection.\n"); } else { @@ -139,7 +136,7 @@ int main(int argc, char *argv[]) free(receive); } } - usbmuxd_disconnect(sfd); //iphone_mux_free_client(syslog_client); + usbmuxd_disconnect(sfd); } else { printf("ERROR: Could not start service com.apple.syslog_relay.\n"); } -- cgit v1.1-32-gdbae From b61667e9eae1a588815453ccdaa8721e228cc0b8 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Tue, 19 May 2009 13:15:11 +0200 Subject: Adapted iphoneinfo and iphonesyslog to new API to allow device selection Added iphone_id tool to list devices attached and retrieve device name. Signed-off-by: Matt Colyer --- dev/syslog_relay.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'dev/syslog_relay.c') diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c index 6fc981b..3407f2f 100644 --- a/dev/syslog_relay.c +++ b/dev/syslog_relay.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -48,8 +47,9 @@ int main(int argc, char *argv[]) iphone_device_t phone = NULL; iphone_error_t ret = IPHONE_E_UNKNOWN_ERROR; int i; - int bus_n = -1, dev_n = -1; + char uuid[41]; int port = 0; + uuid[0] = 0; signal(SIGINT, clean_exit); signal(SIGQUIT, clean_exit); @@ -62,11 +62,13 @@ int main(int argc, char *argv[]) iphone_set_debug_mask(DBGMASK_ALL); continue; } - else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--usb")) { - if (sscanf(argv[++i], "%d,%d", &bus_n, &dev_n) < 2) { + else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { + i++; + if (!argv[i] || (strlen(argv[i]) != 40)) { print_usage(argc, argv); return 0; } + strcpy(uuid, argv[i]); continue; } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { @@ -79,21 +81,21 @@ int main(int argc, char *argv[]) } } -/* if (bus_n != -1) { - ret = iphone_get_specific_device(bus_n, dev_n, &phone); + if (uuid[0] != 0) { + ret = iphone_get_device_by_uuid(&phone, uuid); if (ret != IPHONE_E_SUCCESS) { - printf("No device found for usb bus %d and dev %d, is it plugged in?\n", bus_n, dev_n); + printf("No device found with uuid %s, is it plugged in?\n", uuid); return -1; } } else - {*/ + { ret = iphone_get_device(&phone); if (ret != IPHONE_E_SUCCESS) { printf("No device found, is it plugged in?\n"); return -1; } -/* }*/ + } if (IPHONE_E_SUCCESS != iphone_lckd_new_client(phone, &control)) { iphone_free_device(phone); @@ -152,7 +154,7 @@ void print_usage(int argc, char **argv) printf("Usage: %s [OPTIONS]\n", (strrchr(argv[0], '/') + 1)); printf("Relay syslog of a connected iPhone/iPod Touch.\n\n"); printf(" -d, --debug\t\tenable communication debugging\n"); - printf(" -u, --usb=BUS,DEV\ttarget specific device by usb bus/dev number\n"); + printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); printf(" -h, --help\t\tprints usage information\n"); printf("\n"); } -- cgit v1.1-32-gdbae