Fix memory leaks and all warnings

This commit is contained in:
Amin Ben Ramdhane 2019-11-11 10:45:05 +01:00
parent 8b6a24669f
commit 8ab504585c
19 changed files with 180 additions and 165 deletions

View file

@ -50,6 +50,7 @@
static char *get_parameter_notification(struct dmctx *ctx, char *param);
static int remove_parameter_notification(char *param);
static int set_parameter_notification(struct dmctx *ctx, char *param,char *value);
int dm_browse(struct dmctx *dmctx, DMNODE *parent_node, DMOBJ *entryobj, void *data, char *instance);
static int get_value_obj(DMOBJECT_ARGS);
static int get_value_param(DMPARAM_ARGS);
static int mobj_get_value_in_param(DMOBJECT_ARGS);

View file

@ -1033,7 +1033,8 @@ struct uci_section *get_dup_section_in_dmmap_opt(char *dmmap_package, char *sect
return NULL;
}
struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char* opt_value){
struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char* opt_value)
{
struct uci_section *s;
char *v;
@ -1304,7 +1305,19 @@ bool synchronize_multi_config_sections_with_dmmap_eq_diff(char *package, char *s
return found;
}
void synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list)
void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_section *dmmap_section, char *file_name, char* filepath)
{
struct sysfs_dmsection *dmmap_sysfs;
struct list_head *ilist;
dmmap_sysfs = dmcalloc(1, sizeof(struct sysfs_dmsection));
list_add_tail(&dmmap_sysfs->list, dup_list);
dmmap_sysfs->dm = dmmap_section;
dmmap_sysfs->sysfs_folder_name= dmstrdup(file_name);
dmmap_sysfs->sysfs_folder_path= dmstrdup(filepath);
}
int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
@ -1362,9 +1375,11 @@ void synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_packa
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
}
}
return 0;
}
void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section){
void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section)
{
struct uci_section* s;
uci_path_foreach_option_eq(bbfdm, dmmap_package, section_type, "section_name", section_name, s){
@ -1446,7 +1461,7 @@ void delete_sections_save_next_sections(char* dmmap_package, char *section_type,
char *v=NULL, *lsectname= NULL, *tmp= NULL;
int inst;
asprintf(&lsectname, "%s", section_name);
dmasprintf(&lsectname, "%s", section_name);
uci_path_foreach_sections(bbfdm, dmmap_package, section_type, s) {
dmuci_get_value_by_section_string(s, instancename, &v);
@ -1454,15 +1469,15 @@ void delete_sections_save_next_sections(char* dmmap_package, char *section_type,
if(inst>instance){
dmuci_get_value_by_section_string(s, "section_name", &tmp);
add_dmmap_list_section(dup_list, lsectname, v);
free(lsectname);
dmfree(lsectname);
lsectname= NULL;
asprintf(&lsectname, "%s", tmp);
free(tmp);
dmasprintf(&lsectname, "%s", tmp);
dmfree(tmp);
tmp= NULL;
}
}
if(lsectname != NULL) free(lsectname);
if(lsectname != NULL) dmfree(lsectname);
uci_path_foreach_sections_safe(bbfdm, dmmap_package, section_type, stmp, s) {
@ -1735,7 +1750,7 @@ int command_exec_output_to_array(char *cmd, char **output, int *length)
/* Read the output line by line and store it in output array. */
while (fgets(out, sizeof(out)-1, fp) != NULL)
asprintf(&output[i++], "%s", out);
dmasprintf(&output[i++], "%s", out);
*length = i;
@ -1813,7 +1828,7 @@ char* readFileContent(char *filepath)
long fsize = ftell(f);
fseek(f, 0, SEEK_SET); //same as rewind(f);
char *filecontent = malloc(fsize + 1);
char *filecontent = dmmalloc(fsize + 1);
fread(filecontent, 1, fsize, f);
fclose(f);
@ -1834,16 +1849,16 @@ char* readFileContent(char *filepath)
j++;
dmasprintf(&str, "%s%c", tmp, filecontent[i]);
if(tmp){
free(tmp);
dmfree(tmp);
tmp= NULL;
}
tmp= dmstrdup(str);
if(str!=NULL){
free(str);
dmfree(str);
str= NULL;
}
}
res= (char *)malloc((j+1)*sizeof(char));
res= (char *)dmmalloc((j+1)*sizeof(char));
strcpy(res, tmp);
res[j]= 0;
return res;

View file

@ -79,7 +79,6 @@ do { \
if ((dir = opendir(path)) == NULL) return 0; \
while ((ent = readdir (dir)) != NULL) \
enum notification_enum {
notification_none,
notification_passive,
@ -196,7 +195,8 @@ void synchronize_specific_config_sections_with_dmmap_eq_no_delete(char *package,
void synchronize_specific_config_sections_with_dmmap_cont(char *package, char *section_type, char *dmmap_package,char* option_name, char* option_value, struct list_head *dup_list);
bool synchronize_multi_config_sections_with_dmmap_eq(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, void* additional_attribute, struct list_head *dup_list);
bool synchronize_multi_config_sections_with_dmmap_eq_diff(char *package, char *section_type, char *dmmap_package, char* dmmap_section, char* option_name, char* option_value, char* opt_diff_name, char* opt_diff_value, void* additional_attribute, struct list_head *dup_list);
void synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list);
void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_section *dmmap_section, char *file_name, char* filepath);
int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, struct list_head *dup_list);
void get_dmmap_section_of_config_section(char* dmmap_package, char* section_type, char *section_name, struct uci_section **dmmap_section);
void get_dmmap_section_of_config_section_eq(char* dmmap_package, char* section_type, char *opt, char* value, struct uci_section **dmmap_section);
void get_config_section_of_dmmap_section(char* package, char* section_type, char *section_name, struct uci_section **config_section);
@ -212,6 +212,7 @@ char *get_device(char *ifname);
int is_elt_exit_in_str_list(char *str_list, char *elt);
void add_elt_to_str_list(char **str_list, char *elt);
void remove_elt_from_str_list(char **iface_list, char *ifname);
struct uci_section *get_dup_section_in_dmmap_opt(char *dmmap_package, char *section_type, char *opt_name, char *opt_value);
struct uci_section *get_dup_section_in_dmmap_eq(char *dmmap_package, char* section_type, char*sect_name, char *opt_name, char* opt_value);
int is_array_elt_exist(char **str_array, char *str, int length);
int get_shift_time_time(int shift_time, char *local_time, int size);
@ -225,4 +226,5 @@ struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char
int isfileexist(char *filepath);
int isfolderexist(char *folderpath);
char* readFileContent(char *filepath);
void writeFileContent(const char *filepath, const char *data);
#endif

View file

@ -56,6 +56,42 @@ static int get_stats_folder(char *folder_path, int *file_count, unsigned long *s
return 0;
}
void add_json_data_to_list(struct list_head *dup_list, char *name, char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6)
{
struct dm_json_parameter *dm_json_parameter;
dm_json_parameter = dmcallocjson(1, sizeof(struct dm_json_parameter));
list_add_tail(&dm_json_parameter->list, dup_list);
if(name) dm_json_parameter->name = dmstrdupjson(name);
if (arg1) dm_json_parameter->arg1 = dmstrdupjson(arg1);
if (arg2) dm_json_parameter->arg2 = dmstrdupjson(arg2);
if (arg3) dm_json_parameter->arg3 = dmstrdupjson(arg3);
if (arg4) dm_json_parameter->arg4 = dmstrdupjson(arg4);
if (arg5) dm_json_parameter->arg5 = dmstrdupjson(arg5);
if (arg6) dm_json_parameter->arg6 = dmstrdupjson(arg6);
}
void delete_json_data_from_list(struct dm_json_parameter *dm_json_parameter)
{
list_del(&dm_json_parameter->list);
if (dm_json_parameter->name) dmfreejson(dm_json_parameter->name);
if (dm_json_parameter->arg1) dmfreejson(dm_json_parameter->arg1);
if (dm_json_parameter->arg2) dmfreejson(dm_json_parameter->arg2);
if (dm_json_parameter->arg3) dmfreejson(dm_json_parameter->arg3);
if (dm_json_parameter->arg4) dmfreejson(dm_json_parameter->arg4);
if (dm_json_parameter->arg5) dmfreejson(dm_json_parameter->arg5);
if (dm_json_parameter->arg6) dmfreejson(dm_json_parameter->arg6);
if (dm_json_parameter) dmfreejson(dm_json_parameter);
}
void free_json_data_from_list(struct list_head *dup_list)
{
struct dm_json_parameter *dm_json_parameter;
while (dup_list->next != dup_list) {
dm_json_parameter = list_entry(dup_list->next, struct dm_json_parameter, list);
delete_json_data_from_list(dm_json_parameter);
}
}
int dm_browse_node_object_tree(DMNODE *parent_node, DMOBJ *entryobj)
{
if (!entryobj)
@ -273,42 +309,6 @@ int check_root_obj(struct dmctx *ctx, char *in_param_json, DMOBJ **root_entry)
return 0;
}
void add_json_data_to_list(struct list_head *dup_list, char *name, char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6)
{
struct dm_json_parameter *dm_json_parameter;
dm_json_parameter = dmcallocjson(1, sizeof(struct dm_json_parameter));
list_add_tail(&dm_json_parameter->list, dup_list);
if(name) dm_json_parameter->name = dmstrdupjson(name);
if (arg1) dm_json_parameter->arg1 = dmstrdupjson(arg1);
if (arg2) dm_json_parameter->arg2 = dmstrdupjson(arg2);
if (arg3) dm_json_parameter->arg3 = dmstrdupjson(arg3);
if (arg4) dm_json_parameter->arg4 = dmstrdupjson(arg4);
if (arg5) dm_json_parameter->arg5 = dmstrdupjson(arg5);
if (arg6) dm_json_parameter->arg6 = dmstrdupjson(arg6);
}
void delete_json_data_from_list(struct dm_json_parameter *dm_json_parameter)
{
list_del(&dm_json_parameter->list);
if (dm_json_parameter->name) dmfreejson(dm_json_parameter->name);
if (dm_json_parameter->arg1) dmfreejson(dm_json_parameter->arg1);
if (dm_json_parameter->arg2) dmfreejson(dm_json_parameter->arg2);
if (dm_json_parameter->arg3) dmfreejson(dm_json_parameter->arg3);
if (dm_json_parameter->arg4) dmfreejson(dm_json_parameter->arg4);
if (dm_json_parameter->arg5) dmfreejson(dm_json_parameter->arg5);
if (dm_json_parameter->arg6) dmfreejson(dm_json_parameter->arg6);
if (dm_json_parameter) dmfreejson(dm_json_parameter);
}
void free_json_data_from_list(struct list_head *dup_list)
{
struct dm_json_parameter *dm_json_parameter;
while (dup_list->next != dup_list) {
dm_json_parameter = list_entry(dup_list->next, struct dm_json_parameter, list);
delete_json_data_from_list(dm_json_parameter);
}
}
int browse_obj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
//UCI: arg1=type :: arg2=uci_file :: arg3=uci_section_type :: arg4=uci_dmmap_file :: arg5="" :: arg6=""
@ -384,8 +384,8 @@ static int add_obj(char *refparam, struct dmctx *ctx, void *data, char **instanc
}
if(arg2 && arg3 && arg4) {
char *inst = NULL, *sect_name = NULL;
struct uci_section *section = NULL, *dmmap = NULL, *v;
char *inst = NULL, *sect_name = NULL, *v;
struct uci_section *section = NULL, *dmmap = NULL;
check_create_dmmap_package(arg4);
inst = get_last_instance_bbfdm(arg4, arg3, buf_instance);

View file

@ -34,6 +34,7 @@ json_object *dmjson_select_obj(json_object * jobj, char *argv[]);
json_object *__dmjson_get_obj(json_object *mainjobj, int argc, ...);
char *____dmjson_get_value_in_obj(json_object *mainjobj, char *argv[]);
char *__dmjson_get_value_in_obj(json_object *mainjobj, int argc, ...);
char *__dmjson_get_value_in_array_idx(json_object *mainjobj, json_object **arrobj, char *defret, int index, int argc, ...);
json_object *__dmjson_select_obj_in_array_idx(json_object *mainjobj, json_object **arrobj, int index, int argc, ...);
char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, char *argv[]);

View file

@ -78,7 +78,7 @@ int __dmasprintfjson(char **s, const char *format, ...)
va_start(arg,format);
ret = vsprintf(buf, format, arg);
va_end(arg);
*s = __dmstrdup(buf);
*s = __dmstrdupjson(buf);
if (*s == NULL) return -1;
return 0;
}

View file

@ -100,7 +100,7 @@ DMOBJ tRoot181ObjUPNPBBF[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker, bbfdm_type*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL, BBFDM_BOTH, BBFDM_BOTH},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL, BBFDM_BOTH},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL, BBFDM_BOTH},
#if BBF_TR104
{"VoiceService", &DMREAD, NULL, NULL, NULL, browseVoiceServiceInst, NULL, NULL, tVoiceServiceObj, tVoiceServiceParam, NULL, BBFDM_BOTH},
@ -113,7 +113,7 @@ DMOBJ tRoot181ObjUPNPBBF[] = {
{CUSTOM_PREFIX"SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL, BBFDM_BOTH},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIopsysEuOwsdObj, XIopsysEuOwsdParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH, BBFDM_BOTH},
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, &DMNONE, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, &DMNONE, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL, BBFDM_BOTH},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWifiObj, NULL, NULL, BBFDM_BOTH},

View file

@ -148,7 +148,7 @@ DMLEAF tServicesVoiceServiceVoiceProfileSIPParams[] = {
{"UserAgentTransport", &DMWRITE, DMT_STRING, get_sip_user_agent_transport, set_sip_user_agent_transport, NULL, NULL, BBFDM_BOTH},
{"OutboundProxy", &DMWRITE, DMT_STRING, get_sip_outbound_proxy, set_sip_outbound_proxy, NULL, NULL, BBFDM_BOTH},
{"OutboundProxyPort", &DMWRITE, DMT_UNINT, get_sip_outbound_proxy_port, set_sip_outbound_proxy_port, NULL, NULL, BBFDM_BOTH},
{"RegistrationPeriod", &DMWRITE, DMT_UNINT, get_sip_registration_period, set_sip_registration_period, NULL, NULL, BBFDM_BOTH, BBFDM_BOTH},
{"RegistrationPeriod", &DMWRITE, DMT_UNINT, get_sip_registration_period, set_sip_registration_period, NULL, NULL, BBFDM_BOTH},
{"ReInviteExpires", &DMWRITE, DMT_UNINT, get_sip_re_invite_expires, set_sip_re_invite_expires, NULL, NULL, BBFDM_BOTH},
{"RegisterExpires", &DMWRITE, DMT_UNINT, get_sip_re_invite_expires, set_sip_re_invite_expires, NULL, NULL, BBFDM_BOTH},
{"RegisterRetryInterval", &DMWRITE, DMT_UNINT, get_sip_re_invite_expires, set_sip_re_invite_expires, NULL, NULL, BBFDM_BOTH},
@ -486,8 +486,7 @@ int add_profile_object(char *refparam, struct dmctx *ctx, void *data, char **ins
int delete_associated_line_instances(char *sip_id, char* profile_key)
{
struct uci_section *s;
char *stmp;
struct uci_section *s = NULL, *stmp = NULL;
uci_foreach_option_eq("voice_client", "tel_line", "sip_account", sip_id, s) {
dmuci_set_value_by_section(s, "sip_account", "-");

View file

@ -18,10 +18,10 @@
#include <sys/klog.h>
#include "dmbbf.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "deviceinfo.h"
#include "dmjson.h"
#include "dmubus.h"
/* *** Device.DeviceInfo. *** */
DMOBJ tDeviceInfoObj[] = {
@ -134,7 +134,6 @@ inline int init_process_args(struct process_args *args, char *pid, char *command
return 0;
}
/*
*DeviceInfo. functions
*/
@ -606,7 +605,8 @@ int get_vlf_persistent(char *refparam, struct dmctx *ctx, void *data, char *inst
}
/*#Device.DeviceInfo.MemoryStatus.Total!UBUS:router.system/info//memoryKB.total*/
int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
@ -615,7 +615,8 @@ int get_memory_status_total(char* refparam, struct dmctx *ctx, void *data, char
}
/*#Device.DeviceInfo.MemoryStatus.Free!UBUS:router.system/info//memoryKB.free*/
int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
@ -624,7 +625,8 @@ int get_memory_status_free(char* refparam, struct dmctx *ctx, void *data, char *
}
/*#Device.DeviceInfo.ProcessStatus.CPUUsage!UBUS:router.system/info//system.cpu_per*/
int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
@ -632,37 +634,42 @@ int get_process_cpu_usage(char* refparam, struct dmctx *ctx, void *data, char *i
return 0;
}
int get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_number_of_entries(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res, *processes;
int nbre_process = 0;
dmubus_call("router.system", "processes", UBUS_ARGS{{}}, 0, &res);
processes = json_object_object_get(res, "processes");
json_object_object_get_ex(res, "processes", &processes);
nbre_process= json_object_array_length(processes);
dmasprintf(value,"%d",nbre_process);
return 0;
}
int get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_pid(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
*value= proc_args->pid;
return 0;
}
int get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_command(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
*value= proc_args->command;
return 0;
}
int get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_size(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
if(proc_args->size!=NULL) *value= proc_args->size;
else *value= "0";
return 0;
}
int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
long val;
@ -675,13 +682,15 @@ int get_process_priority(char* refparam, struct dmctx *ctx, void *data, char *in
return 0;
}
int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_cpu_time(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
if(proc_args->cputime!=NULL) *value= proc_args->cputime;
return 0;
}
int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value){
int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct process_args *proc_args= (struct process_args*) data;
if(strchr(proc_args->state, 'S')!=NULL) *value="Sleeping";
else if(strchr(proc_args->state, 'R')!=NULL) *value= "Running";
@ -693,15 +702,16 @@ int get_process_state(char* refparam, struct dmctx *ctx, void *data, char *insta
return 0;
}
int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance){
int browsePocessEntriesInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res, *processes, *fields, *process;
char *pid_field, *command_field, *state_field, *mem_size_field, *cpu_time_field, *priority_field, *pid, *command, *mem_size, *state, *cpu_time, *priority, *idx, *idx_last= NULL;
int i, id=0;
struct process_args proc_args={};
dmubus_call("router.system", "processes", UBUS_ARGS{{}}, 0, &res);
fields = json_object_object_get(res, "fields");
processes = json_object_object_get(res, "processes");
json_object_object_get_ex(res, "fields", &fields);
json_object_object_get_ex(res, "processes", &processes);
size_t nbre_process = json_object_array_length(processes);
pid_field = (char *)dmjson_get_value_in_array_idx(fields, 0, 0, NULL);
command_field = (char *)dmjson_get_value_in_array_idx(fields, 7, 0, NULL);

View file

@ -3095,7 +3095,7 @@ int browseDhcpClientIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *pre
break;
}
}
fclose(fp);
return 0;
}
@ -3196,10 +3196,10 @@ int browseDHCPv4ClientSentOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
if(lgh2>2){
for(j=2; j<lgh2; j++){
tmp=dmstrdup(optionvalue);
free(optionvalue);
dmfree(optionvalue);
optionvalue= NULL;
dmasprintf(&optionvalue, "%s:%s", tmp, buf[j]);
free(tmp);
dmfree(tmp);
tmp= NULL;
}
}
@ -3281,10 +3281,10 @@ int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
if(length>2){
for(j=2; j<length; j++){
tmp=dmstrdup(optionvalue);
free(optionvalue);
dmfree(optionvalue);
optionvalue= NULL;
dmasprintf(&optionvalue, "%s,%s", tmp, tagvalue[j]);
free(tmp);
dmfree(tmp);
tmp= NULL;
}
}
@ -3294,10 +3294,10 @@ int browseDHCPv4ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
uci_path_foreach_option_eq(bbfdm, "dmmap_dhcp", "servpool_option", "section_name", section_name(curr_dhcp_args->dhcp_sec), dmmap_sect) {
dmuci_get_value_by_section_string(dmmap_sect, "option_tag", &v1);
dmuci_get_value_by_section_string(dmmap_sect, "option_value", &v2);
dhcp_client_opt_args.client_sect= curr_dhcp_args->dhcp_sec;
dhcp_client_opt_args.option_tag= strdup(v1);
dhcp_client_opt_args.value= strdup(v2);
dhcp_client_opt_args.opt_sect= dmmap_sect;
dhcp_client_opt_args.client_sect = curr_dhcp_args->dhcp_sec;
dhcp_client_opt_args.option_tag = dmstrdup(v1);
dhcp_client_opt_args.value = dmstrdup(v2);
dhcp_client_opt_args.opt_sect = dmmap_sect;
instance= handle_update_instance(1, dmctx, &instnbr, update_instance_alias_bbfdm, 3, dmmap_sect, "bbf_dhcpv4_servpool_option_instance", "bbf_dhcpv4_servpool_option_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, &dhcp_client_opt_args, instance) == DM_STOP)
break;

View file

@ -273,31 +273,22 @@ inline int init_dhcpv6_args(struct dhcpv6_args *args, struct uci_section *s, cha
/*#Device.DHCPv6.Client.{i}.!UCI:network/interface/dmmap_dhcpv6*/
int browseDHCPv6ClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s = NULL;
struct dmmap_dup *p;
struct dhcpv6_client_args dhcpv6_client_arg = {0};
json_object *res, *jobj;
char *instance, *instnbr = NULL, *proto= NULL, *ipv6addr;
char *instance, *instnbr = NULL, *ipv6addr;
LIST_HEAD(dup_list);
synchronize_specific_config_sections_with_dmmap_eq_no_delete("network", "interface", "dmmap_dhcpv6", "proto", "dhcpv6", &dup_list);
list_for_each_entry(p, &dup_list, list) {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(p->config_section), String}}, 1, &res);
if (res)
{
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv6-address");
ipv6addr = dmjson_get_value(jobj, 1, "address");
}
dhcpv6_client_arg.dhcp_client_conf = p->config_section;
dhcpv6_client_arg.dhcp_client_dm= p->dmmap_section;
dhcpv6_client_arg.ip= strdup(ipv6addr?ipv6addr:"");
dhcpv6_client_arg.dhcp_client_dm = p->dmmap_section;
dhcpv6_client_arg.ip = dmstrdup(ipv6addr?ipv6addr:"");
instance = handle_update_instance(1, dmctx, &instnbr, update_instance_alias, 3, p->dmmap_section, "bbf_dhcpv6client_instance", "bbf_dhcpv6client_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, &dhcpv6_client_arg, instance) == DM_STOP)
break;
@ -408,10 +399,10 @@ int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
if(length>2){
for(j=2; j<length; j++){
tmp=dmstrdup(optionvalue);
free(optionvalue);
dmfree(optionvalue);
optionvalue= NULL;
dmasprintf(&optionvalue, "%s,%s", tmp, tagvalue[j]);
free(tmp);
dmfree(tmp);
tmp= NULL;
}
}
@ -422,9 +413,9 @@ int browseDHCPv6ServerPoolOptionInst(struct dmctx *dmctx, DMNODE *parent_node, v
dmuci_get_value_by_section_string(dmmap_sect, "option_tag", &v1);
dmuci_get_value_by_section_string(dmmap_sect, "option_value", &v2);
dhcp_client_opt_args.client_sect= curr_dhcp_args->dhcp_sec;
dhcp_client_opt_args.option_tag= strdup(v1);
dhcp_client_opt_args.value= strdup(v2);
dhcp_client_opt_args.opt_sect= dmmap_sect;
dhcp_client_opt_args.option_tag = dmstrdup(v1);
dhcp_client_opt_args.value = dmstrdup(v2);
dhcp_client_opt_args.opt_sect = dmmap_sect;
instance= handle_update_instance(1, dmctx, &instnbr, update_instance_alias_bbfdm, 3, dmmap_sect, "bbf_dhcpv6_servpool_option_instance", "bbf_dhcpv6_servpool_option_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, &dhcp_client_opt_args, instance) == DM_STOP)
break;

View file

@ -317,8 +317,8 @@ int add_relay_forwarding(char *refparam, struct dmctx *ctx, void *data, char **i
int delete_client_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL;
char *interface, *ip, *str, *stmp;
struct uci_section *s = NULL, *ss = NULL, *stmp = NULL;
char *interface, *ip, *str;
struct uci_list *v;
struct uci_element *e, *tmp;
@ -354,8 +354,8 @@ int delete_client_server(char *refparam, struct dmctx *ctx, void *data, char *in
int delete_relay_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL, *ss = NULL;
char *interface, *ip, *str, *stmp;
struct uci_section *s = NULL, *ss = NULL, *stmp = NULL;
char *interface, *ip, *str;
struct uci_list *v;
struct uci_element *e, *tmp;

View file

@ -677,14 +677,14 @@ int get_rule_icmp_type(char *refparam, struct dmctx *ctx, void *data, char *inst
dmuci_get_value_by_section_list((struct uci_section *)data, "icmp_type", &v);
if (v != NULL) {
uci_foreach_element(v, e) {
ptr= dmstrdup(*value);
free(*value);
ptr = dmstrdup(*value);
dmfree(*value);
if(strlen(ptr)==0)
dmasprintf(value, "%s", e->name);
else{
else {
dmasprintf(value, "%s %s", ptr, e->name);
free(ptr);
dmfree(ptr);
}
}
}

View file

@ -18,7 +18,6 @@
#include "dmentry.h"
#include "gre.h"
/* *** Device.GRE. *** */
DMOBJ tGREObj[] = {
/* OBJ, permission, addobj, delobj, checkobj, browseinstobj, forced_inform, notification, nexjsontobj, nextobj, leaf, linker, bbfdm_type*/
@ -139,6 +138,7 @@ int browseGRETunnelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_dat
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, gretun_inst) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
@ -148,10 +148,11 @@ int browseGREFilterInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_dat
return 0;
}
struct uci_section *has_tunnel_interface_route(char *interface){
struct uci_section *has_tunnel_interface_route(char *interface)
{
struct uci_section *s;
uci_foreach_option_eq("network", "route", "interface", interface, s){
uci_foreach_option_eq("network", "route", "interface", interface, s) {
return s;
}
return NULL;
@ -159,11 +160,11 @@ struct uci_section *has_tunnel_interface_route(char *interface){
int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *greiface_inst= NULL, *greiface_inst_last= NULL;
char *greiface_inst= NULL, *greiface_inst_last= NULL, *ifname= NULL;
struct dmmap_dup *p, *dm= (struct dmmap_dup *)prev_data;
LIST_HEAD(dup_list);
char *ifname= NULL;
struct uci_section *s;
LIST_HEAD(dup_list);
dmasprintf(&ifname, "@%s", section_name(dm->config_section));
synchronize_specific_config_sections_with_dmmap_eq("network", "interface", "dmmap_network", "ifname", ifname, &dup_list);
list_for_each_entry(p, &dup_list, list) {
@ -174,6 +175,7 @@ int browseGRETunnelInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)p, greiface_inst) == DM_STOP)
break;
}
free_dmmap_config_dup_list(&dup_list);
return 0;
}
@ -241,7 +243,7 @@ int delObjGRETunnel(char *refparam, struct dmctx *ctx, void *data, char *instanc
int addObjGREFilter(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
struct dmmap_dup *p, *dm= (struct dmmap_dup *)data;
struct dmmap_dup *dm = (struct dmmap_dup *)data;
return 0;
}

View file

@ -304,7 +304,7 @@ int set_nat_interface_setting_interface(char *refparam, struct dmctx *ctx, void
adm_entry_get_linker_value(ctx, pch, &iface);
if (iface) {
dmuci_add_list_value_by_section((struct uci_section *)data, "network", iface);
free(iface);
dmfree(iface);
}
}
return 0;

View file

@ -278,8 +278,6 @@ int get_linker_qos_queue(char *refparam, struct dmctx *dmctx, void *data, char *
int browseQoSClassificationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *wnum = NULL, *wnum_last = NULL;
char buf[12];
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);
@ -315,8 +313,6 @@ int browseQoSPolicerInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_da
int browseQoSQueueInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *wnum = NULL, *wnum_last = NULL;
char buf[12];
struct uci_section *s = NULL;
struct dmmap_dup *p;
LIST_HEAD(dup_list);

View file

@ -8,10 +8,12 @@
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#include <dirent.h>
#include "dmbbf.h"
#include "dmcommon.h"
#include "dmuci.h"
#include "dmentry.h"
#include "usb.h"
#include <dirent.h>
/* *** Device.USB. *** */
DMOBJ tUSBObj[] = {
@ -190,18 +192,6 @@ void init_usb_interface(struct uci_section *dm, char *iface_name, char *iface_pa
iface->statistics_path= dmstrdup(statistics_path);
}
void add_sysfs_sectons_list_paramameter(struct list_head *dup_list, struct uci_section *dmmap_section, char *file_name, char* filepath)
{
struct sysfs_dmsection *dmmap_sysfs;
struct list_head *ilist;
dmmap_sysfs = dmcalloc(1, sizeof(struct sysfs_dmsection));
list_add_tail(&dmmap_sysfs->list, dup_list);
dmmap_sysfs->dm = dmmap_section;
dmmap_sysfs->sysfs_folder_name= dmstrdup(file_name);
dmmap_sysfs->sysfs_folder_path= dmstrdup(filepath);
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
@ -229,12 +219,13 @@ int browseUSBInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_
dmasprintf(&port_link, "%s", foldersplit[0]);
DMUCI_SET_VALUE_BY_SECTION(bbfdm, p->dm, "port_link", port_link);
}
sysfs_foreach_file(netfolderpath, dir, ent){
sysfs_foreach_file(netfolderpath, dir, ent) {
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
continue;
dmasprintf(&iface_name, "%s", ent->d_name);
break;
}
if (dir) closedir(dir);
dmasprintf(&iface_path, "%s/%s", netfolderpath, iface_name);
dmasprintf(&statistics_path, "%s/statistics", iface_path);
init_usb_interface(p->dm, iface_name, iface_path, statistics_path, port_link, &iface);
@ -256,7 +247,7 @@ int browseUSBPortInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data,
struct sysfs_dmsection *p;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
check_create_dmmap_package("dmmap_usb");
synchronize_system_folders_with_dmmap_opt(SYSFS_USB_DEVICES_PATH, "dmmap_usb", "dmmap_port", "port_link", "usb_port_instance", &dup_list);
list_for_each_entry(p, &dup_list, list) {
@ -300,7 +291,7 @@ int browseUSBUSBHostsHostInst(struct dmctx *dmctx, DMNODE *parent_node, void *pr
return 0;
}
void synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, int is_root, struct list_head *dup_list)
int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dmmap_package, char *dmmap_section, char *opt_name, char* inst_opt, int is_root, struct list_head *dup_list)
{
struct uci_section *s, *stmp, *dmmap_sect;
FILE *fp;
@ -312,7 +303,7 @@ void synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dm
char *deviceClassFile= NULL, *deviceClass= NULL, *hubpath;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
LIST_HEAD(dup_list_no_inst);
@ -351,8 +342,8 @@ void synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dm
else
add_sysfs_sectons_list_paramameter(dup_list, dmmap_sect, ent->d_name, sysfs_rep_path);
}
}
if (dir) closedir(dir);
/*
* fusion two lists
*/
@ -370,6 +361,7 @@ void synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, char *dm
}
}
}
return 0;
}
int browseUSBUSBHostsHostDeviceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
@ -420,18 +412,19 @@ int browseUSBUSBHostsHostDeviceConfigurationInterfaceInst(struct dmctx *dmctx, D
{
DIR *dir;
struct dirent *ent;
struct usb_port *usb_dev= (struct usb_port*)prev_data;
struct usb_port port= {};
struct usb_port *usb_dev = (struct usb_port*)prev_data;
struct usb_port port = {};
int ret1, ret2;
char *sysfs_rep_path, *v, *instance = NULL, *instnbr = NULL;
struct uci_section *dmmap_sect;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]:[0-9][0-9]*\.[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]:[0-9][0-9]*\.[0-9]*[0-9]$", 0);
ret1 = regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]:[0-9][0-9]*\\.[0-9]*[0-9]$", 0);
ret2 = regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]:[0-9][0-9]*\\.[0-9]*[0-9]$", 0);
check_create_dmmap_package("dmmap_usb");
sysfs_foreach_file(usb_dev->folder_path, dir, ent) {
if(strcmp(ent->d_name, ".")==0 || strcmp(ent->d_name, "..")==0)
continue;
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0){
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0) {
dmasprintf(&sysfs_rep_path, "%s/%s", usb_dev->folder_path, ent->d_name);
if ((dmmap_sect = get_dup_section_in_dmmap_opt("dmmap_usb", "usb_device_conf_interface", "port_link", sysfs_rep_path)) == NULL) {
dmuci_add_section_bbfdm("dmmap_usb", "usb_device_conf_interface", &dmmap_sect, &v);
@ -441,9 +434,10 @@ int browseUSBUSBHostsHostDeviceConfigurationInterfaceInst(struct dmctx *dmctx, D
init_usb_port(dmmap_sect, ent->d_name, sysfs_rep_path, &port);
instance = handle_update_instance(1, dmctx, &instnbr, update_instance_alias_bbfdm, 3, dmmap_sect, "usb_device_conf_iface_instance", "usb_device_conf_iface_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, &port, instance) == DM_STOP)
return 0;
break;
}
}
if (dir) closedir(dir);
return 0;
}
@ -462,7 +456,7 @@ int get_USB_InterfaceNumberOfEntries(char *refparam, struct dmctx *ctx, void *da
if ((dir = opendir ("/sys/class/net")) == NULL)
return 0;
while ((ent = readdir (dir)) != NULL) {
buffer= (char*)malloc(100*sizeof(char));
buffer= (char*)dmmalloc(100*sizeof(char));
sprintf(filename, "/sys/class/net/%s", ent->d_name);
readlink (filename, buffer, size);
if(strstr(buffer, "/usb") == NULL)
@ -477,18 +471,18 @@ int get_USB_PortNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, c
{
DIR *dir;
struct dirent *ent;
int ret1, ret2, i, nbre= 0;
int ret1, ret2, nbre = 0;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret1 = regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2 = regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
sysfs_foreach_file(SYSFS_USB_DEVICES_PATH, dir, ent) {
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0 || strstr(ent->d_name, "usb") == ent->d_name)
nbre++;
}
if (dir) closedir(dir);
dmasprintf(value, "%d", nbre);
return 0;
}
@ -831,13 +825,13 @@ int get_USBUSBHosts_HostNumberOfEntries(char *refparam, struct dmctx *ctx, void
{
DIR *dir;
struct dirent *ent;
int ret, i, nbre= 0;
int nbre= 0;
sysfs_foreach_file(SYSFS_USB_DEVICES_PATH, dir, ent) {
if(strstr(ent->d_name, "usb") == ent->d_name)
nbre++;
}
if (dir) closedir(dir);
dmasprintf(value, "%d", nbre);
return 0;
}
@ -987,16 +981,17 @@ int get_USBUSBHostsHost_USBVersion(char *refparam, struct dmctx *ctx, void *data
return 0;
}
void get_number_devices(char *folderpath, int *nbre){
int get_number_devices(char *folderpath, int *nbre)
{
DIR *dir;
struct dirent *ent;
int ret1, ret2;
char *deviceClassFile= NULL, *deviceClass= NULL, *hubpath;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
sysfs_foreach_file(folderpath, dir, ent){
sysfs_foreach_file(folderpath, dir, ent) {
if(regexec(&regex1, ent->d_name, 0, NULL, 0) == 0 || regexec(&regex2, ent->d_name, 0, NULL, 0) ==0){
dmasprintf(&deviceClassFile, "%s/%s/bDeviceClass", folderpath, ent->d_name);
deviceClass= readFileContent(deviceClassFile);
@ -1007,6 +1002,8 @@ void get_number_devices(char *folderpath, int *nbre){
(*nbre)++;
}
}
if (dir) closedir(dir);
return 0;
}
int get_USBUSBHostsHost_DeviceNumberOfEntries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
@ -1144,15 +1141,15 @@ int get_USBUSBHostsHostDevice_Port(char *refparam, struct dmctx *ctx, void *data
int ret1, ret2, length;
char **busname, **portname;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2= regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret1 = regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]$", 0);
ret2 = regcomp(&regex2, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
if(regexec(&regex1, port->folder_name, 0, NULL, 0) == 0 || regexec(&regex2, port->folder_name, 0, NULL, 0) ==0){
busname= strsplit(port->folder_name, "-", &length);
portname= strsplit(busname[1], ".", &length);
*value= strdup(portname[0]);
busname = strsplit(port->folder_name, "-", &length);
portname = strsplit(busname[1], ".", &length);
*value = dmstrdup(portname[0]);
return 0;
}
*value= "0";
*value = "0";
return 0;
}
@ -1185,7 +1182,7 @@ int get_USBUSBHostsHostDevice_Parent(char *refparam, struct dmctx *ctx, void *da
struct usb_port *port= (struct usb_port*)data;
int ret1;
char *v;
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]\.[0-9]*[0-9]$", 0);
ret1= regcomp(&regex1, "^[0-9][0-9]*-[0-9]*[0-9]\\.[0-9]*[0-9]$", 0);
if(regexec(&regex1, port->folder_name, 0, NULL, 0) != 0 || port->dmsect == NULL){
*value= "";

View file

@ -27,7 +27,7 @@ DMLEAF tSe_IgmpParam[] = {
{"QueryResponseInterval", &DMWRITE, DMT_UNINT, get_igmp_query_response_interval, set_igmp_query_response_interval, NULL, NULL, BBFDM_BOTH},
{"LastMemberQueryInterval", &DMWRITE, DMT_UNINT, get_igmp_last_member_queryinterval, set_igmp_last_member_queryinterval, NULL, NULL, BBFDM_BOTH},
{"RobustnessValue", &DMWRITE, DMT_INT, get_igmp_robustness_value, set_igmp_robustness_value, NULL, NULL, BBFDM_BOTH},
{"LanToLanMulticastEnable", &DMWRITE, DMT_BOOL, get_igmp_multicast_enable, set_igmp_multicast_enable, NULL, NULL, BBFDM_BOTH, BBFDM_BOTH},
{"LanToLanMulticastEnable", &DMWRITE, DMT_BOOL, get_igmp_multicast_enable, set_igmp_multicast_enable, NULL, NULL, BBFDM_BOTH},
{"MaxGroup", &DMWRITE, DMT_UNINT, get_igmp_maxgroup, set_igmp_maxgroup, NULL, NULL, BBFDM_BOTH},
{"MaxSources", &DMWRITE, DMT_UNINT, get_igmp_maxsources, set_igmp_maxsources, NULL, NULL, BBFDM_BOTH},
{"MaxMembers", &DMWRITE, DMT_UNINT, get_igmp_maxmembers, set_igmp_maxmembers, NULL, NULL, BBFDM_BOTH},

View file

@ -172,8 +172,9 @@ struct uci_section *dmuci_walk_section(char *package, char *stype, void *arg1, v
struct uci_section *dmuci_walk_state_section(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk);
struct uci_section *dmuci_walk_section_bbfdm(char *package, char *stype, void *arg1, void *arg2, int cmp , int (*filter)(struct uci_section *s, void *value), struct uci_section *prev_section, int walk);
char *dmuci_set_value_by_section_bbfdm(struct uci_section *s, char *option, char *value);
int dmuci_delete_by_section_unnamed_bbfdm(struct uci_section *s, char *option, char *value);
int dmuci_add_section_bbfdm(char *package, char *stype, struct uci_section **s, char **value);
int dmuci_delete_bbfdm(char *package, char *section, char *option, char *value);
int dmuci_add_state_section(char *package, char *stype, struct uci_section **s, char **value);
char *dmuci_set_varstate_value(char *package, char *section, char *option, char *value);
char *dmuci_set_value_bbfdm(char *package, char *section, char *option, char *value);