diff options
| -rw-r--r-- | include/libimobiledevice/bt_packet_logger.h | 16 | ||||
| -rw-r--r-- | src/bt_packet_logger.c | 1 | ||||
| -rw-r--r-- | src/bt_packet_logger.h | 2 | ||||
| -rw-r--r-- | tools/idevicebtlogger.c | 18 |
4 files changed, 28 insertions, 9 deletions
diff --git a/include/libimobiledevice/bt_packet_logger.h b/include/libimobiledevice/bt_packet_logger.h index 8916219..230040a 100644 --- a/include/libimobiledevice/bt_packet_logger.h +++ b/include/libimobiledevice/bt_packet_logger.h | |||
| @@ -53,7 +53,7 @@ typedef struct { | |||
| 53 | typedef struct bt_packet_logger_client_private bt_packet_logger_client_private; | 53 | typedef struct bt_packet_logger_client_private bt_packet_logger_client_private; |
| 54 | typedef bt_packet_logger_client_private *bt_packet_logger_client_t; /**< The client handle. */ | 54 | typedef bt_packet_logger_client_private *bt_packet_logger_client_t; /**< The client handle. */ |
| 55 | 55 | ||
| 56 | /** Receives each character received from the device. */ | 56 | /** Receives each hci packet received from the device. */ |
| 57 | typedef void (*bt_packet_logger_receive_cb_t)(uint8_t * data, uint16_t len, void *user_data); | 57 | typedef void (*bt_packet_logger_receive_cb_t)(uint8_t * data, uint16_t len, void *user_data); |
| 58 | 58 | ||
| 59 | /* Interface */ | 59 | /* Interface */ |
| @@ -100,32 +100,32 @@ bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t | |||
| 100 | 100 | ||
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * Starts capturing the syslog of the device using a callback. | 103 | * Starts capturing the hci interface from the device using a callback. |
| 104 | * | 104 | * |
| 105 | * Use bt_packet_logger_stop_capture() to stop receiving the syslog. | 105 | * Use bt_packet_logger_stop_capture() to stop receiving hci data. |
| 106 | * | 106 | * |
| 107 | * @param client The bt_packet_logger client to use | 107 | * @param client The bt_packet_logger client to use |
| 108 | * @param callback Callback to receive each character from the syslog. | 108 | * @param callback Callback to receive each packet from the hci interface. |
| 109 | * @param user_data Custom pointer passed to the callback function. | 109 | * @param user_data Custom pointer passed to the callback function. |
| 110 | * | 110 | * |
| 111 | * @return BT_PACKET_LOGGER_E_SUCCESS on success, | 111 | * @return BT_PACKET_LOGGER_E_SUCCESS on success, |
| 112 | * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are | 112 | * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are |
| 113 | * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified | 113 | * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified |
| 114 | * error occurs or a syslog capture has already been started. | 114 | * error occurs or an hci capture has already been started. |
| 115 | */ | 115 | */ |
| 116 | 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); | 116 | 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); |
| 117 | 117 | ||
| 118 | /** | 118 | /** |
| 119 | * Stops capturing the syslog of the device. | 119 | * Stops capturing the hci interface from the device. |
| 120 | * | 120 | * |
| 121 | * Use bt_packet_logger_start_capture() to start receiving the syslog. | 121 | * Use bt_packet_logger_start_capture() to start receiving the hci data. |
| 122 | * | 122 | * |
| 123 | * @param client The bt_packet_logger client to use | 123 | * @param client The bt_packet_logger client to use |
| 124 | * | 124 | * |
| 125 | * @return BT_PACKET_LOGGER_E_SUCCESS on success, | 125 | * @return BT_PACKET_LOGGER_E_SUCCESS on success, |
| 126 | * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are | 126 | * BT_PACKET_LOGGER_E_INVALID_ARG when one or more parameters are |
| 127 | * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified | 127 | * invalid or BT_PACKET_LOGGER_E_UNKNOWN_ERROR when an unspecified |
| 128 | * error occurs or a syslog capture has already been started. | 128 | * error occurs or an hci capture has already been started. |
| 129 | */ | 129 | */ |
| 130 | bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client); | 130 | bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client); |
| 131 | 131 | ||
diff --git a/src/bt_packet_logger.c b/src/bt_packet_logger.c index 196039e..5f7bdeb 100644 --- a/src/bt_packet_logger.c +++ b/src/bt_packet_logger.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include "bt_packet_logger.h" | 28 | #include "bt_packet_logger.h" |
| 29 | #include "lockdown.h" | 29 | #include "lockdown.h" |
| 30 | #include "common/debug.h" | 30 | #include "common/debug.h" |
| 31 | |||
| 31 | struct bt_packet_logger_worker_thread { | 32 | struct bt_packet_logger_worker_thread { |
| 32 | bt_packet_logger_client_t client; | 33 | bt_packet_logger_client_t client; |
| 33 | bt_packet_logger_receive_cb_t cbfunc; | 34 | bt_packet_logger_receive_cb_t cbfunc; |
diff --git a/src/bt_packet_logger.h b/src/bt_packet_logger.h index f9e0c3e..7fb2427 100644 --- a/src/bt_packet_logger.h +++ b/src/bt_packet_logger.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * bt_packet_logger.h | 2 | * bt_packet_logger.h |
| 3 | * com.apple.bt_packet_logger service header file. | 3 | * com.apple.bluetooth.BTPacketLogger service header file. |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2021 Geoffrey Kruse, All Rights Reserved. | 5 | * Copyright (c) 2021 Geoffrey Kruse, All Rights Reserved. |
| 6 | * | 6 | * |
diff --git a/tools/idevicebtlogger.c b/tools/idevicebtlogger.c index 7e1c0b0..b73d958 100644 --- a/tools/idevicebtlogger.c +++ b/tools/idevicebtlogger.c | |||
| @@ -66,6 +66,9 @@ typedef enum { | |||
| 66 | RECV_ACL_DATA = 0x03 | 66 | RECV_ACL_DATA = 0x03 |
| 67 | } PacketLoggerPacketType; | 67 | } PacketLoggerPacketType; |
| 68 | 68 | ||
| 69 | /** | ||
| 70 | * Callback from the packet logger service to handle packets and log to pcap | ||
| 71 | */ | ||
| 69 | static void bt_packet_logger_callback(uint8_t * data, uint16_t len, void *user_data) | 72 | static void bt_packet_logger_callback(uint8_t * data, uint16_t len, void *user_data) |
| 70 | { | 73 | { |
| 71 | bt_packet_logger_header_t * header = (bt_packet_logger_header_t *)data; | 74 | bt_packet_logger_header_t * header = (bt_packet_logger_header_t *)data; |
| @@ -128,6 +131,9 @@ static void bt_packet_logger_callback(uint8_t * data, uint16_t len, void *user_d | |||
| 128 | } | 131 | } |
| 129 | } | 132 | } |
| 130 | 133 | ||
| 134 | /** | ||
| 135 | * Disable HCI log capture | ||
| 136 | */ | ||
| 131 | static void stop_logging(void) | 137 | static void stop_logging(void) |
| 132 | { | 138 | { |
| 133 | fflush(NULL); | 139 | fflush(NULL); |
| @@ -143,6 +149,9 @@ static void stop_logging(void) | |||
| 143 | } | 149 | } |
| 144 | } | 150 | } |
| 145 | 151 | ||
| 152 | /** | ||
| 153 | * Enable HCI log capture | ||
| 154 | */ | ||
| 146 | static int start_logging(void) | 155 | static int start_logging(void) |
| 147 | { | 156 | { |
| 148 | idevice_error_t ret = idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX); | 157 | idevice_error_t ret = idevice_new_with_options(&device, udid, (use_network) ? IDEVICE_LOOKUP_NETWORK : IDEVICE_LOOKUP_USBMUX); |
| @@ -180,6 +189,9 @@ static int start_logging(void) | |||
| 180 | return 0; | 189 | return 0; |
| 181 | } | 190 | } |
| 182 | 191 | ||
| 192 | /** | ||
| 193 | * Callback for device events | ||
| 194 | */ | ||
| 183 | static void device_event_cb(const idevice_event_t* event, void* userdata) | 195 | static void device_event_cb(const idevice_event_t* event, void* userdata) |
| 184 | { | 196 | { |
| 185 | if (use_network && event->conn_type != CONNECTION_NETWORK) { | 197 | if (use_network && event->conn_type != CONNECTION_NETWORK) { |
| @@ -218,6 +230,9 @@ static void clean_exit(int sig) | |||
| 218 | quit_flag++; | 230 | quit_flag++; |
| 219 | } | 231 | } |
| 220 | 232 | ||
| 233 | /** | ||
| 234 | * print usage information | ||
| 235 | */ | ||
| 221 | static void print_usage(int argc, char **argv, int is_error) | 236 | static void print_usage(int argc, char **argv, int is_error) |
| 222 | { | 237 | { |
| 223 | char *name = NULL; | 238 | char *name = NULL; |
| @@ -240,6 +255,9 @@ static void print_usage(int argc, char **argv, int is_error) | |||
| 240 | ); | 255 | ); |
| 241 | } | 256 | } |
| 242 | 257 | ||
| 258 | /** | ||
| 259 | * Program entry | ||
| 260 | */ | ||
| 243 | int main(int argc, char *argv[]) | 261 | int main(int argc, char *argv[]) |
| 244 | { | 262 | { |
| 245 | int c = 0; | 263 | int c = 0; |
