summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-03-02 02:52:39 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2012-03-02 03:17:50 +0200
commit5ee47d3540850709b3c0af136384398ab8bb356d (patch)
tree4ad0fce1bcce9b48a7d8b02e08db93db71b17e40 /lib
parent970e3100d073fd3ba42282ca18394c4133c0b0a9 (diff)
downloadbluez-5ee47d3540850709b3c0af136384398ab8bb356d.tar.gz
mgmt: Move string helpers to lib/mgmt.c
Diffstat (limited to 'lib')
-rw-r--r--lib/mgmt.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/lib/mgmt.h b/lib/mgmt.h
index 9a0ed221f..c1afe812c 100644
--- a/lib/mgmt.h
+++ b/lib/mgmt.h
@@ -431,3 +431,116 @@ struct mgmt_ev_device_unblocked {
struct mgmt_ev_device_unpaired {
struct mgmt_addr_info addr;
} __packed;
+
+static const char *mgmt_op[] = {
+ "<0x0000>",
+ "Read Version",
+ "Read Commands",
+ "Read Index List",
+ "Read Controller Info",
+ "Set Powered",
+ "Set Discoverable",
+ "Set Connectable",
+ "Set Fast Connectable", /* 0x0008 */
+ "Set Pairable",
+ "Set Link Security",
+ "Set Secure Simple Pairing",
+ "Set High Speed",
+ "Set Low Energy",
+ "Set Dev Class",
+ "Set Local Name",
+ "Add UUID", /* 0x0010 */
+ "Remove UUID",
+ "Load Link Keys",
+ "Load Long Term Keys",
+ "Disconnect",
+ "Get Connections",
+ "PIN Code Reply",
+ "PIN Code Neg Reply",
+ "Set IO Capability", /* 0x0018 */
+ "Pair Device",
+ "Cancel Pair Device",
+ "Unpair Device",
+ "User Confirm Reply",
+ "User Confirm Neg Reply",
+ "User Passkey Reply",
+ "User Passkey Neg Reply",
+ "Read Local OOB Data", /* 0x0020 */
+ "Add Remote OOB Data",
+ "Remove Remove OOB Data",
+ "Start Discovery",
+ "Stop Discovery",
+ "Confirm Name",
+ "Block Device",
+ "Unblock Device",
+};
+
+static const char *mgmt_ev[] = {
+ "<0x0000>",
+ "Command Complete",
+ "Command Status",
+ "Controller Error",
+ "Index Added",
+ "Index Removed",
+ "New Settings",
+ "Class of Device Changed",
+ "Local Name Changed", /* 0x0008 */
+ "New Link Key",
+ "New Long Term Key",
+ "Device Connected",
+ "Device Disconnected",
+ "Connect Failed",
+ "PIN Code Request",
+ "User Confirm Request",
+ "User Passkey Request", /* 0x0010 */
+ "Authentication Failed",
+ "Device Found",
+ "Discovering",
+ "Device Blocked",
+ "Device Unblocked",
+ "Device Unpaired",
+};
+
+static const char *mgmt_status[] = {
+ "Success",
+ "Unknown Command",
+ "Not Connected",
+ "Failed",
+ "Connect Failed",
+ "Authentication Failed",
+ "Not Paired",
+ "No Resources",
+ "Timeout",
+ "Already Connected",
+ "Busy",
+ "Rejected",
+ "Not Supported",
+ "Invalid Parameters",
+ "Disconnected",
+ "Not Powered",
+};
+
+#ifndef NELEM
+#define NELEM(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+static inline const char *mgmt_opstr(uint16_t op)
+{
+ if (op >= NELEM(mgmt_op))
+ return "<unknown opcode>";
+ return mgmt_op[op];
+}
+
+static inline const char *mgmt_evstr(uint16_t ev)
+{
+ if (ev >= NELEM(mgmt_ev))
+ return "<unknown event>";
+ return mgmt_ev[ev];
+}
+
+static inline const char *mgmt_errstr(uint8_t status)
+{
+ if (status >= NELEM(mgmt_status))
+ return "<unknown status>";
+ return mgmt_status[status];
+}