Ticket refs #265: TR-181: Device.Firewall object

This commit is contained in:
Omar Kallel 2019-01-31 10:47:46 +01:00
parent 90a55af3c7
commit 414feb8b34
6 changed files with 1217 additions and 2 deletions

View file

@ -58,7 +58,8 @@ libdatamodel_la_SOURCES += \
../dm/dmtree/tr181/ppp.c \
../dm/dmtree/tr181/nat.c \
../dm/dmtree/tr181/routing.c \
../dm/dmtree/tr181/userinterface.c
../dm/dmtree/tr181/userinterface.c \
../dm/dmtree/tr181/firewall.c
if UPNP_TR064
libdatamodel_la_SOURCES += \

View file

@ -1346,3 +1346,47 @@ void update_dmmap_sections(struct list_head *dup_list, char *instancename, char*
dmuci_set_value_by_section(dm_sect, instancename, p->instance);
}
}
struct uci_section *is_dmmap_section_exist(char* package, char* section){
struct uci_section *s;
uci_path_foreach_sections(icwmpd, package, section, s) {
return s;
}
return NULL;
}
unsigned char isdigit_str(char *str) {
if (!(*str)) return 0;
while(isdigit(*str++));
return ((*(str-1)) ? 0 : 1);
}
static inline int isword_delim(char c)
{
if (c == ' ' ||
c == ',' ||
c == '\t' ||
c == '\v' ||
c == '\r' ||
c == '\n' ||
c == '\0')
return 1;
return 0;
}
char *dm_strword(char *src, char *str)
{
char *ret = src;
int len;
if (src[0] == '\0')
return NULL;
len = strlen(str);
while ((ret = strstr(ret, str)) != NULL) {
if ((ret == src && isword_delim(ret[len])) ||
(ret != src && isword_delim(ret[len]) && isword_delim(*(ret - 1))))
return ret;
ret++;
}
return NULL;
}

View file

@ -171,5 +171,6 @@ void check_create_dmmap_package(char *dmmap_package);
int is_section_unnamed(char *section_name);
void delete_sections_save_next_sections(char* dmmap_package, char *section_type, char *instancename, char *section_name, int instance, struct list_head *dup_list);
void update_dmmap_sections(struct list_head *dup_list, char *instancename, char* dmmap_package, char *section_type);
unsigned char isdigit_str(char *str);
char *dm_strword(char *src, char *str);
#endif

View file

@ -55,6 +55,7 @@
#include "downloaddiagnostic.h"
#include "uploaddiagnostic.h"
#include "deviceconfig.h"
#include "firewall.h"
/* *** CWMP *** */
DMOBJ tEntry098Obj[] = {
@ -132,6 +133,7 @@ DMOBJ tRoot_181_Obj[] = {
{"PPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tpppObj, NULL, NULL},
{"Routing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingObj, tRoutingParam, NULL},
{"UserInterface", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUserInterfaceObj, NULL, NULL},
{"Firewall", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tFirewallObj, tFirewallParams, NULL},
#ifdef XMPP_ENABLE
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL},
#endif

1080
dm/dmtree/tr181/firewall.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,87 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2019 iopsys Software Solutions AB
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
*/
#ifndef _FIREWALL_H
#define _FIREWALL_H
#include "dmcwmp.h"
extern DMOBJ tFirewallObj[];
extern DMLEAF tFirewallParams[];
extern DMLEAF tLevelParams[];
extern DMLEAF tChainParams[];
extern DMOBJ tChainObj[];
extern DMLEAF tRuleParams[];
int browseLevelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseChainInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseRuleInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_level_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_chain_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_creator(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_chain_rule_number_of_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_target_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_firewall_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_firewall_config(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_firewall_advanced_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_port_mapping_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_level_default_log_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_chain_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_chain_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_order(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_description(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_target(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_target_chain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_i_p_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_dest_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_rule_source_port_range_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif