summaryrefslogtreecommitdiffstats
path: root/dev/syslog_relay.c
diff options
context:
space:
mode:
Diffstat (limited to 'dev/syslog_relay.c')
-rw-r--r--dev/syslog_relay.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/dev/syslog_relay.c b/dev/syslog_relay.c
index 56cf56c..3407f2f 100644
--- a/dev/syslog_relay.c
+++ b/dev/syslog_relay.c
@@ -24,9 +24,9 @@
#include <errno.h>
#include <netinet/in.h>
#include <signal.h>
-#include <usb.h>
#include <libiphone/libiphone.h>
+#include <usbmuxd.h>
static int quit_flag = 0;
@@ -47,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);
@@ -61,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")) {
@@ -78,10 +81,10 @@ 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;
}
}
@@ -103,15 +106,16 @@ 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);
- if (ret == IPHONE_E_SUCCESS) {
+ int sfd = usbmuxd_connect(iphone_get_device_handle(phone), port);
+ 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 +125,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 +137,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);
} else {
printf("ERROR: Could not start service com.apple.syslog_relay.\n");
}
@@ -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");
}