T#12237: Add support to show password for SecuredRoles

This commit is contained in:
Amin Ben Romdhane 2024-01-09 12:37:39 +00:00 committed by Vivek Kumar Dutta
parent 74382efdc9
commit 8d32f02f35
14 changed files with 179 additions and 131 deletions

View file

@ -1011,23 +1011,10 @@ static void fill_event_schema(struct blob_buf *bb, struct dm_parameter *param)
static void fill_param_schema(struct blob_buf *bb, struct dm_parameter *param)
{
blobmsg_add_string(bb, "path", param->name);
blobmsg_add_string(bb, "data", param->data ? param->data : "0");
blobmsg_add_string(bb, "type", param->type);
if (param->additional_data) {
const char **uniq_keys = (const char **)param->additional_data;
void *key = blobmsg_open_array(bb, "input");
void *table = NULL;
for (int i = 0; uniq_keys[i] != NULL; i++) {
table = blobmsg_open_table(bb, NULL);
blobmsg_add_string(bb, "path", uniq_keys[i]);
blobmsg_close_table(bb, table);
}
blobmsg_close_array(bb, key);
}
bb_add_string(bb, "path", param->name);
bb_add_string(bb, "data", param->data ? param->data : "0");
bb_add_string(bb, "type", param->type);
bb_add_flags_arr(bb, param->additional_data);
}

View file

@ -92,6 +92,27 @@ void bbf_sub_cleanup(struct dmctx *dm_ctx)
bbf_ctx_clean_sub(dm_ctx);
}
void bb_add_flags_arr(struct blob_buf *bb, char *data)
{
uint32_t *dm_falgs = (uint32_t *)data;
if (!bb || !dm_falgs)
return;
void *flags_arr = blobmsg_open_array(bb, "flags");
if (*dm_falgs & DM_FLAG_REFERENCE)
bb_add_string(bb, NULL, "Reference");
if (*dm_falgs & DM_FLAG_UNIQUE)
bb_add_string(bb, NULL, "Unique");
if (*dm_falgs & DM_FLAG_LINKER)
bb_add_string(bb, NULL, "Linker");
if (*dm_falgs & DM_FLAG_SECURE)
bb_add_string(bb, NULL, "Secure");
blobmsg_close_array(bb, flags_arr);
}
bool present_in_path_list(struct list_head *plist, char *entry)
{
struct pathNode *pos;

View file

@ -40,6 +40,8 @@ void fill_err_code_array(bbfdm_data_t *data, int fault);
void bb_add_string(struct blob_buf *bb, const char *name, const char *value);
void bb_add_flags_arr(struct blob_buf *bb, char *data);
int transaction_start(bbfdm_data_t *data, char *app, uint32_t max_timeout);
int transaction_commit(bbfdm_data_t *data, int trans_id, bool is_service_restart);
int transaction_abort(bbfdm_data_t *data, int trans_id);

View file

@ -319,25 +319,6 @@ static bool add_paths_to_stack(struct blob_buf *bb, char *path, size_t begin,
return true;
}
static void bb_add_flags_arr(struct blob_buf *bb, char *data)
{
uint32_t *dm_falgs = (uint32_t *)data;
if (!bb || !dm_falgs)
return;
void *flags_arr = blobmsg_open_array(bb, "flags");
if (*dm_falgs & DM_FLAG_REFERENCE)
bb_add_string(bb, NULL, "Reference");
if (*dm_falgs & DM_FLAG_UNIQUE)
bb_add_string(bb, NULL, "Unique");
if (*dm_falgs & DM_FLAG_LINKER)
bb_add_string(bb, NULL, "Linker");
blobmsg_close_array(bb, flags_arr);
}
// public functions
void prepare_result_blob(struct blob_buf *bb, struct list_head *pv_list)
{

View file

@ -78,7 +78,6 @@ do { \
#define UBUS_ARGS (struct ubus_arg[])
#define RANGE_ARGS (struct range_args[])
#define LIST_KEY (const char *[]) // To be removed later!!!!!!!!!!!!
#define DMPARAM_ARGS \
struct dmctx *dmctx, \
@ -244,7 +243,8 @@ typedef struct {
enum dm_flags_enum {
DM_FLAG_REFERENCE = 1,
DM_FLAG_UNIQUE = 1<<1,
DM_FLAG_LINKER = 1<<2
DM_FLAG_LINKER = 1<<2,
DM_FLAG_SECURE = 1<<3
};
enum set_value_action {

View file

@ -1096,6 +1096,8 @@ static int get_ubus_value(struct dmctx *dmctx, struct dmnode *node)
*dm_flags |= DM_FLAG_UNIQUE;
} else if (DM_LSTRCMP(flag, "Linker") == 0) {
*dm_flags |= DM_FLAG_LINKER;
} else if (DM_LSTRCMP(flag, "Secure") == 0) {
*dm_flags |= DM_FLAG_SECURE;
}
}
}
@ -1150,25 +1152,7 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
char *type = dmjson_get_value(res_obj, 1, "type");
if (DM_LSTRCMP(type, "xsd:object") == 0) { //Object
const char **unique_keys = NULL;
json_object *input_array = dmjson_get_obj(res_obj, 1, "input");
if (input_array) {
size_t j = 0;
size_t in_nbre = json_object_array_length(input_array);
unique_keys = dmcalloc(in_nbre + 1, sizeof(char *));
for (j = 0; j < in_nbre; j++) {
json_object *res_obj = json_object_array_get_idx(input_array, j);
char *in_path = dmjson_get_value(res_obj, 1, "path");
unique_keys[j] = dmstrdup(in_path);
}
unique_keys[j] = NULL;
}
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), "xsd:object", (char *)unique_keys);
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), "xsd:object", NULL);
} else if (DM_LSTRCMP(type, "xsd:command") == 0) { //Command Leaf
operation_args *op = NULL;
@ -1227,7 +1211,33 @@ static int get_ubus_supported_dm(struct dmctx *dmctx, struct dmnode *node)
add_list_parameter(dmctx, dmstrdup(path), (char *)ev, "xsd:event", NULL);
} else { //Param Leaf
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), dmstrdup(type), NULL);
uint32_t *dm_flags = NULL;
json_object *flags_array = dmjson_get_obj(res_obj, 1, "flags");
if (flags_array) {
size_t nbre_falgs = json_object_array_length(flags_array);
dm_flags = (uint32_t *)dmcalloc(1, sizeof(uint32_t));
for (size_t j = 0; j < nbre_falgs; j++) {
json_object *flag_obj = json_object_array_get_idx(flags_array, j);
const char *flag = json_object_get_string(flag_obj);
if (DM_LSTRCMP(flag, "Reference") == 0) {
data = get_value_by_reference(dmctx, data);
*dm_flags |= DM_FLAG_REFERENCE;
} else if (DM_LSTRCMP(flag, "Unique") == 0) {
*dm_flags |= DM_FLAG_UNIQUE;
} else if (DM_LSTRCMP(flag, "Linker") == 0) {
*dm_flags |= DM_FLAG_LINKER;
} else if (DM_LSTRCMP(flag, "Secure") == 0) {
*dm_flags |= DM_FLAG_SECURE;
}
}
}
add_list_parameter(dmctx, dmstrdup(path), dmstrdup(data), dmstrdup(type), (char *)dm_flags);
}
}
@ -1660,7 +1670,9 @@ static int get_value_param(DMPARAM_ARGS)
dmastrcat(&full_param, node->current_object, leaf->parameter);
(leaf->getvalue)(full_param, dmctx, data, instance, &value);
if (value && *value) {
if ((leaf->dm_falgs & DM_FLAG_SECURE) && (dmctx->dm_type == BBFDM_CWMP)) {
value = "";
} else if (value && *value) {
if (leaf->dm_falgs & DM_FLAG_REFERENCE) {
value = get_value_by_reference(dmctx, value);
} else {
@ -1709,7 +1721,9 @@ static int mparam_get_value_in_param(DMPARAM_ARGS)
(leaf->getvalue)(full_param, dmctx, data, instance, &value);
if (value && *value) {
if ((leaf->dm_falgs & DM_FLAG_SECURE) && (dmctx->dm_type == BBFDM_CWMP)) {
value = "";
} else if (value && *value) {
if (leaf->dm_falgs & DM_FLAG_REFERENCE) {
value = get_value_by_reference(dmctx, value);
} else
@ -1969,27 +1983,9 @@ static int mobj_get_supported_dm(DMOBJECT_ARGS)
} else {
char *perm = permission ? permission->val : "0";
char *refparam = node->current_object;
const char **unique_keys = NULL;
if (node->matched && dmctx->isinfo) {
if (node->obj) {
unique_keys = node->obj->unique_keys; // To be removed later!!!!!!!!!!!!
if (unique_keys == NULL) {
struct dm_leaf_s *leaf = node->obj->leaf;
unsigned int idx = 1;
for (; (leaf && leaf->parameter); leaf++) {
if (leaf->dm_falgs & DM_FLAG_UNIQUE) {
idx++;
unique_keys = dmrealloc(unique_keys, idx * sizeof(char *));
unique_keys[idx - 2] = dmstrdup(leaf->parameter);
unique_keys[idx - 1] = NULL;
}
}
}
}
add_list_parameter(dmctx, refparam, perm, "xsd:object", (char *)unique_keys);
add_list_parameter(dmctx, refparam, perm, "xsd:object", NULL);
}
}
@ -2024,7 +2020,7 @@ static int mparam_get_supported_dm(DMPARAM_ARGS)
add_list_parameter(dmctx, refparam, value, DMT_TYPE[leaf->type], leaf->permission->val);
}
} else {
add_list_parameter(dmctx, refparam, leaf->permission->val, DMT_TYPE[leaf->type], NULL);
add_list_parameter(dmctx, refparam, leaf->permission->val, DMT_TYPE[leaf->type], leaf->dm_falgs ? (char *)&leaf->dm_falgs : NULL);
}
}

View file

@ -136,7 +136,6 @@ extern char *RateAdjAlgorithm[];
#define SYSTEM_CERT_PATH "/etc/ssl/certs"
#define BOARD_JSON_FILE "/etc/board.json"
#define DMMAP "dmmap"
#define LIST_KEY (const char *[]) // To be removed later!!!!!!!!!!!!
#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)
#define DM_ASSERT(X, Y) \

View file

@ -1555,26 +1555,6 @@ static char** fill_command_param(int count, struct json_object *obj)
return res_p;
}
static char** fill_unique_keys(size_t count, struct json_object *obj)
{
char **res_p = NULL;
if (!obj || !count)
return res_p;
res_p = malloc(sizeof(char *) * (count + 1));
if (res_p) {
res_p[count] = NULL;
for (int id = 0; id < count; id++) {
struct json_object *key_val = json_object_array_get_idx(obj, id);
res_p[id] = dm_dynamic_strdup(&json_memhead, json_object_get_string(key_val));
}
}
return res_p;
}
static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pleaf, int i, int json_version, struct list_head *list)
{
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type(6)*/
@ -1722,6 +1702,8 @@ static void parse_param(char *object, char *param, json_object *jobj, DMLEAF *pl
pleaf[i].dm_falgs |= DM_FLAG_REFERENCE;
else if (falg_val && strcmp(json_object_get_string(falg_val), "Unique") == 0)
pleaf[i].dm_falgs |= DM_FLAG_UNIQUE;
else if (falg_val && strcmp(json_object_get_string(falg_val), "Secure") == 0)
pleaf[i].dm_falgs |= DM_FLAG_SECURE;
}
snprintf(full_param, sizeof(full_param), "%s%s", object, param_ext);
@ -1807,15 +1789,8 @@ void parse_obj(char *object, json_object *jobj, DMOBJ *pobj, int index, int json
pobj[index].bbfdm_type = BBFDM_BOTH;
}
if (strcmp(key, "uniqueKeys") == 0) {
//uniqueKeys
size_t n_keys = json_obj ? json_object_array_length(json_obj) : 0;
keys_p = fill_unique_keys(n_keys, json_obj);
pobj[index].unique_keys = (const char **)keys_p;
//linker
pobj[index].get_linker = NULL;
}
//linker
pobj[index].get_linker = NULL;
if (strcmp(key, "access") == 0) {
//permission

View file

@ -618,7 +618,7 @@ static int set_DynamicDNSClient_Username(char *refparam, struct dmctx *ctx, void
/*#Device.DynamicDNS.Client.{i}.Password!UCI:ddns/service,@i-1/password*/
static int get_DynamicDNSClient_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "password", value);
return 0;
}
@ -1005,7 +1005,7 @@ DMLEAF tDynamicDNSClientParams[] = {
{"Server", &DMWRITE, DMT_STRING, get_DynamicDNSClient_Server, set_DynamicDNSClient_Server, BBFDM_BOTH, DM_FLAG_UNIQUE|DM_FLAG_REFERENCE},
{"Interface", &DMWRITE, DMT_STRING, get_DynamicDNSClient_Interface, set_DynamicDNSClient_Interface, BBFDM_BOTH, DM_FLAG_REFERENCE},
{"Username", &DMWRITE, DMT_STRING, get_DynamicDNSClient_Username, set_DynamicDNSClient_Username, BBFDM_BOTH, DM_FLAG_UNIQUE},
{"Password", &DMWRITE, DMT_STRING, get_DynamicDNSClient_Password, set_DynamicDNSClient_Password, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_DynamicDNSClient_Password, set_DynamicDNSClient_Password, BBFDM_BOTH, DM_FLAG_SECURE},
{"HostnameNumberOfEntries", &DMREAD, DMT_UNINT, get_DynamicDNSClient_HostnameNumberOfEntries, NULL, BBFDM_BOTH},
{0}
};

View file

@ -1670,6 +1670,13 @@ static int set_IEEE1905ALSecurity_SetupMethod(char *refparam, struct dmctx *ctx,
return 0;
}
/*#Device.IEEE1905.AL.Security.Password!UCI:ieee1905/security,security/method*/
static int get_IEEE1905ALSecurity_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("ieee1905", "security", "key", value);
return 0;
}
static int set_IEEE1905ALSecurity_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
@ -2006,7 +2013,7 @@ DMLEAF tIEEE1905ALNetworkTopologyIEEE1905DeviceBridgingTupleParams[] = {
DMLEAF tIEEE1905ALSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"SetupMethod", &DMWRITE, DMT_STRING, get_IEEE1905ALSecurity_SetupMethod, set_IEEE1905ALSecurity_SetupMethod, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_IEEE1905ALSecurity_Password, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_IEEE1905ALSecurity_Password, set_IEEE1905ALSecurity_Password, BBFDM_BOTH, DM_FLAG_SECURE},
{0}
};

View file

@ -13,7 +13,7 @@
/*#Device.LANConfigSecurity.ConfigPassword!UCI:users/user,user/password*/
static int get_LANConfigSecurity_ConfigPassword(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
dmuci_get_option_value_string("users", "user", "password", value);
return 0;
}
@ -36,6 +36,6 @@ static int set_LANConfigSecurity_ConfigPassword(char *refparam, struct dmctx *ct
***********************************************************************************************************************************/
DMLEAF tLANConfigSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ConfigPassword", &DMWRITE, DMT_STRING, get_LANConfigSecurity_ConfigPassword, set_LANConfigSecurity_ConfigPassword, BBFDM_BOTH},
{"ConfigPassword", &DMWRITE, DMT_STRING, get_LANConfigSecurity_ConfigPassword, set_LANConfigSecurity_ConfigPassword, BBFDM_BOTH, DM_FLAG_SECURE},
{0}
};

View file

@ -266,7 +266,7 @@ static int set_MQTTBroker_Username(char *refparam, struct dmctx *ctx, void *data
static int get_MQTTBroker_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
dmuci_get_value_by_section_string(((struct dmmap_dup *)data)->config_section, "password", value);
return 0;
}
@ -309,7 +309,7 @@ DMLEAF tMQTTBrokerParams[] = {
{"Port", &DMWRITE, DMT_UNINT, get_MQTTBroker_Port, set_MQTTBroker_Port, BBFDM_BOTH},
{"Interface", &DMWRITE, DMT_STRING, get_MQTTBroker_Interface, set_MQTTBroker_Interface, BBFDM_BOTH, DM_FLAG_REFERENCE},
{"Username", &DMWRITE, DMT_STRING, get_MQTTBroker_Username, set_MQTTBroker_Username, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_MQTTBroker_Password, set_MQTTBroker_Password, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_MQTTBroker_Password, set_MQTTBroker_Password, BBFDM_BOTH, DM_FLAG_SECURE},
{0}
};

View file

@ -355,6 +355,15 @@ static int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char
return 0;
}
/*#Device.PPP.Interface.{i}.Password!UCI:network/interface,@i-1/password*/
static int get_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ppp_args *ppp = (struct ppp_args *)data;
dmuci_get_value_by_section_string(ppp->iface_s ? ppp->iface_s : ppp->dmmap_s, "password", value);
return 0;
}
/*#Device.PPP.Interface.{i}.Password!UCI:network/interface,@i-1/password*/
static int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
@ -1163,7 +1172,7 @@ DMLEAF tPPPInterfaceParams[] = {
{"ConnectionStatus", &DMREAD, DMT_STRING, get_ppp_status, NULL, BBFDM_BOTH},
{"LastConnectionError", &DMREAD, DMT_STRING, get_PPPInterface_LastConnectionError, NULL, BBFDM_BOTH},
{"Username", &DMWRITE, DMT_STRING, get_ppp_username, set_ppp_username, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_ppp_password, BBFDM_BOTH},
{"Password", &DMWRITE, DMT_STRING, get_ppp_password, set_ppp_password, BBFDM_BOTH, DM_FLAG_SECURE},
{"Reset()", &DMSYNC, DMT_COMMAND, NULL, operate_PPPInterface_Reset, BBFDM_USP},
{"MaxMRUSize", &DMWRITE, DMT_UNINT, get_PPPInterface_MaxMRUSize, set_PPPInterface_MaxMRUSize, BBFDM_BOTH},
{"CurrentMRUSize", &DMREAD, DMT_UNINT, get_PPPInterface_CurrentMRUSize, NULL, BBFDM_BOTH},

View file

@ -1752,6 +1752,17 @@ static int set_access_point_security_modes(char *refparam, struct dmctx *ctx, vo
return 0;
}
static int get_access_point_security_wepkey(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *key_index = NULL, buf[16];
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", &key_index);
snprintf(buf, sizeof(buf),"key%s", DM_STRLEN(key_index) ? key_index : "1");
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, buf, value);
return 0;
}
static int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *map_s = NULL;
@ -1776,7 +1787,7 @@ static int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, v
char *key_index = NULL, buf[16];
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", &key_index);
snprintf(buf, sizeof(buf),"key%s", key_index ? key_index : "1");
snprintf(buf, sizeof(buf),"key%s", DM_STRLEN(key_index) ? key_index : "1");
// wireless config: Update key option
dmuci_set_value_by_section((((struct wifi_acp_args *)data)->sections)->config_section, buf, value);
@ -1790,6 +1801,12 @@ static int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, v
return 0;
}
static int get_access_point_security_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", value);
return 0;
}
static int set_access_point_security_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *map_s = NULL;
@ -1825,6 +1842,12 @@ static int set_access_point_security_shared_key(char *refparam, struct dmctx *ct
return 0;
}
static int get_access_point_security_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", value);
return 0;
}
static int set_access_point_security_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -1869,6 +1892,12 @@ static int set_access_point_security_rekey_interval(char *refparam, struct dmctx
}
/*#Device.WiFi.AccessPoint.{i}.Security.SAEPassphrase!UCI:wireless/wifi-iface,@i-1/key*/
static int get_WiFiAccessPointSecurity_SAEPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "key", value);
return 0;
}
static int set_WiFiAccessPointSecurity_SAEPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *map_s = NULL;
@ -1953,6 +1982,12 @@ static int set_access_point_security_radius_server_port(char *refparam, struct d
return 0;
}
static int get_access_point_security_radius_secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "auth_secret", value);
return 0;
}
static int set_access_point_security_radius_secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -2211,6 +2246,13 @@ static int set_WiFiAccessPointAccounting_ServerPort(char *refparam, struct dmctx
return 0;
}
/*#Device.WiFi.AccessPoint.{i}.Accounting.Secret!UCI:wireless/wifi-iface,@i-1/acct_secret*/
static int get_WiFiAccessPointAccounting_Secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((((struct wifi_acp_args *)data)->sections)->config_section, "acct_secret", value);
return 0;
}
static int set_WiFiAccessPointAccounting_Secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
@ -2469,6 +2511,17 @@ static int set_WiFiEndPointProfileSecurity_ModeEnabled(char *refparam, struct dm
return 0;
}
static int get_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *key_index = NULL, buf[16];
dmuci_get_value_by_section_string((struct uci_section*)data, "key", &key_index);
snprintf(buf, sizeof(buf),"key%s", DM_STRLEN(key_index) ? key_index : "1");
dmuci_get_value_by_section_string((struct uci_section*)data, buf, value);
return 0;
}
static int set_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -2484,7 +2537,7 @@ static int set_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *
char *key_index = NULL, buf[16];
dmuci_get_value_by_section_string((struct uci_section*)data, "key", &key_index);
snprintf(buf, sizeof(buf),"key%s", key_index ? key_index : "1");
snprintf(buf, sizeof(buf),"key%s", DM_STRLEN(key_index) ? key_index : "1");
dmuci_set_value_by_section((struct uci_section*)data, buf, value);
}
return 0;
@ -2492,6 +2545,12 @@ static int set_WiFiEndPointProfileSecurity_WEPKey(char *refparam, struct dmctx *
return 0;
}
static int get_WiFiEndPointProfileSecurity_PreSharedKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section*)data, "key", value);
return 0;
}
static int set_WiFiEndPointProfileSecurity_PreSharedKey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -2510,6 +2569,12 @@ static int set_WiFiEndPointProfileSecurity_PreSharedKey(char *refparam, struct d
return 0;
}
static int get_WiFiEndPointProfileSecurity_KeyPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section*)data, "key", value);
return 0;
}
static int set_WiFiEndPointProfileSecurity_KeyPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -2529,6 +2594,12 @@ static int set_WiFiEndPointProfileSecurity_KeyPassphrase(char *refparam, struct
}
/*#Device.WiFi.EndPoint.{i}.Profile.{i}.Security.SAEPassphrase!UCI:wireless/wifi-iface,@i-1/key*/
static int get_WiFiEndPointProfileSecurity_SAEPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string((struct uci_section*)data, "key", value);
return 0;
}
static int set_WiFiEndPointProfileSecurity_SAEPassphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *encryption;
@ -4040,14 +4111,14 @@ DMLEAF tWiFiAccessPointSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ModesSupported", &DMREAD, DMT_STRING, get_access_point_security_supported_modes, NULL, BBFDM_BOTH},
{"ModeEnabled", &DMWRITE, DMT_STRING, get_access_point_security_modes, set_access_point_security_modes, BBFDM_BOTH},
{"WEPKey", &DMWRITE, DMT_HEXBIN, get_empty, set_access_point_security_wepkey, BBFDM_BOTH},
{"PreSharedKey", &DMWRITE, DMT_HEXBIN, get_empty, set_access_point_security_shared_key, BBFDM_BOTH},
{"KeyPassphrase", &DMWRITE, DMT_STRING, get_empty, set_access_point_security_passphrase, BBFDM_BOTH},
{"WEPKey", &DMWRITE, DMT_HEXBIN, get_access_point_security_wepkey, set_access_point_security_wepkey, BBFDM_BOTH, DM_FLAG_SECURE},
{"PreSharedKey", &DMWRITE, DMT_HEXBIN, get_access_point_security_shared_key, set_access_point_security_shared_key, BBFDM_BOTH, DM_FLAG_SECURE},
{"KeyPassphrase", &DMWRITE, DMT_STRING, get_access_point_security_passphrase, set_access_point_security_passphrase, BBFDM_BOTH, DM_FLAG_SECURE},
{"RekeyingInterval", &DMWRITE, DMT_UNINT, get_access_point_security_rekey_interval, set_access_point_security_rekey_interval, BBFDM_BOTH},
{"SAEPassphrase", &DMWRITE, DMT_STRING, get_empty, set_WiFiAccessPointSecurity_SAEPassphrase, BBFDM_BOTH},
{"SAEPassphrase", &DMWRITE, DMT_STRING, get_WiFiAccessPointSecurity_SAEPassphrase, set_WiFiAccessPointSecurity_SAEPassphrase, BBFDM_BOTH, DM_FLAG_SECURE},
{"RadiusServerIPAddr", &DMWRITE, DMT_STRING, get_access_point_security_radius_ip_address, set_access_point_security_radius_ip_address, BBFDM_BOTH},
{"RadiusServerPort", &DMWRITE, DMT_UNINT, get_access_point_security_radius_server_port, set_access_point_security_radius_server_port, BBFDM_BOTH},
{"RadiusSecret", &DMWRITE, DMT_STRING, get_empty, set_access_point_security_radius_secret, BBFDM_BOTH},
{"RadiusSecret", &DMWRITE, DMT_STRING, get_access_point_security_radius_secret, set_access_point_security_radius_secret, BBFDM_BOTH, DM_FLAG_SECURE},
{"MFPConfig", &DMWRITE, DMT_STRING, get_WiFiAccessPointSecurity_MFPConfig, set_WiFiAccessPointSecurity_MFPConfig, BBFDM_BOTH},
{"Reset()", &DMSYNC, DMT_COMMAND, NULL, operate_WiFiAccessPointSecurity_Reset, BBFDM_USP},
{0}
@ -4061,7 +4132,7 @@ DMLEAF tWiFiAccessPointWPSParams[] = {
{"ConfigMethodsEnabled", &DMWRITE, DMT_STRING, get_WiFiAccessPointWPS_ConfigMethodsEnabled, set_WiFiAccessPointWPS_ConfigMethodsEnabled, BBFDM_BOTH},
{"Status", &DMREAD, DMT_STRING, get_WiFiAccessPointWPS_Status, NULL, BBFDM_BOTH},
//{"Version", &DMREAD, DMT_STRING, get_WiFiAccessPointWPS_Version, NULL, BBFDM_BOTH},
//{"PIN", &DMWRITE, DMT_STRING, get_empty, set_WiFiAccessPointWPS_PIN, BBFDM_BOTH},
//{"PIN", &DMWRITE, DMT_STRING, get_WiFiAccessPointWPS_PIN, set_WiFiAccessPointWPS_PIN, BBFDM_BOTH, DM_FLAG_SECURE},
{"InitiateWPSPBC()", &DMASYNC, DMT_COMMAND, get_operate_args_WiFiAccessPointWPS_InitiateWPSPBC, operate_WiFiAccessPointWPS_InitiateWPSPBC, BBFDM_USP},
{0}
};
@ -4109,7 +4180,7 @@ DMLEAF tWiFiAccessPointAccountingParams[] = {
//{"SecondaryServerIPAddr", &DMWRITE, DMT_STRING, get_WiFiAccessPointAccounting_SecondaryServerIPAddr, set_WiFiAccessPointAccounting_SecondaryServerIPAddr, BBFDM_BOTH},
{"ServerPort", &DMWRITE, DMT_UNINT, get_WiFiAccessPointAccounting_ServerPort, set_WiFiAccessPointAccounting_ServerPort, BBFDM_BOTH},
//{"SecondaryServerPort", &DMWRITE, DMT_UNINT, get_WiFiAccessPointAccounting_SecondaryServerPort, set_WiFiAccessPointAccounting_SecondaryServerPort, BBFDM_BOTH},
{"Secret", &DMWRITE, DMT_STRING, get_empty, set_WiFiAccessPointAccounting_Secret, BBFDM_BOTH},
{"Secret", &DMWRITE, DMT_STRING, get_WiFiAccessPointAccounting_Secret, set_WiFiAccessPointAccounting_Secret, BBFDM_BOTH, DM_FLAG_SECURE},
//{"SecondarySecret", &DMWRITE, DMT_STRING, get_WiFiAccessPointAccounting_SecondarySecret, set_WiFiAccessPointAccounting_SecondarySecret, BBFDM_BOTH},
//{"InterimInterval", &DMWRITE, DMT_UNINT, get_WiFiAccessPointAccounting_InterimInterval, set_WiFiAccessPointAccounting_InterimInterval, BBFDM_BOTH},
{0}
@ -4175,10 +4246,10 @@ DMLEAF tWiFiEndPointProfileParams[] = {
DMLEAF tWiFiEndPointProfileSecurityParams[] = {
/* PARAM, permission, type, getvalue, setvalue, bbfdm_type, version*/
{"ModeEnabled", &DMWRITE, DMT_STRING, get_WiFiEndPointProfileSecurity_ModeEnabled, set_WiFiEndPointProfileSecurity_ModeEnabled, BBFDM_BOTH},
{"WEPKey", &DMWRITE, DMT_HEXBIN, get_empty, set_WiFiEndPointProfileSecurity_WEPKey, BBFDM_BOTH},
{"PreSharedKey", &DMWRITE, DMT_HEXBIN, get_empty, set_WiFiEndPointProfileSecurity_PreSharedKey, BBFDM_BOTH},
{"KeyPassphrase", &DMWRITE, DMT_STRING, get_empty, set_WiFiEndPointProfileSecurity_KeyPassphrase, BBFDM_BOTH},
{"SAEPassphrase", &DMWRITE, DMT_STRING, get_empty, set_WiFiEndPointProfileSecurity_SAEPassphrase, BBFDM_BOTH},
{"WEPKey", &DMWRITE, DMT_HEXBIN, get_WiFiEndPointProfileSecurity_WEPKey, set_WiFiEndPointProfileSecurity_WEPKey, BBFDM_BOTH, DM_FLAG_SECURE},
{"PreSharedKey", &DMWRITE, DMT_HEXBIN, get_WiFiEndPointProfileSecurity_PreSharedKey, set_WiFiEndPointProfileSecurity_PreSharedKey, BBFDM_BOTH, DM_FLAG_SECURE},
{"KeyPassphrase", &DMWRITE, DMT_STRING, get_WiFiEndPointProfileSecurity_KeyPassphrase, set_WiFiEndPointProfileSecurity_KeyPassphrase, BBFDM_BOTH, DM_FLAG_SECURE},
{"SAEPassphrase", &DMWRITE, DMT_STRING, get_WiFiEndPointProfileSecurity_SAEPassphrase, set_WiFiEndPointProfileSecurity_SAEPassphrase, BBFDM_BOTH, DM_FLAG_SECURE},
{"MFPConfig", &DMWRITE, DMT_STRING, get_WiFiEndPointProfileSecurity_MFPConfig, set_WiFiEndPointProfileSecurity_MFPConfig, BBFDM_BOTH},
{0}
};