WiFi: update parameters with new ubus objects

This commit is contained in:
Amin Ben Ramdhane 2020-03-18 22:47:41 +01:00
parent a1ceee7441
commit e3777371b1
6 changed files with 267 additions and 237 deletions

View file

@ -223,107 +223,45 @@ int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmc
return ssid_read_ubus(data, "rx_unknown_packets", value); return ssid_read_ubus(data, "rx_unknown_packets", value);
} }
static char *get_associative_device_statistics(struct wifi_associative_device_args *wifi_associative_device, char *key) /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.BytesSent!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.tx_total_bytes*/
{
json_object *res, *jobj;
char *macaddr, *stats = "0";
int entries = 0;
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", wifi_associative_device->wdev, String}}, 1, &res);
while (res) {
jobj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations");
if(jobj) {
macaddr = dmjson_get_value(jobj, 1, "macaddr");
if (!strcmp(macaddr, wifi_associative_device->macaddress)) {
stats = dmjson_get_value(jobj, 2, "stats", key);
if(*stats != '\0')
return stats;
}
entries++;
} else
break;
}
return stats;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_bytes*/
int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "tx_total_bytes");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_total_bytes");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_bytes*/ /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.BytesReceived!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.rx_data_bytes*/
int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "rx_data_bytes");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "rx_data_bytes");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_pkts*/ /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.PacketsSent!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.tx_total_pkts*/
int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "tx_total_pkts");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_total_pkts");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_pkts*/ /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.PacketsReceived!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.rx_data_pkts*/
int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "rx_data_pkts");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "rx_data_pkts");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.ErrorsSent!UBUS:wifix/stations/vif,@Name/stats.tx_failures*/ /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.ErrorsSent!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.tx_failures*/
int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "tx_failures");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_failures");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.RetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/ /*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats.RetransCount!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "tx_pkts_retries");
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retries");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.FailedRetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retry_exhausted*/
int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retry_exhausted");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.RetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_pkts_retries");
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Stats.MultipleRetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_data_pkts_retried*/
int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr = (struct wifi_associative_device_args*)data;
*value = get_associative_device_statistics(cur_wifi_associative_device_args_ptr, "tx_data_pkts_retried");
return 0; return 0;
} }
@ -503,14 +441,16 @@ int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *dat
int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
json_object *res = NULL, *supp_channels = NULL; json_object *res = NULL, *supp_channels = NULL;
char object[32]; char object[32], *bandwidth = NULL;
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec)); snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res); dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = ""); DM_ASSERT(res, *value = "");
supp_channels = dmjson_select_obj_in_array_idx(res, 0, 1, "supp_channels"); supp_channels = dmjson_select_obj_in_array_idx(res, 0, 1, "supp_channels");
if (supp_channels) if (supp_channels)
*value = dmjson_get_value(supp_channels, 1, "bandwidth"); bandwidth = dmjson_get_value(supp_channels, 1, "bandwidth");
if (bandwidth)
dmasprintf(value, "%sMHz", bandwidth);
return 0; return 0;
} }
@ -518,12 +458,14 @@ int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct
int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
json_object *res; json_object *res;
char object[32]; char object[32], *bandwidth = NULL;
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec)); snprintf(object, sizeof(object), "wifi.radio.%s", section_name(((struct wifi_radio_args *)data)->wifi_radio_sec));
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res); dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
DM_ASSERT(res, *value = ""); DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "bandwidth"); bandwidth = dmjson_get_value(res, 1, "bandwidth");
if (bandwidth)
dmasprintf(value, "%sMHz", bandwidth);
return 0; return 0;
} }
@ -569,85 +511,35 @@ int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *da
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
json_object *res, *jobj; json_object *res = NULL, *assoclist = NULL, *arrobj = NULL;
int entries = 0; char object[32];
int i = 0, entries = 0;
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", ((struct wifi_ssid_args *)data)->ifname, String}}, 1, &res); snprintf(object, sizeof(object), "wifi.ap.%s", ((struct wifi_acp_args *)data)->ifname);
DM_ASSERT(res, *value = "0"); dmubus_call(object, "assoclist", UBUS_ARGS{}, 0, &res);
while (1) { if (res) {
jobj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations"); dmjson_foreach_obj_in_array(res, arrobj, assoclist, i, 1, "assoclist") {
if (jobj == NULL) entries++;
break; }
entries++;
} }
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN dmasprintf(value, "%d", entries);
return 0; return 0;
} }
int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance) int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{ {
json_object *res, *associated_client_obj; json_object *res = NULL, *stations = NULL, *arrobj = NULL;
struct uci_section *ss = NULL; char object[32], *idx, *idx_last = NULL;
char *value, *ap_ifname, *idx, *idx_last = NULL; int id = 0, i = 0;
int id = 0, entries = 0;
char *macaddr = NULL, *lastdatadownloadlinkrate = NULL, *lastdatauplinkrate = NULL, *signalstrength = NULL, *noise = NULL, *retrans = NULL, *assoctimestr = NULL;
struct wifi_associative_device_args cur_wifi_associative_device_args = {0};
struct uci_section *dmmap_section;
uci_foreach_sections("wireless", "wifi-iface", ss) { snprintf(object, sizeof(object), "wifi.ap.%s", ((struct wifi_acp_args *)prev_data)->ifname);
get_dmmap_section_of_config_section("dmmap_wireless", "wifi-iface", section_name(ss), &dmmap_section); dmubus_call(object, "stations", UBUS_ARGS{}, 0, &res);
dmuci_get_value_by_section_string(dmmap_section, "accesspointinstance", &value); if (res) {
if(!strcmp(value, prev_instance)){ dmjson_foreach_obj_in_array(res, arrobj, stations, i, 1, "stations") {
dmuci_get_value_by_section_string(ss, "ifname", &ap_ifname);
break;
}
}
dmubus_call("wifix", "stations", UBUS_ARGS{{"vif", ap_ifname, String}}, 1, &res);
while (res) {
associated_client_obj = dmjson_select_obj_in_array_idx(res, entries, 1, "stations");
if(associated_client_obj) {
cur_wifi_associative_device_args.wdev = ap_ifname;
macaddr = dmjson_get_value(associated_client_obj, 1, "macaddr");
if(macaddr!=NULL && strlen(macaddr)>0)
dmasprintf(&(cur_wifi_associative_device_args.macaddress),dmjson_get_value(associated_client_obj, 1, "macaddr"));
cur_wifi_associative_device_args.active = 1;
lastdatadownloadlinkrate = dmjson_get_value(associated_client_obj, 2, "stats", "rate_of_last_rx_pkt");
if(lastdatadownloadlinkrate!=NULL && strlen(lastdatadownloadlinkrate)>0)
cur_wifi_associative_device_args.lastdatadownloadlinkrate = atoi(lastdatadownloadlinkrate);
else
cur_wifi_associative_device_args.lastdatadownloadlinkrate = 0;
lastdatauplinkrate = dmjson_get_value(associated_client_obj, 2, "stats", "rate_of_last_tx_pkt");
if(lastdatauplinkrate!=NULL && strlen(lastdatauplinkrate)>0)
cur_wifi_associative_device_args.lastdatauplinkrate = atoi(lastdatauplinkrate);
else
cur_wifi_associative_device_args.lastdatauplinkrate = 0;
signalstrength=dmjson_get_value(associated_client_obj, 1, "rssi");
if(signalstrength!=NULL && strlen(signalstrength)>0)
cur_wifi_associative_device_args.signalstrength = atoi(signalstrength);
else
cur_wifi_associative_device_args.signalstrength = 0;
noise=dmjson_get_value(associated_client_obj, 1, "snr");
if(noise!=NULL && strlen(noise)>0)
cur_wifi_associative_device_args.noise = atoi(noise);
else
cur_wifi_associative_device_args.noise = 0;
retrans= dmjson_get_value(associated_client_obj, 2, "stats", "tx_pkts_retries");
cur_wifi_associative_device_args.retransmissions= atoi(retrans);
assoctimestr=dmjson_get_value(associated_client_obj, 1, "in_network");
if(assoctimestr!=NULL && strlen(assoctimestr)>0)
cur_wifi_associative_device_args.assoctime = atoi(assoctimestr);
else
cur_wifi_associative_device_args.assoctime = 0;
entries++;
idx = handle_update_instance(3, dmctx, &idx_last, update_instance_without_section, 1, ++id); idx = handle_update_instance(3, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&cur_wifi_associative_device_args, idx) == DM_STOP) if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)stations, idx) == DM_STOP)
break; return 0;
} }
else
break;
} }
return 0; return 0;
} }

View file

@ -192,73 +192,61 @@ int os__get_WiFiSSIDStats_UnknownProtoPacketsReceived(char *refparam, struct dmc
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_bytes*/
int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.BytesReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_bytes*/
int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsSent!UBUS:wifix/stations/vif,@Name/stats.tx_total_pkts*/
int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.PacketsReceived!UBUS:wifix/stations/vif,@Name/stats.rx_data_pkts*/
int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.ErrorsSent!UBUS:wifix/stations/vif,@Name/stats.tx_failures*/
int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_tx_errors(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.RetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.FailedRetransCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retry_exhausted*/
int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_failed_retrans_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.RetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_pkts_retries*/
int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.AccessPoint.{i}.Stats.MultipleRetryCount!UBUS:wifix/stations/vif,@Name/stats.tx_data_pkts_retried*/
int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_access_point_associative_device_statistics_multiple_retry_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.MaxBitRate!UBUS:wifi.radio.@Name/status//maxrate*/
int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.OperatingFrequencyBand!UBUS:wifi.radio.@Name/status//band*/
int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.ChannelsInUse!UCI:wireless/wifi-device,@i-1/channel*/
int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
@ -314,19 +302,16 @@ int os__get_neighboring_wifi_diagnostics_result_noise(char *refparam, struct dmc
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.PossibleChannels!UBUS:wifi.radio.@Name/status//supp_channels[0].channels*/
int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.SupportedOperatingChannelBandwidths!UBUS:wifi.radio.@Name/status//supp_channels[0].bandwidth*/
int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
} }
/*#Device.WiFi.Radio.{i}.CurrentOperatingChannelBandwidth!UBUS:wifi.radio.@Name/status//bandwidth*/
int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_WiFiRadio_CurrentOperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);
@ -341,7 +326,6 @@ int os__browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DMNOD
return 0; return 0;
} }
/*#Device.WiFi.Radio.{i}.SupportedStandards!UBUS:wifi/status//radio[i-1].standard*/
int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
return not_implemented(value); return not_implemented(value);

