plugin_mac80211.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: LGPL-2.1
  2. /*
  3. * Copyright (C) 2009 Johannes Berg <[email protected]>
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include "event-parse.h"
  9. #include "trace-seq.h"
  10. #define INDENT 65
  11. static void print_string(struct trace_seq *s, struct tep_event *event,
  12. const char *name, const void *data)
  13. {
  14. struct tep_format_field *f = tep_find_field(event, name);
  15. int offset;
  16. int length;
  17. if (!f) {
  18. trace_seq_printf(s, "NOTFOUND:%s", name);
  19. return;
  20. }
  21. offset = f->offset;
  22. length = f->size;
  23. if (!strncmp(f->type, "__data_loc", 10)) {
  24. unsigned long long v;
  25. if (tep_read_number_field(f, data, &v)) {
  26. trace_seq_printf(s, "invalid_data_loc");
  27. return;
  28. }
  29. offset = v & 0xffff;
  30. length = v >> 16;
  31. }
  32. trace_seq_printf(s, "%.*s", length, (char *)data + offset);
  33. }
  34. #define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
  35. #define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
  36. #define SP() trace_seq_putc(s, ' ')
  37. static int drv_bss_info_changed(struct trace_seq *s,
  38. struct tep_record *record,
  39. struct tep_event *event, void *context)
  40. {
  41. void *data = record->data;
  42. print_string(s, event, "wiphy_name", data);
  43. trace_seq_printf(s, " vif:");
  44. print_string(s, event, "vif_name", data);
  45. tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
  46. trace_seq_printf(s, "\n%*s", INDENT, "");
  47. SF("assoc"); SP();
  48. SF("aid"); SP();
  49. SF("cts"); SP();
  50. SF("shortpre"); SP();
  51. SF("shortslot"); SP();
  52. SF("dtimper"); SP();
  53. trace_seq_printf(s, "\n%*s", INDENT, "");
  54. SF("bcnint"); SP();
  55. SFX("assoc_cap"); SP();
  56. SFX("basic_rates"); SP();
  57. SF("enable_beacon");
  58. trace_seq_printf(s, "\n%*s", INDENT, "");
  59. SF("ht_operation_mode");
  60. return 0;
  61. }
  62. int TEP_PLUGIN_LOADER(struct tep_handle *tep)
  63. {
  64. tep_register_event_handler(tep, -1, "mac80211",
  65. "drv_bss_info_changed",
  66. drv_bss_info_changed, NULL);
  67. return 0;
  68. }
  69. void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
  70. {
  71. tep_unregister_event_handler(tep, -1, "mac80211",
  72. "drv_bss_info_changed",
  73. drv_bss_info_changed, NULL);
  74. }