Ticket #8946 : update amendment version control

This commit is contained in:
Anis Ellouze 2016-04-14 18:18:40 +01:00
parent 68c44a7cf5
commit 5f1cba41da
5 changed files with 42 additions and 36 deletions

View file

@ -495,9 +495,14 @@ int get_global_config(struct config *conf)
{
return error;
}
if((error = get_amd_version_config())!= CWMP_OK)
{
return error;
}
if((error = uci_get_value(UCI_ACS_COMPRESSION ,&value)) == CWMP_OK)
{
if(value != NULL)
conf->compression = COMP_NONE;
if(conf->amd_version >= AMD_5 && value != NULL)
{
if (0 == strcasecmp(value, "gzip")) {
conf->compression = COMP_GZIP;
@ -517,7 +522,7 @@ int get_global_config(struct config *conf)
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)
if(conf->amd_version >= AMD_3 && value != NULL)
{
int a = atoi(value) ;
if ( a <= 65535 || a >=1) {
@ -534,7 +539,7 @@ int get_global_config(struct config *conf)
if((error = uci_get_value(UCI_ACS_RETRY_INTERVAL_MULTIPLIER ,&value)) == CWMP_OK)
{
conf->retry_interval_multiplier = DEFAULT_RETRY_INTERVAL_MULTIPLIER;
if(value != NULL)
if(conf->amd_version >= AMD_3 && value != NULL)
{
int a = atoi(value) ;
if ( a <= 65535 || a >=1000) {
@ -759,11 +764,6 @@ int get_global_config(struct config *conf)
{
return error;
}
if((error = get_amd_version_config())!= CWMP_OK)
{
return error;
}
conf->supported_amd_version = conf->amd_version;
if((error = get_instance_mode_config())!= CWMP_OK)
{
return error;
@ -793,6 +793,7 @@ int get_amd_version_config()
free(value);
value = NULL;
}
cwmp->conf.supported_amd_version = cwmp->conf.amd_version;
}
else
{

View file

@ -11,6 +11,7 @@
#include "cwmp.h"
#include "dmuci.h"
#include "dmcwmp.h"
#include "xml.h"
#include "root.h"
#include "times.h"
#include "upnp.h"
@ -161,7 +162,7 @@ char *handle_update_instance(int instance_ranck, struct dmctx *ctx, char **last_
argv[i] = va_arg(arg, void*);
}
va_end(arg);
if (ctx->amd_version >= 4) {
if (ctx->amd_version >= AMD_4) {
if(pos < ctx->nbrof_instance) {
action = (ctx->alias_register & (1 << pos)) ? INSTANCE_UPDATE_ALIAS : INSTANCE_UPDATE_NUMBER;
} else {

View file

@ -19,6 +19,7 @@
#include "dmubus.h"
#include "dmcommon.h"
#include "managementserver.h"
#include "xml.h"
int get_management_server_url(char *refparam, struct dmctx *ctx, char **value)
{
@ -377,7 +378,7 @@ int set_management_server_retry_interval_multiplier(char *refparam, struct dmctx
int get_alias_based_addressing(char *refparam, struct dmctx *ctx, char **value)
{
dmuci_get_option_value_string("cwmp", "cpe", "amd_version", value);
if((*value)[0] == '\0'|| atoi(value) <= 4) {
if((*value)[0] == '\0'|| atoi(*value) <= AMD_4) {
*value = "false";
}
else {

View file

@ -1157,7 +1157,7 @@ inline int entry_layer2_bridge(struct dmctx *ctx)
inline int entry_layer2_marking(struct dmctx *ctx)
{
char *marking_instance = NULL, marking_instance_last = NULL;
char *marking_instance = NULL, *marking_instance_last = NULL;
struct uci_section *marking_s = NULL;
uci_foreach_sections("dmmap", "marking-bridge", marking_s) {

53
http.c
View file

@ -22,6 +22,7 @@
#include <fcntl.h>
#include "cwmp.h"
#include "log.h"
#include "xml.h"
#include <libubox/uloop.h>
#include <libubox/usock.h>
@ -61,7 +62,7 @@ http_client_init(struct cwmp *cwmp)
return -1;
} else {
if (asprintf(&http_c.url, "%s",
cwmp->conf.acsurl) == -1)
cwmp->conf.acsurl) == -1)
return -1;
}
#endif
@ -74,7 +75,7 @@ http_client_init(struct cwmp *cwmp)
cwmp->conf.acsurl,
cwmp->conf.acs_userid,
cwmp->conf.acs_passwd,
add+3) == -1)
add+3) == -1)
return -1;
#endif
@ -181,14 +182,16 @@ http_send_message(struct cwmp *cwmp, char *msg_out, int msg_out_len,char **msg_i
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
switch (cwmp->conf.compression) {
case COMP_GZIP:
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip");
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: gzip");
break;
case COMP_DEFLATE:
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "deflate");
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: deflate");
break;
case COMP_NONE:
break;
case COMP_GZIP:
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "gzip");
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: gzip");
break;
case COMP_DEFLATE:
curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, "deflate");
http_c.header_list = curl_slist_append(http_c.header_list, "Content-Encoding: deflate");
break;
}
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, http_c.header_list);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg_out);
@ -232,28 +235,28 @@ 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);
external_init();
external_simple("allow_cr_ip", ip_acs);
external_exit();
}
}
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);
external_init();
external_simple("allow_cr_ip", ip_acs);
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");
}
if(http_code == 415)
{
cwmp->conf.compression = COMP_NONE;
if(http_code == 415)
{
cwmp->conf.compression = COMP_NONE;
goto error;
}
}
if (http_code != 200 && http_code != 204)
goto error;