From 8dab9b0bcab616bde55a3a137bd6fb8818ced4a5 Mon Sep 17 00:00:00 2001 From: Max Krasnyansky Date: Thu, 11 Apr 2002 16:56:10 +0000 Subject: Added LMP features to sting translation function and table. --- src/hci.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/hci.c b/src/hci.c index a3ffe28b..af494c15 100644 --- a/src/hci.c +++ b/src/hci.c @@ -53,7 +53,7 @@ typedef struct { static char *hci_bit2str(hci_map *m, unsigned int val) { - char *str = malloc(50); + char *str = malloc(120); char *ptr = str; if (!str) @@ -287,6 +287,71 @@ int lmp_strtover(char *str, unsigned int *ver) return hci_str2uint(ver_map, str, ver); } +/* LMP features mapping */ +hci_map lmp_features_map[][9] = { + { /* byte 0 */ + { "<3-slot packets>", LMP_3SLOT }, + { "<5-slot packets>", LMP_5SLOT }, + { "", LMP_ENCRYPT }, + { "", LMP_SOFFSET }, + { "", LMP_TACCURACY}, + { "", LMP_RSWITCH }, + { "", LMP_HOLD }, + { "", LMP_SNIFF }, + { NULL } + }, + { /* byte 1 */ + { "", LMP_PARK }, + { "", LMP_RSSI }, + { "", LMP_QUALITY }, + { "", LMP_SCO }, + { "", LMP_HV2 }, + { "", LMP_HV3 }, + { "", LMP_ULAW }, + { "", LMP_ALAW }, + { NULL } + }, + { /* byte 2 */ + { "", LMP_CVSD }, + { "", LMP_PSCHEME }, + { "", LMP_PCONTROL }, + { "", LMP_TRSP_SCO }, + { NULL } + }, + {{ NULL }} +}; + +char *lmp_featurestostr(uint8_t *features, char *pref, int width) +{ + char *ptr, *str = malloc(400); + int i, w; + + if (!str) + return NULL; + + ptr = str; *ptr = 0; + + if (pref) + ptr += sprintf(ptr, "%s", pref); + + for(i=0, w=0; lmp_features_map[i][0].str; i++) { + hci_map *m; + + m = lmp_features_map[i]; + while (m->str) { + if ((unsigned int) m->val & (unsigned int) features[i]) + ptr += sprintf(ptr, "%s ", m->str); + m++; + + w = (w + 1) & width; + if (!w) + ptr += sprintf(ptr, "\n%s", pref); + } + } + + return str; +} + /* HCI functions that do not require open device */ int hci_devinfo(int dev_id, struct hci_dev_info *di) -- cgit