a4073bb9fd35e8905da7f242b28eecab17516452
[openwrt/staging/blocktrron.git] /
1 From d3201adfe7d2219217a07ef16ef365ad59c1a89b Mon Sep 17 00:00:00 2001
2 From: Peter Oh <peter.oh@bowerswilkins.com>
3 Date: Tue, 29 May 2018 14:39:21 -0700
4 Subject: [PATCH 17/18] mesh: use right interface context to send DFS event
5 messages
6
7 use mesh interface context to send DFS event messages when
8 DFS events are on mesh interface.
9
10 Signed-off-by: Peter Oh <peter.oh@bowerswilkins.com>
11 Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
12 ---
13 src/ap/dfs.c | 27 +++++++++++++++++++--------
14 1 file changed, 19 insertions(+), 8 deletions(-)
15
16 --- a/src/ap/dfs.c
17 +++ b/src/ap/dfs.c
18 @@ -637,6 +637,17 @@ static unsigned int dfs_get_cac_time(str
19 }
20
21
22 +static void *get_message_ctx(struct hostapd_iface *iface)
23 +{
24 +#ifdef CONFIG_MESH
25 + if (iface->mconf)
26 + return iface->owner;
27 +#endif /* CONFIG_MESH */
28 +
29 + return iface->bss[0]->msg_ctx;
30 +}
31 +
32 +
33 /*
34 * Main DFS handler
35 * 1 - continue channel/ap setup
36 @@ -719,7 +730,7 @@ int hostapd_handle_dfs(struct hostapd_if
37 /* Finally start CAC */
38 hostapd_set_state(iface, HAPD_IFACE_DFS);
39 wpa_printf(MSG_DEBUG, "DFS start CAC on %d MHz", iface->freq);
40 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
41 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_START
42 "freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds",
43 iface->freq,
44 iface->conf->channel, iface->conf->secondary_channel,
45 @@ -768,7 +779,7 @@ int hostapd_dfs_complete_cac(struct host
46 int ht_enabled, int chan_offset, int chan_width,
47 int cf1, int cf2)
48 {
49 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_COMPLETED
50 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_COMPLETED
51 "success=%d freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
52 success, freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
53
54 @@ -810,7 +821,7 @@ int hostapd_dfs_pre_cac_expired(struct h
55 int ht_enabled, int chan_offset, int chan_width,
56 int cf1, int cf2)
57 {
58 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_PRE_CAC_EXPIRED
59 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_PRE_CAC_EXPIRED
60 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
61 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
62
63 @@ -848,7 +859,7 @@ static int hostapd_dfs_start_channel_swi
64
65 wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d",
66 channel->chan);
67 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
68 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NEW_CHANNEL
69 "freq=%d chan=%d sec_chan=%d", channel->freq,
70 channel->chan, secondary_channel);
71
72 @@ -935,7 +946,7 @@ static int hostapd_dfs_start_channel_swi
73
74 wpa_printf(MSG_DEBUG, "DFS will switch to a new channel %d",
75 channel->chan);
76 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NEW_CHANNEL
77 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NEW_CHANNEL
78 "freq=%d chan=%d sec_chan=%d", channel->freq,
79 channel->chan, secondary_channel);
80
81 @@ -997,7 +1008,7 @@ int hostapd_dfs_radar_detected(struct ho
82 {
83 int res;
84
85 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_RADAR_DETECTED
86 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_RADAR_DETECTED
87 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
88 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
89
90 @@ -1028,7 +1039,7 @@ int hostapd_dfs_nop_finished(struct host
91 int ht_enabled, int chan_offset, int chan_width,
92 int cf1, int cf2)
93 {
94 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_NOP_FINISHED
95 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_NOP_FINISHED
96 "freq=%d ht_enabled=%d chan_offset=%d chan_width=%d cf1=%d cf2=%d",
97 freq, ht_enabled, chan_offset, chan_width, cf1, cf2);
98
99 @@ -1078,7 +1089,7 @@ int hostapd_dfs_start_cac(struct hostapd
100 int ht_enabled, int chan_offset, int chan_width,
101 int cf1, int cf2)
102 {
103 - wpa_msg(iface->bss[0]->msg_ctx, MSG_INFO, DFS_EVENT_CAC_START
104 + wpa_msg(get_message_ctx(iface), MSG_INFO, DFS_EVENT_CAC_START
105 "freq=%d chan=%d chan_offset=%d width=%d seg0=%d "
106 "seg1=%d cac_time=%ds",
107 freq, (freq - 5000) / 5, chan_offset, chan_width, cf1, cf2, 60);