summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/usbmuxd-proto.h2
-rw-r--r--src/libusbmuxd.c20
2 files changed, 19 insertions, 3 deletions
diff --git a/include/usbmuxd-proto.h b/include/usbmuxd-proto.h
index 9ad5f71..a2a731e 100644
--- a/include/usbmuxd-proto.h
+++ b/include/usbmuxd-proto.h
@@ -52,7 +52,7 @@ enum usbmuxd_msgtype {
MESSAGE_LISTEN = 3,
MESSAGE_DEVICE_ADD = 4,
MESSAGE_DEVICE_REMOVE = 5,
- //???
+ MESSAGE_DEVICE_PAIRED = 6,
//???
MESSAGE_PLIST = 8,
};
diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c
index af8636b..a8586f2 100644
--- a/src/libusbmuxd.c
+++ b/src/libusbmuxd.c
@@ -41,8 +41,8 @@
#endif
#ifdef WIN32
-#include <windows.h>
#include <winsock2.h>
+#include <windows.h>
#define sleep(x) Sleep(x*1000)
#ifndef EPROTO
#define EPROTO 134
@@ -268,8 +268,24 @@ static int receive_packet(int sfd, struct usbmuxd_header *header, void **payload
hdr.length = sizeof(hdr) + sizeof(dwval);
hdr.message = MESSAGE_DEVICE_REMOVE;
}
+ } else if (strcmp(message, "Paired") == 0) {
+ /* device pair message */
+ uint32_t dwval = 0;
+ plist_t n = plist_dict_get_item(plist, "DeviceID");
+ if (n) {
+ plist_get_uint_val(n, &val);
+ *payload = malloc(sizeof(uint32_t));
+ dwval = val;
+ memcpy(*payload, &dwval, sizeof(dwval));
+ hdr.length = sizeof(hdr) + sizeof(dwval);
+ hdr.message = MESSAGE_DEVICE_PAIRED;
+ }
} else {
- DEBUG(1, "%s: Unexpected message '%s' in plist!\n", __func__, message);
+ char *xml = NULL;
+ uint32_t len = 0;
+ plist_to_xml(plist, &xml, &len);
+ DEBUG(1, "%s: Unexpected message '%s' in plist:\n%s\n", __func__, message, xml);
+ free(xml);
free(message);
plist_free(plist);
return -EBADMSG;