diff options
| -rw-r--r-- | libusbmuxd.h | 45 | ||||
| -rw-r--r-- | usbmuxd.h | 97 |
2 files changed, 45 insertions, 97 deletions
diff --git a/libusbmuxd.h b/libusbmuxd.h deleted file mode 100644 index da99f1f..0000000 --- a/libusbmuxd.h +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 1 | #ifndef __LIBUSBMUXD_H | ||
| 2 | #define __LIBUSBMUXD_H | ||
| 3 | |||
| 4 | /** | ||
| 5 | * Array entry returned by 'usbmuxd_scan()' scanning. | ||
| 6 | * | ||
| 7 | * If more than one device is available, 'product_id' and | ||
| 8 | * 'serial_number' and be analysed to help make a selection. | ||
| 9 | * The relevant 'handle' should be passed to 'usbmuxd_connect()', to | ||
| 10 | * start a proxy connection. The value 'handle' should be considered | ||
| 11 | * opaque and no presumption made about the meaning of its value. | ||
| 12 | */ | ||
| 13 | typedef struct { | ||
| 14 | int handle; | ||
| 15 | int product_id; | ||
| 16 | char serial_number[41]; | ||
| 17 | } usbmuxd_scan_result; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Contacts usbmuxd and performs a scan for connected devices. | ||
| 21 | * | ||
| 22 | * @param available_devices pointer to array of usbmuxd_scan_result. | ||
| 23 | * Array of available devices. The required 'handle' | ||
| 24 | * should be passed to 'usbmuxd_connect()'. The returned array | ||
| 25 | * is zero-terminated for convenience; the final (unused) | ||
| 26 | * entry containing handle == 0. The returned array pointer | ||
| 27 | * should be freed by passing to 'free()' after use. | ||
| 28 | * | ||
| 29 | * @return number of available devices, zero on no devices, or negative on error | ||
| 30 | */ | ||
| 31 | int usbmuxd_scan(usbmuxd_scan_result **available_devices); | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Request proxy connect to | ||
| 35 | * | ||
| 36 | * @param handle returned by 'usbmuxd_scan()' | ||
| 37 | * | ||
| 38 | * @param tcp_port TCP port number on device, in range 0-65535. | ||
| 39 | * common values are 62078 for lockdown, and 22 for SSH. | ||
| 40 | * | ||
| 41 | * @return file descriptor socket of the connection, or -1 on error | ||
| 42 | */ | ||
| 43 | int usbmuxd_connect(const int handle, const unsigned short tcp_port); | ||
| 44 | |||
| 45 | #endif /* __LIBUSBMUXD_H */ | ||
| @@ -1,52 +1,45 @@ | |||
| 1 | /* Protocol defintion for usbmuxd proxy protocol */ | 1 | #ifndef __LIBUSBMUXD_H |
| 2 | 2 | #define __LIBUSBMUXD_H | |
| 3 | #ifndef __USBMUXD_H | 3 | |
| 4 | #define __USBMUXD_H | 4 | /** |
| 5 | 5 | * Array entry returned by 'usbmuxd_scan()' scanning. | |
| 6 | #include <stdint.h> | 6 | * |
| 7 | 7 | * If more than one device is available, 'product_id' and | |
| 8 | #define USBMUXD_SOCKET_FILE "/var/run/usbmuxd" | 8 | * 'serial_number' and be analysed to help make a selection. |
| 9 | 9 | * The relevant 'handle' should be passed to 'usbmuxd_connect()', to | |
| 10 | struct usbmuxd_header { | 10 | * start a proxy connection. The value 'handle' should be considered |
| 11 | uint32_t length; // length of message, including header | 11 | * opaque and no presumption made about the meaning of its value. |
| 12 | uint32_t reserved; // always zero | 12 | */ |
| 13 | uint32_t type; // message type | 13 | typedef struct { |
| 14 | uint32_t tag; // responses to this query will echo back this tag | 14 | int handle; |
| 15 | } __attribute__((__packed__)); | 15 | int product_id; |
| 16 | 16 | char serial_number[41]; | |
| 17 | struct usbmuxd_result { | 17 | } usbmuxd_scan_result; |
| 18 | struct usbmuxd_header header; | 18 | |
| 19 | uint32_t result; | 19 | /** |
| 20 | } __attribute__((__packed__)); | 20 | * Contacts usbmuxd and performs a scan for connected devices. |
| 21 | 21 | * | |
| 22 | struct usbmuxd_connect_request { | 22 | * @param available_devices pointer to array of usbmuxd_scan_result. |
| 23 | struct usbmuxd_header header; | 23 | * Array of available devices. The required 'handle' |
| 24 | uint32_t device_id; | 24 | * should be passed to 'usbmuxd_connect()'. The returned array |
| 25 | uint16_t tcp_dport; // TCP port number | 25 | * is zero-terminated for convenience; the final (unused) |
| 26 | uint16_t reserved; // set to zero | 26 | * entry containing handle == 0. The returned array pointer |
| 27 | } __attribute__((__packed__)); | 27 | * should be freed by passing to 'free()' after use. |
| 28 | 28 | * | |
| 29 | struct usbmuxd_device { | 29 | * @return number of available devices, zero on no devices, or negative on error |
| 30 | uint32_t device_id; | 30 | */ |
| 31 | uint16_t product_id; | 31 | int usbmuxd_scan(usbmuxd_scan_result **available_devices); |
| 32 | char serial_number[40]; | 32 | |
| 33 | } __attribute__((__packed__)); | 33 | /** |
| 34 | 34 | * Request proxy connect to | |
| 35 | struct usbmuxd_device_info_record { | 35 | * |
| 36 | struct usbmuxd_header header; | 36 | * @param handle returned by 'usbmuxd_scan()' |
| 37 | struct usbmuxd_device device; | 37 | * |
| 38 | char padding[222]; | 38 | * @param tcp_port TCP port number on device, in range 0-65535. |
| 39 | } __attribute__((__packed__)); | 39 | * common values are 62078 for lockdown, and 22 for SSH. |
| 40 | 40 | * | |
| 41 | struct usbmuxd_scan_request { | 41 | * @return file descriptor socket of the connection, or -1 on error |
| 42 | struct usbmuxd_header header; | 42 | */ |
| 43 | } __attribute__((__packed__)); | 43 | int usbmuxd_connect(const int handle, const unsigned short tcp_port); |
| 44 | 44 | ||
| 45 | enum { | 45 | #endif /* __LIBUSBMUXD_H */ |
| 46 | USBMUXD_RESULT = 1, | ||
| 47 | USBMUXD_CONNECT = 2, | ||
| 48 | USBMUXD_SCAN = 3, | ||
| 49 | USBMUXD_DEVICE_INFO = 4, | ||
| 50 | }; | ||
| 51 | |||
| 52 | #endif | ||
