mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-13 04:28:33 +01:00
Merge branch 'ICWMP_TR181_AMD5' of public.inteno.se:/icwmp into ICWMP_TR181_AMD5
This commit is contained in:
commit
6194618334
6 changed files with 408 additions and 1 deletions
|
|
@ -37,7 +37,6 @@ icwmpd_SOURCES = \
|
|||
../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/ippingdiagnostics.c \
|
||||
../dm/dmtree/common/softwaremodules.c \
|
||||
../dm/dmtree/common/xmpp.c \
|
||||
../dm/dmtree/common/x_inteno_syslog.c
|
||||
|
|
@ -49,6 +48,7 @@ icwmpd_SOURCES += \
|
|||
../dm/dmtree/tr098/layer_2_bridging.c \
|
||||
../dm/dmtree/tr098/wandevice.c \
|
||||
../dm/dmtree/tr098/x_inteno_se_wifi.c \
|
||||
../dm/dmtree/common/ippingdiagnostics.c \
|
||||
../dm/dmtree/tr098/layer_3_forwarding.c
|
||||
endif
|
||||
if DATAMODEL_TR181
|
||||
|
|
@ -62,6 +62,7 @@ icwmpd_SOURCES += \
|
|||
../dm/dmtree/tr181/ip.c \
|
||||
../dm/dmtree/tr181/ppp.c \
|
||||
../dm/dmtree/tr181/dns.c \
|
||||
../dm/dmtree/tr181/nat.c \
|
||||
../dm/dmtree/tr181/routing.c
|
||||
endif
|
||||
icwmpd_CFLAGS = \
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "dns.h"
|
||||
#include "softwaremodules.h"
|
||||
#include "routing.h"
|
||||
#include "nat.h"
|
||||
|
||||
static char *get_parameter_notification (struct dmctx *ctx, char *param);
|
||||
static int remove_parameter_notification(char *param);
|
||||
|
|
@ -136,6 +137,7 @@ struct prefix_method prefix_methods[] = {
|
|||
{ DMROOT"PPP.", 1, NULL, 0, &entry_method_root_ppp },
|
||||
{ DMROOT"DNS.", 1, NULL, 0, &entry_method_root_dns },
|
||||
{ DMROOT"Routing.", 1, NULL, 0, &entry_method_root_routing },
|
||||
{ DMROOT"NAT.", 1, NULL, 0, &entry_method_root_nat },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
195
dm/dmtree/tr098/ippingdiagnostics.c
Normal file
195
dm/dmtree/tr098/ippingdiagnostics.c
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
/*
|
||||
* 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) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
|
||||
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
|
||||
* Author: Feten Besbes <feten.besbes@pivasoftware.com>
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <uci.h>
|
||||
#include <stdio.h>
|
||||
#include "cwmp.h"
|
||||
#include "ipping.h"
|
||||
#include "ubus.h"
|
||||
#include "dmcwmp.h"
|
||||
#include "dmuci.h"
|
||||
#include "dmubus.h"
|
||||
#include "dmcommon.h"
|
||||
#include "ippingdiagnostics.h"
|
||||
#include "ipping.h"
|
||||
|
||||
int get_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_diagnostics_state(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
if (strcmp(value, "Requested") == 0) {
|
||||
ipping_diagnostic.state = set_ping_diagnostic(ipping_diagnostic.state, value);
|
||||
cwmp_set_end_session(END_SESSION_IPPING_DIAGNOSTIC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_interface(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.interface;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_interface(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
ipping_diagnostic.interface = set_ping_diagnostic(ipping_diagnostic.interface, value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_host(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
|
||||
*value = ipping_diagnostic.host;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_host(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
TRACE();
|
||||
ipping_diagnostic.host = set_ping_diagnostic(ipping_diagnostic.host, value);
|
||||
TRACE();
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_repetition_number(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.repetition;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_repetition_number(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
ipping_diagnostic.repetition = set_ping_diagnostic(ipping_diagnostic.repetition, value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_timeout(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
|
||||
*value = ipping_diagnostic.timeout;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_timeout(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
ipping_diagnostic.timeout = set_ping_diagnostic(ipping_diagnostic.timeout, value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_block_size(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_ipping_block_size(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
ipping_diagnostic.size = set_ping_diagnostic(ipping_diagnostic.size, value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_success_count(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.success_count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_failure_count(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.failure_count;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_average_response_time(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.average_response_time;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_min_response_time(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.minimum_response_time;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_ipping_max_response_time(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
*value = ipping_diagnostic.maximum_response_time;
|
||||
|
||||
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;
|
||||
}
|
||||
16
dm/dmtree/tr098/ippingdiagnostics.h
Normal file
16
dm/dmtree/tr098/ippingdiagnostics.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* 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) 2012-2014 PIVA SOFTWARE (www.pivasoftware.com)
|
||||
* Author: Imen Bhiri <imen.bhiri@pivasoftware.com>
|
||||
*/
|
||||
#ifndef __IPPING_DIAGNOSTIC_H
|
||||
#define __IPPING_DIAGNOSTIC_H
|
||||
|
||||
extern struct ip_ping_diagnostic ipping_diagnostic;
|
||||
int entry_method_root_IPPingDiagnostics(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
177
dm/dmtree/tr181/nat.c
Normal file
177
dm/dmtree/tr181/nat.c
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* 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) 2016 Inteno Broadband Technology AB
|
||||
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <uci.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "dmuci.h"
|
||||
#include "dmubus.h"
|
||||
#include "dmcwmp.h"
|
||||
#include "dmcommon.h"
|
||||
#include "nat.h"
|
||||
|
||||
struct nat_args
|
||||
{
|
||||
struct uci_section *int_sec;
|
||||
};
|
||||
|
||||
struct nat_args cur_nat_args = {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)
|
||||
{
|
||||
*value = "1";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_nat_alias(char *refparam, struct dmctx *ctx, char **value)
|
||||
{
|
||||
struct nat_args *natargs = (struct nat *)ctx->args;
|
||||
dmuci_get_value_by_section_string(natargs->int_sec, "natalias", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int set_nat_alias(char *refparam, struct dmctx *ctx, int action, char *value)
|
||||
{
|
||||
struct nat_args *natargs = (struct nat *)ctx->args;
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
return 0;
|
||||
case VALUESET:
|
||||
dmuci_set_value_by_section(natargs->int_sec, "natalias", value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int get_nat_interface(char *refparam, struct dmctx *ctx, 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
|
||||
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;
|
||||
int max;
|
||||
struct uci_section *s;
|
||||
int cnt = 0;
|
||||
|
||||
uci_foreach_sections("network", "interface", s) {
|
||||
dmuci_get_value_by_section_string(s, "natinstance", &tmp);
|
||||
if (tmp[0] == '\0')
|
||||
continue;
|
||||
else if (atoi(rinst) < atoi(tmp))
|
||||
{
|
||||
rinst = tmp;
|
||||
}
|
||||
}
|
||||
max = atoi(rinst);
|
||||
return max;
|
||||
}
|
||||
|
||||
char *nat_update_instance_alias(int action, char **last_inst, void *argv[])
|
||||
{
|
||||
char *instance, *alias;
|
||||
char buf[8] = {0};
|
||||
|
||||
struct uci_section *s = (struct uci_section *) argv[0];
|
||||
char *inst_opt = (char *) argv[1];
|
||||
char *alias_opt = (char *) argv[2];
|
||||
bool *find_max = (bool *) argv[3];
|
||||
|
||||
dmuci_get_value_by_section_string(s, inst_opt, &instance);
|
||||
if (instance[0] == '\0') {
|
||||
if (*find_max) {
|
||||
int m = get_nat_last_inst();
|
||||
sprintf(buf, "%d", m+1);
|
||||
*find_max = false;
|
||||
}
|
||||
else if (last_inst == NULL) {
|
||||
sprintf(buf, "%d", 1);
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "%d", atoi(*last_inst)+1);
|
||||
}
|
||||
instance = dmuci_set_value_by_section(s, inst_opt, buf);
|
||||
}
|
||||
*last_inst = instance;
|
||||
if (action == INSTANCE_MODE_ALIAS) {
|
||||
dmuci_get_value_by_section_string(s, alias_opt, &alias);
|
||||
if (alias[0] == '\0') {
|
||||
sprintf(buf, "cpe-%s", instance);
|
||||
alias = dmuci_set_value_by_section(s, alias_opt, buf);
|
||||
}
|
||||
sprintf(buf, "[%s]", alias);
|
||||
instance = dmstrdup(buf);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
inline int entry_nat(struct dmctx *ctx)
|
||||
{
|
||||
struct uci_section *net_sec = NULL, *s = NULL;
|
||||
char *nat = NULL;
|
||||
char *nati, *nati_last = NULL;
|
||||
int id = 0;
|
||||
bool find_max = true;
|
||||
uci_foreach_sections("network", "interface", net_sec) {
|
||||
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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
16
dm/dmtree/tr181/nat.h
Normal file
16
dm/dmtree/tr181/nat.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* 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) 2016 Inteno Broadband Technology AB
|
||||
* Author: Imen BHIRI <imen.bhiri@pivasoftware.com>
|
||||
*
|
||||
*/
|
||||
#ifndef __NAT_H
|
||||
#define __NAT_H
|
||||
|
||||
int entry_method_root_nat(struct dmctx *ctx);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue