diff options
Diffstat (limited to 'src/idevice.c')
| -rw-r--r-- | src/idevice.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/idevice.c b/src/idevice.c index 03e2c40..1958bdf 100644 --- a/src/idevice.c +++ b/src/idevice.c | |||
| @@ -515,27 +515,16 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t | |||
| 515 | return IDEVICE_E_SUCCESS; | 515 | return IDEVICE_E_SUCCESS; |
| 516 | } | 516 | } |
| 517 | if (device->conn_type == CONNECTION_NETWORK) { | 517 | if (device->conn_type == CONNECTION_NETWORK) { |
| 518 | struct sockaddr_storage saddr_storage; | 518 | struct sockaddr* saddr = (struct sockaddr*)(device->conn_data); |
| 519 | struct sockaddr* saddr = (struct sockaddr*)&saddr_storage; | 519 | switch (saddr->sa_family) { |
| 520 | 520 | case AF_INET: | |
| 521 | /* FIXME: Improve handling of this platform/host dependent connection data */ | ||
| 522 | if (((char*)device->conn_data)[1] == 0x02) { // AF_INET | ||
| 523 | saddr->sa_family = AF_INET; | ||
| 524 | memcpy(&saddr->sa_data[0], (char*)device->conn_data + 2, 14); | ||
| 525 | } | ||
| 526 | else if (((char*)device->conn_data)[1] == 0x1E) { // AF_INET6 (bsd) | ||
| 527 | #ifdef AF_INET6 | 521 | #ifdef AF_INET6 |
| 528 | saddr->sa_family = AF_INET6; | 522 | case AF_INET6: |
| 529 | /* copy the address and the host dependent scope id */ | ||
| 530 | memcpy(&saddr->sa_data[0], (char*)device->conn_data + 2, 26); | ||
| 531 | #else | ||
| 532 | debug_info("ERROR: Got an IPv6 address but this system doesn't support IPv6"); | ||
| 533 | return IDEVICE_E_UNKNOWN_ERROR; | ||
| 534 | #endif | 523 | #endif |
| 535 | } | 524 | break; |
| 536 | else { | 525 | default: |
| 537 | debug_info("Unsupported address family 0x%02x", ((char*)device->conn_data)[1]); | 526 | debug_info("Unsupported address family 0x%02x", saddr->sa_family); |
| 538 | return IDEVICE_E_UNKNOWN_ERROR; | 527 | return IDEVICE_E_UNKNOWN_ERROR; |
| 539 | } | 528 | } |
| 540 | 529 | ||
| 541 | char addrtxt[48]; | 530 | char addrtxt[48]; |
