cwmp headerwq

This commit is contained in:
imen.bhiri 2016-02-26 18:03:43 +01:00
parent e49318b84e
commit dfdc4cec83
5 changed files with 67 additions and 2 deletions

View file

@ -387,7 +387,7 @@ void bkp_session_insert_transfer_complete(struct transfer_complete *ptransfer_co
bkp_session_insert(b,"complete_time",ptransfer_complete->complete_time);
bkp_session_insert(b,"old_software_version",ptransfer_complete->old_software_version);
bkp_session_insert(b,"fault_code",fault_code);
bkp_session_insert(b,"fault_code",ptransfer_complete->type);
bkp_session_insert(b,"type",ptransfer_complete->type);
}
pthread_mutex_unlock (&mutex_backup_session);
}

View file

@ -767,6 +767,10 @@ int get_global_config(struct config *conf)
{
return error;
}
if((error = get_session_timeout_config())!= CWMP_OK)
{
return error;
}
return CWMP_OK;
}
@ -799,6 +803,32 @@ int get_amd_version_config()
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;

View file

@ -34,6 +34,7 @@ config 'cwmp' 'cpe'
option amd_version '2'
# compression possible configs: InstanceNumber, InstanceAlias
option instance_mode 'InstanceAlias'
option session_timeout '60'
config 'cwmp' 'lwn'
option enable '1'
option hostname ''

View file

@ -34,7 +34,7 @@
#define DEFAULT_RETRY_INTERVAL_MULTIPLIER 2000
#define DEFAULT_AMD_VERSION 2
#define DEFAULT_INSTANCE_MODE 0
#define DEFAULT_SESSION_TIMEOUT 60
#define DEFAULT_ACSURL "http://192.168.1.1:8080/openacs/acs"
#define UCI_DHCP_DISCOVERY_PATH "cwmp.acs.dhcp_discovery"
#define UCI_DHCP_ACS_URL_PATH "cwmp.acs.dhcp_url_path"
@ -63,6 +63,7 @@
#define UCI_CPE_ENABLE_FILE_LOG "cwmp.cpe.log_to_file"
#define UCI_CPE_AMD_VERSION "cwmp.cpe.amd_version"
#define UCI_CPE_INSTANCE_MODE "cwmp.cpe.instance_mode"
#define UCI_CPE_SESSION_TIMEOUT "cwmp.cpe.session_timeout"
#define DM_SOFTWARE_VERSION_PATH "InternetGatewayDevice.DeviceInfo.SoftwareVersion"
#define LW_NOTIFICATION_ENABLE "cwmp.lwn.enable"
#define LW_NOTIFICATION_HOSTNAME "cwmp.lwn.hostname"
@ -166,6 +167,7 @@ typedef struct config {
int lw_notification_port;
unsigned int amd_version;
unsigned int instance_mode;
unsigned int session_timeout;
} config;
typedef struct env {

32
xml.c
View file

@ -630,6 +630,22 @@ error:
return -1;
}
char* xml_get_cwmp_version (int version)
{
int k;
char tmp[10] = "";
static char versions[60] = "";
for (k=0; k < version; k++) {
if (k == 0)
sprintf(tmp, "1.%d", k);
else
sprintf(tmp, ", 1.%d", k);
strcat(versions, tmp);
}
return versions;
}
int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *session, struct rpc *this)
{
struct dm_parameter *dm_parameter;
@ -657,6 +673,22 @@ int cwmp_rpc_acs_prepare_message_inform (struct cwmp *cwmp, struct session *sess
#endif
if (!tree) goto error;
if ( cwmp->conf.amd_version >= 4 ) {
b = mxmlFindElement(tree, tree, "soap_env:Header", NULL, NULL, MXML_DESCEND);
if (!b) goto error;
node = mxmlNewElement(b, "cwmp:SessionTimeout");
if (!node) goto error;
mxmlElementSetAttr(node, "soap_env:mustUnderstand", "0");
node = mxmlNewInteger(node, cwmp->conf.session_timeout);
if (!node) goto error;
}
if ( cwmp->conf.amd_version >= 5 ) {
node = mxmlNewElement(b, "cwmp:SupportedCWMPVersions");
if (!node) goto error;
mxmlElementSetAttr(node, "soap_env:mustUnderstand", "0");
node = mxmlNewText(node, 0, xml_get_cwmp_version(cwmp->conf.amd_version));
if (!node) goto error;
}
b = mxmlFindElement(tree, tree, "RetryCount", NULL, NULL, MXML_DESCEND);
if (!b) goto error;