Merge devel source to be master

This commit is contained in:
Omar Kallel 2017-11-30 15:55:28 +01:00
parent d74b88913f
commit aaaa97d68b
100 changed files with 13766 additions and 8399 deletions

View file

@ -663,7 +663,7 @@ void bkp_session_insert_du_state_change_complete(struct du_state_change_complete
struct opresult *p;
list_for_each_entry(p, &(pdu_state_change_complete->list_opresult), list) {
n = bkp_session_insert(b,"opresult",NULL);
sprintf(resolved,"%b",p->resolved);
sprintf(resolved,"%d",p->resolved);
sprintf(fault_code,"%d",p->fault);
bkp_session_insert(n,"uuid",p->uuid);
bkp_session_insert(n,"du_ref",p->du_ref);

View file

@ -1,23 +1,10 @@
bin_PROGRAMS = icwmpd
CWMP_VERSION = 3.0
CWMP_VERSION = 3.0.0
LIB_DATAMODEL_VERSION = 3:0:0
icwmpd_SOURCES = \
../backupSession.c \
../config.c \
../cwmp.c \
../diagnostic.c \
../digestauth.c \
../event.c \
../external.c \
../http.c \
../jshn.c \
../log.c \
lib_LTLIBRARIES = libdatamodel.la
libdatamodel_la_SOURCES = \
../md5.c \
../netlink.c \
../time.c \
../ubus.c \
../xml.c \
../zlib.c \
../dm/dmcwmp.c \
../dm/dmentry.c \
../dm/dmmem.c \
@ -28,29 +15,23 @@ icwmpd_SOURCES = \
../dm/wepkey.c \
../dm/dmtree/common/deviceinfo.c \
../dm/dmtree/common/managementserver.c \
../dm/dmtree/common/root.c \
../dm/dmtree/common/softwaremodules.c \
../dm/dmtree/common/times.c \
../dm/dmtree/common/upnp.c \
../dm/dmtree/common/voice_services.c \
../dm/dmtree/common/x_inteno_se_ice.c \
../dm/dmtree/common/x_inteno_se_igmp.c \
../dm/dmtree/common/voice_services.c \
../dm/dmtree/common/x_inteno_se_ice.c \
../dm/dmtree/common/x_inteno_se_igmp.c \
../dm/dmtree/common/x_inteno_se_ipacccfg.c \
../dm/dmtree/common/x_inteno_se_logincfg.c \
../dm/dmtree/common/x_inteno_se_power_mgmt.c \
../dm/dmtree/common/softwaremodules.c \
../dm/dmtree/common/x_inteno_se_owsd.c \
../dm/dmtree/common/x_inteno_syslog.c \
../dm/dmtree/common/x_inteno_se_dropbear.c \
../dm/dmtree/common/x_inteno_se_owsd.c \
../dm/dmtree/common/x_inteno_se_buttons.c \
../dm/dmtree/common/x_inteno_syslog.c
if XMPP_ENABLE
icwmpd_SOURCES += \
../dm/dmtree/common/xmpp.c \
../xmpp_cr.c
endif
../dm/dmtree/common/root.c
if DATAMODEL_TR098
icwmpd_SOURCES += \
libdatamodel_la_SOURCES += \
../dm/dmtree/tr098/lan_interfaces.c \
../dm/dmtree/tr098/landevice.c \
../dm/dmtree/tr098/layer_2_bridging.c \
@ -63,7 +44,7 @@ icwmpd_SOURCES += \
../dm/dmtree/tr098/layer_3_forwarding.c
endif
if DATAMODEL_TR181
icwmpd_SOURCES += \
libdatamodel_la_SOURCES += \
../dm/dmtree/tr181/wifi.c \
../dm/dmtree/tr181/ethernet.c \
../dm/dmtree/tr181/wan.c \
@ -75,6 +56,74 @@ icwmpd_SOURCES += \
../dm/dmtree/tr181/nat.c \
../dm/dmtree/tr181/routing.c
endif
if UPNP_TR064
libdatamodel_la_SOURCES += \
../dm/dmtree/upnp/upnp_deviceinfo.c \
../dm/dmtree/upnp/upnp_configuration.c \
../dm/dmtree/upnp/upnp_monitoring.c \
../dm/dmtree/upnp/upnp_common.c
endif
libdatamodel_la_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
$(LIBUBOX_CFLAGS) \
$(LIBUBUS_CFLAGS)
libdatamodel_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBUCI_LDFLAGS) \
$(LIBUBOX_LDFLAGS) \
$(LIBUBUS_LDFLAGS) \
-share \
-version-info $(LIB_DATAMODEL_VERSION)
libdatamodel_la_LIBADD = \
$(AM_LIBS) \
$(LIBUCI_LIBS) \
$(LIBUBOX_LIBS) \
$(LIBUBUS_LIBS) \
$(LIBJSON_LIBS) \
$(LBLOBMSG_LIBS)
libdatamodel_la_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
libdatamodel_la_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
libdatamodel_la_CFLAGS+=-I../inc/
libdatamodel_la_CFLAGS+=-I../dm/
libdatamodel_la_CFLAGS+=-I../dm/dmtree/
libdatamodel_la_CFLAGS+=-I../dm/dmtree/common
libdatamodel_la_CFLAGS+=-I../dm/dmtree/tr098
libdatamodel_la_CFLAGS+=-I../dm/dmtree/tr181
libdatamodel_la_CFLAGS+=-I../dm/dmtree/upnp
bin_PROGRAMS = icwmpd
icwmpd_SOURCES = \
../backupSession.c \
../config.c \
../cwmp.c \
../digestauth.c \
../event.c \
../external.c \
../http.c \
../jshn.c \
../log.c \
../md5.c \
../netlink.c \
../time.c \
../ubus.c \
../xml.c \
../diagnostic.c \
../zlib.c
if XMPP_ENABLE
icwmpd_SOURCES += \
../dm/dmtree/common/xmpp.c \
../xmpp_cr.c
endif
icwmpd_CFLAGS = \
$(AM_CFLAGS) \
$(LIBUCI_CFLAGS) \
@ -103,12 +152,14 @@ icwmpd_LDADD = \
$(LIBTRACE_LIBS) \
$(LIBZSTREAM_LIBS) \
$(LIBPTHREAD_LIBS) \
$(LIBSTROPHE_LIBS) \
$(LCRYPTO_LIBS) \
$(LSSL_LIBS) \
$(LIBJSON_LIBS) \
$(LBLOBMSG_LIBS) \
$(LIBZ_LIBS) \
$(LIBM_LIBS)
$(LIBM_LIBS) \
-ldatamodel
icwmpd_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
icwmpd_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
@ -121,3 +172,4 @@ icwmpd_CFLAGS+=-I../dm/dmtree/
icwmpd_CFLAGS+=-I../dm/dmtree/common
icwmpd_CFLAGS+=-I../dm/dmtree/tr098
icwmpd_CFLAGS+=-I../dm/dmtree/tr181
icwmpd_CFLAGS+=-I../dm/dmtree/upnp

391
config.c
View file

@ -20,12 +20,14 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <getopt.h>
#include "cwmp.h"
#include "backupSession.h"
#include "xml.h"
#include "log.h"
#include "dmentry.h"
#include "deviceinfo.h"
#include "config.h"
typedef enum uci_config_action {
CMD_SET,
@ -34,16 +36,47 @@ typedef enum uci_config_action {
CMD_DEL,
} uci_config_action;
void show_help()
struct option long_options[] = {
{"boot-event", no_argument, NULL, 'b'},
{"get-rpc-methods", no_argument, NULL, 'g'},
{"command-input", no_argument, NULL, 'c'},
{"shell-cli", required_argument, NULL, 'm'},
{"alias-based-addressing", no_argument, NULL, 'a'},
{"instance-mode-number", no_argument, NULL, 'N'},
{"instance-mode-alias", no_argument, NULL, 'A'},
{"upnp", no_argument, NULL, 'U'},
{"user-acl", required_argument, NULL, 'u'},
{"amendment", required_argument, NULL, 'M'},
{"time-tracking", no_argument, NULL, 't'},
{"evaluating-test", no_argument, NULL, 'E'},
{"file", required_argument, NULL, 'f'},
{"wep", required_argument, NULL, 'w'},
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{NULL, 0, NULL, 0}
};
static void show_help(void)
{
fprintf(stdout, "\nUsage: icwmpd [option]\n");
fprintf(stdout, "-b: this option should be added only in the load phase\n");
fprintf(stdout, "-m: execute data model commands\n");
fprintf(stdout, "-w: generate wep keys\n");
fprintf(stdout, "-g: send GetRPCMethods to ACS\n");
fprintf(stdout, "-v: show the application version\n");
fprintf(stdout, "-h: show this help\n\n");
printf("Usage: icwmpd [OPTIONS]\n");
printf(" -b, --boot-event (CWMP daemon) Start CWMP with BOOT event\n");
printf(" -g, --get-rpc-methods (CWMP daemon) Start CWMP with GetRPCMethods request to ACS\n");
printf(" -c, --command-input (DataModel CLI) Execute data model rpc(s) with commands input\n");
printf(" -m, --shell-cli <data model rpc> (DataModel CLI) Execute data model RPC command directly from shell.\n");
printf(" -a, --alias-based-addressing (DataModel CLI) Alias based addressing supported\n");
printf(" -N, --instance-mode-number (DataModel CLI) Instance mode is Number (Enabled by default)\n");
printf(" -A, --instance-mode-alias (DataModel CLI) Instance mode is Alias\n");
printf(" -M, --amendment <amendment version> (DataModel CLI) Amendment version (Default amendment version is 2)\n");
printf(" -U, --upnp (DataModel CLI) Use UPNP data model paths\n");
printf(" -u, --user-acl <public|basic|xxxadmin|superadmin> (DataModel CLI) user access level. Default: superadmin\n");
printf(" -t, --time-tracking (DataModel CLI) Tracking time of RPC commands\n");
printf(" -E, --evaluating-test (DataModel CLI) Evaluating test format\n");
printf(" -f, --file <file path> (DataModel CLI) Execute data model rpc(s) from file\n");
printf(" -w, --wep <strength> <passphrase> (WEP KEY GEN) Generate wep keys\n");
printf(" -h, --help Display this help text\n");
printf(" -v, --version Display the version\n");
}
void show_version()
{
#ifndef CWMP_REVISION
@ -385,84 +418,6 @@ static void uppercase ( char *sPtr )
}
}
int get_amd_version_config()
{
int error;
int a = 0;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_AMD_VERSION ,&value)) == CWMP_OK)
{
cwmp->conf.amd_version = DEFAULT_AMD_VERSION;
if(value != NULL)
{
a = atoi(value) ;
if ( a >= 1 ) {
cwmp->conf.amd_version = a;
}
free(value);
value = NULL;
}
cwmp->conf.supported_amd_version = cwmp->conf.amd_version;
}
else
{
return error;
}
return CWMP_OK;
}
int get_session_timeout_config()
{
int error;
int a = 0;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_SESSION_TIMEOUT ,&value)) == CWMP_OK)
{
cwmp->conf.session_timeout = DEFAULT_SESSION_TIMEOUT;
if(value != NULL)
{
a = atoi(value) ;
if ( a >= 1 ) {
cwmp->conf.session_timeout = a;
}
free(value);
value = NULL;
}
}
else
{
return error;
}
return CWMP_OK;
}
int get_instance_mode_config()
{
int error;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_INSTANCE_MODE ,&value)) == CWMP_OK)
{
cwmp->conf.instance_mode = DEFAULT_INSTANCE_MODE;
if(value != NULL)
{
if ( 0 == strcmp(value, "InstanceNumber") ) {
cwmp->conf.instance_mode = INSTANCE_MODE_NUMBER;
} else {
cwmp->conf.instance_mode = INSTANCE_MODE_ALIAS;
}
free(value);
value = NULL;
}
}
else
{
return error;
}
return CWMP_OK;
}
int get_global_config(struct config *conf)
{
int error, error2, error3;
@ -970,6 +925,84 @@ int get_global_config(struct config *conf)
return CWMP_OK;
}
int get_amd_version_config()
{
int error;
int a = 0;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_AMD_VERSION ,&value)) == CWMP_OK)
{
cwmp->conf.amd_version = DEFAULT_AMD_VERSION;
if(value != NULL)
{
a = atoi(value) ;
if ( a >= 1 ) {
cwmp->conf.amd_version = a;
}
free(value);
value = NULL;
}
cwmp->conf.supported_amd_version = cwmp->conf.amd_version;
}
else
{
return error;
}
return CWMP_OK;
}
int get_session_timeout_config()
{
int error;
int a = 0;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_SESSION_TIMEOUT ,&value)) == CWMP_OK)
{
cwmp->conf.session_timeout = DEFAULT_SESSION_TIMEOUT;
if(value != NULL)
{
a = atoi(value) ;
if ( a >= 1 ) {
cwmp->conf.session_timeout = a;
}
free(value);
value = NULL;
}
}
else
{
return error;
}
return CWMP_OK;
}
int get_instance_mode_config()
{
int error;
char *value = NULL;
struct cwmp *cwmp = &cwmp_main;
if((error = uci_get_value(UCI_CPE_INSTANCE_MODE ,&value)) == CWMP_OK)
{
cwmp->conf.instance_mode = DEFAULT_INSTANCE_MODE;
if(value != NULL)
{
if ( 0 == strcmp(value, "InstanceNumber") ) {
cwmp->conf.instance_mode = INSTANCE_MODE_NUMBER;
} else {
cwmp->conf.instance_mode = INSTANCE_MODE_ALIAS;
}
free(value);
value = NULL;
}
}
else
{
return error;
}
return CWMP_OK;
}
int get_lwn_config(struct config *conf)
{
int error;
@ -1022,42 +1055,151 @@ int get_lwn_config(struct config *conf)
}
return CWMP_OK;
}
int global_env_init (int argc, char** argv, struct env *env)
{
int i,error=0;
unsigned char command_input = 0;
unsigned char from_shell = 0;
unsigned int dmaliassupport = 0;
unsigned int dminstancemode =INSTANCE_MODE_NUMBER;
unsigned int dmamendment = AMD_2;
unsigned int dmtype = DM_CWMP;
struct dmctx dmctx = {0};
for (i=1;i<argc;i++)
{
if (argv[i][0]!='-')
continue;
switch (argv[i][1])
{
case 'b':
env->boot = CWMP_START_BOOT;
break;
case 'g':
env->periodic = CWMP_START_PERIODIC;
break;
case 'm':
dm_entry_cli(argc, argv);
exit(EXIT_SUCCESS);
break;
case 'w':
wepkey_cli(argc, argv);
exit(EXIT_SUCCESS);
break;
case 'v':
show_version();
exit(EXIT_SUCCESS);
break;
case 'h':
show_help();
exit(EXIT_SUCCESS);
break;
}
}
char *file = NULL;
char *upnpuser;
char *next;
char *m_argv[64];
int m_argc;
int c, option_index = 0, iv, idx;
return CWMP_OK;
while ((c = getopt_long(argc, argv, "bgcaNAUtEhvm:u:M:f:w:", long_options, &option_index)) != -1) {
switch (c)
{
case 'b':
env->boot = CWMP_START_BOOT;
break;
case 'g':
env->periodic = CWMP_START_PERIODIC;
break;
case 'c':
command_input = 1;
break;
case 'a':
dmaliassupport = 1;
break;
case 'A':
dminstancemode = INSTANCE_MODE_ALIAS;
break;
case 'M':
iv = atoi(optarg);
if (iv > 0)
dmamendment = (unsigned int)(iv & 0xFF);
break;
case 'm':
from_shell = 1;
idx = optind - 1;
m_argc = 2;
while(idx < argc) {
next = argv[idx];
idx++;
if(next[0] != '-') {
m_argv[m_argc++] = next;
}
else
break;
if (m_argc > 63) {
printf("Too many arguments!\n");
exit(1);
}
}
optind = idx - 1;
break;
case 'U':
dmtype = DM_UPNP;
break;
case 'u':
upnpuser = optarg;
if (strcmp(upnpuser, "public") == 0) {
upnp_in_user_mask = DM_PUBLIC_MASK;
}
else if (strcmp(upnpuser, "basic") == 0) {
upnp_in_user_mask = DM_BASIC_MASK;
}
else if (strcmp(upnpuser, "xxxadmin") == 0) {
upnp_in_user_mask = DM_XXXADMIN_MASK;
}
else if (strcmp(upnpuser, "superadmin") == 0) {
upnp_in_user_mask = DM_SUPERADMIN_MASK;
}
break;
case 'w':
m_argc = 2;
idx = optind - 1;
while(idx < argc) {
next = argv[idx];
idx++;
if(next[0] != '-') {
m_argv[m_argc++] = next;
}
else
break;
if (m_argc > 2) {
printf("Too many arguments!\n");
exit(1);
}
}
optind = idx - 1;
wepkey_cli(m_argc, m_argv);
exit(0);
break;
case 't':
dmcli_timetrack = 1;
break;
case 'E':
dmcli_timetrack = 1;
dmcli_evaluatetest = 1;
break;
case 'f':
file = optarg;
break;
case 'h':
show_help();
exit(0);
case 'v':
show_version();
exit(0);
}
}
if (from_shell) {
if (!dmaliassupport)
dminstancemode =INSTANCE_MODE_NUMBER;
dm_execute_cli_shell(m_argc, (char**)m_argv, dmtype, dmamendment, dminstancemode);
exit (0);
}
else if (command_input) {
if (!dmaliassupport)
dminstancemode =INSTANCE_MODE_NUMBER;
dm_execute_cli_command(file, dmtype, dmamendment, dminstancemode);
exit (0);
}
return CWMP_OK;
}
int global_conf_init (struct config *conf)
@ -1088,13 +1230,13 @@ int save_acs_bkp_config(struct cwmp *cwmp)
int cwmp_get_deviceid(struct cwmp *cwmp) {
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
cwmp->deviceid.manufacturer = strdup(get_deviceid_manufacturer()); //TODO free
cwmp->deviceid.serialnumber = strdup(get_deviceid_serialnumber());
cwmp->deviceid.productclass = strdup(get_deviceid_productclass());
cwmp->deviceid.oui = strdup(get_deviceid_manufactureroui());
cwmp->deviceid.softwareversion = strdup(get_softwareversion());
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
return CWMP_OK;
}
@ -1112,7 +1254,7 @@ int cwmp_get_xmpp_param(struct cwmp *cwmp) {
{
char *enable;
asprintf(&instance, "%d", conf->xmpp_connection_id);
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
char *tmp;
asprintf(&tmp, "%s", get_xmpp_server_enable(instance));
//tmp = ;
@ -1140,7 +1282,7 @@ int cwmp_get_xmpp_param(struct cwmp *cwmp) {
cwmp->xmpp_param.retry_max_interval = atoi((const char *)get_xmpp_connect_retry_max_interval(instance));
cwmp->xmpp_param.retry_max_interval = (cwmp->xmpp_param.retry_max_interval) ? cwmp->xmpp_param.retry_max_interval : DEFAULT_RETRY_MAX_INTERVAL;
}
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
check_xmpp_config(cwmp);
}
else
@ -1188,13 +1330,12 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
{
return error;
}
dm_global_init();
cwmp_get_deviceid(cwmp);
#ifdef XMPP_ENABLE
if (conf->xmpp_enable && conf->xmpp_connection_id > 0)
cwmp_get_xmpp_param(cwmp);
#endif
dm_entry_load_enabled_notify();
dm_entry_load_enabled_notify(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
return CWMP_OK;
}
@ -1213,6 +1354,6 @@ int cwmp_config_reload(struct cwmp *cwmp)
if (conf->xmpp_enable && conf->xmpp_connection_id != 0)
cwmp_get_xmpp_param(cwmp);
#endif
dm_entry_load_enabled_notify();
dm_entry_load_enabled_notify(DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
return CWMP_OK;
}

View file

@ -10,6 +10,12 @@ AC_ARG_ENABLE(acs, [AS_HELP_STRING([--enable-acs],
[specify which ACS is going to be used; there are some optimizations available for HDM and Fusion ACS (default --enable-acs=multi]))],,
[AC_DEFINE(ACS_MULTI)])
AC_ARG_ENABLE(upnptr064, [AS_HELP_STRING([--enable-upnptr064], [enable tr064 upnp feature])], AC_DEFINE(UPNP_TR064),)
AM_CONDITIONAL([UPNP_TR064],[test "x$enable_upnptr064" = "xyes"])
AC_ARG_ENABLE(xmpp, [AS_HELP_STRING([--enable-xmpp], [enable xmpp feature])], AC_DEFINE(XMPP_ENABLE),)
AM_CONDITIONAL([XMPP_ENABLE],[test "x$enable_xmpp" = "xyes"])
AS_IF([test "x$enable_acs" = "xhdm"], [AC_DEFINE(ACS_HDM)])
AS_IF([test "x$enable_acs" = "xfusion"], [AC_DEFINE(ACS_FUSION)])
AS_IF([test "x$enable_acs" = "xmulti"], [AC_DEFINE(ACS_MULTI)])
@ -32,19 +38,20 @@ AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [enable debugging message
AC_ARG_ENABLE(devel, [AS_HELP_STRING([--enable-devel], [enable development messages])], AC_DEFINE(WITH_DEV_DEBUG),)
AC_ARG_ENABLE(dummy_mode, [AS_HELP_STRING([--enable-dummy-mode], [enable dummy mode])], AC_DEFINE(DUMMY_MODE),)
AC_ARG_ENABLE(xmpp, [AS_HELP_STRING([--enable-xmpp],
[enable xmpp; (default --enable-xmpp=disable]))],,)
AM_CONDITIONAL([XMPP_DISABLE], [test "x$enable_xmpp" = "xdisable" ])
AM_CONDITIONAL([XMPP_ENABLE], [test "x$enable_xmpp" = "xenable" ])
# checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
AC_ENABLE_SHARED
# checks for libraries
LIBPTHREAD_LIBS='-lpthread'
AC_SUBST([LIBPTHREAD_LIBS])
# checks for libraries
LIBSTROPHE_LIBS='-lstrophe'
AC_SUBST([LIBSTROPHE_LIBS])
LIBZ_LIBS='-lz'
AC_SUBST([LIBZ_LIBS])
@ -112,13 +119,6 @@ AM_COND_IF([DATAMODEL_TR181], [
AC_DEFINE(DATAMODEL_TR181)
])
AM_COND_IF([XMPP_DISABLE], [
AC_DEFINE(XMPP_DISABLE)
])
AM_COND_IF([XMPP_ENABLE], [
AC_DEFINE(XMPP_ENABLE)
])
AM_COND_IF([HTTP_CURL], [
AC_DEFINE(HTTP_CURL)
PKG_CHECK_MODULES(LIBCURL, [libcurl])

71
cwmp.c
View file

@ -26,53 +26,27 @@
#include "ubus.h"
#include "diagnostic.h"
#include "xmpp_cr.h"
#include "config.h"
#ifdef XMPP_ENABLE
#include <strophe.h>
#include "/home/piva/projects/inteno-tr064/iop-cc/staging_dir/target-mips_mips32_uClibc-0.9.33.2/usr/include/strophe.h"
#endif
#include <unistd.h>
struct cwmp cwmp_main = {0};
int ip_version = 4;
LIST_HEAD(list_execute_end_session);
int dm_add_end_session(void(*function)(int a, void *d), int action, void *data)
int cwmp_dm_ctx_init(struct cwmp *cwmp, struct dmctx *ctx)
{
struct execute_end_session *execute_end_session;
execute_end_session = calloc (1,sizeof(struct execute_end_session));
if (execute_end_session == NULL)
{
return -1;
}
execute_end_session->action = action;
execute_end_session->data = data;
execute_end_session->function = function;
list_add_tail (&(execute_end_session->list), &(list_execute_end_session));
if(cwmp->conf.supported_amd_version == 0)
get_amd_version_config();
get_instance_mode_config();
dm_ctx_init(ctx, DM_CWMP, cwmp->conf.amd_version, cwmp->conf.instance_mode);
return 0;
}
int cwmp_free_dm_end_session(struct execute_end_session *execute_end_session)
int cwmp_dm_ctx_clean(struct cwmp *cwmp, struct dmctx *ctx)
{
if(execute_end_session != NULL)
{
if(execute_end_session->data != NULL)
{
FREE(execute_end_session->data);
}
FREE(execute_end_session);
}
}
int apply_end_session()
{
struct execute_end_session *p, *q;
list_for_each_entry_safe(p, q, &(list_execute_end_session), list) {
p->function(p->action, p->data);
list_del(&(p->list));
cwmp_free_dm_end_session(p);
}
dm_ctx_clean(ctx);
return 0;
}
int cwmp_get_int_event_code(char *code)
@ -216,7 +190,6 @@ void cwmp_schedule_session (struct cwmp *cwmp)
cwmp->session_status.last_start_time = time(NULL);
cwmp->session_status.last_status = SESSION_RUNNING;
cwmp->session_status.next_retry = 0;
dm_global_init();
CWMP_LOG (INFO,"Start session");
error = cwmp_schedule_rpc (cwmp,session);
CWMP_LOG (INFO,"End session");
@ -471,12 +444,6 @@ int cwmp_move_session_to_session_queue (struct cwmp *cwmp, struct session *sessi
return CWMP_OK;
}
void cwmp_set_end_session (unsigned int end_session_flag)
{
if (cwmp_main.session_send)
cwmp_main.session_send->end_session |= end_session_flag;
}
int cwmp_session_destructor (struct cwmp *cwmp, struct session *session)
{
struct rpc *rpc;
@ -532,7 +499,7 @@ int run_session_end_func (struct session *session)
{
apply_end_session();
if (session->end_session & END_SESSION_EXTERNAL_ACTION)
if (end_session_flag & END_SESSION_EXTERNAL_ACTION)
{
CWMP_LOG (INFO,"Executing external commands: end session request");
external_init();
@ -540,7 +507,7 @@ int run_session_end_func (struct session *session)
external_exit();
}
if (session->end_session & END_SESSION_FACTORY_RESET)
if (end_session_flag & END_SESSION_FACTORY_RESET)
{
CWMP_LOG (INFO,"Executing factory reset: end session request");
external_init();
@ -549,24 +516,24 @@ int run_session_end_func (struct session *session)
exit(EXIT_SUCCESS);
}
if (session->end_session & END_SESSION_IPPING_DIAGNOSTIC)
if (end_session_flag & END_SESSION_IPPING_DIAGNOSTIC)
{
CWMP_LOG (INFO,"Executing ippingdiagnostic: end session request");
cwmp_ip_ping_diagnostic();
}
if (session->end_session & END_SESSION_DOWNLOAD_DIAGNOSTIC)
if (end_session_flag & END_SESSION_DOWNLOAD_DIAGNOSTIC)
{
CWMP_LOG (INFO,"Executing download diagnostic: end session request");
cwmp_start_diagnostic(DOWNLOAD_DIAGNOSTIC);
}
if (session->end_session & END_SESSION_UPLOAD_DIAGNOSTIC)
if (end_session_flag & END_SESSION_UPLOAD_DIAGNOSTIC)
{
CWMP_LOG (INFO,"Executing upload diagnostic: end session request");
cwmp_start_diagnostic(UPLOAD_DIAGNOSTIC);
}
if (session->end_session & END_SESSION_REBOOT)
if (end_session_flag & END_SESSION_REBOOT)
{
CWMP_LOG (INFO,"Executing Reboot: end session request");
external_init();
@ -575,14 +542,14 @@ int run_session_end_func (struct session *session)
exit(EXIT_SUCCESS);
}
if (session->end_session & END_SESSION_RELOAD)
if (end_session_flag & END_SESSION_RELOAD)
{
CWMP_LOG (INFO,"Config reload: end session request");
cwmp_apply_acs_changes();
}
if (session->end_session & END_SESSION_X_FACTORY_RESET_SOFT)
if (end_session_flag & END_SESSION_X_FACTORY_RESET_SOFT)
{
CWMP_LOG (INFO,"Executing factory reset soft: end session request");
external_init();
@ -593,7 +560,7 @@ int run_session_end_func (struct session *session)
dm_entry_restart_services();
session->end_session = 0;
end_session_flag = 0;
return CWMP_OK;
}

View file

@ -21,6 +21,7 @@
#include "dmcommon.h"
#include "ubus.h"
#include "diagnostic.h"
#include "config.h"
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>

View file

@ -21,13 +21,23 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <uci.h>
#include <cwmp.h>
#include <ctype.h>
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "dmjson.h"
char *array_notifcation_char[__MAX_notification] = {
[notification_none] = "0",
[notification_passive] = "1",
[notification_active] = "2",
[notification_passive_lw] = "3",
[notification_ppassive_passive_lw] = "4",
[notification_aactive_lw] = "5",
[notification_passive_active_lw] = "6",
};
int set_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char *option, char *value)
{
struct uci_list *v;
@ -89,6 +99,7 @@ int update_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char
}
return 0;
}
void compress_spaces(char *str)
{
char *dst = str;
@ -114,6 +125,58 @@ char *cut_fx(char *str, char *delimiter, int occurence)
return pch;
}
unsigned char dmisnumeric(char *nbr)
{
if (*nbr == '\0')
return 0;
while (*nbr <= '9' && *nbr >= '0') {
nbr++;
}
return ((*nbr) ? 0 : 1);
}
/* int strstructered(char *str1, char *str2)
* Return:
* STRUCTERED_SAME: if str1 is same of str2 (with # match any number)
* STRUCTERED_PART: if str2 is part of str1 (with # match any number)
* STRUCTERED_NULL: if str2 is not part of str1 (with # match any number)
*
*/
int strstructered(char *str1, char *str2)
{
char buf[16];
int i = 0;
for (; *str1 && *str2; str1++, str2++) {
if (*str1 == *str2)
continue;
if (*str2 == '#') {
i = 0;
do {
buf[i++] = *str1;
} while (*(str1+1) && *(str1+1) != dm_delim && str1++);
buf[i] = '\0';
if (dmisnumeric(buf))
continue;
}
else if (*str1 == '#') {
i = 0;
do {
buf[i++] = *str2;
} while (*(str2+1) && *(str2+1) != dm_delim && str2++);
buf[i] = '\0';
if (dmisnumeric(buf))
continue;
}
return STRUCTERED_NULL;
}
if (*str1 == '\0' && *str2 == '\0')
return STRUCTERED_SAME;
else if (*str2 == '\0')
return STRUCTERED_PART;
return STRUCTERED_NULL;
}
pid_t get_pid(char *pname)
{
DIR* dir;
@ -782,3 +845,57 @@ int check_ifname_is_vlan(char *ifname)
return 1;
return 0;
}
int dmcommon_check_notification_value(char *value)
{
int i;
for (i = 0; i< __MAX_notification; i++) {
if (strcmp(value, array_notifcation_char[i]) == 0)
return 0;
}
return -1;
}
char *print_bin(unsigned int n, char *buf, int sep)
{
int i = 0, j;
for (j = 0; j < 32; j++) {
if (j % sep == 0)
buf[i++] = ' ';
buf[i++] = (n & (1<<j)) ? '1' : '0';
}
buf[i] = '\0';
return buf;
}
void parse_proc_route_line(char *line, struct proc_routing *proute)
{
char *pch, *spch;
proute->iface = strtok_r(line, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->destination);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->gateway);
proute->flags = strtok_r(NULL, " \t", &spch);
proute->refcnt = strtok_r(NULL, " \t", &spch);
proute->use = strtok_r(NULL, " \t", &spch);
proute->metric = strtok_r(NULL, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->mask);
proute->mtu = strtok_r(NULL, " \t", &spch);
proute->window = strtok_r(NULL, " \t", &spch);
proute->irtt = strtok_r(NULL, " \t\n\r", &spch);
}
void hex_to_ip(char *address, char *ret)
{
int i;
int ip[4] = {0};
sscanf(address, "%2x%2x%2x%2x", &(ip[0]), &(ip[1]), &(ip[2]), &(ip[3]));
if (htonl(13) == 13) {
sprintf(ret, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
} else {
sprintf(ret, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
}
}

View file

@ -18,6 +18,8 @@
#include "dmcwmp.h"
#define NVRAM_FILE "/proc/nvram/WpaKey"
#define MAX_DHCP_LEASES 256
#define MAX_PROC_ROUTING 256
#define ROUTING_FILE "/proc/net/route"
#define ARP_FILE "/proc/net/arp"
#define DMMAP "dmmap"
#define DHCPSTATICADDRESS_DISABLED_CHADDR "00:00:00:00:00:01"
@ -54,6 +56,54 @@ do { \
if (mpp) close (mpp); \
} while (0)
#define IPPING_STOP DMCMD("/bin/sh", 2, FUNCTION_PATH, "stop");
#define FUNCTION_PATH "/usr/share/icwmp/functions/ipping_launch"
#define DOWNLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/download_launch"
#define DOWNLOAD_DUMP_FILE "/tmp/download_dump"
#define DOWNLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, DOWNLOAD_DIAGNOSTIC_PATH, "stop");
#define UPLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/upload_launch"
#define UPLOAD_DUMP_FILE "/tmp/upload_dump"
#define UPLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, UPLOAD_DIAGNOSTIC_PATH, "stop");
enum notification_enum {
notification_none,
notification_passive,
notification_active,
notification_passive_lw,
notification_ppassive_passive_lw,
notification_aactive_lw,
notification_passive_active_lw,
__MAX_notification
};
enum strstructered_enum {
STRUCTERED_SAME,
STRUCTERED_PART,
STRUCTERED_NULL
};
struct proc_routing {
char *iface;
char *flags;
char *refcnt;
char *use;
char *metric;
char *mtu;
char *window;
char *irtt;
char destination[16];
char gateway[16];
char mask[16];
};
struct routingfwdargs
{
char *permission;
struct uci_section *routefwdsection;
struct proc_routing *proute;
int type;
};
void compress_spaces(char *str);
char *cut_fx(char *str, char *delimiter, int occurence);
pid_t get_pid(char *pname);
@ -88,5 +138,8 @@ int max_array(int a[], int size);
int check_ifname_is_vlan(char *ifname);
int set_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char *option, char *value);
int update_uci_dhcpserver_option(struct dmctx *ctx, struct uci_section *s, char *option, char * new_option, char *value);
void parse_proc_route_line(char *line, struct proc_routing *proute);
int strstructered(char *str1, char *str2);
int dmcommon_check_notification_value(char *value);
void hex_to_ip(char *address, char *ret);
#endif

File diff suppressed because it is too large Load diff

View file

@ -21,85 +21,139 @@
#include "dmmem.h"
#ifdef DATAMODEL_TR098
#define DMROOT "InternetGatewayDevice."
#define DMROOT_CWMP "InternetGatewayDevice"
#endif
#ifdef DATAMODEL_TR181
#define DMROOT "Device."
#define DMROOT_CWMP "Device"
#endif
#ifdef UPNP_TR064
#define DMROOT_UPNP ""
#define DMDELIM_UPNP '/'
#endif
#define DMDELIM_CWMP '.'
#define DM_PROMPT "icwmp>"
#ifdef UPNP_TR064
#define UPNP_CFG "tr064"
#endif
#ifdef UNDEF
#undef UNDEF
#endif
#define UNDEF -1
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#define IF_MATCH(ctx, prefix, ...) \
(ctx)->match = (ctx)->tree; \
if (!(ctx)->tree) { \
sprintf((ctx)->current_obj, prefix, ##__VA_ARGS__); \
if (strstr((ctx)->in_param, (ctx)->current_obj) || \
(strstr((ctx)->current_obj, (ctx)->in_param) && \
(ctx)->in_param[strlen((ctx)->in_param)-1] == '.')) { \
(ctx)->match = true; \
} \
} \
if ((ctx)->match)
#ifndef FREE
#define FREE(x) do { free(x); x = NULL; } while (0)
#endif
#define IF_MATCH_ROOT(ctx) \
(ctx)->match = (ctx)->tree; \
if (!(ctx)->tree) { \
if (strstr((ctx)->in_param, DMROOT) && \
!strchr(((ctx)->in_param + sizeof(DMROOT) - 1), '.')) { \
(ctx)->match = true; \
} \
} \
if ((ctx)->match)
extern struct dm_permession_s DMREAD;
extern struct dm_permession_s DMWRITE;
extern struct dm_forced_inform_s DMFINFRM;
#define DMOBJECT(name, ctx, permission, notif_permission, addobj, delobj, linker, ...) { \
sprintf((ctx)->current_obj, name, ##__VA_ARGS__); \
int error = ctx->method_obj(ctx, permission, notif_permission, addobj, delobj, linker); \
if ((ctx)->stop) return error; \
}
extern struct dm_notif_s DMNONE;
extern struct dm_notif_s DMACTIVE;
extern struct dm_notif_s DMPASSIVE;
#define DMPARAM(lastname, ctx, permission, get_cmd, set_cmd, type, forced_inform, notif_permission, forced_notify, linker) { \
int error = ctx->method_param(lastname, ctx, permission, get_cmd, set_cmd, type, forced_inform, notif_permission, forced_notify, linker); \
if ((ctx)->stop) return error; \
}
#define SUBENTRY(f, ctx, ...) { \
int error = f(ctx, ## __VA_ARGS__); \
if ((ctx)->stop) return error; \
}
#define DMPARAM_API_ARGS \
#define DMPARAM_ARGS \
struct dmctx *dmctx, \
struct dmnode *node, \
char *lastname, \
struct dmctx *ctx, \
char *permission, \
int (*get_cmd)(char *refparam, struct dmctx *ctx, char **value), \
int (*set_cmd)(char *refparam, struct dmctx *ctx, int action, char *value), \
char *type, \
bool forced_inform, \
bool notif_permission, \
int forced_notify, \
char *linker
struct dm_permession_s *permission, \
int type, \
int (*get_cmd)(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value), \
int (*set_cmd)(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action), \
struct dm_forced_inform_s *forced_inform, \
struct dm_notif_s *notification, \
void *data, \
char *instance
#define DMOBJECT_API_ARGS \
struct dmctx *ctx, \
char *permission, \
bool notif_permission, \
int (*addobj)(struct dmctx *ctx, char **instance), \
int (*delobj)(struct dmctx *ctx), \
char *linker
#define DMOBJECT_ARGS \
struct dmctx *dmctx, \
struct dmnode *node, \
struct dm_permession_s *permission, \
int (*addobj)(char *refparam, struct dmctx *ctx, void *data, char **instance), \
int (*delobj)(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action), \
struct dm_forced_inform_s *forced_inform, \
struct dm_notif_s *notification, \
int (*get_linker)(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker), \
void *data, \
char *instance
#define TAILLE_MAX 1024
struct dm_forced_inform_s;
struct dm_permession_s;
struct dm_parameter;
struct dm_leaf_s;
struct dm_obj_s;
struct dmnode;
struct dmctx;
struct dm_notif_s;
struct dm_permession_s {
char *val;
char *(*get_permission)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
struct dm_forced_inform_s {
unsigned char val;
unsigned char (*get_forced_inform)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
struct dm_notif_s {
char *val;
char *(*get_notif)(char *refparam, struct dmctx *dmctx, void *data, char *instance);
};
typedef struct dm_leaf_s {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification(7)*/
char *parameter;
struct dm_permession_s *permission;
int type;
int (*getvalue)(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int (*setvalue)(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
struct dm_forced_inform_s *forced_inform;
struct dm_notif_s *notification;
} DMLEAF;
typedef struct dm_obj_s {
/* OBJ, permission, addobj, delobj, browseinstobj, forced_inform, notification, nextobj, leaf, linker(10)*/
char *obj;
struct dm_permession_s *permission;
int (*addobj)(char *refparam, struct dmctx *ctx, void *data, char **instance);
int (*delobj)(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
bool (*checkobj)(struct dmctx *dmctx, void *data);
int (*browseinstobj)(struct dmctx *dmctx, struct dmnode *node, void *data, char *instance);
struct dm_forced_inform_s *forced_inform;
struct dm_notif_s *notification;
struct dm_obj_s *nextobj;
struct dm_leaf_s *leaf;
int (*get_linker)(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
} DMOBJ;
#ifdef UPNP_TR064
typedef struct dm_upnp_supported_dm_s {
char *location;
char *uri;
char *url;
char *description;
char *source_location;
} UPNP_SUPPORTED_DM;
#endif
struct set_tmp {
struct list_head list;
char *name;
char *value;
unsigned int flags;
};
struct param_fault {
@ -115,41 +169,72 @@ struct dm_enabled_notify {
char *value;
};
#ifdef UPNP_TR064
struct dm_upnp_enabled_track {
struct list_head list;
char *name;
char *key;
char *value;
unsigned int isobj;
};
#endif
struct dm_parameter {
struct list_head list;
char *name;
char *data;
char *type;
char *version;
unsigned int flags;
};
struct dmctx
{
bool stop;
bool tree;
bool match;
int (*method_param)(DMPARAM_API_ARGS);
int (*method_obj)(DMOBJECT_API_ARGS);
void *args;
int (*method_param)(DMPARAM_ARGS);
int (*method_obj)(DMOBJECT_ARGS);
int (*checkobj)(DMOBJECT_ARGS);
int (*checkleaf)(DMOBJECT_ARGS);
struct list_head list_parameter;
struct list_head set_list_tmp;
struct list_head list_fault_param;
DMOBJ *dm_entryobj;
bool nextlevel;
int depth;
int faultcode;
int setaction;
char *in_param;
char *in_notification;
char *in_notification;
bool notification_change;
char *in_value;
char *addobj_instance;
char *linker;
char *linker_param;
unsigned int dmparam_flags;
unsigned int alias_register;
unsigned int nbrof_instance;
unsigned int amd_version;
unsigned int instance_mode;
char current_obj[512];
unsigned int dm_type;
unsigned int user_mask;
unsigned char inparam_isparam;
unsigned char findparam;
char all_instances[512];
char *inst_buf[16];
char *instance_wildchar;
};
typedef struct dmnode {
DMOBJ *obj;
struct dmnode *parent;
char *current_object;
unsigned char instance_level;
unsigned char matched;
unsigned char is_instanceobj;
} DMNODE;
struct prefix_method {
const char *prefix_name;
bool enable;
@ -163,11 +248,30 @@ struct notification {
char *type;
};
struct dm_acl {
unsigned int flag;
char *user_access;
};
typedef struct execute_end_session {
struct list_head list;
int action;
unsigned int dm_type;
unsigned int amd_version;
unsigned int instance_mode;
void *data;
void (*function)(struct execute_end_session *);
} execute_end_session;
enum set_value_action {
VALUECHECK,
VALUESET
};
enum del_action_enum {
DEL_INST,
DEL_ALL
};
enum {
CMD_GET_VALUE,
CMD_GET_NAME,
@ -177,9 +281,35 @@ enum {
CMD_ADD_OBJECT,
CMD_DEL_OBJECT,
CMD_INFORM,
#ifdef UPNP_TR064
CMD_UPNP_GET_SUPPORTED_PARAMETERS,
CMD_UPNP_GET_INSTANCES,
CMD_UPNP_GET_SELECTED_VALUES,
CMD_UPNP_GET_VALUES,
CMD_UPNP_SET_VALUES,
CMD_UPNP_GET_ATTRIBUTES,
CMD_UPNP_SET_ATTRIBUTES,
CMD_UPNP_DEL_INSTANCE,
CMD_UPNP_ADD_INSTANCE,
CMD_UPNP_GET_ACLDATA,
CMD_UPNP_INIT_STATE_VARIABLES,
CMD_UPNP_LOAD_ENABLED_PARAMETRS_TRACK,
CMD_UPNP_GET_CONFIGURATION_UPDATE,
CMD_UPNP_GET_CURRENT_CONFIGURATION_VERSION,
CMD_UPNP_GET_SUPPORTED_DATA_MODEL_UPDATE,
CMD_UPNP_GET_SUPPORTED_PARAMETERS_UPDATE,
CMD_UPNP_GET_ATTRIBUTE_VALUES_UPDATE,
CMD_UPNP_GET_ENABLED_PARAMETRS_ALARM,
CMD_UPNP_GET_ENABLED_PARAMETRS_EVENT,
CMD_UPNP_GET_ENABLED_PARAMETRS_VERSION,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_ALARM,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_EVENT,
CMD_UPNP_CHECK_CHANGED_PARAMETRS_VERSION,
#endif
CMD_EXTERNAL_COMMAND
};
enum fault_code {
enum fault_code_enum {
FAULT_9000 = 9000,// Method not supported
FAULT_9001,// Request denied
FAULT_9002,// Internal error
@ -216,6 +346,21 @@ enum fault_code {
__FAULT_MAX
};
#ifdef UPNP_TR064
enum upnp_fault_code_enum {
FAULT_UPNP_606 = 606,// Action not authorized
FAULT_UPNP_701 = 701,// Invalid Argument Syntax
FAULT_UPNP_702,//Invalid XML Argument
FAULT_UPNP_703,// No Such Name
FAULT_UPNP_704,// Invalid Value Type
FAULT_UPNP_705,// Invalid Value
FAULT_UPNP_706,// Read Only Violation
FAULT_UPNP_707,// Multiple Set
FAULT_UPNP_708,// Resource Temporarily Unavailable
__FAULT_UPNP_MAX
};
#endif
enum {
INSTANCE_UPDATE_NUMBER,
INSTANCE_UPDATE_ALIAS
@ -226,19 +371,111 @@ enum instance_mode {
INSTANCE_MODE_ALIAS
};
enum end_session_enum {
END_SESSION_REBOOT = 1,
END_SESSION_EXTERNAL_ACTION = 1<<1,
END_SESSION_RELOAD = 1<<2,
END_SESSION_FACTORY_RESET = 1<<3,
END_SESSION_IPPING_DIAGNOSTIC = 1<<4,
END_SESSION_DOWNLOAD_DIAGNOSTIC = 1<<5,
END_SESSION_UPLOAD_DIAGNOSTIC = 1<<6,
END_SESSION_X_FACTORY_RESET_SOFT = 1<<7
};
enum dm_browse_enum {
DM_ERROR = -1,
DM_OK = 0,
DM_STOP = 1
};
enum dmt_type_enum {
DMT_STRING,
DMT_UNINT,
DMT_INT,
DMT_LONG,
DMT_BOOL,
DMT_TIME,
DMT_HEXBIN,
};
enum amd_version_enum{
AMD_1 = 1,
AMD_2,
AMD_3,
AMD_4,
AMD_5,
};
enum dm_type_enum{
DM_CWMP,
DM_UPNP,
};
enum dm_param_flags_enum{
/* UPNP OnChange flags flags */
DM_PARAM_ALARAM_ON_CHANGE = 1 << 0,
DM_PARAM_EVENT_ON_CHANGE = 1 << 1,
/* UPNP type flags */
NODE_DATA_ATTRIBUTE_INSTANCE = 0x0010,
NODE_DATA_ATTRIBUTE_MULTIINSTANCE = 0x0020,
NODE_DATA_ATTRIBUTE_TYPESTRING = 0x0100,
NODE_DATA_ATTRIBUTE_TYPEINT = 0x0200,
NODE_DATA_ATTRIBUTE_TYPELONG = 0x0400,
NODE_DATA_ATTRIBUTE_TYPEBOOL = 0x0800,
NODE_DATA_ATTRIBUTE_TYPEDATETIME = 0x1000,
NODE_DATA_ATTRIBUTE_TYPEBASE64 = 0x2000,
NODE_DATA_ATTRIBUTE_TYPEBIN = 0x4000,
NODE_DATA_ATTRIBUTE_TYPEPTR = 0x8000,
NODE_DATA_ATTRIBUTE_TYPEMASK = 0x0000FF00,
/*ACLRoles*/
DM_PUBLIC_LIST = 1 << 0,
DM_PUBLIC_READ = 1 << 1,
DM_PUBLIC_WRITE = 1 << 2,
DM_PUBLIC_MASK = DM_PUBLIC_LIST|DM_PUBLIC_READ|DM_PUBLIC_WRITE,
DM_BASIC_LIST = 1 << 3,
DM_BASIC_READ = 1 << 4,
DM_BASIC_WRITE = 1 << 5,
DM_BASIC_MASK = DM_PUBLIC_MASK|DM_BASIC_LIST|DM_BASIC_READ|DM_BASIC_WRITE,
DM_XXXADMIN_LIST = 1 << 6,
DM_XXXADMIN_READ = 1 << 7,
DM_XXXADMIN_WRITE = 1 << 8,
DM_XXXADMIN_MASK = DM_BASIC_MASK|DM_XXXADMIN_LIST|DM_XXXADMIN_READ|DM_XXXADMIN_WRITE,
DM_SUPERADMIN_MASK = DM_XXXADMIN_MASK | (1 << 9),
DM_LIST_MASK = DM_PUBLIC_LIST|DM_BASIC_LIST|DM_XXXADMIN_LIST,
DM_READ_MASK = DM_PUBLIC_READ|DM_BASIC_READ|DM_XXXADMIN_READ,
DM_WRITE_MASK = DM_PUBLIC_WRITE|DM_BASIC_WRITE|DM_XXXADMIN_WRITE,
DM_FACTORIZED = 1 << 31
};
extern struct list_head list_enabled_notify;
extern struct list_head list_enabled_lw_notify;
extern struct list_head list_execute_end_session;
#ifdef UPNP_TR064
extern struct list_head list_upnp_enabled_onevent;
extern struct list_head list_upnp_enabled_onalarm;
extern struct list_head list_upnp_enabled_version;
extern struct list_head list_upnp_changed_onevent;
extern struct list_head list_upnp_changed_onalarm;
extern struct list_head list_upnp_changed_version;
#endif
extern int end_session_flag;
extern int ip_version;
extern char dm_delim;
extern char DMROOT[64];
extern unsigned int upnp_in_user_mask;
char *update_instance(struct uci_section *s, char *last_inst, char *inst_opt);
char *update_instance_icwmpd(struct uci_section *s, char *last_inst, char *inst_opt);
char *update_instance_alias_icwmpd(int action, char **last_inst , void *argv[]);
char *update_instance_alias(int action, char **last_inst , void *argv[]);
char *update_instance_without_section(int action, char **last_inst, void *argv[]);
int get_empty(char *refparam, struct dmctx *args, char **value);
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type);
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
void add_list_paramameter(struct dmctx *ctx, char *param_name, char *param_data, char *param_type, char *param_version, unsigned int flags);
void del_list_parameter(struct dm_parameter *dm_parameter);
void free_all_list_parameter(struct dmctx *ctx);
void add_set_list_tmp(struct dmctx *ctx, char *param, char *value);
void add_set_list_tmp(struct dmctx *ctx, char *param, char *value, unsigned int flags);
void del_set_list_tmp(struct set_tmp *set_tmp);
void free_all_set_list_tmp(struct dmctx *ctx);
void add_list_fault_param(struct dmctx *ctx, char *param, int fault);
@ -253,19 +490,52 @@ int dm_entry_add_object(struct dmctx *ctx);
int dm_entry_delete_object(struct dmctx *ctx);
int dm_entry_set_value(struct dmctx *ctx);
int dm_entry_set_notification(struct dmctx *ctx);
int dm_entry_set_prefix_methods_enable(void);
int dm_entry_enabled_notify(struct dmctx *ctx);
int dm_entry_get_linker(struct dmctx *ctx);
int dm_entry_get_linker_value(struct dmctx *ctx);
#ifdef UPNP_TR064
int dm_entry_upnp_get_instances(struct dmctx *ctx);
int dm_entry_upnp_get_selected_values(struct dmctx *dmctx);
int dm_entry_upnp_get_values(struct dmctx *dmctx);
int dm_entry_upnp_set_values(struct dmctx *dmctx);
int dm_entry_upnp_get_attributes(struct dmctx *dmctx);
int upnp_state_variables_init(struct dmctx *dmctx);
int dm_entry_upnp_tracked_parameters(struct dmctx *dmctx);
int dm_entry_upnp_get_instance_numbers(struct dmctx *dmctx);
char *dm_entry_get_all_instance_numbers(struct dmctx *pctx, char *param);
void free_all_list_enabled_notify();
void free_all_list_upnp_param_track(struct list_head *head);
#endif
void dm_update_enabled_notify(struct dm_enabled_notify *p, char *new_value);
void dm_update_enabled_notify_byname(char *name, char *new_value);
char *get_last_instance(char *package, char *section, char *opt_inst);
char *get_last_instance_icwmpd(char *package, char *section, char *opt_inst);
char *get_last_instance_lev2(char *package, char *section, char *opt_inst, char *opt_check, char *value_check);
char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_inst, char * (*up_instance)(int action, char **last_inst, void *argv[]), int argc, ...);
int dm_add_end_session(struct dmctx *ctx, void(*function)(struct execute_end_session *), int action, void *data);
int apply_end_session();
void cwmp_set_end_session (unsigned int flag);
char *dm_print_path(char *fpath, ...);
#ifdef UPNP_TR064
void dm_upnp_apply_config(void);
void add_list_upnp_param_track(struct dmctx *dmctx, struct list_head *pchead, char *param, char *key, char *value, unsigned int isobj);
int dm_link_inst_obj(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance);
int dm_entry_upnp_get_supported_parameters(struct dmctx *dmctx);
int dm_entry_upnp_set_attributes(struct dmctx *dmctx);
int dm_entry_upnp_delete_instance(struct dmctx *dmctx);
int dm_entry_upnp_get_acl_data(struct dmctx *dmctx);
void free_all_list_enabled_lwnotify();
int dm_entry_upnp_add_instance(struct dmctx *dmctx);
#endif
static inline int DM_LINK_INST_OBJ(struct dmctx *dmctx, DMNODE *parent_node, void *data, char *instance)
{
dmctx->faultcode = dm_link_inst_obj(dmctx, parent_node, data, instance);
if (dmctx->stop)
return DM_STOP;
return DM_OK;
}
#ifndef TRACE
#define TRACE_TYPE 0
static inline void trace_empty_func()
@ -274,9 +544,11 @@ static inline void trace_empty_func()
#if TRACE_TYPE == 2
#define TRACE(MESSAGE,args...) do { \
const char *A[] = {MESSAGE}; \
printf("TRACE: %s %s %d\n",__FUNCTION__,__FILE__,__LINE__); fflush(stdout);\
fprintf(stderr, "TRACE: %s %s %d ",__FUNCTION__,__FILE__,__LINE__); \
if(sizeof(A) > 0) \
printf(*A,##args); \
fprintf(stderr, *A,##args); \
fprintf(stderr, "\n"); \
fflush(stderr); \
} while(0)
#elif TRACE_TYPE == 1
#define TRACE(MESSAGE, ...) printf(MESSAGE, ## __VA_ARGS__)
@ -285,8 +557,6 @@ static inline void trace_empty_func()
#endif
#endif
#ifndef DETECT_CRASH
#define DETECT_CRASH(MESSAGE,args...) { \
const char *A[] = {MESSAGE}; \

File diff suppressed because it is too large Load diff

View file

@ -3,24 +3,74 @@
#include "dmcwmp.h"
extern struct list_head head_package_change;
extern unsigned char dmcli_timetrack;
extern unsigned char dmcli_evaluatetest;
enum ctx_init_enum {
CTX_INIT_ALL,
CTX_INIT_SUB
};
int dm_global_init(void);
int dm_ctx_init(struct dmctx *ctx);
int dm_ctx_init_sub(struct dmctx *ctx);
int dm_ctx_init(struct dmctx *ctx, unsigned int dm_type, unsigned int amd_version, unsigned int instance_mode);
int dm_ctx_init_sub(struct dmctx *ctx, unsigned int dm_type, unsigned int amd_version, unsigned int instance_mode);
int dm_entry_param_method(struct dmctx *ctx, int cmd, char *inparam, char *arg1, char *arg2);
int dm_entry_apply(struct dmctx *ctx, int cmd, char *arg1, char *arg2);
int dm_entry_load_enabled_notify();
int adm_entry_get_linker_param(char *param, char *linker, char **value);
int adm_entry_get_linker_value(char *param, char **value);
int dm_entry_restart_services();
int dm_entry_load_enabled_notify(unsigned int dm_type, unsigned int amd_version, int instance_mode);
int adm_entry_get_linker_param(struct dmctx *ctx, char *param, char *linker, char **value);
int adm_entry_get_linker_value(struct dmctx *ctx, char *param, char **value);
int dm_entry_restart_services(void);
#ifdef UPNP_TR064
int dm_entry_upnp_restart_services(void);
void dm_upnp_apply_config(void);
int dm_entry_upnp_check_alarmonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_eventonchange_param(struct dmctx *dmctx);
int dm_entry_upnp_check_versiononchange_param(struct dmctx *pctx);
int dm_entry_upnp_load_tracked_parameters(struct dmctx *dmctx);
int dm_entry_upnp_get_supported_parameters_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_supported_datamodel_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_attribute_values_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_configuration_update(struct dmctx *dmctx, char **value);
int dm_entry_upnp_get_current_configuration_version(struct dmctx *dmctx, char **value);
#endif
int dm_ctx_clean(struct dmctx *ctx);
int dm_ctx_clean_sub(struct dmctx *ctx);
void dm_entry_cli(int argc, char** argv);
void dm_execute_cli_shell(int argc, char** argv, unsigned int dmtype, unsigned int amd_version, unsigned int instance_mode);
void dm_execute_cli_command(char *file, unsigned int dmtype, unsigned int amd_version, unsigned int instance_mode);
void wepkey_cli(int argc, char** argv);
void dmentry_instance_lookup_inparam(struct dmctx *ctx);
#ifdef UPNP_TR064
#define DM_ENTRY_UPNP_CHECK_CHANGES(ALARM, EVENT, VERSION) \
do { \
struct dmctx dmctx_chg = {0}; \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
ALARM = dm_entry_upnp_check_alarmonchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
memset(&dmctx_chg, 0, sizeof(struct dmctx)); \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
EVENT = dm_entry_upnp_check_eventonchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
memset(&dmctx_chg, 0, sizeof(struct dmctx)); \
dm_ctx_init(&dmctx_chg, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
VERSION = dm_entry_upnp_check_versiononchange_param(&dmctx_chg); \
dm_ctx_clean(&dmctx_chg); \
} while(0)
#define DM_ENTRY_UPNP_FREE_ALL_CHECK_CHANGES() \
do { \
free_all_list_upnp_param_track(&list_upnp_changed_onevent); \
free_all_list_upnp_param_track(&list_upnp_changed_onalarm); \
free_all_list_upnp_param_track(&list_upnp_changed_version); \
} while(0)
#define DM_ENTRY_UPNP_LOAD_TRACKED_PARAMETERS() \
do { \
struct dmctx dmctx_trk = {0}; \
dm_ctx_init(&dmctx_trk, DM_UPNP, AMD_2, INSTANCE_MODE_NUMBER); \
dm_entry_upnp_load_tracked_parameters(&dmctx_trk); \
dm_ctx_clean(&dmctx_trk); \
} while(0)
#endif
#endif

View file

@ -60,7 +60,7 @@ const char *file, const char *func, int line,
#endif /*WITH_MEMTRACK*/
const char *s
);
//inline void dmfree(void *m);
void dmcleanmem();
#endif /*WITH_MEMLEACKSEC*/
int __dmasprintf

View file

@ -22,18 +22,59 @@
#include "deviceinfo.h"
#include "dmjson.h"
inline int entry_method_device_info_vcf(struct dmctx *ctx);
inline int entry_method_device_info_vcf_instance(struct dmctx *ctx, char *ivcf);
struct dev_vcf cur_dev_vcf = {0};
/*** DeviceInfo. ***/
DMOBJ tDeviceInfoObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf, linker*/
{"X_INTENO_SE_CATV", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tCatTvParams, NULL},
{"VendorConfigFile", &DMREAD, NULL, NULL, NULL, browseVcfInst, NULL, NULL, NULL, tVcfParams, NULL},
{0}
};
inline int init_args_vcf(struct dmctx *ctx, struct uci_section *s)
{
struct dev_vcf *args = &cur_dev_vcf;
ctx->args = (void *)args;
args->vcf_sec = s;
return 0;
}
DMLEAF tDeviceInfoParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification, linker*/
{"Manufacturer", &DMREAD, DMT_STRING, get_device_manufacturer, NULL, &DMFINFRM, NULL},
{"ManufacturerOUI", &DMREAD, DMT_STRING, get_device_manufactureroui, NULL, &DMFINFRM, NULL},
{"ModelName", &DMREAD, DMT_STRING, get_device_routermodel, NULL, &DMFINFRM, NULL},
{"ProductClass", &DMREAD, DMT_STRING, get_device_productclass, NULL, &DMFINFRM, NULL},
{"SerialNumber", &DMREAD, DMT_STRING, get_device_serialnumber, NULL, &DMFINFRM, NULL},
{"HardwareVersion", &DMREAD, DMT_STRING, get_device_hardwareversion, NULL, &DMFINFRM, NULL},
{"SoftwareVersion", &DMREAD, DMT_STRING, get_device_softwareversion, NULL, &DMFINFRM, &DMACTIVE},
{"UpTime", &DMREAD, DMT_UNINT, get_device_info_uptime, NULL, NULL, NULL},
{"DeviceLog", &DMREAD, DMT_STRING, get_device_devicelog, NULL, NULL, NULL},
{"SpecVersion", &DMREAD, DMT_STRING, get_device_specversion, NULL, &DMFINFRM, NULL},
{"ProvisioningCode", &DMWRITE, DMT_STRING, get_device_provisioningcode, set_device_provisioningcode, &DMFINFRM, &DMACTIVE},
{"X_INTENO_SE_BaseMacAddr", &DMREAD, DMT_STRING, get_base_mac_addr, NULL, NULL, NULL},
{"X_INTENO_SE_CATVEnabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL},
{"X_INTENO_SE_MemoryBank", &DMWRITE, DMT_STRING, get_device_memory_bank, set_device_memory_bank, NULL, NULL},
{0}
};
/*** DeviceInfo.X_INTENO_SE_CATV. ***/
DMLEAF tCatTvParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Enabled", &DMWRITE, DMT_STRING, get_catv_enabled, set_device_catvenabled, NULL, NULL},
{"OpticalInputLevel", &DMREAD, DMT_STRING, get_catv_optical_input_level, NULL, NULL, NULL},
{"RFOutputLevel", &DMREAD, DMT_STRING, get_catv_rf_output_level, NULL, NULL, NULL},
{"Temperature", &DMREAD, DMT_STRING, get_catv_temperature, NULL, NULL, NULL},
{"Voltage", &DMREAD, DMT_STRING, get_catv_voltage, NULL, NULL, NULL},
{0}
};
/*** DeviceInfo.VendorConfigFile.{i}. ***/
DMLEAF tVcfParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification*/
{"Alias", &DMWRITE, DMT_STRING, get_vcf_alias, set_vcf_alias, NULL, NULL},
{"Name", &DMREAD, DMT_STRING, get_vcf_name, NULL, NULL, NULL},
{"Version", &DMREAD, DMT_STRING, get_vcf_version, NULL, NULL, NULL},
{"Date", &DMREAD, DMT_TIME, get_vcf_date, NULL, NULL, NULL},
{"Description", &DMREAD, DMT_STRING, get_vcf_desc, NULL, NULL, NULL},
{"UseForBackupRestore", &DMREAD, DMT_BOOL, get_vcf_backup_restore, NULL, NULL, NULL},
{0}
};
/*
*DeviceInfo. functions
*/
char *get_deviceid_manufacturer()
{
char *v;
@ -49,18 +90,18 @@ char *get_deviceid_manufactureroui()
json_object *res;
FILE *nvrammac=NULL;
char macreadfile[18]={0};
dmuci_get_option_value_string("cwmp", "cpe", "override_oui", &v);
if (v[0] == '\0')
{
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
dmubus_call("router.system", "info", UBUS_ARGS{{}}, 0, &res);
if(!(res)){
db_get_value_string("hw", "board", "BaseMacAddr", &mac);
if(!mac || strlen(mac)==0 ){
if ((nvrammac = fopen("/proc/nvram/BaseMacAddr", "r")) == NULL)
{
{
mac = NULL;
}
}
else{
fscanf(nvrammac,"%[^\n]", macreadfile);
macreadfile[17]='\0';
@ -74,6 +115,7 @@ char *get_deviceid_manufactureroui()
}
else
mac = dm_ubus_get_value(res, 2, "system", "basemac");
if(mac)
{
size_t ln = strlen(mac);
@ -122,49 +164,49 @@ char *get_softwareversion()
return val;
}
int get_device_manufacturer(char *refparam, struct dmctx *ctx, char **value)
int get_device_manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_manufacturer();
return 0;
}
int get_device_manufactureroui(char *refparam, struct dmctx *ctx, char **value)
int get_device_manufactureroui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_manufactureroui();
return 0;
}
int get_device_productclass(char *refparam, struct dmctx *ctx, char **value)
int get_device_productclass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_productclass();
return 0;
}
int get_device_serialnumber(char *refparam, struct dmctx *ctx, char **value)
int get_device_serialnumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_deviceid_serialnumber();
return 0;
}
int get_device_softwareversion(char *refparam, struct dmctx *ctx, char **value)
int get_device_softwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = get_softwareversion();
return 0;
}
int get_device_hardwareversion(char *refparam, struct dmctx *ctx, char **value)
int get_device_hardwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
db_get_value_string("hw", "board", "hardwareVersion", value);
return 0;
}
int get_device_routermodel(char *refparam, struct dmctx *ctx, char **value)
int get_device_routermodel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
db_get_value_string("hw", "board", "routerModel", value);
return 0;
}
int get_device_info_uptime(char *refparam, struct dmctx *ctx, char **value)
int get_device_info_uptime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
FILE* fp = NULL;
char *pch, *spch;
@ -182,7 +224,7 @@ int get_device_info_uptime(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_device_devicelog(char *refparam, struct dmctx *ctx, char **value)
int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
int i = 0, nbrlines = 4;
@ -199,6 +241,7 @@ int get_device_devicelog(char *refparam, struct dmctx *ctx, char **value)
if(msg == NULL) msg = p;
i++;
if (i == nbrlines) {
*(p-1) = '\0';
break;
}
}
@ -214,19 +257,19 @@ int get_device_devicelog(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_device_specversion(char *refparam, struct dmctx *ctx, char **value)
int get_device_specversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "1.0";
return 0;
}
int get_device_provisioningcode(char *refparam, struct dmctx *ctx, char **value)
int get_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "provisioning_code", value);
return 0;
}
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, int action, char *value)
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
switch (action) {
@ -240,7 +283,7 @@ int set_device_provisioningcode(char *refparam, struct dmctx *ctx, int action, c
}
int get_base_mac_addr(char *refparam, struct dmctx *ctx, char **value)
int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
@ -250,7 +293,7 @@ int get_base_mac_addr(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_device_memory_bank(char *refparam, struct dmctx *ctx, char **value)
int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
@ -260,7 +303,7 @@ int get_device_memory_bank(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_device_memory_bank(char *refparam, struct dmctx *ctx, int action, char *value)
int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -271,7 +314,7 @@ int set_device_memory_bank(char *refparam, struct dmctx *ctx, int action, char *
}
return 0;
}
int get_catv_enabled(char *refparam, struct dmctx *ctx, char **value)
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *catv;
dmuci_get_option_value_string("catv", "catv", "enable", &catv);
@ -283,7 +326,7 @@ int get_catv_enabled(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_device_catvenabled(char *refparam, struct dmctx *ctx, int action, char *value)
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *stat;
@ -304,7 +347,7 @@ int set_device_catvenabled(char *refparam, struct dmctx *ctx, int action, char *
return 0;
}
int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, char **value)
int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
@ -316,7 +359,7 @@ int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, char **value
return 0;
}
int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, char **value)
int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
@ -328,7 +371,7 @@ int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_catv_temperature(char *refparam, struct dmctx *ctx, char **value)
int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
@ -340,7 +383,7 @@ int get_catv_temperature(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_catv_voltage(char *refparam, struct dmctx *ctx, char **value)
int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *str;
@ -352,27 +395,30 @@ int get_catv_voltage(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_vcf_name(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "name", value);
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "name", value);
return 0;
}
int get_vcf_version(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "version", value);
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "version", value);
return 0;
}
int get_vcf_date(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
DIR *dir;
struct dirent *d_file;
struct stat attr;
char path[128];
char date[sizeof "AAAA-MM-JJTHH:MM:SS.000Z"];
struct uci_section *vcf_sec = (struct uci_section *)data;
*value = "";
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "name", value);
dmuci_get_value_by_section_string(vcf_sec, "name", value);
if ((dir = opendir (DEFAULT_CONFIG_DIR)) != NULL) {
while ((d_file = readdir (dir)) != NULL) {
if(strcmp(*value, d_file->d_name) == 0) {
@ -382,69 +428,53 @@ int get_vcf_date(char *refparam, struct dmctx *ctx, char **value)
*value = dmstrdup(date);
}
}
closedir (dir);
closedir (dir);
}
return 0;
}
int get_vcf_backup_restore(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_backup_restore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "backup_restore", value);
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "backup_restore", value);
return 0;
}
int get_vcf_desc(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_desc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "description", value);
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "description", value);
return 0;
}
int get_vcf_alias(char *refparam, struct dmctx *ctx, char **value)
int get_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dev_vcf.vcf_sec, "vcf_alias", value);
struct uci_section *vcf_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(vcf_sec, "vcf_alias", value);
return 0;
}
int lookup_vcf_name(char *instance, char **value) {
int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *vcf_sec = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(vcf_sec, "vcf_alias", value);
return 0;
}
return 0;
}
int lookup_vcf_name(char *instance, char **value)
{
struct uci_section *s = NULL;
uci_path_foreach_option_eq(icwmpd, DMMAP, "vcf", "vcf_instance", instance, s) {
dmuci_get_value_by_section_string(s, "name", value);
}
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_DeviceInfo(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"DeviceInfo.") {
DMOBJECT(DMROOT"DeviceInfo.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("Manufacturer", ctx, "0", get_device_manufacturer, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("ManufacturerOUI", ctx, "0", get_device_manufactureroui, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("ModelName", ctx, "0", get_device_routermodel, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("ProductClass", ctx, "0", get_device_productclass, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("SerialNumber", ctx, "0", get_device_serialnumber, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("HardwareVersion", ctx, "0", get_device_hardwareversion, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("SoftwareVersion", ctx, "0", get_device_softwareversion, NULL, NULL, 1, 0, 2, NULL);
DMPARAM("UpTime", ctx, "0", get_device_info_uptime, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("DeviceLog", ctx, "0", get_device_devicelog, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SpecVersion", ctx, "0", get_device_specversion, NULL, NULL, 1, 1, UNDEF, NULL);
DMPARAM("ProvisioningCode", ctx, "1", get_device_provisioningcode, set_device_provisioningcode, NULL, 1, 0, 2, NULL);
DMPARAM("X_INTENO_SE_BaseMacAddr", ctx, "0", get_base_mac_addr, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("X_INTENO_SE_MemoryBank", ctx, "1", get_device_memory_bank, set_device_memory_bank, NULL, 0, 1, UNDEF, NULL);
DMPARAM("X_INTENO_SE_CATVEnabled", ctx, "1", get_catv_enabled, set_device_catvenabled, NULL, 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"DeviceInfo.X_INTENO_SE_CATV.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("Enabled", ctx, "1", get_catv_enabled, set_device_catvenabled, NULL, 0, 1, UNDEF, NULL);
DMPARAM("OpticalInputLevel", ctx, "0", get_catv_optical_input_level, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("RFOutputLevel", ctx, "0", get_catv_rf_output_level, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Temperature", ctx, "0", get_catv_temperature, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Voltage", ctx, "0", get_catv_voltage, NULL, NULL, 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"DeviceInfo.VendorConfigFile.", ctx, "0", 0, NULL, NULL, NULL);
SUBENTRY(entry_method_device_info_vcf, ctx);
return 0;
}
return FAULT_9005;
}
int check_file_dir(char *name)
{
@ -457,12 +487,13 @@ int check_file_dir(char *name)
return 1;
}
}
closedir(dir);
closedir(dir);
}
return 0;
}
inline int entry_method_device_info_vcf(struct dmctx *ctx)
int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *vcf = NULL, *vcf_last = NULL, *name;
struct uci_section *s = NULL, *del_sec = NULL;
@ -487,26 +518,11 @@ inline int entry_method_device_info_vcf(struct dmctx *ctx)
del_sec = s;
continue;
}
init_args_vcf(ctx, s);
vcf = handle_update_instance(1, ctx, &vcf_last, update_instance_alias_icwmpd, 3, s, "vcf_instance", "vcf_alias");
SUBENTRY(entry_method_device_info_vcf_instance, ctx, vcf);
vcf = handle_update_instance(1, dmctx, &vcf_last, update_instance_alias_icwmpd, 3, s, "vcf_instance", "vcf_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, vcf) == DM_STOP)
break;
}
if(del_sec)
DMUCI_DELETE_BY_SECTION(icwmpd, del_sec, NULL, NULL);
return 0;
}
inline int entry_method_device_info_vcf_instance(struct dmctx *ctx, char *ivcf)
{
IF_MATCH(ctx, DMROOT"DeviceInfo.VendorConfigFile.%s.", ivcf) {
DMOBJECT(DMROOT"DeviceInfo.VendorConfigFile.%s.", ctx, "0", 1, NULL, NULL, NULL, ivcf);
DMPARAM("Alias", ctx, "0", get_vcf_alias, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "0", get_vcf_name, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Version", ctx, "0", get_vcf_version, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Date", ctx, "0", get_vcf_date, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("Description", ctx, "0", get_vcf_desc, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("UseForBackupRestore", ctx, "0", get_vcf_backup_restore, NULL, "xsd:boolean", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -16,17 +16,49 @@
#define UPTIME "/proc/uptime"
#define DEFAULT_CONFIG_DIR "/etc/config/"
extern DMLEAF tDeviceInfoParams[];
extern DMLEAF tCatTvParams[];
extern DMLEAF tVcfParams[];
extern DMOBJ tDeviceInfoObj[];
char *get_deviceid_manufacturer();
char *get_deviceid_manufactureroui();
char *get_deviceid_productclass();
char *get_deviceid_serialnumber();
char *get_softwareversion();
int entry_method_root_DeviceInfo(struct dmctx *ctx);
int lookup_vcf_name(char *instance, char **value);
int browseVcfInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_device_manufacturer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_manufactureroui(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_routermodel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_productclass(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_serialnumber(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_hardwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_softwareversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_info_uptime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_devicelog(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_specversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_base_mac_addr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_optical_input_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_rf_output_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_temperature(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_catv_voltage(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_date(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_desc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vcf_backup_restore(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_device_provisioningcode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_memory_bank(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_device_catvenabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_vcf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
struct dev_vcf
{
struct uci_section *vcf_sec;
};
#endif

View file

@ -13,15 +13,40 @@
#include <stdio.h>
#include <time.h>
#include "cwmp.h"
#include "ubus.h"
#include "dmmem.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "managementserver.h"
#include "xml.h"
int get_management_server_url(char *refparam, struct dmctx *ctx, char **value)
/*** ManagementServer. ***/
DMLEAF tManagementServerParams[] = {
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, linker*/
{"URL", &DMWRITE, DMT_STRING, get_management_server_url, set_management_server_url, NULL, NULL},
{"Username", &DMWRITE, DMT_STRING, get_management_server_username, set_management_server_username, NULL, NULL},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_management_server_passwd, NULL, NULL},
{"ParameterKey", &DMREAD, DMT_STRING, get_management_server_key, NULL, &DMFINFRM, &DMNONE},
{"PeriodicInformEnable", &DMWRITE, DMT_BOOL, get_management_server_periodic_inform_enable, set_management_server_periodic_inform_enable, NULL, NULL},
{"PeriodicInformInterval", &DMWRITE, DMT_UNINT, get_management_server_periodic_inform_interval, set_management_server_periodic_inform_interval, NULL, NULL},
{"PeriodicInformTime", &DMWRITE, DMT_TIME, get_management_server_periodic_inform_time, set_management_server_periodic_inform_time, NULL, NULL},
{"ConnectionRequestURL", &DMREAD, DMT_STRING, get_management_server_connection_request_url, NULL, &DMFINFRM, &DMACTIVE},
{"ConnectionRequestUsername", &DMWRITE, DMT_STRING, get_management_server_connection_request_username, set_management_server_connection_request_username, NULL, NULL},
{"ConnectionRequestPassword", &DMWRITE, DMT_STRING, get_empty, set_management_server_connection_request_passwd, NULL, NULL},
{"HTTPCompressionSupported", &DMREAD, DMT_STRING, get_management_server_http_compression_supportted, NULL, NULL, NULL},
{"HTTPCompression", &DMWRITE, DMT_STRING, get_management_server_http_compression, set_management_server_http_compression, NULL, NULL},
{"LightweightNotificationProtocolsSupported", &DMREAD, DMT_STRING, get_lwn_protocol_supported, NULL, NULL, NULL},
{"LightweightNotificationProtocolsUsed", &DMWRITE, DMT_STRING, get_lwn_protocol_used, set_lwn_protocol_used, NULL, NULL},
{"UDPLightweightNotificationHost", &DMWRITE, DMT_STRING, get_lwn_host, set_lwn_host, NULL, NULL},
{"UDPLightweightNotificationPort", &DMWRITE, DMT_STRING, get_lwn_port, set_lwn_port, NULL, NULL},
{"CWMPRetryMinimumWaitInterval", &DMWRITE, DMT_UNINT, get_management_server_retry_min_wait_interval, set_management_server_retry_min_wait_interval, NULL, NULL},
{"CWMPRetryIntervalMultiplier", &DMWRITE, DMT_UNINT, get_management_server_retry_interval_multiplier, set_management_server_retry_interval_multiplier, NULL, NULL},
{"AliasBasedAddressing", &DMREAD, DMT_BOOL, get_alias_based_addressing, NULL, &DMFINFRM, NULL},
{"InstanceMode", &DMWRITE, DMT_STRING, get_instance_mode, set_instance_mode, NULL, NULL},
{0}
};
int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int i = 1;
char *dhcp = NULL, *pch = NULL, *spch = NULL;
@ -66,10 +91,10 @@ int get_management_server_url(char *refparam, struct dmctx *ctx, char **value)
*value = url;
else
*value = dmstrdup(DEFAULT_ACSURL);
return 0;
return 0;
}
int set_management_server_url(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -83,13 +108,13 @@ int set_management_server_url(char *refparam, struct dmctx *ctx, int action, cha
return 0;
}
int get_management_server_username(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "userid", value);
return 0;
}
int set_management_server_username(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -102,7 +127,7 @@ int set_management_server_username(char *refparam, struct dmctx *ctx, int action
return 0;
}
int set_management_server_passwd(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -115,19 +140,19 @@ int set_management_server_passwd(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_management_server_key(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "ParameterKey", value);
return 0;
}
int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_enable", value);
return 0;
}
int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -148,13 +173,13 @@ int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *c
return 0;
}
int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "periodic_inform_interval", value);
return 0;
}
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -167,7 +192,7 @@ int set_management_server_periodic_inform_interval(char *refparam, struct dmctx
return 0;
}
int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
time_t time_value;
@ -184,7 +209,7 @@ int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx
return 0;
}
int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct tm tm;
char *p, buf[16];
@ -203,7 +228,7 @@ int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx
return 0;
}
int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *ip, *port, *iface;
@ -219,13 +244,13 @@ int get_management_server_connection_request_url(char *refparam, struct dmctx *c
return 0;
}
int get_management_server_connection_request_username(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "userid", value);
return 0;
}
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -238,7 +263,7 @@ int set_management_server_connection_request_username(char *refparam, struct dmc
return 0;
}
int set_management_server_connection_request_passwd(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_connection_request_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -251,13 +276,13 @@ int set_management_server_connection_request_passwd(char *refparam, struct dmctx
return 0;
}
int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, char **value)
int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "UDP";
return 0;
}
int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, char **value)
int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
char *tmp;
@ -271,7 +296,7 @@ int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, int action, char *value)
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -290,13 +315,13 @@ int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
}
int get_lwn_host(char *refparam, struct dmctx *ctx, char **value)
int get_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "lwn", "hostname", value);
return 0;
}
int set_lwn_host(char *refparam, struct dmctx *ctx, int action, char *value)
int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -309,13 +334,13 @@ int set_lwn_host(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
}
int get_lwn_port(char *refparam, struct dmctx *ctx, char **value)
int get_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "lwn", "port", value);
return 0;
}
int set_lwn_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -328,19 +353,19 @@ int set_lwn_port(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
}
int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "GZIP,Deflate";
return 0;
}
int get_management_server_http_compression(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "compression", value);
return 0;
}
int set_management_server_http_compression(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -356,13 +381,13 @@ int set_management_server_http_compression(char *refparam, struct dmctx *ctx, in
return 0;
}
int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "retry_min_wait_interval", value);
return 0;
}
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
@ -380,13 +405,13 @@ int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *
return 0;
}
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, char **value)
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "acs", "retry_interval_multiplier", value);
return 0;
}
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, int action, char *value)
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int a;
switch (action) {
@ -404,7 +429,7 @@ int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx
return 0;
}
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, char **value)
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", value);
if((*value)[0] == '\0'|| atoi(*value) <= AMD_4) {
@ -416,13 +441,13 @@ int get_alias_based_addressing(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_instance_mode(char *refparam, struct dmctx *ctx, char **value)
int get_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "instance_mode", value);
return 0;
}
int set_instance_mode(char *refparam, struct dmctx *ctx, int action, char *value)
int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -438,32 +463,4 @@ int set_instance_mode(char *refparam, struct dmctx *ctx, int action, char *value
return 0;
}
int entry_method_root_ManagementServer(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"ManagementServer.") {
DMOBJECT(DMROOT"ManagementServer.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("URL", ctx, "1", get_management_server_url, set_management_server_url, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Username", ctx, "1", get_management_server_username, set_management_server_username, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Password", ctx, "1", get_empty, set_management_server_passwd, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ParameterKey", ctx, "0", get_management_server_key, NULL, NULL, 1, 0, 0, NULL);
DMPARAM("PeriodicInformEnable", ctx, "1", get_management_server_periodic_inform_enable, set_management_server_periodic_inform_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("PeriodicInformInterval", ctx, "1", get_management_server_periodic_inform_interval, set_management_server_periodic_inform_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("PeriodicInformTime", ctx, "1", get_management_server_periodic_inform_time, set_management_server_periodic_inform_time, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("ConnectionRequestURL", ctx, "0", get_management_server_connection_request_url, NULL, NULL, 1, 0, 2, NULL);
DMPARAM("ConnectionRequestUsername", ctx, "1", get_management_server_connection_request_username, set_management_server_connection_request_username, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ConnectionRequestPassword", ctx, "1", get_empty, set_management_server_connection_request_passwd, NULL, 0, 1, UNDEF, NULL);
DMPARAM("HTTPCompressionSupported", ctx, "0", get_management_server_http_compression_supportted, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("HTTPCompression", ctx, "1", get_management_server_http_compression, set_management_server_http_compression, NULL, 0, 1, UNDEF, NULL);
DMPARAM("LightweightNotificationProtocolsSupported", ctx, "0", get_lwn_protocol_supported, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("LightweightNotificationProtocolsUsed", ctx, "1", get_lwn_protocol_used, set_lwn_protocol_used, NULL, 0, 1, UNDEF, NULL);
DMPARAM("UDPLightweightNotificationHost", ctx, "1", get_lwn_host, set_lwn_host, NULL, 0, 1, UNDEF, NULL);
DMPARAM("UDPLightweightNotificationPort", ctx, "1", get_lwn_port, set_lwn_port, NULL, 0, 1, UNDEF, NULL);
DMPARAM("CWMPRetryMinimumWaitInterval", ctx, "1", get_management_server_retry_min_wait_interval, set_management_server_retry_min_wait_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("CWMPRetryIntervalMultiplier", ctx, "1", get_management_server_retry_interval_multiplier, set_management_server_retry_interval_multiplier, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("AliasBasedAddressing", ctx, "0", get_alias_based_addressing, NULL, "xsd:boolean", 1, 1, UNDEF, NULL);
DMPARAM("InstanceMode", ctx, "1", get_instance_mode, set_instance_mode, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -10,6 +10,44 @@
*/
#ifndef __MANAGEMENT_SERVER_H
#define __MANAGEMENT_SERVER_H
#include "dmcwmp.h"
extern DMLEAF tManagementServerParams[];
int entry_method_root_ManagementServer(struct dmctx *ctx);
#endif
int get_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_empty(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_connection_request_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_http_compression_supportted(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_protocol_supported(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_management_server_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_periodic_inform_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_connection_request_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_connection_request_passwd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_http_compression(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_protocol_used(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lwn_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_retry_min_wait_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_instance_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -4,23 +4,239 @@
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2015 Inteno Broadband Technology AB
* Author MOHAMED Kallel <mohamed.kallel@pivasoftware.com>
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author Feten Besbes <feten.besbes@pivasoftware.com>
*
* Copyright (C) 2012-2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#include "dmuci.h"
#include "dmcwmp.h"
#include "root.h"
#include "deviceinfo.h"
#include "managementserver.h"
#include "times.h"
#include "upnp.h"
#include "voice_services.h"
#include "x_inteno_se_ice.h"
#include "x_inteno_se_igmp.h"
#include "x_inteno_se_ipacccfg.h"
#include "x_inteno_se_logincfg.h"
#include "x_inteno_se_power_mgmt.h"
#include "x_inteno_syslog.h"
#include "softwaremodules.h"
#include "xmpp.h"
#include "x_inteno_se_owsd.h"
#include "x_inteno_se_dropbear.h"
#include "x_inteno_se_buttons.h"
#ifdef UPNP_TR064
#include "upnp_deviceinfo.h"
#include "upnp_configuration.h"
#include "upnp_monitoring.h"
#endif
int entry_method_root(struct dmctx *ctx)
{
char *val = NULL;
IF_MATCH_ROOT(ctx) {
DMOBJECT(DMROOT, ctx, "0", 0, NULL, NULL, NULL);
return 0;
}
return FAULT_9005;
}
#ifdef DATAMODEL_TR181
#include "ip.h"
#include "ethernet.h"
#include "bridging.h"
#include "wifi.h"
#include "wan.h"
#include "dhcp.h"
#include "hosts.h"
#include "nat.h"
#include "ppp.h"
#include "routing.h"
#endif
#ifdef DATAMODEL_TR098
#include "landevice.h"
#include "wandevice.h"
#include "ippingdiagnostics.h"
#include "lan_interfaces.h"
#include "layer_3_forwarding.h"
#include "x_inteno_se_wifi.h"
#include "layer_2_bridging.h"
#include "downloaddiagnostic.h"
#include "uploaddiagnostic.h"
#include "deviceconfig.h"
#endif
/* *** CWMP *** */
DMOBJ tEntryObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, NOTIFICATION, nextobj, leaf, linker*/
{(char *)&DMROOT, &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRootObj, NULL, NULL},
{0}
};
DMOBJ tRootObj[] = {
/* OBJ permission, addobj, delobj, browseinstobj, finform, nextobj, leaf, notification, linker*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL},
{"Services", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tServiceObj, NULL, NULL},
{"X_INTENO_SE_ICE", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IceParam, NULL},
{"X_INTENO_SE_IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IgmpParam, NULL},
{"X_INTENO_SE_IpAccCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSe_IpAccObj, NULL, NULL},
{"X_INTENO_SE_LoginCfg", &DMREAD, NULL, NULL, NULL, NULL,NULL, &DMNONE,NULL, tSe_LoginCfgParam, NULL},
{"X_INTENO_SE_PowerManagement", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_PowerManagementParam, NULL},
{"X_INTENO_SE_SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL},
{"X_INTENO_SE_Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIntenoSeOwsdObj, XIntenoSeOwsdParams, NULL},
{"X_INTENO_SE_Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIntenoDropbear, NULL, &DMNONE, NULL, X_INTENO_SE_DropbearParams, NULL},
{"X_INTENO_SE_Buttons", &DMREAD, NULL, NULL, NULL, browseXIntenoButton, NULL, &DMNONE, NULL, X_INTENO_SE_ButtonParams, NULL},
#ifdef DATAMODEL_TR098
{"LANDevice", &DMREAD, NULL, NULL, NULL, browselandeviceInst, &DMFINFRM, &DMNONE,tLANDeviceObj, tLANDeviceParam, NULL},
{"WANDevice", &DMREAD, NULL, NULL, NULL, browsewandeviceInst, &DMFINFRM, &DMWANConnectionDevicenotif,tWANDeviceObj, tWANDeviceParam, NULL},
{"LANInterfaces", &DMREAD, NULL, NULL, check_laninterfaces, NULL, &DMFINFRM, &DMNONE,tLANInterfacesObj, tLANInterfacesParam, NULL},
{"IPPingDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tIPPingDiagnosticsParam, NULL},
{"Layer3Forwarding", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer3ForwardingObj, tLayer3ForwardingParam, NULL},
{"Layer2Bridging", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer2BridgingObj, NULL, NULL},
{"X_INTENO_SE_Wifi", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tsewifiObj, tsewifiParam, NULL},
{"DownloadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tDownloadDiagnosticsParam, NULL},
{"UploadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tUploadDiagnosticsParam, NULL},
{"DeviceConfig", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tDeviceConfigParam, NULL},
#endif
#ifdef XMPP_ENABLE
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL},
#endif
#ifdef DATAMODEL_TR181
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWifiObj, tWifiParams, NULL},
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL},
{"Ethernet", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetObj, NULL, NULL},
{"DSL",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDslObj, NULL, NULL},
{"ATM",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tAtmObj, NULL, NULL},
{"PTM", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tPtmObj, NULL, NULL},
{"DHCPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDhcpv4Obj, NULL, NULL},
{"Hosts", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, thostsObj, thostsParam, NULL},
{"NAT", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tnatObj, NULL, NULL},
{"PPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tpppObj, NULL, NULL},
{"Routing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingObj, tRoutingParam, NULL},
#endif
{0}
};
/*** UPNP ***/
#ifdef UPNP_TR064
DMOBJ tEntryObjUPNP[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, NOTIFICATION, nextobj, leaf, linker*/
{(char *)&DMROOT, &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRootObjUPNP, NULL, NULL},
{0}
};
DMOBJ tRootObjUPNP[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, NOTIFICATION, nextobj, leaf, linker*/
{"BBF", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRootObjUPNPBBF, NULL, NULL},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRootObjUPNPDMROOT, NULL, NULL},
{0}
};
DMOBJ tRootObjUPNPDMROOT[] = {
{"DM", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE, tRootObjUPNPDM, NULL, NULL},
{0}
};
DMOBJ tRootObjUPNPDM[] = {
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpDeviceInfoObj, upnpDeviceInfoParams, NULL},
{"Configuration", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpConfigurationObj, NULL, NULL},
{"Monitoring", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,upnpMonitoringObj, upnpMonitoringParams, NULL},
{0}
};
DMOBJ tRootObjUPNPBBF[] = {
/* OBJ permission, addobj, delobj, browseinstobj, finform, nextobj, leaf, notification, linker*/
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tDeviceInfoObj, tDeviceInfoParams, NULL},
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tManagementServerParams, NULL},
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tTimeParams, NULL},
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tUPnPObj, NULL, NULL},
{"VoiceService", &DMREAD, NULL, NULL, NULL, browseVoiceServiceInst, NULL, NULL, tVoiceServiceObj, tVoiceServiceParam, NULL},
{"X_INTENO_SE_ICE", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IceParam, NULL},
{"X_INTENO_SE_IGMP", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_IgmpParam, NULL},
{"X_INTENO_SE_IpAccCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSe_IpAccObj, NULL, NULL},
{"X_INTENO_SE_LoginCfg", &DMREAD, NULL, NULL, NULL, NULL,NULL, &DMNONE,NULL, tSe_LoginCfgParam, NULL},
{"X_INTENO_SE_PowerManagement", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_PowerManagementParam, NULL},
{"X_INTENO_SE_SyslogCfg", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,NULL, tSe_SyslogCfgParam, NULL},
{"SoftwareModules", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,tSoftwareModulesObj, NULL, NULL},
{"X_INTENO_SE_Owsd", &DMREAD, NULL, NULL, NULL, NULL, NULL, &DMNONE,XIntenoSeOwsdObj, XIntenoSeOwsdParams, NULL},
{"X_INTENO_SE_Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIntenoDropbear, NULL, &DMNONE, NULL, X_INTENO_SE_DropbearParams, NULL},
{"X_INTENO_SE_Buttons", &DMREAD, NULL, NULL, NULL, browseXIntenoButton, NULL, &DMNONE, NULL, X_INTENO_SE_ButtonParams, NULL},
#ifdef DATAMODEL_TR098
{"LANDevice", &DMREAD, NULL, NULL, NULL, browselandeviceInst, &DMFINFRM, &DMNONE,tLANDeviceObj, tLANDeviceParam, NULL},
{"WANDevice", &DMREAD, NULL, NULL, NULL, browsewandeviceInst, &DMFINFRM, &DMWANConnectionDevicenotif,tWANDeviceObj, tWANDeviceParam, NULL},
{"LANInterfaces", &DMREAD, NULL, NULL, check_laninterfaces, NULL, &DMFINFRM, &DMNONE,tLANInterfacesObj, tLANInterfacesParam, NULL},
{"IPPingDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tIPPingDiagnosticsParam, NULL},
{"Layer3Forwarding", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer3ForwardingObj, tLayer3ForwardingParam, NULL},
{"Layer2Bridging", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tLayer2BridgingObj, NULL, NULL},
{"X_INTENO_SE_Wifi", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,tsewifiObj, NULL, NULL},
{"DownloadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tDownloadDiagnosticsParam, NULL},
{"UploadDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, &DMFINFRM, &DMNONE,NULL, tUploadDiagnosticsParam, NULL},
#endif
#ifdef XMPP_ENABLE
{"XMPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,tXMPPObj, tXMPPParams, NULL},
#endif
#ifdef DATAMODEL_TR181
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL},
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tWifiObj, NULL, NULL},
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL},
{"Ethernet", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetObj, NULL, NULL},
{"DSL",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDslObj, NULL, NULL},
{"ATM",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tAtmObj, NULL, NULL},
{"PTM", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tPtmObj, NULL, NULL},
{"DHCPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDhcpv4Obj, NULL, NULL},
{"Hosts", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, thostsObj, thostsParam, NULL},
{"NAT", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tnatObj, NULL, NULL},
{"PPP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tpppObj, NULL, NULL},
{"Routing", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tRoutingObj, tRoutingParam, NULL},
#endif
{0}
};
UPNP_SUPPORTED_DM tUPNPSupportedDM[] = {
{"/UPnP/DM/DeviceInfo/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL, "UPnP DeviceInfo from "DMROOT_DESC, ""},
{"/UPnP/DM/Configuration/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL, "Configuration from "DMROOT_DESC, ""},
{"/UPnP/DM/Monitoring/", "urn:UPnP:Parent Device:1:ConfigurationManagement:2", DMROOT_URL, "Monitoring from "DMROOT_DESC, ""},
{"/BBF/DeviceInfo/", DMROOT_URI, DMROOT_URL, "DeviceInfo from "DMROOT_DESC, ""},
{"/BBF/ManagementServer/", DMROOT_URI, DMROOT_URL, "ManagementServer from "DMROOT_DESC, ""},
{"/BBF/Time/", DMROOT_URI, DMROOT_URL, "Time from "DMROOT_DESC, ""},
{"/BBF/UPnP/", DMROOT_URI, DMROOT_URL, "UPnP from "DMROOT_DESC, ""},
{"/BBF/VoiceService/", "urn:broadband-forum-org:wt-104-2-0-0", "https://www.broadband-forum.org/cwmp/tr-104-2-0-0.html", "TR-104 Voice:2 Service Object definition", ""},
{"/BBF/X_INTENO_SE_ICE/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/X_INTENO_SE_IGMP/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for ICE", ""},
{"/BBF/X_INTENO_SE_IpAccCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for IGMP", ""},
{"/BBF/X_INTENO_SE_LoginCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for LoginCfg", ""},
{"/BBF/X_INTENO_SE_PowerManagement/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for PowerManagement", ""},
{"/BBF/X_INTENO_SE_SyslogCfg/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for SyslogCfg", ""},
{"/BBF/SoftwareModules/", DMROOT_URI, DMROOT_URL, "SoftwareModules from "DMROOT_DESC, ""},
{"/BBF/X_INTENO_SE_Owsd/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Owsd", ""},
{"/BBF/X_INTENO_SE_Dropbear/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Dropbear", ""},
{"/BBF/X_INTENO_SE_Buttons/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for Buttons", ""},
#ifdef DATAMODEL_TR098
{"/BBF/LANDevice/", DMROOT_URI, DMROOT_URL, "LANDevice from "DMROOT_DESC, ""},
{"/BBF/WANDevice/", DMROOT_URI, DMROOT_URL, "WANDevice from "DMROOT_DESC, ""},
{"/BBF/LANInterfaces/", DMROOT_URI, DMROOT_URL, "LANInterfaces from "DMROOT_DESC, ""},
{"/BBF/IPPingDiagnostics/", DMROOT_URI, DMROOT_URL, "IPPingDiagnostics from "DMROOT_DESC, ""},
{"/BBF/Layer3Forwarding/", DMROOT_URI, DMROOT_URL, "Layer3Forwarding from "DMROOT_DESC, ""},
{"/BBF/Layer2Bridging/", DMROOT_URI, DMROOT_URL, "Layer2Bridging from "DMROOT_DESC, ""},
{"/BBF/X_INTENO_SE_Wifi/", "urn:intenogroup-com:na", "https://www.intenogroup.com/", "Inteno extension for WiFi", ""},
{"/BBF/DownloadDiagnostics/", DMROOT_URI, DMROOT_URL, "DownloadDiagnostics from "DMROOT_DESC, ""},
{"/BBF/UploadDiagnostics/", DMROOT_URI, DMROOT_URL, "UploadDiagnostics from "DMROOT_DESC, ""},
#endif
#ifdef XMPP_ENABLE
{"/BBF/XMPP/", DMROOT_URI, DMROOT_URL, "XMPP from "DMROOT_DESC, ""},
#endif
#ifdef DATAMODEL_TR181
{"/BBF/Bridging/", DMROOT_URI, DMROOT_URL, "Bridging from "DMROOT_DESC, ""},
{"/BBF/WiFi/", DMROOT_URI, DMROOT_URL, "WiFi from "DMROOT_DESC, ""},
{"/BBF/IP/", DMROOT_URI, DMROOT_URL, "IP from "DMROOT_DESC, ""},
{"/BBF/Ethernet/", DMROOT_URI, DMROOT_URL, "Ethernet from "DMROOT_DESC, ""},
{"/BBF/DSL/", DMROOT_URI, DMROOT_URL, "DSL from "DMROOT_DESC, ""},
{"/BBF/ATM/", DMROOT_URI, DMROOT_URL, "ATM from "DMROOT_DESC, ""},
{"/BBF/PTM/", DMROOT_URI, DMROOT_URL, "PTM from "DMROOT_DESC, ""},
{"/BBF/DHCPv4/", DMROOT_URI, DMROOT_URL, "DHCPv4 from "DMROOT_DESC, ""},
{"/BBF/Hosts/", DMROOT_URI, DMROOT_URL, "Hosts from "DMROOT_DESC, ""},
{"/BBF/NAT/", DMROOT_URI, DMROOT_URL, "NAT from "DMROOT_DESC, ""},
{"/BBF/PPP/", DMROOT_URI, DMROOT_URL, "PPP from "DMROOT_DESC, ""},
{"/BBF/Routing/", DMROOT_URI, DMROOT_URL, "Routing from "DMROOT_DESC, ""},
#endif
{0}
};
#endif

View file

@ -13,6 +13,33 @@
#ifndef __ROOT_H
#define __ROOT_H
#include "dmcwmp.h"
int entry_method_root(struct dmctx *ctx);
extern DMOBJ tEntryObj[];
extern DMOBJ tRootObj[];
#ifdef UPNP_TR064
extern DMOBJ tEntryObjUPNP[];
extern DMOBJ tRootObjUPNP[];
extern DMOBJ tRootObjUPNPDMROOT[];
extern DMOBJ tRootObjUPNPDM[];
extern DMOBJ tRootObjUPNPBBF[];
extern UPNP_SUPPORTED_DM tUPNPSupportedDM[];
#define UPNP_SUPPORTED_PARAMETERS_VERSION 1 //Should be incremented each time the Parameters are updated
#define UPNP_SUPPORTED_DATAMODEL_VERSION 1 //Should be incremented each time the tUPNPSupportedDM array is updated
#endif
#ifdef DATAMODEL_TR098
#define DMROOT_URI "urn:broadband-forum-org:tr-098-1-8-0"
#define DMROOT_URL "https://www.broadband-forum.org/cwmp/tr-098-1-8-0.html"
#define DMROOT_DESC "TR-098 InternetGatewayDevice:1 Root Object definition"
#endif
#ifdef DATAMODEL_TR181
#define DMROOT_URI "urn:broadband-forum-org:tr-181-2-11-0"
#define DMROOT_URL "https://www.broadband-forum.org/cwmp/tr-181-2-11-0.html"
#define DMROOT_DESC "TR-181 Device:2 Root Object definition"
#endif
#endif

View file

@ -12,80 +12,87 @@
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include "cwmp.h"
#include "diagnostic.h"
#include "ubus.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "softwaremodules.h"
struct software_module cur_software_module = {0};
inline int entry_softwaremodules_deploymentunit_instance(struct dmctx *ctx, char *idu);
inline int init_args_du_entry(struct dmctx *ctx, struct uci_section *s)
/*** SoftwareModules. ***/
DMOBJ tSoftwareModulesObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"DeploymentUnit", &DMREAD, NULL, NULL, NULL, browsesoftwaremodules_deploymentunitInst, NULL, NULL, NULL, tDeploymentUnitParams, NULL},
{0}
};
DMLEAF tDeploymentUnitParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"UUID", &DMREAD, DMT_STRING, get_deploymentunit_uuid, NULL, NULL, NULL},
{"Name", &DMREAD, DMT_STRING, get_deploymentunit_name, NULL, NULL, NULL},
{"Resolved", &DMREAD, DMT_BOOL, get_deploymentunit_resolved, NULL, NULL, NULL},
{"URL", &DMREAD, DMT_STRING, get_deploymentunit_url, NULL, NULL, NULL},
{"Vendor", &DMREAD, DMT_STRING, get_deploymentunit_vendor, NULL, NULL, NULL},
{"Version", &DMREAD, DMT_STRING, get_deploymentunit_version, NULL, NULL, NULL},
{"ExecutionEnvRef", &DMREAD, DMT_STRING, get_deploymentunit_execution_env_ref, NULL, NULL, NULL},
{0}
};
int get_deploymentunit_uuid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *args = &cur_software_module;
ctx->args = (void *)args;
args->softsection = s;
return 0;
}
struct uci_section *softsection = (struct uci_section *)data;
int get_deploymentunit_uuid(char *refparam, struct dmctx *ctx, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
dmuci_get_value_by_section_string(softawreargs->softsection, "uuid", value);
dmuci_get_value_by_section_string(softsection, "uuid", value);
return 0;
}
int get_deploymentunit_name(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "name", value);
dmuci_get_value_by_section_string(softsection, "name", value);
return 0;
}
int get_deploymentunit_resolved(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_resolved(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "resolved", value);
dmuci_get_value_by_section_string(softsection, "resolved", value);
return 0;
}
int get_deploymentunit_url(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "url", value);
dmuci_get_value_by_section_string(softsection, "url", value);
return 0;
}
int get_deploymentunit_vendor(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_vendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "vendor", value);
dmuci_get_value_by_section_string(softsection, "vendor", value);
return 0;
}
int get_deploymentunit_version(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "version", value);
dmuci_get_value_by_section_string(softsection, "version", value);
return 0;
}
int get_deploymentunit_execution_env_ref(char *refparam, struct dmctx *ctx, char **value)
int get_deploymentunit_execution_env_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct software_module *softawreargs = (struct software_module *)ctx->args;
struct uci_section *softsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(softawreargs->softsection, "execution_env_ref", value);
dmuci_get_value_by_section_string(softsection, "execution_env_ref", value);
return 0;
}
@ -222,44 +229,21 @@ char *get_softwaremodules_version(char *uuid)
return "";
}
inline int entry_softwaremodules_deploymentunit(struct dmctx *ctx)
int browsesoftwaremodules_deploymentunitInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *idu = NULL, *idu_last = NULL;
char *permission = "1";
struct uci_section *s = NULL;
uci_path_foreach_sections(icwmpd, "dmmap", "deploymentunit", s) {
init_args_du_entry(ctx, s);
idu = handle_update_instance(1, ctx, &idu_last, update_instance_alias_icwmpd, 3, s, "duinstance", "duinstance_alias");
SUBENTRY(entry_softwaremodules_deploymentunit_instance, ctx, idu);
idu = handle_update_instance(1, dmctx, &idu_last, update_instance_alias_icwmpd, 3, s, "duinstance", "duinstance_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, idu) == DM_STOP)
break;
}
return 0;
}
inline int entry_softwaremodules_deploymentunit_instance(struct dmctx *ctx, char *idu)
{
IF_MATCH(ctx, DMROOT"SoftwareModules.DeploymentUnit.%s.", idu) {
DMOBJECT(DMROOT"SoftwareModules.DeploymentUnit.%s.", ctx, "0", 1, NULL, NULL, NULL, idu);
DMPARAM("UUID", ctx, "0", get_deploymentunit_uuid, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "0", get_deploymentunit_name, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Resolved", ctx, "0", get_deploymentunit_resolved, NULL, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("URL", ctx, "0", get_deploymentunit_url, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Vendor", ctx, "0", get_deploymentunit_vendor, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Version", ctx, "0", get_deploymentunit_version, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ExecutionEnvRef", ctx, "0", get_deploymentunit_execution_env_ref, NULL, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
int entry_method_root_software_modules(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"SoftwareModules.") {
DMOBJECT(DMROOT"SoftwareModules.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"SoftwareModules.DeploymentUnit.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_softwaremodules_deploymentunit, ctx);
return 0;
}
return FAULT_9005;
}

View file

@ -10,12 +10,7 @@
#ifndef __SOFTWARE_MODULE_H
#define __SOFTWARE_MODULE_H
struct software_module
{
struct uci_section *softsection;
};
int update_softwaremodules_url(char *uuid, char *url);
char *get_softwaremodules_url(char *uuid);
char *get_softwaremodules_uuid(char *url);
char *get_softwaremodules_username(char *uuid);
char *get_softwaremodules_pass(char *uuid);
@ -23,5 +18,17 @@ char *get_softwaremodules_instance(char *uuid);
char *get_softwaremodules_version(char *uuid);
char *add_softwaremodules_deploymentunit(char *uuid, char*url, char *username, char *password, char *name, char *version);
char *get_softwaremodules_name(char *uuid);
int entry_method_root_software_modules(struct dmctx *ctx);
char *get_softwaremodules_url(char *uuid);
extern DMLEAF tDeploymentUnitParams[];
extern DMOBJ tSoftwareModulesObj[];
int browsesoftwaremodules_deploymentunitInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_deploymentunit_uuid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_resolved(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_vendor(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_deploymentunit_execution_env_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -17,7 +17,19 @@
#include "times.h"
#include "dmcommon.h"
int get_time_enable(char *refparam, struct dmctx *ctx, char **value)
/*** Time. ***/
DMLEAF tTimeParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification, linker*/
{"Enable", &DMWRITE, DMT_BOOL, get_time_enable, set_time_enable, NULL, NULL},
{"NTPServer1", &DMWRITE, DMT_STRING, get_time_ntpserver1, set_time_ntpserver1, NULL, NULL},
{"NTPServer2", &DMWRITE, DMT_STRING, get_time_ntpserver2, set_time_ntpserver2, NULL, NULL},
{"NTPServer3", &DMWRITE, DMT_STRING, get_time_ntpserver3, set_time_ntpserver3, NULL, NULL},
{"NTPServer4", &DMWRITE, DMT_STRING, get_time_ntpserver4, set_time_ntpserver4, NULL, NULL},
{"NTPServer5", &DMWRITE, DMT_STRING, get_time_ntpserver5, set_time_ntpserver5, NULL, NULL},
{0}
};
int get_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *path = "/etc/rc.d/*sysntpd";
@ -28,7 +40,7 @@ int get_time_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_time_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
@ -90,27 +102,27 @@ int get_time_ntpserver(char *refparam, struct dmctx *ctx, char **value, int inde
return 0;
}
int get_time_ntpserver1(char *refparam, struct dmctx *ctx, char **value)
int get_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 1);
}
int get_time_ntpserver2(char *refparam, struct dmctx *ctx, char **value)
int get_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 2);
}
int get_time_ntpserver3(char *refparam, struct dmctx *ctx, char **value)
int get_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 3);
}
int get_time_ntpserver4(char *refparam, struct dmctx *ctx, char **value)
int get_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 4);
}
int get_time_ntpserver5(char *refparam, struct dmctx *ctx, char **value)
int get_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_time_ntpserver(refparam, ctx, value, 5);
}
@ -161,42 +173,28 @@ int set_time_ntpserver(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
}
int set_time_ntpserver1(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 1);
}
int set_time_ntpserver2(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 2);
}
int set_time_ntpserver3(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 3);
}
int set_time_ntpserver4(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 4);
}
int set_time_ntpserver5(char *refparam, struct dmctx *ctx, int action, char *value)
int set_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_time_ntpserver(refparam, ctx, action, value, 5);
}
int entry_method_root_Time(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"Time.") {
DMOBJECT(DMROOT"Time.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("Enable", ctx, "1", get_time_enable, set_time_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("NTPServer1", ctx, "1", get_time_ntpserver1, set_time_ntpserver1, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NTPServer2", ctx, "1", get_time_ntpserver2, set_time_ntpserver2, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NTPServer3", ctx, "1", get_time_ntpserver3, set_time_ntpserver3, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NTPServer4", ctx, "1", get_time_ntpserver4, set_time_ntpserver4, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NTPServer5", ctx, "1", get_time_ntpserver5, set_time_ntpserver5, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,6 +1,20 @@
#ifndef __TIMES_H
#define __TIMES_H
int entry_method_root_Time(struct dmctx *ctx);
extern DMLEAF tTimeParams[];
#endif
int get_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_time_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver2(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver3(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver4(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_time_ntpserver5(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -18,7 +18,21 @@
#include "dmcommon.h"
#include "upnp.h"
int get_upnp_enable(char *refparam, struct dmctx *ctx, char **value)
/*** UPnP. ***/
DMOBJ tUPnPObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf, linker*/
{"Device", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tUPnPDeviceParams, NULL},
{0}
};
DMLEAF tUPnPDeviceParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Enable", &DMWRITE, DMT_BOOL, get_upnp_enable, set_upnp_enable, NULL, NULL},
{"X_INTENO_SE_Status", &DMREAD, DMT_STRING, get_upnp_status, NULL, NULL, NULL},
{0}
};
int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("upnpd","config","enabled", value);
if ((*value)[0] == '\0') {
@ -27,7 +41,7 @@ int get_upnp_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_upnp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
@ -47,7 +61,7 @@ int set_upnp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
}
int get_upnp_status(char *refparam, struct dmctx *ctx, char **value)
int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
pid_t pid = get_pid("miniupnpd");
@ -59,15 +73,3 @@ int get_upnp_status(char *refparam, struct dmctx *ctx, char **value)
}
return 0;
}
int entry_method_root_upnp(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"UPnP.") {
DMOBJECT(DMROOT"UPnP.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"UPnP.Device.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("Enable", ctx, "1", get_upnp_enable, set_upnp_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("X_INTENO_SE_Status", ctx, "0", get_upnp_status, NULL, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,6 +1,12 @@
#ifndef __UPNP_H
#define __UPNP_H
int entry_method_root_upnp(struct dmctx *ctx);
extern DMLEAF tUPnPDeviceParams[];
extern DMOBJ tUPnPObj[];
#endif
int get_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upnp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upnp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

File diff suppressed because it is too large Load diff

View file

@ -13,6 +13,30 @@
#ifndef __VOICE_H
#define __VOICE_H
extern DMOBJ tServiceObj[];
extern DMOBJ tVoiceServiceObj[];
extern DMLEAF tVoiceServiceParam[];
extern DMLEAF tCapabilitiesParams[];
extern DMOBJ tCapabilitiesObj[];
extern DMLEAF tSIPParams[];
extern DMLEAF tCodecsParams[] ;
extern DMOBJ tProfileObj[] ;
extern DMLEAF tProfileSIPParams[];
extern DMLEAF tServiceProviderInfoParams[];
extern DMLEAF tProfileParam[];
extern DMOBJ tLineObj[];
extern DMOBJ tLineCodecObj[];
extern DMLEAF tLineCodecListParams[];
extern DMLEAF tLineSIPParams[];
extern DMLEAF tVoiceProcessingParams[];
extern DMLEAF tCallingFeaturesParams[];
extern DMLEAF tLineParams[];
extern DMLEAF tRTPParams[];
extern DMOBJ tRTPObj[];
extern DMLEAF tSRTPParam[];
extern DMLEAF tRTCPParams[];
extern DMLEAF tFaxT38Params[];
/*Args of get_voice_service_capabilities_codecs_generic*/
struct codec_args
{
@ -85,11 +109,6 @@ struct codec
char *priority;
};
struct service_args
{
struct uci_section *service_section;
};
enum enum_cap_sip_codecs {
SIP_CODEC_G723,
SIP_CODEC_GSM,
@ -112,6 +131,132 @@ enum enum_cap_sip_codecs {
SIP_CODEC_TESTLAW
};
int entry_method_root_Service(struct dmctx *ctx);
bool dm_service_enable_set(void);
int browseVoiceServiceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseCodecsInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseProfileInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseLineCodecListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_profile_object(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_profile_object(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_line_object(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_line_object(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_profile_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_line_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_true_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_max_session_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_signal_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_regions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_false_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_role(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_extension(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_auth_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_enc_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_tls_key_protocols(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_entry_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_codec(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_bitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_pperiod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_signalprotocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_max_sessions(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_number_of_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_profile_region(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_proxyserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_proxy_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_registerserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_registrar_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_registration_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_x_002207_call_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_serviceproviderinfo_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_portmax(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_rtcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_voice_profile_line_callstate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_x_002207_line_profile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_x_002207_brcm_line(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_confort_noise_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_voice_processing_cancellation_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_calling_features_caller_id_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_sip_auth_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_sip_uri(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_codec_entry_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int capabilities_sip_codecs_get_codec(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int capabilities_sip_codecs_get_bitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_capabilities_sip_codecs_pperiod(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_directory_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_service_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_cap_codec_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_reset(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_signaling_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_dtmfmethod(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_proxyserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_proxy_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_proxy_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_registerserver(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_sip_registerserverport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_registrar_server_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_user_agent_transport(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_outbound_proxy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_outbound_proxy_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_registration_period(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_re_invite_expires(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_x_002207_call_lines(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_serviceproviderinfo_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_fax_t38_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_portmin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_rtp_localportmax(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_rtcp_txrepeatinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_service_vp_rtp_srtp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_voice_profile_line_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_directory_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_x_002207_line_profile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_x_002207_brcm_line(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_confort_noise_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_calling_features_caller_id_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_voice_processing_cancellation_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_calling_features_callwaiting(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_auth_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_auth_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_sip_uri(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_packetization(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_line_codec_list_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_sip_profile_region(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_voice_service_max_line();
#endif

View file

@ -18,15 +18,29 @@
#include "dmcommon.h"
#include "x_inteno_se_buttons.h"
struct button_args cur_button_args = {0};
inline int entry_xinteno_button_instance(struct dmctx *ctx, char *ibutton);
inline int entry_xinteno_buttons(struct dmctx *ctx);
/*** DMROOT.X_INTENO_SE_Buttons.{i}. ****/
DMLEAF X_INTENO_SE_ButtonParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"Alias", &DMWRITE, DMT_STRING, get_x_inteno_button_alias, set_x_inteno_button_alias, NULL, NULL},
{"button", &DMREAD, DMT_STRING, get_x_inteno_button_name, NULL, NULL, NULL},
{"hotplug", &DMREAD, DMT_STRING, get_x_inteno_button_hotplug, NULL, NULL, NULL},
{"hotplug_long", &DMREAD, DMT_STRING, get_x_inteno_button_hotplug_long, NULL, NULL, NULL},
{"minpress", &DMWRITE, DMT_UNINT, get_x_inteno_button_minpress, set_x_inteno_button_minpress, NULL, NULL},
{"longpress", &DMWRITE, DMT_UNINT, get_x_inteno_button_longpress, set_x_inteno_button_longpress, NULL, NULL},
{"enable", &DMWRITE, DMT_BOOL, get_x_inteno_button_enable, set_x_inteno_button_enable, NULL, NULL},
{0}
};
inline int init_args_button(struct dmctx *ctx, struct uci_section *s)
int browseXIntenoButton(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct button_args *args = &cur_button_args;
ctx->args = (void *)args;
args->button_section = s;
char *ibutton = NULL, *ibutton_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("buttons", "button", s) {
ibutton = handle_update_instance(1, dmctx, &ibutton_last, update_instance_alias, 3, s, "buttoninstance", "buttonalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, ibutton) == DM_STOP)
break;
}
return 0;
}
@ -34,11 +48,11 @@ inline int init_args_button(struct dmctx *ctx, struct uci_section *s)
**** function related to button ****
**************************************************************************************/
int get_x_inteno_button_name(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
dmuci_get_value_by_section_list(cur_button_args.button_section, "button", &val);
dmuci_get_value_by_section_list((struct uci_section *)data, "button", &val);
if (val)
*value = dmuci_list_to_string(val, " ");
else
@ -46,67 +60,67 @@ int get_x_inteno_button_name(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_x_inteno_button_hotplug(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_hotplug(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "hotplug", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "hotplug", value);
return 0;
}
int get_x_inteno_button_hotplug_long(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_hotplug_long(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "hotplug_long", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "hotplug_long", value);
return 0;
}
int get_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "minpress", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "minpress", value);
return 0;
}
int set_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_button_args.button_section, "minpress", value);
dmuci_set_value_by_section((struct uci_section *)data, "minpress", value);
return 0;
}
return 0;
}
int get_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "longpress", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "longpress", value);
return 0;
}
int set_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_button_args.button_section, "longpress", value);
dmuci_set_value_by_section((struct uci_section *)data, "longpress", value);
return 0;
}
return 0;
}
int get_x_inteno_button_enable(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "enable", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "enable", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_x_inteno_button_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -118,72 +132,31 @@ int set_x_inteno_button_enable(char *refparam, struct dmctx *ctx, int action, ch
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_button_args.button_section, "enable", "");
dmuci_set_value_by_section((struct uci_section *)data, "enable", "");
else
dmuci_set_value_by_section(cur_button_args.button_section, "enable", "0");
dmuci_set_value_by_section((struct uci_section *)data, "enable", "0");
return 0;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_inteno_button_alias(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_button_args.button_section, "buttonalias", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "buttonalias", value);
return 0;
}
int set_x_inteno_button_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_button_args.button_section, "buttonalias", value);
dmuci_set_value_by_section((struct uci_section *)data, "buttonalias", value);
return 0;
}
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_xinteno_buttons(struct dmctx *ctx)
{
char *ibutton = NULL, *ibutton_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("buttons", "button", s) {
init_args_button(ctx, s);
ibutton = handle_update_instance(1, ctx, &ibutton_last, update_instance_alias, 3, s, "buttoninstance", "buttonalias");
SUBENTRY(entry_xinteno_button_instance, ctx, ibutton);
}
return 0;
}
//////////////////////////////////////
int entry_method_root_X_INTENO_SE_BUTTONS(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Buttons.") {
DMOBJECT(DMROOT"X_INTENO_SE_Buttons.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_xinteno_buttons, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_xinteno_button_instance(struct dmctx *ctx, char *ibutton)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Buttons.%s.", ibutton) {
DMOBJECT(DMROOT"X_INTENO_SE_Buttons.%s.", ctx, "0", 1, NULL, NULL, NULL, ibutton);
DMPARAM("Alias", ctx, "1", get_x_inteno_button_alias, set_x_inteno_button_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("button", ctx, "0", get_x_inteno_button_name, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("hotplug", ctx, "0", get_x_inteno_button_hotplug, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("hotplug_long", ctx, "0", get_x_inteno_button_hotplug_long, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("minpress", ctx, "1", get_x_inteno_button_minpress, set_x_inteno_button_minpress, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("longpress", ctx, "1", get_x_inteno_button_longpress, set_x_inteno_button_longpress, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("enable", ctx, "1", get_x_inteno_button_enable, set_x_inteno_button_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,10 +1,18 @@
#ifndef __SE_BUTTONS_H
#define __SE_BUTTONS_H
struct button_args
{
struct uci_section *button_section;
};
extern DMLEAF X_INTENO_SE_ButtonParams[];
int browseXIntenoButton(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_inteno_button_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_button_hotplug(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_button_hotplug_long(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_button_minpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_button_longpress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_button_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_button_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int entry_method_root_X_INTENO_SE_BUTTONS(struct dmctx *ctx);
#endif

View file

@ -18,15 +18,35 @@
#include "dmcommon.h"
#include "x_inteno_se_dropbear.h"
inline int entry_xinteno_dropbear_instance(struct dmctx *ctx, char *idropbear);
inline int entry_xinteno_dropbear(struct dmctx *ctx);
struct dropbear_args cur_dropbear_args = {0};
/*** DMROOT.X_INTENO_SE_Dropbear.{i}. ****/
DMLEAF X_INTENO_SE_DropbearParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"Alias", &DMWRITE, DMT_STRING, get_x_inteno_dropbear_alias, set_x_inteno_dropbear_alias, NULL, NULL},
{"PasswordAuth", &DMWRITE, DMT_BOOL, get_x_inteno_dropbear_password_auth, set_x_inteno_dropbear_password_auth, NULL, NULL},
{"RootPasswordAuth", &DMWRITE, DMT_BOOL, get_x_inteno_dropbear_root_password_auth, set_x_inteno_dropbear_root_password_auth, NULL, NULL},
{"Port", &DMWRITE, DMT_UNINT, get_x_inteno_dropbear_port, set_x_inteno_dropbear_port, NULL, NULL},
{"RootLogin", &DMWRITE, DMT_BOOL, get_x_inteno_dropbear_root_login, set_x_inteno_dropbear_root_login, NULL, NULL},
{"GatewayPorts", &DMWRITE, DMT_BOOL, get_x_inteno_dropbear_gateway_ports, set_x_inteno_dropbear_gateway_ports, NULL, NULL},
{"Interface", &DMWRITE, DMT_STRING, get_x_inteno_dropbear_interface, set_x_inteno_dropbear_interface, NULL, NULL},
{"rsakeyfile", &DMWRITE, DMT_STRING, get_x_inteno_dropbear_rsakeyfile, set_x_inteno_dropbear_rsakeyfile, NULL, NULL},
{"dsskeyfile", &DMWRITE, DMT_STRING, get_x_inteno_dropbear_dsskeyfile, set_x_inteno_dropbear_dsskeyfile, NULL, NULL},
{"SSHKeepAlive", &DMWRITE, DMT_UNINT, get_x_inteno_dropbear_ssh_keepalive, set_x_inteno_dropbear_ssh_keepalive, NULL, NULL},
{"IdleTimeout", &DMWRITE, DMT_UNINT, get_x_inteno_dropbear_idle_timeout, set_x_inteno_dropbear_idle_timeout, NULL, NULL},
{"verbose", &DMWRITE, DMT_BOOL, get_x_inteno_dropbear_gateway_ports, set_x_inteno_dropbear_gateway_ports, NULL, NULL},
{"BannerFile", &DMWRITE, DMT_STRING, get_x_inteno_dropbear_interface, set_x_inteno_dropbear_interface, NULL, NULL},
{0}
};
inline int init_args_dropbear(struct dmctx *ctx, struct uci_section *s)
int browseXIntenoDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct dropbear_args *args = &cur_dropbear_args;
ctx->args = (void *)args;
args->dropbear_section = s;
char *idropbear = NULL, *idropbear_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("dropbear", "dropbear", s) {
idropbear = handle_update_instance(1, dmctx, &idropbear_last, update_instance_alias, 3, s, "dropbearinstance", "dropbearalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, idropbear) == DM_STOP)
break;
}
return 0;
}
@ -35,9 +55,9 @@ inline int init_args_dropbear(struct dmctx *ctx, struct uci_section *s)
**************************************************************************************/
int get_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "PasswordAuth", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "PasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
*value = "1";
}
@ -46,7 +66,7 @@ int get_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, char
return 0;
}
int set_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -58,17 +78,17 @@ int set_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, int a
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "PasswordAuth", "1");
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "1");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "PasswordAuth", "0");
dmuci_set_value_by_section((struct uci_section *)data, "PasswordAuth", "0");
return 0;
}
return 0;
}
int get_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "RootPasswordAuth", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "RootPasswordAuth", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1') {
*value = "1";
}
@ -77,7 +97,7 @@ int get_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx,
return 0;
}
int set_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -89,24 +109,24 @@ int set_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx,
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "RootPasswordAuth", "1");
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "1");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "RootPasswordAuth", "0");
dmuci_set_value_by_section((struct uci_section *)data, "RootPasswordAuth", "0");
return 0;
}
return 0;
}
int get_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "Port", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "Port", value);
if ((*value)[0] == '\0') {
*value = "22";
}
return 0;
}
int set_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
@ -114,17 +134,17 @@ int set_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, int action, ch
return 0;
case VALUESET:
if (value[0] == '\0')
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "Port", "22");
dmuci_set_value_by_section((struct uci_section *)data, "Port", "22");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "Port", value);
dmuci_set_value_by_section((struct uci_section *)data, "Port", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "RootLogin", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "RootLogin", value);
if ((*value)[0] == '\0' || ((*value)[0] == 'o' && (*value)[1] == 'n') || (*value)[0] == '1' ) {
*value = "1";
}
@ -133,7 +153,7 @@ int get_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int set_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -145,17 +165,17 @@ int set_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, int acti
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "RootLogin", "1");
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "1");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "RootLogin", "0");
dmuci_set_value_by_section((struct uci_section *)data, "RootLogin", "0");
return 0;
}
return 0;
}
int get_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "verbose", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "verbose", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
*value = "0";
}
@ -164,7 +184,7 @@ int get_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int set_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -176,18 +196,18 @@ int set_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, int action,
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "verbose", "1");
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "1");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "verbose", "0");
dmuci_set_value_by_section((struct uci_section *)data, "verbose", "0");
return 0;
}
return 0;
}
int get_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "GatewayPorts", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "GatewayPorts", value);
if ((*value)[0] == '\0' || (*value)[0] == '0' ) {
*value = "0";
}
@ -196,7 +216,7 @@ int get_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, char
return 0;
}
int set_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -208,81 +228,81 @@ int set_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, int a
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "GatewayPorts", "1");
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "1");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "GatewayPorts", "");
dmuci_set_value_by_section((struct uci_section *)data, "GatewayPorts", "");
return 0;
}
return 0;
}
int get_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "Interface", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "Interface", value);
return 0;
}
int set_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "Interface", value);
dmuci_set_value_by_section((struct uci_section *)data, "Interface", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "rsakeyfile", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "rsakeyfile", value);
return 0;
}
int set_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "rsakeyfile", value);
dmuci_set_value_by_section((struct uci_section *)data, "rsakeyfile", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "dsskeyfile", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "dsskeyfile", value);
return 0;
}
int set_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "dsskeyfile", value);
dmuci_set_value_by_section((struct uci_section *)data, "dsskeyfile", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "SSHKeepAlive", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "SSHKeepAlive", value);
if ((*value)[0] == '\0') {
*value = "300";
}
return 0;
}
int set_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
@ -290,24 +310,24 @@ int set_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, int a
return 0;
case VALUESET:
if (strcmp(value, "300") == 0)
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "SSHKeepAlive", "");
dmuci_set_value_by_section((struct uci_section *)data, "SSHKeepAlive", "");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "SSHKeepAlive", value);
dmuci_set_value_by_section((struct uci_section *)data, "SSHKeepAlive", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "IdleTimeout", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "IdleTimeout", value);
if ((*value)[0] == '\0') {
*value = "300";
}
return 0;
}
int set_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
@ -315,28 +335,28 @@ int set_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, int ac
return 0;
case VALUESET:
if (value[0] == '0')
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "IdleTimeout", "");
dmuci_set_value_by_section((struct uci_section *)data, "IdleTimeout", "");
else
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "IdleTimeout", value);
dmuci_set_value_by_section((struct uci_section *)data, "IdleTimeout", value);
return 0;
}
return 0;
}
int get_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "BannerFile", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "BannerFile", value);
return 0;
}
int set_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "BannerFile", value);
dmuci_set_value_by_section((struct uci_section *)data, "BannerFile", value);
return 0;
}
return 0;
@ -344,26 +364,26 @@ int set_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, int act
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dropbear_args.dropbear_section, "dropbearalias", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "dropbearalias", value);
return 0;
}
int set_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dropbear_args.dropbear_section, "dropbearalias", value);
dmuci_set_value_by_section((struct uci_section *)data, "dropbearalias", value);
return 0;
}
return 0;
}
/***** ADD DEL OBJ *******/
int add_dropbear_instance(struct dmctx *ctx, char **instancepara)
int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
@ -381,75 +401,26 @@ int add_dropbear_instance(struct dmctx *ctx, char **instancepara)
return 0;
}
int delete_dropbear_all(struct dmctx *ctx)
int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
int found = 0;
uci_foreach_sections("dropbear", "dropbear", s) {
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section((struct uci_section *)data, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("dropbear", "dropbear", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
int delete_dropbear_instance(struct dmctx *ctx)
{
dmuci_delete_by_section(cur_dropbear_args.dropbear_section, NULL, NULL);
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_xinteno_dropbear(struct dmctx *ctx)
{
char *idropbear = NULL, *idropbear_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("dropbear", "dropbear", s) {
init_args_dropbear(ctx, s);
idropbear = handle_update_instance(1, ctx, &idropbear_last, update_instance_alias, 3, s, "dropbearinstance", "dropbearalias");
SUBENTRY(entry_xinteno_dropbear_instance, ctx, idropbear);
}
return 0;
}
//////////////////////////////////////
int entry_method_root_X_INTENO_SE_DROPBEAR(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Dropbear.") {
DMOBJECT(DMROOT"X_INTENO_SE_Dropbear.", ctx, "1", 1, add_dropbear_instance, delete_dropbear_all, NULL);
SUBENTRY(entry_xinteno_dropbear, ctx);
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
return FAULT_9005;
}
inline int entry_xinteno_dropbear_instance(struct dmctx *ctx, char *idropbear)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Dropbear.%s.", idropbear) {
DMOBJECT(DMROOT"X_INTENO_SE_Dropbear.%s.", ctx, "1", 1, NULL, delete_dropbear_instance, NULL, idropbear);
DMPARAM("Alias", ctx, "1", get_x_inteno_dropbear_alias, set_x_inteno_dropbear_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("PasswordAuth", ctx, "1", get_x_inteno_dropbear_password_auth, set_x_inteno_dropbear_password_auth, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("RootPasswordAuth", ctx, "1", get_x_inteno_dropbear_root_password_auth, set_x_inteno_dropbear_root_password_auth, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Port", ctx, "1", get_x_inteno_dropbear_port, set_x_inteno_dropbear_port, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("RootLogin", ctx, "1", get_x_inteno_dropbear_root_login, set_x_inteno_dropbear_root_login, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("GatewayPorts", ctx, "1", get_x_inteno_dropbear_gateway_ports, set_x_inteno_dropbear_gateway_ports, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, "1", get_x_inteno_dropbear_interface, set_x_inteno_dropbear_interface, NULL, 0, 1, UNDEF, NULL);
DMPARAM("rsakeyfile", ctx, "1", get_x_inteno_dropbear_rsakeyfile, set_x_inteno_dropbear_rsakeyfile, NULL, 0, 1, UNDEF, NULL);
DMPARAM("dsskeyfile", ctx, "1", get_x_inteno_dropbear_dsskeyfile, set_x_inteno_dropbear_dsskeyfile, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SSHKeepAlive", ctx, "1", get_x_inteno_dropbear_ssh_keepalive, set_x_inteno_dropbear_ssh_keepalive, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("IdleTimeout", ctx, "1", get_x_inteno_dropbear_idle_timeout, set_x_inteno_dropbear_idle_timeout, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
//DMPARAM("enable", ctx, "1", get_x_inteno_dropbear_enable, set_x_inteno_dropbear_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("verbose", ctx, "1", get_x_inteno_dropbear_verbose, set_x_inteno_dropbear_verbose, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("BannerFile", ctx, "1", get_x_inteno_dropbear_banner_file, set_x_inteno_dropbear_banner_file, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
return 0;
}

View file

@ -1,10 +1,35 @@
#ifndef __SE_DROPBEAR_H
#define __SE_DROPBEAR_H
struct dropbear_args
{
struct uci_section *dropbear_section;
};
extern DMLEAF X_INTENO_SE_DropbearParams[];
int browseXIntenoDropbear(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_root_password_auth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_root_login(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_verbose(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_gateway_ports(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_rsakeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_dsskeyfile(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_ssh_keepalive(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_idle_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_banner_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_dropbear_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int add_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dropbear_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int entry_method_root_X_INTENO_SE_DROPBEAR(struct dmctx *ctx);
#endif

View file

@ -18,7 +18,14 @@
#include "dmcommon.h"
#include "x_inteno_se_ice.h"
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, char **value)
/*** DMROOT.X_INTENO_SE_ICE. ***/
DMLEAF tSe_IceParam[] = {
{"Enable", &DMWRITE, DMT_BOOL, get_ice_cloud_enable, set_ice_cloud_enable, NULL, NULL},
{"Server", &DMWRITE, DMT_STRING, get_ice_cloud_server, set_ice_cloud_server, NULL, NULL},
{0}
};
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
dmuci_get_option_value_string("ice", "cloud", "enabled", value);
@ -31,7 +38,7 @@ int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -50,13 +57,13 @@ int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, int action, char *va
}
}
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, char **value)
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("ice", "cloud", "server", value);
return 0;
}
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -69,14 +76,3 @@ int set_ice_cloud_server(char *refparam, struct dmctx *ctx, int action, char *va
}
return 0;
}
int entry_method_root_X_INTENO_SE_Ice(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_ICE.") {
DMOBJECT(DMROOT"X_INTENO_SE_ICE.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("Enable", ctx, "1", get_ice_cloud_enable, set_ice_cloud_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Server", ctx, "1", get_ice_cloud_server, set_ice_cloud_server, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,6 +1,12 @@
#ifndef __SE_ICE_H
#define __SE_ICE_H
int entry_method_root_X_INTENO_SE_Ice(struct dmctx *ctx);
extern DMLEAF tSe_IceParam[];
#endif
int get_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ice_cloud_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ice_cloud_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -19,13 +19,13 @@
#include "x_inteno_se_igmp.h"
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_dscp_mark", value);
return 0;
}
int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -37,7 +37,7 @@ int set_igmp_dscp_mark(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
}
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *p;
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_interfaces", value);
@ -49,7 +49,7 @@ int get_igmp_proxy_interface(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
char *p;
@ -73,13 +73,13 @@ int set_igmp_proxy_interface(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_igmp_default_version(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_default_version", value);
return 0;
}
int set_igmp_default_version(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_default_version(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -91,13 +91,13 @@ int set_igmp_default_version(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_query_interval", value);
return 0;
}
int set_igmp_query_interval(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_query_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -109,13 +109,13 @@ int set_igmp_query_interval(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_query_response_interval", value);
return 0;
}
int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -127,13 +127,13 @@ int set_igmp_query_response_interval(char *refparam, struct dmctx *ctx, int acti
return 0;
}
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_last_member_query_interval", value);
return 0;
}
int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -145,13 +145,13 @@ int set_igmp_last_member_queryinterval(char *refparam, struct dmctx *ctx, int ac
return 0;
}
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_robustness_value", value);
return 0;
}
int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -163,7 +163,7 @@ int set_igmp_robustness_value(char *refparam, struct dmctx *ctx, int action, cha
return 0;
}
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_lan_to_lan_multicast", value);
if ((*value)[0] == '\0') {
@ -172,7 +172,7 @@ int get_igmp_multicast_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -192,7 +192,7 @@ int set_igmp_multicast_enable(char *refparam, struct dmctx *ctx, int action, cha
return 0;
}
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_fast_leave", value);
if ((*value)[0] == '\0') {
@ -201,7 +201,7 @@ int get_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -221,7 +221,7 @@ int set_igmp_fastleave_enable(char *refparam, struct dmctx *ctx, int action, cha
return 0;
}
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_join_immediate", value);
if ((*value)[0] == '\0') {
@ -230,7 +230,7 @@ int get_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -250,7 +250,7 @@ int set_igmp_joinimmediate_enable(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_proxy_enable", value);
if ((*value)[0] == '\0') {
@ -259,7 +259,7 @@ int get_igmp_proxy_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -279,13 +279,13 @@ int set_igmp_proxy_enable(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
}
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_groups", value);
return 0;
}
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -297,13 +297,13 @@ int set_igmp_maxgroup(char *refparam, struct dmctx *ctx, int action, char *value
return 0;
}
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_sources", value);
return 0;
}
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_maxsources(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -315,13 +315,13 @@ int set_igmp_maxsources(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_max_members", value);
return 0;
}
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -333,13 +333,13 @@ int set_igmp_maxmembers(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("mcpd", "mcpd", "igmp_snooping_enable", value);
return 0;
}
int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -351,7 +351,7 @@ int set_igmp_snooping_mode(char *refparam, struct dmctx *ctx, int action, char *
return 0;
}
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, char **value)
int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *p;
@ -365,7 +365,7 @@ int get_igmp_snooping_interface(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
char *p;
@ -389,27 +389,22 @@ int set_igmp_snooping_interface(char *refparam, struct dmctx *ctx, int action, c
return 0;
}
int entry_method_root_X_INTENO_SE_IGMP(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_IGMP.") {
DMOBJECT(DMROOT"X_INTENO_SE_IGMP.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("DifferentiateService", ctx, "1", get_igmp_dscp_mark, set_igmp_dscp_mark, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ProxyInterface", ctx, "1", get_igmp_proxy_interface, set_igmp_proxy_interface, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DefaultVersion", ctx, "1", get_igmp_default_version, set_igmp_default_version, NULL, 0, 1, UNDEF, NULL);
DMPARAM("QueryInterval", ctx, "1", get_igmp_query_interval, set_igmp_query_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("QueryResponseInterval", ctx, "1", get_igmp_query_response_interval, set_igmp_query_response_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("LastMemberQueryInterval", ctx, "1", get_igmp_last_member_queryinterval, set_igmp_last_member_queryinterval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("RobustnessValue", ctx, "1", get_igmp_robustness_value, set_igmp_robustness_value, "xsd:int", 0, 1, UNDEF, NULL);
DMPARAM("LanToLanMulticastEnable", ctx, "1", get_igmp_multicast_enable, set_igmp_multicast_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("MaxGroup", ctx, "1", get_igmp_maxgroup, set_igmp_maxgroup, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MaxSources", ctx, "1", get_igmp_maxsources, set_igmp_maxsources, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MaxMembers", ctx, "1", get_igmp_maxmembers, set_igmp_maxmembers, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("FastLeaveEnable", ctx, "1", get_igmp_fastleave_enable, set_igmp_fastleave_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("JoinImmediateEnable", ctx, "1", get_igmp_joinimmediate_enable, set_igmp_joinimmediate_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("ProxyEnable", ctx, "1", get_igmp_proxy_enable, set_igmp_proxy_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("SnoopingMode", ctx, "1", get_igmp_snooping_mode, set_igmp_snooping_mode, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SnoopingInterfaces", ctx, "1", get_igmp_snooping_interface, set_igmp_snooping_interface, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
DMLEAF tSe_IgmpParam[] = {
{"DifferentiateService", &DMWRITE, DMT_STRING, get_igmp_dscp_mark, set_igmp_dscp_mark, NULL, NULL},
{"ProxyInterface", &DMWRITE, DMT_STRING, get_igmp_proxy_interface, set_igmp_proxy_interface, NULL, NULL},
{"DefaultVersion", &DMWRITE, DMT_STRING, get_igmp_default_version, set_igmp_default_version, NULL, NULL},
{"QueryInterval", &DMWRITE, DMT_UNINT, get_igmp_query_interval, set_igmp_query_interval, NULL, NULL},
{"QueryResponseInterval", &DMWRITE, DMT_UNINT, get_igmp_query_response_interval, set_igmp_query_response_interval, NULL, NULL},
{"LastMemberQueryInterval", &DMWRITE, DMT_UNINT, get_igmp_last_member_queryinterval, set_igmp_last_member_queryinterval, NULL, NULL},
{"RobustnessValue", &DMWRITE, DMT_INT, get_igmp_robustness_value, set_igmp_robustness_value, NULL, NULL},
{"LanToLanMulticastEnable", &DMWRITE, DMT_BOOL, get_igmp_multicast_enable, set_igmp_multicast_enable, NULL, NULL},
{"MaxGroup", &DMWRITE, DMT_UNINT, get_igmp_maxgroup, set_igmp_maxgroup, NULL, NULL},
{"MaxSources", &DMWRITE, DMT_UNINT, get_igmp_maxsources, set_igmp_maxsources, NULL, NULL},
{"MaxMembers", &DMWRITE, DMT_UNINT, get_igmp_maxmembers, set_igmp_maxmembers, NULL, NULL},
{"FastLeaveEnable", &DMWRITE, DMT_BOOL, get_igmp_fastleave_enable, set_igmp_fastleave_enable, NULL, NULL},
{"JoinImmediateEnable", &DMWRITE, DMT_BOOL, get_igmp_joinimmediate_enable, set_igmp_joinimmediate_enable, NULL, NULL},
{"ProxyEnable", &DMWRITE, DMT_BOOL, get_igmp_proxy_enable, set_igmp_proxy_enable, NULL, NULL},
{"SnoopingMode", &DMWRITE, DMT_STRING, get_igmp_snooping_mode, set_igmp_snooping_mode, NULL, NULL},
{"SnoopingInterfaces", &DMWRITE, DMT_STRING, get_igmp_snooping_interface, set_igmp_snooping_interface, NULL, NULL},
{0}
};

View file

@ -1,6 +1,6 @@
#ifndef __SE_IGMP_H
#define __SE_IGMP_H
int entry_method_root_X_INTENO_SE_IGMP(struct dmctx *ctx);
extern DMLEAF tSe_IgmpParam[];
#endif

View file

@ -18,49 +18,65 @@
#include "dmcommon.h"
#include "x_inteno_se_ipacccfg.h"
struct ipaccargs cur_ipaccargs = {0};
struct pforwardrgs cur_pforwardrgs = {0};
/*** DMROOT.X_INTENO_SE_IpAccCfg. ***/
DMOBJ tSe_IpAccObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"X_INTENO_SE_IpAccListCfgObj", &DMWRITE, add_ipacccfg_rule, delete_ipacccfg_rule, NULL, browseAccListInst, NULL, NULL, NULL, tSe_IpAccCfgParam, NULL},
{"X_INTENO_SE_PortForwarding", &DMWRITE, add_ipacccfg_port_forwarding, delete_ipacccfg_port_forwarding, NULL, browseport_forwardingInst, NULL, NULL, NULL, tSe_PortForwardingParam, NULL},
{0}
};
DMLEAF tSe_PortForwardingParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_port_forwarding_alias, set_port_forwarding_alias, NULL, NULL},
{"Name", &DMWRITE, DMT_STRING, get_port_forwarding_name, set_port_forwarding_name, NULL, NULL},
{"Enable", &DMWRITE, DMT_BOOL, get_port_forwarding_enable, set_port_forwarding_enable, NULL, NULL},
{"EnalbeNatLoopback", &DMWRITE, DMT_BOOL, get_port_forwarding_loopback, set_port_forwarding_loopback, NULL, NULL},
{"Protocol", &DMWRITE, DMT_STRING, get_port_forwarding_protocol, set_port_forwarding_protocol, NULL, NULL},
{"ExternalZone", &DMWRITE, DMT_STRING, get_port_forwarding_external_zone, set_port_forwarding_external_zone, NULL, NULL},
{"InternalZone", &DMWRITE, DMT_STRING, get_port_forwarding_internal_zone, set_port_forwarding_internal_zone, NULL, NULL},
{"ExternalPort", &DMWRITE, DMT_STRING, get_port_forwarding_external_port, set_port_forwarding_external_port, NULL, NULL},
{"InternalPort", &DMWRITE, DMT_STRING, get_port_forwarding_internal_port, set_port_forwarding_internal_port, NULL, NULL},
{"SourcePort", &DMWRITE, DMT_STRING, get_port_forwarding_source_port, set_port_forwarding_source_port, NULL, NULL},
{"InternalIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_internal_ipaddress, set_port_forwarding_internal_ipaddress, NULL, NULL},
{"ExternalIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_external_ipaddress, set_port_forwarding_external_ipaddress, NULL, NULL},
{"SourceIpAddress", &DMWRITE, DMT_STRING, get_port_forwarding_source_ipaddress, set_port_forwarding_source_ipaddress, NULL, NULL},
{"SourceMacAddress", &DMWRITE, DMT_STRING, get_port_forwarding_src_mac, set_port_forwarding_src_mac, NULL, NULL},
{0}
};
DMLEAF tSe_IpAccCfgParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_x_inteno_cfgobj_address_alias, set_x_inteno_cfgobj_address_alias, NULL, NULL},
{"Enable", &DMWRITE, DMT_BOOL, get_x_bcm_com_ip_acc_list_cfgobj_enable, set_x_bcm_com_ip_acc_list_cfgobj_enable, NULL, NULL},
{"IPVersion", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_ipversion, set_x_bcm_com_ip_acc_list_cfgobj_ipversion, NULL, NULL},
{"Protocol", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_protocol, set_x_bcm_com_ip_acc_list_cfgobj_protocol, NULL, NULL},
{"FilterName", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_name, set_x_bcm_com_ip_acc_list_cfgobj_name, NULL, NULL},
{"AccAddressAndNetMask", &DMWRITE, DMT_STRING, get_x_inteno_cfgobj_address_netmask, set_x_inteno_cfgobj_address_netmask, NULL, NULL},
{"AccPort", &DMWRITE, DMT_STRING, get_x_bcm_com_ip_acc_list_cfgobj_acc_port, set_x_bcm_com_ip_acc_list_cfgobj_acc_port, NULL, NULL},
{0}
};
inline int entry_xinteno_ipacccfg_listcfgobj(struct dmctx *ctx);
inline int entry_xinteno_ipacccfg_portforwarding(struct dmctx *ctx);
inline int entry_xinteno_ipacccfg_portforwarding_instance(struct dmctx *ctx, char *iforward);
inline int entry_xinteno_ipacccfg_listcfgobj_instance(struct dmctx *ctx, char *irule);
inline int init_args_ipacc(struct dmctx *ctx, struct uci_section *s)
{
struct ipaccargs *args = &cur_ipaccargs;
ctx->args = (void *)args;
args->ipaccsection = s;
return 0;
}
inline int init_args_pforward(struct dmctx *ctx, struct uci_section *s)
{
struct pforwardrgs *args = &cur_pforwardrgs;
ctx->args = (void *)args;
args->forwardsection = s;
return 0;
}
/*************************************************************************************
**** function related to get_object_ip_acc_list_cfgobj ****
**************************************************************************************/
int get_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, char **value)
int get_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(accargs->ipaccsection, "enabled", value);
dmuci_get_value_by_section_string(ipaccsection, "enabled", value);
if ((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -75,86 +91,86 @@ int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, i
else {
value = "0";
}
dmuci_set_value_by_section(accargs->ipaccsection, "enabled", value);
dmuci_set_value_by_section(ipaccsection, "enabled", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, char **value)
int get_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(accargs->ipaccsection, "family", value);
dmuci_get_value_by_section_string(ipaccsection, "family", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(accargs->ipaccsection, "family", value);
dmuci_set_value_by_section(ipaccsection, "family", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, char **value)
int get_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(accargs->ipaccsection, "proto", value);
dmuci_get_value_by_section_string(ipaccsection, "proto", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(accargs->ipaccsection, "proto", value);
dmuci_set_value_by_section(ipaccsection, "proto", value);
return 0;
}
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, char **value)
int get_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(accargs->ipaccsection, "name", value);
dmuci_get_value_by_section_string(ipaccsection, "name", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(accargs->ipaccsection, "name", value);
dmuci_set_value_by_section(ipaccsection, "name", value);
return 0;
}
return 0;
}
int get_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_element *e = NULL;
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
struct uci_list *list = NULL;
dmuci_get_value_by_section_list(accargs->ipaccsection, "src_ip", &val);
dmuci_get_value_by_section_list(ipaccsection, "src_ip", &val);
if (val) {
*value = dmuci_list_to_string(val, ",");
}
@ -167,20 +183,20 @@ int get_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, char
return 0;
}
int set_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch, *val;
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(accargs->ipaccsection, "src_ip", "");
dmuci_delete_by_section(ipaccsection, "src_ip", "");
val = dmstrdup(value);
pch = strtok_r(val, " ,", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(accargs->ipaccsection, "src_ip", pch);
dmuci_add_list_value_by_section(ipaccsection, "src_ip", pch);
pch = strtok_r(NULL, " ,", &spch);
}
dmfree(val);
@ -189,23 +205,23 @@ int set_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, int a
return 0;
}
int get_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, char **value)
int get_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(accargs->ipaccsection, "dest_port", value);
dmuci_get_value_by_section_string(ipaccsection, "dest_port", value);
return 0;
}
int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(accargs->ipaccsection, "dest_port", value);
dmuci_set_value_by_section(ipaccsection, "dest_port", value);
return 0;
}
return 0;
@ -217,41 +233,41 @@ int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx,
**** function related to get_cache_object_port_forwarding ****
**************************************************************************************/
int get_port_forwarding_name(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "name", value);
dmuci_get_value_by_section_string(forwardsection, "name", value);
return 0;
}
int set_port_forwarding_name(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "name", value);
dmuci_set_value_by_section(forwardsection, "name", value);
return 0;
}
return 0;
}
int get_port_forwarding_enable(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "enabled", value);
dmuci_get_value_by_section_string(forwardsection, "enabled", value);
return 0;
}
int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
int check;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -261,29 +277,29 @@ int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, int action, ch
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(forwardargs->forwardsection, "enabled", "1");
dmuci_set_value_by_section(forwardsection, "enabled", "1");
else
dmuci_set_value_by_section(forwardargs->forwardsection, "enabled", "0");
dmuci_set_value_by_section(forwardsection, "enabled", "0");
return 0;
}
return 0;
}
int get_port_forwarding_loopback(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "reflection", value);
dmuci_get_value_by_section_string(forwardsection, "reflection", value);
if((*value)[0] == '\0') {
*value = "1";
}
return 0;
}
int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -293,121 +309,121 @@ int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, int action,
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(forwardargs->forwardsection, "reflection", "1");
dmuci_set_value_by_section(forwardsection, "reflection", "1");
else
dmuci_set_value_by_section(forwardargs->forwardsection, "reflection", "0");
dmuci_set_value_by_section(forwardsection, "reflection", "0");
return 0;
}
return 0;
}
int get_port_forwarding_protocol(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "proto", value);
dmuci_get_value_by_section_string(forwardsection, "proto", value);
return 0;
}
int set_port_forwarding_protocol(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "proto", value);
dmuci_set_value_by_section(forwardsection, "proto", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "src", value);
dmuci_get_value_by_section_string(forwardsection, "src", value);
return 0;
}
int set_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "src", value);
dmuci_set_value_by_section(forwardsection, "src", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "dest", value);
dmuci_get_value_by_section_string(forwardsection, "dest", value);
return 0;
}
int set_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "dest", value);
dmuci_set_value_by_section(forwardsection, "dest", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_port(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "src_dport", value);
dmuci_get_value_by_section_string(forwardsection, "src_dport", value);
return 0;
}
int set_port_forwarding_external_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "src_dport", value);
dmuci_set_value_by_section(forwardsection, "src_dport", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "dest_port", value);
dmuci_get_value_by_section_string(forwardsection, "dest_port", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -416,27 +432,27 @@ int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, int act
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardargs->forwardsection, "dest_port", value);
dmuci_set_value_by_section(forwardsection, "dest_port", value);
return 0;
}
return 0;
}
int get_port_forwarding_source_port(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "src_port", value);
dmuci_get_value_by_section_string(forwardsection, "src_port", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -445,50 +461,50 @@ int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, int actio
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardargs->forwardsection, "src_port", value);
dmuci_set_value_by_section(forwardsection, "src_port", value);
return 0;
}
return 0;
}
int get_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "dest_ip", value);
dmuci_get_value_by_section_string(forwardsection, "dest_ip", value);
return 0;
}
int set_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(forwardargs->forwardsection, "dest_ip", value);
dmuci_set_value_by_section(forwardsection, "dest_ip", value);
return 0;
}
return 0;
}
int get_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardargs->forwardsection, "src_dip", value);
dmuci_get_value_by_section_string(forwardsection, "src_dip", value);
if ((*value)[0] == '\0') {
*value = "any";
}
return 0;
}
int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -497,19 +513,19 @@ int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, in
if (strcasecmp(value, "any") == 0) {
value = "";
}
dmuci_set_value_by_section(forwardargs->forwardsection, "src_dip", value);
dmuci_set_value_by_section(forwardsection, "src_dip", value);
return 0;
}
return 0;
}
int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_element *e = NULL;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_list(forwardargs->forwardsection, "src_ip", &val);
dmuci_get_value_by_section_list(forwardsection, "src_ip", &val);
if (val) {
*value = dmuci_list_to_string(val, ",");
}
@ -522,24 +538,24 @@ int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, char
return 0;
}
int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *val, *spch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (strcasecmp(value, "any") == 0) {
dmuci_delete_by_section(forwardargs->forwardsection, "src_ip", "");
dmuci_delete_by_section(forwardsection, "src_ip", "");
}
else {
dmuci_delete_by_section(forwardargs->forwardsection, "src_ip", "");
dmuci_delete_by_section(forwardsection, "src_ip", "");
val = dmstrdup(value);
pch = strtok_r(val, " ,", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(forwardargs->forwardsection, "src_ip", pch);
dmuci_add_list_value_by_section(forwardsection, "src_ip", pch);
pch = strtok_r(NULL, " ,", &spch);
}
dmfree(val);
@ -549,30 +565,30 @@ int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, int
return 0;
}
int get_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *list = NULL;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_list(forwardargs->forwardsection, "src_mac", &list);
dmuci_get_value_by_section_list(forwardsection, "src_mac", &list);
*value = dmuci_list_to_string(list, " ");
return 0;
}
int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch;
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(forwardargs->forwardsection, "src_mac", NULL);
dmuci_delete_by_section(forwardsection, "src_mac", NULL);
value = dmstrdup(value);
pch = strtok_r(value, " ", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(forwardargs->forwardsection, "src_mac", pch);
dmuci_add_list_value_by_section(forwardsection, "src_mac", pch);
pch = strtok_r(NULL, " ", &spch);
}
dmfree(value);
@ -582,49 +598,7 @@ int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, int action, c
}
/***** ADD DEL OBJ *******/
int add_ipacccfg_port_forwarding(struct dmctx *ctx, char **instancepara)
{
char *value;
char *instance;
struct uci_section *redirect = NULL;
instance = get_last_instance_lev2("firewall", "redirect", "forwardinstance", "target", "DNAT");
dmuci_add_section("firewall", "redirect", &redirect, &value);
dmuci_set_value_by_section(redirect, "enabled", "0");
dmuci_set_value_by_section(redirect, "target", "DNAT");
dmuci_set_value_by_section(redirect, "proto", "tcp udp");
*instancepara = update_instance(redirect, instance, "forwardinstance");
return 0;
}
int delete_ipacccfg_port_forwarding_all(struct dmctx *ctx)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
int found = 0;
uci_foreach_option_eq("firewall", "redirect", "target", "DNAT", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
int delete_ipacccfg_port_forwarding_instance(struct dmctx *ctx)
{
struct pforwardrgs *forwardargs = (struct pforwardrgs *)ctx->args;
dmuci_delete_by_section(forwardargs->forwardsection, NULL, NULL);
return 0;
}
int add_ipacccfg_rule(struct dmctx *ctx, char **instancepara)
int add_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
@ -644,143 +618,136 @@ int add_ipacccfg_rule(struct dmctx *ctx, char **instancepara)
return 0;
}
int delete_ipacccfg_rule_all(struct dmctx *ctx)
int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
int found = 0;
uci_foreach_sections("firewall", "rule", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(ipaccsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("firewall", "rule", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
break;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
int delete_ipacccfg_rule_instance(struct dmctx *ctx)
{
struct ipaccargs *accargs = (struct ipaccargs *)ctx->args;
int add_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
struct uci_section *redirect = NULL;
instance = get_last_instance_lev2("firewall", "redirect", "forwardinstance", "target", "DNAT");
dmuci_add_section("firewall", "redirect", &redirect, &value);
dmuci_set_value_by_section(redirect, "enabled", "0");
dmuci_set_value_by_section(redirect, "target", "DNAT");
dmuci_set_value_by_section(redirect, "proto", "tcp udp");
*instancepara = update_instance(redirect, instance, "forwardinstance");
return 0;
}
dmuci_delete_by_section(accargs->ipaccsection, NULL, NULL);
int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct pforwardrgs *forwardargs;
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *forwardsection = (struct uci_section *)data;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(forwardsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("firewall", "redirect", "target", "DNAT", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
break;
}
return 0;
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipaccargs.ipaccsection, "frulealias", value);
struct uci_section *ipaccsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(ipaccsection, "frulealias", value);
return 0;
}
int set_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *ipaccsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_ipaccargs.ipaccsection, "frulealias", value);
dmuci_set_value_by_section(ipaccsection, "frulealias", value);
return 0;
}
return 0;
}
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, char **value)
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_pforwardrgs.forwardsection, "forwardalias", value);
struct uci_section *forwardsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(forwardsection, "forwardalias", value);
return 0;
}
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *forwardsection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_pforwardrgs.forwardsection, "forwardalias", value);
dmuci_set_value_by_section(forwardsection, "forwardalias", value);
return 0;
}
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_xinteno_ipacccfg_listcfgobj(struct dmctx *ctx)
int browseAccListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *irule = NULL, *irule_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("firewall", "rule", s) {
init_args_ipacc(ctx, s);
irule = handle_update_instance(1, ctx, &irule_last, update_instance_alias, 3, s, "fruleinstance", "frulealias");
SUBENTRY(entry_xinteno_ipacccfg_listcfgobj_instance, ctx, irule);
irule = handle_update_instance(1, dmctx, &irule_last, update_instance_alias, 3, s, "fruleinstance", "frulealias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, irule) == DM_STOP)
break;
}
return 0;
}
inline int entry_xinteno_ipacccfg_portforwarding(struct dmctx *ctx)
int browseport_forwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iforward = NULL, *iforward_last = NULL;
struct uci_section *s = NULL;
uci_foreach_option_eq("firewall", "redirect", "target", "DNAT", s) {
init_args_pforward(ctx, s);
iforward = handle_update_instance(1, ctx, &iforward_last, update_instance_alias, 3, s, "forwardinstance", "forwardalias");
SUBENTRY(entry_xinteno_ipacccfg_portforwarding_instance, ctx, iforward);
iforward = handle_update_instance(1, dmctx, &iforward_last, update_instance_alias, 3, s, "forwardinstance", "forwardalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, iforward) == DM_STOP)
break;
}
return 0;
}
//////////////////////////////////////
int entry_method_root_X_INTENO_SE_IpAccCfg(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_IpAccCfg.") {
DMOBJECT(DMROOT"X_INTENO_SE_IpAccCfg.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_IpAccListCfgObj.", ctx, "1", 1, add_ipacccfg_rule, delete_ipacccfg_rule_all, NULL);
DMOBJECT(DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_PortForwarding.", ctx, "1", 1, add_ipacccfg_port_forwarding, delete_ipacccfg_port_forwarding_all, NULL);
SUBENTRY(entry_xinteno_ipacccfg_listcfgobj, ctx);
SUBENTRY(entry_xinteno_ipacccfg_portforwarding, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_xinteno_ipacccfg_listcfgobj_instance(struct dmctx *ctx, char *irule)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_IpAccListCfgObj.%s.", irule) {
DMOBJECT(DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_IpAccListCfgObj.%s.", ctx, "1", 1, NULL, delete_ipacccfg_rule_instance, NULL, irule);
DMPARAM("Alias", ctx, "1", get_x_inteno_cfgobj_address_alias, set_x_inteno_cfgobj_address_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_x_bcm_com_ip_acc_list_cfgobj_enable, set_x_bcm_com_ip_acc_list_cfgobj_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("IPVersion", ctx, "1", get_x_bcm_com_ip_acc_list_cfgobj_ipversion, set_x_bcm_com_ip_acc_list_cfgobj_ipversion, "xsd:string", 0, 1, UNDEF, NULL);
DMPARAM("Protocol", ctx, "1", get_x_bcm_com_ip_acc_list_cfgobj_protocol, set_x_bcm_com_ip_acc_list_cfgobj_protocol, "xsd:string", 0, 1, UNDEF, NULL);
DMPARAM("FilterName", ctx, "1", get_x_bcm_com_ip_acc_list_cfgobj_name, set_x_bcm_com_ip_acc_list_cfgobj_name, "xsd:string", 0, 1, UNDEF, NULL);
DMPARAM("AccAddressAndNetMask", ctx, "1", get_x_inteno_cfgobj_address_netmask, set_x_inteno_cfgobj_address_netmask, NULL, 0, 1, UNDEF, NULL);
DMPARAM("AccPort", ctx, "1", get_x_bcm_com_ip_acc_list_cfgobj_acc_port, set_x_bcm_com_ip_acc_list_cfgobj_acc_port, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
inline int entry_xinteno_ipacccfg_portforwarding_instance(struct dmctx *ctx, char *iforward)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_PortForwarding.%s.", iforward) {
DMOBJECT(DMROOT"X_INTENO_SE_IpAccCfg.X_INTENO_SE_PortForwarding.%s.", ctx, "0", 1, NULL, delete_ipacccfg_port_forwarding_instance, NULL, iforward);
DMPARAM("Alias", ctx, "1", get_port_forwarding_alias, set_port_forwarding_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "1", get_port_forwarding_name, set_port_forwarding_name, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_port_forwarding_enable, set_port_forwarding_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("EnalbeNatLoopback", ctx, "1", get_port_forwarding_loopback, set_port_forwarding_loopback, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Protocol", ctx, "1", get_port_forwarding_protocol, set_port_forwarding_protocol, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ExternalZone", ctx, "1", get_port_forwarding_external_zone, set_port_forwarding_external_zone, NULL, 0, 1, UNDEF, NULL);
DMPARAM("InternalZone", ctx, "1", get_port_forwarding_internal_zone, set_port_forwarding_internal_zone, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ExternalPort", ctx, "1", get_port_forwarding_external_port, set_port_forwarding_external_port, NULL, 0, 1, UNDEF, NULL);
DMPARAM("InternalPort", ctx, "1", get_port_forwarding_internal_port, set_port_forwarding_internal_port, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourcePort", ctx, "1", get_port_forwarding_source_port, set_port_forwarding_source_port, NULL, 0, 1, UNDEF, NULL);
DMPARAM("InternalIpAddress", ctx, "1", get_port_forwarding_internal_ipaddress, set_port_forwarding_internal_ipaddress, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ExternalIpAddress", ctx, "1", get_port_forwarding_external_ipaddress, set_port_forwarding_external_ipaddress, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceIpAddress", ctx, "1", get_port_forwarding_source_ipaddress, set_port_forwarding_source_ipaddress, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceMacAddress", ctx, "1", get_port_forwarding_src_mac, set_port_forwarding_src_mac, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,15 +1,61 @@
#ifndef __SE_IPACCCFG_H
#define __SE_IPACCCFG_H
struct ipaccargs
{
struct uci_section *ipaccsection;
};
extern DMOBJ tSe_IpAccObj[];
extern DMLEAF tSe_IpAccCfgParam[];
extern DMLEAF tSe_PortForwardingParam[];
struct pforwardrgs
{
struct uci_section *forwardsection;
};
int browseport_forwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseAccListInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int entry_method_root_X_INTENO_SE_IpAccCfg(struct dmctx *ctx);
#endif
int add_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipacccfg_port_forwarding(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipacccfg_rule(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_port_forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_loopback(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_zone(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_source_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_internal_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_external_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_source_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_forwarding_src_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_cfgobj_address_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_ipversion(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_protocol(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_cfgobj_address_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_com_ip_acc_list_cfgobj_acc_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -16,6 +16,15 @@
#include "dmcommon.h"
#include "x_inteno_se_logincfg.h"
DMLEAF tSe_LoginCfgParam[] = {
{"AdminPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_admin_password, NULL, NULL},
{"SupportPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_support_password, NULL, NULL},
{"UserPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_user_password, NULL, NULL},
{"RootPassword", &DMWRITE, DMT_STRING, get_empty, set_x_bcm_root_password, NULL, NULL},
{0}
};
int set_x_bcm_password(char *refparam, struct dmctx *ctx, int action, char *value, char *user_type)
{
switch (action) {
@ -28,39 +37,26 @@ int set_x_bcm_password(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
}
int set_x_bcm_admin_password(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_admin_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "admin");
return 0;
}
int set_x_bcm_support_password(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_support_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "support");
return 0;
}
int set_x_bcm_user_password(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "user");
return 0;
}
int set_x_bcm_root_password(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_bcm_root_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_x_bcm_password(refparam, ctx, action, value, "root");
return 0;
}
int entry_method_root_X_INTENO_SE_LOGIN_CFG(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_LoginCfg.") {
DMOBJECT(DMROOT"X_INTENO_SE_LoginCfg.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("AdminPassword", ctx, "1", get_empty, set_x_bcm_admin_password, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SupportPassword", ctx, "1", get_empty, set_x_bcm_support_password, NULL, 0, 1, UNDEF, NULL);
DMPARAM("UserPassword", ctx, "1", get_empty, set_x_bcm_user_password, NULL, 0, 1, UNDEF, NULL);
DMPARAM("RootPassword", ctx, "1", get_empty, set_x_bcm_root_password, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,6 +1,11 @@
#ifndef __SE_LOGINCFG_H
#define __SE_LOGINCFG_H
int entry_method_root_X_INTENO_SE_LOGIN_CFG(struct dmctx *ctx);
extern DMLEAF tSe_LoginCfgParam[];
#endif
int set_x_bcm_admin_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_support_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_user_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_bcm_root_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -19,28 +19,54 @@
#include "dmentry.h"
#include "x_inteno_se_owsd.h"
struct owsd_listenargs cur_owsd_listenargs = {0};
inline int entry_xinteno_owsd_listenobj_instance(struct dmctx *ctx, char *iowsd_listen);
inline int entry_xinteno_owsd_listenobj(struct dmctx *ctx);
DMLEAF XIntenoSeOwsdParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"Socket", &DMWRITE, DMT_STRING, get_x_inteno_owsd_global_sock, set_x_inteno_owsd_global_sock, NULL, NULL},
{"Redirect", &DMWRITE, DMT_STRING, get_x_inteno_owsd_global_redirect, set_x_inteno_owsd_global_redirect, NULL, NULL},
{0}
};
inline int init_args_owsd_listen(struct dmctx *ctx, struct uci_section *s)
DMOBJ XIntenoSeOwsdObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf*/
{"X_INTENO_SE_ListenObj", &DMWRITE, add_owsd_listen, delete_owsd_listen_instance, NULL, browseXIntenoOwsdListenObj, NULL, NULL, NULL, X_INTENO_SE_ListenObjParams, NULL},
{0}
};
DMLEAF X_INTENO_SE_ListenObjParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"Alias", &DMWRITE, DMT_STRING, get_x_inteno_owsd_listenobj_alias, set_x_inteno_owsd_listenobj_alias, NULL, NULL},
{"Port", &DMWRITE, DMT_UNINT, get_x_inteno_owsd_listenobj_port, set_x_inteno_owsd_listenobj_alias, NULL, NULL},
{"Interface", &DMWRITE, DMT_STRING, get_x_inteno_owsd_listenobj_interface, set_x_inteno_owsd_listenobj_interface, NULL, NULL},
{"Ipv6", &DMWRITE, DMT_BOOL, get_x_inteno_owsd_listenobj_ipv6_enable, set_x_inteno_owsd_listenobj_ipv6_enable, NULL, NULL},
{"Whitelist_interface", &DMWRITE, DMT_BOOL, get_x_inteno_owsd_listenobj_whitelist_interface, set_x_inteno_owsd_listenobj_whitelist_interface, NULL, NULL},
{"Whitelist_dhcp", &DMWRITE, DMT_BOOL, get_x_inteno_owsd_listenobj_whitelist_dhcp, set_x_inteno_owsd_listenobj_whitelist_dhcp, NULL, NULL},
{"Origin", &DMWRITE, DMT_STRING, get_x_inteno_owsd_listenobj_origin, set_x_inteno_owsd_listenobj_origin, NULL, NULL},
{0}
};
int browseXIntenoOwsdListenObj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct owsd_listenargs *args = &cur_owsd_listenargs;
ctx->args = (void *)args;
args->owsd_listensection = s;
char *iowsd_listen = NULL, *iowsd_listen_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("owsd", "owsd-listen", s) {
iowsd_listen = handle_update_instance(1, dmctx, &iowsd_listen_last, update_instance_alias, 3, s, "olisteninstance", "olistenalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, iowsd_listen) == DM_STOP)
break;
}
return 0;
}
/*************************************************************************************
**** function related to owsd_origin ****
**************************************************************************************/
int get_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd", "global", "sock", value);
return 0;
}
int set_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -52,13 +78,13 @@ int set_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("owsd", "global", "redirect", value);
return 0;
}
int set_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -74,39 +100,42 @@ int set_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, int act
**** function related to owsd_listenobj ****
**************************************************************************************/
int get_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "port", value);
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "port", value);
if ((*value)[0] == '\0') {
*value = "";
}
return 0;
}
int set_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "port", value);
dmuci_set_value_by_section(owsd_listensection, "port", value);
return 0;
}
return 0;
}
int get_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface, *linker;
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "interface", &iface);
dmuci_get_value_by_section_string(owsd_listensection, "interface", &iface);
#ifdef DATAMODEL_TR098
if (iface[0] != '\0') {
dmastrcat(&linker, "linker_interface:", iface);
adm_entry_get_linker_param(DMROOT"WANDevice.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWANDevice%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
adm_entry_get_linker_param(DMROOT"LANDevice.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cLANDevice%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
}
@ -115,7 +144,7 @@ int get_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, cha
#endif
#ifdef DATAMODEL_TR181
if (iface[0] != '\0') {
adm_entry_get_linker_param(DMROOT"IP.Interface.", iface, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), iface, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
}
@ -123,21 +152,22 @@ int get_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, cha
return 0;
}
int set_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int check;
char *linker, *iface;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
#ifdef DATAMODEL_TR098
iface = linker + sizeof("linker_interface:") - 1;
#endif
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "interface", iface);
dmuci_set_value_by_section(owsd_listensection, "interface", iface);
dmfree(linker);
}
return 0;
@ -145,10 +175,11 @@ int set_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, int
return 0;
}
int get_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "ipv6", value);
dmuci_get_value_by_section_string(owsd_listensection, "ipv6", value);
if ((*value)[0] != '\0' && (*value)[0] == 'o' && (*value)[1] == 'n' ) {
*value = "1";
}
@ -157,9 +188,10 @@ int get_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, c
return 0;
}
int set_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -169,26 +201,28 @@ int set_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, i
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "ipv6", "on");
dmuci_set_value_by_section(owsd_listensection, "ipv6", "on");
else
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "ipv6", "off");
dmuci_set_value_by_section(owsd_listensection, "ipv6", "off");
return 0;
}
return 0;
}
int get_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "whitelist_interface_as_origin", value);
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "whitelist_interface_as_origin", value);
if ((*value)[0] == '\0' ) {
*value = "0";
}
return 0;
}
int set_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -198,26 +232,28 @@ int set_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "whitelist_interface_as_origin", "1");
dmuci_set_value_by_section(owsd_listensection, "whitelist_interface_as_origin", "1");
else
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "whitelist_interface_as_origin", "0");
dmuci_set_value_by_section(owsd_listensection, "whitelist_interface_as_origin", "0");
return 0;
}
return 0;
}
int get_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "whitelist_dhcp_domains", value);
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "whitelist_dhcp_domains", value);
if ((*value)[0] == '\0') {
*value = "0";
}
return 0;
}
int set_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
@ -227,19 +263,20 @@ int set_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx
case VALUESET:
string_to_bool(value, &b);
if(b)
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "whitelist_dhcp_domains", "1");
dmuci_set_value_by_section(owsd_listensection, "whitelist_dhcp_domains", "1");
else
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "whitelist_dhcp_domains", "0");
dmuci_set_value_by_section(owsd_listensection, "whitelist_dhcp_domains", "0");
return 0;
}
return 0;
}
int get_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_list *val;
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_list(cur_owsd_listenargs.owsd_listensection, "origin", &val);
dmuci_get_value_by_section_list(owsd_listensection, "origin", &val);
if (val)
*value = dmuci_list_to_string(val, " ");
else
@ -247,18 +284,19 @@ int get_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, char *
return 0;
}
int set_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *pch, *spch;
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_delete_by_section(cur_owsd_listenargs.owsd_listensection, "origin", NULL);
dmuci_delete_by_section(owsd_listensection, "origin", NULL);
value = dmstrdup(value);
pch = strtok_r(value, " ", &spch);
while (pch != NULL) {
dmuci_add_list_value_by_section(cur_owsd_listenargs.owsd_listensection, "origin", pch);
dmuci_add_list_value_by_section(owsd_listensection, "origin", pch);
pch = strtok_r(NULL, " ", &spch);
}
dmfree(value);
@ -268,26 +306,28 @@ int set_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, int ac
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, char **value)
int get_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_owsd_listenargs.owsd_listensection, "olistenalias", value);
struct uci_section *owsd_listensection = (struct uci_section *)data;
dmuci_get_value_by_section_string(owsd_listensection, "olistenalias", value);
return 0;
}
int set_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *owsd_listensection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_owsd_listenargs.owsd_listensection, "olistenalias", value);
dmuci_set_value_by_section(owsd_listensection, "olistenalias", value);
return 0;
}
return 0;
}
/***** ADD DEL OBJ *******/
int add_owsd_listen(struct dmctx *ctx, char **instancepara)
int add_owsd_listen(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
@ -303,71 +343,26 @@ int add_owsd_listen(struct dmctx *ctx, char **instancepara)
return 0;
}
int delete_owsd_listen_all(struct dmctx *ctx)
int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
struct uci_section *owsd_listensection = (struct uci_section *)data;
int found = 0;
uci_foreach_sections("owsd", "owsd-listen", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
int delete_owsd_listen_instance(struct dmctx *ctx)
{
dmuci_delete_by_section(cur_owsd_listenargs.owsd_listensection, NULL, NULL);
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_xinteno_owsd_listenobj(struct dmctx *ctx)
{
char *iowsd_listen = NULL, *iowsd_listen_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("owsd", "owsd-listen", s) {
init_args_owsd_listen(ctx, s);
iowsd_listen = handle_update_instance(1, ctx, &iowsd_listen_last, update_instance_alias, 3, s, "olisteninstance", "olistenalias");
SUBENTRY(entry_xinteno_owsd_listenobj_instance, ctx, iowsd_listen);
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(owsd_listensection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("owsd", "owsd-listen", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
return 0;
}
//////////////////////////////////////
int entry_method_root_X_INTENO_SE_OWSD(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Owsd.") {
DMOBJECT(DMROOT"X_INTENO_SE_Owsd.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("Socket", ctx, "1", get_x_inteno_owsd_global_sock, set_x_inteno_owsd_global_sock, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Redirect", ctx, "1", get_x_inteno_owsd_global_redirect, set_x_inteno_owsd_global_redirect, NULL, 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"X_INTENO_SE_Owsd.X_INTENO_SE_ListenObj.", ctx, "1", 1, add_owsd_listen, delete_owsd_listen_all, NULL);
SUBENTRY(entry_xinteno_owsd_listenobj, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_xinteno_owsd_listenobj_instance(struct dmctx *ctx, char *iowsd_listen)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Owsd.X_INTENO_SE_ListenObj.%s.", iowsd_listen) {
DMOBJECT(DMROOT"X_INTENO_SE_Owsd.X_INTENO_SE_ListenObj.%s.", ctx, "1", 1, NULL, delete_owsd_listen_instance, NULL, iowsd_listen);
DMPARAM("Alias", ctx, "1", get_x_inteno_owsd_listenobj_alias, set_x_inteno_owsd_listenobj_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Port", ctx, "1", get_x_inteno_owsd_listenobj_port, set_x_inteno_owsd_listenobj_port, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, "1", get_x_inteno_owsd_listenobj_interface, set_x_inteno_owsd_listenobj_interface, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Ipv6", ctx, "1", get_x_inteno_owsd_listenobj_ipv6_enable, set_x_inteno_owsd_listenobj_ipv6_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Whitelist_interface", ctx, "1", get_x_inteno_owsd_listenobj_whitelist_interface, set_x_inteno_owsd_listenobj_whitelist_interface, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Whitelist_dhcp", ctx, "1", get_x_inteno_owsd_listenobj_whitelist_dhcp, set_x_inteno_owsd_listenobj_whitelist_dhcp, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Origin", ctx, "1", get_x_inteno_owsd_listenobj_origin, set_x_inteno_owsd_listenobj_origin, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,10 +1,32 @@
#ifndef __SE_OWSD_H
#define __SE_OWSD_H
struct owsd_listenargs
{
struct uci_section *owsd_listensection;
};
int browseXIntenoOwsdListenObj(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_global_sock(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_global_redirect(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_ipv6_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_whitelist_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_whitelist_dhcp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_origin(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_x_inteno_owsd_listenobj_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int add_owsd_listen(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_owsd_listen_instance(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
extern DMLEAF XIntenoSeOwsdParams[];
extern DMOBJ XIntenoSeOwsdObj[];
extern DMLEAF X_INTENO_SE_ListenObjParams[];
int entry_method_root_X_INTENO_SE_OWSD(struct dmctx *ctx);
#endif

View file

@ -15,20 +15,30 @@
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmcommon.h"
#include "x_inteno_se_power_mgmt.h"
int get_pwr_mgmt_value_ethapd(char *refparam, struct dmctx *ctx, char **value)
/*** DMROOT.X_INTENO_SE_PowerManagement. ***/
DMLEAF tSe_PowerManagementParam[] = {
{"EthernetAutoPowerDownEnable", &DMWRITE, DMT_BOOL, get_pwr_mgmt_value_ethapd, set_power_mgmt_param_ethapd, NULL, NULL},
{"EnergyEfficientEthernetEnable", &DMWRITE, DMT_BOOL, get_pwr_mgmt_value_eee, set_power_mgmt_param_eee, NULL, NULL},
{"NumberOfEthernetInterfacesPoweredUp", &DMREAD, DMT_UNINT, get_pwr_nbr_interfaces_up, NULL, NULL, NULL},
{"NumberOfEthernetInterfacesPoweredDown", &DMREAD, DMT_UNINT, get_pwr_nbr_interfaces_down, NULL, NULL, NULL},
{0}
};
int get_pwr_mgmt_value_ethapd(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("power_mgmt", "power_mgmt", "ethapd", value);
return 0;
}
int get_pwr_mgmt_value_eee(char *refparam, struct dmctx *ctx, char **value)
int get_pwr_mgmt_value_eee(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("power_mgmt", "power_mgmt", "eee", value);
return 0;
}
int get_pwr_nbr_interfaces_up(char *refparam, struct dmctx *ctx, char **value)
int get_pwr_nbr_interfaces_up(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char buf[256];
int pp, r;
@ -44,7 +54,7 @@ int get_pwr_nbr_interfaces_up(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_pwr_nbr_interfaces_down(char *refparam, struct dmctx *ctx, char **value)
int get_pwr_nbr_interfaces_down(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char buf[256];
int pp, r;
@ -60,7 +70,7 @@ int get_pwr_nbr_interfaces_down(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_power_mgmt_param_ethapd(char *refparam, struct dmctx *ctx, int action, char *value)
int set_power_mgmt_param_ethapd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -80,7 +90,7 @@ int set_power_mgmt_param_ethapd(char *refparam, struct dmctx *ctx, int action, c
return 0;
}
int set_power_mgmt_param_eee(char *refparam, struct dmctx *ctx, int action, char *value)
int set_power_mgmt_param_eee(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -109,15 +119,3 @@ bool dm_powermgmt_enable_set(void)
return false;
}
}
int entry_method_root_X_INTENO_SE_PowerManagement(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_PowerManagement.") {
DMOBJECT(DMROOT"X_INTENO_SE_PowerManagement.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("EthernetAutoPowerDownEnable", ctx, "1", get_pwr_mgmt_value_ethapd, set_power_mgmt_param_ethapd, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("EnergyEfficientEthernetEnable", ctx, "1", get_pwr_mgmt_value_eee, set_power_mgmt_param_eee, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("NumberOfEthernetInterfacesPoweredUp", ctx, "0", get_pwr_nbr_interfaces_up, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("NumberOfEthernetInterfacesPoweredDown", ctx, "0", get_pwr_nbr_interfaces_down, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -12,6 +12,14 @@
#ifndef __POWER_MGMT_H
#define __POWER_MGMT_H
extern DMLEAF tSe_PowerManagementParam[];
bool dm_powermgmt_enable_set(void);
int entry_method_root_X_INTENO_SE_PowerManagement(struct dmctx *ctx);
#endif
int get_pwr_mgmt_value_ethapd(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_pwr_mgmt_value_eee(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_pwr_nbr_interfaces_up(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_pwr_nbr_interfaces_down(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_power_mgmt_param_ethapd(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_power_mgmt_param_eee(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -18,13 +18,20 @@
#include "dmcommon.h"
#include "x_inteno_syslog.h"
int get_server_ip_address(char *refparam, struct dmctx *ctx, char **value)
DMLEAF tSe_SyslogCfgParam[] = {
{"ServerIPAddress", &DMWRITE, DMT_STRING, get_server_ip_address, set_server_ip_address, NULL, NULL},
{"ServerPortNumber", &DMWRITE, DMT_UNINT, get_server_port_number, set_server_port_number, NULL, NULL},
{"RemoteLogLevel", &DMWRITE, DMT_UNINT, get_remote_log_level, set_remote_log_level, NULL, NULL},
{0}
};
int get_server_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("system", "@system[0]", "log_ip", value);
return 0;
}
int set_server_ip_address(char *refparam, struct dmctx *ctx, int action, char *value)
int set_server_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -36,7 +43,7 @@ int set_server_ip_address(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
}
int get_server_port_number(char *refparam, struct dmctx *ctx, char **value)
int get_server_port_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *tmp;
dmuci_get_option_value_string("system", "@system[0]", "log_port", &tmp);
@ -47,7 +54,7 @@ int get_server_port_number(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_server_port_number(char *refparam, struct dmctx *ctx, int action, char *value)
int set_server_port_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -59,7 +66,7 @@ int set_server_port_number(char *refparam, struct dmctx *ctx, int action, char *
return 0;
}
int get_remote_log_level(char *refparam, struct dmctx *ctx, char **value)
int get_remote_log_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *tmp;
dmuci_get_option_value_string("system", "@system[0]", "conloglevel", &tmp);
@ -70,7 +77,7 @@ int get_remote_log_level(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_remote_log_level(char *refparam, struct dmctx *ctx, int action, char *value)
int set_remote_log_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
@ -81,15 +88,3 @@ int set_remote_log_level(char *refparam, struct dmctx *ctx, int action, char *va
}
return 0;
}
int entry_method_root_syslog(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_SyslogCfg.") {
DMOBJECT(DMROOT"X_INTENO_SE_SyslogCfg.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("ServerIPAddress", ctx, "1", get_server_ip_address, set_server_ip_address, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ServerPortNumber", ctx, "1", get_server_port_number, set_server_port_number, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("RemoteLogLevel", ctx, "1", get_remote_log_level, set_remote_log_level, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,6 +1,14 @@
#ifndef __SE_SYSLOG_H
#define __SE_SYSLOG_H
int entry_method_root_syslog(struct dmctx *ctx);
extern DMLEAF tSe_SyslogCfgParam[];
#endif
int get_server_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_server_port_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_remote_log_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_server_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_server_port_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_remote_log_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -17,16 +17,36 @@
#include "dmcommon.h"
#include "xmpp.h"
struct connectionargs cur_connectionargs = {0};
inline int entry_xmpp_connection_instance(struct dmctx *ctx, char *iconnection);
/*** XMPP.Connection. ***/
DMOBJ tXMPPObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Connection", &DMWRITE, add_xmpp_connection, delete_xmpp_connection, NULL, browsexmpp_connectionInst, NULL, NULL, NULL, tConnectionParams, get_xmpp_connection_linker},
{0}
};
DMLEAF tXMPPParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"ConnectionNumberOfEntries", &DMREAD, DMT_UNINT, get_xmpp_connection_nbr_entry, NULL, NULL, NULL},
{0}
};
DMLEAF tConnectionParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Enable", &DMWRITE, DMT_BOOL, get_connection_enable, set_connection_enable, NULL, NULL},
//{"Username", &DMWRITE, DMT_STRING, get_xmpp_connection_username, set_xmpp_connection_username, NULL, NULL},
{"Password", &DMWRITE, DMT_STRING, get_xmpp_connection_password, set_xmpp_connection_password, NULL, NULL},
{"Domain", &DMWRITE, DMT_STRING, get_xmpp_connection_domain, set_xmpp_connection_domain, NULL, NULL},
{"Resource", &DMWRITE, DMT_STRING, get_xmpp_connection_resource, set_xmpp_connection_resource, NULL, NULL},
{"ServerConnectAlgorithm", &DMWRITE, DMT_STRING, get_xmpp_connection_server_connect_algorithm, set_xmpp_connection_server_connect_algorithm, NULL, NULL},
{"KeepAliveInterval", &DMWRITE, DMT_LONG, get_xmpp_connection_keepalive_interval, set_xmpp_connection_keepalive_interval, NULL, NULL},
{"ServerConnectAttempts", &DMWRITE, DMT_UNINT, get_xmpp_connection_server_attempts, set_xmpp_connection_server_attempts, NULL, NULL},
{"ServerRetryInitialInterval", &DMWRITE, DMT_UNINT, get_xmpp_connection_retry_initial_interval, set_xmpp_connection_retry_initial_interval, NULL, NULL},
{"ServerRetryIntervalMultiplier", &DMWRITE, DMT_UNINT, get_xmpp_connection_retry_interval_multiplier, set_xmpp_connection_retry_interval_multiplier, NULL, NULL},
{"ServerRetryMaxInterval", &DMWRITE, DMT_UNINT, get_xmpp_connection_retry_max_interval, set_xmpp_connection_retry_max_interval, NULL, NULL},
{"UseTLS", &DMWRITE, DMT_BOOL, get_xmpp_connection_server_usetls, set_xmpp_connection_server_usetls, NULL, NULL},
{0}
};
inline int init_args_connection_entry(struct dmctx *ctx, struct uci_section *s)
{
struct connectionargs *args = &cur_connectionargs;
ctx->args = (void *)args;
args->connsection = s;
return 0;
}
char *get_xmpp_server_enable(char *instance)
{
@ -148,7 +168,7 @@ char *get_xmpp_connect_retry_max_interval(char *instance)
return v;
}
int add_xmpp_connection(struct dmctx *ctx, char **instancepara)
int add_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
struct uci_section *s;
char *value, *name;
@ -158,33 +178,34 @@ int add_xmpp_connection(struct dmctx *ctx, char **instancepara)
return 0;
}
int delete_xmpp_connection_all()
int delete_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
struct uci_section *s, *ss = NULL;
struct connectionargs *connargs;
struct uci_section *connsection = (struct uci_section *)data;
uci_foreach_sections("cwmp", "xmpp_connection", s) {
if (found != 0) {
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(connsection, NULL, NULL);
return 0;
case DEL_ALL:
uci_foreach_sections("cwmp", "xmpp_connection", s) {
if (found != 0) {
dmuci_delete_by_section(ss, NULL, NULL);
}
ss = s;
found++;
}
if (ss != NULL) {
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
if (ss != NULL) {
dmuci_delete_by_section(ss, NULL, NULL);
}
return 0;
}
int delete_xmpp_connection(struct dmctx *ctx)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_delete_by_section(connargs->connsection, NULL, NULL);
return 0;
}
int get_xmpp_connection_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
int get_xmpp_connection_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
int cnt = 0;
@ -196,311 +217,294 @@ int get_xmpp_connection_nbr_entry(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
inline int entry_xmpp_connection(struct dmctx *ctx)
int get_connection_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "enable", value);
return 0;
}
int set_connection_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "enable", value);
return 0;
}
return 0;
}
int get_xmpp_connection_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "password", value);
return 0;
}
int set_xmpp_connection_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "password", value);
return 0;
}
return 0;
}
int get_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "password", value);
return 0;
}
int set_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "password", value);
return 0;
}
return 0;
}
int get_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "resource", value);
return 0;
}
int set_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "resource", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "serveralgorithm", value);
return 0;
}
int set_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "serveralgorithm", value);
return 0;
}
return 0;
}
int get_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "interval", value);
return 0;
}
int set_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "attempt", value);
return 0;
}
int set_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "attempt", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "initial_retry_interval", value);
return 0;
}
int set_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "initial_retry_interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "retry_interval_multiplier", value);
return 0;
}
int set_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "retry_interval_multiplier", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "retry_max_interval", value);
return 0;
}
int set_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "retry_max_interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *connsection = (struct uci_section *)data;
dmuci_get_value_by_section_string(connsection, "usetls", value);
return 0;
}
int set_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *connsection = (struct uci_section *)data;
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(connsection, "usetls", value);
return 0;
}
return 0;
}
/**************************************************************************
* LINKER
***************************************************************************/
int get_xmpp_connection_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
char *conn_instance;
struct uci_section *connsection = (struct uci_section *)data;
if (connsection)
{
dmuci_get_value_by_section_string(connsection, "connection_instance", &conn_instance);
dmasprintf(linker,"xmppc:%s", conn_instance);
return 0;
}
else
*linker = "";
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int browsexmpp_connectionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iconnection = NULL, *iconnection_last = NULL;;
struct uci_section *s = NULL;
uci_foreach_sections("cwmp", "xmpp_connection", s) {
init_args_connection_entry(ctx, s);
iconnection = handle_update_instance(1, ctx, &iconnection_last, update_instance_alias, 3, s, "connection_instance", "connection_instance_alias");
SUBENTRY(entry_xmpp_connection_instance, ctx, iconnection);
}
}
int get_connection_enable(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "enable", value);
return 0;
}
int set_connection_enable(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "enable", value);
return 0;
iconnection = handle_update_instance(1, dmctx, &iconnection_last, update_instance_alias, 3, s, "connection_instance", "connection_instance_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, iconnection) == DM_STOP)
break;
}
return 0;
}
int get_xmpp_connection_password(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "password", value);
return 0;
}
int set_xmpp_connection_password(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "password", value);
return 0;
}
return 0;
}
int get_xmpp_connection_domain(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "password", value);
return 0;
}
int set_xmpp_connection_domain(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "password", value);
return 0;
}
return 0;
}
int get_xmpp_connection_resource(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "resource", value);
return 0;
}
int set_xmpp_connection_resource(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "resource", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "serveralgorithm", value);
return 0;
}
int set_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "serveralgorithm", value);
return 0;
}
return 0;
}
int get_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "interval", value);
return 0;
}
int set_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "attempt", value);
return 0;
}
int set_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "attempt", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "initial_retry_interval", value);
return 0;
}
int set_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "initial_retry_interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "retry_interval_multiplier", value);
return 0;
}
int set_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "retry_interval_multiplier", value);
return 0;
}
return 0;
}
int get_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "retry_max_interval", value);
return 0;
}
int set_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "retry_max_interval", value);
return 0;
}
return 0;
}
int get_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, char **value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
dmuci_get_value_by_section_string(connargs->connsection, "usetls", value);
return 0;
}
int set_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, int action, char *value)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
bool b;
switch (action) {
case VALUECHECK:
if (string_to_bool(value, &b))
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value_by_section(connargs->connsection, "usetls", value);
return 0;
}
return 0;
}
inline int entry_xmpp_connection_instance(struct dmctx *ctx, char *iconnection)
{
struct connectionargs *connargs = (struct connectionargs *)ctx->args;
char linker[32] = "xmppc:";
char *conn_instance;
dmuci_get_value_by_section_string(connargs->connsection, "connection_instance", &conn_instance);
strcat(linker, conn_instance);
IF_MATCH(ctx, DMROOT"XMPP.Connection.%s.", iconnection) {
DMOBJECT(DMROOT"XMPP.Connection.%s.", ctx, "0", 1, NULL, delete_xmpp_connection, linker, iconnection);
DMPARAM("Enable", ctx, "1", get_connection_enable, set_connection_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
//DMPARAM("Username", ctx, "1", get_xmpp_connection_username, set_xmpp_connection_username, NULL, 0, 1, UNDEF, NULL); //TO CHECK
DMPARAM("Password", ctx, "1", get_xmpp_connection_password, set_xmpp_connection_password, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Domain", ctx, "1", get_xmpp_connection_domain, set_xmpp_connection_domain, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Resource", ctx, "1", get_xmpp_connection_resource, set_xmpp_connection_resource, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ServerConnectAlgorithm", ctx, "1", get_xmpp_connection_server_connect_algorithm, set_xmpp_connection_server_connect_algorithm, NULL, 0, 1, UNDEF, NULL);
DMPARAM("KeepAliveInterval", ctx, "1", get_xmpp_connection_keepalive_interval, set_xmpp_connection_keepalive_interval, "xsd:long", 0, 1, UNDEF, NULL);
DMPARAM("ServerConnectAttempts", ctx, "1", get_xmpp_connection_server_attempts, set_xmpp_connection_server_attempts, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("ServerRetryInitialInterval", ctx, "1", get_xmpp_connection_retry_initial_interval, set_xmpp_connection_retry_initial_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("ServerRetryIntervalMultiplier", ctx, "1", get_xmpp_connection_retry_interval_multiplier, set_xmpp_connection_retry_interval_multiplier, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("ServerRetryMaxInterval", ctx, "1", get_xmpp_connection_retry_max_interval, set_xmpp_connection_retry_max_interval, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("UseTLS", ctx, "1", get_xmpp_connection_server_usetls, set_xmpp_connection_server_usetls, "xsd:boolean", 0, 1, UNDEF, NULL); //TO CHECK
//SUBENTRY(entry_xmpp_connection_server, ctx, iconnection);
return 0;
}
return FAULT_9005;
}
int entry_method_root_xmpp(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"XMPP.") {
DMOBJECT(DMROOT"XMPP.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("ConnectionNumberOfEntries", ctx, "0", get_xmpp_connection_nbr_entry, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"XMPP.Connection.", ctx, "0", 1, add_xmpp_connection, delete_xmpp_connection_all, NULL);
SUBENTRY(entry_xmpp_connection, ctx);
return 0;
}
return FAULT_9005;
}

View file

@ -1,10 +1,14 @@
#ifndef __XMPP_H
#define __XMPP_H
struct connectionargs
{
struct uci_section *connsection;
};
extern DMOBJ tXMPPObj[];
extern DMLEAF tXMPPParams[];
extern DMLEAF tConnectionParams[];
int browsexmpp_connectionInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_xmpp_connection(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
char *get_xmpp_server_enable(char *instance);
char *get_xmpp_username(char *instance);
@ -16,5 +20,33 @@ char *get_xmpp_connect_attempts(char *instance);
char *get_xmpp_connect_initial_retry_interval(char *instance);
char *get_xmpp_connect_retry_interval_multiplier(char *instance);
char *get_xmpp_connect_retry_max_interval(char *instance);
int entry_method_root_xmpp(struct dmctx *ctx);
int get_xmpp_connection_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_connection_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_connection_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_domain(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_resource(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_server_connect_algorithm(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_keepalive_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_server_attempts(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_retry_initial_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_retry_interval_multiplier(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_retry_max_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_xmpp_connection_server_usetls(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_xmpp_connection_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -1,81 +1,75 @@
/*
* 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) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "deviceconfig.h"
#define BACKUP_CONFIG_FILE "/etc/backup"
#define RESTORE_FUNCTION_PATH "/usr/share/icwmp/functions/conf_backup"
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_config_file(char *refparam, struct dmctx *ctx, char **value)
{
long length;
FILE * f = NULL;
char *pch = NULL, *spch = NULL;
char * buffer = 0;
int first = 1;
dmcmd("/bin/sh", 2, RESTORE_FUNCTION_PATH, "export_conf");
f = fopen (BACKUP_CONFIG_FILE, "rb");
if (f)
{
fseek(f, 0, SEEK_END);
length = ftell(f);
fseek(f, 0, SEEK_SET);
buffer = dmmalloc(length);
if (buffer)
{
fread(buffer, 1, length, f);
}
fclose(f);
}
if (buffer)
{
*value = dmstrdup(buffer);
dmfree(buffer);
}
return 0;
}
int set_config_file(char *refparam, struct dmctx *ctx, int action, char *value)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmcmd("/bin/sh", 2, RESTORE_FUNCTION_PATH, "import_conf");
return 0;
}
return 0;
}
//////////////////////////////////////
int entry_method_root_device_config(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"DeviceConfig.") {
DMOBJECT(DMROOT"DeviceConfig.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("ConfigFile", ctx, "1", get_config_file, set_config_file, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
/*
* 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) 2015 Inteno Broadband Technology AB
* Author Imen Bhiri <imen.bhiri@pivasoftware.com>
*
*/
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "deviceconfig.h"
#define BACKUP_CONFIG_FILE "/etc/backup"
#define RESTORE_FUNCTION_PATH "/usr/share/icwmp/functions/conf_backup"
////////////////////////SET AND GET ALIAS/////////////////////////////////
/*** DMROOT.DownloadDiagnostics. ***/
DMLEAF tDeviceConfigParam[] = {
{"ConfigFile", &DMWRITE, DMT_STRING, get_config_file, set_config_file, NULL, NULL},
{0}
};
int get_config_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
long length;
FILE * f = NULL;
char *pch = NULL, *spch = NULL;
char * buffer = 0;
int first = 1;
dmcmd("/bin/sh", 2, RESTORE_FUNCTION_PATH, "export_conf");
f = fopen (BACKUP_CONFIG_FILE, "rb");
if (f)
{
fseek(f, 0, SEEK_END);
length = ftell(f);
fseek(f, 0, SEEK_SET);
buffer = dmmalloc(length);
if (buffer)
{
fread(buffer, 1, length, f);
}
fclose(f);
}
if (buffer)
{
*value = dmstrdup(buffer);
dmfree(buffer);
}
return 0;
}
int set_config_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmcmd("/bin/sh", 2, RESTORE_FUNCTION_PATH, "import_conf");
return 0;
}
return 0;
}

View file

@ -1,6 +1,8 @@
#ifndef __SE_CONFIG_FILE_H
#define __SE_CONFIG_FILE_H
int entry_method_root_device_config(struct dmctx *ctx);
#endif
#ifndef __SE_CONFIG_FILE_H
#define __SE_CONFIG_FILE_H
extern DMLEAF tDeviceConfigParam[];
int get_config_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_config_file(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -4,7 +4,7 @@
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Copyright (C) 2012-2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
*/
@ -12,15 +12,29 @@
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include "cwmp.h"
#include "diagnostic.h"
#include "ubus.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "downloaddiagnostic.h"
/*** DMROOT.DownloadDiagnostics. ***/
DMLEAF tDownloadDiagnosticsParam[] = {
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_download_diagnostics_state, set_download_diagnostics_state, NULL, NULL},
{"DownloadURL", &DMWRITE, DMT_STRING, get_download_diagnostics_url, set_download_diagnostics_url, NULL, NULL},
{"EthernetPriority", &DMWRITE, DMT_UNINT, get_download_diagnostics_ethernet_priority,set_download_diagnostics_ethernet_priority, NULL, NULL},
{"ROMTime", &DMREAD, DMT_TIME, get_download_diagnostic_romtime, NULL, NULL, NULL},
{"BOMTime", &DMREAD, DMT_TIME, get_download_diagnostic_bomtime, NULL, NULL, NULL},
{"EOMTime", &DMREAD, DMT_TIME, get_download_diagnostic_eomtime, NULL, NULL, NULL},
{"TestBytesReceived", &DMREAD, DMT_UNINT, get_download_diagnostic_testbytes, NULL, NULL, NULL},
{"TotalBytesReceived", &DMREAD, DMT_UNINT, get_download_diagnostic_totalbytes, NULL, NULL, NULL},
{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_download_diagnostic_tcp_open_request_time, NULL, NULL, NULL},
{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_download_diagnostic_tcp_open_response_time, NULL, NULL, NULL},
//{"DSCP", &DMWRITE, DMT_UNINT, get_download_diagnostics_dscp, set_download_diagnostics_dscp, NULL, NULL},
//{"Interface", &DMWRITE, DMT_UNINT, get_download_diagnostics_interface, set_download_diagnostics_interface, NULL, NULL},
{0}
};
static inline char *download_diagnostic_get(char *option, char *def)
{
char *tmp;
@ -30,13 +44,13 @@ static inline char *download_diagnostic_get(char *option, char *def)
else
return tmp;
}
int get_download_diagnostics_state(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = download_diagnostic_get("DiagnosticState", "None");
return 0;
}
int set_download_diagnostics_state(char *refparam, struct dmctx *ctx, int action, char *value)
int set_download_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -59,13 +73,13 @@ int set_download_diagnostics_state(char *refparam, struct dmctx *ctx, int action
return 0;
}
int get_download_diagnostics_interface(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "interface", value);
return 0;
}
int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -74,7 +88,7 @@ int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, int ac
return 0;
case VALUESET:
DOWNLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "downloaddiagnostic", &curr_section, &tmp);
@ -85,14 +99,14 @@ int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, int ac
return 0;
}
int get_download_diagnostics_url(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "url", value);
return 0;
}
int set_download_diagnostics_url(char *refparam, struct dmctx *ctx, int action, char *value)
int set_download_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -101,7 +115,7 @@ int set_download_diagnostics_url(char *refparam, struct dmctx *ctx, int action,
return 0;
case VALUESET:
DOWNLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "downloaddiagnostic", &curr_section, &tmp);
@ -112,13 +126,13 @@ int set_download_diagnostics_url(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
return 0;
}
int set_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, int action, char *value)
int set_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -128,7 +142,7 @@ int set_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx
return 0;
case VALUESET:
DOWNLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "downloaddiagnostic", &curr_section, &tmp);
@ -139,7 +153,7 @@ int set_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx
return 0;
}
int get_download_diagnostic_romtime(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_romtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "ROMtime", value);
@ -148,7 +162,7 @@ int get_download_diagnostic_romtime(char *refparam, struct dmctx *ctx, char **va
return 0;
}
int get_download_diagnostic_bomtime(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_bomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "BOMtime", value);
@ -157,7 +171,7 @@ int get_download_diagnostic_bomtime(char *refparam, struct dmctx *ctx, char **va
return 0;
}
int get_download_diagnostic_eomtime(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_eomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "EOMtime", value);
@ -166,7 +180,7 @@ int get_download_diagnostic_eomtime(char *refparam, struct dmctx *ctx, char **va
return 0;
}
int get_download_diagnostic_testbytes(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_testbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "TestBytesReceived", value);
@ -175,7 +189,7 @@ int get_download_diagnostic_testbytes(char *refparam, struct dmctx *ctx, char **
return 0;
}
int get_download_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "TotalBytesReceived", value);
@ -184,7 +198,7 @@ int get_download_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, char *
return 0;
}
int get_download_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "TCPOpenRequestTime", value);
@ -193,7 +207,7 @@ int get_download_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *
return 0;
}
int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "TCPOpenResponseTime", value);
@ -201,26 +215,3 @@ int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx
*value = "0";
return 0;
}
int entry_method_root_Download_Diagnostics(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"DownloadDiagnostics.") {
DMOBJECT(DMROOT"DownloadDiagnostics.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("DiagnosticsState", ctx, "1", get_download_diagnostics_state, set_download_diagnostics_state, NULL, 0, 1, UNDEF, NULL);
//DMPARAM("Interface", ctx, "1", get_download_diagnostics_interface, set_download_diagnostics_interface, NULL, 0, 1, UNDEF, NULL); //TODO
DMPARAM("DownloadURL", ctx, "1", get_download_diagnostics_url, set_download_diagnostics_url, NULL, 0, 1, UNDEF, NULL);
//DMPARAM("DSCP", ctx, "1", get_download_diagnostics_dscp, set_download_diagnostics_dscp, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("EthernetPriority", ctx, "1", get_download_diagnostics_ethernet_priority, set_download_diagnostics_ethernet_priority, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("ROMTime", ctx, "0", get_download_diagnostic_romtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("BOMTime", ctx, "0", get_download_diagnostic_bomtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("EOMTime", ctx, "0", get_download_diagnostic_eomtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("TestBytesReceived", ctx, "0", get_download_diagnostic_testbytes, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("TotalBytesReceived", ctx, "0", get_download_diagnostic_totalbytes, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("TCPOpenRequestTime", ctx, "0", get_download_diagnostic_tcp_open_request_time, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("TCPOpenResponseTime", ctx, "0", get_download_diagnostic_tcp_open_response_time, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -4,12 +4,29 @@
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Copyright (C) 2012-2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#ifndef __DOWNLOAD_DIAGNOSTIC_H
#define __DOWNLOAD_DIAGNOSTIC_H
int entry_method_root_Download_Diagnostics(struct dmctx *ctx);
static inline char *download_diagnostic_get(char *option, char *def);
int get_download_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_download_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_download_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_download_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_download_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_download_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_download_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_download_diagnostic_romtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_bomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_eomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_testbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
extern DMLEAF tDownloadDiagnosticsParam[];
#endif

View file

@ -12,15 +12,29 @@
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include "cwmp.h"
#include "diagnostic.h"
#include "ubus.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "ippingdiagnostics.h"
/*** IPPingDiagnostics. ***/
DMLEAF tIPPingDiagnosticsParam[] = {
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_ipping_diagnostics_state, set_ipping_diagnostics_state, NULL, NULL},
{"Interface", &DMWRITE, DMT_STRING, get_ipping_interface, set_ipping_interface, NULL, NULL},
{"Host", &DMWRITE, DMT_STRING, get_ipping_host, set_ipping_host, NULL, NULL},
{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_ipping_repetition_number, set_ipping_repetition_number, NULL, NULL},
{"Timeout", &DMWRITE, DMT_UNINT, get_ipping_timeout, set_ipping_timeout, NULL, NULL},
{"DataBlockSize", &DMWRITE, DMT_UNINT, get_ipping_block_size, set_ipping_block_size, NULL, NULL},
//{"DSCP", &DMWRITE, DMT_UNINT, get_ipping_dscp, set_ipping_dscp, NULL, NULL},
{"SuccessCount", &DMREAD, DMT_UNINT, get_ipping_success_count, NULL, NULL, NULL},
{"FailureCount", &DMREAD, DMT_UNINT, get_ipping_failure_count, NULL, NULL, NULL},
{"AverageResponseTime", &DMREAD, DMT_UNINT, get_ipping_average_response_time, NULL, NULL, NULL},
{"MinimumResponseTime", &DMREAD, DMT_UNINT, get_ipping_min_response_time, NULL, NULL, NULL},
{"MaximumResponseTime", &DMREAD, DMT_UNINT, get_ipping_max_response_time, NULL, NULL, NULL},
{0}
};
static inline char *ipping_get(char *option, char *def)
{
char *tmp;
@ -30,13 +44,13 @@ static inline char *ipping_get(char *option, char *def)
else
return tmp;
}
int get_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("DiagnosticState", "None");
return 0;
}
int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -46,7 +60,7 @@ int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, int action,
case VALUESET:
if (strcmp(value, "Requested") == 0) {
IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -59,13 +73,13 @@ int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_ipping_interface(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@ippingdiagnostic[0]", "interface", value);
return 0;
}
int set_ipping_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -74,7 +88,7 @@ int set_ipping_interface(char *refparam, struct dmctx *ctx, int action, char *va
return 0;
case VALUESET:
//IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -85,14 +99,14 @@ int set_ipping_interface(char *refparam, struct dmctx *ctx, int action, char *va
return 0;
}
int get_ipping_host(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@ippingdiagnostic[0]", "Host", value);
return 0;
}
int set_ipping_host(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -101,7 +115,7 @@ int set_ipping_host(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
case VALUESET:
IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -112,13 +126,13 @@ int set_ipping_host(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
}
int get_ipping_repetition_number(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("NumberOfRepetitions", "3");
return 0;
}
int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -128,7 +142,7 @@ int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, int action,
return 0;
case VALUESET:
IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -139,14 +153,14 @@ int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_ipping_timeout(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("Timeout", "1000");
return 0;
}
int set_ipping_timeout(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *curr_section = NULL;
char *tmp;
@ -156,7 +170,7 @@ int set_ipping_timeout(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
case VALUESET:
IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -167,14 +181,14 @@ int set_ipping_timeout(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
}
int get_ipping_block_size(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("DataBlockSize", "64");
return 0;
}
int set_ipping_block_size(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -183,7 +197,7 @@ int set_ipping_block_size(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
case VALUESET:
IPPING_STOP
curr_section = dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp);
@ -193,57 +207,37 @@ int set_ipping_block_size(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
}
int get_ipping_success_count(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("SuccessCount", "0");
return 0;
}
int get_ipping_failure_count(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("FailureCount", "0");
return 0;
}
int get_ipping_average_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("AverageResponseTime", "0");
return 0;
}
int get_ipping_min_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("MinimumResponseTime", "0");
return 0;
}
int get_ipping_max_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ipping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("MaximumResponseTime", "0");
return 0;
}
int entry_method_root_IPPingDiagnostics(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"IPPingDiagnostics.") {
DMOBJECT(DMROOT"IPPingDiagnostics.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("DiagnosticsState", ctx, "1", get_ipping_diagnostics_state, set_ipping_diagnostics_state, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, "1", get_ipping_interface, set_ipping_interface, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Host", ctx, "1", get_ipping_host, set_ipping_host, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NumberOfRepetitions", ctx, "1", get_ipping_repetition_number, set_ipping_repetition_number, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("Timeout", ctx, "1", get_ipping_timeout, set_ipping_timeout, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("DataBlockSize", ctx, "1", get_ipping_block_size, set_ipping_block_size, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
//DMPARAM("DSCP", ctx, "1", get_ipping_dscp, set_ipping_dscp, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("SuccessCount", ctx, "0", get_ipping_success_count, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("FailureCount", ctx, "0", get_ipping_failure_count, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("AverageResponseTime", ctx, "0", get_ipping_average_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MinimumResponseTime", ctx, "0", get_ipping_min_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MaximumResponseTime", ctx, "0", get_ipping_max_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -10,7 +10,27 @@
#ifndef __IPPING_DIAGNOSTIC_H
#define __IPPING_DIAGNOSTIC_H
extern struct ip_ping_diagnostic ipping_diagnostic;
int entry_method_root_IPPingDiagnostics(struct dmctx *ctx);
extern DMLEAF tIPPingDiagnosticsParam[];
#endif
int get_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -16,31 +16,47 @@
#include "dmcommon.h"
#include "lan_interfaces.h"
struct linterfargs cur_linterfargs = {0};
struct wifaceargs cur_wifaceargs = {0};
static inline void laninterface_lookup(char *eths[], int *size);
int entry_laninterface_lan(struct dmctx *ctx);
int entry_laninterface_wlan(struct dmctx *ctx);
inline int entry_laninterface_wlan_instance(struct dmctx *ctx, char *wli);
inline int entry_laninterface_lan_instance(struct dmctx *ctx, char *li);
struct ethrnet_ifaces_s ethrnet_ifaces_g = {0};
void laninterface_lookup(char *eths[], int *size);
/*** LANInterfaces. ***/
DMOBJ tLANInterfacesObj[] = {
{"LANEthernetInterfaceConfig", &DMREAD, NULL, NULL, NULL, browselaninterface_lanInst, NULL, NULL, NULL, tlaninterface_lanParam, NULL},
{"WLANConfiguration", &DMREAD, NULL, NULL, NULL, browselaninterface_wlanInst, NULL, NULL, NULL, tlaninterface_wlanParam, NULL},
{0}
};
DMLEAF tLANInterfacesParam[] = {
{"LANEthernetInterfaceNumberOfEntries", &DMREAD, DMT_UNINT, get_lan_ethernet_interface_number, NULL, NULL, NULL},
{"LANWLANConfigurationNumberOfEntries", &DMREAD, DMT_UNINT, get_lan_wlan_configuration_number, NULL, NULL, NULL},
{0}
};
/*** LANInterfaces.LANEthernetInterfaceConfig. ***/
DMLEAF tlaninterface_lanParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_lan_eth_int_alias, set_lan_eth_int_alias, NULL, NULL},
{"X_INTENO_COM_EthName", &DMREAD, DMT_STRING, get_eth_name, NULL, NULL, NULL},
{0}
};
/*** LANInterfaces.WLANConfiguration. ***/
DMLEAF tlaninterface_wlanParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_wlan_conf_alias, set_wlan_conf_alias, NULL, NULL},
{0}
};
//////////////////////INIT ARGS////////////////////////////////
static inline int init_lan_interface_args(char *lif, struct uci_section *port_sec)
int init_lan_interface_args(struct linterfargs *args, char *lif, struct uci_section *port_sec)
{
cur_linterfargs.linterf = lif;
cur_linterfargs.port_sec = port_sec;
args->linterf = lif;
args->port_sec = port_sec;
return 0;
}
static inline int init_wifi_iface_args(struct uci_section *s)
int get_lan_ethernet_interface_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
cur_wifaceargs.wiface_sec = s;
return 0;
}
int get_lan_ethernet_interface_number(char *refparam, struct dmctx *ctx, char **value)
{
struct linterfargs *lifargs = (struct linterfargs *)ctx->args;
dmasprintf(value, "%d", lifargs->eths_size);// MEM WILL BE FREED IN DMMEMCLEAN
dmasprintf(value, "%d", ethrnet_ifaces_g.eths_size);// MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
@ -56,7 +72,7 @@ static inline int lan_wlan_configuration_number()
return cnt;
}
int get_lan_wlan_configuration_number(char *refparam, struct dmctx *ctx, char **value)
int get_lan_wlan_configuration_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int cnt = lan_wlan_configuration_number();
@ -64,21 +80,23 @@ int get_lan_wlan_configuration_number(char *refparam, struct dmctx *ctx, char **
return 0;
}
int get_eth_name(char *refparam, struct dmctx *ctx, char **value)
int get_eth_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct linterfargs *lifargs = (struct linterfargs *)ctx->args;
struct linterfargs *lifargs = (struct linterfargs *)data;
*value = lifargs->linterf;
return 0;
}
static inline void laninterface_lookup(char *eths[], int *size)
void laninterface_lookup(char *eths[], int *size)
{
static char eths_buf[64];
char *phy_itf;
char *savepch;
int n = 0;
if (*size)
return;
db_get_value_string("hw", "board", "ethernetLanPorts", &phy_itf);
strcpy(eths_buf, phy_itf);
eths[n] = strtok_r(eths_buf, " ", &savepch);
@ -88,107 +106,84 @@ static inline void laninterface_lookup(char *eths[], int *size)
*size = n;
}
void init_laninterface_lan(struct dmctx *ctx)
inline void init_laninterface_lan(struct dmctx *ctx, void *data)
{
struct linterfargs *args = &cur_linterfargs;
ctx->args = (void *)args;
laninterface_lookup(args->eths, &(args->eths_size));
laninterface_lookup(ethrnet_ifaces_g.eths, &(ethrnet_ifaces_g.eths_size));
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_lan_eth_int_alias(char *refparam, struct dmctx *ctx, char **value)
int get_lan_eth_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_linterfargs.port_sec, "lanportalias", value);
struct linterfargs *args = (struct linterfargs *)data;
dmuci_get_value_by_section_string(args->port_sec, "lanportalias", value);
return 0;
}
int set_lan_eth_int_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_lan_eth_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct linterfargs *args = (struct linterfargs *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_linterfargs.port_sec, "lanportalias", value);
dmuci_set_value_by_section(args->port_sec, "lanportalias", value);
return 0;
}
return 0;
}
int get_wlan_conf_alias(char *refparam, struct dmctx *ctx, char **value)
int get_wlan_conf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_wifaceargs.wiface_sec, "wifacealias", value);
struct uci_section *wiface_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(wiface_sec, "wifacealias", value);
return 0;
}
int set_wlan_conf_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_wlan_conf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *wiface_sec = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_wifaceargs.wiface_sec, "wifacealias", value);
dmuci_set_value_by_section(wiface_sec, "wifacealias", value);
return 0;
}
return 0;
}
/////////////SUB ENTRIES///////////////
int entry_laninterface_lan(struct dmctx *ctx)
bool check_laninterfaces(struct dmctx *dmctx, void *data)
{
init_laninterface_lan(dmctx, data);
return true;
}
int browselaninterface_lanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *ei, *ei_last = NULL;
int i = 0;
struct linterfargs *args = &cur_linterfargs;
ctx->args = (void *)args;
struct linterfargs curr_linterfargs = {0};
struct linterfargs *args = &curr_linterfargs;
struct uci_section *s = NULL;
laninterface_lookup(args->eths, &(args->eths_size));
update_section_list(DMMAP,"lan_port", NULL, args->eths_size, NULL, NULL, NULL, NULL, NULL);
update_section_list(DMMAP,"lan_port", NULL, ethrnet_ifaces_g.eths_size, NULL, NULL, NULL, NULL, NULL);
uci_path_foreach_sections(icwmpd, "dmmap", "lan_port", s) {
init_lan_interface_args(args->eths[i++], s);
ei = handle_update_instance(1, ctx, &ei_last, update_instance_alias_icwmpd, 3, s, "lanportinstance", "lanportalias");
SUBENTRY(entry_laninterface_lan_instance, ctx, ei);
init_lan_interface_args(args, ethrnet_ifaces_g.eths[i++], s);
ei = handle_update_instance(1, dmctx, &ei_last, update_instance_alias_icwmpd, 3, s, "lanportinstance", "lanportalias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)args, ei) == DM_STOP)
break;
}
return 0;
}
int entry_laninterface_wlan(struct dmctx *ctx)
int browselaninterface_wlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s = NULL;
char *wi, *wi_last = NULL;
uci_foreach_sections("wireless", "wifi-iface", s) {
init_wifi_iface_args(s);
wi = handle_update_instance(1, ctx, &wi_last, update_instance_alias, 3, s, "wifaceinstance", "wifacealias");
SUBENTRY(entry_laninterface_wlan_instance, ctx, wi);
wi = handle_update_instance(1, dmctx, &wi_last, update_instance_alias, 3, s, "wifaceinstance", "wifacealias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, wi) == DM_STOP)
break;
}
return 0;
}
////////////////////////////////////////
int entry_method_root_InternetGatewayDevice_LANInterfaces(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"LANInterfaces.") {
init_laninterface_lan(ctx);
DMOBJECT(DMROOT"LANInterfaces.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("LANEthernetInterfaceNumberOfEntries", ctx, "0", get_lan_ethernet_interface_number, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("LANWLANConfigurationNumberOfEntries", ctx, "0", get_lan_wlan_configuration_number, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"LANInterfaces.LANEthernetInterfaceConfig.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"LANInterfaces.WLANConfiguration.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_laninterface_lan, ctx);
SUBENTRY(entry_laninterface_wlan, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_laninterface_lan_instance(struct dmctx *ctx, char *li)
{
DMOBJECT(DMROOT"LANInterfaces.LANEthernetInterfaceConfig.%s.", ctx, "0", 1, NULL, NULL, NULL, li);
DMPARAM("Alias", ctx, "1", get_lan_eth_int_alias, set_lan_eth_int_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("X_INTENO_COM_EthName", ctx, "0", get_eth_name, NULL, NULL, 0, 1, UNDEF, NULL);
return 0;
}
inline int entry_laninterface_wlan_instance(struct dmctx *ctx, char *wli)
{
DMOBJECT(DMROOT"LANInterfaces.WLANConfiguration.%s.", ctx, "0", 1, NULL, NULL, NULL, wli);
DMPARAM("Alias", ctx, "1", get_wlan_conf_alias, set_wlan_conf_alias, NULL, 0, 1, UNDEF, NULL);
return 0;
}

View file

@ -4,16 +4,31 @@
struct linterfargs
{
char *linterf;
char *eths[16];
int eths_size;
struct uci_section *port_sec;
};
struct wifaceargs
struct ethrnet_ifaces_s
{
struct uci_section *wiface_sec;
char *eths[16];
int eths_size;
};
int entry_method_root_InternetGatewayDevice_LANInterfaces(struct dmctx *ctx);
bool check_laninterfaces(struct dmctx *dmctx, void *data);
extern DMLEAF tlaninterface_lanParam[];
extern DMLEAF tlaninterface_wlanParam[];
extern DMLEAF tLANInterfacesParam[];
extern DMOBJ tLANInterfacesObj[];
#endif
int browselaninterface_lanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselaninterface_wlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_lan_eth_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_conf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_ethernet_interface_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_wlan_configuration_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_lan_eth_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_conf_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

File diff suppressed because it is too large Load diff

View file

@ -15,6 +15,28 @@
#include <json-c/json.h>
#define NVRAM_FILE "/proc/nvram/WpaKey"
extern DMLEAF tLanhost_Config_ManagementParam[];
extern DMLEAF tDHCPStaticAddressParam[];
extern DMLEAF tIPInterfaceParam[];
extern DMLEAF tlanethernetinterfaceconfigParam[];
extern DMOBJ tLanhost_Config_ManagementObj[];
extern DMLEAF tWlanConfigurationParam[];
extern DMLEAF tWPSParam[];
extern DMLEAF tWepKeyParam[];
extern DMLEAF tpresharedkeyParam[];
extern DMLEAF tassociateddeviceParam[];
extern DMOBJ tWlanConfigurationObj[];
extern DMOBJ tLANDeviceinstObj[];
extern DMOBJ tLANDeviceObj[];
extern DMOBJ tlanethernetinterfaceconfigObj[];
extern DMLEAF tlanethernetinterfaceStatsParam[];
extern DMLEAF tLANDeviceParam[];
extern DMLEAF tlandevice_hostParam[];
extern DMOBJ tlandevice_hostObj[];
extern DMLEAF tlandevice_hostsParam[];
extern DMOBJ tDHCPConditionalServingPoolobj[];
extern DMLEAF tDHCPConditionalServingPoolParam[];
extern DMLEAF tDHCPOptionParam[];
struct wl_clientargs
{
char *mac;
@ -33,27 +55,6 @@ struct ldlanargs
char *ldinstance;
};
struct ldipargs
{
struct uci_section *ldipsection;
};
struct lddhcpargs
{
struct uci_section *lddhcpsection;
};
struct dhcppoolargs
{
struct uci_section *dhcppoolsection;
};
struct dhcppooloptionargs
{
struct uci_section *dhcppooloptionsection;
struct uci_section *dhcppoolsection;
};
struct ldwlanargs
{
struct uci_section *lwlansection;
@ -74,11 +75,15 @@ struct ldethargs
struct wlan_psk
{
struct uci_section *wlanpsk;
struct uci_section *lwlansection;
char *wiface;
int pki;
};
struct wlan_wep
{
struct uci_section *wlanwep;
struct uci_section *lwlansection;
unsigned int key_index;
};
@ -88,5 +93,188 @@ typedef struct dhcp_param
char *state_sec;
}dhcp_param;
int entry_method_root_LANDevice(struct dmctx *ctx);
struct dhcppooloptionargs
{
struct uci_section *dhcppooloptionsection;
struct uci_section *dhcppoolsection;
};
int browselandeviceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcp_static_addressInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselanethernetinterfaceconfigInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWlanConfigurationInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWepKeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsepresharedkeyInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseassociateddeviceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselandevice_hostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseentry_landevice_dhcpconditionalservingpool_option_instance(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselandevice_lanhostconfigmanagement_dhcpconditionalservingpool_instance(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_landevice_wlanconfiguration(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_landevice_wlanconfiguration(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_landevice_dhcpstaticaddress(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_landevice_dhcpstaticaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_dhcp_conditional_serving_pool(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_conditional_serving_pool(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_dhcp_serving_pool_option(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_serving_pool_option(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_lan_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dns(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_server_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_interval_address_start(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_interval_address_end(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_ip_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_enable_ipinterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_firewall_enabled_ipinterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcpstaticaddress_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcpstaticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcpstaticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_conditional_servingpool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_conditional_servingpool_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_conditional_servingpool_vendorclassid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_conditional_servingpool_network_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_servingpool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_servingpool_tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_servingpool_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_macaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_addresssource(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_host_leasetimeremaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_lan_eth_iface_cfg_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_max_bit_rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_beacon_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_mac_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wep_key_index(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wep_encryption_level(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_basic_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_basic_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wpa_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wpa_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ieee_11i_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ieee_11i_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_radio_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_device_operation_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_authentication_service_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_devstatus_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_devstatus_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_devstatus_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_devstatus_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_channelmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_maxssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_scantimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_x_inteno_se_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wps_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_wep_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_psk_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_psk_assoc_MACAddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_associated_macaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_associated_ipddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_associated_authenticationstate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_lanhost_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_lan_dns(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_server_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_server_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_address_start(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_address_end(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_ip_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_enable_ipinterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_firewall_enabled_ipinterface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_addressingtype(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcpstaticaddress_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcpstaticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcpstaticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_conditional_servingpool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_conditionalservingpool_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_conditional_servingpool_vendorclassid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_conditional_servingpool_network_id(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_servingpool_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_servingpool_tag(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_servingpool_value(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_eth_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_eth_iface_cfg_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_eth_iface_cfg_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_eth_iface_cfg_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_max_bit_rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_beacon_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_mac_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wep_key_index(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_key_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_basic_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_basic_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wpa_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wpa_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ieee_11i_encryption_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ieee_11i_authentication_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_radio_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_device_operation_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_authentication_service_mode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_se_channelmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_se_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_se_maxssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_se_scantimer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_x_inteno_se_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wps_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wep_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_wep_key1(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_psk_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_pre_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_preshared_key_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_lan_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

File diff suppressed because it is too large Load diff

View file

@ -12,6 +12,90 @@
#ifndef __Layer_2_bridging_H
#define __Layer_2_bridging_H
int entry_method_root_Layer2Bridging(struct dmctx *ctx);
extern DMOBJ tLayer2BridgingObj[];
extern DMOBJ tlayer2_bridgeObj[];
extern DMLEAF tbridge_vlanParam[];
extern DMLEAF tlayer2_bridgeParam[];
extern DMLEAF tlayer2_markingParam[];
extern DMLEAF tavailableinterfaceParam[];
struct wan_interface
{
char *instance;
char *name;
char *package;
char *section;
};
struct args_layer2
{
struct uci_section *layer2section;
struct uci_section *layer2sectionlev2;
char *bridge_instance;
char *availableinterface_instance;
char *interface_type;
char *oface;
};
int browselayer2_availableinterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselayer2_bridgeInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browselayer2_markingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsebridge_vlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int set_marking_bridge_key_sub(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value);
int set_marking_interface_key_sub(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value);
int set_bridge_vlan_enable_sub(char *refparam, struct dmctx *ctx, void *data, char *instance, bool b);
int set_bridge_vlanid_sub(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value);
void remove_config_interfaces(char *baseifname, char *bridge_key, struct uci_section *bridge_s, char *mbi);
int synchrinize_layer2_bridgeInst(struct dmctx *dmctx);
int synchronize_availableinterfaceInst(struct dmctx *dmctx);
void init_args_layer2(struct args_layer2 *args, struct uci_section *s, struct uci_section *ss,
char *availableinterface_instance, char *bridge_instance,
char *interface_type, char *oface);
void init_args_layer2_vlan(struct args_layer2 *args, struct uci_section *ss);
struct uci_section *update_availableinterface_list(struct dmctx *ctx, char *iface, char **instance, char **instance_last);
void update_markinginterface_list(struct uci_section *interface_section, char *bridge_key, char *ifname);
int add_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_layer2bridging_bridge(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_layer2bridging_marking(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_layer2bridging_marking(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_layer2bridging_bridge_vlan(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_layer2bridging_bridge_vlan(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_avai_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_avai_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_marking_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_marking_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_bridge_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bridge_vlanid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_vlanid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_available_interface_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_reference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interfaces_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
char *layer2_get_last_section_instance(char *package, char *section, char *opt_inst);
int update_bridge_vlan_config(char *vid, char *bridge_key);
int update_bridge_all_vlan_config_bybridge(struct dmctx *ctx, struct args_layer2 *curr_args);
void update_add_vlan_interfaces(char *bridge_key, char *vid);
void update_add_vlan_to_bridge_interface(char *bridge_key, struct uci_section *dmmap_s);
int get_marking_bridge_reference(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
void get_baseifname_from_ifname(char *ifname, char *baseifname);
int set_marking_bridge_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_marking_interface_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_marking_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_brvlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_brvlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_marking_interface_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bridge_vlan_vid_sub(struct uci_section *vb, char *value);
#endif

View file

@ -20,19 +20,40 @@
#include "dmjson.h"
#include "layer_3_forwarding.h"
enum enum_route_type {
ROUTE_STATIC,
ROUTE_DYNAMIC,
ROUTE_DISABLED
/*** Layer3Forwarding. ***/
DMOBJ tLayer3ForwardingObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Forwarding", &DMREAD, NULL, NULL, NULL, browseForwardingInst, NULL, NULL, NULL, tForwardingInstParam, NULL},
{0}
};
struct routefwdargs cur_routefwdargs = {0};
DMLEAF tLayer3ForwardingParam[] = {
{"DefaultConnectionService", &DMWRITE, DMT_STRING, get_layer3_def_conn_serv, set_layer3_def_conn_serv, NULL, NULL},
{"ForwardNumberOfEntries", &DMREAD, DMT_UNINT, get_layer3_nbr_entry, NULL, NULL, NULL},
{0}
};
inline int entry_layer3_forwarding_instance(struct dmctx *ctx, char *iroute, char *permission);
inline int init_args_rentry(struct dmctx *ctx, struct uci_section *s, char *permission, struct proc_route *proute, int type)
/*** Layer3Forwarding.Forwarding.{i}. ***/
DMLEAF tForwardingInstParam[] = {
{"Enable", &DMForwarding_perm, DMT_BOOL, get_layer3_enable, set_layer3_enable, NULL, NULL},
{"Status", &DMREAD, DMT_STRING, get_layer3_status, NULL, NULL, NULL},
{"Alias", &DMWRITE, DMT_STRING, get_layer3_alias, set_layer3_alias, NULL, NULL},
{"Type", &DMREAD, DMT_STRING, get_layer3_type, NULL, NULL, NULL},
{"DestIPAddress", &DMForwarding_perm, DMT_STRING, get_layer3_destip, set_layer3_destip, NULL, NULL},
{"DestSubnetMask", &DMForwarding_perm, DMT_STRING, get_layer3_destmask, set_layer3_destmask, NULL, NULL},
{"SourceIPAddress", &DMREAD, DMT_STRING, get_layer3_src_address, NULL, NULL, NULL},
{"SourceSubnetMask", &DMREAD, DMT_STRING, get_layer3_src_mask, NULL, NULL, NULL},
{"GatewayIPAddress", &DMForwarding_perm, DMT_STRING, get_layer3_gatewayip, set_layer3_gatewayip, NULL, NULL},
{"Interface", &DMForwarding_perm, DMT_STRING, get_layer3_interface_linker_parameter, set_layer3_interface_linker_parameter, NULL, NULL},
{"ForwardingMetric", &DMForwarding_perm, DMT_STRING, get_layer3_metric, set_layer3_metric, NULL, NULL},
{"MTU", &DMForwarding_perm, DMT_STRING, get_layer3_mtu, set_layer3_mtu, NULL, NULL},
{0}
};
inline int init_args_rentry(struct routingfwdargs *args, struct uci_section *s, char *permission, struct proc_routing *proute, int type)
{
struct routefwdargs *args = &cur_routefwdargs;
ctx->args = (void *)args;
args->permission = permission;
args->routefwdsection = s;
args->proute = proute;
@ -52,39 +73,7 @@ void ip_to_hex(char *address, char *ret) //TODO Move to the common.c
sprintf(ret, "%02X%02X%02X%02X", ip[0], ip[1], ip[2], ip[3]);
}
void hex_to_ip(char *address, char *ret) //TODO Move to the common.c
{
int i;
int ip[4] = {0};
sscanf(address, "%2x%2x%2x%2x", &(ip[0]), &(ip[1]), &(ip[2]), &(ip[3]));
if (htonl(13) == 13) {
sprintf(ret, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
} else {
sprintf(ret, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
}
}
void parse_proc_route_line(char *line, struct proc_route *proute)
{
char *pch, *spch;
proute->iface = strtok_r(line, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->destination);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->gateway);
proute->flags = strtok_r(NULL, " \t", &spch);
proute->refcnt = strtok_r(NULL, " \t", &spch);
proute->use = strtok_r(NULL, " \t", &spch);
proute->metric = strtok_r(NULL, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->mask);
proute->mtu = strtok_r(NULL, " \t", &spch);
proute->window = strtok_r(NULL, " \t", &spch);
proute->irtt = strtok_r(NULL, " \t\n\r", &spch);
}
bool is_proute_static(struct proc_route *proute)
bool is_proute_static(struct proc_routing *proute)
{
char *mask;
struct uci_section *s;
@ -104,8 +93,8 @@ bool is_proute_static(struct proc_route *proute)
bool is_cfg_route_active(struct uci_section *s)
{
FILE *fp;
char line[MAX_PROC_ROUTE];
struct proc_route proute;
char line[MAX_PROC_ROUTING];
struct proc_routing proute;
char *dest, *mask;
dmuci_get_value_by_section_string(s, "target", &dest);
@ -114,8 +103,8 @@ bool is_cfg_route_active(struct uci_section *s)
fp = fopen(ROUTE_FILE, "r");
if ( fp != NULL)
{
fgets(line, MAX_PROC_ROUTE, fp);
while (fgets(line, MAX_PROC_ROUTE, fp) != NULL )
fgets(line, MAX_PROC_ROUTING, fp);
while (fgets(line, MAX_PROC_ROUTING, fp) != NULL )
{
if (line[0] == '\n')
continue;
@ -138,8 +127,8 @@ int get_forwarding_last_inst()
struct uci_section *s;
int cnt = 0;
FILE *fp;
char line[MAX_PROC_ROUTE];
struct proc_route proute;
char line[MAX_PROC_ROUTING];
struct proc_routing proute;
uci_foreach_sections("network", "route", s) {
dmuci_get_value_by_section_string(s, "routeinstance", &tmp);
@ -242,7 +231,7 @@ char *forwarding_update_instance_alias_icwmpd(int action, char **last_inst, void
return instance;
}
struct uci_section *update_route_dynamic_section(struct proc_route *proute)
struct uci_section *update_route_dynamic_section(struct proc_routing *proute)
{
struct uci_section *s = NULL;
char *name, *mask;
@ -259,9 +248,9 @@ struct uci_section *update_route_dynamic_section(struct proc_route *proute)
return s;
}
int get_layer3_enable(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection == NULL) {
*value = "1";
@ -275,11 +264,11 @@ int get_layer3_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_layer3_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *pch;
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -303,9 +292,9 @@ int set_layer3_enable(char *refparam, struct dmctx *ctx, int action, char *value
return 0;
}
int get_layer3_status(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection == NULL) {
*value = "Enabled";
@ -322,26 +311,26 @@ int get_layer3_status(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_layer3_type(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *netmask;
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "netmask", value);
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = proute->mask;
}
*value = (strcmp(*value, "255.255.255.255") == 0 || (*value)[0] == '\0') ? "Host" : "Network";
return 0;
}
int get_layer3_destip(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "target", value);
@ -350,15 +339,15 @@ int get_layer3_destip(char *refparam, struct dmctx *ctx, char **value)
}
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = dmstrdup(proute->destination); // MEM WILL BE FREED IN DMMEMCLEAN
}
return 0;
}
int set_layer3_destip(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -370,9 +359,9 @@ int set_layer3_destip(char *refparam, struct dmctx *ctx, int action, char *value
return 0;
}
int get_layer3_destmask(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "netmask", value);
@ -381,15 +370,15 @@ int get_layer3_destmask(char *refparam, struct dmctx *ctx, char **value)
}
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = dmstrdup(proute->mask); // MEM WILL BE FREED IN DMMEMCLEAN
}
return 0;
}
int set_layer3_destmask(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -401,21 +390,21 @@ int set_layer3_destmask(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_layer3_src_address(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_src_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0.0.0.0";
return 0;
}
int get_layer3_src_mask(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_src_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0.0.0.0";
return 0;
}
int get_layer3_gatewayip(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "gateway", value);
@ -424,15 +413,15 @@ int get_layer3_gatewayip(char *refparam, struct dmctx *ctx, char **value)
}
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = dmstrdup(proute->gateway); // MEM WILL BE FREED IN DMMEMCLEAN
}
return 0;
}
int set_layer3_gatewayip(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -444,20 +433,19 @@ int set_layer3_gatewayip(char *refparam, struct dmctx *ctx, int action, char *va
return 0;
}
char *get_layer3_interface(struct dmctx *ctx)
char *get_layer3_interface(struct dmctx *ctx, struct routingfwdargs *routeargs)
{
json_object *res;
char *val, *bval, *ifname, *device;
char *name;
struct uci_section *ss;
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "interface", &val);
return val;
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
bval = proute->iface;
val = bval;
if (!strstr(bval, "br-")) {
@ -480,16 +468,17 @@ char *get_layer3_interface(struct dmctx *ctx)
return "";
}
int get_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface, *linker;
*value = "";
iface = get_layer3_interface(ctx);
iface = get_layer3_interface(ctx, (struct routingfwdargs *)data);
if (iface[0] != '\0') {
dmastrcat(&linker, "linker_interface:", iface);
adm_entry_get_linker_param(DMROOT"WANDevice.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWANDevice%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
adm_entry_get_linker_param(DMROOT"LANDevice.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cLANDevice%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
}
@ -498,16 +487,16 @@ int get_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, cha
return 0;
}
int set_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker, *iface;
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
iface = linker + sizeof("linker_interface:") - 1;
dmuci_set_value_by_section(routeargs->routefwdsection, "interface", iface);
@ -518,16 +507,16 @@ int set_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, int
return 0;
}
int get_layer3_metric(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *name;
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "metric", value);
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = dmstrdup(proute->metric); // MEM WILL BE FREED IN DMMEMCLEAN
}
if ((*value)[0] == '\0') {
@ -536,9 +525,9 @@ int get_layer3_metric(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_layer3_metric(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -550,15 +539,15 @@ int set_layer3_metric(char *refparam, struct dmctx *ctx, int action, char *value
return 0;
}
int get_layer3_mtu(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_mtu(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "mtu", value);
}
else {
struct proc_route *proute = routeargs->proute;
struct proc_routing *proute = routeargs->proute;
*value = dmstrdup(proute->mtu); // MEM WILL BE FREED IN DMMEMCLEAN
}
if ((*value)[0] == '\0') {
@ -567,9 +556,9 @@ int get_layer3_mtu(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_layer3_mtu(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_mtu(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routefwdargs *routeargs = (struct routefwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -582,14 +571,14 @@ int set_layer3_mtu(char *refparam, struct dmctx *ctx, int action, char *value)
}
int get_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface, *linker;
dmuci_get_option_value_string("cwmp", "cpe", "default_wan_interface", &iface);
if (iface[0] != '\0') {
dmastrcat(&linker, "linker_interface:", iface);
adm_entry_get_linker_param(DMROOT"WANDevice.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
dmasprintf(&linker, "linker_interface:%s", iface);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWANDevice%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
*value = "";
}
@ -597,7 +586,7 @@ int get_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, char **value)
}
return 0;
}
int set_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i;
char *linker, *iface;
@ -606,7 +595,7 @@ int set_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, int action, char
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
iface = linker + sizeof("linker_interface:") - 1;
dmuci_set_value("cwmp", "cpe", "default_wan_interface", iface);
@ -617,13 +606,13 @@ int set_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_layer3_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
int cnt = 0;
FILE *fp;
char line[MAX_PROC_ROUTE];
struct proc_route proute;
char line[MAX_PROC_ROUTING];
struct proc_routing proute;
uci_foreach_sections("network", "route", s) {
cnt++;
@ -634,8 +623,8 @@ int get_layer3_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
fp = fopen(ROUTE_FILE, "r");
if ( fp != NULL)
{
fgets(line, MAX_PROC_ROUTE, fp);
while (fgets(line, MAX_PROC_ROUTE, fp) != NULL )
fgets(line, MAX_PROC_ROUTING, fp);
while (fgets(line, MAX_PROC_ROUTING, fp) != NULL )
{
if (line[0] == '\n')
continue;
@ -650,49 +639,60 @@ int get_layer3_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_layer3_alias(char *refparam, struct dmctx *ctx, char **value)
int get_layer3_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
if (cur_routefwdargs.routefwdsection) dmuci_get_value_by_section_string(cur_routefwdargs.routefwdsection, "routealias", value);
if (((struct routingfwdargs *)data)->routefwdsection) dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "routealias", value);
return 0;
}
int set_layer3_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_layer3_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (cur_routefwdargs.routefwdsection) dmuci_set_value_by_section(cur_routefwdargs.routefwdsection, "routealias", value);
if (((struct routingfwdargs *)data)->routefwdsection) dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "routealias", value);
return 0;
}
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_layer3_forwarding(struct dmctx *ctx)
struct dm_permession_s DMForwarding_perm = {"0", &get_forwording_perm};
char *get_forwording_perm(char *refparam, struct dmctx *dmctx, void *data, char *instance)
{
return ((struct routingfwdargs *)data)->permission;
}
int browseForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iroute = NULL, *iroute_last = NULL;
char *permission = "1";
struct uci_section *s = NULL, *ss = NULL;
FILE* fp = NULL;
char line[MAX_PROC_ROUTE];
struct proc_route proute;
char line[MAX_PROC_ROUTING];
struct proc_routing proute;
bool find_max = true;
struct routingfwdargs curr_routefwdargs = {0};
uci_foreach_sections("network", "route", s) {
init_args_rentry(ctx, s, "1", NULL, ROUTE_STATIC);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_layer3_forwarding_instance, ctx, iroute, permission);
init_args_rentry(&curr_routefwdargs, s, "1", NULL, ROUTE_STATIC);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
uci_foreach_sections("network", "route_disabled", s) {
init_args_rentry(ctx, s, "1", NULL, ROUTE_DISABLED);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_layer3_forwarding_instance, ctx, iroute, permission);
init_args_rentry(&curr_routefwdargs, s, "1", NULL, ROUTE_DISABLED);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
fp = fopen(ROUTE_FILE, "r");
if ( fp != NULL)
{
fgets(line, MAX_PROC_ROUTE, fp);
while (fgets(line, MAX_PROC_ROUTE, fp) != NULL )
fgets(line, MAX_PROC_ROUTING, fp);
while (fgets(line, MAX_PROC_ROUTING, fp) != NULL )
{
if (line[0] == '\n')
continue;
@ -700,46 +700,13 @@ inline int entry_layer3_forwarding(struct dmctx *ctx)
if (is_proute_static(&proute))
continue;
ss = update_route_dynamic_section(&proute);
init_args_rentry(ctx, ss, "0", &proute, ROUTE_DYNAMIC);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias_icwmpd, 4, ss, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_layer3_forwarding_instance, ctx, iroute, "0");
init_args_rentry(&curr_routefwdargs, ss, "0", &proute, ROUTE_DYNAMIC);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias_icwmpd, 4, ss, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
fclose(fp) ;
}
end:
return 0;
}
//////////////////////////////////////
int entry_method_root_layer3_forwarding(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"Layer3Forwarding.") {
DMOBJECT(DMROOT"Layer3Forwarding.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"Layer3Forwarding.Forwarding.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("DefaultConnectionService", ctx, "1", get_layer3_def_conn_serv, set_layer3_def_conn_serv, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ForwardNumberOfEntries", ctx, "0", get_layer3_nbr_entry, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
SUBENTRY(entry_layer3_forwarding, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_layer3_forwarding_instance(struct dmctx *ctx, char *iroute, char *permission)
{
IF_MATCH(ctx, DMROOT"Layer3Forwarding.Forwarding.%s.", iroute) {
DMOBJECT(DMROOT"Layer3Forwarding.Forwarding.%s.", ctx, "0", 1, NULL, NULL, NULL, iroute);
DMPARAM("Enable", ctx, permission, get_layer3_enable, set_layer3_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Status", ctx, "0", get_layer3_status, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Alias", ctx, "1", get_layer3_alias, set_layer3_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Type", ctx, "0", get_layer3_type, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DestIPAddress", ctx, permission, get_layer3_destip, set_layer3_destip, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DestSubnetMask", ctx, permission, get_layer3_destmask, set_layer3_destmask, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceIPAddress", ctx, "0", get_layer3_src_address, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceSubnetMask", ctx, "0", get_layer3_src_mask, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("GatewayIPAddress", ctx, permission, get_layer3_gatewayip, set_layer3_gatewayip, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, permission, get_layer3_interface_linker_parameter, set_layer3_interface_linker_parameter, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ForwardingMetric", ctx, permission, get_layer3_metric, set_layer3_metric, NULL, 0, 1, UNDEF, NULL);
DMPARAM("MTU", ctx, permission, get_layer3_mtu, set_layer3_mtu, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -2,29 +2,45 @@
#define __LAYER3_FORWORDING_H
#define ROUTE_FILE "/proc/net/route"
#define MAX_PROC_ROUTE 256
struct proc_route {
char *iface;
char *flags;
char *refcnt;
char *use;
char *metric;
char *mtu;
char *window;
char *irtt;
char destination[16];
char gateway[16];
char mask[16];
enum enum_route_type {
ROUTE_STATIC,
ROUTE_DYNAMIC,
ROUTE_DISABLED
};
struct routefwdargs
{
char *permission;
struct uci_section *routefwdsection;
struct proc_route *proute;
int type;
};
extern struct dm_permession_s DMForwarding_perm;
extern DMLEAF tForwardingInstParam[];
extern DMOBJ tLayer3ForwardingObj[];
extern DMLEAF tLayer3ForwardingParam[];
int browseForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
char *get_forwording_perm(char *refparam, struct dmctx *dmctx, void *data, char *instance);
int get_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_src_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_src_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_layer3_mtu(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_layer3_def_conn_serv(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_mtu(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_layer3_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int entry_method_root_layer3_forwarding(struct dmctx *ctx);
#endif

View file

@ -4,23 +4,37 @@
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
* Copyright (C) 2012-2016 PIVA SOFTWARE (www.pivasoftware.com)
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
*/
#include <ctype.h>
#include <uci.h>
#include <stdio.h>
#include "cwmp.h"
#include "diagnostic.h"
#include "ubus.h"
#include "dmcwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcommon.h"
#include "uploaddiagnostic.h"
DMLEAF tUploadDiagnosticsParam[] = {
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_upload_diagnostics_state, set_upload_diagnostics_state, NULL, NULL},
{"UploadURL", &DMWRITE, DMT_STRING, get_upload_diagnostics_url, set_upload_diagnostics_url, NULL, NULL},
{"TestFileLength", &DMWRITE, DMT_UNINT, get_upload_diagnostic_test_file_length, set_upload_diagnostic_test_file_length, NULL, NULL},
{"EthernetPriority", &DMWRITE, DMT_UNINT, get_upload_diagnostics_ethernet_priority, set_upload_diagnostics_ethernet_priority, NULL, NULL},
{"ROMTime", &DMREAD, DMT_TIME, get_upload_diagnostic_romtime, NULL, NULL, NULL},
{"BOMTime", &DMREAD, DMT_TIME, get_upload_diagnostic_bomtime, NULL, NULL, NULL},
{"EOMTime", &DMREAD, DMT_TIME, get_upload_diagnostic_eomtime, NULL, NULL, NULL},
{"TotalBytesSent", &DMREAD, DMT_UNINT, get_upload_diagnostic_totalbytes, NULL, NULL, NULL},
{"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_upload_diagnostic_tcp_open_request_time, NULL, NULL, NULL},
{"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_upload_diagnostic_tcp_open_response_time, NULL, NULL, NULL},
//{"DSCP", &DMWRITE, DMT_UNINT, get_upload_diagnostics_dscp, set_upload_diagnostics_dscp, NULL, NULL},
//{"Interface", &DMWRITE, DMT_UNINT, get_upload_diagnostics_interface, set_upload_diagnostics_interface, NULL, NULL},
{0}
};
static inline char *upload_diagnostic_get(char *option, char *def)
{
char *tmp;
@ -30,13 +44,13 @@ static inline char *upload_diagnostic_get(char *option, char *def)
else
return tmp;
}
int get_upload_diagnostics_state(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = upload_diagnostic_get("DiagnosticState", "None");
return 0;
}
int set_upload_diagnostics_state(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upload_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -46,7 +60,7 @@ int set_upload_diagnostics_state(char *refparam, struct dmctx *ctx, int action,
case VALUESET:
if (strcmp(value, "Requested") == 0) {
UPLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp);
@ -59,13 +73,13 @@ int set_upload_diagnostics_state(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "interface", value);
return 0;
}
int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -74,7 +88,7 @@ int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, int acti
return 0;
case VALUESET:
UPLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp);
@ -85,14 +99,14 @@ int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, int acti
return 0;
}
int get_upload_diagnostics_url(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "url", value);
return 0;
}
int set_upload_diagnostics_url(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upload_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -101,7 +115,7 @@ int set_upload_diagnostics_url(char *refparam, struct dmctx *ctx, int action, ch
return 0;
case VALUESET:
UPLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp);
@ -112,13 +126,13 @@ int set_upload_diagnostics_url(char *refparam, struct dmctx *ctx, int action, ch
return 0;
}
int get_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
return 0;
}
int set_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -128,7 +142,7 @@ int set_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx,
return 0;
case VALUESET:
UPLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp);
@ -139,7 +153,7 @@ int set_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx,
return 0;
}
int get_upload_diagnostic_romtime(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_romtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "ROMtime", value);
@ -148,7 +162,7 @@ int get_upload_diagnostic_romtime(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int get_upload_diagnostic_bomtime(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_bomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "BOMtime", value);
@ -157,7 +171,7 @@ int get_upload_diagnostic_bomtime(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int get_upload_diagnostic_eomtime(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_eomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "EOMtime", value);
@ -166,7 +180,7 @@ int get_upload_diagnostic_eomtime(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int get_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "TestFileLength", value);
@ -175,7 +189,7 @@ int get_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, ch
return 0;
}
int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, int action, char *value)
int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -185,7 +199,7 @@ int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, in
return 0;
case VALUESET:
UPLOAD_DIAGNOSTIC_STOP
curr_section = dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION);
if(!curr_section)
{
dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp);
@ -196,7 +210,7 @@ int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, in
return 0;
}
int get_upload_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "TotalBytesSent", value);
@ -205,7 +219,7 @@ int get_upload_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int get_upload_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "TCPOpenRequestTime", value);
@ -214,7 +228,7 @@ int get_upload_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ct
return 0;
}
int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "TCPOpenResponseTime", value);
@ -223,23 +237,3 @@ int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *c
return 0;
}
int entry_method_root_Upload_Diagnostics(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"UploadDiagnostics.") {
DMOBJECT(DMROOT"UploadDiagnostics.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("DiagnosticsState", ctx, "1", get_upload_diagnostics_state, set_upload_diagnostics_state, NULL, 0, 1, UNDEF, NULL);
//DMPARAM("Interface", ctx, "1", get_upload_diagnostics_interface, set_upload_diagnostics_interface, NULL, 0, 1, UNDEF, NULL); //TODO
DMPARAM("UploadURL", ctx, "1", get_upload_diagnostics_url, set_upload_diagnostics_url, NULL, 0, 1, UNDEF, NULL);
DMPARAM("TestFileLength", ctx, "1", get_upload_diagnostic_test_file_length, set_upload_diagnostic_test_file_length, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
//DMPARAM("DSCP", ctx, "1", get_upload_diagnostics_dscp, set_upload_diagnostics_dscp, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("EthernetPriority", ctx, "1", get_upload_diagnostics_ethernet_priority, set_upload_diagnostics_ethernet_priority, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("ROMTime", ctx, "0", get_upload_diagnostic_romtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("BOMTime", ctx, "0", get_upload_diagnostic_bomtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("EOMTime", ctx, "0", get_upload_diagnostic_eomtime, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("TotalBytesSent", ctx, "0", get_upload_diagnostic_totalbytes, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("TCPOpenRequestTime", ctx, "0", get_upload_diagnostic_tcp_open_request_time, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
DMPARAM("TCPOpenResponseTime", ctx, "0", get_upload_diagnostic_tcp_open_response_time, NULL, "xsd:dateTime", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -10,6 +10,23 @@
#ifndef __UPLOAD_DIAGNOSTIC_H
#define __UPLOAD_DIAGNOSTIC_H
int entry_method_root_Upload_Diagnostics(struct dmctx *ctx);
extern DMLEAF tUploadDiagnosticsParam[];
static inline char *upload_diagnostic_get(char *option, char *def);
int get_upload_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upload_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upload_diagnostics_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_upload_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upload_diagnostics_url(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upload_diagnostics_ethernet_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_upload_diagnostic_romtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upload_diagnostic_bomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upload_diagnostic_eomtime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_upload_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upload_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

File diff suppressed because it is too large Load diff

View file

@ -14,27 +14,130 @@
#include <libubox/blobmsg_json.h>
#include <json-c/json.h>
struct wancprotoargs
{
struct uci_section *wancprotosection;
struct uci_ptr *ptr;
};
struct wancdevargs
{
struct uci_section *wandevsection;
int index;
char *fwan;
char *iwan;
char *wan_ifname;
};
struct wanargs
{
/* WANDevice */
struct uci_section *wandevsection;
int instance;
char *fdev;
/* WANConnectionDevice */
struct uci_section *wancdsection;
char *fwan;
char *iwan;
char *wan_ifname;
/* WAN###Connection */
struct uci_section *wancprotosection;
};
int entry_method_root_WANDevice(struct dmctx *ctx);
extern struct dm_permession_s DMWANConnectionDevice;
extern struct dm_notif_s DMWANConnectionDevicenotif;
extern struct dm_forced_inform_s DMWANConnectionProtocolinform;
extern struct dm_notif_s DMWANConnectionDevicenotif;
extern DMOBJ tWANDeviceObj[];
extern DMLEAF tWANDeviceParam[];
extern DMOBJ tWANConnectionDeviceObj[];
extern DMLEAF tWANConnectionDeviceParam[];
extern DMOBJ tWANConnectionObj[];
extern DMLEAF tWANIPConnectionParam[];
extern DMLEAF tWANPPPConnectionParam[];
extern DMLEAF tWANConnectionStatsParam[];
extern DMLEAF tWANConnection_VLANParam[];
extern DMLEAF tWANDSLLinkConfigParam[];
extern DMLEAF tWANCommonInterfaceConfigParam[];
extern DMLEAF tWANDSLInterfaceConfigParam[];
extern DMOBJ tWANEthernetInterfaceConfigObj[];
extern DMLEAF tWANEthernetInterfaceConfigParam[];
extern DMLEAF tWANEthernetInterfaceConfigStatsParam[];
int browsewandeviceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
unsigned char get_wan_protocol_connection_forced_inform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
int browsewanconnectiondeviceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsewanprotocolconnectionipInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsewanprotocolconnectionpppInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_wan_wanconnectiondevice(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_wan_wanconnectiondevice(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_wan_wanipconnection(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_wan_wanipconnectiondevice(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_wan_wanpppconnection(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_wan_wanpppconnectiondevice(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
bool check_wan_is_ethernet(struct dmctx *dmctx, void *data);
bool check_wan_is_atm(struct dmctx *dmctx, void *data);
int get_wan_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_con_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_con_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_enable_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_mng_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_mng_interface_ip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_mng_interface_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_connection_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_nat_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_firewall_enabled_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_igmp_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_dns_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ppp_con_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_interface_enable_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_mng_interface_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_link_connection_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_link_connection_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_link_connection_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_link_connection_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_vpriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_ip_link_connection_layer2_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_dsl_link_config_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_dsl_link_config_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_dsl_link_config_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_wan_access_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_wan_dsl_interface_config_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_wan_dsl_interface_config_modulation_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_datapath(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_downstreamcurrrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_downstreammaxrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_downstreamattenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_downstreamnoisemargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_upstreamcurrrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_upstreammaxrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_upstreamattenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_device_dsl_upstreamnoisemargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_annexm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_mac(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wan_eth_intf_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_protocol_connection_linker(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_wan_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_con_dev_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_con_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_enable_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_connection_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_nat_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_firewall_enabled_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_igmp_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_dns_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_connection_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ppp_con_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_interface_enable_wanproto(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_device_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_device_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_vpriority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_ip_link_connection_layer2_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_dsl_link_config_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_dsl_link_config_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_annexm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wan_eth_intf_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -19,25 +19,37 @@
#include "x_inteno_se_wifi.h"
#include "dmjson.h"
struct sewifiargs cur_wifiargs = {0};
/*** X_INTENO_SE_Wifi. ***/
DMLEAF tsewifiParam[] = {
{"Bandsteering_Enable", &DMWRITE, DMT_BOOL, get_bandsteering_enable, set_bandsteering_enable, NULL, NULL},
{"Bandsteering_Rssi_Threshold", &DMWRITE, DMT_BOOL, get_bandsteering_rssi_threshold, set_bandsteering_rssi_threshold, NULL, NULL},
{"Bandsteering_Policy", &DMWRITE, DMT_BOOL, get_bandsteering_policy, set_bandsteering_policy, NULL, NULL},
{"Bandsteering_Bw_Util", &DMWRITE, DMT_BOOL, get_bandsteering_bw_util, set_bandsteering_bw_util, NULL, NULL},
{0}
};
inline int entry_sewifi_radio(struct dmctx *ctx);
inline int entry_sewifi_radio_instance(struct dmctx *ctx, char *wnum);
inline int init_se_wifi(struct dmctx *ctx, struct uci_section *s)
{
struct sewifiargs *args = &cur_wifiargs;
ctx->args = (void *)args;
args->sewifisection = s;
return 0;
}
DMOBJ tsewifiObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Radio", &DMREAD, NULL, NULL, NULL, browsesewifiradioInst, NULL, NULL, NULL, tsewifiradioParam, NULL},
{0}
};
int get_bandsteering_enable(char *refparam, struct dmctx *ctx, char **value)
/*** X_INTENO_SE_Wifi.Radio.{i}. ***/
DMLEAF tsewifiradioParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_radio_alias, set_radio_alias, NULL, NULL},
{"Frequency", &DMREAD, DMT_STRING, get_wifi_frequency, NULL, NULL, NULL},
{"MaxAssociations", &DMWRITE, DMT_STRING, get_wifi_maxassoc, set_wifi_maxassoc, NULL, NULL},
{"DFSEnable", &DMWRITE, DMT_BOOL, get_wifi_dfsenable, set_wifi_dfsenable, NULL, NULL},
{0}
};
int get_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("wireless", "bandsteering", "enabled", value);
return 0;
}
int set_bandsteering_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
@ -59,74 +71,74 @@ int set_bandsteering_enable(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, char **value)
int get_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("wireless", "bandsteering", "rssi_threshold", value);
return 0;
dmuci_get_option_value_string("wireless", "bandsteering", "rssi_threshold", value);
return 0;
}
int set_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, int action, char *value)
int set_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (value == NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "rssi_threshold", value);
return 0;
}
return 0;
switch (action) {
case VALUECHECK:
if (value == NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "rssi_threshold", value);
return 0;
}
return 0;
}
int get_bandsteering_policy(char *refparam, struct dmctx *ctx, char **value)
int get_bandsteering_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("wireless", "bandsteering", "policy", value);
return 0;
dmuci_get_option_value_string("wireless", "bandsteering", "policy", value);
return 0;
}
int set_bandsteering_policy(char *refparam, struct dmctx *ctx, int action, char *value)
int set_bandsteering_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
if (value == NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "policy", value);
return 0;
}
return 0;
switch (action) {
case VALUECHECK:
if (value == NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "policy", value);
return 0;
}
return 0;
}
int get_bandsteering_bw_util(char *refparam, struct dmctx *ctx, char **value)
int get_bandsteering_bw_util(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("wireless", "bandsteering", "bw_util", value);
return 0;
dmuci_get_option_value_string("wireless", "bandsteering", "bw_util", value);
return 0;
}
int set_bandsteering_bw_util(char *refparam, struct dmctx *ctx, int action, char *value)
int set_bandsteering_bw_util(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
bool b;
switch (action) {
case VALUECHECK:
if (value==NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "bw_util", value);
return 0;
}
return 0;
switch (action) {
case VALUECHECK:
if (value==NULL)
return FAULT_9007;
return 0;
case VALUESET:
dmuci_set_value("wireless", "bandsteering", "bw_util", value);
return 0;
}
return 0;
}
int get_wifi_frequency(char *refparam, struct dmctx *ctx, char **value)
int get_wifi_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *freq;
json_object *res;
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
char *wlan_name = section_name(wifiargs->sewifisection);
struct uci_section *sewifisection = (struct uci_section *)data;
char *wlan_name = section_name(sewifisection);
dmubus_call("router.wireless", "status", UBUS_ARGS{{"vif", wlan_name, String}}, 1, &res);
DM_ASSERT(res, *value = "");
@ -135,50 +147,50 @@ int get_wifi_frequency(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_wifi_maxassoc(char *refparam, struct dmctx *ctx, char **value)
int get_wifi_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
struct uci_section *sewifisection = (struct uci_section *)data;
dmuci_get_value_by_section_string(wifiargs->sewifisection, "maxassoc", value);
dmuci_get_value_by_section_string(sewifisection, "maxassoc", value);
return 0;
}
int set_wifi_maxassoc(char *refparam, struct dmctx *ctx, int action, char *value)
int set_wifi_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
struct uci_section *sewifisection = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(wifiargs->sewifisection, "maxassoc", value);
dmuci_set_value_by_section(sewifisection, "maxassoc", value);
return 0;
}
return 0;
}
int get_wifi_dfsenable(char *refparam, struct dmctx *ctx, char **value)
int get_wifi_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *val;
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
char *wlan_name = section_name(wifiargs->sewifisection);
struct uci_section *sewifisection = (struct uci_section *)data;
char *wlan_name = section_name(sewifisection);
*value = "";
dmuci_get_value_by_section_string(wifiargs->sewifisection, "band", &val);
dmuci_get_value_by_section_string(sewifisection, "band", &val);
if (val[0] == 'a') {
dmuci_get_value_by_section_string(wifiargs->sewifisection, "dfsc", value);
dmuci_get_value_by_section_string(sewifisection, "dfsc", value);
if ((*value)[0] == '\0')
*value = "0";
}
return 0;
}
int set_wifi_dfsenable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_wifi_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *val;
struct sewifiargs *wifiargs = (struct sewifiargs *)ctx->args;
char *wlan_name = section_name(wifiargs->sewifisection);
struct uci_section *sewifisection = (struct uci_section *)data;
char *wlan_name = section_name(sewifisection);
switch (action) {
case VALUECHECK:
@ -186,13 +198,13 @@ int set_wifi_dfsenable(char *refparam, struct dmctx *ctx, int action, char *valu
return FAULT_9007;
return 0;
case VALUESET:
dmuci_get_value_by_section_string(wifiargs->sewifisection, "band", &val);
dmuci_get_value_by_section_string(sewifisection, "band", &val);
if (val[0] == 'a') {
string_to_bool(value, &b);
if (b)
dmuci_set_value_by_section(wifiargs->sewifisection, "dfsc", "1");
dmuci_set_value_by_section(sewifisection, "dfsc", "1");
else
dmuci_set_value_by_section(wifiargs->sewifisection, "dfsc", "0");
dmuci_set_value_by_section(sewifisection, "dfsc", "0");
}
return 0;
}
@ -200,61 +212,34 @@ int set_wifi_dfsenable(char *refparam, struct dmctx *ctx, int action, char *valu
}
////////////////////////SET AND GET ALIAS/////////////////////////////////
int get_radio_alias(char *refparam, struct dmctx *ctx, char **value)
int get_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_wifiargs.sewifisection, "radioalias", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "radioalias", value);
return 0;
}
int set_radio_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_wifiargs.sewifisection, "radioalias", value);
dmuci_set_value_by_section((struct uci_section *)data, "radioalias", value);
return 0;
}
return 0;
}
/////////////SUB ENTRIES///////////////
inline int entry_sewifi_radio(struct dmctx *ctx)
int browsesewifiradioInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *wnum = NULL, *wnum_last = NULL;
struct uci_section *s = NULL;
uci_foreach_sections("wireless", "wifi-device", s) {
init_se_wifi(ctx, s);
wnum = handle_update_instance(1, ctx, &wnum_last, update_instance_alias, 3, s, "radioinstance", "radioalias");
SUBENTRY(entry_sewifi_radio_instance, ctx, wnum);
wnum = handle_update_instance(1, dmctx, &wnum_last, update_instance_alias, 3, s, "radioinstance", "radioalias");
//SUBENTRY(entry_sewifi_radio_instance, ctx, wnum);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, wnum) == DM_STOP)
break;
}
return 0;
}
//////////////////////////////////////
int entry_method_root_SE_Wifi(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Wifi.") {
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("Bandsteering_Enable", ctx, "1", get_bandsteering_enable, set_bandsteering_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Bandsteering_Rssi_Threshold", ctx, "1", get_bandsteering_rssi_threshold, set_bandsteering_rssi_threshold, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Bandsteering_Policy", ctx, "1", get_bandsteering_policy, set_bandsteering_policy, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Bandsteering_Bw_Util", ctx, "1", get_bandsteering_bw_util, set_bandsteering_bw_util, "xsd:boolean", 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.Radio.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_sewifi_radio, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_sewifi_radio_instance(struct dmctx *ctx, char *wnum)
{
IF_MATCH(ctx, DMROOT"X_INTENO_SE_Wifi.Radio.%s.", wnum) {
DMOBJECT(DMROOT"X_INTENO_SE_Wifi.Radio.%s.", ctx, "0", 1, NULL, NULL, NULL, wnum);
DMPARAM("Alias", ctx, "1", get_radio_alias, set_radio_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Frequency", ctx, "0", get_wifi_frequency, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("MaxAssociations", ctx, "1", get_wifi_maxassoc, set_wifi_maxassoc, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DFSEnable", ctx, "1", get_wifi_dfsenable, set_wifi_dfsenable, "xsd:boolean", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -1,11 +1,28 @@
#ifndef __SE_WIFI_H
#define __SE_WIFI_H
struct sewifiargs
{
struct uci_section *sewifisection;
};
extern DMLEAF tsewifiradioParam[];
extern DMLEAF tsewifiParam[];
extern DMOBJ tsewifiObj[];
int entry_method_root_SE_Wifi(struct dmctx *ctx);
int get_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bandsteering_rssi_threshold(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bandsteering_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bandsteering_policy(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_bandsteering_bw_util(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_bandsteering_bw_util(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int browsesewifiradioInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

File diff suppressed because it is too large Load diff

View file

@ -16,11 +16,14 @@ struct bridging_args
{
struct uci_section *bridge_sec;
char *br_key;
char *ifname;
char *br_inst;
};
struct bridging_port_args
{
struct uci_section *bridge_port_sec;
struct uci_section *bridge_sec;
bool vlan;
char *ifname;
};
@ -28,12 +31,71 @@ struct bridging_port_args
struct bridging_vlan_args
{
struct uci_section *bridge_vlan_sec;
struct uci_section *bridge_sec;
char *vlan_port;
char *br_inst;
char *ifname;
};
#define BUF_SIZE 7
int entry_method_root_bridging(struct dmctx *ctx);
extern DMOBJ tBridgingObj[];
extern DMOBJ tDridgingBridgeObj[];
extern DMLEAF tDridgingBridgeParams[];
extern DMLEAF tBridgeVlanParams[];
extern DMLEAF tBridgePortParams[];
extern DMLEAF tBridgeVlanPortParams[];
extern DMOBJ tBridgePortObj[];
extern DMLEAF tBridgePortStatParams[];
int browseBridgeVlanPortInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgeVlanInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgePortInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseBridgeInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_bridge(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_bridge(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_br_vlan(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_br_port(char *refparam, struct dmctx *ctx, void *data, char **instance);
int delete_br_port(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_management(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_port_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlan_port_vlan_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_br_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_associated_interfaces(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_vlan_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_vlan_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_vlan_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_vlan_priority(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_br_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_linker_br_port(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_linker_br_vlan(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -17,43 +17,101 @@
#include "dmcwmp.h"
#include "dmcommon.h"
#include "dhcp.h"
#include "dmjson.h"
#define DELIMITOR ","
struct dhcp_args cur_dhcp_args = {0};
struct client_args cur_dhcp_client_args = {0};
struct dhcp_static_args cur_dhcp_staticargs = {0};
/*** DHCPv4. ***/
DMOBJ tDhcpv4Obj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf, linker*/
{"Server", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDhcpv4ServerObj, NULL, NULL},
{0}
};
/*** DHCPv4.Server. ***/
DMOBJ tDhcpv4ServerObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf, linker*/
{"Pool", &DMWRITE, add_dhcp_server, delete_dhcp_server, NULL, browseDhcpInst, NULL, NULL, tDhcpServerPoolObj, tDhcpServerPoolParams, NULL},
{0}
};
/*** DHCPv4.Server.Pool.{i}. ***/
DMOBJ tDhcpServerPoolObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf, linker*/
{"StaticAddress", &DMWRITE, add_dhcp_staticaddress, delete_dhcp_staticaddress, NULL, browseDhcpStaticInst, NULL, NULL, NULL, tDhcpServerPoolAddressParams, NULL},
{"Client", &DMREAD, NULL, NULL, NULL, browseDhcpClientInst, NULL, NULL, NULL, tDhcpServerPoolClientParams, get_dhcp_client_linker},
{0}
};
DMLEAF tDhcpServerPoolParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"DNSServers", &DMWRITE, DMT_STRING, get_dns_server, set_dns_server, NULL, NULL},
{"X_INTENO_SE_DHCPServerConfigurable", &DMWRITE, DMT_BOOL, get_dhcp_configurable, set_dhcp_configurable, NULL, NULL},
{"Enable", &DMWRITE, DMT_BOOL, get_dhcp_enable, set_dhcp_enable, NULL, NULL},
{"MinAddress", &DMWRITE, DMT_STRING, get_dhcp_interval_address_min, set_dhcp_address_min, NULL, NULL},
{"MaxAddress", &DMWRITE, DMT_STRING,get_dhcp_interval_address_max, set_dhcp_address_max, NULL, NULL},
{"ReservedAddresses", &DMWRITE, DMT_STRING, get_dhcp_reserved_addresses, set_dhcp_reserved_addresses, NULL, NULL},
{"SubnetMask", &DMWRITE, DMT_STRING,get_dhcp_subnetmask, set_dhcp_subnetmask, NULL, NULL},
{"IPRouters", &DMWRITE, DMT_STRING, get_dhcp_iprouters, set_dhcp_iprouters, NULL, NULL},
{"LeaseTime", &DMWRITE, DMT_STRING, get_dhcp_leasetime, set_dhcp_leasetime, NULL, NULL},
{"DomainName", &DMWRITE, DMT_STRING, get_dhcp_domainname, set_dhcp_domainname, NULL, NULL},
{"Interface", &DMWRITE, DMT_STRING, get_dhcp_interface, set_dhcp_interface_linker_parameter, NULL, NULL},
{0}
};
/*** DHCPv4.Server.Pool.{i}.StaticAddress.{i}. ***/
DMLEAF tDhcpServerPoolAddressParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Alias", &DMWRITE, DMT_STRING, get_dhcp_static_alias, set_dhcp_static_alias, NULL, NULL},
{"Chaddr", &DMWRITE, DMT_STRING, get_dhcp_staticaddress_chaddr, set_dhcp_staticaddress_chaddr, NULL, NULL},
{"Yiaddr", &DMWRITE, DMT_STRING, get_dhcp_staticaddress_yiaddr, set_dhcp_staticaddress_yiaddr, NULL, NULL},
{0}
};
/*** DHCPv4.Server.Pool.{i}.Client.{i}. ***/
DMLEAF tDhcpServerPoolClientParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Chaddr", &DMREAD, DMT_STRING, get_dhcp_client_chaddr, NULL, NULL, NULL},
{0}
};
/**************************************************************************
* LINKER
***************************************************************************/
int get_dhcp_client_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if (((struct client_args *)data)->key) {
*linker = ((struct client_args *)data)->key;
return 0;
} else {
*linker = "";
return 0;
}
}
/*************************************************************
* INIT
/*************************************************************/
inline int init_dhcp_args(struct dmctx *ctx, struct uci_section *s, char *interface)
inline int init_dhcp_args(struct dhcp_args *args, struct uci_section *s, char *interface)
{
struct dhcp_args *args = &cur_dhcp_args;
ctx->args = (void *)args;
args->interface = interface;
args->dhcp_sec = s;
return 0;
}
inline int init_args_dhcp_host(struct dmctx *ctx, struct uci_section *s)
inline int init_args_dhcp_host(struct dhcp_static_args *args, struct uci_section *s)
{
struct dhcp_static_args *args = &cur_dhcp_staticargs;
ctx->args = (void *)args;
args->dhcpsection = s;
return 0;
}
inline int init_dhcp_client_args(struct dmctx *ctx, json_object *client)
inline int init_dhcp_client_args(struct client_args *args, json_object *client, char *key)
{
struct client_args *args = &cur_dhcp_client_args;
ctx->args = (void *)args;
args->client = client;
args->key = key;
return 0;
}
/*******************ADD-DEL OBJECT*********************/
int add_dhcp_server(struct dmctx *ctx, char **instancepara)
int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
@ -68,86 +126,87 @@ int add_dhcp_server(struct dmctx *ctx, char **instancepara)
return 0;
}
int delete_dhcp_server(struct dmctx *ctx)
{
dmuci_delete_by_section(cur_dhcp_args.dhcp_sec, NULL, NULL);
return 0;
}
int delete_dhcp_server_all(struct dmctx *ctx)
int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
char *lan_name;
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
uci_foreach_sections("dhcp", "dhcp", s) {
if (found != 0)
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(((struct dhcp_args *)data)->dhcp_sec, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_sections("dhcp", "dhcp", s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
break;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
return 0;
}
int add_dhcp_staticaddress(struct dmctx *ctx, char **instancepara)
int add_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *value;
char *instance;
struct uci_section *s = NULL;
instance = get_last_instance_lev2("dhcp", "host", "ldhcpinstance", "interface", cur_dhcp_args.interface);
instance = get_last_instance_lev2("dhcp", "host", "ldhcpinstance", "interface", ((struct dhcp_args *)data)->interface);
dmuci_add_section("dhcp", "host", &s, &value);
dmuci_set_value_by_section(s, "mac", DHCPSTATICADDRESS_DISABLED_CHADDR);
dmuci_set_value_by_section(s, "interface", cur_dhcp_args.interface);
dmuci_set_value_by_section(s, "interface", ((struct dhcp_args *)data)->interface);
*instancepara = update_instance(s, instance, "ldhcpinstance");
return 0;
}
int delete_dhcp_staticaddress_all(struct dmctx *ctx)
int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
int found = 0;
char *lan_name;
struct uci_section *s = NULL;
struct uci_section *ss = NULL;
uci_foreach_option_eq("dhcp", "host", "interface", cur_dhcp_args.interface, s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
return 0;
}
int delete_dhcp_staticaddress(struct dmctx *ctx)
{
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)ctx->args;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
dmuci_delete_by_section(dhcpargs->dhcpsection, NULL, NULL);
switch (del_action) {
case DEL_INST:
dmuci_delete_by_section(dhcpargs->dhcpsection, NULL, NULL);
break;
case DEL_ALL:
uci_foreach_option_eq("dhcp", "host", "interface", ((struct dhcp_args *)data)->interface, s) {
if (found != 0)
dmuci_delete_by_section(ss, NULL, NULL);
ss = s;
found++;
}
if (ss != NULL)
dmuci_delete_by_section(ss, NULL, NULL);
break;
}
return 0;
}
/*************************************************************
* GET & SET PARAM
/*************************************************************/
int get_dns_server(char *refparam, struct dmctx *ctx, char **value)
int get_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
int len;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if(res)
{
*value = dmjson_get_value_array_all(res, DELIMITOR, 1, "dns-server");
}
}
else
*value = "";
if ((*value)[0] == '\0') {
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "dns", value);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "dns", value);
*value = dmstrdup(*value); // MEM WILL BE FREED IN DMMEMCLEAN
char *p = *value;
while (*p) {
@ -160,7 +219,7 @@ int get_dns_server(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dns_server(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *dup, *p;
@ -176,18 +235,18 @@ int set_dns_server(char *refparam, struct dmctx *ctx, int action, char *value)
else
p++;
}
dmuci_set_value("network", cur_dhcp_args.interface, "dns", dup);
dmuci_set_value("network", ((struct dhcp_args *)data)->interface, "dns", dup);
dmfree(dup);
return 0;
}
return 0;
}
int get_dhcp_configurable(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
*value = "1";
return 0;
}
@ -195,7 +254,7 @@ int get_dhcp_configurable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_configurable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *s = NULL;
@ -207,29 +266,29 @@ int set_dhcp_configurable(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
case VALUESET:
string_to_bool(value, &b);
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
if (!b) {
dmuci_delete_by_section(s, NULL, NULL);
}
break;
}
if (s == NULL && b) {
dmuci_set_value("dhcp",cur_dhcp_args.interface, NULL, "dhcp");
dmuci_set_value("dhcp", cur_dhcp_args.interface, "interface", cur_dhcp_args.interface);
dmuci_set_value("dhcp", cur_dhcp_args.interface, "start", "100");
dmuci_set_value("dhcp", cur_dhcp_args.interface, "limit", "150");
dmuci_set_value("dhcp", cur_dhcp_args.interface, "leasetime", "12h");
dmuci_set_value("dhcp",((struct dhcp_args *)data)->interface, NULL, "dhcp");
dmuci_set_value("dhcp", ((struct dhcp_args *)data)->interface, "interface", ((struct dhcp_args *)data)->interface);
dmuci_set_value("dhcp", ((struct dhcp_args *)data)->interface, "start", "100");
dmuci_set_value("dhcp", ((struct dhcp_args *)data)->interface, "limit", "150");
dmuci_set_value("dhcp", ((struct dhcp_args *)data)->interface, "leasetime", "12h");
}
return 0;
}
return 0;
}
int get_dhcp_enable(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s = NULL;
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "ignore", value);
if ((*value)[0] == '\0')
*value = "1";
@ -241,7 +300,7 @@ int get_dhcp_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
struct uci_section *s = NULL;
@ -253,7 +312,7 @@ int set_dhcp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
case VALUESET:
string_to_bool(value, &b);
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
if (b)
dmuci_set_value_by_section(s, "ignore", "");
else
@ -270,7 +329,7 @@ enum enum_lanip_interval_address {
LANIP_INTERVAL_END
};
int get_dhcp_interval_address(struct dmctx *ctx, char **value, int option)
int get_dhcp_interval_address(struct dmctx *ctx, void *data, char *instance, char **value, int option)
{
json_object *res, *jobj;
char *ipaddr = "" , *mask = "", *start , *limit;
@ -279,7 +338,7 @@ int get_dhcp_interval_address(struct dmctx *ctx, char **value, int option)
*value = "";
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "start", &start);
if (option == LANIP_INTERVAL_END)
dmuci_get_value_by_section_string(s, "limit", &limit);
@ -288,9 +347,9 @@ int get_dhcp_interval_address(struct dmctx *ctx, char **value, int option)
if (s == NULL) {
return 0;
}
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "ipaddr", &ipaddr);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "ipaddr", &ipaddr);
if (ipaddr[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res)
{
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
@ -300,9 +359,9 @@ int get_dhcp_interval_address(struct dmctx *ctx, char **value, int option)
if (ipaddr[0] == '\0') {
return 0;
}
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "netmask", &mask);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "netmask", &mask);
if (mask[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
mask = dmjson_get_value(jobj, 1, "mask");
@ -325,19 +384,19 @@ int get_dhcp_interval_address(struct dmctx *ctx, char **value, int option)
}
return 0;
}
int get_dhcp_interval_address_min(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_interval_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
get_dhcp_interval_address(ctx, value, LANIP_INTERVAL_START);
get_dhcp_interval_address(ctx, data, instance, value, LANIP_INTERVAL_START);
return 0;
}
int get_dhcp_interval_address_max(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_interval_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
get_dhcp_interval_address(ctx, value, LANIP_INTERVAL_END);
get_dhcp_interval_address(ctx, data, instance, value, LANIP_INTERVAL_END);
return 0;
}
int set_dhcp_address_min(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
json_object *res, *jobj;
char *ipaddr = "", *mask = "", *start , *limit, buf[16];
@ -347,9 +406,9 @@ int set_dhcp_address_min(char *refparam, struct dmctx *ctx, int action, char *va
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "ipaddr", &ipaddr);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "ipaddr", &ipaddr);
if (ipaddr[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
ipaddr = dmjson_get_value(jobj, 1, "address");
@ -358,9 +417,9 @@ int set_dhcp_address_min(char *refparam, struct dmctx *ctx, int action, char *va
if (ipaddr[0] == '\0')
return 0;
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "netmask", &mask);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "netmask", &mask);
if (mask[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
mask = dmjson_get_value(jobj, 1, "mask");
@ -373,7 +432,7 @@ int set_dhcp_address_min(char *refparam, struct dmctx *ctx, int action, char *va
mask = "255.255.255.0";
ipcalc_rev_start(ipaddr, mask, value, buf);
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_set_value_by_section(s, "start", buf);
break;
}
@ -383,7 +442,7 @@ int set_dhcp_address_min(char *refparam, struct dmctx *ctx, int action, char *va
return 0;
}
int set_dhcp_address_max(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
int i_val;
json_object *res, *jobj;
@ -394,15 +453,15 @@ int set_dhcp_address_max(char *refparam, struct dmctx *ctx, int action, char *va
case VALUECHECK:
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "start", &start);
break;
}
if (!s) return 0;
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "ipaddr", &ipaddr);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "ipaddr", &ipaddr);
if (ipaddr[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
ipaddr = dmjson_get_value(jobj, 1, "address"); }
@ -410,9 +469,9 @@ int set_dhcp_address_max(char *refparam, struct dmctx *ctx, int action, char *va
if (ipaddr[0] == '\0')
return 0;
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "netmask", &mask);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "netmask", &mask);
if (mask[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
if (res) {
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
mask = dmjson_get_value(jobj, 1, "mask");
@ -432,7 +491,7 @@ int set_dhcp_address_max(char *refparam, struct dmctx *ctx, int action, char *va
}
int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char val[512] = {0}, *p;
struct uci_section *s = NULL;
@ -440,8 +499,8 @@ int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, char **value)
unsigned int n_min, n_max, n_ip;
*value = "";
get_dhcp_interval_address(ctx, &min, LANIP_INTERVAL_START);
get_dhcp_interval_address(ctx, &max, LANIP_INTERVAL_END);
get_dhcp_interval_address(ctx, data, instance, &min, LANIP_INTERVAL_START);
get_dhcp_interval_address(ctx, data, instance, &max, LANIP_INTERVAL_END);
if (min[0] == '\0' || max[0] == '\0')
return 0;
n_min = inet_network(min);
@ -463,7 +522,7 @@ int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *s = NULL;
struct uci_section *dhcp_section = NULL;
@ -475,8 +534,8 @@ int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, int action, c
case VALUECHECK:
return 0;
case VALUESET:
get_dhcp_interval_address(ctx, &min, LANIP_INTERVAL_START);
get_dhcp_interval_address(ctx, &max, LANIP_INTERVAL_END);
get_dhcp_interval_address(ctx, data, instance, &min, LANIP_INTERVAL_START);
get_dhcp_interval_address(ctx, data, instance, &max, LANIP_INTERVAL_END);
n_min = inet_network(min);
n_max = inet_network(max);
local_value = dmstrdup(value);
@ -493,7 +552,7 @@ int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, int action, c
else {
dmuci_add_section("dhcp", "host", &dhcp_section, &val);
dmuci_set_value_by_section(dhcp_section, "mac", DHCPSTATICADDRESS_DISABLED_CHADDR);
dmuci_set_value_by_section(dhcp_section, "interface", cur_dhcp_args.interface);
dmuci_set_value_by_section(dhcp_section, "interface", ((struct dhcp_args *)data)->interface);
dmuci_set_value_by_section(dhcp_section, "ip", pch);
}
}
@ -509,7 +568,7 @@ int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, int action, c
return 0;
}
int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mask;
json_object *res, *jobj;
@ -517,14 +576,14 @@ int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, char **value)
char *val;
*value = "";
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "netmask", value);
break;
}
if (s == NULL || (*value)[0] == '\0')
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "netmask", value);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "netmask", value);
if ((*value)[0] == '\0') {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", cur_dhcp_args.interface, String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", ((struct dhcp_args *)data)->interface, String}}, 1, &res);
DM_ASSERT(res, *value = "");
jobj = dmjson_select_obj_in_array_idx(res, 0, 1, "ipv4-address");
mask = dmjson_get_value(jobj, 1, "mask");
@ -535,7 +594,7 @@ int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *s = NULL;
@ -543,7 +602,7 @@ int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, int action, char *val
case VALUECHECK:
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_set_value_by_section(s, "netmask", value);
return 0;
}
@ -552,36 +611,35 @@ int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_dhcp_iprouters(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "gateway", value);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "gateway", value);
if ((*value)[0] == '\0') {
dmuci_get_option_value_string("network", cur_dhcp_args.interface, "ipaddr", value);
dmuci_get_option_value_string("network", ((struct dhcp_args *)data)->interface, "ipaddr", value);
}
return 0;
}
int set_dhcp_iprouters(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct ldlanargs *lanargs = (struct ldlanargs *)ctx->args;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value("network", cur_dhcp_args.interface, "gateway", value);
dmuci_set_value("network", ((struct dhcp_args *)data)->interface, "gateway", value);
return 0;
}
return 0;
}
int get_dhcp_leasetime(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int len, mtime = 0;
char *ltime = "", *pch, *spch, *ltime_ini, *tmp, *tmp_ini;
struct uci_section *s = NULL;
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_string(s, "leasetime", &ltime);
break;
}
@ -642,7 +700,7 @@ int get_dhcp_leasetime(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct uci_section *s = NULL;
char buf[32];
@ -651,7 +709,7 @@ int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, int action, char *valu
case VALUECHECK:
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
int val = atoi(value);
sprintf(buf, "%ds", val);
dmuci_set_value_by_section(s, "leasetime", buf);
@ -662,18 +720,18 @@ int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, int action, char *valu
return 0;
}
int get_dhcp_interface(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
linker = dmstrdup(cur_dhcp_args.interface);
adm_entry_get_linker_param(DMROOT"IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
linker = dmstrdup(((struct dhcp_args *)data)->interface);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
dmfree(linker);
return 0;
}
int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
@ -681,9 +739,9 @@ int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, int a
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
dmuci_set_value_by_section(cur_dhcp_args.dhcp_sec, "interface", linker);
dmuci_set_value_by_section(((struct dhcp_args *)data)->dhcp_sec, "interface", linker);
dmfree(linker);
}
return 0;
@ -691,7 +749,7 @@ int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, int a
return 0;
}
int get_dhcp_domainname(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *result, *str;
struct uci_list *val;
@ -699,12 +757,12 @@ int get_dhcp_domainname(char *refparam, struct dmctx *ctx, char **value)
struct uci_section *s = NULL;
*value = "";
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_list(s, "dhcp_option", &val);
if (val) {
uci_foreach_element(val, e)
{
if (str = strstr(e->name, "15,")) {
if ((str = strstr(e->name, "15,"))) {
*value = dmstrdup(str + sizeof("15,") - 1); //MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
@ -714,7 +772,7 @@ int get_dhcp_domainname(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_dhcp_domainname(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *result, *dn, *pch;
struct uci_list *val;
@ -726,7 +784,7 @@ int set_dhcp_domainname(char *refparam, struct dmctx *ctx, int action, char *val
case VALUECHECK:
return 0;
case VALUESET:
uci_foreach_option_eq("dhcp", "dhcp", "interface", cur_dhcp_args.interface, s) {
uci_foreach_option_eq("dhcp", "dhcp", "interface", ((struct dhcp_args *)data)->interface, s) {
dmuci_get_value_by_section_list(s, option, &val);
if (val) {
uci_foreach_element_safe(val, e, tmp)
@ -742,32 +800,32 @@ int set_dhcp_domainname(char *refparam, struct dmctx *ctx, int action, char *val
}
end:
sprintf(buf, "15,%s", value);
dmuci_add_list_value_by_section(cur_dhcp_args.dhcp_sec, "dhcp_option", buf);
dmuci_add_list_value_by_section(((struct dhcp_args *)data)->dhcp_sec, "dhcp_option", buf);
return 0;
}
int get_dhcp_static_alias(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_dhcp_staticargs.dhcpsection, "ldhcpalias", value);
dmuci_get_value_by_section_string(((struct dhcp_static_args *)data)->dhcpsection, "ldhcpalias", value);
return 0;
}
int set_dhcp_static_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_dhcp_staticargs.dhcpsection, "ldhcpalias", value);
dmuci_set_value_by_section(((struct dhcp_static_args *)data)->dhcpsection, "ldhcpalias", value);
return 0;
}
return 0;
}
int get_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *chaddr;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)ctx->args;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
dmuci_get_value_by_section_string(dhcpargs->dhcpsection, "mac", &chaddr);
if (strcmp(chaddr, DHCPSTATICADDRESS_DISABLED_CHADDR) == 0)
@ -777,10 +835,10 @@ int get_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, char **valu
return 0;
}
int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *chaddr;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)ctx->args;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
switch (action) {
case VALUECHECK:
@ -796,17 +854,17 @@ int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)ctx->args;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
dmuci_get_value_by_section_string(dhcpargs->dhcpsection, "ip", value);
return 0;
}
int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, int action, char *value)
int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)ctx->args;
struct dhcp_static_args *dhcpargs = (struct dhcp_static_args *)data;
switch (action) {
case VALUECHECK:
@ -818,96 +876,55 @@ int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_dhcp_client_chaddr(char *refparam, struct dmctx *ctx, char **value)
int get_dhcp_client_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(cur_dhcp_client_args.client, 1, "macaddr");
*value = dmjson_get_value(((struct client_args *)data)->client, 1, "macaddr");
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_dhcp(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"DHCPv4.") {
DMOBJECT(DMROOT"DHCPv4.", ctx, "0", 0, NULL, NULL, NULL);
DMOBJECT(DMROOT"DHCPv4.Server.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"DHCPv4.Server.Pool.", ctx, "0", 1, add_dhcp_server, delete_dhcp_server_all, NULL);
SUBENTRY(entry_dhcp, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_dhcp(struct dmctx *ctx)
int browseDhcpInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s;
char *interface, *idhcp = NULL, *idhcp_last = NULL;
struct dhcp_args curr_dhcp_args = {0};
uci_foreach_sections("dhcp","dhcp", s) {
dmuci_get_value_by_section_string(s, "interface", &interface);
init_dhcp_args(ctx, s, interface);
idhcp = handle_update_instance(1, ctx, &idhcp_last, update_instance_alias, 3, s, "dhcp_instance", "dhcp_alias");
SUBENTRY(entry_dhcp_instance, ctx, interface, idhcp);
init_dhcp_args(&curr_dhcp_args, s, interface);
idhcp = handle_update_instance(1, dmctx, &idhcp_last, update_instance_alias, 3, s, "dhcp_instance", "dhcp_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp_args, idhcp) == DM_STOP)
break;
}
return 0;
}
inline int entry_dhcp_instance(struct dmctx *ctx, char *interface, char *int_num)
{
IF_MATCH(ctx, DMROOT"DHCPv4.Server.Pool.%s.", int_num) {
DMOBJECT(DMROOT"DHCPv4.Server.Pool.%s.", ctx, "0", NULL, NULL, delete_dhcp_server, NULL, int_num);
DMPARAM("DNSServers", ctx, "1", get_dns_server, set_dns_server, NULL, 0, 1, UNDEF, NULL);
DMPARAM("X_INTENO_SE_DHCPServerConfigurable", ctx, "1", get_dhcp_configurable, set_dhcp_configurable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_dhcp_enable, set_dhcp_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("MinAddress", ctx, "1", get_dhcp_interval_address_min, set_dhcp_address_min, NULL, 0, 1, UNDEF, NULL);
DMPARAM("MaxAddress", ctx, "1", get_dhcp_interval_address_max, set_dhcp_address_max, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ReservedAddresses", ctx, "1", get_dhcp_reserved_addresses, set_dhcp_reserved_addresses, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SubnetMask", ctx, "1", get_dhcp_subnetmask, set_dhcp_subnetmask, NULL, 0, 1, UNDEF, NULL);
DMPARAM("IPRouters", ctx, "1", get_dhcp_iprouters, set_dhcp_iprouters, NULL, 0, 1, UNDEF, NULL);
DMPARAM("LeaseTime", ctx, "1", get_dhcp_leasetime, set_dhcp_leasetime, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DomainName", ctx, "1", get_dhcp_domainname, set_dhcp_domainname, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, "1", get_dhcp_interface, set_dhcp_interface_linker_parameter, NULL, 0, 1, UNDEF, NULL); // refer to IP.Interface
DMOBJECT(DMROOT"DHCPv4.Server.Pool.%s.StaticAddress.", ctx, "0", NULL, add_dhcp_staticaddress, delete_dhcp_staticaddress_all, NULL, int_num); //TODO
SUBENTRY(entry_dhcp_static_address, ctx, interface, int_num);
DMOBJECT(DMROOT"DHCPv4.Server.Pool.%s.Client.", ctx, "0", NULL, NULL, NULL, NULL, int_num); //TODO
SUBENTRY(entry_dhcp_client, ctx, interface, int_num);
return 0;
}
return FAULT_9005;
}
inline int entry_dhcp_static_address(struct dmctx *ctx, char *interface, char *idev)
int browseDhcpStaticInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *sss = NULL;
char *idhcp = NULL, *idhcp_last = NULL;
uci_foreach_option_cont("dhcp", "host", "interface", interface, sss) {
idhcp = handle_update_instance(2, ctx, &idhcp_last, update_instance_alias, 3, sss, "ldhcpinstance", "ldhcpalias");
init_args_dhcp_host(ctx, sss);
SUBENTRY(entry_dhcp_static_address_instance, ctx, idev, idhcp);
struct dhcp_static_args curr_dhcp_staticargs = {0};
uci_foreach_option_cont("dhcp", "host", "interface", ((struct dhcp_args *)prev_data)->interface, sss) {
idhcp = handle_update_instance(2, dmctx, &idhcp_last, update_instance_alias, 3, sss, "ldhcpinstance", "ldhcpalias");
init_args_dhcp_host(&curr_dhcp_staticargs, sss);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp_staticargs, idhcp) == DM_STOP)
break;
}
return 0;
}
inline int entry_dhcp_static_address_instance(struct dmctx *ctx, char *int_num, char *st_address)
{
IF_MATCH(ctx, DMROOT"DHCPv4.Server.Pool.%s.StaticAddress.%s.", int_num, st_address) {
DMOBJECT(DMROOT"DHCPv4.Server.Pool.%s.StaticAddress.%s.", ctx, "1", NULL, NULL, delete_dhcp_staticaddress, NULL, int_num, st_address);
DMPARAM("Alias", ctx, "1", get_dhcp_static_alias, set_dhcp_static_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Chaddr", ctx, "1", get_dhcp_staticaddress_chaddr, set_dhcp_staticaddress_chaddr, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Yiaddr", ctx, "1", get_dhcp_staticaddress_yiaddr, set_dhcp_staticaddress_yiaddr, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
inline int entry_dhcp_client(struct dmctx *ctx, char *interface, char *idev )
int browseDhcpClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *sss = NULL;
char *idx = NULL, *idx_last = NULL;
json_object *res = NULL, *client_obj = NULL;
char *dhcp, *network;
int id = 0;
struct client_args curr_dhcp_client_args = {0};
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_foreach(res, key, client_obj) {
@ -915,11 +932,12 @@ inline int entry_dhcp_client(struct dmctx *ctx, char *interface, char *idev )
if(strcmp(dhcp, "true") == 0)
{
network = dmjson_get_value(client_obj, 1, "network");
if(strcmp(network, interface) == 0)
if(strcmp(network, ((struct dhcp_args *)prev_data)->interface) == 0)
{
init_dhcp_client_args(ctx, client_obj);
idx = handle_update_instance(2, ctx, &idx_last, update_instance_without_section, 1, ++id);
SUBENTRY(entry_dhcp_client_instance, ctx, idev, idx, key);
init_dhcp_client_args(&curr_dhcp_client_args, client_obj, key);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_dhcp_client_args, idx) == DM_STOP)
break;
}
}
}
@ -927,15 +945,3 @@ inline int entry_dhcp_client(struct dmctx *ctx, char *interface, char *idev )
return 0;
}
inline int entry_dhcp_client_instance(struct dmctx *ctx, char *int_num, char *idx, char *key)
{
char linker[32] = "linker_dhcp:";
strcat(linker, key);
IF_MATCH(ctx, DMROOT"DHCPv4.Server.Pool.%s.Client.%s.", int_num, idx) {
DMOBJECT(DMROOT"DHCPv4.Server.Pool.%s.Client.%s.", ctx, "1", NULL, NULL, NULL, linker, int_num, idx);
DMPARAM("Chaddr", ctx, "0", get_dhcp_client_chaddr, NULL, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -11,6 +11,8 @@
#ifndef __DHCP_H
#define __DHCP_H
#include <json-c/json.h>
struct dhcp_args
{
struct uci_section *dhcp_sec;
@ -25,8 +27,56 @@ struct dhcp_static_args
struct client_args
{
json_object *client;
char *key;
};
int entry_method_root_dhcp(struct dmctx *ctx);
extern DMOBJ tDhcpv4Obj[];
extern DMOBJ tDhcpv4ServerObj[];
extern DMOBJ tDhcpServerPoolObj[];
extern DMLEAF tDhcpServerPoolParams[];
extern DMLEAF tDhcpServerPoolAddressParams[];
extern DMLEAF tDhcpServerPoolClientParams[];
int browseDhcpInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcpStaticInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDhcpClientInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_server(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_dhcp_staticaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interval_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interval_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dhcp_client_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_dns_server(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_configurable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_address_min(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_address_max(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_reserved_addresses(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_subnetmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_iprouters(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_leasetime(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_domainname(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_static_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_staticaddress_chaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_dhcp_staticaddress_yiaddr(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_dhcp_client_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -19,46 +19,98 @@
#include "ethernet.h"
#include "dmjson.h"
struct eth_port_args cur_eth_port_args = {0};
char *wan_ifname = NULL;
inline int init_eth_port(struct dmctx *ctx, struct uci_section *s, char *ifname)
/*** Ethernet. ***/
DMOBJ tEthernetObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf, linker*/
{"Interface", &DMREAD, NULL, NULL, NULL, browseEthIfaceInst, NULL, NULL, tEthernetStatObj, tEthernetParams, get_linker_val},
{0}
};
DMLEAF tEthernetParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"Alias", &DMWRITE, DMT_STRING, get_eth_port_alias, set_eth_port_alias, NULL, NULL},
{"Enable", &DMWRITE, DMT_BOOL, get_eth_port_enable, set_eth_port_enable, NULL, NULL},
{"Status", &DMREAD, DMT_STRING, get_eth_port_status, NULL, NULL, NULL},
{"MaxBitRate", &DMWRITE, DMT_STRING, get_eth_port_maxbitrate, set_eth_port_maxbitrate, NULL, NULL},
{"Name", &DMREAD, DMT_STRING, get_eth_port_name, NULL, NULL, NULL},
{"MACAddress", &DMREAD, DMT_STRING, get_eth_port_mac_address, NULL, NULL, NULL},
{"DuplexMode", &DMWRITE, DMT_STRING, get_eth_port_duplexmode, set_eth_port_duplexmode, NULL, NULL},
{0}
};
/*** Ethernet.Stats. ***/
DMOBJ tEthernetStatObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf, linker*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tEthernetStatParams, NULL},
{0}
};
DMLEAF tEthernetStatParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, NOTIFICATION, linker*/
{"BytesSent", &DMREAD, DMT_UNINT, get_eth_port_stats_tx_bytes, NULL, NULL, NULL},
{"BytesReceived", &DMREAD, DMT_UNINT, get_eth_port_stats_rx_bytes, NULL, NULL, NULL},
{"PacketsSent", &DMREAD, DMT_UNINT, get_eth_port_stats_tx_packets, NULL, NULL, NULL},
{"PacketsReceived", &DMREAD, DMT_UNINT, get_eth_port_stats_rx_packets, NULL, NULL, NULL},
{0}
};
/**************************************************************************
* LINKER
***************************************************************************/
int get_linker_val(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if (((struct eth_port_args *)data)->ifname) {
*linker = ((struct eth_port_args *)data)->ifname;
return 0;
} else {
*linker = "";
return 0;
}
}
/**************************************************************************
* INIT
***************************************************************************/
inline int init_eth_port(struct eth_port_args *args, struct uci_section *s, char *ifname)
{
struct eth_port_args *args = &cur_eth_port_args;
ctx->args = (void *)args;
args->eth_port_sec = s;
args->ifname = ifname;
return 0;
}
///////////////////SET & GET ALIAS////////////////////////////////////
int get_eth_port_alias(char *refparam, struct dmctx *ctx, char **value)
/**************************************************************************
* SET & GET ALIAS
***************************************************************************/
int get_eth_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "eth_port_alias", value);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "eth_port_alias", value);
return 0;
}
int set_eth_port_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_eth_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "eth_port_alias", value);
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "eth_port_alias", value);
return 0;
}
return 0;
}
//////////////////////////GET & SET ETH PARAM////////////////:
int get_eth_port_enable(char *refparam, struct dmctx *ctx, char **value)
/**************************************************************************
* GET & SET ETH PARAM
***************************************************************************/
int get_eth_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
char *ifname;
if (strstr(cur_eth_port_args.ifname, wan_ifname)) {
if (strstr(((struct eth_port_args *)data)->ifname, wan_ifname)) {
ifname = dmstrdup(wan_ifname);
} else
ifname = dmstrdup(cur_eth_port_args.ifname);
ifname = dmstrdup(((struct eth_port_args *)data)->ifname);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
@ -67,7 +119,7 @@ int get_eth_port_enable(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_eth_port_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_eth_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *ifname;
@ -79,10 +131,10 @@ int set_eth_port_enable(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
case VALUESET:
string_to_bool(value, &b);
if (strstr(cur_eth_port_args.ifname, wan_ifname)) {
if (strstr(((struct eth_port_args *)data)->ifname, wan_ifname)) {
ifname = dmstrdup(wan_ifname);
} else
ifname = dmstrdup(cur_eth_port_args.ifname);
ifname = dmstrdup(((struct eth_port_args *)data)->ifname);
if (b) {
DMCMD("ethctl", 3, ifname, "phy-power", "up"); //TODO wait ubus command
@ -96,11 +148,11 @@ int set_eth_port_enable(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_eth_port_status(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
bool b;
get_eth_port_enable(refparam, ctx, value);
get_eth_port_enable(refparam, ctx, data, instance, value);
string_to_bool(*value, &b);
if (b)
*value = "Up";
@ -109,11 +161,11 @@ int get_eth_port_status(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *pch, *spch, *v;
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "speed", value);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", value);
if ((*value)[0] == '\0' || strcmp(*value, "disabled") == 0 )
return 0;
else {
@ -128,7 +180,7 @@ int get_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, int action, char *value)
int set_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *val = "", *p = "";
char *duplex;
@ -138,18 +190,18 @@ int set_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, int action, char
return 0;
case VALUESET:
if (strcasecmp(value, "disabled") == 0 ) {
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "speed", "disabled");
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", "disabled");
} else if (strcasecmp(value, "auto") == 0 || strcmp(value, "-1") == 0) {
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "speed", "auto");
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", "auto");
} else {
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "speed", &duplex);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", &duplex);
if (strcmp(duplex, "auto") == 0 || strcmp(duplex, "disabled") == 0)
p = "FDAUTO";
else {
p = strchr(duplex, 'F') ? strchr(duplex, 'F') : strchr(duplex, 'H');
}
if (p) dmastrcat(&val, value, p);
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "speed", val);
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", val);
dmfree(val);
}
return 0;
@ -157,27 +209,27 @@ int set_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_eth_port_name(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "name", value);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "name", value);
return 0;
}
int get_eth_port_mac_address(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_mac_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", cur_eth_port_args.ifname, String}}, 1, &res);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 1, "macaddr");
return 0;
}
int get_eth_port_duplexmode(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *tmp, *name;
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "speed", value);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", value);
if (*value[0] == '\0') {
*value = "";
} else if (strcmp(*value, "auto") == 0) {
@ -193,7 +245,7 @@ int get_eth_port_duplexmode(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, int action, char *value)
int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *m, *spch, *rate, *val = NULL;
@ -202,10 +254,10 @@ int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, int action, char
return 0;
case VALUESET:
if (strcasecmp(value, "auto") == 0) {
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "speed", "auto");
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", "auto");
return 0;
}
dmuci_get_value_by_section_string(cur_eth_port_args.eth_port_sec, "speed", &m);
dmuci_get_value_by_section_string(((struct eth_port_args *)data)->eth_port_sec, "speed", &m);
m = dmstrdup(m);
rate = m;
if (strcmp(rate, "auto") == 0)
@ -221,7 +273,7 @@ int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, int action, char
dmfree(m);
return 0;
}
dmuci_set_value_by_section(cur_eth_port_args.eth_port_sec, "speed", val);
dmuci_set_value_by_section(((struct eth_port_args *)data)->eth_port_sec, "speed", val);
dmfree(m);
dmfree(val);
return 0;
@ -229,62 +281,55 @@ int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, int action, char
return 0;
}
int get_eth_port_stats_tx_bytes(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", cur_eth_port_args.ifname, String}}, 1, &res);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", "tx_bytes");
return 0;
}
int get_eth_port_stats_rx_bytes(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", cur_eth_port_args.ifname, String}}, 1, &res);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", "rx_bytes");
return 0;
}
int get_eth_port_stats_tx_packets(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", cur_eth_port_args.ifname, String}}, 1, &res);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", "tx_packets");
return 0;
}
int get_eth_port_stats_rx_packets(char *refparam, struct dmctx *ctx, char **value)
int get_eth_port_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
dmubus_call("network.device", "status", UBUS_ARGS{{"name", cur_eth_port_args.ifname, String}}, 1, &res);
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct eth_port_args *)data)->ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
*value = dmjson_get_value(res, 2, "statistics", "rx_packets");
return 0;
}
/////////////////////ENTRY METHOD //////////////////////////
int entry_method_root_Ethernet(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"Ethernet.") {
DMOBJECT(DMROOT"Ethernet.", ctx, "0", 0, NULL, NULL, NULL);
DMOBJECT(DMROOT"Ethernet.Interface.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_method_eth_interface, ctx);
return 0;
}
return FAULT_9005;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
inline int entry_method_eth_interface(struct dmctx *ctx)
int browseEthIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *int_num = NULL, *int_num_last = NULL, *ifname;
struct uci_section *ss = NULL;
struct eth_port_args curr_eth_port_args = {0};
#ifndef EX400
dmuci_get_option_value_string("layer2_interface_ethernet", "Wan", "baseifname", &wan_ifname);
#else
@ -295,30 +340,11 @@ inline int entry_method_eth_interface(struct dmctx *ctx)
if (strcmp(ifname, wan_ifname) == 0) {
dmasprintf(&ifname, "%s.1", ifname);
}
init_eth_port(ctx, ss, ifname);
int_num = handle_update_instance(1, ctx, &int_num_last, update_instance_alias, 3, ss, "eth_port_instance", "eth_port_alias");
SUBENTRY(entry_eth_interface_instance, ctx, int_num);
init_eth_port(&curr_eth_port_args, ss, ifname);
int_num = handle_update_instance(1, dmctx, &int_num_last, update_instance_alias, 3, ss, "eth_port_instance", "eth_port_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_eth_port_args, int_num) == DM_STOP)
break;
}
return 0;
}
inline int entry_eth_interface_instance(struct dmctx *ctx, char *int_num)
{
IF_MATCH(ctx, DMROOT"Ethernet.Interface.%s.", int_num) {
DMOBJECT(DMROOT"Ethernet.Interface.%s.", ctx, "0", 1, NULL, NULL, cur_eth_port_args.ifname, int_num);
DMPARAM("Alias", ctx, "1", get_eth_port_alias, set_eth_port_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_eth_port_enable, set_eth_port_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Status", ctx, "0", get_eth_port_status, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("MaxBitRate", ctx, "1", get_eth_port_maxbitrate, set_eth_port_maxbitrate, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "0", get_eth_port_name, NULL, NULL, 0, 1, UNDEF, NULL); //TO CHECK R/W
DMPARAM("MACAddress", ctx, "0", get_eth_port_mac_address, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DuplexMode", ctx, "1", get_eth_port_duplexmode, set_eth_port_duplexmode, NULL, 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"Ethernet.Interface.%s.Stats.", ctx, "0", 1, NULL, NULL, NULL, int_num);
DMPARAM("BytesSent", ctx, "0", get_eth_port_stats_tx_bytes, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("BytesReceived", ctx, "0", get_eth_port_stats_rx_bytes, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("PacketsSent", ctx, "0", get_eth_port_stats_tx_packets, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("PacketsReceived", ctx, "0", get_eth_port_stats_rx_packets, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -16,8 +16,29 @@ struct eth_port_args
struct uci_section *eth_port_sec;
char *ifname;
};
extern DMOBJ tEthernetObj[];
extern DMOBJ tEthernetStatObj[];
extern DMLEAF tEthernetParams[];
extern DMLEAF tEthernetStatParams[];
int browseEthIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_eth_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_mac_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_stats_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_stats_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_stats_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_eth_port_stats_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_eth_port_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_eth_port_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_eth_port_maxbitrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_eth_port_duplexmode(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int entry_method_root_Ethernet(struct dmctx *ctx);
int get_linker_val(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -19,15 +19,38 @@
#include "hosts.h"
#include "dmjson.h"
struct host_args cur_host_args = {0};
/*** Hosts. ***/
DMOBJ thostsObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Host", &DMREAD, NULL, NULL, NULL, browsehostInst, NULL, NULL, NULL, thostParam, NULL},
{0}
};
DMLEAF thostsParam[] = {
{"HostNumberOfEntries", &DMREAD, DMT_UNINT, get_host_nbr_entries, NULL, NULL, NULL},
{0}
};
/*** Hosts.Host ***/
DMLEAF thostParam[] = {
{"IPAddress", &DMREAD, DMT_STRING, get_host_ipaddress, NULL, NULL, &DMNONE},
{"HostName", &DMREAD, DMT_STRING, get_host_hostname, NULL, NULL, &DMNONE},
{"Active", &DMREAD, DMT_BOOL, get_host_active, NULL, NULL, &DMNONE},
{"PhysAddress", &DMREAD, DMT_STRING, get_host_phy_address, NULL, NULL, &DMNONE},
{"X_INTENO_SE_InterfaceType", &DMREAD, DMT_STRING, get_host_interfacetype, NULL, NULL, &DMNONE},
{"AddressSource", &DMREAD, DMT_STRING, get_host_address_source, NULL, NULL, &DMNONE},
{"LeaseTimeRemaining", &DMREAD, DMT_STRING, get_host_leasetime_remaining, NULL, NULL, &DMNONE},
{"DHCPClient", &DMREAD, DMT_STRING, get_host_dhcp_client, NULL, NULL, NULL},
{0}
};
/*************************************************************
* INIT
/*************************************************************/
inline int init_host_args(struct dmctx *ctx, json_object *clients, char *key)
inline int init_host_args(struct host_args *args, json_object *clients, char *key)
{
struct host_args *args = &cur_host_args;
ctx->args = (void *)args;
args->client = clients;
args->key = key;
return 0;
@ -35,34 +58,34 @@ inline int init_host_args(struct dmctx *ctx, json_object *clients, char *key)
/*************************************************************
* GET & SET PARAM
/*************************************************************/
int get_host_ipaddress(char *refparam, struct dmctx *ctx, char **value)
int get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(cur_host_args.client, 1, "ipaddr");
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "ipaddr");
return 0;
}
int get_host_hostname(char *refparam, struct dmctx *ctx, char **value)
int get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(cur_host_args.client, 1, "hostname");
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "hostname");
return 0;
}
int get_host_active(char *refparam, struct dmctx *ctx, char **value)
int get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(cur_host_args.client, 1, "connected");
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "connected");
return 0;
}
int get_host_phy_address(char *refparam, struct dmctx *ctx, char **value)
int get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmjson_get_value(cur_host_args.client, 1, "macaddr");
*value = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
return 0;
}
int get_host_address_source(char *refparam, struct dmctx *ctx, char **value) {
int get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) {
char *dhcp;
dhcp = dmjson_get_value(cur_host_args.client, 1, "dhcp");
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcasecmp(dhcp, "true") == 0)
*value = "DHCP";
else
@ -70,7 +93,7 @@ int get_host_address_source(char *refparam, struct dmctx *ctx, char **value) {
return 0;
}
int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, char **value)
int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char buf[80], *dhcp;
FILE *fp;
@ -79,12 +102,13 @@ int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, char **value
char *leasetime, *mac_f, *mac, *line1;
char delimiter[] = " \t";
dhcp = dmjson_get_value(cur_host_args.client, 1, "dhcp");
dhcp = dmjson_get_value(((struct host_args *)data)->client, 1, "dhcp");
if (strcmp(dhcp, "false") == 0) {
*value = "0";
}
else {
mac = dmjson_get_value(cur_host_args.client, 1, "macaddr");
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
//
fp = fopen(ARP_FILE, "r");
if ( fp != NULL)
{
@ -111,11 +135,11 @@ int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, char **value
return 0;
}
int get_host_dhcp_client(char *refparam, struct dmctx *ctx, char **value)
int get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface, *linker;
dmastrcat(&linker, "linker_dhcp:", cur_host_args.key);
adm_entry_get_linker_param(DMROOT"DHCPv4.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
dmastrcat(&linker, "linker_dhcp:", ((struct host_args *)data)->key);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cDHCPv4%c", DMROOT, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL) {
*value = "";
}
@ -147,7 +171,7 @@ char *get_interface_type(char *mac, char *ndev)
dmubus_call("router.wireless", "stas", UBUS_ARGS{{"vif", p, String}}, 1, &res);
if(res) {
json_object_object_foreach(res, key, val) {
value = dmjson_get_value(res, 1, "macaddr");
value = dmjson_get_value(val, 1, "macaddr");
if (strcasecmp(value, mac) == 0)
return "802.11";
}
@ -159,17 +183,17 @@ char *get_interface_type(char *mac, char *ndev)
return "Ethernet";
}
int get_host_interfacetype(char *refparam, struct dmctx *ctx, char **value)
int get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *mac, *network;
mac = dmjson_get_value(cur_host_args.client, 1, "macaddr");
network = dmjson_get_value(cur_host_args.client, 1, "network");
mac = dmjson_get_value(((struct host_args *)data)->client, 1, "macaddr");
network = dmjson_get_value(((struct host_args *)data)->client, 1, "network");
*value = get_interface_type(mac, network);
return 0;
}
int get_host_nbr_entries(char *refparam, struct dmctx *ctx, char **value)
int get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
int entries = 0;
json_object *res;
@ -182,50 +206,26 @@ int get_host_nbr_entries(char *refparam, struct dmctx *ctx, char **value)
dmasprintf(value, "%d", entries); // MEM WILL BE FREED IN DMMEMCLEAN
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_hosts(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"Hosts.") {
DMOBJECT(DMROOT"Hosts.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("HostNumberOfEntries", ctx, "0", get_host_nbr_entries, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"Hosts.Host.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_host, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_host(struct dmctx *ctx)
int browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
json_object *res, *client_obj;
char *idx, *idx_last = NULL;
int id = 0;
struct host_args curr_host_args = {0};
dmubus_call("router.network", "clients", UBUS_ARGS{}, 0, &res);
if (res) {
json_object_object_foreach(res, key, client_obj) {
init_host_args(ctx, client_obj, key);
idx = handle_update_instance(2, ctx, &idx_last, update_instance_without_section, 1, ++id);
SUBENTRY(entry_host_instance, ctx, idx);
init_host_args(&curr_host_args, client_obj, key);
idx = handle_update_instance(2, dmctx, &idx_last, update_instance_without_section, 1, ++id);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_host_args, idx) == DM_STOP)
break;
}
}
return 0;
}
inline int entry_host_instance(struct dmctx *ctx, char *int_num)
{
IF_MATCH(ctx, DMROOT"Hosts.Host.%s.", int_num) {
DMOBJECT(DMROOT"Hosts.Host.%s.", ctx, "0", NULL, NULL, NULL, NULL, int_num);
DMPARAM("IPAddress", ctx, "0", get_host_ipaddress, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("HostName", ctx, "0", get_host_hostname, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("Active", ctx, "0", get_host_active, NULL, "xsd:boolean", 0, 0, UNDEF, NULL);
DMPARAM("PhysAddress", ctx, "0", get_host_phy_address, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("X_INTENO_SE_InterfaceType", ctx, "0", get_host_interfacetype, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("AddressSource", ctx, "0", get_host_address_source, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("LeaseTimeRemaining", ctx, "0", get_host_leasetime_remaining, NULL, NULL, 0, 0, UNDEF, NULL);
DMPARAM("DHCPClient", ctx, "0", get_host_dhcp_client, NULL, NULL, 0, 1, UNDEF, NULL); //TO CHECK R/W
return 0;
}
return FAULT_9005;
}

View file

@ -17,6 +17,20 @@ struct host_args
char *key;
};
int entry_method_root_hosts(struct dmctx *ctx);
extern DMLEAF thostsParam[];
extern DMLEAF thostParam[];
extern DMOBJ thostsObj[];
int browsehostInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_host_nbr_entries(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_ipaddress(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_hostname(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_active(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_phy_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_interfacetype(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_address_source(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_leasetime_remaining(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_host_dhcp_client(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
#endif

View file

@ -12,38 +12,105 @@
#include <uci.h>
#include <stdio.h>
#include <ctype.h>
#include "cwmp.h"
#include "dmuci.h"
#include "dmubus.h"
#include "dmcwmp.h"
#include "dmcommon.h"
#include "ip.h"
#include "diagnostic.h"
#include "dmjson.h"
struct ip_args cur_ip_args = {0};
struct ipv4_args cur_ipv4_args = {0};
struct dm_forced_inform_s IPv4INFRM = {0, get_ipv4_finform};
struct dm_forced_inform_s IPv6INFRM = {0, get_ipv6_finform};
/* *** Device.IP. *** */
DMOBJ tIPObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Interface", &DMWRITE, add_ip_interface, delete_ip_interface, NULL, browseIPIfaceInst, NULL, NULL, tInterfaceObj, tIPintParams, get_linker_ip_interface},
{"Diagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tDiagnosticObj, NULL, NULL},
{0}
};
DMLEAF tIPintParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification*/
{"Enable", &DMWRITE, DMT_BOOL, get_ip_interface_enable, set_ip_interface_enable, NULL, NULL},
{"Name", &DMREAD, DMT_STRING, get_ip_interface_name, NULL, NULL, NULL},
{"LowerLayers", &DMWRITE, DMT_STRING, get_ip_int_lower_layer, set_ip_int_lower_layer, NULL, NULL},
{0}
};
/* *** Device.IP.Interface. *** */
DMOBJ tInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf*/
{"IPv4Address", &DMWRITE, add_ipv4, delete_ipv4, NULL, browseIfaceIPv4Inst, NULL, NULL, NULL, tIPv4Params, NULL},
{"IPv6Address", &DMWRITE, add_ipv6, delete_ipv6, NULL, browseIfaceIPv6Inst, NULL, NULL, NULL, tIPv6Params, NULL},
{0}
};
DMOBJ tDiagnosticObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, nextobj, leaf*/
{"IPPingDiagnostics", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tIpPingDiagParams, NULL},
{0}
};
/* *** Device.IP.Interface.{i}.IPv4Address.{i}. *** */
DMLEAF tIPv4Params[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform*/
{"Alias", &DMWRITE, DMT_STRING, get_ipv4_alias, set_ipv4_alias, &IPv4INFRM, NULL},
{"Enable", &DMREAD, DMT_BOOL, get_ip_enable, NULL, &IPv4INFRM, NULL},
{"X_BROADCOM_COM_FirewallEnabled", &DMWRITE, DMT_BOOL, get_firewall_enabled, set_firewall_enabled, &IPv4INFRM, NULL},
{"IPAddress", &DMWRITE, DMT_STRING, get_ipv4_address, set_ipv4_address, &IPv4INFRM, NULL},
{"SubnetMask", &DMWRITE, DMT_STRING, get_ipv4_netmask, set_ipv4_netmask, &IPv4INFRM, NULL},
{"AddressingType", &DMWRITE, DMT_STRING, get_ipv4_addressing_type, set_ipv4_addressing_type, &IPv4INFRM, NULL},
{0}
};
/* *** Device.IP.Interface.{i}.IPv6Address.{i}. *** */
DMLEAF tIPv6Params[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform*/
{"Alias", &DMWRITE, DMT_STRING, get_ipv6_alias, set_ipv6_alias, &IPv6INFRM, NULL},
{"Enable", &DMREAD, DMT_BOOL, get_ip_enable, NULL, &IPv6INFRM, NULL},
{"IPAddress", &DMWRITE, DMT_STRING, get_ipv6_address, set_ipv6_address, &IPv6INFRM, NULL},
{"Origin", &DMWRITE, DMT_STRING, get_ipv6_addressing_type, set_ipv6_addressing_type, &IPv6INFRM, NULL},
{0}
};
DMLEAF tIpPingDiagParams[] = {
/* PARAM, permission, type, getvlue, setvalue, forced_inform, notification , linker*/
{"DiagnosticsState", &DMWRITE, DMT_STRING, get_ip_ping_diagnostics_state, set_ip_ping_diagnostics_state, NULL, NULL},
{"Interface", &DMWRITE, DMT_BOOL, get_ip_ping_interface, set_ip_ping_interface, NULL, NULL},
{"Host", &DMWRITE, DMT_STRING, get_ip_ping_host, set_ip_ping_host, NULL, NULL},
{"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_ip_ping_repetition_number, set_ip_ping_repetition_number, NULL, NULL},
{"Timeout", &DMWRITE, DMT_UNINT, get_ip_ping_timeout, set_ip_ping_timeout, NULL, NULL},
{"DataBlockSize", &DMWRITE, DMT_UNINT, get_ip_ping_block_size, set_ip_ping_block_size, NULL, NULL},
{"SuccessCount", &DMREAD, DMT_UNINT, get_ip_ping_success_count, NULL, NULL},
{"FailureCount", &DMREAD, DMT_UNINT, get_ip_ping_failure_count, set_ipv6_addressing_type, NULL, NULL},
{"AverageResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_average_response_time, NULL, NULL, NULL},
{"MinimumResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_min_response_time, NULL, NULL, NULL},
{"MaximumResponseTime", &DMREAD, DMT_UNINT, get_ip_ping_max_response_time, NULL, NULL, NULL},
{0}
};
unsigned char get_ipv4_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance)
{
return 1;
//TODO
}
unsigned char get_ipv6_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance)
{
return 1;
//TODO
}
/*************************************************************
* INIT
/*************************************************************/
inline int init_ip_args(struct dmctx *ctx, struct uci_section *s)
inline int init_ip_args(struct ip_args *args, struct uci_section *s, char *ip_4address, char *ip_6address)
{
struct ip_args *args = &cur_ip_args;
ctx->args = (void *)args;
args->ip_sec = s;
return 0;
}
inline int init_ipv4_args(struct dmctx *ctx, struct uci_section *s, char *ip_address, char *ip_6address)
{
struct ipv4_args *args = &cur_ipv4_args;
ctx->args = (void *)args;
args->ipv4_sec = s;
args->ip_address = ip_address;
args->ip_4address = ip_4address;
args->ip_6address = ip_6address;
return 0;
}
/*************************************************************
* GET & SET PARAM
/*************************************************************/
@ -57,18 +124,19 @@ static inline char *ipping_get(char *option, char *def)
return tmp;
}
int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("DiagnosticState", "None");
return 0;
}
int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
switch (action) {
case VALUECHECK:
case VALUECHECK:
return 0;
case VALUESET:
if (strcmp(value, "Requested") == 0) {
@ -86,16 +154,17 @@ int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_ip_ping_interface(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@ippingdiagnostic[0]", "interface", value);
return 0;
}
int set_ip_ping_interface(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
@ -112,17 +181,18 @@ int set_ip_ping_interface(char *refparam, struct dmctx *ctx, int action, char *v
return 0;
}
int get_ip_ping_host(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_varstate_string("cwmp", "@ippingdiagnostic[0]", "Host", value);
return 0;
}
int set_ip_ping_host(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
@ -139,13 +209,13 @@ int set_ip_ping_host(char *refparam, struct dmctx *ctx, int action, char *value)
return 0;
}
int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("NumberOfRepetitions", "3");
return 0;
}
int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -166,14 +236,14 @@ int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, int action,
return 0;
}
int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("Timeout", "1000");
return 0;
}
int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
@ -194,17 +264,18 @@ int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, int action, char *val
return 0;
}
int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("DataBlockSize", "64");
return 0;
}
int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *tmp;
struct uci_section *curr_section = NULL;
switch (action) {
case VALUECHECK:
return 0;
@ -220,34 +291,34 @@ int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, int action, char *
return 0;
}
int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("SuccessCount", "0");
return 0;
}
int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("FailureCount", "0");
return 0;
}
int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("AverageResponseTime", "0");
return 0;
}
int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("MinimumResponseTime", "0");
return 0;
}
int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, char **value)
int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = ipping_get("MaximumResponseTime", "0");
@ -255,84 +326,84 @@ int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, char **valu
}
int get_ip_interface_enable(char *refparam, struct dmctx *ctx, char **value)
int get_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *lan_name = section_name(cur_ip_args.ip_sec);
char *lan_name = section_name(((struct ip_args *)data)->ip_sec);
get_interface_enable_ubus(lan_name, refparam, ctx, value);
return 0;
}
int set_ip_interface_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *lan_name = section_name(cur_ip_args.ip_sec);
char *lan_name = section_name(((struct ip_args *)data)->ip_sec);
set_interface_enable_ubus(lan_name, refparam, ctx, action, value);
return 0;
}
int get_ip_interface_name(char *refparam, struct dmctx *ctx, char **value)
int get_ip_interface_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmstrdup(section_name(cur_ip_args.ip_sec));
*value = dmstrdup(section_name(((struct ip_args *)data)->ip_sec));
return 0;
}
int get_firewall_enabled(char *refparam, struct dmctx *ctx, char **value)
int get_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
get_interface_firewall_enabled(section_name(cur_ip_args.ip_sec), refparam, ctx, value);
get_interface_firewall_enabled(section_name(((struct ip_args *)data)->ip_sec), refparam, ctx, value);
return 0;
}
int set_firewall_enabled(char *refparam, struct dmctx *ctx, int action, char *value)
int set_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
set_interface_firewall_enabled(section_name(cur_ip_args.ip_sec), refparam, ctx, action, value);
set_interface_firewall_enabled(section_name(((struct ip_args *)data)->ip_sec), refparam, ctx, action, value);
return 0;
}
int get_ipv4_address(char *refparam, struct dmctx *ctx, char **value)
int get_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = cur_ipv4_args.ip_address;
*value = ((struct ip_args *)data)->ip_4address;
return 0;
}
int set_ipv4_address(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ipaddr", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", value);
return 0;
}
return 0;
}
int get_ipv4_netmask(char *refparam, struct dmctx *ctx, char **value)
int get_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "netmask", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "netmask", value);
return 0;
}
int set_ipv4_netmask(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "netmask", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "netmask", value);
return 0;
}
return 0;
}
int get_ipv4_addressing_type (char *refparam, struct dmctx *ctx, char **value)
int get_ipv4_addressing_type (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", value);
if (strcmp(*value, "static") == 0)
*value = "Static";
else if (strcmp(*value, "dhcp") == 0)
@ -342,7 +413,7 @@ int get_ipv4_addressing_type (char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
@ -350,21 +421,21 @@ int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, int action, char
return 0;
case VALUESET:
if(strcasecmp(value, "static") == 0) {
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "proto", "static");
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ipaddr", "0.0.0.0");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "0.0.0.0");
}
if(strcasecmp(value, "dhcp") == 0) {
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "proto", "dhcp");
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ipaddr", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "dhcp");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
}
return 0;
}
return 0;
}
int get_ipv6_addressing_type (char *refparam, struct dmctx *ctx, char **value)
int get_ipv6_addressing_type (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", value);
if (strcmp(*value, "static") == 0)
*value = "Static";
else if (strcmp(*value, "dhcpv6") == 0)
@ -374,7 +445,7 @@ int get_ipv6_addressing_type (char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
@ -382,18 +453,18 @@ int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, int action, char
return 0;
case VALUESET:
if(strcasecmp(value, "static") == 0) {
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "proto", "static");
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ip6addr", "0.0.0.0");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "0.0.0.0");
}
if(strcasecmp(value, "dhcpv6") == 0) {
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "proto", "dhcpv6");
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ip6addr", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "dhcpv6");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "");
}
return 0;
}
return 0;
}
int get_ip_int_lower_layer(char *refparam, struct dmctx *ctx, char **value)
int get_ip_int_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *wifname, *wtype, *br_inst, *mg, *device, *proto;
struct uci_section *port;
@ -401,22 +472,22 @@ int get_ip_int_lower_layer(char *refparam, struct dmctx *ctx, char **value)
char buf[8];
char linker[64] = "";
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "type", &wtype);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "type", &wtype);
if (strcmp(wtype, "bridge") == 0) {
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "bridge_instance", &br_inst);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "bridge_instance", &br_inst);
uci_path_foreach_option_eq(icwmpd, "dmmap", "bridge_port", "bridge_key", br_inst, port) {
dmuci_get_value_by_section_string(port, "mg_port", &mg);
if (strcmp(mg, "true") == 0)
sprintf(linker, "%s+", section_name(port));
adm_entry_get_linker_param(DMROOT"Bridging.Bridge.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cBridging%cBridge%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
*value = "";
return 0;
}
} else if (wtype[0] == '\0' || strcmp(wtype, "anywan") == 0) {
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(cur_ip_args.ip_sec), String}}, 1, &res);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ifname", &wifname);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct ip_args *)data)->ip_sec), String}}, 1, &res);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ifname", &wifname);
strcpy (linker, wifname);
if (res) {
device = dmjson_get_value(res, 1, "device");
@ -427,87 +498,88 @@ int get_ip_int_lower_layer(char *refparam, struct dmctx *ctx, char **value)
strcpy(linker, buf);
}
}
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if (strstr(proto, "ppp")) {
sprintf(linker, "%s", section_name(cur_ip_args.ip_sec));
sprintf(linker, "%s", section_name(((struct ip_args *)data)->ip_sec));
}
}
adm_entry_get_linker_param(DMROOT"ATM.Link.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cATM%cLink%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"PTM.Link.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cPTM%cLink%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"Ethernet.Interface.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"WiFi.SSID.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWiFi%cSSID%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"PPP.Interface.", linker, value);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cPPP%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL)
*value = "";
return 0;
}
int set_ip_int_lower_layer(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_int_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker, *pch, *spch, *dup, *b_key, *proto, *ipaddr, *ip_inst, *ipv4_inst, *p, *type;
char sec[16];
char pat[32] = "";
struct uci_section *s;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
p = strstr(value, ".Port.");
if (linker && p && strcmp(p, ".Port.1.") == 0)
adm_entry_get_linker_value(ctx, value, &linker);
sprintf(pat, "%cPort%c1%c", dm_delim, dm_delim, dm_delim);
if (linker && strstr(value, pat))
{
strncpy(sec, linker, strlen(linker) - 1);
sec[strlen(linker) - 1] = '\0';
DMUCI_GET_OPTION_VALUE_STRING(icwmpd, "dmmap", sec, "bridge_key", &b_key);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "proto", &proto);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ipaddr", &ipaddr);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ip_int_instance", &ip_inst);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ipv4_instance", &ipv4_inst);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipaddr", &ipaddr);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ip_int_instance", &ip_inst);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv4_instance", &ipv4_inst);
uci_foreach_option_eq("network", "interface", "bridge_instance", b_key, s) {
dmuci_set_value_by_section(s, "proto", proto);
dmuci_set_value_by_section(s, "ipaddr", ipaddr);
dmuci_set_value_by_section(s, "ip_int_instance", ip_inst);
dmuci_set_value_by_section(s, "ipv4_instance", ipv4_inst);
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "type", &type);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "type", &type);
if (strcmp (type, "bridge"))
dmuci_delete_by_section(cur_ip_args.ip_sec, NULL, NULL);
dmuci_delete_by_section(((struct ip_args *)data)->ip_sec, NULL, NULL);
}
return 0;
}
if (linker)
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ifname", linker);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ifname", linker);
return 0;
}
return 0;
}
int get_ipv6_address(char *refparam, struct dmctx *ctx, char **value)
int get_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = cur_ipv4_args.ip_6address;
*value = ((struct ip_args *)data)->ip_6address;
return 0;
}
int set_ipv6_address(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ip6addr", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", value);
return 0;
}
return 0;
}
int get_ip_enable(char *refparam, struct dmctx *ctx, char **value)
int get_ip_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "true";
return 0;
@ -515,61 +587,61 @@ int get_ip_enable(char *refparam, struct dmctx *ctx, char **value)
/*************************************************************
* GET & SET ALIAS
/*************************************************************/
int get_ip_int_alias(char *refparam, struct dmctx *ctx, char **value)
int get_ip_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ip_int_alias", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ip_int_alias", value);
return 0;
}
int set_ip_int_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ip_int_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ip_int_alias", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip_int_alias", value);
return 0;
}
return 0;
}
int get_ipv4_alias(char *refparam, struct dmctx *ctx, char **value)
int get_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "ipv4_alias", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv4_alias", value);
return 0;
}
int set_ipv4_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ipv4_alias", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_alias", value);
return 0;
}
return 0;
}
int get_ipv6_alias(char *refparam, struct dmctx *ctx, char **value)
int get_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "ipv6_alias", value);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv6_alias", value);
return 0;
}
int set_ipv6_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *proto;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_get_value_by_section_string(cur_ipv4_args.ipv4_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "proto", &proto);
if(strcmp(proto, "static") == 0)
dmuci_set_value_by_section(cur_ipv4_args.ipv4_sec, "ipv6_alias", value);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_alias", value);
return 0;
}
return 0;
@ -592,7 +664,7 @@ char *get_last_instance_cond(char *package, char *section, char *opt_inst, char
return inst;
}
int add_ip_interface(struct dmctx *ctx, char **instance)
int add_ip_interface(char *refparam, struct dmctx *ctx, void *data, char **instance)
{
char *last_inst;
char ip_name[32], ib[8];
@ -609,86 +681,106 @@ int add_ip_interface(struct dmctx *ctx, char **instance)
return 0;
}
int delete_ip_interface(struct dmctx *ctx)
int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
dmuci_set_value_by_section(cur_ip_args.ip_sec, "proto", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "type", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "bridge_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ip_int_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv4_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv6_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ifname", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipaddr", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ip6addr", "");
return 0;
}
int add_ipv4(struct dmctx *ctx, char **instancepara)
{
char *instance;
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ipv4_instance", &instance);
*instancepara = update_instance(cur_ip_args.ip_sec, instance, "ipv4_instance");
if(instance[0] == '\0') {
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv4_instance", *instancepara);
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipaddr", "0.0.0.0");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "proto", "static");
switch (del_action) {
case DEL_INST:
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "type", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "bridge_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip_int_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ifname", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "");
break;
case DEL_ALL:
return FAULT_9005;
}
return 0;
}
int delete_ipv4(struct dmctx *ctx)
{
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipaddr", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv4_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "proto", "");
return 0;
}
int add_ipv6(struct dmctx *ctx, char **instancepara)
int add_ipv4(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *instance;
dmuci_get_value_by_section_string(cur_ip_args.ip_sec, "ipv6_instance", &instance);
*instancepara = update_instance(cur_ip_args.ip_sec, instance, "ipv6_instance");
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv4_instance", &instance);
*instancepara = update_instance(((struct ip_args *)data)->ip_sec, instance, "ipv4_instance");
if(instance[0] == '\0') {
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv6_instance", *instancepara);
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ip6addr", "::");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "proto", "static");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", *instancepara);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "0.0.0.0");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
}
return 0;
}
int delete_ipv6(struct dmctx *ctx)
int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ip6addr", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "ipv6_instance", "");
dmuci_set_value_by_section(cur_ip_args.ip_sec, "proto", "");
switch (del_action) {
case DEL_INST:
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipaddr", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv4_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
break;
case DEL_ALL:
return FAULT_9005;
}
return 0;
}
int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara)
{
char *instance;
dmuci_get_value_by_section_string(((struct ip_args *)data)->ip_sec, "ipv6_instance", &instance);
*instancepara = update_instance(((struct ip_args *)data)->ip_sec, instance, "ipv6_instance");
if(instance[0] == '\0') {
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", *instancepara);
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "::");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "static");
}
return 0;
}
int delete_ipv6(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action)
{
switch (del_action) {
case DEL_INST:
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ip6addr", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "ipv6_instance", "");
dmuci_set_value_by_section(((struct ip_args *)data)->ip_sec, "proto", "");
break;
case DEL_ALL:
return FAULT_9005;
}
return 0;
}
/**************************************************************************
* LINKER
***************************************************************************/
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(((struct ip_args *)data)->ip_sec) {
dmasprintf(linker,"%s", section_name(((struct ip_args *)data)->ip_sec));
return 0;
} else {
*linker = "";
return 0;
}
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_ip(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"IP.") {
DMOBJECT(DMROOT"IP.", ctx, "0", 0, NULL, NULL, NULL);
DMOBJECT(DMROOT"IP.Interface.", ctx, "1", 1, add_ip_interface, NULL, NULL);
DMOBJECT(DMROOT"IP.Diagnostics.", ctx, "0", 0, NULL, NULL, NULL);
SUBENTRY(entry_ip_interface, ctx);
SUBENTRY(entry_ip_ping_diagnostic, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_ip_interface(struct dmctx *ctx)
int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *net_sec = NULL;
char *ip_int = NULL, *ip_int_last = NULL;
char *type, *ipv4addr = "", *ipv6addr = "", *proto, *inst;
json_object *res, *jobj;
struct ip_args curr_ip_args = {0};
uci_foreach_sections("network", "interface", net_sec) {
dmuci_get_value_by_section_string(net_sec, "type", &type);
@ -717,108 +809,38 @@ inline int entry_ip_interface(struct dmctx *ctx)
if (ipv4addr[0] == '\0' && ipv6addr[0] == '\0' && strcmp(proto, "dhcp") != 0 && strcmp(proto, "dhcpv6") != 0 && strcmp(inst, "") == 0) {
continue;
}
init_ip_args(ctx, net_sec);
ip_int = handle_update_instance(1, ctx, &ip_int_last, update_instance_alias, 3, net_sec, "ip_int_instance", "ip_int_alias");
SUBENTRY(entry_ip_interface_instance, ctx, ip_int);
SUBENTRY(entry_ip_address, ctx, net_sec, ipv4addr, ipv6addr, ip_int);
init_ip_args(&curr_ip_args, net_sec, ipv4addr, ipv6addr);
ip_int = handle_update_instance(1, dmctx, &ip_int_last, update_instance_alias, 3, net_sec, "ip_int_instance", "ip_int_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_ip_args, ip_int) == DM_STOP)
break;
}
return 0;
}
inline int entry_ip_address(struct dmctx *ctx, struct uci_section *net_sec, char *ipv4addr, char *ipv6addr,char *ip_int)
int browseIfaceIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *ip_sec = NULL;
char *type, *ifname, *ipv4, *ipv6, *ipv4_inst = NULL, *ipv6_inst = NULL,*ipv4_inst_last = NULL, *ipv6_inst_last = NULL ;
init_ipv4_args(ctx, net_sec, ipv4addr, ipv6addr);
if(ipv4addr[0] != '\0') {
ipv4_inst = handle_update_instance(2, ctx, &ipv4_inst_last, update_instance_alias, 3, net_sec, "ipv4_instance", "ipv4_alias");
SUBENTRY(entry_ipv4_address_instance, ctx, ip_int, ipv4_inst);
}
if (ipv6addr[0] != '\0') {
ipv6_inst = handle_update_instance(2, ctx, &ipv6_inst_last, update_instance_alias, 3, net_sec, "ipv6_instance", "ipv6_alias");
SUBENTRY(entry_ipv6_address_instance, ctx, ip_int, ipv6_inst);
}
dmasprintf(&ifname, "br-%s", section_name(net_sec));
uci_foreach_option_eq("network", "interface", "ifname", ifname, ip_sec) {
dmuci_get_value_by_section_string(ip_sec, "ipaddr", &ipv4);
dmuci_get_value_by_section_string(ip_sec, "ip6addr", &ipv6);
if(ipv4[0] != '\0') {
init_ipv4_args(ctx, ip_sec, ipv4, ipv6);
ipv4_inst = handle_update_instance(2, ctx, &ipv4_inst_last, update_instance_alias, 3, ip_sec, "ipv4_instance", "ipv4_alias");
SUBENTRY(entry_ipv4_address_instance, ctx, ip_int, ipv4_inst);
}
if(ipv6[0] != '\0') {
init_ipv4_args(ctx, ip_sec, ipv4, ipv6);
ipv6_inst = handle_update_instance(2, ctx, &ipv6_inst_last, update_instance_alias, 3, ip_sec, "ipv6_instance", "ipv6_alias");
SUBENTRY(entry_ipv6_address_instance, ctx, ip_int, ipv6_inst);
}
if(((struct ip_args *)prev_data)->ip_4address[0] != '\0') {
ipv4_inst = handle_update_instance(2, dmctx, &ipv4_inst_last, update_instance_alias, 3, ((struct ip_args *)prev_data)->ip_sec, "ipv4_instance", "ipv4_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, ipv4_inst) == DM_STOP)
goto end;
}
end:
return 0;
}
inline int entry_ip_interface_instance(struct dmctx *ctx, char *int_num)
int browseIfaceIPv6Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
IF_MATCH(ctx, DMROOT"IP.Interface.%s.", int_num) {
char linker[32] = "";
strcat(linker, section_name(cur_ip_args.ip_sec));
DMOBJECT(DMROOT"IP.Interface.%s.", ctx, "1", 1, NULL, delete_ip_interface, linker, int_num);
DMPARAM("Alias", ctx, "1", get_ip_int_alias, set_ip_int_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_ip_interface_enable, set_ip_interface_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "0", get_ip_interface_name, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("LowerLayers", ctx, "1", get_ip_int_lower_layer, set_ip_int_lower_layer, NULL, 0, 1, UNDEF, NULL);//TODO
DMOBJECT(DMROOT"IP.Interface.%s.IPv4Address.", ctx, "1", 1, add_ipv4, NULL, NULL, int_num);
DMOBJECT(DMROOT"IP.Interface.%s.IPv6Address.", ctx, "1", 1, add_ipv6, NULL, NULL, int_num);
return 0;
}
return FAULT_9005;
}
struct uci_section *ip_sec = NULL;
char *type, *ifname, *ipv4, *ipv6, *ipv4_inst = NULL, *ipv6_inst = NULL,*ipv4_inst_last = NULL, *ipv6_inst_last = NULL ;
inline int entry_ipv4_address_instance(struct dmctx *ctx, char *int_num, char *ip_inst)
{
IF_MATCH(ctx, DMROOT"IP.Interface.%s.IPv4Address.%s.", int_num, ip_inst) {
DMOBJECT(DMROOT"IP.Interface.%s.IPv4Address.%s.", ctx, "1", 1, NULL, delete_ipv4, NULL, int_num, ip_inst);
DMPARAM("Alias", ctx, "1", get_ipv4_alias, set_ipv4_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "0", get_ip_enable, NULL, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("X_BROADCOM_COM_FirewallEnabled", ctx, "1", get_firewall_enabled, set_firewall_enabled, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("IPAddress", ctx, "1", get_ipv4_address, set_ipv4_address, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SubnetMask", ctx, "1", get_ipv4_netmask, set_ipv4_netmask, NULL, 0, 1, UNDEF, NULL);
DMPARAM("AddressingType", ctx, "1", get_ipv4_addressing_type, set_ipv4_addressing_type, NULL, 0, 1, UNDEF, NULL);
return 0;
if (((struct ip_args *)prev_data)->ip_6address[0] != '\0') {
ipv6_inst = handle_update_instance(2, dmctx, &ipv6_inst_last, update_instance_alias, 3, ((struct ip_args *)prev_data)->ip_sec, "ipv6_instance", "ipv6_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, prev_data, ipv6_inst) == DM_STOP)
goto end;
}
return FAULT_9005;
}
inline int entry_ipv6_address_instance(struct dmctx *ctx, char *int_num, char *ip_inst)
{
IF_MATCH(ctx, DMROOT"IP.Interface.%s.IPv6Address.%s.", int_num, ip_inst) {
DMOBJECT(DMROOT"IP.Interface.%s.IPv6Address.%s.", ctx, "1", 1, NULL, delete_ipv6, NULL, int_num, ip_inst);
DMPARAM("Alias", ctx, "1", get_ipv6_alias, set_ipv6_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "0", get_ip_enable, NULL, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("IPAddress", ctx, "1", get_ipv6_address, set_ipv6_address, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Origin", ctx, "1", get_ipv6_addressing_type, set_ipv6_addressing_type, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
inline int entry_ip_ping_diagnostic(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"IP.Diagnostics.IPPingDiagnostics.") {
DMOBJECT(DMROOT"IP.Diagnostics.IPPingDiagnostics.", ctx, "0", 0, NULL, NULL, NULL);
DMPARAM("DiagnosticsState", ctx, "1", get_ip_ping_diagnostics_state, set_ip_ping_diagnostics_state, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, "1", get_ip_ping_interface, set_ip_ping_interface, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Host", ctx, "1", get_ip_ping_host, set_ip_ping_host, NULL, 0, 1, UNDEF, NULL);
DMPARAM("NumberOfRepetitions", ctx, "1", get_ip_ping_repetition_number, set_ip_ping_repetition_number, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("Timeout", ctx, "1", get_ip_ping_timeout, set_ip_ping_timeout, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("DataBlockSize", ctx, "1", get_ip_ping_block_size, set_ip_ping_block_size, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
//DMPARAM("DSCP", ctx, "1", get_ipping_dscp, set_ipping_dscp, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("SuccessCount", ctx, "0", get_ip_ping_success_count, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("FailureCount", ctx, "0", get_ip_ping_failure_count, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("AverageResponseTime", ctx, "0", get_ip_ping_average_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MinimumResponseTime", ctx, "0", get_ip_ping_min_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("MaximumResponseTime", ctx, "0", get_ip_ping_max_response_time, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
end:
return 0;
}

View file

@ -15,16 +15,73 @@ extern struct ip_ping_diagnostic ipping_diagnostic;
struct ip_args
{
struct uci_section *ip_sec;
};
struct ipv4_args
{
struct uci_section *ipv4_sec;
char *ip_address;
char *ip_4address;
char *ip_6address;
};
extern DMOBJ tIPObj[];
extern DMOBJ tInterfaceObj[];
extern DMLEAF tIPv4Params[];
extern DMLEAF tIPv6Params[];
extern DMLEAF tIPintParams[];
extern DMLEAF tIpPingDiagParams[];
extern DMOBJ tDiagnosticObj[];
unsigned char get_ipv4_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
unsigned char get_ipv6_finform(char *refparam, struct dmctx *dmctx, void *data, char *instance);
int browseIPIfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIfaceIPv4Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIfaceIPv6Inst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int entry_method_root_ip(struct dmctx *ctx);
int add_ip_interface(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ip_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv4(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipv4(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ipv6(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ipv6(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_interface_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_int_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_failure_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_average_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_min_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ip_ping_max_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ip_int_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_int_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv4_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_firewall_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv4_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv4_netmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv4_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv6_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv6_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_diagnostics_state(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_host(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_repetition_number(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_timeout(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_ping_block_size(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ipv6_addressing_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ip_interface_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_linker_ip_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -18,72 +18,59 @@
#include "dmcommon.h"
#include "nat.h"
struct nat_args
{
struct uci_section *int_sec;
/*** NAT. ***/
DMOBJ tnatObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"InterfaceSetting", &DMREAD, NULL, NULL, NULL, browseInterfaceSettingInst, NULL, NULL, NULL, tInterfaceSettingParam, NULL},
{0}
};
struct nat_args cur_nat_args = {0};
/*** NAT.InterfaceSetting. ***/
DMLEAF tInterfaceSettingParam[] = {
{"Enable", &DMREAD, DMT_BOOL, get_nat_enable, NULL, NULL, &DMNONE},
{"Alias", &DMWRITE, DMT_STRING, get_nat_alias, set_nat_alias, NULL, &DMNONE},
{"Interface", &DMREAD, DMT_STRING, get_nat_interface, NULL, NULL, &DMNONE},
{0}
};
inline int init_nat_args(struct dmctx *ctx, struct uci_section *int_sec)
{
struct nat_args *args = &cur_nat_args;
ctx->args = (void *)args;
args->int_sec = int_sec;
return 0;
}
int get_nat_enable(char *refparam, struct dmctx *ctx, char **value)
int get_nat_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "1";
return 0;
}
int get_nat_alias(char *refparam, struct dmctx *ctx, char **value)
int get_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct nat_args *natargs = (struct nat_args *)ctx->args;
dmuci_get_value_by_section_string(natargs->int_sec, "natalias", value);
struct uci_section *int_sec = (struct uci_section *)data;
dmuci_get_value_by_section_string(int_sec, "natalias", value);
return 0;
}
int set_nat_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct nat_args *natargs = (struct nat_args *)ctx->args;
struct uci_section *int_sec = (struct uci_section *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(natargs->int_sec, "natalias", value);
dmuci_set_value_by_section(int_sec, "natalias", value);
return 0;
}
return 0;
}
int get_nat_interface(char *refparam, struct dmctx *ctx, char **value)
int get_nat_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
linker = dmstrdup(section_name(cur_nat_args.int_sec));
adm_entry_get_linker_param(DMROOT"IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
linker = dmstrdup(section_name(((struct uci_section *)data)));
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
dmfree(linker);
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_nat(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"NAT.") {
DMOBJECT(DMROOT"NAT.", ctx, "0", 0, NULL, NULL, NULL);
DMOBJECT(DMROOT"NAT.InterfaceSetting.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_nat, ctx);
return 0;
}
return FAULT_9005;
}
int get_nat_last_inst()
{
char *rinst = "0", *tmp;
@ -142,7 +129,12 @@ char *nat_update_instance_alias(int action, char **last_inst, void *argv[])
return instance;
}
inline int entry_nat(struct dmctx *ctx)
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *net_sec = NULL, *s = NULL;
char *nat = NULL;
@ -153,26 +145,14 @@ inline int entry_nat(struct dmctx *ctx)
uci_foreach_list_cont("firewall", "zone", "network", section_name(net_sec), s) {
dmuci_get_value_by_section_string(s, "masq", &nat);
if(nat[0] == '1') {
nati = handle_update_instance(1, ctx, &nati_last, nat_update_instance_alias, 4, net_sec, "natinstance", "natalias", &find_max);
init_nat_args(ctx, net_sec);
SUBENTRY(entry_nat_instance, ctx, nati);
nati = handle_update_instance(1, dmctx, &nati_last, nat_update_instance_alias, 4, net_sec, "natinstance", "natalias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)net_sec, nati) == DM_STOP)
goto end;
break;
}
}
}
}
}
end:
return 0;
}
inline int entry_nat_instance(struct dmctx *ctx, char *int_num)
{
IF_MATCH(ctx, DMROOT"NAT.InterfaceSetting.%s.", int_num) {
DMOBJECT(DMROOT"NAT.InterfaceSetting.%s.", ctx, "0", NULL, NULL, NULL, NULL, int_num);
DMPARAM("Enable", ctx, "0", get_nat_enable, NULL, "xsd:boolean", 0, 0, UNDEF, NULL);
DMPARAM("Alias", ctx, "1", get_nat_alias, set_nat_alias, NULL, 0, 0, UNDEF, NULL);
DMPARAM("Interface", ctx, "0", get_nat_interface, NULL, NULL, 0, 0, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -11,6 +11,15 @@
#ifndef __NAT_H
#define __NAT_H
int entry_method_root_nat(struct dmctx *ctx);
extern DMLEAF tInterfaceSettingParam[];
extern DMOBJ tnatObj[];
int browseInterfaceSettingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_nat_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_nat_interface(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_nat_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -19,36 +19,60 @@
#include "dmcommon.h"
#include "ppp.h"
struct ppp_args cur_ppp_args = {0};
/*** PPP. ***/
DMOBJ tpppObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Interface", &DMREAD, NULL, NULL, NULL, browseInterfaceInst, NULL, NULL, tpppInterfaceObj, tpppInterfaceParam, get_linker_ppp_interface},
{0}
};
/*** PPP.Interface. ***/
DMOBJ tpppInterfaceObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Stats", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tStatsParam, NULL},
{0}
};
DMLEAF tpppInterfaceParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_ppp_alias, set_ppp_alias, NULL, NULL},
{"Enable", &DMWRITE, DMT_BOOL, get_ppp_enable, set_ppp_enable, NULL, NULL},
{"Name", &DMREAD, DMT_STRING, get_ppp_name, NULL, NULL, NULL},
{"LowerLayers", &DMWRITE, DMT_STRING, get_ppp_lower_layer, set_ppp_lower_layer, NULL, NULL},
{"ConnectionStatus", &DMREAD, DMT_STRING, get_ppp_status, NULL, NULL, NULL},
{"Username", &DMWRITE, DMT_STRING, get_ppp_username, set_ppp_username, NULL, NULL},
{"Password", &DMWRITE, DMT_STRING, get_empty, set_ppp_password, NULL, NULL},
{0}
};
/*** PPP.Interface.Stats. ***/
DMLEAF tStatsParam[] = {
{"EthernetBytesReceived", &DMREAD, DMT_UNINT, get_ppp_eth_bytes_received, NULL, NULL, NULL},
{"EthernetBytesSent", &DMWRITE, DMT_UNINT, get_ppp_eth_bytes_sent, NULL, NULL, NULL},
{"EthernetPacketsReceived", &DMREAD, DMT_UNINT, get_ppp_eth_pack_received, NULL, NULL, NULL},
{"EthernetPacketsSent", &DMREAD, DMT_UNINT, get_ppp_eth_pack_sent, NULL, NULL, NULL},
{0}
};
/*************************************************************
* INIT
/*************************************************************/
inline int init_ppp_args(struct dmctx *ctx, struct uci_section *s)
{
struct ppp_args *args = &cur_ppp_args;
ctx->args = (void *)args;
args->ppp_sec = s;
return 0;
}
/*************************************************************
* GET SET ALIAS
/*************************************************************/
int get_ppp_alias(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ppp_args.ppp_sec, "ppp_int_alias", value);
dmuci_get_value_by_section_string(((struct uci_section *)data), "ppp_int_alias", value);
return 0;
}
int set_ppp_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_ppp_args.ppp_sec, "ppp_int_alias", value);
dmuci_set_value_by_section(((struct uci_section *)data), "ppp_int_alias", value);
return 0;
}
return 0;
@ -58,23 +82,23 @@ int set_ppp_alias(char *refparam, struct dmctx *ctx, int action, char *value)
* GET & SET PARAMETERS
***************************************************************************/
int get_ppp_enable(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
return get_interface_enable_ubus(section_name(cur_ppp_args.ppp_sec), refparam, ctx, value);
return get_interface_enable_ubus(section_name(((struct uci_section *)data)), refparam, ctx, value);
}
int set_ppp_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
return set_interface_enable_ubus(section_name(cur_ppp_args.ppp_sec), refparam, ctx, action, value);
return set_interface_enable_ubus(section_name(((struct uci_section *)data)), refparam, ctx, action, value);
}
int get_ppp_name(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = dmstrdup(section_name(cur_ppp_args.ppp_sec));
*value = dmstrdup(section_name(((struct uci_section *)data)));
return 0;
}
int get_ppp_status(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *status = NULL;
char *uptime = NULL;
@ -82,7 +106,7 @@ int get_ppp_status(char *refparam, struct dmctx *ctx, char **value)
json_object *res = NULL, *jobj = NULL;
bool bstatus = false, bpend = false;
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(cur_ppp_args.ppp_sec), String}}, 1, &res);
dmubus_call("network.interface", "status", UBUS_ARGS{{"interface", section_name(((struct uci_section *)data)), String}}, 1, &res);
DM_ASSERT(res, *value = "");
jobj = dmjson_get_obj(res, 1, "up");
if(jobj)
@ -104,41 +128,41 @@ int get_ppp_status(char *refparam, struct dmctx *ctx, char **value)
return 0;
}
int get_ppp_username(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_ppp_args.ppp_sec, "username", value);
dmuci_get_value_by_section_string(((struct uci_section *)data), "username", value);
return 0;
}
int set_ppp_username(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_ppp_args.ppp_sec, "username", value);
dmuci_set_value_by_section(((struct uci_section *)data), "username", value);
return 0;
}
return 0;
}
int set_ppp_password(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_ppp_args.ppp_sec, "password", value);
dmuci_set_value_by_section(((struct uci_section *)data), "password", value);
return 0;
}
return 0;
}
inline int ubus_get_wan_stats(json_object *res, char **value, char *stat_mod)
inline int ubus_get_wan_stats(void *data, char *instance, json_object *res, char **value, char *stat_mod)
{
char *ifname, *proto;
dmuci_get_value_by_section_string(cur_ppp_args.ppp_sec, "ifname", &ifname);
dmuci_get_value_by_section_string(cur_ppp_args.ppp_sec, "proto", &proto);
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &ifname);
dmuci_get_value_by_section_string(((struct uci_section *)data), "proto", &proto);
if (strcmp(proto, "pppoe") == 0) {
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ifname, String}}, 1, &res);
DM_ASSERT(res, *value = "");
@ -147,78 +171,83 @@ inline int ubus_get_wan_stats(json_object *res, char **value, char *stat_mod)
return 0;
}
int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(res, value, "rx_bytes");
ubus_get_wan_stats(data, instance, res, value, "rx_bytes");
return 0;
}
int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(res, value, "tx_bytes");
ubus_get_wan_stats(data, instance, res, value, "tx_bytes");
return 0;
}
int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(res, value, "rx_packets");
ubus_get_wan_stats(data, instance, res, value, "rx_packets");
return 0;
}
int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res;
ubus_get_wan_stats(res, value, "tx_packets");
ubus_get_wan_stats(data, instance, res, value, "tx_packets");
return 0;
}
int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, char **value)
int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *linker;
dmuci_get_value_by_section_string(cur_ppp_args.ppp_sec, "ifname", &linker);
adm_entry_get_linker_param(DMROOT"ATM.Link.", linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"PTM.Link.", linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"Ethernet.Interface.", linker, value);
if (*value == NULL)
adm_entry_get_linker_param(DMROOT"WiFi.SSID.", linker, value);
dmuci_get_value_by_section_string(((struct uci_section *)data), "ifname", &linker);
adm_entry_get_linker_param(ctx, dm_print_path("%s%cATM%cLink%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cPTM%cLink%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL) {
adm_entry_get_linker_param(ctx, dm_print_path("%s%cWiFi%cSSID%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value);
}
if (*value == NULL)
*value = "";
return 0;
}
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, int action, char *value)
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
dmuci_set_value_by_section(cur_ppp_args.ppp_sec, "ifname", linker);
adm_entry_get_linker_value(ctx, value, &linker);
dmuci_set_value_by_section(((struct uci_section *)data), "ifname", linker);
return 0;
}
return 0;
}
/**************************************************************************
* LINKER
***************************************************************************/
int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker) {
if(((struct uci_section *)data)) {
dmasprintf(linker,"%s", section_name(((struct uci_section *)data)));
return 0;
}
*linker = "";
return 0;
}
/*************************************************************
* ENTRY METHOD
/*************************************************************/
int entry_method_root_ppp(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"PPP.") {
DMOBJECT(DMROOT"PPP.", ctx, "0", 0, NULL, NULL, NULL);
DMOBJECT(DMROOT"PPP.Interface.", ctx, "0", 1, NULL, NULL, NULL);
SUBENTRY(entry_ppp_interface, ctx);
return 0;
}
return FAULT_9005;
}
inline int entry_ppp_interface(struct dmctx *ctx)
int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *net_sec = NULL;
char *ppp_int = NULL, *ppp_int_last = NULL;
@ -228,32 +257,11 @@ inline int entry_ppp_interface(struct dmctx *ctx)
dmuci_get_value_by_section_string(net_sec, "proto", &proto);
if (!strstr(proto, "ppp"))
continue;
init_ppp_args(ctx, net_sec);
ppp_int = handle_update_instance(1, ctx, &ppp_int_last, update_instance_alias, 3, net_sec, "ppp_int_instance", "ppp_int_alias");
SUBENTRY(entry_ppp_interface_instance, ctx, ppp_int);
ppp_int = handle_update_instance(1, dmctx, &ppp_int_last, update_instance_alias, 3, net_sec, "ppp_int_instance", "ppp_int_alias");
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)net_sec, ppp_int) == DM_STOP)
break;
}
return 0;
}
inline int entry_ppp_interface_instance(struct dmctx *ctx, char *int_num)
{
IF_MATCH(ctx, DMROOT"PPP.Interface.%s.", int_num) {
char linker[32] = "";
strcat(linker, section_name(cur_ppp_args.ppp_sec));
DMOBJECT(DMROOT"PPP.Interface.%s.", ctx, "0", 1, NULL, NULL, linker, int_num);
DMPARAM("Alias", ctx, "1", get_ppp_alias, set_ppp_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Enable", ctx, "1", get_ppp_enable, set_ppp_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Name", ctx, "0", get_ppp_name, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("LowerLayers", ctx, "1", get_ppp_lower_layer, set_ppp_lower_layer, NULL, 0, 1, UNDEF, NULL);//TODO
DMPARAM("ConnectionStatus", ctx, "0", get_ppp_status, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Username", ctx, "1", get_ppp_username, set_ppp_username, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Password", ctx, "1", get_empty, set_ppp_password, NULL, 0, 1, UNDEF, NULL);
DMOBJECT(DMROOT"PPP.Interface.%s.Stats.", ctx, "0", 1, NULL, NULL, NULL, int_num);
DMPARAM("EthernetBytesReceived", ctx, "0", get_ppp_eth_bytes_received, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("EthernetBytesSent", ctx, "0", get_ppp_eth_bytes_sent, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("EthernetPacketsReceived", ctx, "0", get_ppp_eth_pack_received, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
DMPARAM("EthernetPacketsSent", ctx, "0", get_ppp_eth_pack_sent,NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}

View file

@ -11,11 +11,29 @@
#ifndef __PPP_H
#define __PPP_H
struct ppp_args
{
struct uci_section *ppp_sec;
};
extern DMLEAF tpppInterfaceParam[];
extern DMLEAF tStatsParam[];
extern DMOBJ tpppInterfaceObj[];
extern DMOBJ tpppObj[];
int entry_method_root_ppp(struct dmctx *ctx);
int browseInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int get_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ppp_eth_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_ppp_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_username(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ppp_password(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_linker_ppp_interface(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

View file

@ -24,14 +24,50 @@ enum enum_route_type {
ROUTE_DISABLED
};
struct routingfwdargs cur_routefwdargs = {0};
struct router_args cur_router_args = {0};
/*** Routing. ***/
DMOBJ tRoutingObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"Router", &DMREAD, NULL, NULL, NULL, browseRouterInst, NULL, NULL, tRouterObj, tRouterInstParam, NULL},
{0}
};
inline int entry_router_ipv4forwarding_instance(struct dmctx *ctx, char *irouter, char *iroute, char *permission);
inline int init_args_ipv4forward(struct dmctx *ctx, struct uci_section *s, char *permission, struct proc_routing *proute, int type)
DMLEAF tRoutingParam[] = {
{"RouterNumberOfEntries", &DMREAD, DMT_UNINT, get_router_nbr_entry, NULL, NULL, NULL},
{0}
};
/*** Routing.Router. ***/
DMOBJ tRouterObj[] = {
/* OBJ, permission, addobj, delobj, browseinstobj, finform, notification, nextobj, leaf*/
{"IPv4Forwarding", &DMREAD, NULL, NULL, NULL, browseIPv4ForwardingInst, NULL, NULL, NULL, tIPv4ForwardingParam, NULL},
{0}
};
DMLEAF tRouterInstParam[] = {
{"Alias", &DMWRITE, DMT_STRING, get_router_alias, set_router_alias, NULL, NULL},
{0}
};
/*** Routing.Router.IPv4Forwarding. ***/
DMLEAF tIPv4ForwardingParam[] = {
{"Enable", &DMRouting, DMT_BOOL, get_router_ipv4forwarding_enable, set_router_ipv4forwarding_enable, NULL, NULL},
{"Status", &DMREAD, DMT_STRING, get_router_ipv4forwarding_status, NULL, NULL, NULL},
{"Alias", &DMWRITE, DMT_STRING, get_router_ipv4forwarding_alias, set_router_ipv4forwarding_alias, NULL, NULL},
{"DestIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destip, set_router_ipv4forwarding_destip, NULL, NULL},
{"DestSubnetMask", &DMRouting, DMT_STRING, get_router_ipv4forwarding_destmask, set_router_ipv4forwarding_destmask, NULL, NULL},
{"SourceIPAddress", &DMREAD, DMT_STRING, get_router_ipv4forwarding_src_address, NULL, NULL, NULL},
{"SourceSubnetMask", &DMREAD, DMT_STRING, get_router_ipv4forwarding_src_mask, NULL, NULL, NULL},
{"GatewayIPAddress", &DMRouting, DMT_STRING, get_router_ipv4forwarding_gatewayip, set_router_ipv4forwarding_gatewayip, NULL, NULL},
{"Interface", &DMRouting, DMT_STRING, get_router_ipv4forwarding_interface_linker_parameter, set_router_ipv4forwarding_interface_linker_parameter, NULL, NULL},
{"ForwardingMetric", &DMRouting, DMT_STRING, get_router_ipv4forwarding_metric, set_router_ipv4forwarding_metric, NULL, NULL},
{0}
};
/********************************
* inti function
********************************/
inline int init_args_ipv4forward(struct routingfwdargs *args, struct uci_section *s, char *permission, struct proc_routing *proute, int type)
{
struct routingfwdargs *args = &cur_routefwdargs;
ctx->args = (void *)args;
args->permission = permission;
args->routefwdsection = s;
args->proute = proute;
@ -39,13 +75,6 @@ inline int init_args_ipv4forward(struct dmctx *ctx, struct uci_section *s, char
return 0;
}
inline int init_router_args(struct dmctx *ctx, struct uci_section *section)
{
struct router_args *args = &cur_router_args;
ctx->args = (void *)args;
args->router_section = section;
return 0;
}
/*************************************************************************************
**** function related to get_object_router_ipv4forwarding ****
**************************************************************************************/
@ -58,38 +87,6 @@ void ip_to_hex(char *address, char *ret) //TODO Move to the common.c
sprintf(ret, "%02X%02X%02X%02X", ip[0], ip[1], ip[2], ip[3]);
}
void hex_to_ip(char *address, char *ret) //TODO Move to the common.c
{
int i;
int ip[4] = {0};
sscanf(address, "%2x%2x%2x%2x", &(ip[0]), &(ip[1]), &(ip[2]), &(ip[3]));
if (htonl(13) == 13) {
sprintf(ret, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
} else {
sprintf(ret, "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]);
}
}
void parse_proc_route_line(char *line, struct proc_routing *proute)
{
char *pch, *spch;
proute->iface = strtok_r(line, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->destination);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->gateway);
proute->flags = strtok_r(NULL, " \t", &spch);
proute->refcnt = strtok_r(NULL, " \t", &spch);
proute->use = strtok_r(NULL, " \t", &spch);
proute->metric = strtok_r(NULL, " \t", &spch);
pch = strtok_r(NULL, " \t", &spch);
hex_to_ip(pch, proute->mask);
proute->mtu = strtok_r(NULL, " \t", &spch);
proute->window = strtok_r(NULL, " \t", &spch);
proute->irtt = strtok_r(NULL, " \t\n\r", &spch);
}
bool is_proute_static(struct proc_routing *proute)
{
char *mask;
@ -228,9 +225,9 @@ struct uci_section *update_route_dynamic_section(struct proc_routing *proute)
return s;
}
int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection == NULL) {
*value = "1";
@ -244,11 +241,11 @@ int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
bool b;
char *pch;
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -272,9 +269,9 @@ int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, int acti
return 0;
}
int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection == NULL) {
*value = "Enabled";
@ -291,9 +288,9 @@ int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "target", value);
@ -308,9 +305,9 @@ int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -322,9 +319,9 @@ int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, int acti
return 0;
}
int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "netmask", value);
@ -339,9 +336,9 @@ int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, char *
return 0;
}
int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -353,21 +350,21 @@ int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, int ac
return 0;
}
int get_router_ipv4forwarding_src_address(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_src_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0.0.0.0";
return 0;
}
int get_router_ipv4forwarding_src_mask(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_src_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "0.0.0.0";
return 0;
}
int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "gateway", value);
@ -382,9 +379,9 @@ int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, char
return 0;
}
int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -396,13 +393,13 @@ int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, int a
return 0;
}
char *get_router_ipv4forwarding_interface(struct dmctx *ctx)
char *get_router_ipv4forwarding_interface(struct dmctx *ctx, void *data, char *instance)
{
json_object *res;
char *val, *bval, *ifname, *device;
char *name;
struct uci_section *ss;
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "interface", &val);
@ -432,14 +429,14 @@ char *get_router_ipv4forwarding_interface(struct dmctx *ctx)
return "";
}
int get_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *iface, *linker;
iface = get_router_ipv4forwarding_interface(ctx);
iface = get_router_ipv4forwarding_interface(ctx, data, instance);
if (iface[0] != '\0') {
dmasprintf(&linker, "%s", iface);
adm_entry_get_linker_param(DMROOT"IP.Interface.", linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", DMROOT, dm_delim, dm_delim, dm_delim), linker, value); // MEM WILL BE FREED IN DMMEMCLEAN
if (*value == NULL)
*value = "";
dmfree(linker);
@ -447,16 +444,16 @@ int get_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct
return 0;
}
int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char *linker;
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
adm_entry_get_linker_value(value, &linker);
adm_entry_get_linker_value(ctx, value, &linker);
if (linker) {
dmuci_set_value_by_section(routeargs->routefwdsection, "interface", linker);
dmfree(linker);
@ -466,10 +463,10 @@ int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct
return 0;
}
int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *name;
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
if (routeargs->routefwdsection != NULL) {
dmuci_get_value_by_section_string(routeargs->routefwdsection, "metric", value);
@ -484,9 +481,9 @@ int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, char **v
return 0;
}
int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
struct routingfwdargs *routeargs = (struct routingfwdargs *)ctx->args;
struct routingfwdargs *routeargs = (struct routingfwdargs *)data;
switch (action) {
case VALUECHECK:
@ -498,7 +495,7 @@ int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, int acti
return 0;
}
int get_router_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
int get_router_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
struct uci_section *s;
int cnt = 0;
@ -535,48 +532,56 @@ int get_router_nbr_entry(char *refparam, struct dmctx *ctx, char **value)
* SET AND GET ALIAS FOR ROUTER OBJ
/*************************************************************/
int get_router_alias(char *refparam, struct dmctx *ctx, char **value)
int get_router_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(cur_router_args.router_section, "router_alias", value);
dmuci_get_value_by_section_string((struct uci_section *)data, "router_alias", value);
return 0;
}
int set_router_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
dmuci_set_value_by_section(cur_router_args.router_section, "router_alias", value);
dmuci_set_value_by_section((struct uci_section *)data, "router_alias", value);
return 0;
}
return 0;
}
int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, char **value)
int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
*value = "";
if (cur_routefwdargs.routefwdsection) dmuci_get_value_by_section_string(cur_routefwdargs.routefwdsection, "routealias", value);
if (((struct routingfwdargs *)data)->routefwdsection) dmuci_get_value_by_section_string(((struct routingfwdargs *)data)->routefwdsection, "routealias", value);
return 0;
}
int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, int action, char *value)
int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
switch (action) {
case VALUECHECK:
return 0;
case VALUESET:
if (cur_routefwdargs.routefwdsection) dmuci_set_value_by_section(cur_routefwdargs.routefwdsection, "routealias", value);
if (((struct routingfwdargs *)data)->routefwdsection) dmuci_set_value_by_section(((struct routingfwdargs *)data)->routefwdsection, "routealias", value);
return 0;
}
return 0;
}
char *get_routing_perm(char *refparam, struct dmctx *dmctx, void *data, char *instance)
{
return ((struct routingfwdargs *)data)->permission;
}
struct dm_permession_s DMRouting = {"0", &get_routing_perm};
/*************************************************************
* SUB ENTRIES
/*************************************************************/
inline int entry_router_ipv4forwarding(struct dmctx *ctx, char *irouter)
int browseIPv4ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
char *iroute = NULL, *iroute_last = NULL;
char *permission = "1";
@ -585,15 +590,19 @@ inline int entry_router_ipv4forwarding(struct dmctx *ctx, char *irouter)
char line[MAX_PROC_ROUTING];
struct proc_routing proute = {0};
bool find_max = true;
struct routingfwdargs curr_routefwdargs = {0};
uci_foreach_sections("network", "route", s) {
init_args_ipv4forward(ctx, s, "1", NULL, ROUTE_STATIC);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_router_ipv4forwarding_instance, ctx, irouter, iroute, permission);
init_args_ipv4forward(&curr_routefwdargs, s, "1", NULL, ROUTE_STATIC);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
uci_foreach_sections("network", "route_disabled", s) {
init_args_ipv4forward(ctx, s, "1", NULL, ROUTE_DISABLED);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_router_ipv4forwarding_instance, ctx, irouter, iroute, permission);
init_args_ipv4forward(&curr_routefwdargs, s, "1", NULL, ROUTE_DISABLED);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias, 4, s, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
fp = fopen(ROUTING_FILE, "r");
if ( fp != NULL)
@ -607,72 +616,27 @@ inline int entry_router_ipv4forwarding(struct dmctx *ctx, char *irouter)
if (is_proute_static(&proute))
continue;
ss = update_route_dynamic_section(&proute);
init_args_ipv4forward(ctx, ss, "0", &proute, ROUTE_DYNAMIC);
iroute = handle_update_instance(1, ctx, &iroute_last, forwarding_update_instance_alias, 4, ss, "routeinstance", "routealias", &find_max);
SUBENTRY(entry_router_ipv4forwarding_instance, ctx, irouter, iroute, "0");
init_args_ipv4forward(&curr_routefwdargs, ss, "0", &proute, ROUTE_DYNAMIC);
iroute = handle_update_instance(1, dmctx, &iroute_last, forwarding_update_instance_alias, 4, ss, "routeinstance", "routealias", &find_max);
if (DM_LINK_INST_OBJ(dmctx, parent_node, (void *)&curr_routefwdargs, iroute) == DM_STOP)
goto end;
}
fclose(fp) ;
}
end:
return 0;
}
inline int entry_method_router(struct dmctx *ctx)
int browseRouterInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance)
{
struct uci_section *s = NULL;
char *r = NULL, *r_last = NULL;
update_section_list(DMMAP,"router", NULL, 1, NULL, NULL, NULL, NULL, NULL);
uci_path_foreach_sections(icwmpd, "dmmap", "router", s) {
init_router_args(ctx, s);
r = handle_update_instance(1, ctx, &r_last, update_instance_alias_icwmpd, 3, s, "router_instance", "router_alias");
SUBENTRY(entry_method_root_router_sub, ctx, r);
return 0;
}
return FAULT_9005;
}
inline int entry_router_ipv4forwarding_instance(struct dmctx *ctx, char *irouter, char *iroute, char *permission)
{
IF_MATCH(ctx, DMROOT"Routing.Router.%s.IPv4Forwarding.%s.", irouter, iroute) {
DMOBJECT(DMROOT"Routing.Router.%s.IPv4Forwarding.%s.", ctx, "0", 1, NULL, NULL, NULL, irouter, iroute);
DMPARAM("Enable", ctx, permission, get_router_ipv4forwarding_enable, set_router_ipv4forwarding_enable, "xsd:boolean", 0, 1, UNDEF, NULL);
DMPARAM("Status", ctx, "0", get_router_ipv4forwarding_status, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Alias", ctx, "1", get_router_ipv4forwarding_alias, set_router_ipv4forwarding_alias, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DestIPAddress", ctx, permission, get_router_ipv4forwarding_destip, set_router_ipv4forwarding_destip, NULL, 0, 1, UNDEF, NULL);
DMPARAM("DestSubnetMask", ctx, permission, get_router_ipv4forwarding_destmask, set_router_ipv4forwarding_destmask, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceIPAddress", ctx, "0", get_router_ipv4forwarding_src_address, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("SourceSubnetMask", ctx, "0", get_router_ipv4forwarding_src_mask, NULL, NULL, 0, 1, UNDEF, NULL);
DMPARAM("GatewayIPAddress", ctx, permission, get_router_ipv4forwarding_gatewayip, set_router_ipv4forwarding_gatewayip, NULL, 0, 1, UNDEF, NULL);
DMPARAM("Interface", ctx, permission, get_router_ipv4forwarding_interface_linker_parameter, set_router_ipv4forwarding_interface_linker_parameter, NULL, 0, 1, UNDEF, NULL);
DMPARAM("ForwardingMetric", ctx, permission, get_router_ipv4forwarding_metric, set_router_ipv4forwarding_metric, NULL, 0, 1, UNDEF, NULL);
return 0;
}
return FAULT_9005;
}
int entry_method_root_routing(struct dmctx *ctx)
{
IF_MATCH(ctx, DMROOT"Routing.") {
DMOBJECT(DMROOT"Routing.", ctx, "0", 1, NULL, NULL, NULL);
DMOBJECT(DMROOT"Routing.Router.", ctx, "0", 1, NULL, NULL, NULL);
DMPARAM("RouterNumberOfEntries", ctx, "0", get_router_nbr_entry, NULL, "xsd:unsignedInt", 0, 1, UNDEF, NULL);
SUBENTRY(entry_method_router, ctx);
return 0;
}
return FAULT_9005;
}
int entry_method_root_router_sub(struct dmctx *ctx, char *irouter)
{
IF_MATCH(ctx, DMROOT"Routing.Router.%s.", irouter) {
DMOBJECT(DMROOT"Routing.Router.%s.", ctx, "0", 1, NULL, NULL, NULL, irouter);
DMPARAM("Alias", ctx, "1", get_router_alias, set_router_alias, NULL, 0, 1, UNDEF, NULL); //TODO
DMOBJECT(DMROOT"Routing.Router.%s.IPv4Forwarding.", ctx, "0", 1, NULL, NULL, NULL, irouter);
SUBENTRY(entry_router_ipv4forwarding, ctx, irouter);
r = handle_update_instance(1, dmctx, &r_last, update_instance_alias_icwmpd, 3, s, "router_instance", "router_alias");
DM_LINK_INST_OBJ(dmctx, parent_node, (void *)s, r);
break;
}
return 0;
}

View file

@ -1,35 +1,37 @@
#ifndef __ROUTING_H
#define __ROUTING_H
#define ROUTING_FILE "/proc/net/route"
#define MAX_PROC_ROUTING 256
struct proc_routing {
char *iface;
char *flags;
char *refcnt;
char *use;
char *metric;
char *mtu;
char *window;
char *irtt;
char destination[16];
char gateway[16];
char mask[16];
};
extern struct dm_permession_s DMRouting;
struct routingfwdargs
{
char *permission;
struct uci_section *routefwdsection;
struct proc_routing *proute;
int type;
};
extern DMLEAF tRouterInstParam[];
extern DMLEAF tIPv4ForwardingParam[];
extern DMOBJ tRoutingObj[];
extern DMLEAF tRoutingParam[];
extern DMOBJ tRouterObj[];
struct router_args
{
struct uci_section *router_section;
};
int browseRouterInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseIPv4ForwardingInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int entry_method_root_routing(struct dmctx *ctx);
int get_router_nbr_entry(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_src_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_src_mask(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_router_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_router_ipv4forwarding_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_destip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_destmask(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_gatewayip(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_interface_linker_parameter(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_ipv4forwarding_metric(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_router_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

File diff suppressed because it is too large Load diff

View file

@ -18,11 +18,6 @@ struct dsl_line_args
char *type;
};
struct dsl_channel_args
{
struct uci_section *chanel_sec;
};
struct atm_args
{
struct uci_section *atm_sec;
@ -33,8 +28,80 @@ struct ptm_args
struct uci_section *ptm_sec;
char *ifname;
};
int entry_method_root_wan_dsl(struct dmctx *ctx);
int entry_method_root_wan_ptm(struct dmctx *ctx);
int entry_method_root_wan_atm(struct dmctx *ctx);
extern DMOBJ tDslObj[];
extern DMOBJ tAtmObj[];
extern DMOBJ tPtmObj[];
extern DMOBJ tAtmLinkStatsObj[];
extern DMOBJ tPtmLinkStatsObj[];
extern DMLEAF tDslLineParams[];
extern DMLEAF tDslChanelParams[] ;
extern DMLEAF tAtmLineParams[];
extern DMLEAF tAtmLinkStatsParams[] ;
extern DMLEAF tPtmLinkStatsParams[];
extern DMLEAF tPtmLineParams[];
int browseDslLineInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseDslChannelInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseAtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browsePtmLinkInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_atm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_atm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int add_ptm_link(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_ptm_link(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_dsl_link_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_line_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_standard_inuse(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vdsl_link_supported_profile(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_vdsl_link_profile_inuse(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_downstreammaxrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_downstreamattenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_downstreamnoisemargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_upstreammaxrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_upstreamattenuation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_link_upstreamnoisemargin(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_channel_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_channel_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_channel_downstreamcurrrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_dsl_channel_upstreamcurrrate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_channel_annexm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_channel_supported_encap(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_atm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_link_name(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_bytes_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_bytes_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_pack_sent(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ptm_stats_pack_received(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_dsl_link_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_channel_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_channel_annexm_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_link_type(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_destination_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_atm_encapsulation(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ptm_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_dsl_line_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_dsl_channel_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_atm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
int get_ptm_linker(char *refparam, struct dmctx *dmctx, void *data, char *instance, char **linker);
#endif

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,103 @@ struct wifi_ssid_args
char *ifname;
char *linker;
};
int entry_method_root_Wifi(struct dmctx *ctx);
struct wifi_acp_args
{
struct uci_section *wifi_acp_sec;
char *ifname;
};
extern DMOBJ tWifiObj[];
extern DMLEAF tWifiParams[];
extern DMOBJ tWifiRadioStatsObj[];
extern DMOBJ tAcessPointSecurityObj[];
extern DMOBJ tWifiSsidStatsObj[];
extern DMLEAF tWifiAcessPointParams[];
extern DMLEAF tWifiSsidParams[];
extern DMLEAF tWifiRadioParams[];
extern DMLEAF tWifiAcessPointSecurityParams[];
extern DMLEAF tWifiRadioStatsParams[];
extern DMLEAF tWifiSsidStatsParams[];
int browseWifiSsidInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWifiAccessPointInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int browseWifiRadioInst(struct dmctx *dmctx, DMNODE *parent_node, void *prev_data, char *prev_instance);
int add_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char **instancepara);
int delete_wifi_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, unsigned char del_action);
int get_wifi_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_wifi_bandsteering_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int get_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_max_bit_rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_frequency(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_supported_frequency_bands(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_possible_channels(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_radio_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_bssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_tx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_rx_bytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_tx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ssid_statistics_rx_packets(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wifi_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_ap_ssid_ref(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_supported_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_Wifi_Radio(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int get_linker_Wifi_Ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
int set_radio_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_max_bit_rate(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_operating_channel_bandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_channel(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_radio_auto_channel_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ssid_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_ssid_lower_layer(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_alias(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wifi_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wlan_ssid_advertisement_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_maxassoc(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_control_enable(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_modes(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_wepkey(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_shared_key(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_passphrase(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_rekey_interval(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_ip_address(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_server_port(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_access_point_security_radius_secret(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
int set_wmm_enabled(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action);
#endif

View file

@ -26,7 +26,7 @@
#define UBUS_BUFFEER_SIZE 1024 * 8
struct dmubus_ctx dmubus_ctx;
#if 0
#if DM_USE_LIBUBUS
struct ubus_context *ubus_ctx;
static int timeout = 1000;
@ -66,7 +66,7 @@ static inline int ubus_arg_cmp(struct ubus_arg *src_args, int src_size, struct u
return 0;
}
#if 0
#if DM_USE_LIBUBUS
static void receive_call_result_data(struct ubus_request *req, int type, struct blob_attr *msg)
{
if (!msg)
@ -87,6 +87,7 @@ static void receive_call_result_data(struct ubus_request *req, int type, struct
int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_args_size)
{
#if !DM_USE_LIBUBUS
char bufargs[256], *p;
int i, r;
p = bufargs;
@ -95,12 +96,8 @@ int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_arg
sprintf(p, "{");
for (i = 0; i < u_args_size; i++) {
p += strlen(p);
if (i == 0 && u_args[i].type == 1)
sprintf(p, "\"%s\": %s", u_args[i].key, u_args[i].val);
else if (i == 0 && u_args[i].type == 0)
if (i == 0)
sprintf(p, "\"%s\": \"%s\"", u_args[i].key, u_args[i].val);
else if (i != 0 && u_args[i].type == 1)
sprintf(p, ", \"%s\": %s", u_args[i].key, u_args[i].val);
else
sprintf(p, ", \"%s\": \"%s\"", u_args[i].key, u_args[i].val);
}
@ -112,10 +109,40 @@ int dmubus_call_set(char *obj, char *method, struct ubus_arg u_args[], int u_arg
DMCMD("ubus", 6, "-S", "-t", "1", "call", obj, method); //TODO wait to fix uloop ubus freeze
}
return 0;
#else
struct blob_buf b = {0};
uint32_t id;
int ret;
json_res = NULL;
ubus_ctx = ubus_connect(ubus_socket);
if (!ubus_ctx)
return 0;
blob_buf_init(&b, 0);
int i=0;
for (i = 0; i < u_args_size; i++) {
if (!dmblobmsg_json_object_from_uargs(&b, u_args[i].key, u_args[i].val))
goto end_error;
}
ret = ubus_lookup_id(ubus_ctx, obj, &id);
ubus_invoke(ubus_ctx, id, method, b.head, receive_call_result_data, NULL, timeout);
blob_buf_free(&b);
if (json_res != NULL) {
json_object_put(json_res);
json_res = NULL;
}
return 0;
end_error:
blob_buf_free(&b);
return NULL;
#endif
}
static inline json_object *ubus_call_req(char *obj, char *method, struct ubus_arg u_args[], int u_args_size)
{
#if !DM_USE_LIBUBUS
json_object *res = NULL;
char bufres[UBUS_BUFFEER_SIZE], bufargs[256], *p;
int i, pp = 0, r;
@ -150,7 +177,7 @@ static inline json_object *ubus_call_req(char *obj, char *method, struct ubus_ar
}
return res;
#if 0
#else
struct blob_buf b = {0};
uint32_t id;
int ret;
@ -278,4 +305,3 @@ void dmubus_ctx_free(struct dmubus_ctx *ctx)
dmfree(i);
}
}

13
event.c
View file

@ -26,6 +26,7 @@
#include "dmcwmp.h"
#include "dmentry.h"
#include "deviceinfo.h"
#include "config.h"
LIST_HEAD(list_value_change);
LIST_HEAD(list_lw_value_change);
@ -296,9 +297,9 @@ void cwmp_add_notification(void)
cwmp->count_handle_notify = 0;
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
list_for_each_entry(p, &list_enabled_notify, list) {
dm_ctx_init_sub(&dmctx);
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
initiate = true;
fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, p->name, NULL, NULL);
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
@ -317,7 +318,7 @@ void cwmp_add_notification(void)
//dm_ctx_init(&dmctx);
list_for_each_entry(p, &list_enabled_lw_notify, list) {
if (!initiate || i != 0)
dm_ctx_init_sub(&dmctx);
dm_ctx_init_sub(&dmctx, DM_CWMP, cwmp_main.conf.amd_version, cwmp_main.conf.instance_mode);
i++;
if (!conf->lw_notification_enable)
break;
@ -334,7 +335,7 @@ void cwmp_add_notification(void)
}
dm_ctx_clean_sub(&dmctx);
}
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
if (lw_isactive) {
cwmp_lwnotification();
}
@ -441,6 +442,7 @@ int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
int error,cmp=0;
struct event_container *event_container;
struct session *session;
char buf[64] = "";
error = cwmp_load_saved_session(cwmp, &acsurl, ACS);
@ -484,8 +486,9 @@ int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
sprintf(buf, "%sManagementServer.URL", DMROOT);
add_dm_parameter_tolist(&(event_container->head_dm_parameter),
DMROOT"ManagementServer.URL", NULL, NULL);
buf, NULL, NULL);
cwmp_save_event_container (cwmp,event_container);
save_acs_bkp_config(cwmp);
cwmp_scheduleInform_remove_all();

View file

@ -31,6 +31,7 @@
#include "cwmp.h"
#include "xml.h"
#include "log.h"
#include "dmcwmp.h"
#include <stdarg.h>
static int pid;
@ -118,7 +119,7 @@ static void external_read_pipe_input(int (*external_handler)(char *msg))
value = c;
} else {
if (!value) continue;
if (strcmp(value, "icwmp>")==0) {
if (strcmp(value, DM_PROMPT)==0) {
FREE(value);
break;
}

303
http.c
View file

@ -25,6 +25,7 @@
#include "cwmp.h"
#include "log.h"
#include "xml.h"
#include "config.h"
#include <libubox/uloop.h>
#include <libubox/usock.h>
@ -256,25 +257,25 @@ http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len,char **msg_i
if (!strlen(*msg_in))
FREE(*msg_in);
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
if (ip && ip[0] != '\0') {
if (!ip_acs || strcmp(ip_acs, ip) != 0) {
FREE(ip_acs);
ip_acs = strdup(ip);
if (cwmp->conf.ipv6_enable) {
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip);
if (ip && ip[0] != '\0') {
if (!ip_acs || strcmp(ip_acs, ip) != 0) {
FREE(ip_acs);
ip_acs = strdup(ip);
if (cwmp->conf.ipv6_enable) {
tmp = inet_pton(AF_INET, ip, buf);
if (tmp == 1)
tmp = 0;
else
tmp = inet_pton(AF_INET6, ip, buf);
}
external_init();
external_simple("allow_cr_ip", ip_acs, tmp);
external_exit();
}
}
if (tmp == 1)
tmp = 0;
else
tmp = inet_pton(AF_INET6, ip, buf);
}
external_init();
external_simple("allow_cr_ip", ip_acs, tmp);
external_exit();
}
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
if(http_code == 204)
{
CWMP_LOG (INFO,"Receive HTTP 204 No Content");
@ -348,165 +349,165 @@ error:
void http_success_cr()
{
struct event_container *event_container;
CWMP_LOG(INFO,"Connection Request thread: add connection request event in the queue");
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
event_container = cwmp_add_event_container (&cwmp_main, EVENT_IDX_6CONNECTION_REQUEST, "");
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));
pthread_cond_signal(&(cwmp_main.threshold_session_send));
struct event_container *event_container;
CWMP_LOG(INFO,"Connection Request thread: add connection request event in the queue");
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
event_container = cwmp_add_event_container (&cwmp_main, EVENT_IDX_6CONNECTION_REQUEST, "");
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));
pthread_cond_signal(&(cwmp_main.threshold_session_send));
}
static void http_cr_new_client(int client, bool service_available)
{
FILE *fp;
char buffer[BUFSIZ];
int8_t auth_status = 0;
FILE *fp;
char buffer[BUFSIZ];
int8_t auth_status = 0;
fp = fdopen(client, "r+");
fp = fdopen(client, "r+");
while (fgets(buffer, sizeof(buffer), fp)) {
if (!strncasecmp(buffer, "Authorization: Digest ", strlen("Authorization: Digest "))) {
char *username = cwmp_main.conf.cpe_userid;
char *password = cwmp_main.conf.cpe_passwd;
while (fgets(buffer, sizeof(buffer), fp)) {
if (!strncasecmp(buffer, "Authorization: Digest ", strlen("Authorization: Digest "))) {
char *username = cwmp_main.conf.cpe_userid;
char *password = cwmp_main.conf.cpe_passwd;
if (!username || !password) {
// if we dont have username or password configured proceed with connecting to ACS
service_available = false;
goto http_end;
}
if (!username || !password) {
// if we dont have username or password configured proceed with connecting to ACS
service_available = false;
goto http_end;
}
if (http_digest_auth_check("GET", "/", buffer + strlen("Authorization: Digest "), REALM, username, password, 300) == MHD_YES)
auth_status = 1;
else
auth_status = 0;
}
if (http_digest_auth_check("GET", "/", buffer + strlen("Authorization: Digest "), REALM, username, password, 300) == MHD_YES)
auth_status = 1;
else
auth_status = 0;
}
if (buffer[0] == '\r' || buffer[0] == '\n') {
/* end of http request (empty line) */
goto http_end;
}
}
if(!service_available) {
goto http_end;
}
goto http_done;
if (buffer[0] == '\r' || buffer[0] == '\n') {
/* end of http request (empty line) */
goto http_end;
}
}
if(!service_available) {
goto http_end;
}
goto http_done;
http_end:
if (!service_available) {
CWMP_LOG (INFO,"Receive Connection Request: Return 503 Service Unavailable");
fputs("HTTP/1.1 503 Service Unavailable\r\n", fp);
fputs("Connection: close\r\n", fp);
fputs("Content-Length: 0\r\n", fp);
} else if (auth_status) {
CWMP_LOG (INFO,"Receive Connection Request: success authentication");
fputs("HTTP/1.1 200 OK\r\n", fp);
fputs("Connection: close\r\n", fp);
fputs("Content-Length: 0\r\n", fp);
http_success_cr();
} else {
CWMP_LOG (INFO,"Receive Connection Request: Return 401 Unauthorized");
fputs("HTTP/1.1 401 Unauthorized\r\n", fp);
fputs("Connection: close\r\n", fp);
http_digest_auth_fail_response(fp, "GET", "/", REALM, OPAQUE);
fputs("\r\n", fp);
}
fputs("\r\n", fp);
http_end:
if (!service_available) {
CWMP_LOG (INFO,"Receive Connection Request: Return 503 Service Unavailable");
fputs("HTTP/1.1 503 Service Unavailable\r\n", fp);
fputs("Connection: close\r\n", fp);
fputs("Content-Length: 0\r\n", fp);
} else if (auth_status) {
CWMP_LOG (INFO,"Receive Connection Request: success authentication");
fputs("HTTP/1.1 200 OK\r\n", fp);
fputs("Connection: close\r\n", fp);
fputs("Content-Length: 0\r\n", fp);
http_success_cr();
} else {
CWMP_LOG (INFO,"Receive Connection Request: Return 401 Unauthorized");
fputs("HTTP/1.1 401 Unauthorized\r\n", fp);
fputs("Connection: close\r\n", fp);
http_digest_auth_fail_response(fp, "GET", "/", REALM, OPAQUE);
fputs("\r\n", fp);
}
fputs("\r\n", fp);
http_done:
fclose(fp);
http_done:
fclose(fp);
}
void http_server_init(void)
{
struct sockaddr_in6 server = {0};
unsigned short cr_port;
struct sockaddr_in6 server = {0};
unsigned short cr_port;
for(;;) {
cr_port = (unsigned short) (cwmp_main.conf.connection_request_port);
unsigned short i = (DEFAULT_CONNECTION_REQUEST_PORT == cr_port)? 1 : 0;
//Create socket
cwmp_main.cr_socket_desc = socket(AF_INET6 , SOCK_STREAM , 0);
if (cwmp_main.cr_socket_desc == -1)
{
CWMP_LOG (ERROR,"Could not open server socket for Connection Requests, Error no is : %d, Error description is : %s", errno, strerror(errno));
sleep(1);
continue;
}
for(;;) {
cr_port = (unsigned short) (cwmp_main.conf.connection_request_port);
unsigned short i = (DEFAULT_CONNECTION_REQUEST_PORT == cr_port)? 1 : 0;
//Create socket
cwmp_main.cr_socket_desc = socket(AF_INET6 , SOCK_STREAM , 0);
if (cwmp_main.cr_socket_desc == -1)
{
CWMP_LOG (ERROR,"Could not open server socket for Connection Requests, Error no is : %d, Error description is : %s", errno, strerror(errno));
sleep(1);
continue;
}
fcntl(cwmp_main.cr_socket_desc, F_SETFD, fcntl(cwmp_main.cr_socket_desc, F_GETFD) | FD_CLOEXEC);
fcntl(cwmp_main.cr_socket_desc, F_SETFD, fcntl(cwmp_main.cr_socket_desc, F_GETFD) | FD_CLOEXEC);
int reusaddr = 1;
if (setsockopt(cwmp_main.cr_socket_desc, SOL_SOCKET, SO_REUSEADDR, &reusaddr, sizeof(int)) < 0)
{
CWMP_LOG (WARNING,"setsockopt(SO_REUSEADDR) failed");
}
int reusaddr = 1;
if (setsockopt(cwmp_main.cr_socket_desc, SOL_SOCKET, SO_REUSEADDR, &reusaddr, sizeof(int)) < 0)
{
CWMP_LOG (WARNING,"setsockopt(SO_REUSEADDR) failed");
}
//Prepare the sockaddr_in structure
server.sin6_family = AF_INET6;
server.sin6_addr=in6addr_any;
//Prepare the sockaddr_in structure
server.sin6_family = AF_INET6;
server.sin6_addr=in6addr_any;
for(;;i++) {
server.sin6_port = htons(cr_port);
//Bind
if( bind(cwmp_main.cr_socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
//print the error message
CWMP_LOG (ERROR,"Could not bind server socket on the port %d, Error no is : %d, Error description is : %s", cr_port, errno, strerror(errno));
cr_port = DEFAULT_CONNECTION_REQUEST_PORT + i;
CWMP_LOG (INFO,"Trying to use another connection request port: %d", cr_port);
continue;
}
break;
}
break;
}
char buf[64];
sprintf(buf,UCI_CPE_PORT_PATH"=%d", cr_port);
uci_set_state_value(buf);
connection_request_port_value_change(&cwmp_main, cr_port);
CWMP_LOG (INFO,"Connection Request server initiated with the port: %d", cr_port);
for(;;i++) {
server.sin6_port = htons(cr_port);
//Bind
if( bind(cwmp_main.cr_socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0)
{
//print the error message
CWMP_LOG (ERROR,"Could not bind server socket on the port %d, Error no is : %d, Error description is : %s", cr_port, errno, strerror(errno));
cr_port = DEFAULT_CONNECTION_REQUEST_PORT + i;
CWMP_LOG (INFO,"Trying to use another connection request port: %d", cr_port);
continue;
}
break;
}
break;
}
char buf[64];
sprintf(buf,UCI_CPE_PORT_PATH"=%d", cr_port);
uci_set_state_value(buf);
connection_request_port_value_change(&cwmp_main, cr_port);
CWMP_LOG (INFO,"Connection Request server initiated with the port: %d", cr_port);
}
void http_server_listen(void)
{
int client_sock , c;
static int cr_request = 0;
static time_t restrict_start_time = 0;
time_t current_time;
bool service_available;
struct sockaddr_in6 client;
int client_sock , c;
static int cr_request = 0;
static time_t restrict_start_time = 0;
time_t current_time;
bool service_available;
struct sockaddr_in6 client;
//Listen
listen(cwmp_main.cr_socket_desc , 3);
//Listen
listen(cwmp_main.cr_socket_desc , 3);
//Accept and incoming connection
c = sizeof(struct sockaddr_in);
while( (client_sock = accept(cwmp_main.cr_socket_desc, (struct sockaddr *)&client, (socklen_t*)&c)) )
{
current_time = time(NULL);
service_available = true;
if ((restrict_start_time==0) ||
((current_time-restrict_start_time) > CONNECTION_REQUEST_RESTRICT_PERIOD))
{
restrict_start_time = current_time;
cr_request = 1;
}
else
{
cr_request++;
if (cr_request > CONNECTION_REQUEST_RESTRICT_REQUEST)
{
restrict_start_time = current_time;
service_available = false;
}
}
http_cr_new_client(client_sock, service_available);
close(client_sock);
}
//Accept and incoming connection
c = sizeof(struct sockaddr_in);
while( (client_sock = accept(cwmp_main.cr_socket_desc, (struct sockaddr *)&client, (socklen_t*)&c)) )
{
current_time = time(NULL);
service_available = true;
if ((restrict_start_time==0) ||
((current_time-restrict_start_time) > CONNECTION_REQUEST_RESTRICT_PERIOD))
{
restrict_start_time = current_time;
cr_request = 1;
}
else
{
cr_request++;
if (cr_request > CONNECTION_REQUEST_RESTRICT_REQUEST)
{
restrict_start_time = current_time;
service_available = false;
}
}
http_cr_new_client(client_sock, service_available);
close(client_sock);
}
if (client_sock < 0)
{
CWMP_LOG(ERROR,"Could not accept connections for Connection Requests!");
return;
}
if (client_sock < 0)
{
CWMP_LOG(ERROR,"Could not accept connections for Connection Requests!");
return;
}
}

View file

@ -19,6 +19,7 @@
#include <pthread.h>
#include <microxml.h>
#include <libubox/list.h>
#include "dmcwmp.h"
#ifdef XMPP_ENABLE
#include <strophe.h>
#endif
@ -92,17 +93,6 @@ enum action
RESTART,
};
enum end_session {
END_SESSION_REBOOT = 1,
END_SESSION_EXTERNAL_ACTION = 1<<1,
END_SESSION_RELOAD = 1<<2,
END_SESSION_FACTORY_RESET = 1<<3,
END_SESSION_IPPING_DIAGNOSTIC = 1<<4,
END_SESSION_DOWNLOAD_DIAGNOSTIC = 1<<5,
END_SESSION_UPLOAD_DIAGNOSTIC = 1<<6,
END_SESSION_X_FACTORY_RESET_SOFT = 1<<7
};
enum cwmp_start {
CWMP_START_BOOT = 1,
CWMP_START_PERIODIC = 2
@ -307,7 +297,6 @@ typedef struct session {
mxml_node_t *body_in;
bool hold_request;
bool digest_auth;
unsigned int end_session;
int fault_code;
int error;
} session;
@ -319,18 +308,12 @@ typedef struct rpc {
struct list_head *list_set_value_fault;
} rpc;
typedef struct execute_end_session {
struct list_head list;
int action;
void *data;
void (*function)(int, void*);
} execute_end_session;
extern int ip_version;
#define ARRAYSIZEOF(a) (sizeof(a) / sizeof((a)[0]))
#ifndef FREE
#define FREE(x) do { free(x); x = NULL; } while (0)
#endif
extern struct list_head list_execute_end_session;
extern struct cwmp cwmp_main;
extern const struct EVENT_CONST_STRUCT EVENT_CONST [__EVENT_IDX_MAX];
extern struct list_head list_lw_value_change;
@ -338,13 +321,6 @@ extern struct list_head list_value_change;
extern pthread_mutex_t mutex_value_change;
int cwmp_config_reload(struct cwmp *cwmp);
int cwmp_move_session_to_session_send (struct cwmp *cwmp, struct session *session);
int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session);
int run_session_end_func (struct session *session);
int cwmp_move_session_to_session_queue (struct cwmp *cwmp, struct session *session);
int cwmp_session_destructor (struct cwmp *cwmp, struct session *session);
int dm_add_end_session(void(*function)(int a, void *d), int action, void *data);
int apply_end_session();
struct rpc *cwmp_add_session_rpc_cpe (struct session *session, int type);
struct session *cwmp_add_queue_session (struct cwmp *cwmp);
struct rpc *cwmp_add_session_rpc_acs (struct session *session, int type);
@ -355,24 +331,22 @@ void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_
void *thread_event_periodic (void *v);
void cwmp_add_notification(void);
int netlink_init(void);
int netlink_init_v6(void);
char * mix_get_time(void);
char * mix_get_time_of(time_t t_time);
void *thread_exit_program (void *v);
void connection_request_ip_value_change(struct cwmp *cwmp, int version);
void connection_request_port_value_change(struct cwmp *cwmp, int port);
void add_dm_parameter_tolist(struct list_head *head, char *param_name, char *param_data, char *param_type);
void cwmp_set_end_session (unsigned int end_session_flag);
void *thread_handle_notify(void *v);
int zlib_compress (char *message, unsigned char **zmsg, int *zlen, int type);
int cwmp_get_int_event_code(char *code);
int cwmp_apply_acs_changes ();
int cwmp_dm_ctx_init(struct cwmp *cwmp, struct dmctx *ctx);
int cwmp_dm_ctx_clean(struct cwmp *cwmp, struct dmctx *ctx);
int cwmp_apply_acs_changes();
int cwmp_move_session_to_session_send (struct cwmp *cwmp, struct session *session);
int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session);
int run_session_end_func (struct session *session);
int cwmp_move_session_to_session_queue (struct cwmp *cwmp, struct session *session);
int cwmp_session_destructor (struct cwmp *cwmp, struct session *session);
int cwmp_init(int argc, char** argv,struct cwmp *cwmp);
int cwmp_config_reload(struct cwmp *cwmp);
int uci_get_value(char *cmd,char **value);
int uci_set_state_value(char *cmd);
int uci_get_state_value(char *cmd,char **value);
int save_acs_bkp_config(struct cwmp *cwmp);
int get_instance_mode_config();
int get_amd_version_config();
#endif /* _CWMP_H__ */

View file

@ -10,14 +10,6 @@
#ifndef __DIAGNOSTIC__H
#define __DIAGNOSTIC__H
#define FUNCTION_PATH "/usr/share/icwmp/functions/ipping_launch"
#define DOWNLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/download_launch"
#define DOWNLOAD_DUMP_FILE "/tmp/download_dump"
#define IPPING_STOP DMCMD("/bin/sh", 2, FUNCTION_PATH, "stop");
#define DOWNLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, DOWNLOAD_DIAGNOSTIC_PATH, "stop");
#define UPLOAD_DIAGNOSTIC_PATH "/usr/share/icwmp/functions/upload_launch"
#define UPLOAD_DUMP_FILE "/tmp/upload_dump"
#define UPLOAD_DIAGNOSTIC_STOP DMCMD("/bin/sh", 2, UPLOAD_DIAGNOSTIC_PATH, "stop");
#define default_date_format "AAAA-MM-JJTHH:MM:SS.000000Z"
#define default_date_size sizeof(default_date_format) + 1
#define FTP_SIZE_RESPONSE "213"

View file

@ -68,9 +68,11 @@ static inline void trace_empty_func()
#if TRACE_TYPE == 2
#define TRACE(MESSAGE,args...) do { \
const char *A[] = {MESSAGE}; \
printf("TRACE: %s %s %d\n",__FUNCTION__,__FILE__,__LINE__); fflush(stdout);\
fprintf(stderr, "TRACE: %s %s %d ",__FUNCTION__,__FILE__,__LINE__); \
if(sizeof(A) > 0) \
printf(*A,##args); \
fprintf(stderr, *A,##args); \
fprintf(stderr, "\n"); \
fflush(stderr); \
} while(0)
#elif TRACE_TYPE == 1
#define TRACE(MESSAGE, ...) printf(MESSAGE, ## __VA_ARGS__)

View file

@ -50,8 +50,8 @@ enum rpc_cpe_methods_idx {
RPC_CPE_SCHEDULE_DOWNLOAD,
RPC_CPE_CHANGE_DU_STATE,
RPC_CPE_CANCEL_TRANSFER,
RPC_CPE_FAULT,
RPC_CPE_X_FACTORY_RESET_SOFT,
RPC_CPE_FAULT,
__RPC_CPE_MAX
};
@ -114,13 +114,6 @@ enum {
FAULT_CPE_TYPE_SERVER
};
enum {
AMD_1 = 1,
AMD_2,
AMD_3,
AMD_4,
AMD_5,
};
struct rpc_cpe_method {
const char *name;
int (*handler)(struct session *session, struct rpc *rpc);

View file

@ -32,6 +32,7 @@
#include "cwmp.h"
#include "http.h"
#include "log.h"
#include "config.h"
static void netlink_new_msg(struct uloop_fd *ufd, unsigned events);
static void netlink_new_msg_v6(struct uloop_fd *ufd, unsigned events);

View file

@ -365,7 +365,7 @@ handle_action() {
if [ "$action" = "factory_reset_soft" ]; then
/sbin/defaultreset -s wifi fw_redirect fw_parental passwd_user ice
fi
if [ "$action" = "reboot" ]; then
sync
reboot

15
ubus.c
View file

@ -21,6 +21,7 @@
#include "log.h"
#include "wepkey.h"
#include "dmentry.h"
#include "netlink.h"
static struct ubus_context *ctx = NULL;
static struct blob_buf b;
@ -32,8 +33,6 @@ static const char *arr_session_status[] = {
[SESSION_SUCCESS] = "success",
};
static const struct blobmsg_policy notify_policy[] = {};
static int
cwmp_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
@ -102,7 +101,6 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
}
else {
pthread_mutex_lock (&(cwmp_main.mutex_session_queue));
dm_global_init();
cwmp_apply_acs_changes();
pthread_mutex_unlock (&(cwmp_main.mutex_session_queue));
blobmsg_add_u32(&b, "status", 0);
@ -183,9 +181,6 @@ static inline time_t get_session_status_next_time() {
return ntime;
}
static const struct blobmsg_policy status_policy[] = {
};
static int
cwmp_handle_status(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
@ -304,9 +299,9 @@ cwmp_handle_inform(struct ubus_context *ctx, struct ubus_object *obj,
}
static const struct ubus_method freecwmp_methods[] = {
UBUS_METHOD("notify", cwmp_handle_notify, notify_policy),
UBUS_METHOD_NOARG("notify", cwmp_handle_notify),
UBUS_METHOD("command", cwmp_handle_command, command_policy),
UBUS_METHOD("status", cwmp_handle_status, status_policy),
UBUS_METHOD_NOARG("status", cwmp_handle_status),
UBUS_METHOD("inform", cwmp_handle_inform, inform_policy),
};
@ -330,8 +325,8 @@ ubus_init(struct cwmp *cwmp)
}
if (cwmp->conf.ipv6_enable) {
if (netlink_init_v6()) {
CWMP_LOG(ERROR,"netlink initialization failed");
if (netlink_init_v6()) {
CWMP_LOG(ERROR,"netlink initialization failed");
}
}
ctx = ubus_connect(cwmp->conf.ubus_socket);

120
xml.c
View file

@ -631,7 +631,7 @@ int xml_prepare_lwnotification_message(char **msg_out)
b = mxmlFindElement(tree, tree, "CN", NULL, NULL, MXML_DESCEND);
if (!b) goto error;
c = calculate_lwnotification_cnonce();
c = (char*)calculate_lwnotification_cnonce();
b = mxmlNewText(b, 0,c);
free(c);
if (!b) goto error;
@ -695,7 +695,7 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
struct list_head *ilist,*jlist;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
if (session==NULL || this==NULL)
{
@ -797,11 +797,11 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
free(c);
session->tree_out = tree;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
return -1;
}
@ -1120,7 +1120,7 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
b = session->body_in;
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
@ -1198,17 +1198,17 @@ int cwmp_handle_rpc_cpe_get_parameter_values(struct session *session, struct rpc
FREE(c);
#endif
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1226,7 +1226,7 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
NULL, NULL, MXML_DESCEND);
@ -1306,17 +1306,17 @@ int cwmp_handle_rpc_cpe_get_parameter_names(struct session *session, struct rpc
FREE(c);
#endif
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1333,7 +1333,7 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
int counter = 0, fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
b = session->body_in;
n = mxmlFindElement(session->tree_out, session->tree_out, "soap_env:Body",
@ -1415,17 +1415,17 @@ int cwmp_handle_rpc_cpe_get_parameter_attributes(struct session *session, struct
FREE(c);
#endif
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1460,7 +1460,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
int fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
b = mxmlFindElement(session->body_in, session->body_in, "ParameterList", NULL, NULL, MXML_DESCEND);
if(!b) {
@ -1554,18 +1554,18 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct session *session, struct rpc
if (!b) goto fault;
success:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
rpc->list_set_value_fault = &dmctx.list_fault_param;
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1580,7 +1580,7 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
int fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
/* handle cwmp:SetParameterAttributes */
if (asprintf(&c, "%s:%s", ns.cwmp, "SetParameterAttributes") == -1)
@ -1658,17 +1658,17 @@ int cwmp_handle_rpc_cpe_set_parameter_attributes(struct session *session, struct
if (!b) goto fault;
end_success:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1686,7 +1686,7 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
int fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
b = session->body_in;
while (b) {
@ -1737,17 +1737,17 @@ int cwmp_handle_rpc_cpe_add_object(struct session *session, struct rpc *rpc)
if (!b) goto fault;
success:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1764,7 +1764,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
int fault_code = FAULT_CPE_INTERNAL_ERROR;
struct dmctx dmctx = {0};
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
b = session->body_in;
while (b) {
@ -1809,17 +1809,17 @@ int cwmp_handle_rpc_cpe_delete_object(struct session *session, struct rpc *rpc)
if (!b) goto fault;
success:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
fault:
if (cwmp_create_fault_message(session, rpc, fault_code))
goto error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return 0;
error:
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
return -1;
}
@ -1907,6 +1907,10 @@ error:
return -1;
}
/*
* [RPC CPE]: X_FactoryResetSoft
*/
int cwmp_handle_rpc_cpe_x_factory_reset_soft(struct session *session, struct rpc *rpc){
mxml_node_t *b;
@ -2389,13 +2393,13 @@ int cwmp_launch_upload(struct upload *pupload, struct transfer_complete **ptrans
bkp_session_delete_upload(pupload);
bkp_session_save();
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(&cwmp_main, &dmctx);
if (pupload->file_type[0] == '3' && pupload->f_instance && isdigit(pupload->f_instance[0])) {
lookup_vcf_name(pupload->f_instance, &name);
}
external_upload(pupload->url, pupload->file_type,
pupload->username, pupload->password, name);
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(&cwmp_main, &dmctx);
external_handle_action(cwmp_handle_uploadFault);
external_fetch_uploadFaultResp(&fault_code);
@ -2727,14 +2731,14 @@ void *thread_cwmp_rpc_cpe_schedule_download (void *v)
pthread_mutex_unlock(&(cwmp->mutex_session_send));
pthread_cond_signal(&(cwmp->threshold_session_send));
}
else
else
{
cwmp_add_apply_schedule_download(current_download, ptransfer_complete->start_time);
}
}
pthread_mutex_lock (&mutex_schedule_download);
bkp_session_delete_schedule_download(current_download);
bkp_session_save();
bkp_session_save();
list_del(&(current_download->list));
cwmp_free_schedule_download_request(current_download);
pthread_mutex_unlock (&mutex_schedule_download);
@ -3129,11 +3133,11 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
free(fault_code);
if( error == FAULT_CPE_NO_FAULT)
{
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
du_instance = strdup(add_softwaremodules_deploymentunit(p->uuid, p->url, p->username, p->password, package_name, package_version));
dmuci_commit();
dm_ctx_clean(&dmctx);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
cwmp_dm_ctx_clean(cwmp, &dmctx);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
res->uuid = strdup(p->uuid);
res->du_ref = strdup(du_ref);
res->current_state = strdup("Installed");
@ -3154,12 +3158,12 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
}
break;
case DU_UNINSTALL:
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
cur_name = strdup(get_softwaremodules_name(p->uuid));
if (!cur_name || cur_name[0] == '\0') {
error = FAULT_CPE_UNKNOWN_DEPLOYMENT_UNIT;
res->fault = error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
break;
}
if((p->version)[0] == '\0') {
@ -3171,15 +3175,15 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
error = cwmp_launch_uninstall_du_state(cur_name, &res);
else {
error = FAULT_CPE_UNKNOWN_DEPLOYMENT_UNIT;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
break;
}
}
if( error == FAULT_CPE_NO_FAULT)
{
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
du_instance = get_softwaremodules_instance(p->uuid);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
res->uuid = strdup(p->uuid);
res->du_ref = strdup(du_ref);
FREE(du_instance);
@ -3189,13 +3193,13 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
operation_endTime = mix_get_time();
res->complete_time = strdup(operation_endTime);
res->fault = error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
}
else
{
res->uuid = strdup(p->uuid);
du_instance = get_softwaremodules_instance(p->uuid);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
res->du_ref = strdup(du_ref);
FREE(du_instance);
res->version = strdup(p->version);
@ -3204,46 +3208,46 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
operation_endTime = mix_get_time(); //TO CHECK
res->complete_time = strdup(operation_endTime);
res->fault = error;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
}
break;
case DU_UPDATE:
if ((p->url)[0] != '\0' && (p->uuid)[0] != '\0') {
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
uuid = update_softwaremodules_url(p->uuid, p->url);
if(uuid == 0) {
error = FAULT_CPE_UNKNOWN_DEPLOYMENT_UNIT;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
break;
}
cur_instance = strdup(get_softwaremodules_instance(p->uuid));
dmuci_commit();
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
}
else if ((p->url)[0] != '\0' && (p->uuid)[0] == '\0') {
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
cur_uuid = get_softwaremodules_uuid(p->url);
if (!cur_uuid || cur_uuid[0] == '\0')
{
error = FAULT_CPE_UNKNOWN_DEPLOYMENT_UNIT;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
break;
}
cur_instance = strdup(get_softwaremodules_instance(p->uuid));
}
else if ((p->url)[0] == '\0' && (p->uuid)[0] != '\0') {
dm_ctx_init(&dmctx);
cwmp_dm_ctx_init(cwmp, &dmctx);
cur_url = strdup(get_softwaremodules_url(p->uuid));
if (cur_url == NULL || cur_url[0] == '\0')
{
error = FAULT_CPE_UNKNOWN_DEPLOYMENT_UNIT;
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
break;
}
cur_user = strdup(get_softwaremodules_username(p->uuid));
cur_pass = strdup(get_softwaremodules_pass(p->uuid));
dm_ctx_clean(&dmctx);
cwmp_dm_ctx_clean(cwmp, &dmctx);
}
error = cwmp_launch_update_du_state_download((cur_url && cur_url[0]!='\0' )?cur_url:p->url, p->username, p->password, &res);
if(error != FAULT_CPE_NO_FAULT)
@ -3254,7 +3258,7 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
}
else
res->uuid = strdup(p->uuid);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
res->du_ref = strdup(du_ref);
FREE(du_instance);
res->current_state = strdup("Installed");
@ -3271,7 +3275,7 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
}
else
res->uuid = strdup(p->uuid);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
res->du_ref = strdup(du_ref);
FREE(du_instance);
res->current_state = strdup("Failed");
@ -3300,7 +3304,7 @@ void *thread_cwmp_rpc_cpe_change_du_state (void *v)
}
}
free(fault_code);
sprintf(du_ref,DMROOT"SoftwareModules.%s.", du_instance);
sprintf(du_ref,"%sSoftwareModules.%s.", DMROOT, du_instance);
if (p->uuid == NULL || (p->uuid)[0] == '\0') {
res->uuid = strdup(cur_url);
FREE(cur_url);

View file

@ -17,7 +17,9 @@
#include "http.h"
#include "xmpp_cr.h"
#include <unistd.h>
#ifdef XMPP_ENABLE
#include "/home/piva/projects/inteno-tr064/iop-cc/staging_dir/target-mips_mips32_uClibc-0.9.33.2/usr/include/strophe.h"
#endif
int ping_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
{