From 92a1173577e7ae4b332bd38a908e97e2dd9fc73c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 30 Aug 2016 04:43:27 +0200 Subject: [PATCH] monitor: Add support for RAW Open and RAW Close control messages --- monitor/packet.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/monitor/packet.c b/monitor/packet.c index 224d45086..6412af443 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -108,6 +108,7 @@ static uint16_t index_current = 0; #define UNKNOWN_MANUFACTURER 0xffff +#define CTRL_RAW 0x0000 #define CTRL_MGMT 0x0001 #define MAX_CTRL 64 @@ -9173,13 +9174,14 @@ void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index, sprintf(channel, "0x%4.4x", cookie); - if (format == CTRL_MGMT && size >= 8) { + if ((format == CTRL_RAW || format == CTRL_MGMT) && size >= 8) { uint8_t version; uint16_t revision; uint32_t flags; uint8_t ident_len; const char *comm; char details[48]; + const char *title; version = get_u8(data); revision = get_le16(data + 1); @@ -9200,8 +9202,13 @@ void packet_ctrl_open(struct timeval *tv, struct ucred *cred, uint16_t index, flags & 0x0001 ? "(privileged) " : "", version, revision); + if (format == CTRL_RAW) + title = "RAW Open"; + else + title = "MGMT Open"; + print_packet(tv, cred, '@', index, channel, COLOR_CTRL_OPEN, - "MGMT Open", comm, details); + title, comm, details); } else { char label[7]; @@ -9222,6 +9229,7 @@ void packet_ctrl_close(struct timeval *tv, struct ucred *cred, uint16_t index, uint32_t cookie; uint16_t format; char channel[11], label[22]; + const char *title; if (size < 4) { print_packet(tv, cred, '*', index, NULL, COLOR_ERROR, @@ -9239,16 +9247,22 @@ void packet_ctrl_close(struct timeval *tv, struct ucred *cred, uint16_t index, release_ctrl(cookie, &format, label); - if (format == CTRL_MGMT) { - print_packet(tv, cred, '@', index, channel, COLOR_CTRL_CLOSE, - "MGMT Close", label, NULL); - } else { + switch (format) { + case CTRL_RAW: + title = "RAW Close"; + break; + case CTRL_MGMT: + title = "MGMT Close"; + break; + default: sprintf(label, "0x%4.4x", format); - - print_packet(tv, cred, '@', index, channel, COLOR_CTRL_CLOSE, - "Control Close", label, NULL); + title = "Control Close"; + break; } + print_packet(tv, cred, '@', index, channel, COLOR_CTRL_CLOSE, + title, label, NULL); + packet_hexdump(data, size); } -- 2.47.3