mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Device.IP: fix the get/set of IPv4Capable and IPv6Capable parameters
This commit is contained in:
parent
c97f46910d
commit
efe2ca135b
6 changed files with 33 additions and 42 deletions
|
|
@ -25,7 +25,7 @@ static int get_stats_json_folder(char *folder_path, int *file_count, unsigned lo
|
|||
int filecount = 0;
|
||||
unsigned long filesize = 0, filedate = 0;
|
||||
|
||||
if (isfolderexist(folder_path)) {
|
||||
if (folder_exists(folder_path)) {
|
||||
dirp = opendir(folder_path);
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
if ((entry->d_type == DT_REG) && (strstr(entry->d_name, ".json"))) {
|
||||
|
|
@ -877,7 +877,7 @@ int load_json_dynamic_arrays(struct dmctx *ctx)
|
|||
struct dirent *ent;
|
||||
DIR *dir = NULL;
|
||||
|
||||
if (isfolderexist(JSON_FOLDER_PATH)) {
|
||||
if (folder_exists(JSON_FOLDER_PATH)) {
|
||||
sysfs_foreach_file(JSON_FOLDER_PATH, dir, ent) {
|
||||
if (strstr(ent->d_name, ".json")) {
|
||||
DMOBJ *dm_entryobj = NULL;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ static int get_stats_library_folder(char *folder_path, int *file_count, unsigned
|
|||
int filecount = 0;
|
||||
unsigned long filesize = 0, filedate = 0;
|
||||
|
||||
if (isfolderexist(folder_path)) {
|
||||
if (folder_exists(folder_path)) {
|
||||
dirp = opendir(folder_path);
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
if ((entry->d_type == DT_REG) && (strstr(entry->d_name, ".so"))) {
|
||||
|
|
@ -118,7 +118,7 @@ int load_library_dynamic_arrays(struct dmctx *ctx)
|
|||
struct dirent *ent;
|
||||
DIR *dir = NULL;
|
||||
|
||||
if (isfolderexist(LIBRARY_FOLDER_PATH)) {
|
||||
if (folder_exists(LIBRARY_FOLDER_PATH)) {
|
||||
sysfs_foreach_file(LIBRARY_FOLDER_PATH, dir, ent) {
|
||||
if (strstr(ent->d_name, ".so")) {
|
||||
void *handle;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ static char *get_child_prefix_linker(char *interface)
|
|||
*/
|
||||
static int get_IP_IPv4Capable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "1";
|
||||
*value = folder_exists("/proc/sys/net/ipv4") ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -180,23 +180,16 @@ static int get_IP_IPv4Status(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int get_IP_IPv6Capable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
*value = "1";
|
||||
*value = folder_exists("/proc/sys/net/ipv6") ? "1" : "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char buf[64] = {0};
|
||||
char buf[16] = {0};
|
||||
|
||||
*value = "0";
|
||||
int pp = dmcmd("sysctl", 1, "net.ipv6.conf.all.disable_ipv6");
|
||||
if (pp) {
|
||||
int r = dmcmd_read(pp, buf, sizeof(buf));
|
||||
close(pp);
|
||||
char *val = NULL;
|
||||
if (r > 0 && (val = strchr(buf, '=')))
|
||||
*value = (strcmp(val+2, "1") == 0) ? "0" : "1";
|
||||
}
|
||||
dm_read_sysfs_file("/proc/sys/net/ipv6/conf/all/disable_ipv6", buf, sizeof(buf));
|
||||
*value = (strcmp(buf, "1") == 0) ? "0" : "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -221,10 +214,8 @@ static int set_IP_IPv6Enable(char *refparam, struct dmctx *ctx, void *data, char
|
|||
|
||||
static int get_IP_IPv6Status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
dm_read_sysfs_file("/proc/sys/net/ipv6/conf/all/disable_ipv6", buf, sizeof(buf));
|
||||
*value = (strcmp(buf, "1") == 0) ? "Disabled" : "Enabled";
|
||||
get_IP_IPv6Enable(refparam, ctx, data, instance, value);
|
||||
*value = (strcmp(*value, "1") == 0) ? "Enabled" : "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ static int browseUSBInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void
|
|||
iface_name[0] = 0;
|
||||
|
||||
snprintf(netfolderpath, sizeof(netfolderpath), "%s/%s/net", SYSFS_USB_DEVICES_PATH, p->sysfs_folder_name);
|
||||
if(!isfolderexist(netfolderpath)){
|
||||
if (!folder_exists(netfolderpath)) {
|
||||
//dmuci_delete_by_section_unnamed_bbfdm(p->dm, NULL, NULL);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ static int synchronize_usb_devices_with_dmmap_opt_recursively(char *sysfsrep, ch
|
|||
if(is_root){
|
||||
uci_path_foreach_sections_safe(bbfdm, dmmap_package, dmmap_section, stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, opt_name, &v);
|
||||
if(isfolderexist(v) == 0){
|
||||
if (!folder_exists(v)) {
|
||||
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -976,7 +976,7 @@ int synchronize_system_folders_with_dmmap_opt(char *sysfsrep, char *dmmap_packag
|
|||
*/
|
||||
uci_path_foreach_sections_safe(bbfdm, dmmap_package, dmmap_section, stmp, s) {
|
||||
dmuci_get_value_by_section_string(s, opt_name, &v);
|
||||
if (isfolderexist(v) == 0)
|
||||
if (!folder_exists(v))
|
||||
dmuci_delete_by_section_unnamed_bbfdm(s, NULL, NULL);
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1409,16 +1409,6 @@ int command_exec_output_to_array(char *cmd, char **output, int *length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int isfolderexist(char *folderpath)
|
||||
{
|
||||
DIR* dir = opendir(folderpath);
|
||||
if (dir) {
|
||||
closedir(dir);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int copy_temporary_file_to_original_file(char *f1, char *f2)
|
||||
{
|
||||
FILE *fp, *ftmp;
|
||||
|
|
@ -1794,7 +1784,17 @@ int dm_validate_unsignedInt_list(char *value, int min_item, int max_item, int ma
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool file_exists(const char* path)
|
||||
bool folder_exists(const char *path)
|
||||
{
|
||||
struct stat buffer;
|
||||
|
||||
if (stat(path, &buffer) == 0 && S_ISDIR(buffer.st_mode))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool file_exists(const char *path)
|
||||
{
|
||||
struct stat buffer;
|
||||
|
||||
|
|
@ -1804,14 +1804,14 @@ bool file_exists(const char* path)
|
|||
return false;
|
||||
}
|
||||
|
||||
int is_regular_file(const char *path)
|
||||
bool is_regular_file(const char *path)
|
||||
{
|
||||
if (path == NULL || strlen(path) == 0)
|
||||
return 0;
|
||||
struct stat buffer;
|
||||
|
||||
struct stat path_stat;
|
||||
stat(path, &path_stat);
|
||||
return S_ISREG(path_stat.st_mode);
|
||||
if (stat(path, &buffer) == 0 && S_ISREG(buffer.st_mode))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int get_base64char_value(char b64)
|
||||
|
|
|
|||
|
|
@ -301,7 +301,6 @@ int command_exec_output_to_array(char *cmd, char **output, int *length);
|
|||
int copy_temporary_file_to_original_file(char *f1, char *f2);
|
||||
struct uci_section *is_dmmap_section_exist(char* package, char* section);
|
||||
struct uci_section *is_dmmap_section_exist_eq(char* package, char* section, char* opt, char* value);
|
||||
int isfolderexist(char *folderpath);
|
||||
char * dmmap_file_path_get(const char *dmmap_package);
|
||||
int dm_read_sysfs_file(const char *file, char *dst, unsigned len);
|
||||
int get_net_iface_sysfs(const char *uci_iface, const char *name, char **value);
|
||||
|
|
@ -320,8 +319,9 @@ int dm_validate_hexBinary(char *value, struct range_args r_args[], int r_args_si
|
|||
int dm_validate_string_list(char *value, int min_item, int max_item, int max_size, int min, int max, char *enumeration[], int enumeration_size, char *pattern[], int pattern_size);
|
||||
int dm_validate_unsignedInt_list(char *value, int min_item, int max_item, int max_size, struct range_args r_args[], int r_args_size);
|
||||
char *decode64(char *enc);
|
||||
bool folder_exists(const char *path);
|
||||
bool file_exists(const char *path);
|
||||
int is_regular_file(const char *path);
|
||||
bool is_regular_file(const char *path);
|
||||
char *stringToHex(char *text, int length);
|
||||
char *replace_char(char *str, char find, char replace);
|
||||
int is_vlan_termination_section(char *name);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue