plugin_mac80211.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright (C) 2009 Johannes Berg <johannes@sipsolutions.net>
  3. *
  4. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation;
  8. * version 2.1 of the License (not later!)
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this program; if not, see <http://www.gnu.org/licenses>
  17. *
  18. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include "event-parse.h"
  24. #include "trace-seq.h"
  25. #define INDENT 65
  26. static void print_string(struct trace_seq *s, struct tep_event_format *event,
  27. const char *name, const void *data)
  28. {
  29. struct tep_format_field *f = tep_find_field(event, name);
  30. int offset;
  31. int length;
  32. if (!f) {
  33. trace_seq_printf(s, "NOTFOUND:%s", name);
  34. return;
  35. }
  36. offset = f->offset;
  37. length = f->size;
  38. if (!strncmp(f->type, "__data_loc", 10)) {
  39. unsigned long long v;
  40. if (tep_read_number_field(f, data, &v)) {
  41. trace_seq_printf(s, "invalid_data_loc");
  42. return;
  43. }
  44. offset = v & 0xffff;
  45. length = v >> 16;
  46. }
  47. trace_seq_printf(s, "%.*s", length, (char *)data + offset);
  48. }
  49. #define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
  50. #define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
  51. #define SP() trace_seq_putc(s, ' ')
  52. static int drv_bss_info_changed(struct trace_seq *s,
  53. struct tep_record *record,
  54. struct tep_event_format *event, void *context)
  55. {
  56. void *data = record->data;
  57. print_string(s, event, "wiphy_name", data);
  58. trace_seq_printf(s, " vif:");
  59. print_string(s, event, "vif_name", data);
  60. tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
  61. trace_seq_printf(s, "\n%*s", INDENT, "");
  62. SF("assoc"); SP();
  63. SF("aid"); SP();
  64. SF("cts"); SP();
  65. SF("shortpre"); SP();
  66. SF("shortslot"); SP();
  67. SF("dtimper"); SP();
  68. trace_seq_printf(s, "\n%*s", INDENT, "");
  69. SF("bcnint"); SP();
  70. SFX("assoc_cap"); SP();
  71. SFX("basic_rates"); SP();
  72. SF("enable_beacon");
  73. trace_seq_printf(s, "\n%*s", INDENT, "");
  74. SF("ht_operation_mode");
  75. return 0;
  76. }
  77. int TEP_PLUGIN_LOADER(struct tep_handle *pevent)
  78. {
  79. tep_register_event_handler(pevent, -1, "mac80211",
  80. "drv_bss_info_changed",
  81. drv_bss_info_changed, NULL);
  82. return 0;
  83. }
  84. void TEP_PLUGIN_UNLOADER(struct tep_handle *pevent)
  85. {
  86. tep_unregister_event_handler(pevent, -1, "mac80211",
  87. "drv_bss_info_changed",
  88. drv_bss_info_changed, NULL);
  89. }