mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Add missing dependencies for objects and enhancement the code
This commit is contained in:
parent
2583c5cbc0
commit
27cd8b3518
5 changed files with 44 additions and 60 deletions
|
|
@ -78,24 +78,24 @@ DMOBJ tDeviceObj[] = {
|
|||
{"FAST", &DMREAD, NULL, NULL, "ubus:fast", NULL, NULL, NULL, tFASTObj, tFASTParams, NULL, BBFDM_BOTH},
|
||||
{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh", NULL, NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH},
|
||||
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh", NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH},
|
||||
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH},
|
||||
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh,/etc/config/dhcp", NULL, NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH},
|
||||
{"Hosts", &DMREAD, NULL, NULL, "ubus:topology->hosts", NULL, NULL, NULL, tHostsObj, tHostsParams, NULL, BBFDM_BOTH},
|
||||
{"NAT", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tNATObj, tNATParams, NULL, BBFDM_BOTH},
|
||||
{"PPP", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/ppp.sh", NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH},
|
||||
{"PPP", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/ppp.sh,/etc/config/network", NULL, NULL, NULL, tPPPObj, tPPPParams, NULL, BBFDM_BOTH},
|
||||
{"Routing", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tRoutingObj, tRoutingParams, NULL, BBFDM_BOTH},
|
||||
{"Firewall", &DMREAD, NULL, NULL, "file:/etc/config/firewall", NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL, BBFDM_BOTH},
|
||||
{"DNS", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH},
|
||||
{"DNS", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, NULL, tDNSObj, tDNSParams, NULL, BBFDM_BOTH},
|
||||
{"Users", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, tUsersObj, tUsersParams, NULL, BBFDM_BOTH},
|
||||
{"IEEE1905", &DMREAD, NULL, NULL, "file:/etc/config/ieee1905,/etc/config/topology;ubus:ieee1905->info,topology->dump", NULL, NULL, NULL, tIEEE1905Obj, tIEEE1905Params, NULL, BBFDM_BOTH},
|
||||
{"InterfaceStack", &DMREAD, NULL, NULL, "file:/etc/config/network", browseInterfaceStackInst, NULL, NULL, NULL, tInterfaceStackParams, NULL, BBFDM_BOTH},
|
||||
{"USB", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUSBObj, tUSBParams, NULL, BBFDM_BOTH},
|
||||
{"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh", NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH},
|
||||
{"GRE", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/gre.sh,/etc/config/network", NULL, NULL, NULL, tGREObj, tGREParams, NULL, BBFDM_BOTH},
|
||||
{"DynamicDNS", &DMREAD, NULL, NULL, "file:/etc/config/ddns", NULL, NULL, NULL, tDynamicDNSObj, tDynamicDNSParams, NULL, BBFDM_BOTH},
|
||||
{"QoS", &DMREAD, NULL, NULL, "file:/etc/config/qos", NULL, NULL, NULL, tQoSObj, tQoSParams, NULL, BBFDM_BOTH},
|
||||
{"LANConfigSecurity", &DMREAD, NULL, NULL, "file:/etc/config/users", NULL, NULL, NULL, NULL, tLANConfigSecurityParams, NULL, BBFDM_BOTH},
|
||||
{"SoftwareModules", &DMREAD, NULL, NULL, "ubus:swmodules", NULL, NULL, NULL, tSoftwareModulesObj, tSoftwareModulesParams, NULL, BBFDM_BOTH},
|
||||
{"Security", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tSecurityObj, tSecurityParams, NULL, BBFDM_BOTH},
|
||||
{"RouterAdvertisement", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRouterAdvertisementObj, tRouterAdvertisementParams, NULL, BBFDM_BOTH},
|
||||
{"RouterAdvertisement", &DMREAD, NULL, NULL, "file:/etc/config/dhcp", NULL, NULL, NULL, tRouterAdvertisementObj, tRouterAdvertisementParams, NULL, BBFDM_BOTH},
|
||||
{0}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ static int get_device_active_fwimage(char *refparam, struct dmctx *ctx, void *da
|
|||
}
|
||||
}
|
||||
|
||||
snprintf(linker, sizeof(linker), "fw_image:%s", id);
|
||||
snprintf(linker, sizeof(linker), "fw_image:%s", id ? id : "");
|
||||
adm_entry_get_linker_param(ctx, "Device.DeviceInfo.FirmwareImage.", linker, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
|
|
@ -116,7 +116,7 @@ static int get_device_boot_fwimage(char *refparam, struct dmctx *ctx, void *data
|
|||
}
|
||||
}
|
||||
|
||||
snprintf(linker, sizeof(linker), "fw_image:%s", id);
|
||||
snprintf(linker, sizeof(linker), "fw_image:%s", id ? id : "");
|
||||
adm_entry_get_linker_param(ctx, "Device.DeviceInfo.FirmwareImage.", linker, value);
|
||||
if (*value == NULL)
|
||||
*value = "";
|
||||
|
|
|
|||
|
|
@ -794,26 +794,25 @@ static int get_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
|
|||
static int get_WiFiRadio_SupportedOperatingChannelBandwidths(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res = NULL, *supp_channels = NULL, *arrobj = NULL;
|
||||
char object[32], *bandwidth = NULL, *bandwidth_list = "";
|
||||
int i = 0;
|
||||
char bandwidth_list[128], object[32];
|
||||
int i = 0, pos = 0;
|
||||
|
||||
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);
|
||||
DM_ASSERT(res, *value = "Auto");
|
||||
|
||||
bandwidth_list[0] = 0;
|
||||
dmjson_foreach_obj_in_array(res, arrobj, supp_channels, i, 1, "supp_channels") {
|
||||
bandwidth = dmjson_get_value(supp_channels, 1, "bandwidth");
|
||||
char *bandwidth = dmjson_get_value(supp_channels, 1, "bandwidth");
|
||||
if (bandwidth && !strstr(bandwidth_list, !strcmp(bandwidth, "8080") ? "80+80" : !strcmp(bandwidth, "80") ? ",80MHz" : bandwidth)) {
|
||||
if (*bandwidth_list == '\0')
|
||||
dmasprintf(&bandwidth_list, "%sMHz", !strcmp(bandwidth, "8080") ? "80+80" : bandwidth);
|
||||
else {
|
||||
char *tmp = dmstrdup(bandwidth_list);
|
||||
dmfree(bandwidth_list);
|
||||
dmasprintf(&bandwidth_list, "%s,%sMHz", tmp, !strcmp(bandwidth, "8080") ? "80+80" : bandwidth);
|
||||
dmfree(tmp);
|
||||
}
|
||||
pos += snprintf(&bandwidth_list[pos], sizeof(bandwidth_list) - pos, "%sMHz,", !strcmp(bandwidth, "8080") ? "80+80" : bandwidth);
|
||||
}
|
||||
}
|
||||
*value = bandwidth_list;
|
||||
|
||||
if (pos)
|
||||
bandwidth_list[pos - 1] = 0;
|
||||
|
||||
*value = dmstrdup(bandwidth_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2811,37 +2810,6 @@ static int browseWifiNeighboringWiFiDiagnosticResultInst(struct dmctx *dmctx, DM
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_radio_standards(struct uci_section *section, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
char object[32], *standard = NULL;
|
||||
char **standards = NULL, *str_append = NULL;
|
||||
int i;
|
||||
size_t length;
|
||||
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", section_name(section));
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
DM_ASSERT(res, *value = "n,ax");
|
||||
|
||||
standard = dmjson_get_value(res, 1, "standard");
|
||||
standards = strsplit(standard, "/", &length);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
if (strstr(standards[i], "802.11") == standards[i])
|
||||
str_append = dmstrdup(strstr(standards[i], "802.11") + strlen("802.11"));
|
||||
else
|
||||
str_append = dmstrdup(standards[i]);
|
||||
if (strlen(*value) == 0){
|
||||
dmasprintf(value, "%s", str_append);
|
||||
continue;
|
||||
}
|
||||
dmasprintf(value, "%s,%s", *value, str_append);
|
||||
FREE(str_append);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.WiFi.Radio.{i}.SupportedStandards!UBUS:wifi.radio.@Name/status//standard*/
|
||||
static int get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
|
@ -2853,7 +2821,21 @@ static int get_radio_supported_standard(char *refparam, struct dmctx *ctx, void
|
|||
/*#Device.WiFi.Radio.{i}.OperatingStandards!UBUS:wifi.radio.@Name/status//standard*/
|
||||
static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
return get_radio_standards(((struct wifi_radio_args *)data)->wifi_radio_sec, value);
|
||||
json_object *res = NULL;
|
||||
char standard_list[16] = { 0, 0 };
|
||||
char object[16];
|
||||
|
||||
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);
|
||||
DM_ASSERT(res, *value = "n,ax");
|
||||
char *standard = dmjson_get_value(res, 1, "standard");
|
||||
if (strstr(standard, "802.11")) {
|
||||
DM_STRNCPY(standard_list, standard + strlen("802.11"), sizeof(standard_list));
|
||||
replace_char(standard_list, '/', ',');
|
||||
}
|
||||
|
||||
*value = dmstrdup(standard_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
|
|
@ -2885,7 +2867,7 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void
|
|||
|
||||
if (curr_htmode && *curr_htmode) {
|
||||
sscanf(curr_htmode, "%*[A-Z]%d", &freq);
|
||||
freq = !strcmp(htmode, "NOHT") ? 20 : freq;
|
||||
freq = !strcmp(curr_htmode, "NOHT") ? 20 : freq;
|
||||
}
|
||||
|
||||
band = get_radio_option_nocache(data, "band");
|
||||
|
|
@ -4124,7 +4106,7 @@ static int browseWiFiDataElementsDisassociationEventDisassociationEventDataInst(
|
|||
/* *** Device.WiFi. *** */
|
||||
DMOBJ tWiFiObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, dynamicleaf, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
||||
{"DataElements", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWiFiDataElementsObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DataElements", &DMREAD, NULL, NULL, "ubus:wifi.dataelements.collector", NULL, NULL, NULL, tWiFiDataElementsObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"Radio", &DMREAD, NULL, NULL, NULL, browseWifiRadioInst, NULL, NULL, tWiFiRadioObj, tWiFiRadioParams, get_linker_Wifi_Radio, BBFDM_BOTH, LIST_KEY{"Name", "Alias", NULL}},
|
||||
{"SSID", &DMWRITE, add_wifi_ssid, delete_wifi_iface, NULL, browseWifiSsidInst, NULL, NULL, tWiFiSSIDObj, tWiFiSSIDParams, get_linker_Wifi_Ssid, BBFDM_BOTH, LIST_KEY{"Name", "Alias", "BSSID", NULL}},
|
||||
{"AccessPoint", &DMWRITE, add_wifi_accesspoint, delete_wifi_iface, NULL, browseWifiAccessPointInst, NULL, NULL, tWiFiAccessPointObj, tWiFiAccessPointParams, NULL, BBFDM_BOTH, LIST_KEY{"SSIDReference", "Alias", NULL}},
|
||||
|
|
|
|||
|
|
@ -54,17 +54,19 @@ static char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[])
|
|||
char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...)
|
||||
{
|
||||
va_list arg;
|
||||
char *argv[64], *v;
|
||||
char *argv[64];
|
||||
int i;
|
||||
|
||||
if (!mainjobj)
|
||||
return "";
|
||||
|
||||
va_start(arg, argc);
|
||||
for (i = 0; i < argc; i++) {
|
||||
argv[i] = va_arg(arg, char *);
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
va_end(arg);
|
||||
v = ____dmjson_get_value_in_obj(mainjobj, argv);
|
||||
return v;
|
||||
return ____dmjson_get_value_in_obj(mainjobj, argv);
|
||||
}
|
||||
|
||||
json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...)
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ struct package_change
|
|||
section != NULL; \
|
||||
section = dmuci_walk_section(package, stype, arg, NULL, CMP_FILTER_FUNC, func, section, GET_NEXT_SECTION))
|
||||
|
||||
#define section_name(s) (s)->e.name
|
||||
#define section_type(s) (s)->type
|
||||
#define section_config(s) (s)->package->e.name
|
||||
#define section_name(s) s ? (s)->e.name : ""
|
||||
#define section_type(s) s ? (s)->type : ""
|
||||
#define section_config(s) s ? (s)->package->e.name : ""
|
||||
|
||||
static inline void uci_list_insert(struct uci_list *list, struct uci_list *ptr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue