mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
obuspa: List supported operate commands
This commit is contained in:
parent
2e4bc3688b
commit
57ae1244cc
7 changed files with 71 additions and 35 deletions
|
|
@ -290,6 +290,11 @@ int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1,
|
|||
ctx->in_value = arg1 ? arg1 : "";
|
||||
fault = operate_on_node(ctx, ctx->in_param, ctx->in_value);
|
||||
break;
|
||||
|
||||
case CMD_USP_LIST_OPERATE:
|
||||
ctx->in_value = arg1 ? arg1 : "";
|
||||
operate_list_cmds(ctx);
|
||||
break;
|
||||
#ifdef BBF_TR064
|
||||
case CMD_UPNP_GET_SUPPORTED_PARAMETERS:
|
||||
ctx->depth = atoi(arg1);
|
||||
|
|
|
|||
|
|
@ -162,8 +162,10 @@ int load_library_dynamic_arrays(struct dmctx *ctx)
|
|||
*(void **) (&root_dynamic_operate) = dlsym(handle, "tRootDynamicOperate");
|
||||
if(root_dynamic_operate) {
|
||||
for (i = 0; root_dynamic_operate[i].path; i++) {
|
||||
if (root_dynamic_operate[i].operate)
|
||||
add_dynamic_operate(root_dynamic_operate[i].path, root_dynamic_operate[i].operate);
|
||||
if (root_dynamic_operate[i].operate && root_dynamic_operate[i].type)
|
||||
add_dynamic_operate(root_dynamic_operate[i].path,
|
||||
root_dynamic_operate[i].operate,
|
||||
root_dynamic_operate[i].type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
69
dmoperate.c
69
dmoperate.c
|
|
@ -928,12 +928,13 @@ static int get_index_of_available_dynamic_operate(struct op_cmd *operate)
|
|||
return idx;
|
||||
}
|
||||
|
||||
int add_dynamic_operate(char *path, operation operate)
|
||||
int add_dynamic_operate(char *path, operation operate, char *type)
|
||||
{
|
||||
if (dynamic_operate == NULL) {
|
||||
dynamic_operate = calloc(2, sizeof(struct op_cmd));
|
||||
dynamic_operate[0].name = path;
|
||||
dynamic_operate[0].opt = operate;
|
||||
dynamic_operate[0].type = type;
|
||||
} else {
|
||||
int idx = get_index_of_available_dynamic_operate(dynamic_operate);
|
||||
struct op_cmd *new_dynamic_operate = realloc(dynamic_operate, (idx + 2) * sizeof(struct op_cmd));
|
||||
|
|
@ -944,36 +945,58 @@ int add_dynamic_operate(char *path, operation operate)
|
|||
memset(dynamic_operate + (idx + 1), 0, sizeof(struct op_cmd));
|
||||
dynamic_operate[idx].name = path;
|
||||
dynamic_operate[idx].opt = operate;
|
||||
dynamic_operate[idx].type = type;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct op_cmd operate_helper[] = {
|
||||
{"Device.Reboot", reboot_device},
|
||||
{"Device.FactoryReset", factory_reset},
|
||||
{"Device.IP.Interface.*.Reset", network_interface_reset},
|
||||
{"Device.PPP.Interface.*.Reset", network_interface_reset},
|
||||
{"Device.WiFi.Reset", wireless_reset},
|
||||
{"Device.WiFi.AccessPoint.*.Security.Reset", ap_security_reset},
|
||||
{"Device.DHCPv4.Client.*.Renew", dhcp_client_renew},
|
||||
{"Device.DHCPv6.Client.*.Renew", dhcp_client_renew},
|
||||
{"Device.DeviceInfo.VendorConfigFile.*.Backup", vendor_conf_backup},
|
||||
{"Device.DeviceInfo.VendorConfigFile.*.Restore", vendor_conf_restore},
|
||||
{"Device.WiFi.NeighboringWiFiDiagnostic", fetch_neighboring_wifi_diagnostic},
|
||||
{"Device.Reboot", reboot_device, "sync"},
|
||||
{"Device.FactoryReset", factory_reset, "sync"},
|
||||
{"Device.IP.Interface.*.Reset", network_interface_reset, "sync"},
|
||||
{"Device.PPP.Interface.*.Reset", network_interface_reset, "sync"},
|
||||
{"Device.WiFi.Reset", wireless_reset, "sync"},
|
||||
{"Device.WiFi.AccessPoint.*.Security.Reset", ap_security_reset, "sync"},
|
||||
{"Device.DHCPv4.Client.*.Renew", dhcp_client_renew, "sync"},
|
||||
{"Device.DHCPv6.Client.*.Renew", dhcp_client_renew, "sync"},
|
||||
{"Device.DeviceInfo.VendorConfigFile.*.Backup", vendor_conf_backup, "async"},
|
||||
{"Device.DeviceInfo.VendorConfigFile.*.Restore", vendor_conf_restore, "async"},
|
||||
{"Device.WiFi.NeighboringWiFiDiagnostic", fetch_neighboring_wifi_diagnostic, "async"},
|
||||
//{"Device.DeviceInfo.VendorLogFile.*.Upload", blob_parser},
|
||||
{"Device.IP.Diagnostics.IPPing", ip_diagnostics_ipping},
|
||||
{"Device.IP.Diagnostics.TraceRoute", ip_diagnostics_traceroute},
|
||||
{"Device.IP.Diagnostics.DownloadDiagnostics", ip_diagnostics_download},
|
||||
{"Device.IP.Diagnostics.UploadDiagnostics", ip_diagnostics_upload},
|
||||
{"Device.IP.Diagnostics.UDPEchoDiagnostics", ip_diagnostics_udpecho},
|
||||
{"Device.IP.Diagnostics.ServerSelectionDiagnostics", ip_diagnostics_serverselection},
|
||||
{"Device.DNS.Diagnostics.NSLookupDiagnostics", ip_diagnostics_nslookup},
|
||||
{"Device.SoftwareModules.ExecEnv.*.Reset", swmodules_exec_env_reset},
|
||||
{"Device.SoftwareModules.InstallDU", swmodules_install_du},
|
||||
{"Device.SoftwareModules.DeploymentUnit.*.Update", swmodules_update_du},
|
||||
{"Device.SoftwareModules.DeploymentUnit.*.Uninstall", swmodules_uninstall_du}
|
||||
{"Device.IP.Diagnostics.IPPing", ip_diagnostics_ipping, "async"},
|
||||
{"Device.IP.Diagnostics.TraceRoute", ip_diagnostics_traceroute, "async"},
|
||||
{"Device.IP.Diagnostics.DownloadDiagnostics", ip_diagnostics_download, "async"},
|
||||
{"Device.IP.Diagnostics.UploadDiagnostics", ip_diagnostics_upload, "async"},
|
||||
{"Device.IP.Diagnostics.UDPEchoDiagnostics", ip_diagnostics_udpecho, "async"},
|
||||
{"Device.IP.Diagnostics.ServerSelectionDiagnostics", ip_diagnostics_serverselection, "async"},
|
||||
{"Device.DNS.Diagnostics.NSLookupDiagnostics", ip_diagnostics_nslookup, "async"},
|
||||
{"Device.SoftwareModules.ExecEnv.*.Reset", swmodules_exec_env_reset, "sync"},
|
||||
{"Device.SoftwareModules.InstallDU", swmodules_install_du, "async"},
|
||||
{"Device.SoftwareModules.DeploymentUnit.*.Update", swmodules_update_du, "async"},
|
||||
{"Device.SoftwareModules.DeploymentUnit.*.Uninstall", swmodules_uninstall_du, "async"}
|
||||
};
|
||||
|
||||
void operate_list_cmds(struct dmctx *dmctx)
|
||||
{
|
||||
char *param, *type;
|
||||
uint8_t len = 0, i;
|
||||
struct op_cmd *save_pointer = NULL;
|
||||
if (dynamic_operate) save_pointer = dynamic_operate;
|
||||
|
||||
len = ARRAY_SIZE(operate_helper);
|
||||
for(i = 0; i < len; i++) {
|
||||
param = dmstrdup(operate_helper[i].name);
|
||||
type = operate_helper[i].type;
|
||||
add_list_paramameter(dmctx, param, NULL, type, NULL, 0);
|
||||
}
|
||||
|
||||
for (; (dynamic_operate && dynamic_operate->name); dynamic_operate++) {
|
||||
param = dmstrdup(dynamic_operate->name);
|
||||
type = dynamic_operate->type;
|
||||
add_list_paramameter(dmctx, param, NULL, type, NULL, 0);
|
||||
}
|
||||
if (save_pointer) dynamic_operate = save_pointer;
|
||||
}
|
||||
opr_ret_t operate_on_node(struct dmctx *dmctx, char *path, char *input)
|
||||
{
|
||||
uint8_t len = 0, i;
|
||||
|
|
|
|||
|
|
@ -213,9 +213,11 @@ struct deployment_unit_update {
|
|||
struct op_cmd {
|
||||
char *name;
|
||||
operation opt;
|
||||
char *type;
|
||||
};
|
||||
|
||||
int add_dynamic_operate(char *path, operation operate);
|
||||
int add_dynamic_operate(char *path, operation operate, char *optype);
|
||||
void operate_list_cmds(struct dmctx *dmctx);
|
||||
opr_ret_t operate_on_node(struct dmctx *dmctx, char *path, char *input);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
}
|
||||
},
|
||||
"Device.BBKSpeedTest": {
|
||||
"type": "operate"
|
||||
"type": "operate",
|
||||
"optype": "async"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ def cprintheaderRootDynamicOperate( ):
|
|||
fp = open('./.objroot.c', 'a')
|
||||
print >> fp, "/* ********** RootDynamicOperate ********** */"
|
||||
print >> fp, "LIB_MAP_OPERATE tRootDynamicOperate[] = {"
|
||||
print >> fp, "/* pathname, operation */"
|
||||
print >> fp, "/* pathname, operation, type */"
|
||||
fp.close()
|
||||
|
||||
def printObjRootDynamic( dmobject ):
|
||||
|
|
@ -130,9 +130,9 @@ def printObjRootDynamic( dmobject ):
|
|||
print >> fp, "{\"%s\", %s}," % (dmobject, "tdynamic" + commonname + "Obj")
|
||||
fp.close()
|
||||
|
||||
def printOperateRootDynamic( dmobject, commonname ):
|
||||
def printOperateRootDynamic( dmobject, commonname , optype):
|
||||
fp = open('./.objroot.c', 'a')
|
||||
print >> fp, "{\"%s\", %s}," % (dmobject, "dynamic" + commonname + "Operate")
|
||||
print >> fp, "{\"%s\", %s, \"%s\"}," % (dmobject, "dynamic" + commonname + "Operate", optype)
|
||||
fp.close()
|
||||
|
||||
def printtailArrayRootDynamic( ):
|
||||
|
|
@ -550,9 +550,10 @@ def generatecfiles( pdir ):
|
|||
def generatestartedobject( key , value ):
|
||||
obj_type = getoptionparam(value, "type")
|
||||
if obj_type == "operate":
|
||||
op_type = getoptionparam(value, "optype")
|
||||
key = key.replace(".{i}.", ".*.")
|
||||
if key not in ListOperate:
|
||||
ListOperate.append(key)
|
||||
if key not in DictOperate:
|
||||
DictOperate[key] = op_type;
|
||||
else:
|
||||
key = key.replace(".{i}", "")
|
||||
obj = '.'.join(key.split(".")[0:key.count('.')-1]) + '.'
|
||||
|
|
@ -566,9 +567,9 @@ def generateRootDynamicarray( ):
|
|||
printtailArrayRootDynamic()
|
||||
|
||||
cprintheaderRootDynamicOperate()
|
||||
for x in ListOperate:
|
||||
for x in DictOperate:
|
||||
commonname = getname(x)
|
||||
printOperateRootDynamic(x, commonname)
|
||||
printOperateRootDynamic(x, commonname, DictOperate[x])
|
||||
cprintOperate(commonname)
|
||||
hprintOperate(commonname)
|
||||
printtailArrayRootDynamic()
|
||||
|
|
@ -603,7 +604,7 @@ with open(json_file) as file:
|
|||
data = json.loads(file.read(), object_pairs_hook=OrderedDict)
|
||||
|
||||
ListObjects = []
|
||||
ListOperate = []
|
||||
DictOperate = {}
|
||||
for i,(key,value) in enumerate(data.items()):
|
||||
generatestartedobject(key, value)
|
||||
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ typedef opr_ret_t (*operation) (struct dmctx *dmctx, char *p, char *input);
|
|||
typedef struct lib_map_operate {
|
||||
char *path;
|
||||
operation operate;
|
||||
char *type; // sync or async
|
||||
} LIB_MAP_OPERATE;
|
||||
|
||||
enum set_value_action {
|
||||
|
|
@ -333,6 +334,7 @@ enum {
|
|||
CMD_DEL_OBJECT,
|
||||
CMD_INFORM,
|
||||
CMD_USP_OPERATE,
|
||||
CMD_USP_LIST_OPERATE,
|
||||
#ifdef BBF_TR064
|
||||
CMD_UPNP_GET_SUPPORTED_PARAMETERS,
|
||||
CMD_UPNP_GET_INSTANCES,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue