mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-11 19:48:36 +01:00
support new retry session behaviour of amd5
This commit is contained in:
parent
10968bdaee
commit
2f56f5ff41
8 changed files with 118 additions and 21 deletions
|
|
@ -1,7 +1,7 @@
|
|||
bin_PROGRAMS = icwmpd
|
||||
CWMP_VERSION = 3.0
|
||||
|
||||
icwmpd_SOURCES = \
|
||||
icwmpd_SOURCES = \
|
||||
../backupSession.c \
|
||||
../config.c \
|
||||
../cwmp.c \
|
||||
|
|
@ -30,7 +30,7 @@ icwmpd_SOURCES = \
|
|||
../dm/dmtree/landevice.c \
|
||||
../dm/dmtree/layer_2_bridging.c \
|
||||
../dm/dmtree/layer_3_forwarding.c \
|
||||
../dm/dmtree/managementserver.c \
|
||||
../dm/dmtree/managementserver.c \
|
||||
../dm/dmtree/root.c \
|
||||
../dm/dmtree/times.c \
|
||||
../dm/dmtree/upnp.c \
|
||||
|
|
@ -43,7 +43,7 @@ icwmpd_SOURCES = \
|
|||
../dm/dmtree/x_inteno_se_power_mgmt.c \
|
||||
../dm/dmtree/ippingdiagnostics.c \
|
||||
../dm/dmtree/x_inteno_syslog.c \
|
||||
../dm/dmtree/x_inteno_se_wifi.c
|
||||
../dm/dmtree/x_inteno_se_wifi.c
|
||||
|
||||
icwmpd_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
|
|
@ -54,7 +54,7 @@ icwmpd_CFLAGS = \
|
|||
$(LIBCURL_CFLAGS) \
|
||||
$(LIBZSTREAM_CFLAGS)
|
||||
|
||||
icwmpd_LDFLAGS = \
|
||||
icwmpd_LDFLAGS = \
|
||||
$(AM_LDFLAGS) \
|
||||
$(LIBUCI_LDFLAGS) \
|
||||
$(LIBUBOX_LDFLAGS) \
|
||||
|
|
@ -76,7 +76,8 @@ icwmpd_LDADD = \
|
|||
$(LSSL_LIBS) \
|
||||
$(LIBJSON_LIBS) \
|
||||
$(LBLOBMSG_LIBS) \
|
||||
$(LIBZ_LIBS)
|
||||
$(LIBZ_LIBS) \
|
||||
$(LIBM_LIBS)
|
||||
|
||||
icwmpd_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
||||
icwmpd_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\"
|
||||
|
|
|
|||
34
config.c
34
config.c
|
|
@ -514,6 +514,40 @@ int get_global_config(struct config *conf)
|
|||
{
|
||||
return error;
|
||||
}
|
||||
if((error = uci_get_value(UCI_ACS_RETRY_MIN_WAIT_INTERVAL ,&value)) == CWMP_OK)
|
||||
{
|
||||
conf->retry_min_wait_interval = DEFAULT_RETRY_MINIMUM_WAIT_INTERVAL;
|
||||
if(value != NULL)
|
||||
{
|
||||
int a = atoi(value) ;
|
||||
if ( a <= 65535 || a >=1) {
|
||||
conf->retry_min_wait_interval = a;
|
||||
}
|
||||
free(value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
if((error = uci_get_value(UCI_ACS_RETRY_INTERVAL_MULTIPLIER ,&value)) == CWMP_OK)
|
||||
{
|
||||
conf->retry_interval_multiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
|
||||
if(value != NULL)
|
||||
{
|
||||
int a = atoi(value) ;
|
||||
if ( a <= 65535 || a >=1000) {
|
||||
conf->retry_interval_multiplier = a;
|
||||
}
|
||||
free(value);
|
||||
value = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
if((error = uci_get_value(UCI_ACS_SSL_CAPATH,&value)) == CWMP_OK)
|
||||
{
|
||||
if(value != NULL)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ config 'cwmp' 'acs'
|
|||
option 'dhcp_url_path' 'provisioning.iup.urlcwmp'
|
||||
# compression possible configs: GZIP, Deflate, Disabled
|
||||
option compression 'Disabled'
|
||||
#possible configs interval :[1:65535]
|
||||
option retry_min_wait_interval 5
|
||||
#possible configs interval :[1000:65535]
|
||||
option retry_interval_multiplier 2000
|
||||
|
||||
config 'cwmp' 'cpe'
|
||||
option 'interface' 'eth0.1'
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ AC_SUBST([LIBPTHREAD_LIBS])
|
|||
|
||||
LIBZ_LIBS='-lz'
|
||||
AC_SUBST([LIBZ_LIBS])
|
||||
|
||||
LIBM_LIBS='-lm'
|
||||
AC_SUBST([LIBM_LIBS])
|
||||
|
||||
case "$CFLAGS" in
|
||||
*_AADJ*) LIBJSON_LIBS='-ljson -ljson-c' ;;
|
||||
*) LIBJSON_LIBS='-ljson' ;;
|
||||
|
|
|
|||
30
cwmp.c
30
cwmp.c
|
|
@ -13,6 +13,9 @@
|
|||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "cwmp.h"
|
||||
#include "backupSession.h"
|
||||
#include "xml.h"
|
||||
|
|
@ -75,20 +78,19 @@ int cwmp_session_rpc_destructor (struct rpc *rpc)
|
|||
|
||||
int cwmp_get_retry_interval (struct cwmp *cwmp)
|
||||
{
|
||||
switch (cwmp->retry_count_session)
|
||||
{
|
||||
case 0: return MAX_INT32;
|
||||
case 1: return 6;
|
||||
case 2: return 11;
|
||||
case 3: return 21;
|
||||
case 4: return 41;
|
||||
case 5: return 81;
|
||||
case 6: return 161;
|
||||
case 7: return 321;
|
||||
case 8: return 641;
|
||||
case 9: return 1281;
|
||||
default: return 2561;
|
||||
}
|
||||
int retry_count = 0;
|
||||
double min = 0;
|
||||
double max = 0;
|
||||
int m = cwmp->conf.retry_min_wait_interval;
|
||||
int k = cwmp->conf.retry_interval_multiplier;
|
||||
int exp = cwmp->retry_count_session;
|
||||
if (exp == 0) return MAX_INT32;
|
||||
if (exp > 10) exp = 10;
|
||||
min = pow(((double)k/1000), (double)(exp-1)) * m;
|
||||
max = pow(((double)k/1000), (double)exp) * m;
|
||||
srand (time(NULL));
|
||||
retry_count = rand() % ((int)max + 1 - (int)min) + (int)min;
|
||||
return (retry_count);
|
||||
}
|
||||
|
||||
static void cwmp_prepare_value_change (struct cwmp *cwmp, struct session *session)
|
||||
|
|
|
|||
|
|
@ -222,7 +222,6 @@ int dm_entry_get_linker(struct dmctx *ctx);
|
|||
int dm_entry_get_linker_value(struct dmctx *ctx);
|
||||
void free_all_list_enabled_notify();
|
||||
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_lev2(char *package, char *section, char *opt_inst, char *opt_check, char *value_check);
|
||||
|
|
|
|||
|
|
@ -320,6 +320,52 @@ 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)
|
||||
{
|
||||
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 a;
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
a = atoi(value);
|
||||
if (a <= 65535 && a >= 1) {
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9007;
|
||||
case VALUESET:
|
||||
dmuci_set_value("cwmp", "acs", "retry_min_wait_interval", value);
|
||||
cwmp_set_end_session(END_SESSION_RELOAD);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int get_management_server_retry_interval_multiplier(char *refparam, struct dmctx *ctx, 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 a;
|
||||
switch (action) {
|
||||
case VALUECHECK:
|
||||
a = atoi(value);
|
||||
if (a <= 65535 && a >= 1000) {
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9007;
|
||||
case VALUESET:
|
||||
dmuci_set_value("cwmp", "acs", "retry_interval_multiplier", value);
|
||||
cwmp_set_end_session(END_SESSION_RELOAD);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int entry_method_root_ManagementServer(struct dmctx *ctx)
|
||||
{
|
||||
|
|
@ -341,7 +387,8 @@ int entry_method_root_ManagementServer(struct dmctx *ctx)
|
|||
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);
|
||||
return 0;
|
||||
}
|
||||
return FAULT_9005;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
#define CONNECTION_REQUEST_RESTRICT_REQUEST 50
|
||||
#define DEFAULT_CONNECTION_REQUEST_PORT 7547
|
||||
#define DEFAULT_LWN_PORT 7547
|
||||
#define DEFAULT_RETRY_MINIMUM_WAIT_INTERVAL 5
|
||||
#define DEFAULT_RETRY_INTERVAL_MULTIPLIER 2000
|
||||
|
||||
#define DEFAULT_ACSURL "http://192.168.1.1:8080/openacs/acs"
|
||||
#define UCI_DHCP_DISCOVERY_PATH "cwmp.acs.dhcp_discovery"
|
||||
|
|
@ -45,6 +47,8 @@
|
|||
#define UCI_ACS_INSECURE_ENABLE "cwmp.acs.insecure_enable"
|
||||
#define UCI_ACS_SSL_VERSION "cwmp.acs.ssl_version"
|
||||
#define UCI_ACS_COMPRESSION "cwmp.acs.compression"
|
||||
#define UCI_ACS_RETRY_MIN_WAIT_INTERVAL "cwmp.acs.retry_min_wait_interval"
|
||||
#define UCI_ACS_RETRY_INTERVAL_MULTIPLIER "cwmp.acs.retry_interval_multiplier"
|
||||
#define UCI_LOG_SEVERITY_PATH "cwmp.cpe.log_severity"
|
||||
#define UCI_CPE_USERID_PATH "cwmp.cpe.userid"
|
||||
#define UCI_CPE_PASSWD_PATH "cwmp.cpe.passwd"
|
||||
|
|
@ -151,6 +155,8 @@ typedef struct config {
|
|||
time_t time;
|
||||
bool periodic_enable;
|
||||
bool insecure_enable;
|
||||
int retry_min_wait_interval;
|
||||
int retry_interval_multiplier;
|
||||
bool lw_notification_enable;
|
||||
char *lw_notification_hostname;
|
||||
int lw_notification_port;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue