summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-09-29 22:56:14 +0200
committerGravatar Nikias Bassen2018-09-29 22:56:14 +0200
commit05fefa6aeff45fc84665e8427444295d8414df98 (patch)
tree76ac70827e85fced512dfe04c568a97f82eaff8c /src
parentfb71aeef10488ed7b0e60a1c8a553193301428c0 (diff)
downloadlibimobiledevice-05fefa6aeff45fc84665e8427444295d8414df98.tar.gz
libimobiledevice-05fefa6aeff45fc84665e8427444295d8414df98.tar.bz2
idevice: Add usbmux device id (handle/mux id) to internal data structure
Diffstat (limited to 'src')
-rw-r--r--src/idevice.c19
-rw-r--r--src/idevice.h1
2 files changed, 7 insertions, 13 deletions
diff --git a/src/idevice.c b/src/idevice.c
index ead9b86..cb9bb5c 100644
--- a/src/idevice.c
+++ b/src/idevice.c
@@ -254,8 +254,9 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t * device, const char
254 if (res > 0) { 254 if (res > 0) {
255 idevice_t dev = (idevice_t) malloc(sizeof(struct idevice_private)); 255 idevice_t dev = (idevice_t) malloc(sizeof(struct idevice_private));
256 dev->udid = strdup(muxdev.udid); 256 dev->udid = strdup(muxdev.udid);
257 dev->mux_id = muxdev.handle;
257 dev->conn_type = CONNECTION_USBMUXD; 258 dev->conn_type = CONNECTION_USBMUXD;
258 dev->conn_data = (void*)(long)muxdev.handle; 259 dev->conn_data = NULL;
259 dev->version = 0; 260 dev->version = 0;
260 *device = dev; 261 *device = dev;
261 return IDEVICE_E_SUCCESS; 262 return IDEVICE_E_SUCCESS;
@@ -275,9 +276,6 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device)
275 276
276 free(device->udid); 277 free(device->udid);
277 278
278 if (device->conn_type == CONNECTION_USBMUXD) {
279 device->conn_data = 0;
280 }
281 if (device->conn_data) { 279 if (device->conn_data) {
282 free(device->conn_data); 280 free(device->conn_data);
283 } 281 }
@@ -292,7 +290,7 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t
292 } 290 }
293 291
294 if (device->conn_type == CONNECTION_USBMUXD) { 292 if (device->conn_type == CONNECTION_USBMUXD) {
295 int sfd = usbmuxd_connect((uint32_t)(long)device->conn_data, port); 293 int sfd = usbmuxd_connect(device->mux_id, port);
296 if (sfd < 0) { 294 if (sfd < 0) {
297 debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd)); 295 debug_info("ERROR: Connecting to usbmuxd failed: %d (%s)", sfd, strerror(-sfd));
298 return IDEVICE_E_UNKNOWN_ERROR; 296 return IDEVICE_E_UNKNOWN_ERROR;
@@ -502,16 +500,11 @@ LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connectio
502 500
503LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle) 501LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle)
504{ 502{
505 if (!device) 503 if (!device || !handle)
506 return IDEVICE_E_INVALID_ARG; 504 return IDEVICE_E_INVALID_ARG;
507 505
508 if (device->conn_type == CONNECTION_USBMUXD) { 506 *handle = device->mux_id;
509 *handle = (uint32_t)(long)device->conn_data; 507 return IDEVICE_E_SUCCESS;
510 return IDEVICE_E_SUCCESS;
511 } else {
512 debug_info("Unknown connection type %d", device->conn_type);
513 }
514 return IDEVICE_E_UNKNOWN_ERROR;
515} 508}
516 509
517LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid) 510LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid)
diff --git a/src/idevice.h b/src/idevice.h
index e46a7e5..94e828b 100644
--- a/src/idevice.h
+++ b/src/idevice.h
@@ -74,6 +74,7 @@ struct idevice_connection_private {
74 74
75struct idevice_private { 75struct idevice_private {
76 char *udid; 76 char *udid;
77 uint32_t mux_id;
77 enum connection_type conn_type; 78 enum connection_type conn_type;
78 void *conn_data; 79 void *conn_data;
79 int version; 80 int version;