diff options
| -rw-r--r-- | src/idevice.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/idevice.c b/src/idevice.c index de50a62..74e9d77 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -455,23 +455,30 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
| 455 | debug_info("Unsupported address family 0x%02x", ((char*)device->conn_data)[1]); | 455 | debug_info("Unsupported address family 0x%02x", ((char*)device->conn_data)[1]); |
| 456 | return IDEVICE_E_UNKNOWN_ERROR; | 456 | return IDEVICE_E_UNKNOWN_ERROR; |
| 457 | } | 457 | } |
| 458 | |||
| 458 | char addrtxt[48]; | 459 | char addrtxt[48]; |
| 459 | addrtxt[0] = '\0'; | 460 | addrtxt[0] = '\0'; |
| 461 | |||
| 460 | if (!socket_addr_to_string(saddr, addrtxt, sizeof(addrtxt))) { | 462 | if (!socket_addr_to_string(saddr, addrtxt, sizeof(addrtxt))) { |
| 461 | debug_info("Failed to convert network address: %d (%s)", errno, strerror(errno)); | 463 | debug_info("Failed to convert network address: %d (%s)", errno, strerror(errno)); |
| 462 | } | 464 | } |
| 465 | |||
| 463 | debug_info("Connecting to %s port %d...", addrtxt, port); | 466 | debug_info("Connecting to %s port %d...", addrtxt, port); |
| 467 | |||
| 464 | int sfd = socket_connect_addr(saddr, port); | 468 | int sfd = socket_connect_addr(saddr, port); |
| 465 | if (sfd < 0) { | 469 | if (sfd < 0) { |
| 466 | debug_info("ERROR: Connecting to network device failed: %d (%s)", errno, strerror(errno)); | 470 | debug_info("ERROR: Connecting to network device failed: %d (%s)", errno, strerror(errno)); |
| 467 | return IDEVICE_E_NO_DEVICE; | 471 | return IDEVICE_E_NO_DEVICE; |
| 468 | } | 472 | } |
| 473 | |||
| 469 | idevice_connection_t new_connection = (idevice_connection_t)malloc(sizeof(struct idevice_connection_private)); | 474 | idevice_connection_t new_connection = (idevice_connection_t)malloc(sizeof(struct idevice_connection_private)); |
| 470 | new_connection->type = CONNECTION_NETWORK; | 475 | new_connection->type = CONNECTION_NETWORK; |
| 471 | new_connection->data = (void*)(long)sfd; | 476 | new_connection->data = (void*)(long)sfd; |
| 472 | new_connection->ssl_data = NULL; | 477 | new_connection->ssl_data = NULL; |
| 473 | new_connection->device = device; | 478 | new_connection->device = device; |
| 479 | |||
| 474 | *connection = new_connection; | 480 | *connection = new_connection; |
| 481 | |||
| 475 | return IDEVICE_E_SUCCESS; | 482 | return IDEVICE_E_SUCCESS; |
| 476 | } else { | 483 | } else { |
| 477 | debug_info("Unknown connection type %d", device->conn_type); | 484 | debug_info("Unknown connection type %d", device->conn_type); |
