diff options
Diffstat (limited to 'libusbmuxd/usbmuxd.h')
| -rw-r--r-- | libusbmuxd/usbmuxd.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libusbmuxd/usbmuxd.h b/libusbmuxd/usbmuxd.h new file mode 100644 index 0000000..ba45ec3 --- /dev/null +++ b/libusbmuxd/usbmuxd.h | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | #ifndef __USBMUXD_H | ||
| 2 | #define __USBMUXD_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 | /** | ||
| 46 | * Disconnect. For now, this just closes the socket file descriptor. | ||
| 47 | * | ||
| 48 | * @param sfd socker file descriptor returned by usbmuxd_connect() | ||
| 49 | * | ||
| 50 | * @return 0 on success, -1 on error. | ||
| 51 | */ | ||
| 52 | int usbmuxd_disconnect(int sfd); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Send data to the specified socket. | ||
| 56 | * | ||
| 57 | * @param sfd socket file descriptor returned by usbmuxd_connect() | ||
| 58 | * @param data buffer to send | ||
| 59 | * @param len size of buffer to send | ||
| 60 | * @param sent_bytes how many bytes sent | ||
| 61 | * | ||
| 62 | * @return 0 on success, a negative errno value otherwise. | ||
| 63 | */ | ||
| 64 | int usbmuxd_send(int sfd, const char *data, uint32_t len, uint32_t *sent_bytes); | ||
| 65 | |||
| 66 | /** | ||
| 67 | * Receive data from the specified socket. | ||
| 68 | * | ||
| 69 | * @param sfd socket file descriptor returned by usbmuxd_connect() | ||
| 70 | * @param data buffer to put the data to | ||
| 71 | * @param len number of bytes to receive | ||
| 72 | * @param recv_bytes number of bytes received | ||
| 73 | * @param timeout how many milliseconds to wait for data | ||
| 74 | * | ||
| 75 | * @return 0 on success, a negative errno value otherwise. | ||
| 76 | */ | ||
| 77 | int usbmuxd_recv_timeout(int sfd, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); | ||
| 78 | |||
| 79 | /** | ||
| 80 | * Receive data from the specified socket with a default timeout. | ||
| 81 | * | ||
| 82 | * @param sfd socket file descriptor returned by usbmuxd_connect() | ||
| 83 | * @param data buffer to put the data to | ||
| 84 | * @param len number of bytes to receive | ||
| 85 | * @param recv_bytes number of bytes received | ||
| 86 | * | ||
| 87 | * @return 0 on success, a negative errno value otherwise. | ||
| 88 | */ | ||
| 89 | int usbmuxd_recv(int sfd, char *data, uint32_t len, uint32_t *recv_bytes); | ||
| 90 | |||
| 91 | #endif /* __USBMUXD_H */ | ||
