diff options
Diffstat (limited to 'include')
30 files changed, 1461 insertions, 431 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index eaf052a..2abaf49 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,26 +1,31 @@ -EXTRA_DIST = asprintf.h endianness.h +EXTRA_DIST = \ + asprintf.h \ + endianness.h -nobase_include_HEADERS = libimobiledevice/libimobiledevice.h \ - libimobiledevice/lockdown.h \ - libimobiledevice/afc.h \ - libimobiledevice/file_relay.h \ - libimobiledevice/notification_proxy.h \ - libimobiledevice/installation_proxy.h \ - libimobiledevice/sbservices.h \ - libimobiledevice/mobile_image_mounter.h \ - libimobiledevice/screenshotr.h \ - libimobiledevice/mobilesync.h \ - libimobiledevice/mobilebackup.h \ - libimobiledevice/house_arrest.h \ - libimobiledevice/mobilebackup2.h \ - libimobiledevice/misagent.h \ - libimobiledevice/restore.h\ - libimobiledevice/webinspector.h\ - libimobiledevice/heartbeat.h\ - libimobiledevice/diagnostics_relay.h\ - libimobiledevice/debugserver.h\ - libimobiledevice/syslog_relay.h\ - libimobiledevice/mobileactivation.h\ - libimobiledevice/preboard.h\ - libimobiledevice/property_list_service.h\ - libimobiledevice/service.h +nobase_include_HEADERS = \ + libimobiledevice/libimobiledevice.h \ + libimobiledevice/lockdown.h \ + libimobiledevice/afc.h \ + libimobiledevice/file_relay.h \ + libimobiledevice/notification_proxy.h \ + libimobiledevice/installation_proxy.h \ + libimobiledevice/sbservices.h \ + libimobiledevice/mobile_image_mounter.h \ + libimobiledevice/screenshotr.h \ + libimobiledevice/mobilesync.h \ + libimobiledevice/mobilebackup.h \ + libimobiledevice/house_arrest.h \ + libimobiledevice/mobilebackup2.h \ + libimobiledevice/misagent.h \ + libimobiledevice/restore.h \ + libimobiledevice/webinspector.h \ + libimobiledevice/heartbeat.h \ + libimobiledevice/diagnostics_relay.h \ + libimobiledevice/debugserver.h \ + libimobiledevice/syslog_relay.h \ + libimobiledevice/mobileactivation.h \ + libimobiledevice/preboard.h \ + libimobiledevice/companion_proxy.h \ + libimobiledevice/reverse_proxy.h \ + libimobiledevice/property_list_service.h \ + libimobiledevice/service.h diff --git a/include/asprintf.h b/include/asprintf.h index ce26aed..3ed35be 100644 --- a/include/asprintf.h +++ b/include/asprintf.h @@ -5,6 +5,8 @@ #include <config.h> #endif +#include <stdio.h> + #ifndef HAVE_VASPRINTF static inline int vasprintf(char **PTR, const char *TEMPLATE, va_list AP) { diff --git a/include/endianness.h b/include/endianness.h index 2d6ad0e..88b63db 100644 --- a/include/endianness.h +++ b/include/endianness.h @@ -31,6 +31,18 @@ #define htobe16 be16toh #endif +#ifndef le16toh +#if __BYTE_ORDER == __BIG_ENDIAN +#define le16toh(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) +#else +#define le16toh(x) (x) +#endif +#endif + +#ifndef htole16 +#define htole16 le16toh +#endif + #ifndef __bswap_32 #define __bswap_32(x) ((((x) & 0xFF000000) >> 24) \ | (((x) & 0x00FF0000) >> 8) \ @@ -97,4 +109,15 @@ #define htole64 le64toh #endif +#if (defined(__BIG_ENDIAN__) \ + && !defined(__FLOAT_WORD_ORDER__)) \ + || (defined(__FLOAT_WORD_ORDER__) \ + && __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__) +#define float_bswap64(x) __bswap_64(x) +#define float_bswap32(x) __bswap_32(x) +#else +#define float_bswap64(x) (x) +#define float_bswap32(x) (x) +#endif + #endif /* ENDIANNESS_H */ diff --git a/include/libimobiledevice/afc.h b/include/libimobiledevice/afc.h index 13cffd4..4ad3dbd 100644 --- a/include/libimobiledevice/afc.h +++ b/include/libimobiledevice/afc.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the AFC service */ #define AFC_SERVICE_NAME "com.apple.afc" /** Error Codes */ @@ -89,7 +90,7 @@ typedef enum { AFC_LOCK_UN = 8 | 4 /**< unlock */ } afc_lock_op_t; -typedef struct afc_client_private afc_client_private; +typedef struct afc_client_private afc_client_private; /**< \private */ typedef afc_client_private *afc_client_t; /**< The client handle. */ /* Interface */ @@ -106,7 +107,7 @@ typedef afc_client_private *afc_client_t; /**< The client handle. */ * invalid, AFC_E_MUX_ERROR if the connection cannot be established, * or AFC_E_NO_MEM if there is a memory allocation problem. */ -afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client); +LIBIMOBILEDEVICE_API afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t service, afc_client_t *client); /** * Starts a new AFC service on the specified device and connects to it. @@ -119,7 +120,7 @@ afc_error_t afc_client_new(idevice_t device, lockdownd_service_descriptor_t serv * * @return AFC_E_SUCCESS on success, or an AFC_E_* error code otherwise. */ -afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label); +LIBIMOBILEDEVICE_API afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, const char* label); /** * Frees up an AFC client. If the connection was created by the client itself, @@ -127,7 +128,7 @@ afc_error_t afc_client_start_service(idevice_t device, afc_client_t* client, con * * @param client The client to free. */ -afc_error_t afc_client_free(afc_client_t client); +LIBIMOBILEDEVICE_API afc_error_t afc_client_free(afc_client_t client); /** * Get device information for a connected client. The device information @@ -141,7 +142,7 @@ afc_error_t afc_client_free(afc_client_t client); * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_get_device_info(afc_client_t client, char ***device_information); +LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info(afc_client_t client, char ***device_information); /** * Gets a directory listing of the directory requested. @@ -154,7 +155,7 @@ afc_error_t afc_get_device_info(afc_client_t client, char ***device_information) * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information); +LIBIMOBILEDEVICE_API afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***directory_information); /** * Gets information about a specific file. @@ -167,7 +168,7 @@ afc_error_t afc_read_directory(afc_client_t client, const char *path, char ***di * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ***file_information); +LIBIMOBILEDEVICE_API afc_error_t afc_get_file_info(afc_client_t client, const char *path, char ***file_information); /** * Opens a file on the device. @@ -179,7 +180,7 @@ afc_error_t afc_get_file_info(afc_client_t client, const char *filename, char ** * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle); +LIBIMOBILEDEVICE_API afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mode_t file_mode, uint64_t *handle); /** * Closes a file on the device. @@ -187,7 +188,7 @@ afc_error_t afc_file_open(afc_client_t client, const char *filename, afc_file_mo * @param client The client to close the file with. * @param handle File handle of a previously opened file. */ -afc_error_t afc_file_close(afc_client_t client, uint64_t handle); +LIBIMOBILEDEVICE_API afc_error_t afc_file_close(afc_client_t client, uint64_t handle); /** * Locks or unlocks a file on the device. @@ -201,7 +202,7 @@ afc_error_t afc_file_close(afc_client_t client, uint64_t handle); * AFC_LOCK_SH (shared lock), AFC_LOCK_EX (exclusive lock), or * AFC_LOCK_UN (unlock). */ -afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation); +LIBIMOBILEDEVICE_API afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t operation); /** * Attempts to the read the given number of bytes from the given file. @@ -214,7 +215,7 @@ afc_error_t afc_file_lock(afc_client_t client, uint64_t handle, afc_lock_op_t op * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read); +LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint32_t length, uint32_t *bytes_read); /** * Writes a given number of bytes to a file. @@ -227,7 +228,7 @@ afc_error_t afc_file_read(afc_client_t client, uint64_t handle, char *data, uint * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written); +LIBIMOBILEDEVICE_API afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *data, uint32_t length, uint32_t *bytes_written); /** * Seeks to a given position of a pre-opened file on the device. @@ -239,7 +240,7 @@ afc_error_t afc_file_write(afc_client_t client, uint64_t handle, const char *dat * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); +LIBIMOBILEDEVICE_API afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, int whence); /** * Returns current position in a pre-opened file on the device. @@ -250,7 +251,7 @@ afc_error_t afc_file_seek(afc_client_t client, uint64_t handle, int64_t offset, * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position); +LIBIMOBILEDEVICE_API afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *position); /** * Sets the size of a file on the device. @@ -264,7 +265,7 @@ afc_error_t afc_file_tell(afc_client_t client, uint64_t handle, uint64_t *positi * @note This function is more akin to ftruncate than truncate, and truncate * calls would have to open the file before calling this, sadly. */ -afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); +LIBIMOBILEDEVICE_API afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t newsize); /** * Deletes a file or directory. @@ -274,7 +275,7 @@ afc_error_t afc_file_truncate(afc_client_t client, uint64_t handle, uint64_t new * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_remove_path(afc_client_t client, const char *path); +LIBIMOBILEDEVICE_API afc_error_t afc_remove_path(afc_client_t client, const char *path); /** * Renames a file or directory on the device. @@ -285,7 +286,7 @@ afc_error_t afc_remove_path(afc_client_t client, const char *path); * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); +LIBIMOBILEDEVICE_API afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *to); /** * Creates a directory on the device. @@ -296,7 +297,7 @@ afc_error_t afc_rename_path(afc_client_t client, const char *from, const char *t * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_make_directory(afc_client_t client, const char *path); +LIBIMOBILEDEVICE_API afc_error_t afc_make_directory(afc_client_t client, const char *path); /** * Sets the size of a file on the device without prior opening it. @@ -307,7 +308,7 @@ afc_error_t afc_make_directory(afc_client_t client, const char *path); * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize); +LIBIMOBILEDEVICE_API afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize); /** * Creates a hard link or symbolic link on the device. @@ -319,7 +320,7 @@ afc_error_t afc_truncate(afc_client_t client, const char *path, uint64_t newsize * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); +LIBIMOBILEDEVICE_API afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const char *target, const char *linkname); /** * Sets the modification time of a file on the device. @@ -330,7 +331,7 @@ afc_error_t afc_make_link(afc_client_t client, afc_link_type_t linktype, const c * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime); +LIBIMOBILEDEVICE_API afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mtime); /** * Deletes a file or directory including possible contents. @@ -342,7 +343,7 @@ afc_error_t afc_set_file_time(afc_client_t client, const char *path, uint64_t mt * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path); +LIBIMOBILEDEVICE_API afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path); /* Helper functions */ @@ -357,7 +358,7 @@ afc_error_t afc_remove_path_and_contents(afc_client_t client, const char *path); * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value); +LIBIMOBILEDEVICE_API afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char **value); /** * Frees up a char dictionary as returned by some AFC functions. @@ -366,7 +367,16 @@ afc_error_t afc_get_device_info_key(afc_client_t client, const char *key, char * * * @return AFC_E_SUCCESS on success or an AFC_E_* error value. */ -afc_error_t afc_dictionary_free(char **dictionary); +LIBIMOBILEDEVICE_API afc_error_t afc_dictionary_free(char **dictionary); + +/** + * Gets a readable error string for a given AFC error code. + * + * @param err An AFC error code + * + * @returns A readable error string + */ +LIBIMOBILEDEVICE_API const char* afc_strerror(afc_error_t err); #ifdef __cplusplus } diff --git a/include/libimobiledevice/bt_packet_logger.h b/include/libimobiledevice/bt_packet_logger.h new file mode 100644 index 0000000..590e5c1 --- /dev/null +++ b/include/libimobiledevice/bt_packet_logger.h @@ -0,0 +1,156 @@ +/** + * @file libimobiledevice/bt_packet_logger.h + * @brief Capture the Bluetooth HCI trace from a device + * \internal + * + * Copyright (c) 2021 Geoffrey Kruse, All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IBT_PACKET_LOGGER_H +#define IBT_PACKET_LOGGER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <libimobiledevice/libimobiledevice.h> +#include <libimobiledevice/lockdown.h> + +#define BT_PACKETLOGGER_SERVICE_NAME "com.apple.bluetooth.BTPacketLogger" +#define BT_MAX_PACKET_SIZE 65535 + +/** Error Codes */ +typedef enum { + BT_PACKET_LOGGER_E_SUCCESS = 0, + BT_PACKET_LOGGER_E_INVALID_ARG = -1, + BT_PACKET_LOGGER_E_MUX_ERROR = -2, + BT_PACKET_LOGGER_E_SSL_ERROR = -3, + BT_PACKET_LOGGER_E_NOT_ENOUGH_DATA = -4, + BT_PACKET_LOGGER_E_TIMEOUT = -5, + BT_PACKET_LOGGER_E_UNKNOWN_ERROR = -256 +} bt_packet_logger_error_t; + +typedef struct { + uint32_t length; + uint32_t ts_secs; + uint32_t ts_usecs; +} bt_packet_logger_header_t; + +typedef struct bt_packet_logger_client_private bt_packet_logger_client_private; +typedef bt_packet_logger_client_private *bt_packet_logger_client_t; /**< The client handle. */ + +/** Receives each hci packet received from the device. */ +typedef void (*bt_packet_logger_receive_cb_t)(uint8_t * data, uint16_t len, void *user_data); + +/* Interface */ + +/** + * Connects to the bt_packet_logger service on the specified device. + * + * @param device The device to connect to. + * @param service The service descriptor returned by lockdownd_start_service. + * @param client Pointer that will point to a newly allocated + * bt_packet_logger_client_t upon successful return. Must be freed using + * bt_packet_logger_client_free() after use. + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, BT_PACKET_LOGGER_E_INVALID_ARG when + * client is NULL, or an BT_PACKET_LOGGER_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_new(idevice_t device, lockdownd_service_descriptor_t service, bt_packet_logger_client_t * client); + +/** + * Starts a new bt_packet_logger service on the specified device and connects to it. + * + * @param device The device to connect to. + * @param client Pointer that will point to a newly allocated + * bt_packet_logger_client_t upon successful return. Must be freed using + * bt_packet_logger_client_free() after use. + * @param label The label to use for communication. Usually the program name. + * Pass NULL to disable sending the label in requests to lockdownd. + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, or an BT_PACKET_LOGGER_E_* error + * code otherwise. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_start_service(idevice_t device, bt_packet_logger_client_t * client, const char* label); + +/** + * Disconnects a bt_packet_logger client from the device and frees up the + * bt_packet_logger client data. + * + * @param client The bt_packet_logger client to disconnect and free. + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, BT_PACKET_LOGGER_E_INVALID_ARG when + * client is NULL, or an BT_PACKET_LOGGER_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t client); + + +/** + * Starts capturing the hci interface from the device using a callback. + * + * Use bt_packet_logger_stop_capture() to stop receiving hci data. + * + * @param client The bt_packet_logger client to use + * @param callback Callback to receive each packet from the hci interface. + * @param user_data Custom pointer passed to the callback function. + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, + * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are + * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified + * error occurs or an hci capture has already been started. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_start_capture(bt_packet_logger_client_t client, bt_packet_logger_receive_cb_t callback, void* user_data); + +/** + * Stops capturing the hci interface from the device. + * + * Use bt_packet_logger_start_capture() to start receiving the hci data. + * + * @param client The bt_packet_logger client to use + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, + * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are + * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified + * error occurs or an hci capture has already been started. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client); + +/* Receiving */ + +/** + * Receives data using the given bt_packet_logger client with specified timeout. + * + * @param client The bt_packet_logger client to use for receiving + * @param data Buffer that will be filled with the data received + * @param size Number of bytes to receive + * @param received Number of bytes received (can be NULL to ignore) + * @param timeout Maximum time in milliseconds to wait for data. + * + * @return BT_PACKET_LOGGER_E_SUCCESS on success, + * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are + * invalid, BT_PACKET_LOGGER_E_MUX_ERROR when a communication error + * occurs, or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified + * error occurs. + */ +LIBIMOBILEDEVICE_API bt_packet_logger_error_t bt_packet_logger_receive_with_timeout(bt_packet_logger_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libimobiledevice/companion_proxy.h b/include/libimobiledevice/companion_proxy.h new file mode 100644 index 0000000..544322a --- /dev/null +++ b/include/libimobiledevice/companion_proxy.h @@ -0,0 +1,212 @@ +/** + * @file libimobiledevice/companion_proxy.h + * @brief Companion proxy support. + * \internal + * + * Copyright (c) 2019-2020 Nikias Bassen, All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef ICOMPANION_PROXY_H +#define ICOMPANION_PROXY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <libimobiledevice/libimobiledevice.h> +#include <libimobiledevice/lockdown.h> + +/** Service identifier passed to lockdownd_start_service() to start the companion proxy service */ +#define COMPANION_PROXY_SERVICE_NAME "com.apple.companion_proxy" + +/** Error Codes */ +typedef enum { + COMPANION_PROXY_E_SUCCESS = 0, + COMPANION_PROXY_E_INVALID_ARG = -1, + COMPANION_PROXY_E_PLIST_ERROR = -2, + COMPANION_PROXY_E_MUX_ERROR = -3, + COMPANION_PROXY_E_SSL_ERROR = -4, + COMPANION_PROXY_E_NOT_ENOUGH_DATA = -5, + COMPANION_PROXY_E_TIMEOUT = -6, + COMPANION_PROXY_E_OP_IN_PROGRESS = -7, + COMPANION_PROXY_E_NO_DEVICES = -100, + COMPANION_PROXY_E_UNSUPPORTED_KEY = -101, + COMPANION_PROXY_E_TIMEOUT_REPLY = -102, + COMPANION_PROXY_E_UNKNOWN_ERROR = -256 +} companion_proxy_error_t; + +typedef struct companion_proxy_client_private companion_proxy_client_private; /**< \private */ +typedef companion_proxy_client_private *companion_proxy_client_t; /**< The client handle. */ + +/** Callback for companion device events */ +typedef void (*companion_proxy_device_event_cb_t) (plist_t event, void* userdata); + +/** + * Connects to the companion_proxy service on the specified device. + * + * @param device The device to connect to. + * @param service The service descriptor returned by lockdownd_start_service. + * @param client Pointer that will point to a newly allocated + * companion_proxy_client_t upon successful return. Must be freed using + * companion_proxy_client_free() after use. + * + * @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when + * the arguments are invalid, or an COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, companion_proxy_client_t* client); + +/** + * Starts a new companion_proxy service on the specified device and connects to it. + * + * @param device The device to connect to. + * @param client Pointer that will point to a newly allocated + * companion_proxy_client_t upon successful return. Must be freed using + * companion_proxy_client_free() after use. + * @param label The label to use for communication. Usually the program name. + * Pass NULL to disable sending the label in requests to lockdownd. + * + * @return COMPANION_PROXY_E_SUCCESS on success, or an COMPANION_PROXY_E_* error + * code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_start_service(idevice_t device, companion_proxy_client_t* client, const char* label); + +/** + * Disconnects a companion_proxy client from the device and frees up the + * companion_proxy client data. + * + * @param client The companion_proxy client to disconnect and free. + * + * @return COMPANION_PROXY_E_SUCCESS on success, COMPANION_PROXY_E_INVALID_ARG when + * client is NULL, or an COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_client_free(companion_proxy_client_t client); + +/** + * Sends a plist to the service. + * + * @param client The companion_proxy client + * @param plist The plist to send + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_send(companion_proxy_client_t client, plist_t plist); + +/** + * Receives a plist from the service. + * + * @param client The companion_proxy client + * @param plist The plist to store the received data + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * COMPANION_PROXY_E_INVALID_ARG when client or plist is NULL + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_receive(companion_proxy_client_t client, plist_t * plist); + +/** + * Retrieves a list of paired devices. + * + * @param client The companion_proxy client + * @param paired_devices Point that will receive a PLIST_ARRAY with paired device UDIDs + * + * @note The device closes the connection after sending the reply. + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * COMPANION_PROXY_E_NO_DEVICES if no devices are paired, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_device_registry(companion_proxy_client_t client, plist_t* paired_devices); + +/** + * Starts listening for paired devices. + * + * @param client The companion_proxy client + * @param callback Callback function that will be called when a new device is detected + * @param userdata Pointer that that will be passed to the callback function + * + * @note The event parameter that gets passed to the callback function is + * freed internally after returning from the callback. The consumer needs + * to make a copy if required. + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_listening_for_devices(companion_proxy_client_t client, companion_proxy_device_event_cb_t callback, void* userdata); + +/** + * Stops listening for paired devices + * + * @param client The companion_proxy client + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_listening_for_devices(companion_proxy_client_t client); + +/** + * Returns a value for the given key. + * + * @param client The companion_proxy client + * @param companion_udid UDID of the (paired) companion device + * @param key The key to retrieve the value for + * @param value A pointer to a plist_t that will receive the value for the given key. + * The consumer is responsible for freeing the value with plist_free() when no longer needed. + * + * @note The device closes the connection after sending the reply. + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * COMPANION_PROXY_E_INVALID_ARG when client or paired_devices is invalid, + * COMPANION_PROXY_E_UNSUPPORTED_KEY if the companion device doesn't support the given key, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_get_value_from_registry(companion_proxy_client_t client, const char* companion_udid, const char* key, plist_t* value); + +/** + * Start forwarding a service port on the companion device to a port on the idevice. + * + * @see companion_proxy_stop_forwarding_service_port + * + * @param client The companion_proxy client + * @param remote_port remote port + * @param service_name The name of the service that shall be forwarded + * @param forward_port Pointer that will receive the newly-assigned port accessible via USB/Network on the idevice + * @param options PLIST_DICT with additional options. Currently known are + * IsServiceLowPriority (boolean) and PreferWifi (boolean). + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_start_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port, const char* service_name, uint16_t* forward_port, plist_t options); + +/** + * Stop forwarding a service port between companion device and idevice. + * + * @see companion_proxy_start_forwarding_service_port + * + * @param client The companion_proxy client + * @param remote_port remote port + * + * @return COMPANION_PROXY_E_SUCCESS on success, + * or a COMPANION_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API companion_proxy_error_t companion_proxy_stop_forwarding_service_port(companion_proxy_client_t client, uint16_t remote_port); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libimobiledevice/debugserver.h b/include/libimobiledevice/debugserver.h index 19a4f5d..809b97f 100644 --- a/include/libimobiledevice/debugserver.h +++ b/include/libimobiledevice/debugserver.h @@ -30,7 +30,10 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the debugserver service */ #define DEBUGSERVER_SERVICE_NAME "com.apple.debugserver" +/** Service identifier passed to lockdownd_start_service() to start the secure debugserver service */ +#define DEBUGSERVER_SECURE_SERVICE_NAME DEBUGSERVER_SERVICE_NAME ".DVTSecureSocketProxy" /** Error Codes */ typedef enum { @@ -39,13 +42,14 @@ typedef enum { DEBUGSERVER_E_MUX_ERROR = -2, DEBUGSERVER_E_SSL_ERROR = -3, DEBUGSERVER_E_RESPONSE_ERROR = -4, + DEBUGSERVER_E_TIMEOUT = -5, DEBUGSERVER_E_UNKNOWN_ERROR = -256 } debugserver_error_t; -typedef struct debugserver_client_private debugserver_client_private; +typedef struct debugserver_client_private debugserver_client_private; /**< \private */ typedef debugserver_client_private *debugserver_client_t; /**< The client handle. */ -typedef struct debugserver_command_private debugserver_command_private; +typedef struct debugserver_command_private debugserver_command_private; /**< \private */ typedef debugserver_command_private *debugserver_command_t; /**< The command handle. */ /* Interface */ @@ -62,7 +66,7 @@ typedef debugserver_command_private *debugserver_command_t; /**< The command han * @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when * client is NULL, or an DEBUGSERVER_E_* error code otherwise. */ -debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t * client); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_descriptor_t service, debugserver_client_t * client); /** * Starts a new debugserver service on the specified device and connects to it. @@ -77,7 +81,7 @@ debugserver_error_t debugserver_client_new(idevice_t device, lockdownd_service_d * @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error * code otherwise. */ -debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_start_service(idevice_t device, debugserver_client_t * client, const char* label); /** * Disconnects a debugserver client from the device and frees up the @@ -88,7 +92,7 @@ debugserver_error_t debugserver_client_start_service(idevice_t device, debugserv * @return DEBUGSERVER_E_SUCCESS on success, DEBUGSERVER_E_INVALID_ARG when * client is NULL, or an DEBUGSERVER_E_* error code otherwise. */ -debugserver_error_t debugserver_client_free(debugserver_client_t client); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_free(debugserver_client_t client); /** * Sends raw data using the given debugserver service client. @@ -103,7 +107,7 @@ debugserver_error_t debugserver_client_free(debugserver_client_t client); * invalid, or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send(debugserver_client_t client, const char* data, uint32_t size, uint32_t *sent); /** * Receives raw data using the given debugserver client with specified timeout. @@ -117,10 +121,11 @@ debugserver_error_t debugserver_client_send(debugserver_client_t client, const c * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when one or more parameters are * invalid, DEBUGSERVER_E_MUX_ERROR when a communication error - * occurs, or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified + * occurs, DEBUGSERVER_E_TIMEOUT when the timeout is reached, + * or DEBUGSERVER_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); /** * Receives raw data from the debugserver service. @@ -134,7 +139,7 @@ debugserver_error_t debugserver_client_receive_with_timeout(debugserver_client_t * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when client or plist is NULL */ -debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive(debugserver_client_t client, char *data, uint32_t size, uint32_t *received); /** * Sends a command to the debugserver service. @@ -142,22 +147,24 @@ debugserver_error_t debugserver_client_receive(debugserver_client_t client, char * @param client The debugserver client * @param command Command to process and send * @param response Response received for the command (can be NULL to ignore) + * @param response_size Pointer to receive response size. Set to NULL to ignore. * * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when client or command is NULL */ -debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_send_command(debugserver_client_t client, debugserver_command_t command, char** response, size_t* response_size); /** * Receives and parses response of debugserver service. * * @param client The debugserver client * @param response Response received for last command (can be NULL to ignore) + * @param response_size Pointer to receive response size. Set to NULL to ignore. * * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when client is NULL */ -debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_receive_response(debugserver_client_t client, char** response, size_t* response_size); /** * Controls status of ACK mode when sending commands or receiving responses. @@ -171,7 +178,26 @@ debugserver_error_t debugserver_client_receive_response(debugserver_client_t cli * @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error * code otherwise. */ -debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, int enabled); + +/** + * Sets behavior when awaiting a response from the server. + * + * @see debugserver_client_send_command, debugserver_client_receive_response, + * debugserver_client_receive + * + * @param client The debugserver client + * @param cancel_receive A function pointer that will be called approximately + * every receive_loop_timeout milliseconds; the function should return a + * boolean flag specifying whether to stop waiting for a response. If NULL, + * behaves as if it always returns true. + * @param receive_loop_timeout Time in milliseconds between calls to + * cancel_receive. + * + * @return DEBUGSERVER_E_SUCCESS on success, or an DEBUGSERVER_E_* error + * code otherwise. + */ +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_receive_params(debugserver_client_t client, int (*cancel_receive)(), int receive_loop_timeout); /** * Sets the argv which launches an app. @@ -184,7 +210,7 @@ debugserver_error_t debugserver_client_set_ack_mode(debugserver_client_t client, * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when client is NULL */ -debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int argc, char* argv[], char** response); /** * Adds or sets an environment variable. @@ -196,7 +222,7 @@ debugserver_error_t debugserver_client_set_argv(debugserver_client_t client, int * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when client is NULL */ -debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_client_t client, const char* env, char** response); /** * Creates and initializes a new command object. @@ -209,7 +235,7 @@ debugserver_error_t debugserver_client_set_environment_hex_encoded(debugserver_c * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when name or command is NULL */ -debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_new(const char* name, int argc, char* argv[], debugserver_command_t* command); /** * Frees memory of command object. @@ -219,7 +245,7 @@ debugserver_error_t debugserver_command_new(const char* name, int argc, char* ar * @return DEBUGSERVER_E_SUCCESS on success, * DEBUGSERVER_E_INVALID_ARG when command is NULL */ -debugserver_error_t debugserver_command_free(debugserver_command_t command); +LIBIMOBILEDEVICE_API debugserver_error_t debugserver_command_free(debugserver_command_t command); /** * Encodes a string into hex notation. @@ -228,7 +254,7 @@ debugserver_error_t debugserver_command_free(debugserver_command_t command); * @param encoded_buffer The buffer receives a hex encoded string * @param encoded_length Length of the hex encoded string */ -void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length); +LIBIMOBILEDEVICE_API void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32_t* encoded_length); /** * Decodes a hex encoded string. @@ -237,7 +263,7 @@ void debugserver_encode_string(const char* buffer, char** encoded_buffer, uint32 * @param encoded_length Length of the encoded buffer * @param buffer Decoded string to be freed by the caller */ -void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer); +LIBIMOBILEDEVICE_API void debugserver_decode_string(const char *encoded_buffer, size_t encoded_length, char** buffer); #ifdef __cplusplus } diff --git a/include/libimobiledevice/diagnostics_relay.h b/include/libimobiledevice/diagnostics_relay.h index 97ac363..6ab47a9 100644 --- a/include/libimobiledevice/diagnostics_relay.h +++ b/include/libimobiledevice/diagnostics_relay.h @@ -30,6 +30,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the diagnostics relay service */ #define DIAGNOSTICS_RELAY_SERVICE_NAME "com.apple.mobile.diagnostics_relay" /** Error Codes */ @@ -42,16 +43,19 @@ typedef enum { DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR = -256 } diagnostics_relay_error_t; -#define DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT (1 << 1) -#define DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS (1 << 2) -#define DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL (1 << 3) +/** Action type for #diagnostics_relay_restart and #diagnostics_relay_shutdown */ +typedef enum { + DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT = 1 << 1, + DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS = 1 << 2, + DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL = 1 << 3 +} diagnostics_relay_action_t; -#define DIAGNOSTICS_RELAY_REQUEST_TYPE_ALL "All" -#define DIAGNOSTICS_RELAY_REQUEST_TYPE_WIFI "WiFi" -#define DIAGNOSTICS_RELAY_REQUEST_TYPE_GAS_GAUGE "GasGauge" -#define DIAGNOSTICS_RELAY_REQUEST_TYPE_NAND "NAND" +#define DIAGNOSTICS_RELAY_REQUEST_TYPE_ALL "All" /**< Query all available diagnostics */ +#define DIAGNOSTICS_RELAY_REQUEST_TYPE_WIFI "WiFi" /**< Query WiFi diagnostics */ +#define DIAGNOSTICS_RELAY_REQUEST_TYPE_GAS_GAUGE "GasGauge" /**< Query GasGauge diagnostics */ +#define DIAGNOSTICS_RELAY_REQUEST_TYPE_NAND "NAND" /**< Query NAND diagnostics */ -typedef struct diagnostics_relay_client_private diagnostics_relay_client_private; +typedef struct diagnostics_relay_client_private diagnostics_relay_client_private; /**< \private */ typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The client handle. */ /** @@ -66,7 +70,7 @@ typedef diagnostics_relay_client_private *diagnostics_relay_client_t; /**< The c * DIAGNOSTICS_RELAY_E_INVALID_ARG when one of the parameters is invalid, * or DIAGNOSTICS_RELAY_E_MUX_ERROR when the connection failed. */ -diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, diagnostics_relay_client_t *client); /** * Starts a new diagnostics_relay service on the specified device and connects to it. @@ -81,7 +85,7 @@ diagnostics_relay_error_t diagnostics_relay_client_new(idevice_t device, lockdow * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, or an DIAGNOSTICS_RELAY_E_* error * code otherwise. */ -diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t device, diagnostics_relay_client_t* client, const char* label); /** * Disconnects a diagnostics_relay client from the device and frees up the @@ -94,7 +98,7 @@ diagnostics_relay_error_t diagnostics_relay_client_start_service(idevice_t devic * is invalid, or DIAGNOSTICS_RELAY_E_UNKNOWN_ERROR when the was an * error freeing the parent property_list_service client. */ -diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client_t client); /** @@ -107,7 +111,7 @@ diagnostics_relay_error_t diagnostics_relay_client_free(diagnostics_relay_client * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the * request */ -diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t client); /** * Puts the device into deep sleep mode and disconnects from host. @@ -119,7 +123,7 @@ diagnostics_relay_error_t diagnostics_relay_goodbye(diagnostics_relay_client_t c * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the * request */ -diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t client); /** * Restart the device and optionally show a user notification. @@ -136,7 +140,7 @@ diagnostics_relay_error_t diagnostics_relay_sleep(diagnostics_relay_client_t cli * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the * request */ -diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, int flags); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t client, diagnostics_relay_action_t flags); /** * Shutdown of the device and optionally show a user notification. @@ -153,30 +157,69 @@ diagnostics_relay_error_t diagnostics_relay_restart(diagnostics_relay_client_t c * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the * request */ -diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, int flags); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_shutdown(diagnostics_relay_client_t client, diagnostics_relay_action_t flags); /** - * Shutdown of the device and optionally show a user notification. + * Request diagnostics information for a given type. * * @param client The diagnostics_relay client - * @param flags A binary flag combination of - * DIAGNOSTICS_RELAY_ACTION_FLAG_WAIT_FOR_DISCONNECT to wait until - * diagnostics_relay_client_free() disconnects before execution and - * DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_FAIL to show a "FAIL" dialog - * or DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS to show an "OK" dialog + * @param type The type or domain to query for diagnostics. Some known values + * are "All", "WiFi", "GasGauge", and "NAND". + * @param diagnostics A pointer to plist_t that will receive the diagnostics information. + * The consumer has to free the allocated memory with plist_free() when no longer needed. * * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL, * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the * request */ -diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics); +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_request_diagnostics(diagnostics_relay_client_t client, const char* type, plist_t* diagnostics); -diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result); +/** + * Query one or multiple MobileGestalt keys. + * + * @param client The diagnostics_relay client + * @param keys A PLIST_ARRAY with the keys to query. + * @param result A pointer to plist_t that will receive the result. The consumer + * has to free the allocated memory with plist_free() when no longer needed. + * + * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, + * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL, + * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the + * request + */ +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_mobilegestalt(diagnostics_relay_client_t client, plist_t keys, plist_t* result); -diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* name, const char* class, plist_t* result); +/** + * Query an IORegistry entry of a given class. + * + * @param client The diagnostics_relay client + * @param entry_name The IORegistry entry name to query. + * @param entry_class The IORegistry class to query. + * @param result A pointer to plist_t that will receive the result. The consumer + * has to free the allocated memory with plist_free() when no longer needed. + * + * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, + * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL, + * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the + * request + */ +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_entry(diagnostics_relay_client_t client, const char* entry_name, const char* entry_class, plist_t* result); -diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result); +/** + * Query an IORegistry plane. + * + * @param client The diagnostics_relay client + * @param plane The IORegistry plane name to query. + * @param result A pointer to plist_t that will receive the result. The consumer + * has to free the allocated memory with plist_free() when no longer needed. + * + * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, + * DIAGNOSTICS_RELAY_E_INVALID_ARG when client is NULL, + * DIAGNOSTICS_RELAY_E_PLIST_ERROR if the device did not acknowledge the + * request + */ +LIBIMOBILEDEVICE_API diagnostics_relay_error_t diagnostics_relay_query_ioregistry_plane(diagnostics_relay_client_t client, const char* plane, plist_t* result); #ifdef __cplusplus } diff --git a/include/libimobiledevice/file_relay.h b/include/libimobiledevice/file_relay.h index e41bb2d..00773b8 100644 --- a/include/libimobiledevice/file_relay.h +++ b/include/libimobiledevice/file_relay.h @@ -32,6 +32,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the file relay service */ #define FILE_RELAY_SERVICE_NAME "com.apple.mobile.file_relay" /** Error Codes */ @@ -46,7 +47,7 @@ typedef enum { FILE_RELAY_E_UNKNOWN_ERROR = -256 } file_relay_error_t; -typedef struct file_relay_client_private file_relay_client_private; +typedef struct file_relay_client_private file_relay_client_private; /**< \private */ typedef file_relay_client_private *file_relay_client_t; /**< The client handle. */ /** @@ -61,7 +62,7 @@ typedef file_relay_client_private *file_relay_client_t; /**< The client handle. * FILE_RELAY_E_INVALID_ARG when one of the parameters is invalid, * or FILE_RELAY_E_MUX_ERROR when the connection failed. */ -file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client); +LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, file_relay_client_t *client); /** * Starts a new file_relay service on the specified device and connects to it. @@ -76,7 +77,7 @@ file_relay_error_t file_relay_client_new(idevice_t device, lockdownd_service_des * @return FILE_RELAY_E_SUCCESS on success, or an FILE_RELAY_E_* error * code otherwise. */ -file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label); +LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_client_t* client, const char* label); /** * Disconnects a file_relay client from the device and frees up the file_relay @@ -89,7 +90,7 @@ file_relay_error_t file_relay_client_start_service(idevice_t device, file_relay_ * is invalid, or FILE_RELAY_E_UNKNOWN_ERROR when the was an error * freeing the parent property_list_service client. */ -file_relay_error_t file_relay_client_free(file_relay_client_t client); +LIBIMOBILEDEVICE_API file_relay_error_t file_relay_client_free(file_relay_client_t client); /** @@ -110,8 +111,7 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client); * data using idevice_connection_receive(). The connection will be closed * automatically by the device, but use file_relay_client_free() to clean * up properly. - * @param timeout Maximum time in milliseconds to wait for data. - * + * * @note WARNING: Don't call this function without reading the data afterwards. * A directory mobile_file_relay.XXXX used for creating the archive will * remain in the /tmp directory otherwise. @@ -123,7 +123,7 @@ file_relay_error_t file_relay_client_free(file_relay_client_t client); * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise. */ -file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection); +LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources(file_relay_client_t client, const char **sources, idevice_connection_t *connection); /** * Request data for the given sources. Calls file_relay_request_sources_timeout() with @@ -144,6 +144,7 @@ file_relay_error_t file_relay_request_sources(file_relay_client_t client, const * data using idevice_connection_receive(). The connection will be closed * automatically by the device, but use file_relay_client_free() to clean * up properly. + * @param timeout Maximum time in milliseconds to wait for data. * * @note WARNING: Don't call this function without reading the data afterwards. * A directory mobile_file_relay.XXXX used for creating the archive will @@ -156,7 +157,7 @@ file_relay_error_t file_relay_request_sources(file_relay_client_t client, const * sources are invalid, FILE_RELAY_E_STAGING_EMPTY if no data is available * for the given sources, or FILE_RELAY_E_UNKNOWN_ERROR otherwise. */ -file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout); +LIBIMOBILEDEVICE_API file_relay_error_t file_relay_request_sources_timeout(file_relay_client_t client, const char **sources, idevice_connection_t *connection, unsigned int timeout); #ifdef __cplusplus } diff --git a/include/libimobiledevice/heartbeat.h b/include/libimobiledevice/heartbeat.h index 1f5344a..4074b8b 100644 --- a/include/libimobiledevice/heartbeat.h +++ b/include/libimobiledevice/heartbeat.h @@ -30,6 +30,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the heartbeat service */ #define HEARTBEAT_SERVICE_NAME "com.apple.mobile.heartbeat" /** Error Codes */ @@ -44,7 +45,7 @@ typedef enum { HEARTBEAT_E_UNKNOWN_ERROR = -256 } heartbeat_error_t; -typedef struct heartbeat_client_private heartbeat_client_private; +typedef struct heartbeat_client_private heartbeat_client_private; /**< \private */ typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */ /** @@ -59,7 +60,7 @@ typedef heartbeat_client_private *heartbeat_client_t; /**< The client handle. */ * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when * client is NULL, or an HEARTBEAT_E_* error code otherwise. */ -heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descriptor_t service, heartbeat_client_t * client); /** * Starts a new heartbeat service on the specified device and connects to it. @@ -74,7 +75,7 @@ heartbeat_error_t heartbeat_client_new(idevice_t device, lockdownd_service_descr * @return HEARTBEAT_E_SUCCESS on success, or an HEARTBEAT_E_* error * code otherwise. */ -heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_client_t * client, const char* label); /** * Disconnects a heartbeat client from the device and frees up the @@ -85,7 +86,7 @@ heartbeat_error_t heartbeat_client_start_service(idevice_t device, heartbeat_cli * @return HEARTBEAT_E_SUCCESS on success, HEARTBEAT_E_INVALID_ARG when * client is NULL, or an HEARTBEAT_E_* error code otherwise. */ -heartbeat_error_t heartbeat_client_free(heartbeat_client_t client); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_client_free(heartbeat_client_t client); /** @@ -97,7 +98,7 @@ heartbeat_error_t heartbeat_client_free(heartbeat_client_t client); * @return HEARTBEAT_E_SUCCESS on success, * HEARTBEAT_E_INVALID_ARG when client or plist is NULL */ -heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist); /** * Receives a plist from the service. @@ -108,7 +109,7 @@ heartbeat_error_t heartbeat_send(heartbeat_client_t client, plist_t plist); * @return HEARTBEAT_E_SUCCESS on success, * HEARTBEAT_E_INVALID_ARG when client or plist is NULL */ -heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist); /** * Receives a plist using the given heartbeat client. @@ -116,7 +117,7 @@ heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist); * @param client The heartbeat client to use for receiving * @param plist pointer to a plist_t that will point to the received plist * upon successful return - * @param timeout Maximum time in milliseconds to wait for data. + * @param timeout_ms Maximum time in milliseconds to wait for data. * * @return HEARTBEAT_E_SUCCESS on success, * HEARTBEAT_E_INVALID_ARG when client or *plist is NULL, @@ -127,7 +128,7 @@ heartbeat_error_t heartbeat_receive(heartbeat_client_t client, plist_t * plist); * communication error occurs, or HEARTBEAT_E_UNKNOWN_ERROR * when an unspecified error occurs. */ -heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms); +LIBIMOBILEDEVICE_API heartbeat_error_t heartbeat_receive_with_timeout(heartbeat_client_t client, plist_t * plist, uint32_t timeout_ms); #ifdef __cplusplus } diff --git a/include/libimobiledevice/house_arrest.h b/include/libimobiledevice/house_arrest.h index 5a42838..f9ba68a 100644 --- a/include/libimobiledevice/house_arrest.h +++ b/include/libimobiledevice/house_arrest.h @@ -32,6 +32,7 @@ extern "C" { #include <libimobiledevice/lockdown.h> #include <libimobiledevice/afc.h> +/** Service identifier passed to lockdownd_start_service() to start the house arrest service */ #define HOUSE_ARREST_SERVICE_NAME "com.apple.mobile.house_arrest" /** Error Codes */ @@ -44,7 +45,7 @@ typedef enum { HOUSE_ARREST_E_UNKNOWN_ERROR = -256 } house_arrest_error_t; -typedef struct house_arrest_client_private house_arrest_client_private; +typedef struct house_arrest_client_private house_arrest_client_private; /**< \private */ typedef house_arrest_client_private *house_arrest_client_t; /**< The client handle. */ /* Interface */ @@ -60,7 +61,7 @@ typedef house_arrest_client_private *house_arrest_client_t; /**< The client hand * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when * client is NULL, or an HOUSE_ARREST_E_* error code otherwise. */ -house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service_descriptor_t service, house_arrest_client_t *client); /** * Starts a new house_arrest service on the specified device and connects to it. @@ -75,7 +76,7 @@ house_arrest_error_t house_arrest_client_new(idevice_t device, lockdownd_service * @return HOUSE_ARREST_E_SUCCESS on success, or an HOUSE_ARREST_E_* error * code otherwise. */ -house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_arrest_client_t* client, const char* label); /** * Disconnects an house_arrest client from the device and frees up the @@ -91,7 +92,7 @@ house_arrest_error_t house_arrest_client_start_service(idevice_t device, house_a * @return HOUSE_ARREST_E_SUCCESS on success, HOUSE_ARREST_E_INVALID_ARG when * client is NULL, or an HOUSE_ARREST_E_* error code otherwise. */ -house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); /** @@ -111,7 +112,7 @@ house_arrest_error_t house_arrest_client_free(house_arrest_client_t client); * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. */ -house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, plist_t dict); /** * Send a command to the connected house_arrest service. @@ -132,7 +133,7 @@ house_arrest_error_t house_arrest_send_request(house_arrest_client_t client, pli * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. */ -house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, const char *command, const char *appid); /** * Retrieves the result of a previously sent house_arrest_request_* request. @@ -148,7 +149,7 @@ house_arrest_error_t house_arrest_send_command(house_arrest_client_t client, con * HOUSE_ARREST_E_INVALID_MODE if the client is not in the correct mode, * or HOUSE_ARREST_E_CONN_FAILED if a connection error occurred. */ -house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict); +LIBIMOBILEDEVICE_API house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist_t *dict); /** @@ -170,7 +171,7 @@ house_arrest_error_t house_arrest_get_result(house_arrest_client_t client, plist * an afc client, or an AFC_E_* error code returned by * afc_client_new_with_service_client(). */ -afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client); +LIBIMOBILEDEVICE_API afc_error_t afc_client_new_from_house_arrest_client(house_arrest_client_t client, afc_client_t *afc_client); #ifdef __cplusplus } diff --git a/include/libimobiledevice/installation_proxy.h b/include/libimobiledevice/installation_proxy.h index 1ff82dc..44331aa 100644 --- a/include/libimobiledevice/installation_proxy.h +++ b/include/libimobiledevice/installation_proxy.h @@ -33,6 +33,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the installation proxy service */ #define INSTPROXY_SERVICE_NAME "com.apple.mobile.installation_proxy" /** Error Codes */ @@ -107,7 +108,7 @@ typedef enum { INSTPROXY_E_UNKNOWN_ERROR = -256 } instproxy_error_t; -typedef struct instproxy_client_private instproxy_client_private; +typedef struct instproxy_client_private instproxy_client_private; /**< \private */ typedef instproxy_client_private *instproxy_client_t; /**< The client handle. */ /** Reports the status response of the given command */ @@ -126,7 +127,7 @@ typedef void (*instproxy_status_cb_t) (plist_t command, plist_t status, void *us * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error value * when an error occurred. */ -instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descriptor_t service, instproxy_client_t *client); /** * Starts a new installation_proxy service on the specified device and connects to it. @@ -141,7 +142,7 @@ instproxy_error_t instproxy_client_new(idevice_t device, lockdownd_service_descr * @return INSTPROXY_E_SUCCESS on success, or an INSTPROXY_E_* error * code otherwise. */ -instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_client_t * client, const char* label); /** * Disconnects an installation_proxy client from the device and frees up the @@ -152,7 +153,7 @@ instproxy_error_t instproxy_client_start_service(idevice_t device, instproxy_cli * @return INSTPROXY_E_SUCCESS on success * or INSTPROXY_E_INVALID_ARG if client is NULL. */ -instproxy_error_t instproxy_client_free(instproxy_client_t client); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_free(instproxy_client_t client); /** * List installed applications. This function runs synchronously. @@ -170,7 +171,7 @@ instproxy_error_t instproxy_client_free(instproxy_client_t client); * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occurred. */ -instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_options, plist_t *result); /** * List pages of installed applications in a callback. @@ -189,7 +190,7 @@ instproxy_error_t instproxy_browse(instproxy_client_t client, plist_t client_opt * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occurred. */ -instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Lookup information about specific applications from the device. @@ -205,7 +206,7 @@ instproxy_error_t instproxy_browse_with_callback(instproxy_client_t client, plis * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occurred. */ -instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appids, plist_t client_options, plist_t *result); /** * Install an application on the device. @@ -228,10 +229,10 @@ instproxy_error_t instproxy_lookup(instproxy_client_t client, const char** appid * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Upgrade an application on the device. This function is nearly the same as @@ -256,10 +257,10 @@ instproxy_error_t instproxy_install(instproxy_client_t client, const char *pkg_p * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_path, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Uninstall an application from the device. @@ -277,10 +278,10 @@ instproxy_error_t instproxy_upgrade(instproxy_client_t client, const char *pkg_p * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * List archived applications. This function runs synchronously. @@ -296,7 +297,7 @@ instproxy_error_t instproxy_uninstall(instproxy_client_t client, const char *app * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occurred. */ -instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t client_options, plist_t *result); /** * Archive an application on the device. @@ -319,10 +320,10 @@ instproxy_error_t instproxy_lookup_archives(instproxy_client_t client, plist_t c * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Restore a previously archived application on the device. @@ -343,10 +344,10 @@ instproxy_error_t instproxy_archive(instproxy_client_t client, const char *appid * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Removes a previously archived application from the device. @@ -366,10 +367,10 @@ instproxy_error_t instproxy_restore(instproxy_client_t client, const char *appid * * @note If a callback function is given (async mode), this function returns * INSTPROXY_E_SUCCESS immediately if the status updater thread has been - * created successfully; any error occuring during the command has to be + * created successfully; any error occurring during the command has to be * handled inside the specified callback function. */ -instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char *appid, plist_t client_options, instproxy_status_cb_t status_cb, void *user_data); /** * Checks a device for certain capabilities. @@ -385,7 +386,7 @@ instproxy_error_t instproxy_remove_archive(instproxy_client_t client, const char * @return INSTPROXY_E_SUCCESS on success or an INSTPROXY_E_* error value if * an error occurred. */ -instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, const char** capabilities, plist_t client_options, plist_t *result); /* Helper */ @@ -395,7 +396,7 @@ instproxy_error_t instproxy_check_capabilities_match(instproxy_client_t client, * @param command The dictionary describing the command. * @param name Pointer to store the name of the command. */ -void instproxy_command_get_name(plist_t command, char** name); +LIBIMOBILEDEVICE_API void instproxy_command_get_name(plist_t command, char** name); /** * Gets the name of a status. @@ -403,7 +404,7 @@ void instproxy_command_get_name(plist_t command, char** name); * @param status The dictionary status response to use. * @param name Pointer to store the name of the status. */ -void instproxy_status_get_name(plist_t status, char **name); +LIBIMOBILEDEVICE_API void instproxy_status_get_name(plist_t status, char **name); /** * Gets error name, code and description from a response if available. @@ -419,7 +420,7 @@ void instproxy_status_get_name(plist_t status, char **name); * @return INSTPROXY_E_SUCCESS if no error is found or an INSTPROXY_E_* error * value matching the error that ẃas found in the status. */ -instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** description, uint64_t* code); /** * Gets total and current item information from a browse response if available. @@ -434,24 +435,24 @@ instproxy_error_t instproxy_status_get_error(plist_t status, char **name, char** * If NULL is passed no list will be returned. If NULL is returned no * list was found in the status. */ -void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list); +LIBIMOBILEDEVICE_API void instproxy_status_get_current_list(plist_t status, uint64_t* total, uint64_t* current_index, uint64_t* current_amount, plist_t* list); /** * Gets progress in percentage from a status if available. * * @param status The dictionary status response to use. - * @param name Pointer to store the progress in percent (0-100) or -1 if not - * progress was found in the status. + * @param percent Pointer to an int to store the progress in percent (0-100) + * or -1 if no progress was found in the status. */ -void instproxy_status_get_percent_complete(plist_t status, int *percent); +LIBIMOBILEDEVICE_API void instproxy_status_get_percent_complete(plist_t status, int *percent); /** * Creates a new client_options plist. * * @return A new plist_t of type PLIST_DICT. */ -plist_t instproxy_client_options_new(void); +LIBIMOBILEDEVICE_API plist_t instproxy_client_options_new(void); /** * Adds one or more new key:value pairs to the given client_options. @@ -463,7 +464,7 @@ plist_t instproxy_client_options_new(void); * keys "ApplicationSINF", "iTunesMetadata", "ReturnAttributes" which are * expecting a plist_t node as value and "SkipUninstall" expects int. */ -void instproxy_client_options_add(plist_t client_options, ...); +LIBIMOBILEDEVICE_API void instproxy_client_options_add(plist_t client_options, ...); /** * Adds attributes to the given client_options to filter browse results. @@ -473,7 +474,7 @@ void instproxy_client_options_add(plist_t client_options, ...); * * @note The values passed are expected to be strings. */ -void instproxy_client_options_set_return_attributes(plist_t client_options, ...); +LIBIMOBILEDEVICE_API void instproxy_client_options_set_return_attributes(plist_t client_options, ...); /** * Frees client_options plist. @@ -481,13 +482,13 @@ void instproxy_client_options_set_return_attributes(plist_t client_options, ...) * @param client_options The client options plist to free. Does nothing if NULL * is passed. */ -void instproxy_client_options_free(plist_t client_options); +LIBIMOBILEDEVICE_API void instproxy_client_options_free(plist_t client_options); /** * Queries the device for the path of an application. * * @param client The connected installation proxy client. - * @param appid ApplicationIdentifier of app to retrieve the path for. + * @param bundle_id ApplicationIdentifier of app to retrieve the path for. * @param path Pointer to store the device path for the application * which is set to NULL if it could not be determined. * @@ -495,7 +496,7 @@ void instproxy_client_options_free(plist_t client_options); * the path could not be determined or an INSTPROXY_E_* error * value if an error occurred. */ -instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path); +LIBIMOBILEDEVICE_API instproxy_error_t instproxy_client_get_path_for_bundle_identifier(instproxy_client_t client, const char* bundle_id, char** path); #ifdef __cplusplus } diff --git a/include/libimobiledevice/libimobiledevice.h b/include/libimobiledevice/libimobiledevice.h index 8f8589d..a9d270b 100644 --- a/include/libimobiledevice/libimobiledevice.h +++ b/include/libimobiledevice/libimobiledevice.h @@ -3,6 +3,7 @@ * @brief Device/Connection handling and communication * \internal * + * Copyright (c) 2010-2019 Nikias Bassen All Rights Reserved. * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. * Copyright (c) 2014 Christophe Fergeau All Rights Reserved. * Copyright (c) 2008 Jonathan Beck All Rights Reserved. @@ -34,6 +35,16 @@ extern "C" { #include <sys/stat.h> #include <plist/plist.h> +#ifndef LIBIMOBILEDEVICE_API + #ifdef LIBIMOBILEDEVICE_STATIC + #define LIBIMOBILEDEVICE_API + #elif defined(_WIN32) + #define LIBIMOBILEDEVICE_API __declspec(dllimport) + #else + #define LIBIMOBILEDEVICE_API + #endif +#endif + /** Error Codes */ typedef enum { IDEVICE_E_SUCCESS = 0, @@ -41,22 +52,44 @@ typedef enum { IDEVICE_E_UNKNOWN_ERROR = -2, IDEVICE_E_NO_DEVICE = -3, IDEVICE_E_NOT_ENOUGH_DATA = -4, + IDEVICE_E_CONNREFUSED = -5, IDEVICE_E_SSL_ERROR = -6, IDEVICE_E_TIMEOUT = -7 } idevice_error_t; -typedef struct idevice_private idevice_private; +typedef struct idevice_private idevice_private; /**< \private */ typedef idevice_private *idevice_t; /**< The device handle. */ -typedef struct idevice_connection_private idevice_connection_private; +typedef struct idevice_connection_private idevice_connection_private; /**< \private */ typedef idevice_connection_private *idevice_connection_t; /**< The connection handle. */ +/** Options for idevice_new_with_options() */ +enum idevice_options { + IDEVICE_LOOKUP_USBMUX = 1 << 1, /**< include USBMUX devices during lookup */ + IDEVICE_LOOKUP_NETWORK = 1 << 2, /**< include network devices during lookup */ + IDEVICE_LOOKUP_PREFER_NETWORK = 1 << 3 /**< prefer network connection if device is available via USBMUX *and* network */ +}; + +/** Type of connection a device is available on */ +enum idevice_connection_type { + CONNECTION_USBMUXD = 1, /**< device is available via USBMUX */ + CONNECTION_NETWORK /**< device is available via network */ +}; + +/** Device information returned by #idevice_get_device_list_extended API */ +struct idevice_info { + char *udid; /**< UDID of the device */ + enum idevice_connection_type conn_type; /**< Type of connection the device is available on */ + void* conn_data; /**< Connection data, depending on the connection type */ +}; +typedef struct idevice_info* idevice_info_t; + /* discovery (events/asynchronous) */ /** The event type for device add or removal */ enum idevice_event_type { - IDEVICE_DEVICE_ADD = 1, - IDEVICE_DEVICE_REMOVE, - IDEVICE_DEVICE_PAIRED + IDEVICE_DEVICE_ADD = 1, /**< device was added */ + IDEVICE_DEVICE_REMOVE, /**< device was removed */ + IDEVICE_DEVICE_PAIRED /**< device completed pairing process */ }; /* event data structure */ @@ -64,13 +97,16 @@ enum idevice_event_type { typedef struct { enum idevice_event_type event; /**< The event type. */ const char *udid; /**< The device unique id. */ - int conn_type; /**< The connection type. Currently only 1 for usbmuxd. */ + enum idevice_connection_type conn_type; /**< The connection type. */ } idevice_event_t; /* event callback function prototype */ /** Callback to notifiy if a device was added or removed. */ typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_data); +/** Event subscription context type */ +typedef struct idevice_subscription_context* idevice_subscription_context_t; + /* functions */ /** @@ -78,58 +114,115 @@ typedef void (*idevice_event_cb_t) (const idevice_event_t *event, void *user_dat * * @param level Set to 0 for no debug output or 1 to enable debug output. */ -void idevice_set_debug_level(int level); +LIBIMOBILEDEVICE_API void idevice_set_debug_level(int level); + +/** + * Subscribe a callback function that will be called when device add/remove + * events occur. + * + * @param context A pointer to a idevice_subscription_context_t that will be + * set upon creation of the subscription. The returned context must be + * passed to idevice_events_unsubscribe() to unsubscribe the callback. + * @param callback Callback function to call. + * @param user_data Application-specific data passed as parameter + * to the registered callback function. + * + * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_events_subscribe(idevice_subscription_context_t *context, idevice_event_cb_t callback, void *user_data); /** - * Register a callback function that will be called when device add/remove + * Unsubscribe the event callback function that has been registered with + * idevice_events_subscribe(). + * + * @param context A valid context as returned from idevice_events_subscribe(). + * + * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_events_unsubscribe(idevice_subscription_context_t context); + +/** + * (DEPRECATED) Register a callback function that will be called when device add/remove * events occur. * + * @deprecated Use idevice_events_subscribe() instead. + * * @param callback Callback function to call. * @param user_data Application-specific data passed as parameter * to the registered callback function. * * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. */ -idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data); +LIBIMOBILEDEVICE_API idevice_error_t idevice_event_subscribe(idevice_event_cb_t callback, void *user_data); /** - * Release the event callback function that has been registered with + * (DEPRECATED) Release the event callback function that has been registered with * idevice_event_subscribe(). * + * @deprecated Use idevice_events_unsubscribe() instead. + * * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. */ -idevice_error_t idevice_event_unsubscribe(void); +LIBIMOBILEDEVICE_API idevice_error_t idevice_event_unsubscribe(void); /* discovery (synchronous) */ /** - * Get a list of currently available devices. + * Get a list of UDIDs of currently available devices (USBMUX devices only). * - * @param devices List of udids of devices that are currently available. + * @param devices List of UDIDs of devices that are currently available. * This list is terminated by a NULL pointer. * @param count Number of devices found. * * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. + * + * @note This function only returns the UDIDs of USBMUX devices. To also include + * network devices in the list, use idevice_get_device_list_extended(). + * @see idevice_get_device_list_extended */ -idevice_error_t idevice_get_device_list(char ***devices, int *count); +LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list(char ***devices, int *count); /** - * Free a list of device udids. + * Free a list of device UDIDs. * - * @param devices List of udids to free. + * @param devices List of UDIDs to free. * * @return Always returnes IDEVICE_E_SUCCESS. */ -idevice_error_t idevice_device_list_free(char **devices); +LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_free(char **devices); + +/** + * Get a list of currently available devices + * + * @param devices List of idevice_info_t records with device information. + * This list is terminated by a NULL pointer. + * @param count Number of devices included in the list. + * + * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_get_device_list_extended(idevice_info_t **devices, int *count); + +/** + * Free an extended device list retrieved through idevice_get_device_list_extended(). + * + * @param devices Device list to free. + * + * @return IDEVICE_E_SUCCESS on success or an error value when an error occurred. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_device_list_extended_free(idevice_info_t *devices); /* device structure creation and destruction */ /** - * Creates an idevice_t structure for the device specified by udid, - * if the device is available. + * Creates an idevice_t structure for the device specified by UDID, + * if the device is available (USBMUX devices only). * * @note The resulting idevice_t structure has to be freed with * idevice_free() if it is no longer used. + * If you need to connect to a device available via network, use + * idevice_new_with_options() and include IDEVICE_LOOKUP_NETWORK in options. + * + * @see idevice_new_with_options * * @param device Upon calling this function, a pointer to a location of type * idevice_t. On successful return, this location will be populated. @@ -137,16 +230,37 @@ idevice_error_t idevice_device_list_free(char **devices); * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_new(idevice_t *device, const char *udid); +LIBIMOBILEDEVICE_API idevice_error_t idevice_new(idevice_t *device, const char *udid); + +/** + * Creates an idevice_t structure for the device specified by UDID, + * if the device is available, with the given lookup options. + * + * @note The resulting idevice_t structure has to be freed with + * idevice_free() if it is no longer used. + * + * @param device Upon calling this function, a pointer to a location of type + * idevice_t. On successful return, this location will be populated. + * @param udid The UDID to match. + * @param options Specifies what connection types should be considered + * when looking up devices. Accepts bitwise or'ed values of idevice_options. + * If 0 (no option) is specified it will default to IDEVICE_LOOKUP_USBMUX. + * To lookup both USB and network-connected devices, pass + * IDEVICE_LOOKUP_USBMUX | IDEVICE_LOOKUP_NETWORK. If a device is available + * both via USBMUX *and* network, it will select the USB connection. + * This behavior can be changed by adding IDEVICE_LOOKUP_PREFER_NETWORK + * to the options in which case it will select the network connection. + * + * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_new_with_options(idevice_t *device, const char *udid, enum idevice_options options); /** * Cleans up an idevice structure, then frees the structure itself. - * This is a library-level function; deals directly with the device to tear - * down relations, but otherwise is mostly internal. * * @param device idevice_t to free. */ -idevice_error_t idevice_free(idevice_t device); +LIBIMOBILEDEVICE_API idevice_error_t idevice_free(idevice_t device); /* connection/disconnection */ @@ -160,7 +274,7 @@ idevice_error_t idevice_free(idevice_t device); * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connection_t *connection); /** * Disconnect from the device and clean up the connection structure. @@ -169,7 +283,7 @@ idevice_error_t idevice_connect(idevice_t device, uint16_t port, idevice_connect * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_disconnect(idevice_connection_t connection); +LIBIMOBILEDEVICE_API idevice_error_t idevice_disconnect(idevice_connection_t connection); /* communication */ @@ -184,7 +298,7 @@ idevice_error_t idevice_disconnect(idevice_connection_t connection); * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes); /** * Receive data from a device via the given connection. @@ -201,7 +315,7 @@ idevice_error_t idevice_connection_send(idevice_connection_t connection, const c * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout); /** * Receive data from a device via the given connection. @@ -216,7 +330,7 @@ idevice_error_t idevice_connection_receive_timeout(idevice_connection_t connecti * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_receive(idevice_connection_t connection, char *data, uint32_t len, uint32_t *recv_bytes); /** * Enables SSL for the given connection. @@ -227,7 +341,7 @@ idevice_error_t idevice_connection_receive(idevice_connection_t connection, char * is NULL or connection->ssl_data is non-NULL, or IDEVICE_E_SSL_ERROR when * SSL initialization, setup, or handshake fails. */ -idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); /** * Disable SSL for the given connection. @@ -238,7 +352,21 @@ idevice_error_t idevice_connection_enable_ssl(idevice_connection_t connection); * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not * enabled and does no further error checking on cleanup. */ -idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); + +/** + * Disable bypass SSL for the given connection without sending out terminate messages. + * + * @param connection The connection to disable SSL for. + * @param sslBypass if true ssl connection will not be terminated but just cleaned up, allowing + * plain text data going on underlying connection + * + * @return IDEVICE_E_SUCCESS on success, IDEVICE_E_INVALID_ARG when connection + * is NULL. This function also returns IDEVICE_E_SUCCESS when SSL is not + * enabled and does no further error checking on cleanup. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_disable_bypass_ssl(idevice_connection_t connection, uint8_t sslBypass); + /** * Get the underlying file descriptor for a connection @@ -248,19 +376,36 @@ idevice_error_t idevice_connection_disable_ssl(idevice_connection_t connection); * * @return IDEVICE_E_SUCCESS if ok, otherwise an error code. */ -idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd); +LIBIMOBILEDEVICE_API idevice_error_t idevice_connection_get_fd(idevice_connection_t connection, int *fd); /* misc */ /** - * Gets the handle or (usbmux device id) of the device. + * Gets the handle or (USBMUX device id) of the device. + * + * @param device The device to get the USBMUX device id for. + * @param handle Pointer to a uint32_t that will be set to the USBMUX handle value. + * + * @return IDEVICE_E_SUCCESS on success, otherwise an error code. + */ +LIBIMOBILEDEVICE_API idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); + +/** + * Gets the Unique Device ID for the device. + * + * @param device The device to get the Unique Device ID for. + * @param udid Pointer that will be set to an allocated buffer with the device UDID. The consumer is responsible for releasing the allocated memory. + * + * @return IDEVICE_E_SUCCESS on success, otherwise an error code. */ -idevice_error_t idevice_get_handle(idevice_t device, uint32_t *handle); +LIBIMOBILEDEVICE_API idevice_error_t idevice_get_udid(idevice_t device, char **udid); /** - * Gets the unique id for the device. + * Returns a static string of the libimobiledevice version. + * + * @return The libimobiledevice version as static ascii string */ -idevice_error_t idevice_get_udid(idevice_t device, char **udid); +LIBIMOBILEDEVICE_API const char* libimobiledevice_version(); #ifdef __cplusplus } diff --git a/include/libimobiledevice/lockdown.h b/include/libimobiledevice/lockdown.h index b5c126c..21669ef 100644 --- a/include/libimobiledevice/lockdown.h +++ b/include/libimobiledevice/lockdown.h @@ -31,7 +31,6 @@ extern "C" { #endif #include <libimobiledevice/libimobiledevice.h> -#include <libimobiledevice/lockdown.h> /** Error Codes */ typedef enum { @@ -80,7 +79,7 @@ typedef enum { LOCKDOWN_E_UNKNOWN_ERROR = -256 } lockdownd_error_t; -typedef struct lockdownd_client_private lockdownd_client_private; +typedef struct lockdownd_client_private lockdownd_client_private; /**< \private */ typedef lockdownd_client_private *lockdownd_client_t; /**< The client handle. */ struct lockdownd_pair_record { @@ -88,17 +87,32 @@ struct lockdownd_pair_record { char *host_certificate; /**< The host certificate */ char *root_certificate; /**< The root certificate */ char *host_id; /**< A unique HostID for the host computer */ - char *system_buid; /**< A unique system id */ + char *system_buid; /**< A unique system id */ }; -/** A pair record holding device, host and root certificates along the host_id */ -typedef struct lockdownd_pair_record *lockdownd_pair_record_t; +/** pair record holding device, host and root certificates along the host_id */ +typedef struct lockdownd_pair_record *lockdownd_pair_record_t; /**< pair record */ +/** service descriptor */ struct lockdownd_service_descriptor { - uint16_t port; - uint8_t ssl_enabled; + uint16_t port; /**< port number the service was started on */ + uint8_t ssl_enabled; /**< an indicator if the service requires SSL */ + char* identifier; /**< identifier of the service */ }; typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t; +/** Callback types used in #lockdownd_cu_pairing_cb_t */ +typedef enum { + LOCKDOWN_CU_PAIRING_PIN_REQUESTED, /**< PIN requested: data_ptr is a char* buffer, and data_size points to the size of this buffer that must not be exceeded and has to be updated to the actual number of characters filled into the buffer. */ + LOCKDOWN_CU_PAIRING_DEVICE_INFO, /**< device information available: data_ptr is a plist_t, and data_size is ignored. The plist_t has to be copied if required, since it is freed when the callback function returns. */ + LOCKDOWN_CU_PAIRING_ERROR /**< pairing error message available: data_ptr is a NULL-terminated char* buffer containing the error message, and data_size is ignored. Buffer needs to be copied if it shall persist outside the callback. */ +} lockdownd_cu_pairing_cb_type_t; + +/* CU pairing callback function prototype */ +/** Callback used to supply the pairing PIN during a CU pairing session, + * and to report device information and pairing error messages. */ +typedef void (*lockdownd_cu_pairing_cb_t) (lockdownd_cu_pairing_cb_type_t cb_type, void *user_data, void* data_ptr, unsigned int* data_size); + + /* Interface */ /** @@ -116,7 +130,7 @@ typedef struct lockdownd_service_descriptor *lockdownd_service_descriptor_t; * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *client, const char *label); /** * Creates a new lockdownd client for the device and starts initial handshake. @@ -135,7 +149,7 @@ lockdownd_error_t lockdownd_client_new(idevice_t device, lockdownd_client_t *cli * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL, * LOCKDOWN_E_INVALID_CONF if configuration data is wrong */ -lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdownd_client_t *client, const char *label); /** * Closes the lockdownd client session if one is running and frees up the @@ -145,7 +159,7 @@ lockdownd_error_t lockdownd_client_new_with_handshake(idevice_t device, lockdown * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); /** @@ -157,7 +171,7 @@ lockdownd_error_t lockdownd_client_free(lockdownd_client_t client); * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); /** * Retrieves a preferences plist using an optional domain and/or key name. @@ -169,7 +183,7 @@ lockdownd_error_t lockdownd_query_type(lockdownd_client_t client, char **type); * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *domain, const char *key, plist_t *value); /** * Sets a preferences value using a plist and optional by domain and/or key name. @@ -182,7 +196,7 @@ lockdownd_error_t lockdownd_get_value(lockdownd_client_t client, const char *dom * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or * value is NULL */ -lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *domain, const char *key, plist_t value); /** * Removes a preference node by domain and/or key name. @@ -195,21 +209,21 @@ lockdownd_error_t lockdownd_set_value(lockdownd_client_t client, const char *dom * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_remove_value(lockdownd_client_t client, const char *domain, const char *key); /** * Requests to start a service and retrieve it's port on success. * * @param client The lockdownd client * @param identifier The identifier of the service to start - * @param descriptor The service descriptor on success or NULL on failure + * @param service The service descriptor on success or NULL on failure * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known * by the device, LOCKDOWN_E_START_SERVICE_FAILED if the service could not be * started by the device */ -lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); /** * Requests to start a service and retrieve it's port on success. @@ -217,7 +231,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char * * @param client The lockdownd client * @param identifier The identifier of the service to start - * @param descriptor The service descriptor on success or NULL on failure + * @param service The service descriptor on success or NULL on failure * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if a parameter * is NULL, LOCKDOWN_E_INVALID_SERVICE if the requested service is not known @@ -225,7 +239,7 @@ lockdownd_error_t lockdownd_start_service(lockdownd_client_t client, const char * started by the device, LOCKDOWN_E_INVALID_CONF if the host id or escrow bag are * missing from the device record. */ -lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t client, const char *identifier, lockdownd_service_descriptor_t *service); /** * Opens a session with lockdownd and switches to SSL mode if device wants it. @@ -240,7 +254,7 @@ lockdownd_error_t lockdownd_start_service_with_escrow_bag(lockdownd_client_t cli * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the supplied HostID, * LOCKDOWN_E_SSL_ERROR if enabling SSL communication failed */ -lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char *host_id, char **session_id, int *ssl_enabled); /** * Closes the lockdownd session by sending the StopSession request. @@ -252,7 +266,7 @@ lockdownd_error_t lockdownd_start_session(lockdownd_client_t client, const char * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char *session_id); /** * Sends a plist to lockdownd. @@ -266,7 +280,7 @@ lockdownd_error_t lockdownd_stop_session(lockdownd_client_t client, const char * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or * plist is NULL */ -lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist); /** * Receives a plist from lockdownd. @@ -277,7 +291,7 @@ lockdownd_error_t lockdownd_send(lockdownd_client_t client, plist_t plist); * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client or * plist is NULL */ -lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist); /** * Pairs the device using the supplied pair record. @@ -293,7 +307,7 @@ lockdownd_error_t lockdownd_receive(lockdownd_client_t client, plist_t *plist); * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id */ -lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); /** * Pairs the device using the supplied pair record and passing the given options. @@ -312,7 +326,7 @@ lockdownd_error_t lockdownd_pair(lockdownd_client_t client, lockdownd_pair_recor * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id */ -lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdownd_pair_record_t pair_record, plist_t options, plist_t *response); /** * Validates if the device is paired with the given HostID. If successful the @@ -331,7 +345,7 @@ lockdownd_error_t lockdownd_pair_with_options(lockdownd_client_t client, lockdow * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id */ -lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); /** * Unpairs the device with the given HostID and removes the pairing records @@ -347,7 +361,7 @@ lockdownd_error_t lockdownd_validate_pair(lockdownd_client_t client, lockdownd_p * LOCKDOWN_E_PASSWORD_PROTECTED if the device is password protected, * LOCKDOWN_E_INVALID_HOST_ID if the device does not know the caller's host id */ -lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_record_t pair_record); /** * Activates the device. Only works within an open session. @@ -364,7 +378,7 @@ lockdownd_error_t lockdownd_unpair(lockdownd_client_t client, lockdownd_pair_rec * LOCKDOWN_E_INVALID_ACTIVATION_RECORD if the device reports that the * activation_record is invalid */ -lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activation_record); /** * Deactivates the device, returning it to the locked “Activate with iTunes” @@ -376,7 +390,7 @@ lockdownd_error_t lockdownd_activate(lockdownd_client_t client, plist_t activati * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open, * LOCKDOWN_E_PLIST_ERROR if the received plist is broken */ -lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client); /** * Tells the device to immediately enter recovery mode. @@ -385,7 +399,7 @@ lockdownd_error_t lockdownd_deactivate(lockdownd_client_t client); * * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client is NULL */ -lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client); /** * Sends the Goodbye request to lockdownd signaling the end of communication. @@ -396,7 +410,90 @@ lockdownd_error_t lockdownd_enter_recovery(lockdownd_client_t client); * is NULL, LOCKDOWN_E_PLIST_ERROR if the device did not acknowledge the * request */ -lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client); + +/** + * Creates a CU pairing session for the current lockdown client. + * This is required to allow lockdownd_cu_send_request_and_get_reply(), + * lockdownd_get_value_cu() and lockdonwd_pair_cu() requests, and eventually + * allows to perform an actual wireless pairing. + * + * Through the callback function, the PIN displayed on the device has to be + * supplied during the process. Currently, only AppleTV devices have this + * capability. + * + * @param client The lockdown client to perform the CU pairing for + * @param pairing_callback Callback function that is used to supply the PIN + * for the pairing process, but also to receive device information or + * pairing error messages. + * @param cb_user_data User data that will be passed as additional argument + * to the callback function. + * @param host_info (Optional) A dictionary containing host information to + * send to the device when finalizing the CU pairing. The supplied + * values will override the default values gathered for the current host. + * @param acl (Optional) A dictionary containing ACL information. Currently + * only com.apple.ScreenCapture:true and com.apple.developer:true are known + * valid ACL values, which are used as default when NULL is passed. + * + * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if one of the + * parameters is invalid, LOCKDOWN_E_PAIRING_FAILED if the pairing failed, + * or a LOCKDOWN_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_pairing_create(lockdownd_client_t client, lockdownd_cu_pairing_cb_t pairing_callback, void* cb_user_data, plist_t host_info, plist_t acl); + +/** + * Sends a request via lockdown client with established CU pairing session + * and attempts to retrieve a reply. This function is used internally + * by lockdownd_get_value_cu() and lockdownd_pair_cu(), but exposed here to + * allow custom requests being sent and their replies being received. + * + * @param client A lockdown client with an established CU pairing. + * @param request The request to perform. + * @param request_payload The payload for the request. + * @param reply (Optional) If not NULL, the plist_t will be set to the reply + * dictionary that has been received. Consumer is responsible to free it + * using plist_free() when no longer required. + * + * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if one of the + * parameters is invalid, LOCKDOWN_E_NO_RUNNING_SESSION if the current + * lockdown client does not have an established CU pairing session, + * or a LOCKDOWN_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_cu_send_request_and_get_reply(lockdownd_client_t client, const char* request, plist_t request_payload, plist_t* reply); + +/** + * Retrieves a value using an optional domain and/or key name from a lockdown + * client with established CU pairing session. + * + * This is used to retrieve values that are only accessible after a CU pairing + * has been established, and would otherwise only be accessible with a valid + * device pairing. + * + * @param client A lockdown client with an established CU pairing. + * @param domain The domain to query on or NULL for global domain + * @param key The key name to request or NULL to query for all keys + * @param value A plist node representing the result value node + * + * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG if one of the + * parameters is invalid, LOCKDOWN_E_NO_RUNNING_SESSION if the current + * lockdown client does not have an established CU pairing session, + * or a LOCKDOWN_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_value_cu(lockdownd_client_t client, const char* domain, const char* key, plist_t* value); + +/** + * Perform a device pairing with a lockdown client that has an established + * CU pairing session. + * + * @param client A lockdown client with an established CU pairing. + * + * @return LOCKDOWN_E_SUCCESS on success, LOCKDOWN_E_INVALID_ARG when client + * is NULL, LOCKDOWN_E_NO_RUNNING_SESSION if the current lockdown client + * does not have an established CU pairing session, or a LOCKDOWN_E_* error + * code otherwise. + */ +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_pair_cu(lockdownd_client_t client); + /* Helper */ @@ -407,7 +504,7 @@ lockdownd_error_t lockdownd_goodbye(lockdownd_client_t client); * @param label The label to set or NULL to disable sending a label * */ -void lockdownd_client_set_label(lockdownd_client_t client, const char *label); +LIBIMOBILEDEVICE_API void lockdownd_client_set_label(lockdownd_client_t client, const char *label); /** * Returns the unique id of the device from lockdownd. @@ -418,7 +515,7 @@ void lockdownd_client_set_label(lockdownd_client_t client, const char *label); * * @return LOCKDOWN_E_SUCCESS on success */ -lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **udid); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t client, char **udid); /** * Retrieves the name of the device from lockdownd set by the user. @@ -429,7 +526,7 @@ lockdownd_error_t lockdownd_get_device_udid(lockdownd_client_t control, char **u * * @return LOCKDOWN_E_SUCCESS on success */ -lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **device_name); /** * Calculates and returns the data classes the device supports from lockdownd. @@ -444,7 +541,7 @@ lockdownd_error_t lockdownd_get_device_name(lockdownd_client_t client, char **de * LOCKDOWN_E_NO_RUNNING_SESSION if no session is open, * LOCKDOWN_E_PLIST_ERROR if the received plist is broken */ -lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, char ***classes, int *count); /** * Frees memory of an allocated array of data classes as returned by lockdownd_get_sync_data_classes() @@ -453,16 +550,25 @@ lockdownd_error_t lockdownd_get_sync_data_classes(lockdownd_client_t client, cha * * @return LOCKDOWN_E_SUCCESS on success */ -lockdownd_error_t lockdownd_data_classes_free(char **classes); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_data_classes_free(char **classes); /** * Frees memory of a service descriptor as returned by lockdownd_start_service() * - * @param sevice A service descriptor instance to free. + * @param service A service descriptor instance to free. * * @return LOCKDOWN_E_SUCCESS on success */ -lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service); +LIBIMOBILEDEVICE_API lockdownd_error_t lockdownd_service_descriptor_free(lockdownd_service_descriptor_t service); + +/** + * Gets a readable error string for a given lockdown error code. + * + * @param err A lockdownd error code + * + * @returns A readable error string + */ +LIBIMOBILEDEVICE_API const char* lockdownd_strerror(lockdownd_error_t err); #ifdef __cplusplus } diff --git a/include/libimobiledevice/misagent.h b/include/libimobiledevice/misagent.h index 09af57a..7981a8b 100644 --- a/include/libimobiledevice/misagent.h +++ b/include/libimobiledevice/misagent.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the misagent service */ #define MISAGENT_SERVICE_NAME "com.apple.misagent" /** Error Codes */ @@ -43,7 +44,7 @@ typedef enum { MISAGENT_E_UNKNOWN_ERROR = -256 } misagent_error_t; -typedef struct misagent_client_private misagent_client_private; +typedef struct misagent_client_private misagent_client_private; /**< \private */ typedef misagent_client_private *misagent_client_t; /**< The client handle. */ /* Interface */ @@ -59,7 +60,7 @@ typedef misagent_client_private *misagent_client_t; /**< The client handle. */ * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when * client is NULL, or an MISAGENT_E_* error code otherwise. */ -misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client); +LIBIMOBILEDEVICE_API misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descriptor_t service, misagent_client_t *client); /** * Starts a new misagent service on the specified device and connects to it. @@ -74,7 +75,7 @@ misagent_error_t misagent_client_new(idevice_t device, lockdownd_service_descrip * @return MISAGENT_E_SUCCESS on success, or an MISAGENT_E_* error * code otherwise. */ -misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label); +LIBIMOBILEDEVICE_API misagent_error_t misagent_client_start_service(idevice_t device, misagent_client_t* client, const char* label); /** * Disconnects an misagent client from the device and frees up the @@ -85,7 +86,7 @@ misagent_error_t misagent_client_start_service(idevice_t device, misagent_client * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when * client is NULL, or an MISAGENT_E_* error code otherwise. */ -misagent_error_t misagent_client_free(misagent_client_t client); +LIBIMOBILEDEVICE_API misagent_error_t misagent_client_free(misagent_client_t client); /** @@ -98,7 +99,7 @@ misagent_error_t misagent_client_free(misagent_client_t client); * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when * client is invalid, or an MISAGENT_E_* error code otherwise. */ -misagent_error_t misagent_install(misagent_client_t client, plist_t profile); +LIBIMOBILEDEVICE_API misagent_error_t misagent_install(misagent_client_t client, plist_t profile); /** * Retrieves all installed provisioning profiles (iOS 9.2.1 or below). @@ -117,7 +118,7 @@ misagent_error_t misagent_install(misagent_client_t client, plist_t profile); * still returns MISAGENT_E_SUCCESS and profiles will just point to an * empty array. */ -misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); +LIBIMOBILEDEVICE_API misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); /** * Retrieves all installed provisioning profiles (iOS 9.3 or higher). @@ -136,7 +137,7 @@ misagent_error_t misagent_copy(misagent_client_t client, plist_t* profiles); * still returns MISAGENT_E_SUCCESS and profiles will just point to an * empty array. */ -misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles); +LIBIMOBILEDEVICE_API misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles); /** * Removes a given provisioning profile. @@ -149,7 +150,7 @@ misagent_error_t misagent_copy_all(misagent_client_t client, plist_t* profiles); * @return MISAGENT_E_SUCCESS on success, MISAGENT_E_INVALID_ARG when * client is invalid, or an MISAGENT_E_* error code otherwise. */ -misagent_error_t misagent_remove(misagent_client_t client, const char* profileID); +LIBIMOBILEDEVICE_API misagent_error_t misagent_remove(misagent_client_t client, const char* profileID); /** * Retrieves the status code from the last operation. @@ -158,7 +159,7 @@ misagent_error_t misagent_remove(misagent_client_t client, const char* profileID * * @return -1 if client is invalid, or the status code from the last operation */ -int misagent_get_status_code(misagent_client_t client); +LIBIMOBILEDEVICE_API int misagent_get_status_code(misagent_client_t client); #ifdef __cplusplus } diff --git a/include/libimobiledevice/mobile_image_mounter.h b/include/libimobiledevice/mobile_image_mounter.h index 8d783c4..d4fc3f4 100644 --- a/include/libimobiledevice/mobile_image_mounter.h +++ b/include/libimobiledevice/mobile_image_mounter.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the mobile image mounter service */ #define MOBILE_IMAGE_MOUNTER_SERVICE_NAME "com.apple.mobile.mobile_image_mounter" /** Error Codes */ @@ -40,10 +41,11 @@ typedef enum { MOBILE_IMAGE_MOUNTER_E_PLIST_ERROR = -2, MOBILE_IMAGE_MOUNTER_E_CONN_FAILED = -3, MOBILE_IMAGE_MOUNTER_E_COMMAND_FAILED = -4, + MOBILE_IMAGE_MOUNTER_E_DEVICE_LOCKED = -5, MOBILE_IMAGE_MOUNTER_E_UNKNOWN_ERROR = -256 } mobile_image_mounter_error_t; -typedef struct mobile_image_mounter_client_private mobile_image_mounter_client_private; +typedef struct mobile_image_mounter_client_private mobile_image_mounter_client_private; /**< \private */ typedef mobile_image_mounter_client_private *mobile_image_mounter_client_t; /**< The client handle. */ /** callback for image upload */ @@ -64,7 +66,7 @@ typedef ssize_t (*mobile_image_mounter_upload_cb_t) (void* buffer, size_t length * or MOBILE_IMAGE_MOUNTER_E_CONN_FAILED if the connection to the * device could not be established. */ -mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdownd_service_descriptor_t service, mobile_image_mounter_client_t *client); /** * Starts a new mobile_image_mounter service on the specified device and connects to it. @@ -79,7 +81,7 @@ mobile_image_mounter_error_t mobile_image_mounter_new(idevice_t device, lockdown * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an MOBILE_IMAGE_MOUNTER_E_* error * code otherwise. */ -mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device, mobile_image_mounter_client_t* client, const char* label); /** * Disconnects a mobile_image_mounter client from the device and frees up the @@ -90,7 +92,7 @@ mobile_image_mounter_error_t mobile_image_mounter_start_service(idevice_t device * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, * or MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is NULL. */ -mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_client_t client); /** @@ -106,7 +108,7 @@ mobile_image_mounter_error_t mobile_image_mounter_free(mobile_image_mounter_clie * * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on success, or an error code on error */ -mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_mounter_client_t client, const char *image_type, plist_t *result); /** * Uploads an image with an optional signature to the device. @@ -125,7 +127,7 @@ mobile_image_mounter_error_t mobile_image_mounter_lookup_image(mobile_image_moun * @return MOBILE_IMAGE_MOUNTER_E_SUCCESS on succes, or a * MOBILE_IMAGE_MOUNTER_E_* error code otherwise. */ -mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_mounter_client_t client, const char *image_type, size_t image_size, const char *signature, uint16_t signature_size, mobile_image_mounter_upload_cb_t upload_cb, void* userdata); /** * Mounts an image on the device. @@ -148,7 +150,7 @@ mobile_image_mounter_error_t mobile_image_mounter_upload_image(mobile_image_moun * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if on ore more parameters are * invalid, or another error code otherwise. */ -mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mounter_client_t client, const char *image_path, const char *signature, uint16_t signature_size, const char *image_type, plist_t *result); /** * Hangs up the connection to the mobile_image_mounter service. @@ -161,7 +163,7 @@ mobile_image_mounter_error_t mobile_image_mounter_mount_image(mobile_image_mount * MOBILE_IMAGE_MOUNTER_E_INVALID_ARG if client is invalid, * or another error code otherwise. */ -mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client); +LIBIMOBILEDEVICE_API mobile_image_mounter_error_t mobile_image_mounter_hangup(mobile_image_mounter_client_t client); #ifdef __cplusplus } diff --git a/include/libimobiledevice/mobileactivation.h b/include/libimobiledevice/mobileactivation.h index b7f8064..8e036a8 100644 --- a/include/libimobiledevice/mobileactivation.h +++ b/include/libimobiledevice/mobileactivation.h @@ -30,6 +30,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the mobile activation service */ #define MOBILEACTIVATION_SERVICE_NAME "com.apple.mobileactivationd" /** Error Codes */ @@ -43,7 +44,7 @@ typedef enum { MOBILEACTIVATION_E_UNKNOWN_ERROR = -256 } mobileactivation_error_t; -typedef struct mobileactivation_client_private mobileactivation_client_private; +typedef struct mobileactivation_client_private mobileactivation_client_private; /**< \private */ typedef mobileactivation_client_private *mobileactivation_client_t; /**< The client handle. */ /** @@ -58,7 +59,7 @@ typedef mobileactivation_client_private *mobileactivation_client_t; /**< The cli * MOBILEACTIVATION_E_INVALID_ARG when one of the parameters is invalid, * or MOBILEACTIVATION_E_MUX_ERROR when the connection failed. */ -mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobileactivation_client_t *client); /** * Starts a new mobileactivation service on the specified device and connects to it. @@ -73,7 +74,7 @@ mobileactivation_error_t mobileactivation_client_new(idevice_t device, lockdownd * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, mobileactivation_client_t* client, const char* label); /** * Disconnects a mobileactivation client from the device and frees up the @@ -86,7 +87,7 @@ mobileactivation_error_t mobileactivation_client_start_service(idevice_t device, * is invalid, or MOBILEACTIVATION_E_UNKNOWN_ERROR when the was an * error freeing the parent property_list_service client. */ -mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t client); /** @@ -101,7 +102,7 @@ mobileactivation_error_t mobileactivation_client_free(mobileactivation_client_t * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_client_t client, plist_t *state); /** * Retrieves a session blob required for 'drmHandshake' via albert.apple.com. @@ -115,7 +116,7 @@ mobileactivation_error_t mobileactivation_get_activation_state(mobileactivation_ * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_session_info(mobileactivation_client_t client, plist_t *blob); /** * Retrieves the activation info required for device activation. @@ -129,7 +130,7 @@ mobileactivation_error_t mobileactivation_create_activation_session_info(mobilea * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info(mobileactivation_client_t client, plist_t *info); /** * Retrieves the activation info required for device activation in 'session' @@ -138,7 +139,7 @@ mobileactivation_error_t mobileactivation_create_activation_info(mobileactivatio * provided by mobileactivation_create_activation_session_info(). * * @param client The mobileactivation client - * @aram handshake_result The handshake result returned from drmHandshake + * @param handshake_response The handshake response returned from drmHandshake * @param info Pointer to a plist_t variable that will be set to the * activation info created by the mobileactivation service. The * consumer is responsible for freeing the returned object using @@ -147,7 +148,7 @@ mobileactivation_error_t mobileactivation_create_activation_info(mobileactivatio * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_result, plist_t *info); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_create_activation_info_with_session(mobileactivation_client_t client, plist_t handshake_response, plist_t *info); /** * Activates the device with the given activation record. @@ -160,7 +161,7 @@ mobileactivation_error_t mobileactivation_create_activation_info_with_session(mo * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t client, plist_t activation_record); /** * Activates the device with the given activation record in 'session' mode. @@ -175,14 +176,14 @@ mobileactivation_error_t mobileactivation_activate(mobileactivation_client_t cli * @return MOBILEACTIVATION_E_SUCCESS on success, or an MOBILEACTIVATION_E_* * error code otherwise. */ -mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_activate_with_session(mobileactivation_client_t client, plist_t activation_record, plist_t headers); /** * Deactivates the device. * * @param client The mobileactivation client */ -mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client); +LIBIMOBILEDEVICE_API mobileactivation_error_t mobileactivation_deactivate(mobileactivation_client_t client); #ifdef __cplusplus } diff --git a/include/libimobiledevice/mobilebackup.h b/include/libimobiledevice/mobilebackup.h index 6da3bed..2ecb60c 100644 --- a/include/libimobiledevice/mobilebackup.h +++ b/include/libimobiledevice/mobilebackup.h @@ -3,8 +3,8 @@ * @brief Backup and restore of all device data. * \internal * - * Copyright (c) 2009-2014 Martin Szulecki All Rights Reserved. - * Copyright (c) 2010 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2009-2014 Martin Szulecki, All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,22 +31,26 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the mobilebackup service */ #define MOBILEBACKUP_SERVICE_NAME "com.apple.mobilebackup" /** Error Codes */ typedef enum { - MOBILEBACKUP_E_SUCCESS = 0, - MOBILEBACKUP_E_INVALID_ARG = -1, - MOBILEBACKUP_E_PLIST_ERROR = -2, - MOBILEBACKUP_E_MUX_ERROR = -3, - MOBILEBACKUP_E_BAD_VERSION = -4, - MOBILEBACKUP_E_REPLY_NOT_OK = -5, - MOBILEBACKUP_E_UNKNOWN_ERROR = -256 + MOBILEBACKUP_E_SUCCESS = 0, + MOBILEBACKUP_E_INVALID_ARG = -1, + MOBILEBACKUP_E_PLIST_ERROR = -2, + MOBILEBACKUP_E_MUX_ERROR = -3, + MOBILEBACKUP_E_SSL_ERROR = -4, + MOBILEBACKUP_E_RECEIVE_TIMEOUT = -5, + MOBILEBACKUP_E_BAD_VERSION = -6, + MOBILEBACKUP_E_REPLY_NOT_OK = -7, + MOBILEBACKUP_E_UNKNOWN_ERROR = -256 } mobilebackup_error_t; -typedef struct mobilebackup_client_private mobilebackup_client_private; +typedef struct mobilebackup_client_private mobilebackup_client_private; /**< \private */ typedef mobilebackup_client_private *mobilebackup_client_t; /**< The client handle. */ +/** Available flags passed to #mobilebackup_request_restore */ typedef enum { MB_RESTORE_NOTIFY_SPRINGBOARD = 1 << 0, MB_RESTORE_PRESERVE_SETTINGS = 1 << 1, @@ -65,7 +69,7 @@ typedef enum { * or more parameters are invalid, or DEVICE_LINK_SERVICE_E_BAD_VERSION if * the mobilebackup version on the device is newer. */ -mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup_client_t * client); /** * Starts a new mobilebackup service on the specified device and connects to it. @@ -80,7 +84,7 @@ mobilebackup_error_t mobilebackup_client_new(idevice_t device, lockdownd_service * @return MOBILEBACKUP_E_SUCCESS on success, or an MOBILEBACKUP_E_* error * code otherwise. */ -mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobilebackup_client_t* client, const char* label); /** * Disconnects a mobilebackup client from the device and frees up the @@ -91,7 +95,7 @@ mobilebackup_error_t mobilebackup_client_start_service(idevice_t device, mobileb * @return MOBILEBACKUP_E_SUCCESS on success, or MOBILEBACKUP_E_INVALID_ARG * if client is NULL. */ -mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client); /** @@ -102,7 +106,7 @@ mobilebackup_error_t mobilebackup_client_free(mobilebackup_client_t client); * * @return an error code */ -mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t *plist); /** * Sends mobilebackup data to the device @@ -115,7 +119,7 @@ mobilebackup_error_t mobilebackup_receive(mobilebackup_client_t client, plist_t * * @return an error code */ -mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t plist); /** * Request a backup from the connected device. @@ -134,7 +138,7 @@ mobilebackup_error_t mobilebackup_send(mobilebackup_client_t client, plist_t pli * backup_manifest is not of type PLIST_DICT, MOBILEBACKUP_E_MUX_ERROR * if a communication error occurs, MOBILEBACKUP_E_REPLY_NOT_OK */ -mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, plist_t backup_manifest, const char *base_path, const char *proto_version); /** * Sends a confirmation to the device that a backup file has been received. @@ -145,7 +149,7 @@ mobilebackup_error_t mobilebackup_request_backup(mobilebackup_client_t client, p * client is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication error * occurs. */ -mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_t client); /** * Request that a backup should be restored to the connected device. @@ -168,7 +172,7 @@ mobilebackup_error_t mobilebackup_send_backup_file_received(mobilebackup_client_ * if a communication error occurs, or MOBILEBACKUP_E_REPLY_NOT_OK * if the device did not accept the request. */ -mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, plist_t backup_manifest, mobilebackup_flags_t flags, const char *proto_version); /** * Receive a confirmation from the device that it successfully received @@ -188,7 +192,7 @@ mobilebackup_error_t mobilebackup_request_restore(mobilebackup_client_t client, * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error * occurs. */ -mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_client_t client, plist_t *result); /** * Receive a confirmation from the device that it successfully received @@ -208,7 +212,7 @@ mobilebackup_error_t mobilebackup_receive_restore_file_received(mobilebackup_cli * message plist, or MOBILEBACKUP_E_MUX_ERROR if a communication error * occurs. */ -mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebackup_client_t client, plist_t *result); /** * Tells the device that the restore process is complete and waits for the @@ -221,7 +225,7 @@ mobilebackup_error_t mobilebackup_receive_restore_application_received(mobilebac * message plist is invalid, or MOBILEBACKUP_E_MUX_ERROR if a communication * error occurs. */ -mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t client); /** * Sends a backup error message to the device. @@ -233,7 +237,7 @@ mobilebackup_error_t mobilebackup_send_restore_complete(mobilebackup_client_t cl * one of the parameters is invalid, or MOBILEBACKUP_E_MUX_ERROR if a * communication error occurs. */ -mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason); +LIBIMOBILEDEVICE_API mobilebackup_error_t mobilebackup_send_error(mobilebackup_client_t client, const char *reason); #ifdef __cplusplus } diff --git a/include/libimobiledevice/mobilebackup2.h b/include/libimobiledevice/mobilebackup2.h index 0c42334..2e9222d 100644 --- a/include/libimobiledevice/mobilebackup2.h +++ b/include/libimobiledevice/mobilebackup2.h @@ -3,8 +3,8 @@ * @brief Backup and restore of all device data (mobilebackup2, iOS4+ only) * \internal * - * Copyright (c) 2011-2014 Martin Szulecki All Rights Reserved. - * Copyright (c) 2010-2012 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2011-2014 Martin Szulecki, All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the mobilebackup2 service */ #define MOBILEBACKUP2_SERVICE_NAME "com.apple.mobilebackup2" /** Error Codes */ @@ -39,13 +40,15 @@ typedef enum { MOBILEBACKUP2_E_INVALID_ARG = -1, MOBILEBACKUP2_E_PLIST_ERROR = -2, MOBILEBACKUP2_E_MUX_ERROR = -3, - MOBILEBACKUP2_E_BAD_VERSION = -4, - MOBILEBACKUP2_E_REPLY_NOT_OK = -5, - MOBILEBACKUP2_E_NO_COMMON_VERSION = -6, + MOBILEBACKUP2_E_SSL_ERROR = -4, + MOBILEBACKUP2_E_RECEIVE_TIMEOUT = -5, + MOBILEBACKUP2_E_BAD_VERSION = -6, + MOBILEBACKUP2_E_REPLY_NOT_OK = -7, + MOBILEBACKUP2_E_NO_COMMON_VERSION = -8, MOBILEBACKUP2_E_UNKNOWN_ERROR = -256 } mobilebackup2_error_t; -typedef struct mobilebackup2_client_private mobilebackup2_client_private; +typedef struct mobilebackup2_client_private mobilebackup2_client_private; /**< \private */ typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client handle. */ @@ -61,7 +64,7 @@ typedef mobilebackup2_client_private *mobilebackup2_client_t; /**< The client ha * if one or more parameter is invalid, or MOBILEBACKUP2_E_BAD_VERSION * if the mobilebackup2 version on the device is newer. */ -mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilebackup2_client_t * client); /** * Starts a new mobilebackup2 service on the specified device and connects to it. @@ -76,7 +79,7 @@ mobilebackup2_error_t mobilebackup2_client_new(idevice_t device, lockdownd_servi * @return MOBILEBACKUP2_E_SUCCESS on success, or an MOBILEBACKUP2_E_* error * code otherwise. */ -mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobilebackup2_client_t* client, const char* label); /** * Disconnects a mobilebackup2 client from the device and frees up the @@ -87,7 +90,7 @@ mobilebackup2_error_t mobilebackup2_client_start_service(idevice_t device, mobil * @return MOBILEBACKUP2_E_SUCCESS on success, or MOBILEBACKUP2_E_INVALID_ARG * if client is NULL. */ -mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client); /** @@ -102,7 +105,7 @@ mobilebackup2_error_t mobilebackup2_client_free(mobilebackup2_client_t client); * will be inserted into this plist before sending it. This parameter * can be NULL if message is not NULL. */ -mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, const char *message, plist_t options); /** * Receives a DL* message plist from the device. @@ -122,7 +125,7 @@ mobilebackup2_error_t mobilebackup2_send_message(mobilebackup2_client_t client, * or is not a DL* message plist, or MOBILEBACKUP2_E_MUX_ERROR if * receiving from the device failed. */ -mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t client, plist_t *msg_plist, char **dlmessage); /** * Send binary data to the device. @@ -140,7 +143,7 @@ mobilebackup2_error_t mobilebackup2_receive_message(mobilebackup2_client_t clien * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid, * or MOBILEBACKUP2_E_MUX_ERROR if sending of the data failed. */ -mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, const char *data, uint32_t length, uint32_t *bytes); /** * Receive binary from the device. @@ -154,13 +157,13 @@ mobilebackup2_error_t mobilebackup2_send_raw(mobilebackup2_client_t client, cons * @param data Pointer to a buffer that will be filled with the received data. * @param length Number of bytes to receive. The data buffer needs to be large * enough to store this amount of data. - * @paran bytes Number of bytes actually received. + * @param bytes Number of bytes actually received. * * @return MOBILEBACKUP2_E_SUCCESS if any or no data was received, * MOBILEBACKUP2_E_INVALID_ARG if one of the parameters is invalid, * or MOBILEBACKUP2_E_MUX_ERROR if receiving the data failed. */ -mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, char *data, uint32_t length, uint32_t *bytes); /** * Performs the mobilebackup2 protocol version exchange. @@ -173,7 +176,7 @@ mobilebackup2_error_t mobilebackup2_receive_raw(mobilebackup2_client_t client, c * @return MOBILEBACKUP2_E_SUCCESS on success, or a MOBILEBACKUP2_E_* error * code otherwise. */ -mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t client, double local_versions[], char count, double *remote_version); /** * Send a request to the connected mobilebackup2 service. @@ -188,7 +191,7 @@ mobilebackup2_error_t mobilebackup2_version_exchange(mobilebackup2_client_t clie * @return MOBILEBACKUP2_E_SUCCESS if the request was successfully sent, * or a MOBILEBACKUP2_E_* error value otherwise. */ -mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, const char *request, const char *target_identifier, const char *source_identifier, plist_t options); /** * Sends a DLMessageStatusResponse to the device. @@ -202,7 +205,7 @@ mobilebackup2_error_t mobilebackup2_send_request(mobilebackup2_client_t client, * @return MOBILEBACKUP2_E_SUCCESS on success, MOBILEBACKUP2_E_INVALID_ARG * if client is invalid, or another MOBILEBACKUP2_E_* otherwise. */ -mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2); +LIBIMOBILEDEVICE_API mobilebackup2_error_t mobilebackup2_send_status_response(mobilebackup2_client_t client, int status_code, const char *status1, plist_t status2); #ifdef __cplusplus } diff --git a/include/libimobiledevice/mobilesync.h b/include/libimobiledevice/mobilesync.h index e6885c7..c3bc53d 100644 --- a/include/libimobiledevice/mobilesync.h +++ b/include/libimobiledevice/mobilesync.h @@ -3,8 +3,8 @@ * @brief Synchronize data classes with a device and computer. * \internal * + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved. * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. - * Copyright (c) 2010-2011 Nikias Bassen All Rights Reserved. * Copyright (c) 2014 Christophe Fergeau All Rights Reserved. * Copyright (c) 2010 Bryan Forbes All Rights Reserved. * Copyright (c) 2009 Jonathan Beck All Rights Reserved. @@ -34,6 +34,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the mobilesync service */ #define MOBILESYNC_SERVICE_NAME "com.apple.mobilesync" /** Error Codes */ @@ -42,11 +43,13 @@ typedef enum { MOBILESYNC_E_INVALID_ARG = -1, MOBILESYNC_E_PLIST_ERROR = -2, MOBILESYNC_E_MUX_ERROR = -3, - MOBILESYNC_E_BAD_VERSION = -4, - MOBILESYNC_E_SYNC_REFUSED = -5, - MOBILESYNC_E_CANCELLED = -6, - MOBILESYNC_E_WRONG_DIRECTION = -7, - MOBILESYNC_E_NOT_READY = -8, + MOBILESYNC_E_SSL_ERROR = -4, + MOBILESYNC_E_RECEIVE_TIMEOUT = -5, + MOBILESYNC_E_BAD_VERSION = -6, + MOBILESYNC_E_SYNC_REFUSED = -7, + MOBILESYNC_E_CANCELLED = -8, + MOBILESYNC_E_WRONG_DIRECTION = -9, + MOBILESYNC_E_NOT_READY = -10, MOBILESYNC_E_UNKNOWN_ERROR = -256 } mobilesync_error_t; @@ -57,14 +60,16 @@ typedef enum { MOBILESYNC_SYNC_TYPE_RESET /**< Reset-sync signals that the computer should send all data again. */ } mobilesync_sync_type_t; -typedef struct mobilesync_client_private mobilesync_client_private; +typedef struct mobilesync_client_private mobilesync_client_private; /**< \private */ typedef mobilesync_client_private *mobilesync_client_t; /**< The client handle */ +/** Anchors used by the device and computer (structure) */ typedef struct { - char *device_anchor; - char *computer_anchor; + char *device_anchor; /**< device anchor */ + char *computer_anchor; /**< computer anchor */ } mobilesync_anchors; -typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the device and computer. */ +/** Anchors used by the device and computer */ +typedef mobilesync_anchors *mobilesync_anchors_t; /* Interface */ @@ -81,7 +86,7 @@ typedef mobilesync_anchors *mobilesync_anchors_t; /**< Anchors used by the devic * @retval DEVICE_LINK_SERVICE_E_BAD_VERSION if the mobilesync version on * the device is newer. */ -mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_descriptor_t service, mobilesync_client_t * client); /** * Starts a new mobilesync service on the specified device and connects to it. @@ -96,7 +101,7 @@ mobilesync_error_t mobilesync_client_new(idevice_t device, lockdownd_service_des * @return MOBILESYNC_E_SUCCESS on success, or an MOBILESYNC_E_* error * code otherwise. */ -mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_client_t* client, const char* label); /** * Disconnects a mobilesync client from the device and frees up the @@ -107,7 +112,7 @@ mobilesync_error_t mobilesync_client_start_service(idevice_t device, mobilesync_ * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if \a client is NULL. */ -mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); /** @@ -118,7 +123,7 @@ mobilesync_error_t mobilesync_client_free(mobilesync_client_t client); * * @return an error code */ -mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist); /** * Sends mobilesync data to the device @@ -131,7 +136,7 @@ mobilesync_error_t mobilesync_receive(mobilesync_client_t client, plist_t *plist * * @return an error code */ -mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); /** @@ -154,7 +159,7 @@ mobilesync_error_t mobilesync_send(mobilesync_client_t client, plist_t plist); * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the * sync request */ -mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data_class, mobilesync_anchors_t anchors, uint64_t computer_data_class_version, mobilesync_sync_type_t *sync_type, uint64_t *device_data_class_version, char** error_description); /** * Cancels a running synchronization session with a device at any time. @@ -165,7 +170,7 @@ mobilesync_error_t mobilesync_start(mobilesync_client_t client, const char *data * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid */ -mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* reason); /** * Finish a synchronization session of a data class on the device. @@ -178,7 +183,7 @@ mobilesync_error_t mobilesync_cancel(mobilesync_client_t client, const char* rea * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid * form */ -mobilesync_error_t mobilesync_finish(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_finish(mobilesync_client_t client); /** @@ -191,7 +196,7 @@ mobilesync_error_t mobilesync_finish(mobilesync_client_t client); * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid */ -mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t client); /** * Requests to receive only changed records of the currently set data class from the device. @@ -203,7 +208,7 @@ mobilesync_error_t mobilesync_get_all_records_from_device(mobilesync_client_t cl * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid */ -mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client); /** * Requests the device to delete all records of the current data class @@ -216,7 +221,7 @@ mobilesync_error_t mobilesync_get_changes_from_device(mobilesync_client_t client * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid * @retval MOBILESYNC_E_PLIST_ERROR if the received plist is not of valid form */ -mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t client); /** @@ -232,7 +237,7 @@ mobilesync_error_t mobilesync_clear_all_records_on_device(mobilesync_client_t cl * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the * session */ -mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_t *entities, uint8_t *is_last_record, plist_t *actions); /** * Acknowledges to the device that the changes have been merged on the computer @@ -242,7 +247,7 @@ mobilesync_error_t mobilesync_receive_changes(mobilesync_client_t client, plist_ * @retval MOBILESYNC_E_SUCCESS on success * @retval MOBILESYNC_E_INVALID_ARG if one of the parameters is invalid */ -mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_t client); /** @@ -262,7 +267,7 @@ mobilesync_error_t mobilesync_acknowledge_changes_from_device(mobilesync_client_ * @retval MOBILESYNC_E_NOT_READY if the device is not ready to start * receiving any changes */ -mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_client_t client); /** @@ -279,7 +284,7 @@ mobilesync_error_t mobilesync_ready_to_send_changes_from_computer(mobilesync_cli * @retval MOBILESYNC_E_WRONG_DIRECTION if the current sync direction does * not permit this call */ -mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t entities, uint8_t is_last_record, plist_t actions); /** * Receives any remapped identifiers reported after the device merged submitted changes. @@ -296,7 +301,7 @@ mobilesync_error_t mobilesync_send_changes(mobilesync_client_t client, plist_t e * @retval MOBILESYNC_E_CANCELLED if the device explicitly cancelled the * session */ -mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping); +LIBIMOBILEDEVICE_API mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plist_t *mapping); /* Helper */ @@ -309,14 +314,14 @@ mobilesync_error_t mobilesync_remap_identifiers(mobilesync_client_t client, plis * * @return A new #mobilesync_anchors_t struct. Must be freed using mobilesync_anchors_free(). */ -mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor); +LIBIMOBILEDEVICE_API mobilesync_anchors_t mobilesync_anchors_new(const char *device_anchor, const char *computer_anchor); /** * Free memory used by anchors. * * @param anchors The anchors to free. */ -void mobilesync_anchors_free(mobilesync_anchors_t anchors); +LIBIMOBILEDEVICE_API void mobilesync_anchors_free(mobilesync_anchors_t anchors); /** @@ -324,7 +329,7 @@ void mobilesync_anchors_free(mobilesync_anchors_t anchors); * * @return A new plist_t of type PLIST_DICT. */ -plist_t mobilesync_actions_new(void); +LIBIMOBILEDEVICE_API plist_t mobilesync_actions_new(void); /** * Add one or more new key:value pairs to the given actions plist. @@ -338,14 +343,14 @@ plist_t mobilesync_actions_new(void); * integer to use as a boolean value indicating that the device should * link submitted changes and report remapped identifiers. */ -void mobilesync_actions_add(plist_t actions, ...); +LIBIMOBILEDEVICE_API void mobilesync_actions_add(plist_t actions, ...); /** * Free actions plist. * * @param actions The actions plist to free. Does nothing if NULL is passed. */ -void mobilesync_actions_free(plist_t actions); +LIBIMOBILEDEVICE_API void mobilesync_actions_free(plist_t actions); #ifdef __cplusplus } diff --git a/include/libimobiledevice/notification_proxy.h b/include/libimobiledevice/notification_proxy.h index a9d2d3f..f4f090b 100644 --- a/include/libimobiledevice/notification_proxy.h +++ b/include/libimobiledevice/notification_proxy.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the notification proxy service */ #define NP_SERVICE_NAME "com.apple.mobile.notification_proxy" /** Error Codes */ @@ -43,22 +44,26 @@ typedef enum { } np_error_t; /** - * @name Notifications that can be send + * @name Notifications that can be sent * * For use with np_post_notification() (client --> device) */ +/**@{*/ +//! @cond #define NP_SYNC_WILL_START "com.apple.itunes-mobdev.syncWillStart" #define NP_SYNC_DID_START "com.apple.itunes-mobdev.syncDidStart" #define NP_SYNC_DID_FINISH "com.apple.itunes-mobdev.syncDidFinish" #define NP_SYNC_LOCK_REQUEST "com.apple.itunes-mobdev.syncLockRequest" -/*@}*/ +//! @endcond +/**@}*/ /** * @name Notifications that can be received * * For use with np_observe_notification() (device --> client) */ -/*@{*/ +/**@{*/ +//! @cond #define NP_SYNC_CANCEL_REQUEST "com.apple.itunes-client.syncCancelRequest" #define NP_SYNC_SUSPEND_REQUEST "com.apple.itunes-client.syncSuspendRequest" #define NP_SYNC_RESUME_REQUEST "com.apple.itunes-client.syncResumeRequest" @@ -81,12 +86,13 @@ typedef enum { #define NP_ITDBPREP_DID_END "com.apple.itdbprep.notification.didEnd" #define NP_LANGUAGE_CHANGED "com.apple.language.changed" #define NP_ADDRESS_BOOK_PREF_CHANGED "com.apple.AddressBook.PreferenceChanged" -/*@}*/ +//! @endcond +/**@}*/ -typedef struct np_client_private np_client_private; +typedef struct np_client_private np_client_private; /**< \private */ typedef np_client_private *np_client_t; /**< The client handle. */ -/** Reports which notification was received. */ +/** Callback function that reports which notification was received. */ typedef void (*np_notify_cb_t) (const char *notification, void *user_data); /* Interface */ @@ -103,7 +109,7 @@ typedef void (*np_notify_cb_t) (const char *notification, void *user_data); * or NP_E_CONN_FAILED when the connection to the device could not be * established. */ -np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client); +LIBIMOBILEDEVICE_API np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t service, np_client_t *client); /** * Starts a new notification proxy service on the specified device and connects to it. @@ -118,7 +124,7 @@ np_error_t np_client_new(idevice_t device, lockdownd_service_descriptor_t servic * @return NP_E_SUCCESS on success, or an NP_E_* error * code otherwise. */ -np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label); +LIBIMOBILEDEVICE_API np_error_t np_client_start_service(idevice_t device, np_client_t* client, const char* label); /** * Disconnects a notification_proxy client from the device and frees up the @@ -128,7 +134,7 @@ np_error_t np_client_start_service(idevice_t device, np_client_t* client, const * * @return NP_E_SUCCESS on success, or NP_E_INVALID_ARG when client is NULL. */ -np_error_t np_client_free(np_client_t client); +LIBIMOBILEDEVICE_API np_error_t np_client_free(np_client_t client); /** @@ -139,7 +145,7 @@ np_error_t np_client_free(np_client_t client); * * @return NP_E_SUCCESS on success, or an error returned by np_plist_send */ -np_error_t np_post_notification(np_client_t client, const char *notification); +LIBIMOBILEDEVICE_API np_error_t np_post_notification(np_client_t client, const char *notification); /** * Tells the device to send a notification on the specified event. @@ -150,7 +156,7 @@ np_error_t np_post_notification(np_client_t client, const char *notification); * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client or * notification are NULL, or an error returned by np_plist_send. */ -np_error_t np_observe_notification(np_client_t client, const char *notification); +LIBIMOBILEDEVICE_API np_error_t np_observe_notification(np_client_t client, const char *notification); /** * Tells the device to send a notification on specified events. @@ -163,7 +169,7 @@ np_error_t np_observe_notification(np_client_t client, const char *notification) * @return NP_E_SUCCESS on success, NP_E_INVALID_ARG when client is null, * or an error returned by np_observe_notification. */ -np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); +LIBIMOBILEDEVICE_API np_error_t np_observe_notifications(np_client_t client, const char **notification_spec); /** * This function allows an application to define a callback function that will @@ -187,7 +193,7 @@ np_error_t np_observe_notifications(np_client_t client, const char **notificatio * NP_E_INVALID_ARG when client is NULL, or NP_E_UNKNOWN_ERROR when * the callback thread could no be created. */ -np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *userdata); +LIBIMOBILEDEVICE_API np_error_t np_set_notify_callback(np_client_t client, np_notify_cb_t notify_cb, void *user_data); #ifdef __cplusplus } diff --git a/include/libimobiledevice/preboard.h b/include/libimobiledevice/preboard.h index 60b8e26..0d89eb4 100644 --- a/include/libimobiledevice/preboard.h +++ b/include/libimobiledevice/preboard.h @@ -30,6 +30,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the preboard service */ #define PREBOARD_SERVICE_NAME "com.apple.preboardservice_v2" /** Error Codes */ @@ -45,7 +46,7 @@ typedef enum { PREBOARD_E_UNKNOWN_ERROR = -256 } preboard_error_t; -typedef struct preboard_client_private preboard_client_private; +typedef struct preboard_client_private preboard_client_private; /**< \private */ typedef preboard_client_private *preboard_client_t; /**< The client handle. */ /** Reports the status response of the given command */ @@ -63,7 +64,7 @@ typedef void (*preboard_status_cb_t) (plist_t message, void *user_data); * @return PREBOARD_E_SUCCESS on success, PREBOARD_E_INVALID_ARG when * client is NULL, or an PREBOARD_E_* error code otherwise. */ -preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client); +LIBIMOBILEDEVICE_API preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descriptor_t service, preboard_client_t * client); /** * Starts a new preboard service on the specified device and connects to it. @@ -78,7 +79,7 @@ preboard_error_t preboard_client_new(idevice_t device, lockdownd_service_descrip * @return PREBOARD_E_SUCCESS on success, or a PREBOARD_E_* error * code otherwise. */ -preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label); +LIBIMOBILEDEVICE_API preboard_error_t preboard_client_start_service(idevice_t device, preboard_client_t * client, const char* label); /** * Disconnects a preboard client from the device and frees up the @@ -89,7 +90,7 @@ preboard_error_t preboard_client_start_service(idevice_t device, preboard_client * @return PREBOARD_E_SUCCESS on success, PREBOARD_E_INVALID_ARG when * client is NULL, or a PREBOARD_E_* error code otherwise. */ -preboard_error_t preboard_client_free(preboard_client_t client); +LIBIMOBILEDEVICE_API preboard_error_t preboard_client_free(preboard_client_t client); /** * Sends a plist to the service. @@ -101,7 +102,7 @@ preboard_error_t preboard_client_free(preboard_client_t client); * PREBOARD_E_INVALID_ARG when client or plist is NULL, * or a PREBOARD_E_* error code on error */ -preboard_error_t preboard_send(preboard_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API preboard_error_t preboard_send(preboard_client_t client, plist_t plist); /** * Receives a plist from the service. @@ -114,20 +115,21 @@ preboard_error_t preboard_send(preboard_client_t client, plist_t plist); * PREBOARD_E_TIMEOUT when no data was received after 5 seconds, * or a PREBOARD_E_* error code on error */ -preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist); +LIBIMOBILEDEVICE_API preboard_error_t preboard_receive(preboard_client_t client, plist_t * plist); /** * Receives a plist from the service with the specified timeout. * * @param client The preboard client * @param plist Pointer to a plist_t what will be set to the received plist + * @param timeout_ms Timeout in milliseconds * * @return PREBOARD_E_SUCCESS on success, * PREBOARD_E_INVALID_ARG when client or plist is NULL, * PREBOARD_E_TIMEOUT when no data was received after the given timeout, * or a PREBOARD_E_* error code on error. */ -preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms); +LIBIMOBILEDEVICE_API preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * plist, uint32_t timeout_ms); /** * Tells the preboard service to create a stashbag. This will make the device @@ -148,14 +150,14 @@ preboard_error_t preboard_receive_with_timeout(preboard_client_t client, plist_t * { Timeout: true } * followed by { HideDialog: true } * If the user aborts the passcode entry, the device sends a dictionary: - * { Error: 1, ErrorString: <error string> } + * { Error: 1, ErrorString: \<error string\> } * followed by { HideDialog: true } * * @return PREBOARD_E_SUCCESS if the command was successfully submitted, * PREBOARD_E_INVALID_ARG when client is invalid, * or a PREBOARD_E_* error code on error. */ -preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data); /** * Instructs the preboard service to commit a previously created stashbag. @@ -170,13 +172,13 @@ preboard_error_t preboard_create_stashbag(preboard_client_t client, plist_t mani * receive a dictionary with: * { StashbagCommitComplete: true } * or in case of an error: - * { StashbagCommitComplete: 0, Error: 1, <optional> ErrorString: <error string> } + * { StashbagCommitComplete: 0, Error: 1, \<optional\> ErrorString: \<error string\> } * * @return PREBOARD_E_SUCCESS if the command was successfully submitted, * PREBOARD_E_INVALID_ARG when client is invalid, * or a PREBOARD_E_* error code on error. */ -preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data); +LIBIMOBILEDEVICE_API preboard_error_t preboard_commit_stashbag(preboard_client_t client, plist_t manifest, preboard_status_cb_t status_cb, void *user_data); #ifdef __cplusplus } diff --git a/include/libimobiledevice/property_list_service.h b/include/libimobiledevice/property_list_service.h index 031d6f8..e6b26a3 100644 --- a/include/libimobiledevice/property_list_service.h +++ b/include/libimobiledevice/property_list_service.h @@ -29,8 +29,9 @@ extern "C" { #endif #include <libimobiledevice/lockdown.h> +#include <libimobiledevice/service.h> -/* Error Codes */ +/** Error Codes */ typedef enum { PROPERTY_LIST_SERVICE_E_SUCCESS = 0, PROPERTY_LIST_SERVICE_E_INVALID_ARG = -1, @@ -42,7 +43,7 @@ typedef enum { PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR = -256 } property_list_service_error_t; -typedef struct property_list_service_client_private property_list_service_private; +typedef struct property_list_service_client_private property_list_service_private; /**< \private */ typedef property_list_service_private* property_list_service_client_t; /**< The client handle. */ /* Interface */ @@ -59,7 +60,7 @@ typedef property_list_service_private* property_list_service_client_t; /**< The * PROPERTY_LIST_SERVICE_E_INVALID_ARG when one of the arguments is invalid, * or PROPERTY_LIST_SERVICE_E_MUX_ERROR when connecting to the device failed. */ -property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_new(idevice_t device, lockdownd_service_descriptor_t service, property_list_service_client_t *client); /** * Frees a PropertyList service. @@ -70,7 +71,7 @@ property_list_service_error_t property_list_service_client_new(idevice_t device, * PROPERTY_LIST_SERVICE_E_INVALID_ARG when client is invalid, or a * PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when another error occurred. */ -property_list_service_error_t property_list_service_client_free(property_list_service_client_t client); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_client_free(property_list_service_client_t client); /** * Sends an XML plist. @@ -83,7 +84,7 @@ property_list_service_error_t property_list_service_client_free(property_list_se * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist, * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs. */ -property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_xml_plist(property_list_service_client_t client, plist_t plist); /** * Sends a binary plist. @@ -96,7 +97,7 @@ property_list_service_error_t property_list_service_send_xml_plist(property_list * PROPERTY_LIST_SERVICE_E_PLIST_ERROR when dict is not a valid plist, * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when an unspecified error occurs. */ -property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_send_binary_plist(property_list_service_client_t client, plist_t plist); /** * Receives a plist using the given property list service client with specified @@ -115,7 +116,7 @@ property_list_service_error_t property_list_service_send_binary_plist(property_l * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when * an unspecified error occurs. */ -property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist_with_timeout(property_list_service_client_t client, plist_t *plist, unsigned int timeout); /** * Receives a plist using the given property list service client. @@ -138,7 +139,7 @@ property_list_service_error_t property_list_service_receive_plist_with_timeout(p * communication error occurs, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR when * an unspecified error occurs. */ -property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_receive_plist(property_list_service_client_t client, plist_t *plist); /** * Enable SSL for the given property list service client. @@ -147,11 +148,11 @@ property_list_service_error_t property_list_service_receive_plist(property_list_ * should be enabled. * * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, - * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is - * NULL, PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled, + * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid, + * PROPERTY_LIST_SERVICE_E_SSL_ERROR when SSL could not be enabled, * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. */ -property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_enable_ssl(property_list_service_client_t client); /** * Disable SSL for the given property list service client. @@ -160,10 +161,21 @@ property_list_service_error_t property_list_service_enable_ssl(property_list_ser * should be disabled. * * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, - * PROPERTY_LIST_SERVICE_E_INVALID_ARG if client or client->connection is - * NULL, or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. + * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid, + * or PROPERTY_LIST_SERVICE_E_UNKNOWN_ERROR otherwise. + */ +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client); + +/** + * Return a handle to the parent #service_client_t of the given property list service client. + * + * @param client The property list service client + * @param service_client Pointer to be assigned to the parent #service_client_t + * + * @return PROPERTY_LIST_SERVICE_E_SUCCESS on success, + * PROPERTY_LIST_SERVICE_E_INVALID_ARG if one or more of the arguments are invalid. */ -property_list_service_error_t property_list_service_disable_ssl(property_list_service_client_t client); +LIBIMOBILEDEVICE_API property_list_service_error_t property_list_service_get_service_client(property_list_service_client_t client, service_client_t *service_client); #ifdef __cplusplus } diff --git a/include/libimobiledevice/restore.h b/include/libimobiledevice/restore.h index 897c07c..859dc98 100644 --- a/include/libimobiledevice/restore.h +++ b/include/libimobiledevice/restore.h @@ -35,17 +35,14 @@ extern "C" { typedef enum { RESTORE_E_SUCCESS = 0, RESTORE_E_INVALID_ARG = -1, - RESTORE_E_INVALID_CONF = -2, - RESTORE_E_PLIST_ERROR = -3, - RESTORE_E_DICT_ERROR = -4, - RESTORE_E_NOT_ENOUGH_DATA = -5, - RESTORE_E_MUX_ERROR = -6, - RESTORE_E_START_RESTORE_FAILED = -7, - RESTORE_E_DEVICE_ERROR = -8, + RESTORE_E_PLIST_ERROR = -2, + RESTORE_E_MUX_ERROR = -3, + RESTORE_E_NOT_ENOUGH_DATA = -4, + RESTORE_E_RECEIVE_TIMEOUT = -5, RESTORE_E_UNKNOWN_ERROR = -256 } restored_error_t; -typedef struct restored_client_private restored_client_private; +typedef struct restored_client_private restored_client_private; /**< \private */ typedef restored_client_private *restored_client_t; /**< The client handle. */ /* Interface */ @@ -59,7 +56,7 @@ typedef restored_client_private *restored_client_t; /**< The client handle. */ * * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL */ -restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label); +LIBIMOBILEDEVICE_API restored_error_t restored_client_new(idevice_t device, restored_client_t *client, const char *label); /** * Closes the restored client session if one is running and frees up the @@ -69,7 +66,7 @@ restored_error_t restored_client_new(idevice_t device, restored_client_t *client * * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL */ -restored_error_t restored_client_free(restored_client_t client); +LIBIMOBILEDEVICE_API restored_error_t restored_client_free(restored_client_t client); /** @@ -82,7 +79,7 @@ restored_error_t restored_client_free(restored_client_t client); * * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL */ -restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version); +LIBIMOBILEDEVICE_API restored_error_t restored_query_type(restored_client_t client, char **type, uint64_t *version); /** * Queries a value from the device specified by a key. @@ -93,7 +90,7 @@ restored_error_t restored_query_type(restored_client_t client, char **type, uint * * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found */ -restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value); +LIBIMOBILEDEVICE_API restored_error_t restored_query_value(restored_client_t client, const char *key, plist_t *value); /** * Retrieves a value from information plist specified by a key. @@ -104,7 +101,7 @@ restored_error_t restored_query_value(restored_client_t client, const char *key, * * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, RESTORE_E_PLIST_ERROR if value for key can't be found */ -restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ; +LIBIMOBILEDEVICE_API restored_error_t restored_get_value(restored_client_t client, const char *key, plist_t *value) ; /** * Sends a plist to restored. @@ -118,7 +115,7 @@ restored_error_t restored_get_value(restored_client_t client, const char *key, p * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or * plist is NULL */ -restored_error_t restored_send(restored_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API restored_error_t restored_send(restored_client_t client, plist_t plist); /** * Receives a plist from restored. @@ -129,7 +126,7 @@ restored_error_t restored_send(restored_client_t client, plist_t plist); * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client or * plist is NULL */ -restored_error_t restored_receive(restored_client_t client, plist_t *plist); +LIBIMOBILEDEVICE_API restored_error_t restored_receive(restored_client_t client, plist_t *plist); /** * Sends the Goodbye request to restored signaling the end of communication. @@ -139,7 +136,7 @@ restored_error_t restored_receive(restored_client_t client, plist_t *plist); * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG when client is NULL, * RESTORE_E_PLIST_ERROR if the device did not acknowledge the request */ -restored_error_t restored_goodbye(restored_client_t client); +LIBIMOBILEDEVICE_API restored_error_t restored_goodbye(restored_client_t client); /** @@ -152,7 +149,7 @@ restored_error_t restored_goodbye(restored_client_t client); * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter * is NULL, RESTORE_E_START_RESTORE_FAILED if the request fails */ -restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version); +LIBIMOBILEDEVICE_API restored_error_t restored_start_restore(restored_client_t client, plist_t options, uint64_t version); /** * Requests device to reboot. @@ -162,7 +159,7 @@ restored_error_t restored_start_restore(restored_client_t client, plist_t option * @return RESTORE_E_SUCCESS on success, RESTORE_E_INVALID_ARG if a parameter * is NULL */ -restored_error_t restored_reboot(restored_client_t client); +LIBIMOBILEDEVICE_API restored_error_t restored_reboot(restored_client_t client); /* Helper */ @@ -173,7 +170,7 @@ restored_error_t restored_reboot(restored_client_t client); * @param label The label to set or NULL to disable sending a label * */ -void restored_client_set_label(restored_client_t client, const char *label); +LIBIMOBILEDEVICE_API void restored_client_set_label(restored_client_t client, const char *label); #ifdef __cplusplus } diff --git a/include/libimobiledevice/reverse_proxy.h b/include/libimobiledevice/reverse_proxy.h new file mode 100644 index 0000000..5e2f54b --- /dev/null +++ b/include/libimobiledevice/reverse_proxy.h @@ -0,0 +1,213 @@ +/** + * @file libimobiledevice/reverse_proxy.h + * @brief Provide a reverse proxy to allow the device to communicate through, + * which is used during firmware restore. + * \internal + * + * Copyright (c) 2021 Nikias Bassen, All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IREVERSE_PROXY_H +#define IREVERSE_PROXY_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <libimobiledevice/libimobiledevice.h> + +#define REVERSE_PROXY_DEFAULT_PORT 1082 /**< default port the reverse proxy is listening on */ + +/** Error Codes */ +typedef enum { + REVERSE_PROXY_E_SUCCESS = 0, + REVERSE_PROXY_E_INVALID_ARG = -1, + REVERSE_PROXY_E_PLIST_ERROR = -2, + REVERSE_PROXY_E_MUX_ERROR = -3, + REVERSE_PROXY_E_SSL_ERROR = -4, + REVERSE_PROXY_E_NOT_ENOUGH_DATA = -5, + REVERSE_PROXY_E_TIMEOUT = -6, + REVERSE_PROXY_E_UNKNOWN_ERROR = -256 +} reverse_proxy_error_t; + +typedef struct reverse_proxy_client_private reverse_proxy_client_private; /**< \private */ +typedef reverse_proxy_client_private *reverse_proxy_client_t; /**< The client handle. */ + +/** reverse proxy client type */ +typedef enum { + RP_TYPE_CTRL = 1, /**< control connection */ + RP_TYPE_CONN /**< proxy connection */ +} reverse_proxy_client_type_t; + +/** reverse proxy status for reverse_proxy_status_cb_t callback */ +typedef enum { + RP_STATUS_READY = 1, /**< proxy is ready */ + RP_STATUS_TERMINATE, /**< proxy terminated */ + RP_STATUS_CONNECT_REQ, /**< connection request received (only RP_TYPE_CTRL) */ + RP_STATUS_SHUTDOWN_REQ, /**< shutdown request received (only RP_TYPE_CTRL) */ + RP_STATUS_CONNECTED, /**< connection established (only RP_TYPE_CONN) */ + RP_STATUS_DISCONNECTED, /**< connection closed (only RP_TYPE_CONN) */ +} reverse_proxy_status_t; + +/** reverse proxy data direction passed to reverse_proxy_data_cb_t callback */ +typedef enum { + RP_DATA_DIRECTION_OUT = 1, /**< data going out to remote host */ + RP_DATA_DIRECTION_IN /**< data coming in from remote host */ +} reverse_proxy_data_direction_t; + +/** + * Log callback function prototype. + * + * @param client The client that called the callback function + * @param log_msg The log message + * @param user_data The user_data pointer that was set when registering the callback + */ +typedef void (*reverse_proxy_log_cb_t) (reverse_proxy_client_t client, const char* log_msg, void* user_data); + +/** + * Data callback function prototype. + * + * @param client The client that called the callback function + * @param direction The direction of the data, either RP_DATA_DIRECTION_OUT or RP_DATA_DIRECTION_IN + * @param buffer The data buffer + * @param length The length of the data buffer + * @param user_data The user_data pointer that was set when registering the callback + */ +typedef void (*reverse_proxy_data_cb_t) (reverse_proxy_client_t client, reverse_proxy_data_direction_t direction, const char* buffer, uint32_t length, void* user_data); + +/** + * Status callback function prototype. + * + * @param client The client that called the callback function + * @param status The status the client is reporting + * @param status_msg A status message the client reports along with the status + * @param user_data The user_data pointer that was set when registering the callback + */ +typedef void (*reverse_proxy_status_cb_t) (reverse_proxy_client_t client, reverse_proxy_status_t status, const char* status_msg, void* user_data); + +/** + * Create a reverse proxy client using com.apple.PurpleReverseProxy.Ctrl and + * com.apple.PurpleReverseProxy.Conn lockdown services. This will open a port + * 1083 on the device that iOS apps could connect to; \b however that is + * only allowed if an app has the com.apple.private.PurpleReverseProxy.allowed + * entitlement, which currently only \c /usr/libexec/fdrhelper holds. + * + * @note This function only creates and initializes the reverse proxy; + * to make it operational, call reverse_proxy_client_start_proxy(). + * + * @param device The device to connect to. + * @param client Pointer that will be set to a newly allocated #reverse_proxy_client_t + * upon successful return. + * @param label A label to pass to lockdownd when creating the service + * connections, usually the program name. + * + * @return REVERSE_PROXY_E_SUCCESS on success, + * or a REVERSE_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_service(idevice_t device, reverse_proxy_client_t* client, const char* label); + +/** + * Create a reverse proxy client using an open port on the device. This is + * used during firmware restores with the default port REVERSE_PROXY_DEFAULT_PORT (1082). + * + * @note This function only creates and initializes the reverse proxy; + * to make it operational, call reverse_proxy_client_start_proxy(). + * + * @param device The device to connect to. + * @param client Pointer that will be set to a newly allocated reverse_proxy_client_t + * upon successful return. + * @param device_port An open port on the device. Unless it's being used for + * a custom implementation, pass REVERSE_PROXY_DEFAULT_PORT here. + * + * @return REVERSE_PROXY_E_SUCCESS on success, + * or a REVERSE_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_create_with_port(idevice_t device, reverse_proxy_client_t* client, uint16_t device_port); + +/** + * Disconnects a reverse proxy client and frees up the client data. + * + * @param client The reverse proxy client to disconnect and free. + */ +LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_free(reverse_proxy_client_t client); + +/** + * Make an initialized reverse proxy client operational, i.e. start the actual proxy. + * + * @param client The reverse proxy client to start. + * @param control_protocol_version The control protocol version to use. + * This is either 1 or 2. Recent devices use 2. + * + * @return REVERSE_PROXY_E_SUCCESS on success, + * or a REVERSE_PROXY_E_* error code otherwise. + */ +LIBIMOBILEDEVICE_API reverse_proxy_error_t reverse_proxy_client_start_proxy(reverse_proxy_client_t client, int control_protocol_version); + +/** + * Set a status callback function. This allows to report the status of the + * reverse proxy, like Ready, Connect Request, Connected, etc. + * + * @note Set the callback before calling reverse_proxy_client_start_proxy(). + * + * @param client The reverse proxy client + * @param callback The status callback function that will be called + * when the status of the reverse proxy changes. + * @param user_data A pointer that will be passed to the callback function. + */ +LIBIMOBILEDEVICE_API void reverse_proxy_client_set_status_callback(reverse_proxy_client_t client, reverse_proxy_status_cb_t callback, void* user_data); + +/** + * Set a log callback function. Useful for debugging or verbosity. + * + * @note Set the callback before calling reverse_proxy_client_start_proxy(). + * + * @param client The reverse proxy client + * @param callback The log callback function that will be called + * when the reverse proxy logs something. + * @param user_data A pointer that will be passed to the callback function. + */ +LIBIMOBILEDEVICE_API void reverse_proxy_client_set_log_callback(reverse_proxy_client_t client, reverse_proxy_log_cb_t callback, void* user_data); + +/** + * Set a data callback function. Useful for debugging or extra verbosity. + * + * @note Set the callback before calling reverse_proxy_client_start_proxy(). + * + * @param client The reverse proxy client + * @param callback The status callback function that will be called + * when the status of the reverse proxy changes. + * @param user_data A pointer that will be passed to the callback function. + */ + +LIBIMOBILEDEVICE_API void reverse_proxy_client_set_data_callback(reverse_proxy_client_t client, reverse_proxy_data_cb_t callback, void* user_data); + +/** + * Helper function to return the type of a given reverse proxy client, which + * is either RP_TYPE_CTRL or RP_TYPE_CONN. Useful for callback functions. + * @see reverse_proxy_client_type_t + * + * @param client The reverse proxy client + * + * @return The type of the rerverse proxy client + */ +LIBIMOBILEDEVICE_API reverse_proxy_client_type_t reverse_proxy_get_type(reverse_proxy_client_t client); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/libimobiledevice/sbservices.h b/include/libimobiledevice/sbservices.h index 0259d97..7435947 100644 --- a/include/libimobiledevice/sbservices.h +++ b/include/libimobiledevice/sbservices.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the springboardservices service */ #define SBSERVICES_SERVICE_NAME "com.apple.springboardservices" /** Error Codes */ @@ -42,8 +43,7 @@ typedef enum { SBSERVICES_E_UNKNOWN_ERROR = -256 } sbservices_error_t; -/** @name Orientation of the user interface on the device */ -/*@{*/ +/** Orientation of the user interface on the device */ typedef enum { SBSERVICES_INTERFACE_ORIENTATION_UNKNOWN = 0, SBSERVICES_INTERFACE_ORIENTATION_PORTRAIT = 1, @@ -51,9 +51,8 @@ typedef enum { SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_RIGHT = 3, SBSERVICES_INTERFACE_ORIENTATION_LANDSCAPE_LEFT = 4 } sbservices_interface_orientation_t; -/*@}*/ -typedef struct sbservices_client_private sbservices_client_private; +typedef struct sbservices_client_private sbservices_client_private; /**< \private */ typedef sbservices_client_private *sbservices_client_t; /**< The client handle. */ /* Interface */ @@ -69,7 +68,7 @@ typedef sbservices_client_private *sbservices_client_t; /**< The client handle. * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when * client is NULL, or an SBSERVICES_E_* error code otherwise. */ -sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_descriptor_t service, sbservices_client_t *client); /** * Starts a new sbservices service on the specified device and connects to it. @@ -84,7 +83,7 @@ sbservices_error_t sbservices_client_new(idevice_t device, lockdownd_service_des * @return SBSERVICES_E_SUCCESS on success, or an SBSERVICES_E_* error * code otherwise. */ -sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_client_t* client, const char* label); /** * Disconnects an sbservices client from the device and frees up the @@ -95,7 +94,7 @@ sbservices_error_t sbservices_client_start_service(idevice_t device, sbservices_ * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when * client is NULL, or an SBSERVICES_E_* error code otherwise. */ -sbservices_error_t sbservices_client_free(sbservices_client_t client); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_client_free(sbservices_client_t client); /** @@ -112,7 +111,7 @@ sbservices_error_t sbservices_client_free(sbservices_client_t client); * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when * client or state is invalid, or an SBSERVICES_E_* error code otherwise. */ -sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t *state, const char *format_version); /** * Sets the icon state of the connected device. @@ -123,7 +122,7 @@ sbservices_error_t sbservices_get_icon_state(sbservices_client_t client, plist_t * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when * client or newstate is NULL, or an SBSERVICES_E_* error code otherwise. */ -sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t newstate); /** * Get the icon of the specified app as PNG data. @@ -140,7 +139,7 @@ sbservices_error_t sbservices_set_icon_state(sbservices_client_t client, plist_t * client, bundleId, or pngdata are invalid, or an SBSERVICES_E_* error * code otherwise. */ -sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const char *bundleId, char **pngdata, uint64_t *pngsize); /** * Gets the interface orientation of the device. @@ -151,7 +150,7 @@ sbservices_error_t sbservices_get_icon_pngdata(sbservices_client_t client, const * @return SBSERVICES_E_SUCCESS on success, SBSERVICES_E_INVALID_ARG when * client or state is invalid, or an SBSERVICES_E_* error code otherwise. */ -sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t client, sbservices_interface_orientation_t* interface_orientation); /** * Get the home screen wallpaper as PNG data. @@ -167,7 +166,7 @@ sbservices_error_t sbservices_get_interface_orientation(sbservices_client_t clie * client or pngdata are invalid, or an SBSERVICES_E_* error * code otherwise. */ -sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); +LIBIMOBILEDEVICE_API sbservices_error_t sbservices_get_home_screen_wallpaper_pngdata(sbservices_client_t client, char **pngdata, uint64_t *pngsize); #ifdef __cplusplus } diff --git a/include/libimobiledevice/screenshotr.h b/include/libimobiledevice/screenshotr.h index c12646b..db3c969 100644 --- a/include/libimobiledevice/screenshotr.h +++ b/include/libimobiledevice/screenshotr.h @@ -4,8 +4,8 @@ * @note Requires a mounted developer image. * \internal * - * Copyright (c) 2010-2014 Martin Szulecki All Rights Reserved. - * Copyright (c) 2010 Nikias Bassen All Rights Reserved. + * Copyright (c) 2010-2019 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2010-2014 Martin Szulecki, All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -32,19 +32,22 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the screenshotr service */ #define SCREENSHOTR_SERVICE_NAME "com.apple.mobile.screenshotr" /** Error Codes */ typedef enum { - SCREENSHOTR_E_SUCCESS = 0, - SCREENSHOTR_E_INVALID_ARG = -1, - SCREENSHOTR_E_PLIST_ERROR = -2, - SCREENSHOTR_E_MUX_ERROR = -3, - SCREENSHOTR_E_BAD_VERSION = -4, - SCREENSHOTR_E_UNKNOWN_ERROR = -256 + SCREENSHOTR_E_SUCCESS = 0, + SCREENSHOTR_E_INVALID_ARG = -1, + SCREENSHOTR_E_PLIST_ERROR = -2, + SCREENSHOTR_E_MUX_ERROR = -3, + SCREENSHOTR_E_SSL_ERROR = -4, + SCREENSHOTR_E_RECEIVE_TIMEOUT = -5, + SCREENSHOTR_E_BAD_VERSION = -6, + SCREENSHOTR_E_UNKNOWN_ERROR = -256 } screenshotr_error_t; -typedef struct screenshotr_client_private screenshotr_client_private; +typedef struct screenshotr_client_private screenshotr_client_private; /**< \private */ typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle. */ @@ -63,7 +66,7 @@ typedef screenshotr_client_private *screenshotr_client_t; /**< The client handle * or more parameters are invalid, or SCREENSHOTR_E_CONN_FAILED if the * connection to the device could not be established. */ -screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client); +LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_descriptor_t service, screenshotr_client_t * client); /** * Starts a new screenshotr service on the specified device and connects to it. @@ -78,7 +81,7 @@ screenshotr_error_t screenshotr_client_new(idevice_t device, lockdownd_service_d * @return SCREENSHOTR_E_SUCCESS on success, or an SCREENSHOTR_E_* error * code otherwise. */ -screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label); +LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_start_service(idevice_t device, screenshotr_client_t* client, const char* label); /** * Disconnects a screenshotr client from the device and frees up the @@ -89,7 +92,7 @@ screenshotr_error_t screenshotr_client_start_service(idevice_t device, screensho * @return SCREENSHOTR_E_SUCCESS on success, or SCREENSHOTR_E_INVALID_ARG * if client is NULL. */ -screenshotr_error_t screenshotr_client_free(screenshotr_client_t client); +LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_client_free(screenshotr_client_t client); /** @@ -106,7 +109,7 @@ screenshotr_error_t screenshotr_client_free(screenshotr_client_t client); * one or more parameters are invalid, or another error code if an * error occurred. */ -screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize); +LIBIMOBILEDEVICE_API screenshotr_error_t screenshotr_take_screenshot(screenshotr_client_t client, char **imgdata, uint64_t *imgsize); #ifdef __cplusplus } diff --git a/include/libimobiledevice/service.h b/include/libimobiledevice/service.h index 84c5092..f31ada4 100644 --- a/include/libimobiledevice/service.h +++ b/include/libimobiledevice/service.h @@ -42,9 +42,10 @@ typedef enum { SERVICE_E_UNKNOWN_ERROR = -256 } service_error_t; -typedef struct service_client_private service_client_private; +typedef struct service_client_private service_client_private; /**< \private */ typedef service_client_private* service_client_t; /**< The client handle. */ +/** service constructor cast */ #define SERVICE_CONSTRUCTOR(x) (int32_t (*)(idevice_t, lockdownd_service_descriptor_t, void**))(x) /* Interface */ @@ -61,7 +62,7 @@ typedef service_client_private* service_client_t; /**< The client handle. */ * SERVICE_E_INVALID_ARG when one of the arguments is invalid, * or SERVICE_E_MUX_ERROR when connecting to the device failed. */ -service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client); +LIBIMOBILEDEVICE_API service_error_t service_client_new(idevice_t device, lockdownd_service_descriptor_t service, service_client_t *client); /** * Starts a new service on the specified device with given name and @@ -74,11 +75,13 @@ service_error_t service_client_new(idevice_t device, lockdownd_service_descripto * use. * @param label The label to use for communication. Usually the program name. * Pass NULL to disable sending the label in requests to lockdownd. + * @param constructor_func Constructor function for the service client to create (e.g. afc_client_new()) + * @param error_code Pointer to an int32_t that will receive the service start error code. * * @return SERVICE_E_SUCCESS on success, or a SERVICE_E_* error code * otherwise. */ -service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code); +LIBIMOBILEDEVICE_API service_error_t service_client_factory_start_service(idevice_t device, const char* service_name, void **client, const char* label, int32_t (*constructor_func)(idevice_t, lockdownd_service_descriptor_t, void**), int32_t *error_code); /** * Frees a service instance. @@ -89,7 +92,7 @@ service_error_t service_client_factory_start_service(idevice_t device, const cha * SERVICE_E_INVALID_ARG when client is invalid, or a * SERVICE_E_UNKNOWN_ERROR when another error occurred. */ -service_error_t service_client_free(service_client_t client); +LIBIMOBILEDEVICE_API service_error_t service_client_free(service_client_t client); /** @@ -105,7 +108,7 @@ service_error_t service_client_free(service_client_t client); * invalid, or SERVICE_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent); +LIBIMOBILEDEVICE_API service_error_t service_send(service_client_t client, const char *data, uint32_t size, uint32_t *sent); /** * Receives data using the given service client with specified timeout. @@ -122,7 +125,7 @@ service_error_t service_send(service_client_t client, const char *data, uint32_t * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); +LIBIMOBILEDEVICE_API service_error_t service_receive_with_timeout(service_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); /** * Receives data using the given service client. @@ -140,7 +143,7 @@ service_error_t service_receive_with_timeout(service_client_t client, char *data * occurs, or SERVICE_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received); +LIBIMOBILEDEVICE_API service_error_t service_receive(service_client_t client, char *data, uint32_t size, uint32_t *received); /** @@ -155,18 +158,42 @@ service_error_t service_receive(service_client_t client, char *data, uint32_t si * SERVICE_E_SSL_ERROR when SSL could not be enabled, * or SERVICE_E_UNKNOWN_ERROR otherwise. */ -service_error_t service_enable_ssl(service_client_t client); +LIBIMOBILEDEVICE_API service_error_t service_enable_ssl(service_client_t client); /** * Disable SSL for the given service client. * - * @param client The connected service client for that SSL should be disabled. + * @param client The connected service client for which SSL should be disabled. * * @return SERVICE_E_SUCCESS on success, * SERVICE_E_INVALID_ARG if client or client->connection is * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise. */ -service_error_t service_disable_ssl(service_client_t client); +LIBIMOBILEDEVICE_API service_error_t service_disable_ssl(service_client_t client); + +/** + * Disable SSL for the given service client, optionally without sending SSL terminate messages. + * + * @param client The connected service client for which SSL should be disabled. + * @param sslBypass A boolean value indicating wether to disable SSL with a proper + * SSL shutdown (0), or bypass the shutdown (1). + * + * @return SERVICE_E_SUCCESS on success, + * SERVICE_E_INVALID_ARG if client or client->connection is + * NULL, or SERVICE_E_UNKNOWN_ERROR otherwise. + */ +LIBIMOBILEDEVICE_API service_error_t service_disable_bypass_ssl(service_client_t client, uint8_t sslBypass); + +/** + * Return a handle to the parent #idevice_connection_t of the given service client. + * + * @param client The service client + * @param connection Pointer to be assigned to the #idevice_connection_t. + * + * @return SERVICE_E_SUCCESS on success, + * SERVICE_E_INVALID_ARG if one or more of the arguments are invalid. + */ +LIBIMOBILEDEVICE_API service_error_t service_get_connection(service_client_t client, idevice_connection_t *connection); #ifdef __cplusplus } diff --git a/include/libimobiledevice/syslog_relay.h b/include/libimobiledevice/syslog_relay.h index ea7b649..0f6487a 100644 --- a/include/libimobiledevice/syslog_relay.h +++ b/include/libimobiledevice/syslog_relay.h @@ -3,7 +3,8 @@ * @brief Capture the syslog output from a device. * \internal * - * Copyright (c) 2013-2014 Martin Szulecki All Rights Reserved. + * Copyright (c) 2019-2020 Nikias Bassen, All Rights Reserved. + * Copyright (c) 2013-2014 Martin Szulecki, All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the syslog relay service */ #define SYSLOG_RELAY_SERVICE_NAME "com.apple.syslog_relay" /** Error Codes */ @@ -43,7 +45,7 @@ typedef enum { SYSLOG_RELAY_E_UNKNOWN_ERROR = -256 } syslog_relay_error_t; -typedef struct syslog_relay_client_private syslog_relay_client_private; +typedef struct syslog_relay_client_private syslog_relay_client_private; /**< \private */ typedef syslog_relay_client_private *syslog_relay_client_t; /**< The client handle. */ /** Receives each character received from the device. */ @@ -63,7 +65,7 @@ typedef void (*syslog_relay_receive_cb_t)(char c, void *user_data); * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise. */ -syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service_descriptor_t service, syslog_relay_client_t * client); /** * Starts a new syslog_relay service on the specified device and connects to it. @@ -78,7 +80,7 @@ syslog_relay_error_t syslog_relay_client_new(idevice_t device, lockdownd_service * @return SYSLOG_RELAY_E_SUCCESS on success, or an SYSLOG_RELAY_E_* error * code otherwise. */ -syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_relay_client_t * client, const char* label); /** * Disconnects a syslog_relay client from the device and frees up the @@ -89,7 +91,7 @@ syslog_relay_error_t syslog_relay_client_start_service(idevice_t device, syslog_ * @return SYSLOG_RELAY_E_SUCCESS on success, SYSLOG_RELAY_E_INVALID_ARG when * client is NULL, or an SYSLOG_RELAY_E_* error code otherwise. */ -syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client); /** @@ -106,7 +108,28 @@ syslog_relay_error_t syslog_relay_client_free(syslog_relay_client_t client); * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified * error occurs or a syslog capture has already been started. */ -syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data); + +/** + * Starts capturing the *raw* syslog of the device using a callback. + * This function is like syslog_relay_start_capture with the difference that + * it will neither check nor process the received data before passing it to + * the callback function. + * + * Use syslog_relay_stop_capture() to stop receiving the syslog. + * + * @note Use syslog_relay_start_capture for a safer implementation. + * + * @param client The syslog_relay client to use + * @param callback Callback to receive each character from the syslog. + * @param user_data Custom pointer passed to the callback function. + * + * @return SYSLOG_RELAY_E_SUCCESS on success, + * SYSLOG_RELAY_E_INVALID_ARG when one or more parameters are + * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified + * error occurs or a syslog capture has already been started. + */ +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_start_capture_raw(syslog_relay_client_t client, syslog_relay_receive_cb_t callback, void* user_data); /** * Stops capturing the syslog of the device. @@ -120,7 +143,7 @@ syslog_relay_error_t syslog_relay_start_capture(syslog_relay_client_t client, sy * invalid or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified * error occurs or a syslog capture has already been started. */ -syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client); /* Receiving */ @@ -139,7 +162,7 @@ syslog_relay_error_t syslog_relay_stop_capture(syslog_relay_client_t client); * occurs, or SYSLOG_RELAY_E_UNKNOWN_ERROR when an unspecified * error occurs. */ -syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received, unsigned int timeout); /** * Receives data from the service. @@ -148,12 +171,11 @@ syslog_relay_error_t syslog_relay_receive_with_timeout(syslog_relay_client_t cli * @param data Buffer that will be filled with the data received * @param size Number of bytes to receive * @param received Number of bytes received (can be NULL to ignore) - * @param timeout Maximum time in milliseconds to wait for data. * * @return SYSLOG_RELAY_E_SUCCESS on success, * SYSLOG_RELAY_E_INVALID_ARG when client or plist is NULL */ -syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received); +LIBIMOBILEDEVICE_API syslog_relay_error_t syslog_relay_receive(syslog_relay_client_t client, char *data, uint32_t size, uint32_t *received); #ifdef __cplusplus } diff --git a/include/libimobiledevice/webinspector.h b/include/libimobiledevice/webinspector.h index da0759c..16d2ca2 100644 --- a/include/libimobiledevice/webinspector.h +++ b/include/libimobiledevice/webinspector.h @@ -31,6 +31,7 @@ extern "C" { #include <libimobiledevice/libimobiledevice.h> #include <libimobiledevice/lockdown.h> +/** Service identifier passed to lockdownd_start_service() to start the webinspector service */ #define WEBINSPECTOR_SERVICE_NAME "com.apple.webinspector" /** Error Codes */ @@ -45,7 +46,7 @@ typedef enum { WEBINSPECTOR_E_UNKNOWN_ERROR = -256 } webinspector_error_t; -typedef struct webinspector_client_private webinspector_client_private; +typedef struct webinspector_client_private webinspector_client_private; /**< \private */ typedef webinspector_client_private *webinspector_client_t; /**< The client handle. */ @@ -61,7 +62,7 @@ typedef webinspector_client_private *webinspector_client_t; /**< The client hand * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when * client is NULL, or an WEBINSPECTOR_E_* error code otherwise. */ -webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service_descriptor_t service, webinspector_client_t * client); /** * Starts a new webinspector service on the specified device and connects to it. @@ -76,7 +77,7 @@ webinspector_error_t webinspector_client_new(idevice_t device, lockdownd_service * @return WEBINSPECTOR_E_SUCCESS on success, or an WEBINSPECTOR_E_* error * code otherwise. */ -webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_start_service(idevice_t device, webinspector_client_t * client, const char* label); /** * Disconnects a webinspector client from the device and frees up the @@ -87,7 +88,7 @@ webinspector_error_t webinspector_client_start_service(idevice_t device, webinsp * @return WEBINSPECTOR_E_SUCCESS on success, WEBINSPECTOR_E_INVALID_ARG when * client is NULL, or an WEBINSPECTOR_E_* error code otherwise. */ -webinspector_error_t webinspector_client_free(webinspector_client_t client); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_client_free(webinspector_client_t client); /** @@ -99,7 +100,7 @@ webinspector_error_t webinspector_client_free(webinspector_client_t client); * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL */ -webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_send(webinspector_client_t client, plist_t plist); /** * Receives a plist from the service. @@ -110,7 +111,7 @@ webinspector_error_t webinspector_send(webinspector_client_t client, plist_t pli * @return DIAGNOSTICS_RELAY_E_SUCCESS on success, * DIAGNOSTICS_RELAY_E_INVALID_ARG when client or plist is NULL */ -webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * plist); /** * Receives a plist using the given webinspector client. @@ -118,7 +119,7 @@ webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * @param client The webinspector client to use for receiving * @param plist pointer to a plist_t that will point to the received plist * upon successful return - * @param timeout Maximum time in milliseconds to wait for data. + * @param timeout_ms Maximum time in milliseconds to wait for data. * * @return WEBINSPECTOR_E_SUCCESS on success, * WEBINSPECTOR_E_INVALID_ARG when client or *plist is NULL, @@ -127,7 +128,7 @@ webinspector_error_t webinspector_receive(webinspector_client_t client, plist_t * communication error occurs, or WEBINSPECTOR_E_UNKNOWN_ERROR * when an unspecified error occurs. */ -webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms); +LIBIMOBILEDEVICE_API webinspector_error_t webinspector_receive_with_timeout(webinspector_client_t client, plist_t * plist, uint32_t timeout_ms); #ifdef __cplusplus } |