View file

@ -41,8 +41,8 @@ static int get_linker_Wifi_Ssid(char *refparam, struct dmctx *dmctx, void *data,
static int get_linker_associated_device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) static int get_linker_associated_device(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker)
{ {
if (data && ((struct wifi_associative_device_args*)data)->macaddress) { if (data) {
*linker = ((struct wifi_associative_device_args*)data)->macaddress; *linker = dmjson_get_value((json_object *)data, 1, "macaddr");
return 0; return 0;
} }
*linker = ""; *linker = "";
@ -358,6 +358,8 @@ static int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, ch
static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "hwmode", value); dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "hwmode", value);
if (strcmp(*value, "auto") == 0)
*value = "n";
return 0; return 0;
} }
@ -1468,60 +1470,70 @@ static int get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.LastDataDownlinkRate!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.rate_of_last_rx_pkt*/
static int get_access_point_associative_device_lastdatadownlinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_access_point_associative_device_lastdatadownlinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "rate_of_last_rx_pkt");
dmasprintf(value, "%d", cur_wifi_associative_device_args_ptr->lastdatadownloadlinkrate);
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.LastDataUplinkRate!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.rate_of_last_tx_pkt*/
static int get_access_point_associative_device_lastdatauplinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_access_point_associative_device_lastdatauplinkrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "rate_of_last_tx_pkt");
dmasprintf(value, "%d", cur_wifi_associative_device_args_ptr->lastdatauplinkrate);
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.SignalStrength!UBUS:wifi.ap.@Name/stations//stations[i-1].rssi*/
static int get_access_point_associative_device_signalstrength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_access_point_associative_device_signalstrength(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 1, "rssi");
dmasprintf(value, "%d", cur_wifi_associative_device_args_ptr->signalstrength);
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Retransmissions!UBUS:wifi.ap.@Name/stations//stations[i-1].stats.tx_pkts_retries*/
static int get_WiFiAccessPointAssociatedDevice_Retransmissions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_WiFiAccessPointAssociatedDevice_Retransmissions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 2, "stats", "tx_pkts_retries");
dmasprintf(value, "%d", cur_wifi_associative_device_args_ptr->retransmissions);
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.AssociationTime!UBUS:wifi.ap.@Name/stations//stations[i-1].in_network*/
static int get_WiFiAccessPointAssociatedDevice_AssociationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_WiFiAccessPointAssociatedDevice_AssociationTime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; char local_time[32] = {0};
dmasprintf(value, "%s", cur_wifi_associative_device_args_ptr->assoctime?int_period_to_date_time_format(cur_wifi_associative_device_args_ptr->assoctime):"0"); time_t t_time;
*value = "0001-01-01T00:00:00Z";
char *in_network = dmjson_get_value((json_object *)data, 1, "in_network");
t_time = time(NULL) - atoi(in_network);
if (localtime(&t_time) == NULL)
return -1;
if (strftime(local_time, sizeof(local_time), "%Y-%m-%dT%H:%M:%SZ", localtime(&t_time)) == 0)
return -1;
*value = dmstrdup(local_time);
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.MACAddress!UBUS:wifi.ap.@Name/stations//stations[i-1].macaddr*/
static int get_access_point_associative_device_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_access_point_associative_device_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 1, "macaddr");
dmasprintf(value, cur_wifi_associative_device_args_ptr->macaddress);
return 0; return 0;
} }
static int get_access_point_associative_device_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_access_point_associative_device_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = "true";
dmasprintf(value, "%s", cur_wifi_associative_device_args_ptr->active?"true":"false");
return 0; return 0;
} }
/*#Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Noise!UBUS:wifi.ap.@Name/stations//stations[i-1].tx_failures*/
static int get_WiFiAccessPointAssociatedDevice_Noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) static int get_WiFiAccessPointAssociatedDevice_Noise(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{ {
struct wifi_associative_device_args *cur_wifi_associative_device_args_ptr=(struct wifi_associative_device_args*)data; *value = dmjson_get_value((json_object *)data, 1, "snr");
dmasprintf(value, "%d", cur_wifi_associative_device_args_ptr->noise);
return 0; return 0;
} }
@ -2610,15 +2622,15 @@ DMLEAF tWiFiAccessPointAssociatedDeviceParams[] = {
/* *** Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats. *** */ /* *** Device.WiFi.AccessPoint.{i}.AssociatedDevice.{i}.Stats. *** */
DMLEAF tWiFiAccessPointAssociatedDeviceStatsParams[] = { DMLEAF tWiFiAccessPointAssociatedDeviceStatsParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/ /* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
{"BytesSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, {"BytesSent", &DMREAD, DMT_UNLONG, os__get_access_point_associative_device_statistics_tx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"BytesReceived", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH}, {"BytesReceived", &DMREAD, DMT_UNLONG, os__get_access_point_associative_device_statistics_rx_bytes, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_packets, NULL, NULL, NULL, BBFDM_BOTH}, {"PacketsSent", &DMREAD, DMT_UNLONG, os__get_access_point_associative_device_statistics_tx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"PacketsReceived", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_rx_packets, NULL, NULL, NULL, BBFDM_BOTH}, {"PacketsReceived", &DMREAD, DMT_UNLONG, os__get_access_point_associative_device_statistics_rx_packets, NULL, NULL, NULL, BBFDM_BOTH},
{"ErrorsSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_errors, NULL, NULL, NULL, BBFDM_BOTH}, {"ErrorsSent", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_tx_errors, NULL, NULL, NULL, BBFDM_BOTH},
{"RetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, {"RetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retrans_count, NULL, NULL, NULL, BBFDM_BOTH},
{"FailedRetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_failed_retrans_count, NULL, NULL, NULL, BBFDM_BOTH}, //{"FailedRetransCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_failed_retrans_count, NULL, NULL, NULL, BBFDM_BOTH},
{"RetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, //{"RetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_retry_count, NULL, NULL, NULL, BBFDM_BOTH},
{"MultipleRetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_multiple_retry_count, NULL, NULL, NULL, BBFDM_BOTH}, //{"MultipleRetryCount", &DMREAD, DMT_UNINT, os__get_access_point_associative_device_statistics_multiple_retry_count, NULL, NULL, NULL, BBFDM_BOTH},
{0} {0}
}; };

View file

@ -68,17 +68,4 @@ struct wifi_acp_args
char *ifname; char *ifname;
}; };
struct wifi_associative_device_args
{
int active;
int lastdatadownloadlinkrate;
int lastdatauplinkrate;
int signalstrength;
char *macaddress;
char *wdev;
int noise;
int retransmissions;
int assoctime;
};
#endif #endif

View file

@ -937,9 +937,9 @@
"type": "ubus", "type": "ubus",
"ubus": { "ubus": {
"object": "router.system", "object": "router.system",
"method": "info", "method": "memory",
"args": {}, "args": {},
"key": "memoryKB.total" "key": "total"
} }
} }
] ]
@ -959,9 +959,9 @@
"type": "ubus", "type": "ubus",
"ubus": { "ubus": {
"object": "router.system", "object": "router.system",
"method": "info", "method": "memory",
"args": {}, "args": {},
"key": "memoryKB.free" "key": "free"
} }
} }
] ]
@ -995,9 +995,9 @@
"type": "ubus", "type": "ubus",
"ubus": { "ubus": {
"object": "router.system", "object": "router.system",
"method": "info", "method": "process",
"args": {}, "args": {},
"key": "system.cpu_per" "key": "cpu_usage"
} }
} }
] ]
@ -29079,15 +29079,6 @@
"name": "bandwidth" "name": "bandwidth"
} }
} }
},
{
"type": "ubus",
"ubus": {
"object": "wifi.radio.@Name",
"method": "status",
"args": {},
"key": "bandwidth"
}
} }
] ]
}, },
@ -31603,6 +31594,17 @@
], ],
"pattern": [ "pattern": [
"([0-9A-Fa-f][0-9A-Fa-f]:){5}([0-9A-Fa-f][0-9A-Fa-f])" "([0-9A-Fa-f][0-9A-Fa-f]:){5}([0-9A-Fa-f][0-9A-Fa-f])"
],
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].macaddr"
}
}
] ]
}, },
"OperatingStandard": { "OperatingStandard": {
@ -31647,7 +31649,18 @@
"min": 1000 "min": 1000
} }
], ],
"unit": "kbps" "unit": "kbps",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.rate_of_last_rx_pkt"
}
}
]
}, },
"LastDataUplinkRate": { "LastDataUplinkRate": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31663,7 +31676,18 @@
"min": 1000 "min": 1000
} }
], ],
"unit": "kbps" "unit": "kbps",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.rate_of_last_tx_pkt"
}
}
]
}, },
"AssociationTime": { "AssociationTime": {
"type": "dateTime", "type": "dateTime",
@ -31673,7 +31697,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "dateTime" "datatype": "dateTime",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].in_network"
}
}
]
}, },
"SignalStrength": { "SignalStrength": {
"type": "int", "type": "int",
@ -31690,7 +31725,18 @@
"max": 0 "max": 0
} }
], ],
"unit": "dBm" "unit": "dBm",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].rssi"
}
}
]
}, },
"Noise": { "Noise": {
"type": "int", "type": "int",
@ -31707,7 +31753,18 @@
"max": 0 "max": 0
} }
], ],
"unit": "dBm" "unit": "dBm",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].tx_failures"
}
}
]
}, },
"Retransmissions": { "Retransmissions": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31724,7 +31781,18 @@
"max": 100 "max": 100
} }
], ],
"unit": "packets" "unit": "packets",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.tx_pkts_retries"
}
}
]
}, },
"Active": { "Active": {
"type": "boolean", "type": "boolean",
@ -31752,7 +31820,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter64" "datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.tx_total_bytes"
}
}
]
}, },
"BytesReceived": { "BytesReceived": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31762,7 +31841,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter64" "datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.rx_data_bytes"
}
}
]
}, },
"PacketsSent": { "PacketsSent": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31772,7 +31862,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter64" "datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.tx_total_pkts"
}
}
]
}, },
"PacketsReceived": { "PacketsReceived": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31782,7 +31883,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter64" "datatype": "StatsCounter64",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.rx_data_pkts"
}
}
]
}, },
"ErrorsSent": { "ErrorsSent": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31792,7 +31904,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter32" "datatype": "StatsCounter32",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.tx_failures"
}
}
]
}, },
"RetransCount": { "RetransCount": {
"type": "unsignedInt", "type": "unsignedInt",
@ -31802,7 +31925,18 @@
"cwmp", "cwmp",
"usp" "usp"
], ],
"datatype": "StatsCounter32" "datatype": "StatsCounter32",
"mapping": [
{
"type": "ubus",
"ubus": {
"object": "wifi.ap.@Name",
"method": "stations",
"args": {},
"key": "stations[i-1].stats.tx_pkts_retries"
}
}
]
}, },
"FailedRetransCount": { "FailedRetransCount": {
"type": "unsignedInt", "type": "unsignedInt",
@ -37892,6 +38026,21 @@
"Enabled", "Enabled",
"Error_Misconfigured", "Error_Misconfigured",
"Error" "Error"
],
"mapping": [
{
"type": "uci",
"uci": {
"file": "network",
"section": {
"type": "interface",
"index": "@i-1"
},
"option": {
"name": "disabled"
}
}
}
] ]
}, },
"Alias": { "Alias": {

View file

@ -217,18 +217,24 @@ def generatelistfromfile(dmobject):
obj = dmobject.get('name').split(".") obj = dmobject.get('name').split(".")
if "tr-104" in sys.argv[1]: if "tr-104" in sys.argv[1]:
pathfilename = "../dmtree/tr104/voice_services.c" pathfilename = "../dmtree/tr104/voice_services.c"
pathiopsyswrtfilename = "../dmtree/tr104/voice_services-iopsyswrt.c"
elif obj[1] == "SoftwareModules" or obj[1] == "BulkData" : elif obj[1] == "SoftwareModules" or obj[1] == "BulkData" :
pathfilename = "../dmtree/tr157/" + obj[1].lower() + ".c" pathfilename = "../dmtree/tr157/" + obj[1].lower() + ".c"
pathiopsyswrtfilename = "../dmtree/tr157/" + obj[1].lower() + "-iopsyswrt.c"
else: else:
pathfilename = "../dmtree/tr181/" + obj[1].lower() + ".c" pathfilename = "../dmtree/tr181/" + obj[1].lower() + ".c"
exists = os.path.isfile(pathfilename) pathiopsyswrtfilename = "../dmtree/tr181/" + obj[1].lower() + "-iopsyswrt.c"
if exists:
filec = open(pathfilename, "r") for x in range(0, 2):
for linec in filec: pathfile = pathfilename if x == 0 else pathiopsyswrtfilename
if "/*#" in linec: exists = os.path.isfile(pathfile)
listmapping.append(linec) if exists:
else: filec = open(pathfile, "r")
pass for linec in filec:
if "/*#" in linec:
listmapping.append(linec)
else:
pass
def getparammapping(dmobject, dmparam): def getparammapping(dmobject, dmparam):
hasmapping = 0 hasmapping = 0