1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24#include "event-parse.h"
25#include "trace-seq.h"
26
27#define INDENT 65
28
29static void print_string(struct trace_seq *s, struct tep_event *event,
30 const char *name, const void *data)
31{
32 struct tep_format_field *f = tep_find_field(event, name);
33 int offset;
34 int length;
35
36 if (!f) {
37 trace_seq_printf(s, "NOTFOUND:%s", name);
38 return;
39 }
40
41 offset = f->offset;
42 length = f->size;
43
44 if (!strncmp(f->type, "__data_loc", 10)) {
45 unsigned long long v;
46 if (tep_read_number_field(f, data, &v)) {
47 trace_seq_printf(s, "invalid_data_loc");
48 return;
49 }
50 offset = v & 0xffff;
51 length = v >> 16;
52 }
53
54 trace_seq_printf(s, "%.*s", length, (char *)data + offset);
55}
56
57#define SF(fn) tep_print_num_field(s, fn ":%d", event, fn, record, 0)
58#define SFX(fn) tep_print_num_field(s, fn ":%#x", event, fn, record, 0)
59#define SP() trace_seq_putc(s, ' ')
60
61static int drv_bss_info_changed(struct trace_seq *s,
62 struct tep_record *record,
63 struct tep_event *event, void *context)
64{
65 void *data = record->data;
66
67 print_string(s, event, "wiphy_name", data);
68 trace_seq_printf(s, " vif:");
69 print_string(s, event, "vif_name", data);
70 tep_print_num_field(s, "(%d)", event, "vif_type", record, 1);
71
72 trace_seq_printf(s, "\n%*s", INDENT, "");
73 SF("assoc"); SP();
74 SF("aid"); SP();
75 SF("cts"); SP();
76 SF("shortpre"); SP();
77 SF("shortslot"); SP();
78 SF("dtimper"); SP();
79 trace_seq_printf(s, "\n%*s", INDENT, "");
80 SF("bcnint"); SP();
81 SFX("assoc_cap"); SP();
82 SFX("basic_rates"); SP();
83 SF("enable_beacon");
84 trace_seq_printf(s, "\n%*s", INDENT, "");
85 SF("ht_operation_mode");
86
87 return 0;
88}
89
90int TEP_PLUGIN_LOADER(struct tep_handle *tep)
91{
92 tep_register_event_handler(tep, -1, "mac80211",
93 "drv_bss_info_changed",
94 drv_bss_info_changed, NULL);
95 return 0;
96}
97
98void TEP_PLUGIN_UNLOADER(struct tep_handle *tep)
99{
100 tep_unregister_event_handler(tep, -1, "mac80211",
101 "drv_bss_info_changed",
102 drv_bss_info_changed, NULL);
103}
104