Index: opensync-2.0.5.0/interfaces/opensync_stats.proto =================================================================== --- opensync-2.0.5.0.orig/interfaces/opensync_stats.proto +++ opensync-2.0.5.0/interfaces/opensync_stats.proto @@ -678,6 +678,12 @@ message VideoVoiceReport { optional uint64 timestamp_ms = 7; } + +enum ChannelSwitchReason { + radar_detected = 0; + high_interference = 1; + } + message EventReport { /* Client Association Event */ message ClientAssocEvent { @@ -791,6 +797,14 @@ message EventReport { optional uint32 timestamp_ms = 6; } + /* Channel Switch Event */ + message ChannelSwitchEvent { + required RadioBandType band = 1; + required ChannelSwitchReason reason = 2; + required uint32 channel = 3; + optional uint64 timestamp_ms = 4; + } + /* Client Session */ message ClientSession { required uint64 session_id = 1; @@ -877,6 +891,10 @@ message EventReport { /* Multiple Client Sessions */ repeated ClientSession client_session = 1; + + /* Multiple Channel Switch events */ + repeated ChannelSwitchEvent channel_switch = 2; + /* Multiple DHCP Transactions */ repeated DhcpTransaction dhcp_transaction = 3; } Index: opensync-2.0.5.0/src/lib/datapipeline/src/dppline.c =================================================================== --- opensync-2.0.5.0.orig/src/lib/datapipeline/src/dppline.c +++ opensync-2.0.5.0/src/lib/datapipeline/src/dppline.c @@ -165,6 +165,9 @@ typedef struct dpp_ucc_stats { typedef struct dpp_events_stats { dpp_event_record_session_t *client_event_list; uint32_t client_event_qty; + + dpp_event_record_channel_switch_t *channel_event_list; + uint32_t channel_event_qty; } dppline_events_stats_t; /* DPP stats type, used as element in internal double ds */ @@ -274,7 +277,12 @@ static void dppline_free_stat(dppline_st if(s->u.events.client_event_list[i].timeout_event) free(s->u.events.client_event_list[i].timeout_event); } + + if(s->u.events.client_event_list) free(s->u.events.client_event_list); + + if(s->u.events.channel_event_list) + free(s->u.events.channel_event_list); break; default:; @@ -655,6 +663,23 @@ static bool dppline_copysts(dppline_stat count++; } + dpp_event_channel_switch_t *channel_result = NULL; + dst->u.events.channel_event_qty = 0; + count = 0; + ds_dlist_foreach(&report_data->channel_switch_list, channel_result) + { + dst->u.events.channel_event_qty++; + } + + size = dst->u.events.channel_event_qty * sizeof(dpp_event_record_channel_switch_t); + dst->u.events.channel_event_list = calloc(1, size); + ds_dlist_foreach(&report_data->channel_switch_list, channel_result) + { + assert(count < (int)dst->u.events.channel_event_qty); + memcpy(&dst->u.events.channel_event_list[count], &channel_result->channel_event, + sizeof(dpp_event_record_channel_switch_t)); + count++; + } } break; @@ -1859,6 +1884,7 @@ static void dppline_add_stat_events(Sts_ Sts__EventReport *sr = NULL; uint32_t session = 0; + uint32_t channel_switch_count = 0; dppline_events_stats_t *events = &s->u.events; // increase the number of event_report @@ -1881,6 +1907,26 @@ static void dppline_add_stat_events(Sts_ assert(sr->client_session); sr->n_client_session = events->client_event_qty; + sr->channel_switch = malloc(events->channel_event_qty * sizeof(*sr->channel_switch)); + assert(sr->channel_switch); + sr->n_channel_switch = events->channel_event_qty; + + for (channel_switch_count = 0; channel_switch_count < events->channel_event_qty; channel_switch_count++) { + + dpp_event_record_channel_switch_t *channel_switch_rec = &events->channel_event_list[channel_switch_count]; + + Sts__EventReport__ChannelSwitchEvent *channel_switch = NULL; + channel_switch = sr->channel_switch[channel_switch_count] = malloc(sizeof(**sr->channel_switch)); + assert(channel_switch); + sts__event_report__channel_switch_event__init(channel_switch); + + channel_switch->band = channel_switch_rec->band; + channel_switch->reason = channel_switch_rec->reason; + channel_switch->channel = channel_switch_rec->freq; + channel_switch->timestamp_ms = channel_switch_rec->timestamp; + channel_switch->has_timestamp_ms = true; + } + for (session = 0; session < events->client_event_qty; session++) { dpp_event_record_session_t *cs_rec = &events->client_event_list[session];