mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-01-28 01:47:18 +01:00
Added support for DUStateChangeComplPolicy
This commit is contained in:
parent
586493681a
commit
65d4d48929
2 changed files with 131 additions and 0 deletions
|
|
@ -14,7 +14,12 @@
|
|||
#include "managementserver.h"
|
||||
#include "dmbbfcommon.h"
|
||||
|
||||
#define DU_STATE_CHANGE_SEC_NAME "du_state_change"
|
||||
|
||||
static char *CWMP_EVENTS[] = {"0 BOOTSTRAP", "1 BOOT", "2 PERIODIC", "3 SCHEDULED", "5 KICKED", "6 CONNECTION REQUEST", "7 TRANSFER COMPLETE", "8 DIAGNOSTICS COMPLETE", "9 REQUEST DOWNLOAD", "10 AUTONOMOUS TRANSFER COMPLETE", "11 DU STATE CHANGE COMPLETE", "M Reboot", "M ScheduleInform", "M Download", "M ScheduleDownload", "M Upload", "M ChangeDUState", "14 HEARTBEAT", NULL};
|
||||
static char *DUStateOperationType[] = {"Install", "Update", "Uninstall", NULL};
|
||||
static char *DUStateResultType[] = {"Success", "Failure", "Both", NULL};
|
||||
static char *DUStateFaultCode[] = {"9001", "9003", "9012", "9013", "9015", "9016", "9017", "9018","9022", "9023", "9024", "9025", "9026", "9027", "9028", "9029", "9030", "9031", "9032", NULL};
|
||||
|
||||
enum suboption_125 {
|
||||
OPT_OUI,
|
||||
|
|
@ -30,6 +35,22 @@ struct manageable_device_args {
|
|||
char host[1025];
|
||||
};
|
||||
|
||||
static struct uci_section* get_autonomous_notify_section(char *sec_name)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
uci_path_foreach_sections(varstate, "cwmp", "autonomous_notify", s) {
|
||||
if (strcmp(section_name(s), sec_name) == 0) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
dmuci_add_section_varstate("cwmp", "autonomous_notify", &s);
|
||||
if (s != NULL)
|
||||
dmuci_rename_section_by_section(s, sec_name);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
static void get_option125_suboption(char *data, int option, char *dst, int dst_len)
|
||||
{
|
||||
int data_len = 0, len = 0;
|
||||
|
|
@ -1001,6 +1022,106 @@ static int get_manageable_device_host(char *refparam, struct dmctx *ctx, void *d
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int get_du_state_change_compl_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", DU_STATE_CHANGE_SEC_NAME, "enable", value);
|
||||
if (DM_STRLEN(*value) == 0)
|
||||
*value = "0";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_du_state_change_compl_policy_operation_type_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", DU_STATE_CHANGE_SEC_NAME, "operation_type", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_du_state_change_compl_policy_result_type_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", DU_STATE_CHANGE_SEC_NAME, "result_type", value);
|
||||
if (DM_STRLEN(*value) == 0)
|
||||
*value = strdup("Both");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_du_state_change_compl_policy_fault_code_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_option_value_string_varstate("cwmp", DU_STATE_CHANGE_SEC_NAME, "fault_code", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_du_state_change_compl_policy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
bool b;
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_boolean(value))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
string_to_bool(value, &b);
|
||||
s = get_autonomous_notify_section(DU_STATE_CHANGE_SEC_NAME);
|
||||
dmuci_set_value_by_section_varstate(s, "enable", b ? "1" : "0");
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_du_state_change_compl_policy_operation_type_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string_list(value, -1, -1, -1, -1, -1, DUStateOperationType, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
s = get_autonomous_notify_section(DU_STATE_CHANGE_SEC_NAME);
|
||||
dmuci_set_value_by_section_varstate(s, "operation_type", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_du_state_change_compl_policy_result_type_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string(value, -1, -1, DUStateResultType, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
s = get_autonomous_notify_section(DU_STATE_CHANGE_SEC_NAME);
|
||||
dmuci_set_value_by_section_varstate(s, "result_type", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_du_state_change_compl_policy_fault_code_filter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
struct uci_section *s = NULL;
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
if (dm_validate_string_list(value, -1, -1, -1, -1, -1, DUStateFaultCode, NULL))
|
||||
return FAULT_9007;
|
||||
return 0;
|
||||
case VALUESET:
|
||||
s = get_autonomous_notify_section(DU_STATE_CHANGE_SEC_NAME);
|
||||
dmuci_set_value_by_section_varstate(s, "fault_code", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**********************************************************************************************************************************
|
||||
* OBJ & PARAM DEFINITION
|
||||
***********************************************************************************************************************************/
|
||||
|
|
@ -1009,6 +1130,7 @@ DMOBJ tManagementServerObj[] = {
|
|||
{"HeartbeatPolicy", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tHeartbeatPolicyParams, NULL, BBFDM_CWMP, NULL, "2.12"},
|
||||
{"ManageableDevice", &DMREAD, NULL, NULL, NULL, browseManageableDevice, NULL, NULL, NULL, tManageableDeviceParams, NULL, BBFDM_CWMP, NULL, "2.12"},
|
||||
{"InformParameter", &DMWRITE, add_inform_parameter, delete_inform_parameter, NULL, browseInformParameterInst, NULL, NULL, NULL, tInformParameterParams, NULL, BBFDM_CWMP, NULL, "2.8"},
|
||||
{"DUStateChangeComplPolicy", &DMREAD, NULL, NULL, "file:/etc/config/swmodd", NULL, NULL, NULL, NULL, tDUStateChangeComplPolicyParams, NULL, BBFDM_CWMP, NULL, "2.1"},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -1070,3 +1192,11 @@ DMLEAF tManageableDeviceParams[] = {
|
|||
{"Host", &DMREAD, DMT_STRING, get_manageable_device_host, NULL, BBFDM_CWMP, "2.0"},
|
||||
{0}
|
||||
};
|
||||
|
||||
DMLEAF tDUStateChangeComplPolicyParams[] = {
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_du_state_change_compl_policy_enable, set_du_state_change_compl_policy_enable, BBFDM_CWMP, "2.1"},
|
||||
{"OperationTypeFilter", &DMWRITE, DMT_STRING, get_du_state_change_compl_policy_operation_type_filter, set_du_state_change_compl_policy_operation_type_filter, BBFDM_CWMP, "2.1"},
|
||||
{"ResultTypeFilter", &DMWRITE, DMT_STRING, get_du_state_change_compl_policy_result_type_filter, set_du_state_change_compl_policy_result_type_filter, BBFDM_CWMP, "2.1"},
|
||||
{"FaultCodeFilter", &DMWRITE, DMT_STRING, get_du_state_change_compl_policy_fault_code_filter, set_du_state_change_compl_policy_fault_code_filter, BBFDM_CWMP, "2.1"},
|
||||
{0}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@ extern DMLEAF tManagementServerParams[];
|
|||
extern DMLEAF tHeartbeatPolicyParams[];
|
||||
extern DMLEAF tInformParameterParams[];
|
||||
extern DMLEAF tManageableDeviceParams[];
|
||||
extern DMLEAF tDUStateChangeComplPolicyParams[];
|
||||
extern DMOBJ tManagementServerObj[];
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue