bpa.c 929 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2004-2011 Marcel Holtmann <marcel@holtmann.org>
  7. *
  8. *
  9. */
  10. #ifdef HAVE_CONFIG_H
  11. #include <config.h>
  12. #endif
  13. #define _GNU_SOURCE
  14. #include <stdio.h>
  15. #include <errno.h>
  16. #include <unistd.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include "parser.h"
  20. #define BPA_U8(frm) (p_get_u8(frm))
  21. #define BPA_U16(frm) (btohs(htons(p_get_u16(frm))))
  22. #define BPA_U32(frm) (btohl(htonl(p_get_u32(frm))))
  23. void bpa_dump(int level, struct frame *frm)
  24. {
  25. uint8_t id, status, channel;
  26. uint16_t num, len;
  27. uint32_t time;
  28. id = p_get_u8(frm);
  29. num = p_get_u16(frm);
  30. len = BPA_U16(frm);
  31. status = p_get_u8(frm);
  32. time = p_get_u32(frm);
  33. channel = p_get_u8(frm);
  34. p_indent(level, frm);
  35. printf("BPA: id %d num %d len %u status 0x%02x time %d channel %d\n",
  36. id, num, len, status, time, channel);
  37. raw_dump(level, frm);
  38. }