diff options
-rw-r--r-- | include/libimobiledevice/libimobiledevice.h | 1 | ||||
-rw-r--r-- | src/idevice.c | 19 |
2 files changed, 18 insertions, 2 deletions
diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index e0aa518..40edd71 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h | |||
@@ -42,6 +42,7 @@ typedef enum { | |||
42 | IDEVICE_E_UNKNOWN_ERROR = -2, | 42 | IDEVICE_E_UNKNOWN_ERROR = -2, |
43 | IDEVICE_E_NO_DEVICE = -3, | 43 | IDEVICE_E_NO_DEVICE = -3, |
44 | IDEVICE_E_NOT_ENOUGH_DATA = -4, | 44 | IDEVICE_E_NOT_ENOUGH_DATA = -4, |
45 | IDEVICE_E_CONNREFUSED = -5, | ||
45 | IDEVICE_E_SSL_ERROR = -6, | 46 | IDEVICE_E_SSL_ERROR = -6, |
46 | IDEVICE_E_TIMEOUT = -7 | 47 | IDEVICE_E_TIMEOUT = -7 |
47 | } idevice_error_t; | 48 | } idevice_error_t; |
diff --git a/src/idevice.c b/src/idevice.c index 6a03c5e..04189d6 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
@@ -447,7 +447,15 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
447 | if (device->conn_type == CONNECTION_USBMUXD) { | 447 | if (device->conn_type == CONNECTION_USBMUXD) { |
448 | int sfd = usbmuxd_connect(device->mux_id, port); | 448 | int sfd = usbmuxd_connect(device->mux_id, port); |
449 | if (sfd < 0) { | 449 | if (sfd < 0) { |
450 | debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd)); | 450 | debug_info("ERROR: Connecting to usbmux device failed: %d (%s)", sfd, strerror(-sfd)); |
451 | switch (-sfd) { | ||
452 | case ECONNREFUSED: | ||
453 | return IDEVICE_E_CONNREFUSED; | ||
454 | case ENODEV: | ||
455 | return IDEVICE_E_NO_DEVICE; | ||
456 | default: | ||
457 | break; | ||
458 | } | ||
451 | return IDEVICE_E_UNKNOWN_ERROR; | 459 | return IDEVICE_E_UNKNOWN_ERROR; |
452 | } | 460 | } |
453 | idevice_connection_t new_connection = (idevice_connection_t)malloc(sizeof(struct idevice_connection_private)); | 461 | idevice_connection_t new_connection = (idevice_connection_t)malloc(sizeof(struct idevice_connection_private)); |
@@ -494,7 +502,14 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
494 | 502 | ||
495 | int sfd = socket_connect_addr(saddr, port); | 503 | int sfd = socket_connect_addr(saddr, port); |
496 | if (sfd < 0) { | 504 | if (sfd < 0) { |
497 | debug_info("ERROR: Connecting to network device failed: %d (%s)", errno, strerror(errno)); | 505 | int result = errno; |
506 | debug_info("ERROR: Connecting to network device failed: %d (%s)", result, strerror(result)); | ||
507 | switch (result) { | ||
508 | case ECONNREFUSED: | ||
509 | return IDEVICE_E_CONNREFUSED; | ||
510 | default: | ||
511 | break; | ||
512 | } | ||
498 | return IDEVICE_E_NO_DEVICE; | 513 | return IDEVICE_E_NO_DEVICE; |
499 | } | 514 | } |
500 | 515 | ||