/** * Send data to a device via the given connection. * * @param connection The connection to send data over. * @param data Buffer with data to send. * @param len Size of the buffer to send. * @param sent_bytes Pointer to an uint32_t that will be filled * with the number of bytes actually sent. * * @return IPHONE_E_SUCCESS if ok, otherwise an error code. */ iphone_error_t iphone_device_send(iphone_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes) { if (!connection || !data) { return IPHONE_E_INVALID_ARG; } if (connection->type == CONNECTION_USBMUXD) { int res = usbmuxd_send((int)(connection->data), data, len, sent_bytes); if (res < 0) { log_debug_msg("%s: ERROR: usbmuxd_send returned %d (%s)\n", __func__, res, strerror(-res)); return IPHONE_E_UNKNOWN_ERROR; } return IPHONE_E_SUCCESS; } else { log_debug_msg("%s: Unknown connection type %d\n", __func__, connection->type); } return IPHONE_E_UNKNOWN_ERROR; }
/** * Internally used function to send raw data over the given connection. */ static idevice_error_t internal_connection_send(idevice_connection_t connection, const char *data, uint32_t len, uint32_t *sent_bytes) { if (!connection || !data) { return IDEVICE_E_INVALID_ARG; } if (connection->type == CONNECTION_USBMUXD) { int res = usbmuxd_send((int)(long)connection->data, data, len, sent_bytes); if (res < 0) { debug_info("ERROR: usbmuxd_send returned %d (%s)", res, strerror(-res)); return IDEVICE_E_UNKNOWN_ERROR; } return IDEVICE_E_SUCCESS; } else { debug_info("Unknown connection type %d", connection->type); } return IDEVICE_E_UNKNOWN_ERROR; }