summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/libimobiledevice/bt_packet_logger.h16
-rw-r--r--src/bt_packet_logger.c1
-rw-r--r--src/bt_packet_logger.h2
-rw-r--r--tools/idevicebtlogger.c18
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 {
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 character received from the device. */
+/** 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 */
@@ -100,32 +100,32 @@ bt_packet_logger_error_t bt_packet_logger_client_free(bt_packet_logger_client_t
/**
- * Starts capturing the syslog of the device using a callback.
+ * Starts capturing the hci interface from the device using a callback.
*
- * Use bt_packet_logger_stop_capture() to stop receiving the syslog.
+ * 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 character from the syslog.
+ * @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 a syslog capture has already been started.
+ * error occurs or an hci capture has already been started.
*/
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 syslog of the device.
+ * Stops capturing the hci interface from the device.
*
- * Use bt_packet_logger_start_capture() to start receiving the syslog.
+ * 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 a syslog capture has already been started.
+ * error occurs or an hci capture has already been started.
*/
bt_packet_logger_error_t bt_packet_logger_stop_capture(bt_packet_logger_client_t client);
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 @@
#include "bt_packet_logger.h"
#include "lockdown.h"
#include "common/debug.h"
+
struct bt_packet_logger_worker_thread {
bt_packet_logger_client_t client;
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 @@
/*
* bt_packet_logger.h
- * com.apple.bt_packet_logger service header file.
+ * com.apple.bluetooth.BTPacketLogger service header file.
*
* Copyright (c) 2021 Geoffrey Kruse, All Rights Reserved.
*
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 {
RECV_ACL_DATA = 0x03
} PacketLoggerPacketType;
+/**
+ * Callback from the packet logger service to handle packets and log to pcap
+ */
static void bt_packet_logger_callback(uint8_t * data, uint16_t len, void *user_data)
{
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
}
}
+/**
+ * Disable HCI log capture
+ */
static void stop_logging(void)
{
fflush(NULL);
@@ -143,6 +149,9 @@ static void stop_logging(void)
}
}
+/**
+ * Enable HCI log capture
+ */
static int start_logging(void)
{
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)
return 0;
}
+/**
+ * Callback for device events
+ */
static void device_event_cb(const idevice_event_t* event, void* userdata)
{
if (use_network && event->conn_type != CONNECTION_NETWORK) {
@@ -218,6 +230,9 @@ static void clean_exit(int sig)
quit_flag++;
}
+/**
+ * print usage information
+ */
static void print_usage(int argc, char **argv, int is_error)
{
char *name = NULL;
@@ -240,6 +255,9 @@ static void print_usage(int argc, char **argv, int is_error)
);
}
+/**
+ * Program entry
+ */
int main(int argc, char *argv[])
{
int c = 0;