diff options
| -rw-r--r-- | configure.ac | 24 | ||||
| -rw-r--r-- | src/client.c | 32 |
2 files changed, 4 insertions, 52 deletions
diff --git a/configure.ac b/configure.ac index 3067304..9e113d7 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -17,31 +17,10 @@ AC_PROG_LIBTOOL | |||
| 17 | 17 | ||
| 18 | # Checks for libraries. | 18 | # Checks for libraries. |
| 19 | PKG_CHECK_MODULES(libusb, libusb-1.0 >= 1.0.3) | 19 | PKG_CHECK_MODULES(libusb, libusb-1.0 >= 1.0.3) |
| 20 | PKG_CHECK_MODULES(libplist, libplist >= 1.9, have_plist=yes, have_plist=no) | 20 | PKG_CHECK_MODULES(libplist, libplist >= 1.11) |
| 21 | PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 1.1.6, have_limd=yes, have_limd=no) | 21 | PKG_CHECK_MODULES(libimobiledevice, libimobiledevice-1.0 >= 1.1.6, have_limd=yes, have_limd=no) |
| 22 | AC_CHECK_LIB(pthread, [pthread_create, pthread_mutex_lock], [AC_SUBST(libpthread_LIBS,[-lpthread])], [AC_MSG_ERROR([libpthread is required to build usbmuxd])]) | 22 | AC_CHECK_LIB(pthread, [pthread_create, pthread_mutex_lock], [AC_SUBST(libpthread_LIBS,[-lpthread])], [AC_MSG_ERROR([libpthread is required to build usbmuxd])]) |
| 23 | 23 | ||
| 24 | AC_ARG_WITH([protov1], | ||
| 25 | [AS_HELP_STRING([--without-protov1], | ||
| 26 | [do not build with protocol v1 support (default is yes)])], | ||
| 27 | [with_protov1=no], | ||
| 28 | [with_protov1=yes]) | ||
| 29 | |||
| 30 | if test "x$have_plist" = "xyes"; then | ||
| 31 | if test "x$with_protov1" != "xyes"; then | ||
| 32 | have_plist=no | ||
| 33 | echo "*** Note: Protocol V1 support has been disabled ***" | ||
| 34 | else | ||
| 35 | AC_DEFINE(HAVE_PLIST, 1, [Define if you have libplist support]) | ||
| 36 | AC_SUBST(libplist_CFLAGS) | ||
| 37 | AC_SUBST(libplist_LIBS) | ||
| 38 | fi | ||
| 39 | else | ||
| 40 | if test "x$with_protov1" == "xyes"; then | ||
| 41 | AC_MSG_ERROR([protocol V1 support requested but libplist could not be found]) | ||
| 42 | fi | ||
| 43 | fi | ||
| 44 | |||
| 45 | AC_ARG_WITH([preflight], | 24 | AC_ARG_WITH([preflight], |
| 46 | [AS_HELP_STRING([--without-preflight], | 25 | [AS_HELP_STRING([--without-preflight], |
| 47 | [do not build with preflight worker support (default is yes)])], | 26 | [do not build with preflight worker support (default is yes)])], |
| @@ -112,7 +91,6 @@ Configuration for $PACKAGE $VERSION: | |||
| 112 | ------------------------------------------- | 91 | ------------------------------------------- |
| 113 | 92 | ||
| 114 | Install prefix: ...........: $prefix | 93 | Install prefix: ...........: $prefix |
| 115 | Protocol v1 support: ......: $have_plist | ||
| 116 | Preflight worker support ..: $have_limd | 94 | Preflight worker support ..: $have_limd |
| 117 | 95 | ||
| 118 | Now type 'make' to build $PACKAGE $VERSION, | 96 | Now type 'make' to build $PACKAGE $VERSION, |
diff --git a/src/client.c b/src/client.c index ac5d08e..b81c11c 100644 --- a/src/client.c +++ b/src/client.c | |||
| @@ -33,9 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
| 33 | #include <arpa/inet.h> | 33 | #include <arpa/inet.h> |
| 34 | #include <pthread.h> | 34 | #include <pthread.h> |
| 35 | 35 | ||
| 36 | #ifdef HAVE_PLIST | ||
| 37 | #include <plist/plist.h> | 36 | #include <plist/plist.h> |
| 38 | #endif | ||
| 39 | 37 | ||
| 40 | #include "log.h" | 38 | #include "log.h" |
| 41 | #include "usb.h" | 39 | #include "usb.h" |
| @@ -186,7 +184,6 @@ static int send_pkt(struct mux_client *client, uint32_t tag, enum usbmuxd_msgtyp | |||
| 186 | return hdr.length; | 184 | return hdr.length; |
| 187 | } | 185 | } |
| 188 | 186 | ||
| 189 | #ifdef HAVE_PLIST | ||
| 190 | static int send_plist_pkt(struct mux_client *client, uint32_t tag, plist_t plist) | 187 | static int send_plist_pkt(struct mux_client *client, uint32_t tag, plist_t plist) |
| 191 | { | 188 | { |
| 192 | int res = -1; | 189 | int res = -1; |
| @@ -201,12 +198,10 @@ static int send_plist_pkt(struct mux_client *client, uint32_t tag, plist_t plist | |||
| 201 | } | 198 | } |
| 202 | return res; | 199 | return res; |
| 203 | } | 200 | } |
| 204 | #endif | ||
| 205 | 201 | ||
| 206 | static int send_result(struct mux_client *client, uint32_t tag, uint32_t result) | 202 | static int send_result(struct mux_client *client, uint32_t tag, uint32_t result) |
| 207 | { | 203 | { |
| 208 | int res = -1; | 204 | int res = -1; |
| 209 | #ifdef HAVE_PLIST | ||
| 210 | if (client->proto_version == 1) { | 205 | if (client->proto_version == 1) { |
| 211 | /* XML plist packet */ | 206 | /* XML plist packet */ |
| 212 | plist_t dict = plist_new_dict(); | 207 | plist_t dict = plist_new_dict(); |
| @@ -214,9 +209,7 @@ static int send_result(struct mux_client *client, uint32_t tag, uint32_t result) | |||
| 214 | plist_dict_insert_item(dict, "Number", plist_new_uint(result)); | 209 | plist_dict_insert_item(dict, "Number", plist_new_uint(result)); |
| 215 | res = send_plist_pkt(client, tag, dict); | 210 | res = send_plist_pkt(client, tag, dict); |
| 216 | free(dict); | 211 | free(dict); |
| 217 | } else | 212 | } else { |
| 218 | #endif | ||
| 219 | { | ||
| 220 | /* binary packet */ | 213 | /* binary packet */ |
| 221 | res = send_pkt(client, tag, MESSAGE_RESULT, &result, sizeof(uint32_t)); | 214 | res = send_pkt(client, tag, MESSAGE_RESULT, &result, sizeof(uint32_t)); |
| 222 | } | 215 | } |
| @@ -246,7 +239,6 @@ int client_notify_connect(struct mux_client *client, enum usbmuxd_result result) | |||
| 246 | return 0; | 239 | return 0; |
| 247 | } | 240 | } |
| 248 | 241 | ||
| 249 | #ifdef HAVE_PLIST | ||
| 250 | static plist_t create_device_attached_plist(struct device_info *dev) | 242 | static plist_t create_device_attached_plist(struct device_info *dev) |
| 251 | { | 243 | { |
| 252 | plist_t dict = plist_new_dict(); | 244 | plist_t dict = plist_new_dict(); |
| @@ -292,20 +284,16 @@ static int send_device_list(struct mux_client *client, uint32_t tag) | |||
| 292 | plist_free(dict); | 284 | plist_free(dict); |
| 293 | return res; | 285 | return res; |
| 294 | } | 286 | } |
| 295 | #endif | ||
| 296 | 287 | ||
| 297 | static int notify_device_add(struct mux_client *client, struct device_info *dev) | 288 | static int notify_device_add(struct mux_client *client, struct device_info *dev) |
| 298 | { | 289 | { |
| 299 | int res = -1; | 290 | int res = -1; |
| 300 | #ifdef HAVE_PLIST | ||
| 301 | if (client->proto_version == 1) { | 291 | if (client->proto_version == 1) { |
| 302 | /* XML plist packet */ | 292 | /* XML plist packet */ |
| 303 | plist_t dict = create_device_attached_plist(dev); | 293 | plist_t dict = create_device_attached_plist(dev); |
| 304 | res = send_plist_pkt(client, 0, dict); | 294 | res = send_plist_pkt(client, 0, dict); |
| 305 | plist_free(dict); | 295 | plist_free(dict); |
| 306 | } else | 296 | } else { |
| 307 | #endif | ||
| 308 | { | ||
| 309 | /* binary packet */ | 297 | /* binary packet */ |
| 310 | struct usbmuxd_device_record dmsg; | 298 | struct usbmuxd_device_record dmsg; |
| 311 | memset(&dmsg, 0, sizeof(dmsg)); | 299 | memset(&dmsg, 0, sizeof(dmsg)); |
| @@ -322,7 +310,6 @@ static int notify_device_add(struct mux_client *client, struct device_info *dev) | |||
| 322 | static int notify_device_remove(struct mux_client *client, uint32_t device_id) | 310 | static int notify_device_remove(struct mux_client *client, uint32_t device_id) |
| 323 | { | 311 | { |
| 324 | int res = -1; | 312 | int res = -1; |
| 325 | #ifdef HAVE_PLIST | ||
| 326 | if (client->proto_version == 1) { | 313 | if (client->proto_version == 1) { |
| 327 | /* XML plist packet */ | 314 | /* XML plist packet */ |
| 328 | plist_t dict = plist_new_dict(); | 315 | plist_t dict = plist_new_dict(); |
| @@ -330,9 +317,7 @@ static int notify_device_remove(struct mux_client *client, uint32_t device_id) | |||
| 330 | plist_dict_insert_item(dict, "DeviceID", plist_new_uint(device_id)); | 317 | plist_dict_insert_item(dict, "DeviceID", plist_new_uint(device_id)); |
| 331 | res = send_plist_pkt(client, 0, dict); | 318 | res = send_plist_pkt(client, 0, dict); |
| 332 | plist_free(dict); | 319 | plist_free(dict); |
| 333 | } else | 320 | } else { |
| 334 | #endif | ||
| 335 | { | ||
| 336 | /* binary packet */ | 321 | /* binary packet */ |
| 337 | res = send_pkt(client, 0, MESSAGE_DEVICE_REMOVE, &device_id, sizeof(uint32_t)); | 322 | res = send_pkt(client, 0, MESSAGE_DEVICE_REMOVE, &device_id, sizeof(uint32_t)); |
| 338 | } | 323 | } |
| @@ -383,25 +368,17 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) | |||
| 383 | return -1; | 368 | return -1; |
| 384 | } | 369 | } |
| 385 | 370 | ||
| 386 | #ifdef HAVE_PLIST | ||
| 387 | if((hdr->version != 0) && (hdr->version != 1)) { | 371 | if((hdr->version != 0) && (hdr->version != 1)) { |
| 388 | usbmuxd_log(LL_INFO, "Client %d version mismatch: expected 0 or 1, got %d", client->fd, hdr->version); | 372 | usbmuxd_log(LL_INFO, "Client %d version mismatch: expected 0 or 1, got %d", client->fd, hdr->version); |
| 389 | #else | ||
| 390 | if(hdr->version != USBMUXD_PROTOCOL_VERSION) { | ||
| 391 | usbmuxd_log(LL_INFO, "Client %d version mismatch: expected %d, got %d", client->fd, USBMUXD_PROTOCOL_VERSION, hdr->version); | ||
| 392 | #endif | ||
| 393 | send_result(client, hdr->tag, RESULT_BADVERSION); | 373 | send_result(client, hdr->tag, RESULT_BADVERSION); |
| 394 | return 0; | 374 | return 0; |
| 395 | } | 375 | } |
| 396 | 376 | ||
| 397 | struct usbmuxd_connect_request *ch; | 377 | struct usbmuxd_connect_request *ch; |
| 398 | #ifdef HAVE_PLIST | ||
| 399 | char *payload; | 378 | char *payload; |
| 400 | uint32_t payload_size; | 379 | uint32_t payload_size; |
| 401 | #endif | ||
| 402 | 380 | ||
| 403 | switch(hdr->message) { | 381 | switch(hdr->message) { |
| 404 | #ifdef HAVE_PLIST | ||
| 405 | case MESSAGE_PLIST: | 382 | case MESSAGE_PLIST: |
| 406 | client->proto_version = 1; | 383 | client->proto_version = 1; |
| 407 | payload = (char*)(hdr) + sizeof(struct usbmuxd_header); | 384 | payload = (char*)(hdr) + sizeof(struct usbmuxd_header); |
| @@ -469,12 +446,10 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) | |||
| 469 | client->state = CLIENT_CONNECTING1; | 446 | client->state = CLIENT_CONNECTING1; |
| 470 | } | 447 | } |
| 471 | return 0; | 448 | return 0; |
| 472 | #ifdef HAVE_PLIST | ||
| 473 | } else if (!strcmp(message, "ListDevices")) { | 449 | } else if (!strcmp(message, "ListDevices")) { |
| 474 | if (send_device_list(client, hdr->tag) < 0) | 450 | if (send_device_list(client, hdr->tag) < 0) |
| 475 | return -1; | 451 | return -1; |
| 476 | return 0; | 452 | return 0; |
| 477 | #endif | ||
| 478 | } else { | 453 | } else { |
| 479 | usbmuxd_log(LL_ERROR, "Unexpected command '%s' received!", message); | 454 | usbmuxd_log(LL_ERROR, "Unexpected command '%s' received!", message); |
| 480 | free(message); | 455 | free(message); |
| @@ -486,7 +461,6 @@ static int client_command(struct mux_client *client, struct usbmuxd_header *hdr) | |||
| 486 | } | 461 | } |
| 487 | // should not be reached?! | 462 | // should not be reached?! |
| 488 | return -1; | 463 | return -1; |
| 489 | #endif | ||
| 490 | case MESSAGE_LISTEN: | 464 | case MESSAGE_LISTEN: |
| 491 | if(send_result(client, hdr->tag, 0) < 0) | 465 | if(send_result(client, hdr->tag, 0) < 0) |
| 492 | return -1; | 466 | return -1; |
