This commit is contained in:
zribiahmed 2012-11-22 13:29:17 +00:00
commit c59214acbe
64 changed files with 52355 additions and 0 deletions

121
Makefile Normal file
View file

@ -0,0 +1,121 @@
#
# Copyright (C) 2011 Inteno
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=cwmpd
PKG_RELEASE:=0
PKG_VERSION:=1.3
CWMP_BKP_FILE:=/etc/cwmpd/.cwmpd_backup_session.xml
OTHER_MENU:=Other modules
include $(INCLUDE_DIR)/package.mk
define KernelPackage/kcwmp
SUBMENU:=$(OTHER_MENU)
TITLE:=Modules for TR-069 value change notification
KCONFIG:=
FILES:=$(PKG_BUILD_DIR)/kcwmp.$(LINUX_KMOD_SUFFIX)
AUTOLOAD:=$(call AutoLoad,1,kcwmp)
endef
define KernelPackage/kcwmp/description
TR-069 kernel modules for value change notification
endef
EXTRA_KCONFIG:= \
CONFIG_HELLO_MOD=m
EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(EXTRA_KCONFIG)
define Package/cwmpd
CATEGORY:=Utilities
TITLE:=TR-069 client
DEPENDS:=PACKAGE_libuci:libuci PACKAGE_libexpat:libexpat PACKAGE_libcurl:libcurl PACKAGE_libpthread:libpthread PACKAGE_libopenssl:libopenssl
endef
define Package/libcwmp
SECTION:=libs
CATEGORY:=Libraries
TITLE:=C library for the TR-069 client
endef
define Package/cwmpd/description
TR-069 client
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) LINUX_DIR=$(LINUX_DIR) MAKE_OPTS=$(MAKE_OPTS) LDFLAGS="-L$(STAGING_DIR)/usr/lib" CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include -I$(STAGING_DIR)/usr/include -DCWMP_BKP_FILE=\\\"$(CWMP_BKP_FILE)\\\""
endef
define Package/libcwmp/install
$(INSTALL_DIR) $(1)/lib
$(CP) $(PKG_BUILD_DIR)/libcwmp.so* $(1)/lib/
endef
define Package/cwmpd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cwmpd $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cwmp_value_change $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) -m0644 $(PKG_BUILD_DIR)/config/cwmp $(1)/etc/config/
$(INSTALL_DIR) $(1)/etc/cwmpd/dm
$(INSTALL_DATA) -m0644 $(PKG_BUILD_DIR)/dm/xml/* $(1)/etc/cwmpd/dm
$(INSTALL_DIR) $(1)/etc/cwmpd/scripts
$(INSTALL_DATA) -m0755 $(PKG_BUILD_DIR)/dm/scripts/* $(1)/etc/cwmpd/scripts
$(INSTALL_DATA) -m0755 $(PKG_BUILD_DIR)/init/iccu_enable $(1)/etc/cwmpd/scripts/iccu_enable
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DATA) -m0755 $(PKG_BUILD_DIR)/init/cwmpd.init $(1)/etc/init.d/cwmpd
$(INSTALL_DATA) -m0755 $(PKG_BUILD_DIR)/init/iccu.init $(1)/etc/init.d/iccu
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/inc/cwmp_lib.h $(1)/usr/include
$(CP) $(PKG_BUILD_DIR)/inc/cwmp_kernel.h $(LINUX_DIR)/include/linux
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libcwmp.so* $(1)/usr/lib
endef
define Package/cwmpd/postinst
#!/bin/sh
echo "$(CWMP_BKP_FILE)" >> $${IPKG_INSTROOT}/etc/sysupgrade.conf
echo "/etc/cwmpd/.iccu/cwmp" >> $${IPKG_INSTROOT}/etc/sysupgrade.conf
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Enabling rc.d symlink for cwmpd"
/etc/init.d/cwmpd enable
/etc/init.d/iccu enable
fi
exit 0
endef
define Package/cwmpd/prerm
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Disabling rc.d symlink for cwmpd"
/etc/init.d/cwmpd disable
/etc/init.d/iccu disable
fi
exit 0
endef
$(eval $(call BuildPackage,cwmpd))
$(eval $(call BuildPackage,libcwmp))
$(eval $(call KernelPackage,kcwmp))

136
README Normal file
View file

@ -0,0 +1,136 @@
1)Build
Requirements :
librairies:
- libuci.so
- libexpat.so
- libcurl.so
- libpthread.so
- libopenssl.so
- libz.so
- libcrypto.so
the librairies should be present in the "staging_dir/target-i386_uClibc-0.9.30.1/usr/lib/" or "staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib"
header files and folders:
- expat.h
- expat_external.h
- uci.h
- uci_config.h
- zlib.h
- curl folder
- openssl folder
the header files and folders should be present in the staging_dir/target-i386_uClibc-0.9.30.1/usr/include/ or staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/usr/include/
if a librairie doesn't exist:
a- run make menuconfig and select the librarie
b- build the librarie package
2) Build
this software is composed of 3 packages:
- cwmpd package: contains cwmpd daemon
- cwmp lib package: contains cwmplib and contains cwmp_value_change binary. They could be used by other user space applications in order to notify the cwmp daemon when paramter changes
- cwmp kernel package: contains cwmp kernel module. This module could be used by other kernel modules to notify the cwmpd daemon when kernel parameter changes
The three packages should be selected in the make menu config in order to get the three packages compiled.
To compile the three packages: $ make package/cwmpd/compile
3) OpenWRT settings
in the OpenWRT, Add the following lines in the /usr/share/udhcpc/default.script file:
uci_set_state provisioning iup tr069url "$url"
uci_set_state provisioning iup provisioningcode "$provisioningcode"
4) Run
Requirements:
- libuci package should be installed
- libexpat package should be installed
- libcurl package should be installed
- libpthread package should be installed
- libopenssl package should be installed
- libz package should be installed
- libcrypto package should be installed
Configure the acs url in the /etc/config/cwmp
and then start the cwmpd service: /etc/init.d/cwmpd start
for the help: /etc/init.d/cwmpd
5) Value Change
5.1) value change for user space applications (using the libcwmp)
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
The libcwmp should be installed uin the OpenWRT firmware
example of using libcwmp
in myapplication.c
#...
#include <cwmp_lib.h>
#...
int anyfunction ()
{
.....
/* parameter change here */
/* so we inform the cwmp: */
lib_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
.....
/*
Description of lib_api_cwmp_value_change_call input parameters
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
parameter 2 : is the parameter path
parameter 3 : is the first correspondence related to the first indice
parameter 4 : is the second correspondence related to the second indice
.
.
.
parameter n : is the (n-2) correspondence related to the (n-2) indice
*/
}
5.2) value change for user space applications (using the cwmp_value_change CLI)
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
The libcwmp should be installed uin the OpenWRT firmware
in OpenWRT:
root@OpenWrt:~# cwmp_value_change InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress "lan2" "3"
in this case the command will force cwmp client to send a notification to the ACS (if and only if the parameter path as configured as active or as passive parameter using the setAttributeParameter method)
5.3) value change for kernel space modules
Before using the cwmp kernel module for value change, we should check that the kernel module package is selected in "make menu config". and we should check that the package is compiled.
The kernel module should be installed uin the OpenWRT firmware and should be insert before all other kernel modules
example of using cwmp kernel module
in mykernelmodule.c
#...
#include <linux/cwmp_kernel.h>
#...
int anykernelfunction ()
{
.....
/* parameter change here */
/* so we inform the cwmp: */
kernel_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
.....
/*
Description of lib_api_cwmp_value_change_call input parameters
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
parameter 2 : is the parameter path
parameter 3 : is the first correspondence related to the first indice
parameter 4 : is the second correspondence related to the second indice
.
.
.
parameter n : is the (n-2) correspondence related to the (n-2) indice
*/
}

BIN
docs/README.doc Normal file

Binary file not shown.

BIN
docs/conception.doc Normal file

Binary file not shown.

BIN
docs/conception.odg Normal file

Binary file not shown.

BIN
docs/holdrequest.doc Normal file

Binary file not shown.

Binary file not shown.

157
src/AddObject.c Normal file
View file

@ -0,0 +1,157 @@
/*
AddObject.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
LIST_HEAD(list_dm_add_handler);
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_addObject (struct session *session);
int cwmp_rpc_cpe_addObject (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_addObject_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_addObject_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_addObject_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int cwmp_dm_addObject(struct cwmp *cwmp, struct dm_set_handler *dm_set_handler, char *path, int *InstanceNumber);
int dm_run_queue_cmd_handler_at_end_session (struct cwmp *cwmp, struct dm_set_handler *dm_set_handler);
int cwmp_reboot(struct cwmp *cwmp,void *v);
int dm_cwmp_config_reload (struct cwmp *cwmp, void *v );
struct rpc_cpe *cwmp_add_session_rpc_cpe_addObject (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__AddObject));
rpc_cpe->method = cwmp_rpc_cpe_addObject;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__AddObjectResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_addObject_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_addObject_response;
rpc_cpe->method_end = cwmp_rpc_cpe_addObject_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:AddObject";
soap_methods->envelope_response = "cwmp:AddObjectResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__AddObjectResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__AddObjectResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__AddObject;
return rpc_cpe;
}
int cwmp_rpc_cpe_addObject (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_addObject_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__AddObject *p_soap_cwmp1__AddObject;
struct _cwmp1__AddObjectResponse *p_soap_cwmp1__AddObjectResponse;
struct dm_set_handler *dm_add_handler;
char buf[128];
int error;
int InstanceNumber;
dm_add_handler = calloc(1,sizeof(struct dm_set_handler));
if (dm_add_handler == NULL)
{
return FAULT_CPE_INTERNAL_ERROR_IDX;
}
list_add_tail(&(dm_add_handler->list),&(list_dm_add_handler));
INIT_LIST_HEAD (&(dm_add_handler->cmd_list));
INIT_LIST_HEAD (&(dm_add_handler->cancel_list));
INIT_LIST_HEAD (&(dm_add_handler->service_list));
p_soap_cwmp1__AddObject = (struct _cwmp1__AddObject*)this->method_data;
p_soap_cwmp1__AddObjectResponse = (struct _cwmp1__AddObjectResponse*)this->method_response_data;
error = cwmp_dm_addObject(cwmp, dm_add_handler, p_soap_cwmp1__AddObject->ObjectName,&InstanceNumber);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
dm_free_dm_set_handler_queues(dm_add_handler);
if (dm_add_handler!=NULL)
{
list_del(&(dm_add_handler->list));
free(dm_add_handler);
}
if (cwmp_add_session_rpc_cpe_Fault(session,error)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
CWMP_LOG(INFO,"RUN uci commit"); /* TODO to be removed*/
sprintf(buf,"%s=%s",UCI_ACS_PARAMETERKEY_PATH,p_soap_cwmp1__AddObject->ParameterKey);
uci_set_value (buf);
uci_commit_value();
dm_run_queue_cmd_handler(dm_add_handler,FALSE);
p_soap_cwmp1__AddObjectResponse->InstanceNumber = InstanceNumber;
p_soap_cwmp1__AddObjectResponse->Status = _cwmp1__AddObjectResponse_Status__0;
if (dm_add_handler->reboot_required==TRUE)
{
CWMP_LOG(INFO,"Add reboot at the end of the session");
add_session_end_func(session,cwmp_reboot,NULL,TRUE);
p_soap_cwmp1__AddObjectResponse->Status = _cwmp1__AddObjectResponse_Status__1;
}
if (dm_add_handler->cmd_list.next!=&(dm_add_handler->cmd_list))
{
add_session_end_func(session,dm_run_queue_cmd_handler_at_end_session,dm_add_handler,FALSE);
p_soap_cwmp1__AddObjectResponse->Status = _cwmp1__AddObjectResponse_Status__1;
return CWMP_OK;
}
dm_free_dm_set_handler_queues(dm_add_handler);
if (dm_add_handler!=NULL)
{
list_del(&(dm_add_handler->list));
free(dm_add_handler);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_addObject_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send AddObject response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_addObject_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}

157
src/DeleteObject.c Normal file
View file

@ -0,0 +1,157 @@
/*
DeleteObject.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
LIST_HEAD(list_dm_del_handler);
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_deleteObject (struct session *session);
int cwmp_rpc_cpe_deleteObject (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_deleteObject_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_deleteObject_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_deleteObject_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int cwmp_dm_deleteObject(struct cwmp *cwmp, struct dm_set_handler *dm_set_handler, char *path);
int dm_run_queue_cmd_handler_at_end_session (struct cwmp *cwmp, struct dm_set_handler *dm_set_handler);
int cwmp_reboot(struct cwmp *cwmp,void *v);
int dm_cwmp_config_reload (struct cwmp *cwmp, void *v );
struct rpc_cpe *cwmp_add_session_rpc_cpe_deleteObject (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__DeleteObject));
rpc_cpe->method = cwmp_rpc_cpe_deleteObject;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__DeleteObjectResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_deleteObject_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_deleteObject_response;
rpc_cpe->method_end = cwmp_rpc_cpe_deleteObject_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:DeleteObject";
soap_methods->envelope_response = "cwmp:DeleteObjectResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__DeleteObjectResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__DeleteObjectResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__DeleteObject;
return rpc_cpe;
}
int cwmp_rpc_cpe_deleteObject (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_deleteObject_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__DeleteObject *p_soap_cwmp1__DeleteObject;
struct _cwmp1__DeleteObjectResponse *p_soap_cwmp1__DeleteObjectResponse;
struct dm_set_handler *dm_del_handler;
char buf[128];
int error;
int InstanceNumber;
dm_del_handler = calloc(1,sizeof(struct dm_set_handler));
if (dm_del_handler == NULL)
{
return FAULT_CPE_INTERNAL_ERROR_IDX;
}
list_add_tail(&(dm_del_handler->list),&(list_dm_del_handler));
INIT_LIST_HEAD (&(dm_del_handler->cmd_list));
INIT_LIST_HEAD (&(dm_del_handler->cancel_list));
INIT_LIST_HEAD (&(dm_del_handler->service_list));
p_soap_cwmp1__DeleteObject = (struct _cwmp1__DeleteObject*)this->method_data;
p_soap_cwmp1__DeleteObjectResponse = (struct _cwmp1__DeleteObjectResponse*)this->method_response_data;
error = cwmp_dm_deleteObject(cwmp, dm_del_handler, p_soap_cwmp1__DeleteObject->ObjectName);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
dm_free_dm_set_handler_queues(dm_del_handler);
if (dm_del_handler!=NULL)
{
list_del(&(dm_del_handler->list));
free(dm_del_handler);
}
if (cwmp_add_session_rpc_cpe_Fault(session,error)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
CWMP_LOG(INFO,"RUN uci commit"); /* TODO to be removed*/
sprintf(buf,"%s=%s",UCI_ACS_PARAMETERKEY_PATH,p_soap_cwmp1__DeleteObject->ParameterKey);
uci_set_value (buf);
uci_commit_value();
dm_run_queue_cmd_handler(dm_del_handler,FALSE);
p_soap_cwmp1__DeleteObjectResponse->Status = _cwmp1__DeleteObjectResponse_Status__0;
if (dm_del_handler->reboot_required==TRUE)
{
CWMP_LOG(INFO,"Add reboot at the end of the session");
add_session_end_func(session,cwmp_reboot,NULL,TRUE);
p_soap_cwmp1__DeleteObjectResponse->Status = _cwmp1__DeleteObjectResponse_Status__1;
}
if (dm_del_handler->cmd_list.next!=&(dm_del_handler->cmd_list))
{
add_session_end_func(session,dm_run_queue_cmd_handler_at_end_session,dm_del_handler,FALSE);
p_soap_cwmp1__DeleteObjectResponse->Status = _cwmp1__DeleteObjectResponse_Status__1;
return CWMP_OK;
}
dm_free_dm_set_handler_queues(dm_del_handler);
if (dm_del_handler!=NULL)
{
list_del(&(dm_del_handler->list));
free(dm_del_handler);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_deleteObject_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send DeleteObject response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_deleteObject_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}

639
src/Download.c Normal file
View file

@ -0,0 +1,639 @@
/*
Download.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <time.h>
#include <curl/curl.h>
#include <curl/easy.h>
#include <string.h>
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "backupSession.h"
#if LIBCURL_VERSION_NUM < 0x070907
#error LIBCURL version should be >= 7.9.7
#endif
LIST_HEAD(list_download);
static struct download_end_func *download_end_func = NULL;
static pthread_mutex_t mutex_download;
static pthread_cond_t threshold_download;
static bool thread_download_is_working = FALSE;
int count_download_queue = 0;
extern struct cwmp cwmp_main;
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_download (struct session *session);
int cwmp_rpc_cpe_download (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_download_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_download_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_download_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
struct _cwmp1__TransferComplete *cwmp_set_data_rpc_acs_transferComplete();
int cwmp_reboot(struct cwmp *cwmp,void *v);
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
int cwmp_launch_download(struct cwmp *cwmp, struct session *session, struct download *pDownload);
int cwmp_download_firmware(struct cwmp *cwmp, struct session *session);
int cwmp_download_web_content(struct cwmp *cwmp, struct session *session);
int cwmp_download_configuration_file(struct cwmp *cwmp, struct session *session);
void backup_session_insert_download(char *commandKey, char *url, time_t id);
void backup_session_delete_download(char *commandKey, char *url, time_t id);
void backup_session_insert_parameter_download(char *name, char *value, char *url, int id, char *commandKey);
typedef struct FILE_DOWNLOAD_TYPE
{
char *FILE_TYPE;
char *FILE_NAME;
unsigned short APPLY_AFTER_REBOOT;
unsigned int CHECK_SIZE;
long int *MEMORY_SIZE;
int (*UPDATE_VALUE)();
int (*DOWNLOAD)(struct cwmp *cwmp, struct session *session);
} FILE_DOWNLOAD_TYPE;
const struct FILE_DOWNLOAD_TYPE FILE_DOWNLOAD_TYPE_ARRAY [] = {
{"1 Firmware Upgrade Image" ,DOWNLOADED_FIRMWARE_FILE ,1,ENABLE_CHECK_SIZE ,&(cwmp_main.env.max_firmware_size),NULL,cwmp_download_firmware},
{"2 Web Content" ,DOWNLOADED_WEBCONTENT_FILE,0,DISABLE_CHECK_SIZE,0 ,NULL,cwmp_download_web_content},
{"3 Vendor Configuration File",DOWNLOADED_CONFIG_FILE ,1,DISABLE_CHECK_SIZE,0 ,NULL,cwmp_download_configuration_file}
};
struct rpc_cpe *cwmp_add_session_rpc_cpe_download (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__Download));
rpc_cpe->method = cwmp_rpc_cpe_download;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__DownloadResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_download_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_download_response;
rpc_cpe->method_end = cwmp_rpc_cpe_download_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:Download";
soap_methods->envelope_response = "cwmp:DownloadResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__DownloadResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__DownloadResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__Download;
return rpc_cpe;
}
void *thread_cwmp_rpc_cpe_download (void *v)
{
struct cwmp *cwmp = (struct cwmp *)v;
struct download *download;
struct timespec download_timeout = {0, 0};
time_t current_time;
int error = FAULT_CPE_NO_FAULT_IDX;
time_t download_startTime;
time_t download_completeTime;
char startTime[64];
char completeTime[64];
struct _cwmp1__TransferComplete *p_soap_cwmp1__TransferComplete;
extern struct FAULT_CPE FAULT_CPE_ARRAY [FAULT_CPE_ARRAY_SIZE];
long int time_of_grace = 3600,timeout;
thread_download_is_working = TRUE;
while (list_download.next!=&(list_download))
{
download = list_entry(list_download.next,struct download, list);
current_time = time(NULL);
timeout = current_time - download->scheduled_time;
if((timeout >= 0)&&(timeout > time_of_grace))
{
pthread_mutex_lock (&mutex_download);
backup_session_delete_download(download->CommandKey,download->URL,download->scheduled_time);
p_soap_cwmp1__TransferComplete = cwmp_set_data_rpc_acs_transferComplete ();
if(p_soap_cwmp1__TransferComplete != NULL)
{
error = FAULT_CPE_DOWNLOAD_FAILURE_IDX;
download_completeTime = time((time_t*)NULL);
p_soap_cwmp1__TransferComplete->CommandKey = strdup(download->CommandKey);
p_soap_cwmp1__TransferComplete->StartTime = time((time_t*)NULL);
p_soap_cwmp1__TransferComplete->CompleteTime = p_soap_cwmp1__TransferComplete->StartTime;
sprintf(startTime,"%li",p_soap_cwmp1__TransferComplete->StartTime);
backup_session_insert_rpc("TransferComplete",p_soap_cwmp1__TransferComplete->CommandKey,RPC_NO_STATUS);
backup_session_insert_parameter("StartTime",startTime,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
backup_session_insert_parameter("CompleteTime",startTime,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
p_soap_cwmp1__TransferComplete->FaultStruct = calloc(1,sizeof(struct cwmp1__FaultStruct));
p_soap_cwmp1__TransferComplete->FaultStruct->FaultCode = strdup(FAULT_CPE_ARRAY[error].CODE);
p_soap_cwmp1__TransferComplete->FaultStruct->FaultString = strdup(FAULT_CPE_ARRAY[error].DESCRIPTION);
backup_session_insert_parameter("FaultCode",p_soap_cwmp1__TransferComplete->FaultStruct->FaultCode,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
cwmp_root_cause_TransferComplete (cwmp);
}
list_del (&(download->list));
count_download_queue--;
cwmp_free_download_request(download);
pthread_mutex_unlock (&mutex_download);
}
if((timeout >= 0)&&(timeout <= time_of_grace))
{
pthread_mutex_lock (&(cwmp->mutex_session_send));
CWMP_LOG(INFO,"Launch download file %s",download->URL);
error = cwmp_launch_download(cwmp,NULL,download);
if((error != FAULT_CPE_NO_FAULT_IDX)||(download_end_func == NULL))
{
cwmp_root_cause_TransferComplete (cwmp);
}
run_download_end_func (cwmp);
pthread_mutex_unlock (&(cwmp->mutex_session_send));
pthread_cond_signal (&(cwmp->threshold_session_send));
pthread_mutex_lock (&mutex_download);
list_del (&(download->list));
count_download_queue--;
cwmp_free_download_request(download);
pthread_mutex_unlock (&mutex_download);
continue;
}
pthread_mutex_lock (&mutex_download);
download_timeout.tv_sec = download->scheduled_time;
pthread_cond_timedwait(&threshold_download, &mutex_download, &download_timeout);
pthread_mutex_unlock (&mutex_download);
}
thread_download_is_working = FALSE;
return CWMP_OK;
}
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
int cwmp_rpc_cpe_download (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__DownloadResponse *p_soap_cwmp1__DownloadResponse;
struct _cwmp1__Download *p_soap_cwmp1__Download;
int error = FAULT_CPE_NO_FAULT_IDX;
int i;
char *url;
long int check_size;
struct download *download;
time_t scheduled_time;
struct list_head *ilist;
bool cond_signal = FALSE;
pthread_t download_thread;
char scheduledTime[64];
char delaySeconds[64];
bool valid_file_type = FALSE;
p_soap_cwmp1__Download = (struct _cwmp1__Download *)this->method_data;
p_soap_cwmp1__DownloadResponse = (struct _cwmp1__DownloadResponse *)this->method_response_data;
url = p_soap_cwmp1__Download->URL;
p_soap_cwmp1__DownloadResponse->Status = _cwmp1__DownloadResponse_Status__1;
for(i=0;i<sizearray(FILE_DOWNLOAD_TYPE_ARRAY);i++)
{
if(strcmp(FILE_DOWNLOAD_TYPE_ARRAY[i].FILE_TYPE,p_soap_cwmp1__Download->FileType) == 0)
{
valid_file_type = TRUE;
if(FILE_DOWNLOAD_TYPE_ARRAY[i].CHECK_SIZE == ENABLE_CHECK_SIZE)
{
if(FILE_DOWNLOAD_TYPE_ARRAY[i].UPDATE_VALUE != NULL)
{
FILE_DOWNLOAD_TYPE_ARRAY[i].UPDATE_VALUE();
}
check_size = *(FILE_DOWNLOAD_TYPE_ARRAY[i].MEMORY_SIZE);
}
break;
}
}
if((FILE_DOWNLOAD_TYPE_ARRAY[i].CHECK_SIZE == ENABLE_CHECK_SIZE) &&
((check_size>0)&&(check_size < (long int)p_soap_cwmp1__Download->FileSize)))
{
error = FAULT_CPE_DOWNLOAD_FAILURE_IDX;
}
else if(count_download_queue>=MAX_DOWNLOAD_QUEUE)
{
error = FAULT_CPE_RESOURCES_EXCEEDED_IDX;
}
else if((url == NULL || ((url != NULL) && (strcmp(url,"")==0)))||
(!valid_file_type))
{
error = FAULT_CPE_REQUEST_DENIED_IDX;
}
else if(strstr(url,"@") != NULL)
{
error = FAULT_CPE_INVALID_ARGUMENTS_IDX;
}
else if(strncmp(url,DOWNLOAD_PROTOCOL_HTTP,strlen(DOWNLOAD_PROTOCOL_HTTP))!=0 &&
strncmp(url,DOWNLOAD_PROTOCOL_FTP,strlen(DOWNLOAD_PROTOCOL_FTP))!=0)
{
error = FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL_IDX;
}
if(error != FAULT_CPE_NO_FAULT_IDX)
{
if (cwmp_add_session_rpc_cpe_Fault(session,error) == NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
if(p_soap_cwmp1__Download->DelaySeconds == 0)
{
download = calloc (1,sizeof(struct download));
if (download == NULL)
{
return CWMP_GEN_ERR;
}
download->CommandKey = strdup(p_soap_cwmp1__Download->CommandKey);
download->FileType = strdup(p_soap_cwmp1__Download->FileType);
download->URL = strdup(p_soap_cwmp1__Download->URL);
download->Username = strdup(p_soap_cwmp1__Download->Username);
download->Password = strdup(p_soap_cwmp1__Download->Password);
download->scheduled_time = 0;
error = cwmp_launch_download(cwmp,session,download);
if((error != FAULT_CPE_NO_FAULT_IDX)||(FILE_DOWNLOAD_TYPE_ARRAY[i].APPLY_AFTER_REBOOT == 0))
{
if(cwmp_root_cause_TransferComplete (cwmp) != CWMP_OK)
{
cwmp_free_download_request(download);
return CWMP_GEN_ERR;
}
}
cwmp_free_download_request(download);
}
else
{
pthread_mutex_lock (&mutex_download);
scheduled_time = time(NULL) + p_soap_cwmp1__Download->DelaySeconds;
__list_for_each(ilist,&(list_download))
{
download = list_entry(ilist,struct download, list);
if (download->scheduled_time == scheduled_time)
{
pthread_mutex_unlock (&mutex_download);
return CWMP_OK;
}
if (download->scheduled_time > scheduled_time)
{
cond_signal = TRUE;
break;
}
}
CWMP_LOG(INFO,"Download will start in %us",p_soap_cwmp1__Download->DelaySeconds);
download = calloc (1,sizeof(struct download));
if (download == NULL)
{
pthread_mutex_unlock (&mutex_download);
return CWMP_OK;
}
download->CommandKey = strdup(p_soap_cwmp1__Download->CommandKey);
download->FileType = strdup(p_soap_cwmp1__Download->FileType);
download->URL = strdup(p_soap_cwmp1__Download->URL);
download->Username = strdup(p_soap_cwmp1__Download->Username);
download->Password = strdup(p_soap_cwmp1__Download->Password);
download->scheduled_time = scheduled_time;
backup_session_insert_download(download->CommandKey,download->URL,download->scheduled_time);
backup_session_insert_parameter_download("Password",download->Password,download->URL,download->scheduled_time,download->CommandKey);
backup_session_insert_parameter_download("Username",download->Username,download->URL,download->scheduled_time,download->CommandKey);
backup_session_insert_parameter_download("FileType",download->FileType,download->URL,download->scheduled_time,download->CommandKey);
list_add (&(download->list), ilist->prev);
count_download_queue++;
if (cond_signal)
{
pthread_cond_signal(&threshold_download);
}
pthread_mutex_unlock (&mutex_download);
if (!thread_download_is_working)
{
thread_download_is_working = TRUE;
error = pthread_create(&download_thread, NULL, &thread_cwmp_rpc_cpe_download, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the download thread!");
thread_download_is_working = FALSE;
return CWMP_OK;
}
}
}
return CWMP_OK;
}
int cwmp_rpc_cpe_download_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_download_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_download_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_launch_download(struct cwmp *cwmp, struct session *session, struct download *pDownload)
{
CURL *curl;
FILE *fp;
CURLcode res;
int error = FAULT_CPE_NO_FAULT_IDX;
int i;
char filename[256];
int (*doDownload)(struct cwmp *cwmp, struct session *session);
time_t download_startTime;
time_t download_completeTime;
char startTime[64];
char completeTime[64];
struct _cwmp1__TransferComplete *p_soap_cwmp1__TransferComplete;
extern struct FAULT_CPE FAULT_CPE_ARRAY [FAULT_CPE_ARRAY_SIZE];
char userpwd[256];
download_startTime = time((time_t*)NULL);
if(pDownload->scheduled_time != 0)
{
backup_session_delete_download(pDownload->CommandKey,pDownload->URL,pDownload->scheduled_time);
}
for(i=0;i<sizearray(FILE_DOWNLOAD_TYPE_ARRAY);i++)
{
if(strcmp(FILE_DOWNLOAD_TYPE_ARRAY[i].FILE_TYPE,pDownload->FileType) == 0)
{
doDownload = FILE_DOWNLOAD_TYPE_ARRAY[i].DOWNLOAD;
strcpy(filename,FILE_DOWNLOAD_TYPE_ARRAY[i].FILE_NAME);
break;
}
}
curl = curl_easy_init();
if (curl)
{
fp = fopen(filename,"wb");
if((strcmp(pDownload->URL,"") != 0)&&
(pDownload->URL != NULL))
{
#if LIBCURL_VERSION_NUM >= 0x071301
if((strcmp(pDownload->Username,"") != 0)&&
(pDownload->Username != NULL))
{
curl_easy_setopt(curl, CURLOPT_USERNAME, pDownload->Username);
}
if((strcmp(pDownload->Password,"") != 0)&&
(pDownload->Password != NULL))
{
curl_easy_setopt(curl, CURLOPT_PASSWORD, pDownload->Password);
}
#else
if(((strcmp(pDownload->Username,"") != 0)&&(pDownload->Username != NULL))&&
(strcmp(pDownload->Password,"") != 0)&&(pDownload->Password != NULL))
{
sprintf(userpwd,"%s:%s",pDownload->Username,pDownload->Password);
curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd);
}
#endif
curl_easy_setopt(curl, CURLOPT_URL, pDownload->URL);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, TRUE);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
fclose(fp);
}
if(res != CURLE_OK)
{
remove(filename);
}
switch(res)
{
case CURLE_OK:
error = FAULT_CPE_NO_FAULT_IDX; /** No fault code **/
break;
case CURLE_UNSUPPORTED_PROTOCOL:
#if LIBCURL_VERSION_NUM >= 0x071100
case CURLE_REMOTE_ACCESS_DENIED:
#endif
error = FAULT_CPE_REQUEST_DENIED_IDX; /** Request denied **/
break;
case CURLE_OUT_OF_MEMORY:
error = FAULT_CPE_INTERNAL_ERROR_IDX; /** Internal error **/
break;
case CURLE_FTP_CANT_GET_HOST:
case CURLE_URL_MALFORMAT:
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_COULDNT_CONNECT:
error = FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER_IDX; /** Download failure: unable to contact file server **/
break;
case CURLE_FTP_COULDNT_RETR_FILE:
#if LIBCURL_VERSION_NUM >= 0x071001
case CURLE_REMOTE_FILE_NOT_FOUND:
#endif
#if LIBCURL_VERSION_NUM >= 0x070a03
case CURLE_HTTP_RETURNED_ERROR:
#endif
#if LIBCURL_VERSION_NUM >= 0x071500
case CURLE_FTP_BAD_FILE_LIST:
#endif
#if LIBCURL_VERSION_NUM >= 0x070901
case CURLE_GOT_NOTHING:
#endif
error = FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE_IDX; /** Download failure: unable to access file **/
break;
#if LIBCURL_VERSION_NUM >= 0x070a02
case CURLE_OPERATION_TIMEDOUT:
error = FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD_IDX; /** Download failure: unable to complete download **/
break;
#endif
#if LIBCURL_VERSION_NUM >= 0x070d01
case CURLE_LOGIN_DENIED:
error = FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION_IDX; /** Download failure: file authentication failure **/
break;
#endif
default:
error = FAULT_CPE_DOWNLOAD_FAILURE_IDX; /** Download failure **/
break;
}
if(error == FAULT_CPE_NO_FAULT_IDX)
{
error = doDownload (cwmp,session);
}
p_soap_cwmp1__TransferComplete = cwmp_set_data_rpc_acs_transferComplete ();
if(p_soap_cwmp1__TransferComplete == NULL)
{
error = FAULT_CPE_INTERNAL_ERROR_IDX;
return error;
}
download_completeTime = time((time_t*)NULL);
p_soap_cwmp1__TransferComplete->CommandKey = strdup(pDownload->CommandKey);
p_soap_cwmp1__TransferComplete->StartTime = download_startTime;
p_soap_cwmp1__TransferComplete->CompleteTime = download_completeTime;
sprintf(startTime,"%li",p_soap_cwmp1__TransferComplete->StartTime);
sprintf(completeTime,"%li",download_completeTime);
backup_session_insert_rpc("TransferComplete",p_soap_cwmp1__TransferComplete->CommandKey,RPC_NO_STATUS);
backup_session_insert_parameter("StartTime",startTime,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
backup_session_insert_parameter("CompleteTime",completeTime,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
if(error != FAULT_CPE_NO_FAULT_IDX)
{
p_soap_cwmp1__TransferComplete->FaultStruct = calloc(1,sizeof(struct cwmp1__FaultStruct));
p_soap_cwmp1__TransferComplete->FaultStruct->FaultCode = strdup(FAULT_CPE_ARRAY[error].CODE);
p_soap_cwmp1__TransferComplete->FaultStruct->FaultString = strdup(FAULT_CPE_ARRAY[error].DESCRIPTION);
backup_session_insert_parameter("FaultCode",p_soap_cwmp1__TransferComplete->FaultStruct->FaultCode,"rpc","TransferComplete",-1,p_soap_cwmp1__TransferComplete->CommandKey);
}
return error;
}
int cwmp_download_firmware (struct cwmp *cwmp, struct session *session)
{
int error = FAULT_CPE_NO_FAULT_IDX;
error = uci_upgrade_image(cwmp,session);
return error;
}
int cwmp_download_web_content (struct cwmp *cwmp, struct session *session)
{
int error = FAULT_CPE_NO_FAULT_IDX;
error = uci_apply_web_packages();
return error;
}
int cwmp_download_configuration_file (struct cwmp *cwmp, struct session *session)
{
int error = FAULT_CPE_NO_FAULT_IDX;
error = uci_apply_configuration();
if(error == FAULT_CPE_NO_FAULT_IDX)
{
if(session != NULL)
{
add_session_end_func(session,cwmp_reboot,NULL,TRUE);
}
else
{
add_download_end_func(cwmp_reboot,NULL);
}
}
return error;
}
int cwmp_free_download_request(struct download *download)
{
if(download != NULL)
{
if(download->CommandKey != NULL)
{
free(download->CommandKey);
}
if(download->FileType != NULL)
{
free(download->FileType);
}
if(download->URL != NULL)
{
free(download->URL);
}
if(download->Username != NULL)
{
free(download->Username);
}
if(download->Password != NULL)
{
free(download->Password);
}
free(download);
}
return CWMP_OK;
}
int add_download_end_func (int (*func)(struct cwmp *cwmp, void *input),void *input)
{
download_end_func = calloc(1,sizeof(struct download_end_func));
if(download_end_func == NULL)
{
return CWMP_MEM_ERR;
}
download_end_func->func = func;
download_end_func->input = input;
return CWMP_OK;
}
int run_download_end_func (struct cwmp *cwmp)
{
int error = CWMP_OK;
if(download_end_func != NULL)
{
error = download_end_func->func(cwmp,download_end_func->input);
free (download_end_func);
download_end_func = NULL;
}
return error;
}
int cwmp_scheduledDownload_remove_all()
{
struct download *download;
pthread_mutex_lock (&mutex_download);
while (list_download.next!=&(list_download))
{
download = list_entry(list_download.next,struct download, list);
list_del (&(download->list));
backup_session_delete_download(download->CommandKey,download->URL,download->scheduled_time);
count_download_queue--;
cwmp_free_download_request(download);
}
pthread_mutex_unlock (&mutex_download);
return CWMP_OK;
}

79
src/FactoryReset.c Normal file
View file

@ -0,0 +1,79 @@
/*
FactoryReset.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include "soapH.h"
#include "cwmp.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_factoryReset (struct session *session);
int cwmp_rpc_cpe_factoryReset (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_factoryReset_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_factoryReset_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_factoryReset_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
int cwmp_reset_factory(struct cwmp *cwmp,void *v);
struct rpc_cpe *cwmp_add_session_rpc_cpe_factoryReset (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__FactoryReset));
rpc_cpe->method = cwmp_rpc_cpe_factoryReset;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__FactoryResetResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_factoryReset_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_factoryReset_response;
rpc_cpe->method_end = cwmp_rpc_cpe_factoryReset_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:FactoryReset";
soap_methods->envelope_response = "cwmp:FactoryResetResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__FactoryReset;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__FactoryReset;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__FactoryReset;
return rpc_cpe;
}
int cwmp_rpc_cpe_factoryReset (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
add_session_end_func(session,cwmp_reset_factory,NULL,TRUE);
return CWMP_OK;
}
int cwmp_rpc_cpe_factoryReset_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_factoryReset_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_factoryReset_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}

211
src/Fault_cpe.c Normal file
View file

@ -0,0 +1,211 @@
/*
Fault_cpe.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#define FAULT_CPE_TYPE_CLIENT 0
#define FAULT_CPE_TYPE_SERVER 1
char *FAULT_CPE_ARRAY_TYPE [] = {
[FAULT_CPE_TYPE_CLIENT] = "Client",
[FAULT_CPE_TYPE_SERVER] = "Server"
};
struct FAULT_CPE FAULT_CPE_ARRAY [] = {
[FAULT_CPE_NO_FAULT_IDX] = {NULL, 0, NULL},
[FAULT_CPE_METHOD_NOT_SUPPORTED_IDX] = {"9000",FAULT_CPE_TYPE_SERVER, "Method not supported"},
[FAULT_CPE_REQUEST_DENIED_IDX] = {"9001",FAULT_CPE_TYPE_SERVER, "Request denied (no reason specified)"},
[FAULT_CPE_INTERNAL_ERROR_IDX] = {"9002",FAULT_CPE_TYPE_SERVER, "Internal error"},
[FAULT_CPE_INVALID_ARGUMENTS_IDX] = {"9003",FAULT_CPE_TYPE_CLIENT, "Invalid arguments"},
[FAULT_CPE_RESOURCES_EXCEEDED_IDX] = {"9004",FAULT_CPE_TYPE_SERVER, "Resources exceeded"},
[FAULT_CPE_INVALID_PARAMETER_NAME_IDX] = {"9005",FAULT_CPE_TYPE_CLIENT, "Invalid parameter name"},
[FAULT_CPE_INVALID_PARAMETER_TYPE_IDX] = {"9006",FAULT_CPE_TYPE_CLIENT, "Invalid parameter type"},
[FAULT_CPE_INVALID_PARAMETER_VALUE_IDX] = {"9007",FAULT_CPE_TYPE_CLIENT, "Invalid parameter value"},
[FAULT_CPE_NON_WRITABLE_PARAMETER_IDX] = {"9008",FAULT_CPE_TYPE_CLIENT, "Attempt to set a non-writable parameter"},
[FAULT_CPE_NOTIFICATION_REJECTED_IDX] = {"9009",FAULT_CPE_TYPE_SERVER, "Notification request rejected"},
[FAULT_CPE_DOWNLOAD_FAILURE_IDX] = {"9010",FAULT_CPE_TYPE_SERVER, "Download failure"},
[FAULT_CPE_UPLOAD_FAILURE_IDX] = {"9011",FAULT_CPE_TYPE_SERVER, "Upload failure"},
[FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE_IDX]= {"9012",FAULT_CPE_TYPE_SERVER, "File transfer server authentication failure"},
[FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL_IDX] = {"9013",FAULT_CPE_TYPE_SERVER, "Unsupported protocol for file transfer"},
[FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP_IDX] = {"9014",FAULT_CPE_TYPE_SERVER, "Download failure: unable to join multicast group"},
[FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER_IDX] = {"9015",FAULT_CPE_TYPE_SERVER, "Download failure: unable to contact file server"},
[FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE_IDX] = {"9016",FAULT_CPE_TYPE_SERVER, "Download failure: unable to access file"},
[FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD_IDX] = {"9017",FAULT_CPE_TYPE_SERVER, "Download failure: unable to complete download"},
[FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED_IDX] = {"9018",FAULT_CPE_TYPE_SERVER, "Download failure: file corrupted"},
[FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION_IDX] = {"9019",FAULT_CPE_TYPE_SERVER, "Download failure: file authentication failure"}
};
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
int cwmp_rpc_cpe_fault (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_fault_response_data_init (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_fault_response (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_fault_end (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_fault_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
SOAP_FMAC3 void SOAP_FMAC4 soap_serialize_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a);
SOAP_FMAC3 int SOAP_FMAC4 soap_put_SOAP_ENV__Fault(struct soap *soap, const struct SOAP_ENV__Fault *a, const char *tag, const char *type);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
struct fault *fault;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
fault = &(rpc_cpe->fault);
rpc_cpe->method_data = NULL;
rpc_cpe->method = cwmp_rpc_cpe_fault;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct SOAP_ENV__Fault));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_fault_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_fault_response;
rpc_cpe->method_end = cwmp_rpc_cpe_fault_end;
rpc_cpe->destructor = cwmp_rpc_cpe_fault_destructor;
soap_methods->envelope = "";
soap_methods->envelope_response = "SOAP-ENV:Fault";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize_SOAP_ENV__Fault;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put_SOAP_ENV__Fault;
soap_methods->soap_get_cwmp1__rpc_received_data = NULL;
fault->code_idx = idx;
return rpc_cpe;
}
int cwmp_rpc_cpe_fault (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_fault_response_data_init (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct SOAP_ENV__Fault *p_soap_Fault;
struct _cwmp1__Fault *fault;
struct fault *rpc_fault;
struct SOAP_ENV__Detail *detail;
int type_idx;
if (session==NULL || this==NULL)
{
return CWMP_GEN_ERR;
}
p_soap_Fault = (struct SOAP_ENV__Fault *) this->method_response_data;
rpc_fault = &(this->fault);
type_idx = FAULT_CPE_ARRAY[rpc_fault->code_idx].TYPE;
p_soap_Fault->faultcode = FAULT_CPE_ARRAY_TYPE[type_idx];
p_soap_Fault->faultstring = "CWMP fault";
p_soap_Fault->detail = (struct SOAP_ENV__Detail *) calloc(1, sizeof(struct SOAP_ENV__Detail));
if (p_soap_Fault->detail == NULL)
{
return CWMP_MEM_ERR;
}
detail = p_soap_Fault->detail;
detail->__type = SOAP_TYPE__cwmp1__Fault;
detail->fault = (struct _cwmp1__Fault *) calloc(1, sizeof(struct _cwmp1__Fault));
if (detail->fault == NULL)
{
return CWMP_MEM_ERR;
}
fault = (struct _cwmp1__Fault *) detail->fault;
fault->FaultCode = FAULT_CPE_ARRAY[rpc_fault->code_idx].CODE;
fault->FaultString = FAULT_CPE_ARRAY[rpc_fault->code_idx].DESCRIPTION;
if (rpc_fault->parameter_cause!=NULL)
{
fault->SetParameterValuesFault = (struct _cwmp1__Fault_SetParameterValuesFault *) calloc(1, sizeof(struct _cwmp1__Fault_SetParameterValuesFault));
fault->SetParameterValuesFault->FaultCode = strdup(FAULT_CPE_ARRAY[rpc_fault->code_idx].CODE);
fault->SetParameterValuesFault->FaultString = strdup(FAULT_CPE_ARRAY[rpc_fault->code_idx].DESCRIPTION);
fault->SetParameterValuesFault->ParameterName = rpc_fault->parameter_cause;
fault->__sizeSetParameterValuesFault = 1;
}
return CWMP_OK;
}
int cwmp_rpc_cpe_fault_response (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send Fault response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_Fault_parameter_cause (struct rpc_cpe *this, char *parameter)
{
this->fault.parameter_cause = strdup(parameter);
return CWMP_OK;
}
int cwmp_rpc_cpe_fault_end (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct SOAP_ENV__Fault *p_soap_Fault;
struct _cwmp1__Fault *fault;
struct SOAP_ENV__Detail *detail;
p_soap_Fault = (struct SOAP_ENV__Fault *) this->method_response_data;
if (p_soap_Fault!=NULL)
{
detail = p_soap_Fault->detail;
if (detail!=NULL)
{
fault = (struct _cwmp1__Fault *)detail->fault;
if (fault->SetParameterValuesFault!=NULL)
{
if (fault->SetParameterValuesFault->FaultCode!=NULL)
{
free (fault->SetParameterValuesFault->FaultCode);
}
if (fault->SetParameterValuesFault->FaultString!=NULL)
{
free (fault->SetParameterValuesFault->FaultString);
}
free (fault->SetParameterValuesFault);
}
if (fault!=NULL)
{
free (fault);
}
free (detail);
}
}
return CWMP_OK;
}
int cwmp_rpc_cpe_fault_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct SOAP_ENV__Fault *p_soap_Fault;
p_soap_Fault = (struct SOAP_ENV__Fault *) this->method_response_data;
if (p_soap_Fault!=NULL)
{
free (p_soap_Fault);
}
if (this->fault.parameter_cause!=NULL)
{
free (this->fault.parameter_cause);
}
list_del(&(this->list));
free (this);
return CWMP_OK;
}

View file

@ -0,0 +1,216 @@
/*
GetParameterAttributes.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterAttributes (struct session *session);
int cwmp_rpc_cpe_getParameterAttributes (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterAttributes_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterAttributes_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterAttributes_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int cwmp_dm_getParameterAttributes(struct cwmp *cwmp, char *path, struct list_head *list, int *n);
int free_list_getParameterAttributes(struct list_head *list);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterAttributes (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterAttributes));
rpc_cpe->method = cwmp_rpc_cpe_getParameterAttributes;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterAttributesResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_getParameterAttributes_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_getParameterAttributes_response;
rpc_cpe->method_end = cwmp_rpc_cpe_getParameterAttributes_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:GetParameterAttributes";
soap_methods->envelope_response = "cwmp:GetParameterAttributesResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__GetParameterAttributesResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__GetParameterAttributesResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__GetParameterAttributes;
return rpc_cpe;
}
int cwmp_rpc_cpe_getParameterAttributes (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterAttributes_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterAttributes *p_soap_cwmp1__GetParameterAttributes;
struct _cwmp1__GetParameterAttributesResponse *p_soap_cwmp1__GetParameterAttributesResponse;
struct cwmp1__ParameterAttributeStruct **ptr_ParameterAttributeStruct;
struct cwmp1ParameterAttributeList *ParameterList;
char **name;
int i,n,size,error;
int size_response = 0;
LIST_HEAD(list_ParameterAttributesStruct);
p_soap_cwmp1__GetParameterAttributes = (struct _cwmp1__GetParameterAttributes *)this->method_data;
p_soap_cwmp1__GetParameterAttributesResponse = (struct _cwmp1__GetParameterAttributesResponse *)this->method_response_data;
name = p_soap_cwmp1__GetParameterAttributes->ParameterNames->__ptrstring;
size = p_soap_cwmp1__GetParameterAttributes->ParameterNames->__size;
for(i=0;i<size;i++,name++)
{
error = cwmp_dm_getParameterAttributes(cwmp, *name, &list_ParameterAttributesStruct,&n);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
free_list_getParameterAttributes(&list_ParameterAttributesStruct);
if (cwmp_add_session_rpc_cpe_Fault(session,error)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
size_response += n;
}
ParameterList = calloc(1,sizeof(struct cwmp1ParameterAttributeList));
ptr_ParameterAttributeStruct = calloc(size_response, sizeof(struct cwmp1__ParameterAttributeStruct *));
if(ParameterList == NULL ||
ptr_ParameterAttributeStruct == NULL)
{
return CWMP_MEM_ERR;
}
ParameterList->__size = size_response;
ParameterList->__ptrParameterAttributeStruct = ptr_ParameterAttributeStruct;
p_soap_cwmp1__GetParameterAttributesResponse->ParameterList = ParameterList;
while(!list_empty(&list_ParameterAttributesStruct))
{
struct handler_ParameterAttributeStruct *handler_ParameterAttributeStruct;
handler_ParameterAttributeStruct = list_entry (list_ParameterAttributesStruct.next, struct handler_ParameterAttributeStruct, list);
*ptr_ParameterAttributeStruct = handler_ParameterAttributeStruct->ParameterAttributeStruct;
ptr_ParameterAttributeStruct++;
list_del(list_ParameterAttributesStruct.next);
free(handler_ParameterAttributeStruct);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterAttributes_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send GetParameterAttributes response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_getParameterAttributes_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterAttributesResponse *p_soap_cwmp1__GetParameterAttributesResponse;
struct cwmp1__ParameterAttributeStruct **ptrParameterAttributeStruct,*pParameterAttributeStruct;
char **ptrAccessList,*pAccessList;
int i,j,size_ParameterAttributeStruct,size_AccessList;
p_soap_cwmp1__GetParameterAttributesResponse = (struct _cwmp1__GetParameterAttributesResponse *)this->method_response_data;
if(p_soap_cwmp1__GetParameterAttributesResponse->ParameterList != NULL)
{
size_ParameterAttributeStruct = p_soap_cwmp1__GetParameterAttributesResponse->ParameterList->__size;
ptrParameterAttributeStruct = p_soap_cwmp1__GetParameterAttributesResponse->ParameterList->__ptrParameterAttributeStruct;
for(i=0;i<size_ParameterAttributeStruct;i++)
{
pParameterAttributeStruct = *ptrParameterAttributeStruct;
if(pParameterAttributeStruct != NULL)
{
if(pParameterAttributeStruct->Name != NULL)
{
free(pParameterAttributeStruct->Name);
}
if(pParameterAttributeStruct->AccessList != NULL)
{
size_AccessList = pParameterAttributeStruct->AccessList->__size;
ptrAccessList = pParameterAttributeStruct->AccessList->__ptrstring;
for(j=0;j<size_AccessList;j++)
{
pAccessList = *ptrAccessList;
ptrAccessList++;
if(pAccessList != NULL)
{
free(pAccessList);
}
}
free(pParameterAttributeStruct->AccessList);
}
ptrParameterAttributeStruct++;
free(pParameterAttributeStruct);
}
}
free(p_soap_cwmp1__GetParameterAttributesResponse->ParameterList);
}
return CWMP_OK;
}
int free_list_getParameterAttributes(struct list_head *list)
{
struct handler_ParameterAttributeStruct *handler_ParameterAttributeStruct;
struct cwmp1__ParameterAttributeStruct *ParameterAttributeStruct;
int i;
char **pAccessList;
while(list->next!=list)
{
handler_ParameterAttributeStruct = list_entry (list->next, struct handler_ParameterAttributeStruct, list);
ParameterAttributeStruct = handler_ParameterAttributeStruct->ParameterAttributeStruct;
if (ParameterAttributeStruct!=NULL)
{
if (ParameterAttributeStruct->Name!=NULL)
{
free(ParameterAttributeStruct->Name);
}
if (ParameterAttributeStruct->AccessList!=NULL)
{
if (ParameterAttributeStruct->AccessList->__ptrstring!=NULL)
{
pAccessList = ParameterAttributeStruct->AccessList->__ptrstring;
for(i=0;i<ParameterAttributeStruct->AccessList->__size;i++,pAccessList++)
{
if(*pAccessList!=NULL)
{
free(*pAccessList);
}
}
free(ParameterAttributeStruct->AccessList->__ptrstring);
}
free(ParameterAttributeStruct->AccessList);
}
free(ParameterAttributeStruct);
}
list_del(list->next);
free (handler_ParameterAttributeStruct);
}
return CWMP_OK;
}

180
src/GetParameterNames.c Normal file
View file

@ -0,0 +1,180 @@
/*
GetParameterNames.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterNames (struct session *session);
int cwmp_rpc_cpe_getParameterNames (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterNames_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterNames_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterNames_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_dm_getParameterNames(struct cwmp *cwmp, char *path, struct list_head *list, int *n, enum xsd__boolean NextLevel);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
static int free_list_getParameterNames(struct list_head *list);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
extern const struct CPE_METHOD_CONSTRUCTORS CPE_METHOD_CONSTRUCTORS_ARRAY [COUNT_RPC_CPE];
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterNames (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterNames));
rpc_cpe->method = cwmp_rpc_cpe_getParameterNames;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterNamesResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_getParameterNames_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_getParameterNames_response;
rpc_cpe->method_end = cwmp_rpc_cpe_getParameterNames_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:GetParameterNames";
soap_methods->envelope_response = "cwmp:GetParameterNamesResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__GetParameterNamesResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__GetParameterNamesResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__GetParameterNames;
return rpc_cpe;
}
int cwmp_rpc_cpe_getParameterNames (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterNames *p_soap_cwmp1__GetParameterNames;
struct _cwmp1__GetParameterNamesResponse *p_soap_cwmp1__GetParameterNamesResponse;
struct cwmp1ParameterInfoList *ParameterList;
struct cwmp1__ParameterInfoStruct **ptrParameterInfoStruct;
char *ParameterPath;
enum xsd__boolean NextLevel;
int i,size,error;
LIST_HEAD(list_ParameterInfoStruct);
p_soap_cwmp1__GetParameterNames = (struct _cwmp1__GetParameterNames *)this->method_data;
p_soap_cwmp1__GetParameterNamesResponse = (struct _cwmp1__GetParameterNamesResponse *)this->method_response_data;
ParameterPath = *(p_soap_cwmp1__GetParameterNames->ParameterPath);
NextLevel = p_soap_cwmp1__GetParameterNames->NextLevel;
CWMP_LOG(INFO,"ParameterPath = \"%s\"", ParameterPath);
error = cwmp_dm_getParameterNames(cwmp, ParameterPath, &list_ParameterInfoStruct, &size,NextLevel);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
free_list_getParameterNames(&list_ParameterInfoStruct);
if (cwmp_add_session_rpc_cpe_Fault(session,error)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
ParameterList = calloc(1,sizeof(struct cwmp1ParameterInfoList));
ptrParameterInfoStruct = calloc(size,sizeof(struct cwmp1__ParameterInfoStruct *));
if (ParameterList == NULL ||
ptrParameterInfoStruct == NULL)
{
return CWMP_MEM_ERR;
}
ParameterList->__size = size;
ParameterList->__ptrParameterInfoStruct = ptrParameterInfoStruct;
p_soap_cwmp1__GetParameterNamesResponse->ParameterList = ParameterList;
while(list_ParameterInfoStruct.next!=&list_ParameterInfoStruct)
{
struct handler_ParameterInfoStruct *handler_ParameterInfoStruct;
handler_ParameterInfoStruct = list_entry(list_ParameterInfoStruct.next,struct handler_ParameterInfoStruct,list);
*ptrParameterInfoStruct = handler_ParameterInfoStruct->ParameterInfoStruct;
ptrParameterInfoStruct++;
list_del(list_ParameterInfoStruct.next);
free (handler_ParameterInfoStruct);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterNames_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterNames_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send GetParameterNames response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_getParameterNames_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterNames *p_soap_cwmp1__GetParameterNames;
struct _cwmp1__GetParameterNamesResponse *p_soap_cwmp1__GetParameterNamesResponse;
struct cwmp1ParameterInfoList *ParameterList;
struct cwmp1__ParameterInfoStruct **ptrParameterInfoStruct,*ParameterInfoStruct;
int i;
p_soap_cwmp1__GetParameterNamesResponse = (struct _cwmp1__GetParameterNamesResponse *)this->method_response_data;
if (p_soap_cwmp1__GetParameterNamesResponse!=NULL)
{
if (p_soap_cwmp1__GetParameterNamesResponse->ParameterList != NULL)
{
if(p_soap_cwmp1__GetParameterNamesResponse->ParameterList->__ptrParameterInfoStruct != NULL)
{
ptrParameterInfoStruct = p_soap_cwmp1__GetParameterNamesResponse->ParameterList->__ptrParameterInfoStruct;
for (i=0;i<p_soap_cwmp1__GetParameterNamesResponse->ParameterList->__size;i++,ptrParameterInfoStruct++)
{
ParameterInfoStruct = *ptrParameterInfoStruct;
if (ParameterInfoStruct!=NULL)
{
if (ParameterInfoStruct->Name!=NULL)
{
free(ParameterInfoStruct->Name);
}
free(ParameterInfoStruct);
}
}
free (p_soap_cwmp1__GetParameterNamesResponse->ParameterList->__ptrParameterInfoStruct);
}
free (p_soap_cwmp1__GetParameterNamesResponse->ParameterList);
}
}
return CWMP_OK;
}
static int free_list_getParameterNames(struct list_head *list)
{
struct handler_ParameterInfoStruct *handler_ParameterInfoStruct;
struct cwmp1__ParameterInfoStruct *ParameterInfoStruct;
while(list->next!=list)
{
handler_ParameterInfoStruct = list_entry(list->next,struct handler_ParameterInfoStruct,list);
ParameterInfoStruct = handler_ParameterInfoStruct->ParameterInfoStruct;
if (ParameterInfoStruct!=NULL)
{
if (ParameterInfoStruct->Name!=NULL)
{
free(ParameterInfoStruct->Name);
}
free(ParameterInfoStruct);
}
list_del(list->next);
free (handler_ParameterInfoStruct);
}
return CWMP_OK;
}

190
src/GetParameterValues.c Normal file
View file

@ -0,0 +1,190 @@
/*
GetParameterValues.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterValues (struct session *session);
int cwmp_rpc_cpe_getParameterValues (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterValues_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterValues_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getParameterValues_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_dm_getParameterValues(struct cwmp *cwmp, char *name, struct list_head *list, int *n);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int free_list_getParameterValues(struct list_head *list);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
extern const struct CPE_METHOD_CONSTRUCTORS CPE_METHOD_CONSTRUCTORS_ARRAY [COUNT_RPC_CPE];
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterValues (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterValues));
rpc_cpe->method = cwmp_rpc_cpe_getParameterValues;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__GetParameterValuesResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_getParameterValues_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_getParameterValues_response;
rpc_cpe->method_end = cwmp_rpc_cpe_getParameterValues_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:GetParameterValues";
soap_methods->envelope_response = "cwmp:GetParameterValuesResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__GetParameterValuesResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__GetParameterValuesResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__GetParameterValues;
return rpc_cpe;
}
int cwmp_rpc_cpe_getParameterValues (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterValues *p_soap_cwmp1__GetParameterValues;
struct _cwmp1__GetParameterValuesResponse *p_soap_cwmp1__GetParameterValuesResponse;
struct cwmp1ParameterValueList *ParameterList;
struct cwmp1__ParameterValueStruct **ptr_ParameterValueStruct;
char **name;
int i,n,size,error;
int size_resp=0;
LIST_HEAD(list_ParameterValueStruct);
p_soap_cwmp1__GetParameterValues = (struct _cwmp1__GetParameterValues *)this->method_data;
p_soap_cwmp1__GetParameterValuesResponse = (struct _cwmp1__GetParameterValuesResponse *)this->method_response_data;
name = p_soap_cwmp1__GetParameterValues->ParameterNames->__ptrstring;
size = p_soap_cwmp1__GetParameterValues->ParameterNames->__size;
for (i=0;i<size;i++,name++)
{
CWMP_LOG(INFO,"param[%d] = \"%s\"",i,*name);
error = cwmp_dm_getParameterValues(cwmp, *name, &list_ParameterValueStruct,&n);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
free_list_getParameterValues(&list_ParameterValueStruct);
if (cwmp_add_session_rpc_cpe_Fault(session,error)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
size_resp += n;
}
ParameterList = calloc(1,sizeof(struct cwmp1ParameterValueList));
ptr_ParameterValueStruct = calloc(size_resp,sizeof(struct cwmp1__ParameterValueStruct *));
if (ParameterList == NULL ||
ptr_ParameterValueStruct == NULL)
{
return CWMP_MEM_ERR;
}
ParameterList->__size = size_resp;
ParameterList->__ptrParameterValueStruct = ptr_ParameterValueStruct;
p_soap_cwmp1__GetParameterValuesResponse->ParameterList = ParameterList;
while(list_ParameterValueStruct.next!=&list_ParameterValueStruct)
{
struct handler_ParameterValueStruct *handler_ParameterValueStruct;
handler_ParameterValueStruct = list_entry(list_ParameterValueStruct.next,struct handler_ParameterValueStruct,list);
*ptr_ParameterValueStruct = handler_ParameterValueStruct->ParameterValueStruct;
ptr_ParameterValueStruct++;
list_del(list_ParameterValueStruct.next);
free (handler_ParameterValueStruct);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterValues_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_getParameterValues_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send GetParameterValues response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_getParameterValues_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetParameterValues *p_soap_cwmp1__GetParameterValues;
struct _cwmp1__GetParameterValuesResponse *p_soap_cwmp1__GetParameterValuesResponse;
struct cwmp1__ParameterValueStruct **ptr_ParameterValueStruct,*ParameterValueStruct;
int i;
p_soap_cwmp1__GetParameterValuesResponse = (struct _cwmp1__GetParameterValuesResponse *)this->method_response_data;
if (p_soap_cwmp1__GetParameterValuesResponse!=NULL)
{
if (p_soap_cwmp1__GetParameterValuesResponse->ParameterList != NULL)
{
if(p_soap_cwmp1__GetParameterValuesResponse->ParameterList->__ptrParameterValueStruct != NULL)
{
ptr_ParameterValueStruct = p_soap_cwmp1__GetParameterValuesResponse->ParameterList->__ptrParameterValueStruct;
for (i=0;i<p_soap_cwmp1__GetParameterValuesResponse->ParameterList->__size;i++,ptr_ParameterValueStruct++)
{
ParameterValueStruct = *ptr_ParameterValueStruct;
if (ParameterValueStruct!=NULL)
{
if (ParameterValueStruct->Name!=NULL)
{
free(ParameterValueStruct->Name);
}
if (ParameterValueStruct->Value!=NULL)
{
free(ParameterValueStruct->Value);
}
free(ParameterValueStruct);
}
}
free (p_soap_cwmp1__GetParameterValuesResponse->ParameterList->__ptrParameterValueStruct);
}
free (p_soap_cwmp1__GetParameterValuesResponse->ParameterList);
}
}
return CWMP_OK;
}
int free_list_getParameterValues(struct list_head *list)
{
struct handler_ParameterValueStruct *handler_ParameterValueStruct;
struct cwmp1__ParameterValueStruct *ParameterValueStruct;
while(list->next!=list)
{
handler_ParameterValueStruct = list_entry(list->next,struct handler_ParameterValueStruct,list);
ParameterValueStruct = handler_ParameterValueStruct->ParameterValueStruct;
if (ParameterValueStruct!=NULL)
{
if (ParameterValueStruct->Name!=NULL)
{
free(ParameterValueStruct->Name);
}
if (ParameterValueStruct->Value!=NULL)
{
free(ParameterValueStruct->Value);
}
free(ParameterValueStruct);
}
list_del(list->next);
free (handler_ParameterValueStruct);
}
return CWMP_OK;
}

88
src/GetRPCMethods_acs.c Normal file
View file

@ -0,0 +1,88 @@
/*
GetRPCMethods_acs.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
int cwmp_rpc_acs_getRPCMethods_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_getRPCMethods_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_getRPCMethods_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_getRPCMethods_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_getRPCMethods_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
void soap_serialize__cwmp1__GetRPCMethods(struct soap *soap, const struct _cwmp1__GetRPCMethods *a);
int soap_put__cwmp1__GetRPCMethods(struct soap *soap, const struct _cwmp1__GetRPCMethods *a, const char *tag, const char *type);
struct _cwmp1__GetRPCMethodsResponse * soap_get__cwmp1__GetRPCMethodsResponse(struct soap *soap, struct _cwmp1__GetRPCMethodsResponse *p, const char *tag, const char *type);
struct rpc_acs *cwmp_add_session_rpc_acs (struct session *session);
struct rpc_acs *cwmp_add_session_rpc_acs_getRPCMethods (struct session *session)
{
struct rpc_acs *rpc_acs;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_acs = cwmp_add_session_rpc_acs (session);
if (rpc_acs == NULL)
{
return NULL;
}
soap_methods = &(rpc_acs->soap_methods);
rpc_acs->method_data = (void *) calloc (1,sizeof(struct _cwmp1__GetRPCMethods));
rpc_acs->method_data_init = cwmp_rpc_acs_getRPCMethods_data_init;
rpc_acs->method_remote_call = cwmp_rpc_acs_getRPCMethods_remote_call;
rpc_acs->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__GetRPCMethodsResponse));
rpc_acs->method_response = cwmp_rpc_acs_getRPCMethods_response;
rpc_acs->method_end = cwmp_rpc_acs_getRPCMethods_end;
rpc_acs->destructor = cwmp_rpc_acs_getRPCMethods_destructor;
rpc_acs->type = RPC_ACS_GETRPCMETHODS_IDX;
soap_methods->envelope = "cwmp:GetRPCMethods";
soap_methods->envelope_response = "cwmp:GetRPCMethodsResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__GetRPCMethods;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__GetRPCMethods;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__GetRPCMethodsResponse;
return rpc_acs;
}
int cwmp_rpc_acs_getRPCMethods_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_getRPCMethods_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
CWMP_LOG (INFO,"Trying to call the GetRPCMethods remote method");
cwmp_soap_call_rpc_acs (cwmp, session, this);
return CWMP_OK;
}
int cwmp_rpc_acs_getRPCMethods_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_getRPCMethods_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_getRPCMethods_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
cwmp_session_rpc_acs_destructor (cwmp, session, this);
return CWMP_OK;
}

119
src/GetRPCMethods_cpe.c Normal file
View file

@ -0,0 +1,119 @@
/*
GetRPCMethods_cpe.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getRPCMethods (struct session *session);
int cwmp_rpc_cpe_getRPCMethods (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getRPCMethods_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getRPCMethods_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_getRPCMethods_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
extern const struct CPE_METHOD_CONSTRUCTORS CPE_METHOD_CONSTRUCTORS_ARRAY [COUNT_RPC_CPE];
struct rpc_cpe *cwmp_add_session_rpc_cpe_getRPCMethods (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__GetRPCMethods));
rpc_cpe->method = cwmp_rpc_cpe_getRPCMethods;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__GetRPCMethodsResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_getRPCMethods_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_getRPCMethods_response;
rpc_cpe->method_end = cwmp_rpc_cpe_getRPCMethods_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:GetRPCMethods";
soap_methods->envelope_response = "cwmp:GetRPCMethodsResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__GetRPCMethodsResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__GetRPCMethodsResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__GetRPCMethods;
return rpc_cpe;
}
int cwmp_rpc_cpe_getRPCMethods (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_getRPCMethods_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int i;
struct cwmp1MethodList *MethodList;
char **mlstruct;
struct _cwmp1__GetRPCMethodsResponse *p_soap_cwmp1__GetRPCMethodsResponse;
MethodList = calloc(1,sizeof(struct cwmp1MethodList));
mlstruct = calloc(COUNT_RPC_CPE,sizeof(char *));
if(MethodList == NULL ||
mlstruct == NULL)
{
return CWMP_MEM_ERR;
}
MethodList->__ptrstring = mlstruct;
for(i=0;i<COUNT_RPC_CPE;i++)
{
if(CPE_METHOD_CONSTRUCTORS_ARRAY[i].CONSTRUCTOR != NULL)
{
*mlstruct = CPE_METHOD_CONSTRUCTORS_ARRAY[i].METHOD;
MethodList->__size++;
mlstruct++;
}
}
p_soap_cwmp1__GetRPCMethodsResponse = (struct _cwmp1__GetRPCMethodsResponse *)this->method_response_data;
p_soap_cwmp1__GetRPCMethodsResponse->MethodList = MethodList;
return CWMP_OK;
}
int cwmp_rpc_cpe_getRPCMethods_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send GetRPCMethods response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_getRPCMethods_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__GetRPCMethodsResponse *p_soap_cwmp1__GetRPCMethodsResponse;
p_soap_cwmp1__GetRPCMethodsResponse = (struct _cwmp1__GetRPCMethodsResponse *)this->method_response_data;
if (p_soap_cwmp1__GetRPCMethodsResponse!=NULL)
{
if (p_soap_cwmp1__GetRPCMethodsResponse->MethodList != NULL)
{
if(p_soap_cwmp1__GetRPCMethodsResponse->MethodList->__ptrstring != NULL)
{
free (p_soap_cwmp1__GetRPCMethodsResponse->MethodList->__ptrstring);
}
free (p_soap_cwmp1__GetRPCMethodsResponse->MethodList);
}
}
return CWMP_OK;
}

413
src/Inform.c Normal file
View file

@ -0,0 +1,413 @@
/*
inform.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "soapH.h"
#include "list.h"
#include "cwmp.h"
#include "dm.h"
#include "dm_rpc.h"
#include <uci.h>
#include "backupSession.h"
struct rpc_acs *cwmp_add_session_rpc_acs (struct session *session);
struct rpc_acs *cwmp_add_session_rpc_acs_head (struct session *session);
int cwmp_rpc_acs_inform_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_inform_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_inform_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_inform_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_session_rpc_acs_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *rpc_acs);
int cwmp_rpc_acs_inform_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int event_remove_all_event_container(struct session *session, int rem_from);
void soap_serialize_cwmp1__Inform (struct soap *soap, const struct cwmp1__Inform *a);
int soap_put_cwmp1__Inform (struct soap *soap, const struct cwmp1__Inform *a, const char *tag, const char *type);
int free_list_getParameterValues(struct list_head *list);
struct cwmp1__InformResponse *soap_get_cwmp1__InformResponse (struct soap *soap, struct cwmp1__InformResponse *p, const char *tag, const char *type);
extern struct list_head forced_inform_parameter_list;
static int forced_inform_parameter_size=0;
static LIST_HEAD(forced_inform_parameter_indice_list);
extern char *TYPE_VALUES_ARRAY [COUNT_TYPE_VALUES];
struct rpc_acs *cwmp_add_session_rpc_acs_inform (struct session *session)
{
struct rpc_acs *rpc_acs;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_acs = cwmp_add_session_rpc_acs_head (session); /* Only the inform rpc should be added in the head of the rpc acs list*/
if (rpc_acs == NULL)
{
return NULL;
}
soap_methods = &(rpc_acs->soap_methods);
rpc_acs->method_data = (void *) calloc (1,sizeof(struct cwmp1__Inform));
rpc_acs->method_data_init = cwmp_rpc_acs_inform_data_init;
rpc_acs->method_remote_call = cwmp_rpc_acs_inform_remote_call;
rpc_acs->method_response_data = (void *) calloc (1,sizeof(struct cwmp1__InformResponse));
rpc_acs->method_response = cwmp_rpc_acs_inform_response;
rpc_acs->method_end = cwmp_rpc_acs_inform_end;
rpc_acs->destructor = cwmp_rpc_acs_inform_destructor;
rpc_acs->type = RPC_ACS_INFORM_IDX;
soap_methods->envelope = "cwmp:Inform";
soap_methods->envelope_response = "cwmp:InformResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize_cwmp1__Inform;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put_cwmp1__Inform;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get_cwmp1__InformResponse;
return rpc_acs;
}
int cwmp_rpc_acs_inform_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
struct cwmp1__Inform *p_soap_cwmp1__Inform;
struct cwmp1__DeviceIdStruct *DeviceIdStruct;
struct cwmp1__EventStruct **pEventStruct;
struct cwmp1__ParameterValueStruct *ParameterValueStructForce, **ptr_ParameterValueStruct, *p,**pp;
struct event_container *event_container;
struct paramater_container *paramater_container;
struct forced_inform_parameter *fip;
int i, j, size, force_size = 0 , error;
struct list_head *ilist,*jlist;
if (session==NULL || this==NULL)
{
return CWMP_GEN_ERR;
}
DeviceIdStruct = calloc(1,sizeof(struct cwmp1__DeviceIdStruct));
if (DeviceIdStruct == NULL)
{
return CWMP_MEM_ERR;
}
dm_get_deviceId_manufacturer(cwmp,&(DeviceIdStruct->Manufacturer));
dm_get_deviceId_oui(cwmp,&(DeviceIdStruct->OUI));
dm_get_deviceId_productClass(cwmp,&(DeviceIdStruct->ProductClass));
dm_get_deviceId_serialNumber(cwmp,&(DeviceIdStruct->SerialNumber));
p_soap_cwmp1__Inform = (struct cwmp1__Inform *) this->method_data;
p_soap_cwmp1__Inform->DeviceId = DeviceIdStruct;
p_soap_cwmp1__Inform->CurrentTime = time((time_t*)NULL);
p_soap_cwmp1__Inform->RetryCount = cwmp->retry_count_session;
p_soap_cwmp1__Inform->MaxEnvelopesI = 1;
__list_for_each(ilist, &(forced_inform_parameter_list))
{
fip = list_entry (ilist, struct forced_inform_parameter,list);
if (strstr(fip->name,"{i}")==NULL)
{
force_size++;
}
else
{
int n = 0;
inform_dm_getParameterPaths_by_correspondence(cwmp,fip->name,&forced_inform_parameter_indice_list,&n);
force_size += n;
}
}
forced_inform_parameter_size = force_size;
size = force_size + session->parameter_size;
p_soap_cwmp1__Inform->ParameterList = calloc(1,sizeof(struct cwmp1ParameterValueList));
ParameterValueStructForce = calloc(force_size,sizeof(struct cwmp1__ParameterValueStruct));
ptr_ParameterValueStruct = calloc(size,sizeof(struct cwmp1__ParameterValueStruct *));
p_soap_cwmp1__Inform->Event = calloc(1,sizeof(struct cwmp1EventList));
pEventStruct = calloc(session->event_size,sizeof(struct cwmp1__EventStruct *));
if (p_soap_cwmp1__Inform->ParameterList == NULL ||
ParameterValueStructForce == NULL ||
ptr_ParameterValueStruct == NULL ||
p_soap_cwmp1__Inform->Event == NULL ||
pEventStruct==NULL)
{
return CWMP_MEM_ERR;
}
p_soap_cwmp1__Inform->ParameterList->__ptrParameterValueStruct = ptr_ParameterValueStruct;
p_soap_cwmp1__Inform->Event->__size = session->event_size;
p_soap_cwmp1__Inform->Event->__ptrEventStruct = pEventStruct;
i = 0;
__list_for_each(ilist, &(forced_inform_parameter_list))
{
fip = list_entry (ilist, struct forced_inform_parameter,list);
if (strstr(fip->name,"{i}")==NULL)
{
if (i!=0)
{
ParameterValueStructForce++;
ptr_ParameterValueStruct++;
}
i++;
ParameterValueStructForce->Name = strdup (fip->name);
ParameterValueStructForce->Type = TYPE_VALUES_ARRAY [fip->node->value_type];
if (error = get_node_paramater_value(fip->node,NULL,0,&(ParameterValueStructForce->Value)))
{
char t[1];
t[0] = 0;
ParameterValueStructForce->Value = strdup(t);
}
*ptr_ParameterValueStruct = ParameterValueStructForce;
}
}
__list_for_each(ilist, &(forced_inform_parameter_indice_list))
{
struct handler_ParameterValueStruct *handler_ParameterValueStruct;
if (i!=0)
{
ParameterValueStructForce++;
ptr_ParameterValueStruct++;
}
i++;
handler_ParameterValueStruct = list_entry(ilist,struct handler_ParameterValueStruct,list);
ParameterValueStructForce->Name = handler_ParameterValueStruct->ParameterValueStruct->Name;
ParameterValueStructForce->Value = handler_ParameterValueStruct->ParameterValueStruct->Value;
ParameterValueStructForce->Type = handler_ParameterValueStruct->ParameterValueStruct->Type;
*ptr_ParameterValueStruct = ParameterValueStructForce;
ilist = ilist->prev;
list_del(&(handler_ParameterValueStruct->list));
free (handler_ParameterValueStruct->ParameterValueStruct);
free (handler_ParameterValueStruct);
}
pp = p_soap_cwmp1__Inform->ParameterList->__ptrParameterValueStruct;
size = 0;
error = 1;
__list_for_each(ilist,&(session->head_event_container))
{
event_container = list_entry(ilist, struct event_container, list);
*pEventStruct = &(event_container->event);
pEventStruct ++;
__list_for_each(jlist,&(event_container->head_paramater_container))
{
paramater_container = list_entry(jlist, struct paramater_container, list);
for (j=0;j<(size+force_size);j++)
{
p = *(pp+j);
if ((error = strcmp(paramater_container->paramater.Name,p->Name))==0)
{
break;
}
}
if (error==0)
{
continue;
}
if (i!=0)
{
ptr_ParameterValueStruct++;
}
i++;
inform_dm_get_value_by_path (cwmp, paramater_container->paramater.Name, &(paramater_container->paramater.Value), &(paramater_container->paramater.Type));
*ptr_ParameterValueStruct = &(paramater_container->paramater);
size++;
}
}
p_soap_cwmp1__Inform->ParameterList->__size = size + force_size;
return CWMP_OK;
}
int cwmp_rpc_acs_inform_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
CWMP_LOG(INFO, "Trying to call the Inform remote method");
cwmp_soap_call_rpc_acs (cwmp, session, this);
return CWMP_OK;
}
int cwmp_rpc_acs_inform_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_inform_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
struct cwmp1__Inform *p_soap_cwmp1__Inform;
struct cwmp1__InformResponse *p_soap_cwmp1__InformResponse;
int force_size;
force_size = forced_inform_parameter_size;
p_soap_cwmp1__Inform = (struct cwmp1__Inform *)this->method_data;
if (p_soap_cwmp1__Inform!=NULL)
{
if (p_soap_cwmp1__Inform->DeviceId!=NULL)
{
if (p_soap_cwmp1__Inform->DeviceId->Manufacturer!=NULL)
{
free (p_soap_cwmp1__Inform->DeviceId->Manufacturer);
}
if (p_soap_cwmp1__Inform->DeviceId->OUI!=NULL)
{
free (p_soap_cwmp1__Inform->DeviceId->OUI);
}
if (p_soap_cwmp1__Inform->DeviceId->ProductClass!=NULL)
{
free (p_soap_cwmp1__Inform->DeviceId->ProductClass);
}
if (p_soap_cwmp1__Inform->DeviceId->SerialNumber!=NULL)
{
free (p_soap_cwmp1__Inform->DeviceId->SerialNumber);
}
free (p_soap_cwmp1__Inform->DeviceId);
}
if (p_soap_cwmp1__Inform->Event!=NULL)
{
if (p_soap_cwmp1__Inform->Event->__ptrEventStruct!=NULL)
{
free (p_soap_cwmp1__Inform->Event->__ptrEventStruct);
}
free (p_soap_cwmp1__Inform->Event);
}
if (p_soap_cwmp1__Inform->ParameterList!=NULL)
{
struct cwmp1__ParameterValueStruct *ParameterValueStructForce,*p;
int i = 0;
if (p_soap_cwmp1__Inform->ParameterList->__ptrParameterValueStruct!= NULL)
{
if (force_size>0)
{
ParameterValueStructForce = *(p_soap_cwmp1__Inform->ParameterList->__ptrParameterValueStruct);
p = ParameterValueStructForce;
while (p!=NULL && i<force_size)
{
if (p->Name!=NULL)
{
free (p->Name);
}
if (p->Value!=NULL)
{
free (p->Value);
}
p++;
i++;
}
if (ParameterValueStructForce!=NULL)
{
free (ParameterValueStructForce);
}
}
free(p_soap_cwmp1__Inform->ParameterList->__ptrParameterValueStruct);
}
free (p_soap_cwmp1__Inform->ParameterList);
}
}
return CWMP_OK;
}
int cwmp_rpc_acs_inform_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
cwmp_session_rpc_acs_destructor (cwmp, session, this);
event_remove_all_event_container (session,RPC_SEND);
return CWMP_OK;
}
/*
* Get Device ID values
*/
int dm_get_deviceId_manufacturer(struct cwmp *cwmp, char **value)
{
*value = strdup("Inteno");
return CWMP_OK;
}
int inform_dm_get_value_by_path (struct cwmp *cwmp, char *path, char **value, char **type)
{
int n,error;
LIST_HEAD(list_ParameterValueStruct);
*value = NULL;
*type = NULL;
error = cwmp_dm_getParameterValues(cwmp, path, &list_ParameterValueStruct,&n);
if (error == FAULT_CPE_NO_FAULT_IDX)
{
struct handler_ParameterValueStruct *handler_ParameterValueStruct;
if (list_ParameterValueStruct.next!=&list_ParameterValueStruct)
{
handler_ParameterValueStruct = list_entry(list_ParameterValueStruct.next,struct handler_ParameterValueStruct,list);
*value = strdup(handler_ParameterValueStruct->ParameterValueStruct->Value);
*type = handler_ParameterValueStruct->ParameterValueStruct->Type;
}
}
if (*value==NULL)
{
char t[1];
t[0] = 0;
*value = strdup(t);
}
if (*type==NULL)
{
*type = TYPE_VALUES_ARRAY[TYPE_VALUE_string_IDX];
}
free_list_getParameterValues(&list_ParameterValueStruct);
return CWMP_OK;
}
int dm_get_deviceId_oui(struct cwmp *cwmp, char **value)
{
int error;
char *type;
error = inform_dm_get_value_by_path (cwmp, "InternetGatewayDevice.DeviceInfo.ManufacturerOUI", value, &type);
return error;
}
int dm_get_deviceId_productClass(struct cwmp *cwmp, char **value)
{
int error;
char *type;
error = inform_dm_get_value_by_path (cwmp, "InternetGatewayDevice.DeviceInfo.ProductClass", value, &type);
return error;
}
int dm_get_deviceId_serialNumber(struct cwmp *cwmp, char **value)
{
int error;
char *type;
error = inform_dm_get_value_by_path (cwmp, "InternetGatewayDevice.DeviceInfo.SerialNumber", value, &type);
return error;
}
/*
* End Get Device ID values
*/
int inform_dm_getParameterPaths_by_correspondence(struct cwmp *cwmp, char *path, struct list_head *list, int *n)
{
char *prefix_path=NULL;
char **argv;
struct sub_path *sub_path;
int i,sub_path_size;
argv = calloc (1,sizeof(char *));
sub_path = calloc (DM_MAX_INDICE,sizeof(struct sub_path));
argv[0] = path;
cwmp_dm_get_sub_indice_path(1,argv,&prefix_path,sub_path,&sub_path_size);
cwmp_dm_getParameterPaths_by_correspondence(cwmp,prefix_path,sub_path,sub_path_size,list,n,TRUE,FALSE,&i);
for (i=0;i<sub_path_size;i++)
{
if (sub_path[i].dm_indice.indice!=NULL)
{
free(sub_path[i].dm_indice.indice);
}
}
free(sub_path);
if (prefix_path!=NULL)
{
free(prefix_path);
}
free(argv);
}

59
src/Makefile Normal file
View file

@ -0,0 +1,59 @@
#
# Copyright (C) 2011 Inteno
#
CWMP_VERSION=1.3
CWMP_REVISION=$(shell svnversion $(PWD) -n|cut -f2 -d:)
LINK=$(CC)
SHLIB_EXT=so
SHLIB_FLAGS=-shared -Wl,-soname,$(SHLIB_FILE)
FPIC=-fPIC
LIBS=-lc
SHLIB_FILE=libcwmp.$(SHLIB_EXT).$(CWMP_VERSION)
PCFLAGS+=-Iinc -DCWMP_VERSION=\"$(CWMP_VERSION)\" -DWITH_COOKIES -DWITH_DEV_DEBUG -DWITH_CWMP_DEBUG -DWITH_DM_DEBUG
PLDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\" -DWITH_COOKIES -DWITH_DEV_DEBUG -DWITH_CWMP_DEBUG -DWITH_DM_DEBUG -luci -lexpat -lpthread -lssl -lcurl
ifneq ($(CWMP_REVISION)_,_)
ifneq ($(CWMP_REVISION),exported)
PCFLAGS+=-DCWMP_REVISION=\"$(CWMP_REVISION)\"
PLDFLAGS+=-DCWMP_REVISION=\"$(CWMP_REVISION)\"
endif
endif
CWMPD_OBJECT_FILES=cwmp.o stdsoap2.o soapC.o soapClient.o backupSession.o\
log.o TransferComplete.o Reboot.o GetParameterNames.o GetParameterValues.o\
SetParameterValues.o FactoryReset.o ScheduleInform.o connectionRequest.o dm.o\
config.o Inform.o event.o GetRPCMethods_acs.o Fault_cpe.o GetRPCMethods_cpe.o\
dm_rpc.o httpda.o md5evp.o cwmp_api.o GetParameterAttributes.o SetParameterAttributes.o\
Download.o AddObject.o DeleteObject.o
all: libcwmp.$(SHLIB_EXT) cwmpd cwmp_value_change kcwmp
cwmp_lib.o: cwmp_lib.c
$(CC) $(PCFLAGS) $(CFLAGS) $(FPIC) -c -o $@ $<
libcwmp.$(SHLIB_EXT): cwmp_lib.o
$(LINK) $(SHLIB_FLAGS) -o $(SHLIB_FILE) $< $(LIBS)
ln -sf $(SHLIB_FILE) $@
%.o: %.c
$(CC) $(PCFLAGS) $(CFLAGS) -c -o $@ $^
cwmpd: $(CWMPD_OBJECT_FILES)
$(CC) $(PLDFLAGS) $(LDFLAGS) -o $@ $^
cwmp_value_change: cwmp_value_change.o
$(CC) $(LDFLAGS) $(PLDFLAGS) -o $@ $<
obj-m += kcwmp.o
kcwmp:
$(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) modules
clean:
rm -f *.o *.so* cwmpd cwmp_value_change
$(MAKE) -C $(LINUX_DIR) $(MAKE_OPTS) clean

104
src/Reboot.c Normal file
View file

@ -0,0 +1,104 @@
/*
Reboot.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include <sys/reboot.h>
#include <unistd.h>
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_reboot (struct session *session);
int cwmp_rpc_cpe_reboot (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_reboot_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_reboot_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_reboot_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key);
void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_container);
struct rpc_cpe *cwmp_add_session_rpc_cpe_reboot (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__Reboot));
rpc_cpe->method = cwmp_rpc_cpe_reboot;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__RebootResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_reboot_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_reboot_response;
rpc_cpe->method_end = cwmp_rpc_cpe_reboot_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:Reboot";
soap_methods->envelope_response = "cwmp:RebootResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__RebootResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__RebootResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__Reboot;
return rpc_cpe;
}
int cwmp_reboot(struct cwmp *cwmp,void *v)
{
CWMP_LOG(INFO,"RUN reboot function");
/** flush file system buffers **/
sync();
return reboot(RB_AUTOBOOT);
}
int cwmp_rpc_cpe_reboot (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct event_container *event_container;
struct _cwmp1__Reboot *p;
pthread_mutex_lock (&(cwmp->mutex_session_queue));
p = (struct _cwmp1__Reboot *) this->method_data;
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_M_Reboot, p->CommandKey);
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
add_session_end_func(session,cwmp_reboot,NULL,TRUE);
return CWMP_OK;
}
int cwmp_rpc_cpe_reboot_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_reboot_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send Reboot response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_reboot_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}

232
src/ScheduleInform.c Normal file
View file

@ -0,0 +1,232 @@
/*
ScheduleInform.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <pthread.h>
#include <signal.h>
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
LIST_HEAD(list_schedule_inform);
static pthread_mutex_t mutex_schedule_inform;
static pthread_cond_t threshold_schedule_inform;
static bool thread_is_working=FALSE;
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
int cwmp_rpc_cpe_scheduleInform (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_scheduleInform_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_scheduleInform_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_scheduleInform_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key);
void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_container);
void backup_session_insert_schedule_time(time_t schedule_time,char *commandKey);
void backup_session_delete_schedule_time(time_t schedule_time,char *commandKey);
void backup_session_delete_scheduled_inform();
struct rpc_cpe *cwmp_add_session_rpc_cpe_scheduleInform (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__ScheduleInform));
rpc_cpe->method = cwmp_rpc_cpe_scheduleInform;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__ScheduleInformResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_scheduleInform_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_scheduleInform_response;
rpc_cpe->method_end = cwmp_rpc_cpe_scheduleInform_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:ScheduleInform";
soap_methods->envelope_response = "cwmp:ScheduleInformResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__ScheduleInformResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__ScheduleInformResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__ScheduleInform;
return rpc_cpe;
}
void *thread_cwmp_rpc_cpe_scheduleInform (void *v)
{
struct cwmp *cwmp = (struct cwmp *)v;
struct event_container *event_container;
struct schedule_inform *schedule_inform;
struct timespec si_timeout = {0, 0};
time_t current_time;
bool add_event_same_time = FALSE;
thread_is_working = TRUE;
while (list_schedule_inform.next!=&(list_schedule_inform))
{
schedule_inform = list_entry(list_schedule_inform.next,struct schedule_inform, list);
current_time = time(NULL);
if (current_time >= schedule_inform->scheduled_time)
{
if (add_event_same_time)
{
pthread_mutex_lock (&mutex_schedule_inform);
list_del (&(schedule_inform->list));
if (schedule_inform->commandKey!=NULL)
{
backup_session_delete_schedule_time(schedule_inform->scheduled_time,schedule_inform->commandKey);
free (schedule_inform->commandKey);
}
free(schedule_inform);
pthread_mutex_unlock (&mutex_schedule_inform);
continue;
}
pthread_mutex_lock (&(cwmp->mutex_session_queue));
CWMP_LOG(INFO,"Schedule Inform thread: add ScheduleInform event in the queue");
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_3SCHEDULED, "");
if (event_container != NULL)
{
cwmp_save_event_container (cwmp,event_container);
}
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_M_ScheduleInform, schedule_inform->commandKey);
if (event_container != NULL)
{
cwmp_save_event_container (cwmp,event_container);
}
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
pthread_cond_signal(&(cwmp->threshold_session_send));
pthread_mutex_lock (&mutex_schedule_inform);
list_del (&(schedule_inform->list));
if (schedule_inform->commandKey!=NULL)
{
backup_session_delete_schedule_time(schedule_inform->scheduled_time,schedule_inform->commandKey);
free (schedule_inform->commandKey);
}
free(schedule_inform);
pthread_mutex_unlock (&mutex_schedule_inform);
add_event_same_time = TRUE;
continue;
}
add_event_same_time = FALSE;
pthread_mutex_lock (&mutex_schedule_inform);
si_timeout.tv_sec = schedule_inform->scheduled_time;
pthread_cond_timedwait(&threshold_schedule_inform, &mutex_schedule_inform, &si_timeout);
pthread_mutex_unlock (&mutex_schedule_inform);
}
thread_is_working = FALSE;
return CWMP_OK;
}
int cwmp_rpc_cpe_scheduleInform (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct event_container *event_container;
struct _cwmp1__ScheduleInform *p;
struct schedule_inform *schedule_inform;
time_t scheduled_time;
struct list_head *ilist;
bool cond_signal=FALSE;
pthread_t scheduleInform_thread;
int error;
pthread_mutex_lock (&mutex_schedule_inform);
p = (struct _cwmp1__ScheduleInform *) this->method_data;
scheduled_time = time(NULL) + p->DelaySeconds;
__list_for_each(ilist,&(list_schedule_inform))
{
schedule_inform = list_entry(ilist,struct schedule_inform, list);
if (schedule_inform->scheduled_time == scheduled_time)
{
pthread_mutex_unlock (&mutex_schedule_inform);
return CWMP_OK;
}
if (schedule_inform->scheduled_time > scheduled_time)
{
cond_signal = TRUE;
break;
}
}
CWMP_LOG(INFO,"Schedule inform event will start in %us",p->DelaySeconds);
schedule_inform = calloc (1,sizeof(struct schedule_inform));
if (schedule_inform==NULL)
{
pthread_mutex_unlock (&mutex_schedule_inform);
return CWMP_OK;
}
schedule_inform->commandKey = strdup(p->CommandKey);
schedule_inform->scheduled_time = scheduled_time;
list_add (&(schedule_inform->list), ilist->prev);
backup_session_insert_schedule_time(schedule_inform->scheduled_time,schedule_inform->commandKey);
if (cond_signal)
{
pthread_cond_signal(&threshold_schedule_inform);
}
pthread_mutex_unlock (&mutex_schedule_inform);
if (!thread_is_working)
{
thread_is_working = TRUE;
error = pthread_create(&scheduleInform_thread, NULL, &thread_cwmp_rpc_cpe_scheduleInform, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error error when creating the schedule event thread!");
thread_is_working = FALSE;
return CWMP_OK;
}
}
return CWMP_OK;
}
int cwmp_rpc_cpe_scheduleInform_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_scheduleInform_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send ScheduleInform response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_scheduleInform_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_scheduleInform_remove_all()
{
struct schedule_inform *schedule_inform;
pthread_mutex_lock (&mutex_schedule_inform);
while (list_schedule_inform.next!=&(list_schedule_inform))
{
schedule_inform = list_entry(list_schedule_inform.next,struct schedule_inform, list);
list_del (&(schedule_inform->list));
if (schedule_inform->commandKey!=NULL)
{
backup_session_delete_schedule_time(schedule_inform->scheduled_time,schedule_inform->commandKey);
free (schedule_inform->commandKey);
}
free(schedule_inform);
}
backup_session_delete_scheduled_inform();
pthread_mutex_unlock (&mutex_schedule_inform);
return CWMP_OK;
}

View file

@ -0,0 +1,406 @@
/*
SetParameterAttributes.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterAttributes (struct session *session);
int cwmp_rpc_cpe_setParameterAttributes (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterAttributes_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterAttributes_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterAttributes_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int cwmp_dm_setParameterAttributes(struct cwmp *cwmp, struct cwmp1__SetParameterAttributesStruct *ParameterAttributesStruct);
int cwmp_delete_notification(char *type,char *name);
int cwmp_add_notification(char *type,char *name);
int cwmp_check_notification(char *name, char *type);
int cwmp_off_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change);
int cwmp_apply_passive_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change);
int cwmp_apply_active_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change);
int cwmp_add_in_accesslist(char *name, enum xsd__boolean access_list_change, char *accessList);
int uci_delete_value(char *cmd);
int uci_revert_value ();
int uci_commit_value ();
extern const struct CPE_METHOD_CONSTRUCTORS CPE_METHOD_CONSTRUCTORS_ARRAY [COUNT_RPC_CPE];
const struct ACCESSLIST_CONST_STRUCT ACCESSLIST_CONST_ARRAY [] = {
{"Subscriber","cwmp.accesslist.subscriber"}
};
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterAttributes (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__SetParameterAttributes));
rpc_cpe->method = cwmp_rpc_cpe_setParameterAttributes;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__SetParameterAttributesResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_setParameterAttributes_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_setParameterAttributes_response;
rpc_cpe->method_end = cwmp_rpc_cpe_setParameterAttributes_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:SetParameterAttributes";
soap_methods->envelope_response = "cwmp:SetParameterAttributesResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__SetParameterAttributesResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__SetParameterAttributesResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__SetParameterAttributes;
return rpc_cpe;
}
int cwmp_rpc_cpe_setParameterAttributes (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__SetParameterAttributes *p_soap_cwmp1__SetParameterAttributes;
int i,size,error;
struct cwmp1__SetParameterAttributesStruct *ParameterAttributesStruct,**ptrParameterAttributeStruct;
p_soap_cwmp1__SetParameterAttributes = (struct _cwmp1__SetParameterAttributes *)this->method_data;
size = p_soap_cwmp1__SetParameterAttributes->ParameterList->__size;
ptrParameterAttributeStruct = p_soap_cwmp1__SetParameterAttributes->ParameterList->__ptrSetParameterAttributesStruct;
for (i=0;i<size;i++,ptrParameterAttributeStruct++)
{
ParameterAttributesStruct = *ptrParameterAttributeStruct;
if(error = cwmp_dm_setParameterAttributes(cwmp,ParameterAttributesStruct))
{
uci_revert_value ();
if (cwmp_add_session_rpc_cpe_Fault(session,error) == NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
}
uci_commit_value();
return CWMP_OK;
}
int cwmp_rpc_cpe_setParameterAttributes_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_setParameterAttributes_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send SetParameterAttributes response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_setParameterAttributes_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_add_notification(char *type,char *name)
{
char cmd[256];
int error;
sprintf(cmd,"%s=%s",type,name);
if(error = uci_add_list_value(cmd))
{
return error;
}
return CWMP_OK;
}
int cwmp_delete_notification(char *type,char *name)
{
struct config_uci_list *notification;
struct list_head *list;
LIST_HEAD(notification_list);
uci_get_list_value(type, &notification_list);
uci_delete_value(type);
while(!list_empty(&notification_list))
{
notification = list_entry (notification_list.next, struct config_uci_list, list);
if((notification != NULL)&&(strcmp(name,notification->value) != 0)&&(strstr(notification->value,name) == NULL))
{
cwmp_add_notification(type,notification->value);
}
list_del(notification_list.next);
if(notification != NULL)
{
if(notification->value != NULL)
{
free(notification->value);
}
free(notification);
notification = NULL;
}
}
return CWMP_OK;
}
int cwmp_check_notification(char *name, char *type)
{
struct config_uci_list *notification;
bool partial_found = FALSE;
bool found = FALSE;
int is_parent = 0;
LIST_HEAD(notification_list);
uci_get_list_value(type, &notification_list);
while(!list_empty(&notification_list))
{
notification = list_entry (notification_list.next, struct config_uci_list, list);
if((notification != NULL))
{
if(strstr(notification->value,name) != NULL)
{
partial_found = TRUE;
is_parent = 1;
if(strcmp(notification->value,name) == 0)
{
found = TRUE;
}
}
if(strstr(name,notification->value) != NULL)
{
partial_found = TRUE;
}
list_del(notification_list.next);
free(notification);
notification = NULL;
}
}
if(!partial_found)
{
return CWMP_OK;
}
else
{
if(found)
{
return CWMP_EXACT_FOUND;
}
else
{
if(is_parent == 1)
{
return CWMP_CHILD_FOUND;
}
else
{
return CWMP_PARENT_FOUND;
}
}
}
}
int cwmp_apply_active_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change)
{
int error = FAULT_CPE_NO_FAULT_IDX,i;
if(node != NULL)
{
if(node->active_notify.can_deny)
{
error = FAULT_CPE_NOTIFICATION_REJECTED_IDX;
}
else
{
if(notification_change == xsd__boolean__true_)
{
if(cwmp_check_notification(name,UCI_NOTIFICATION_PASSIVE_PATH) == CWMP_CHILD_FOUND ||
cwmp_check_notification(name,UCI_NOTIFICATION_PASSIVE_PATH) == CWMP_EXACT_FOUND )
{
cwmp_delete_notification(UCI_NOTIFICATION_PASSIVE_PATH,name);
}
if(cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_CHILD_FOUND||
cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_EXACT_FOUND)
{
cwmp_delete_notification(UCI_NOTIFICATION_DENIED_PATH,name);
}
if(cwmp_check_notification(name,UCI_NOTIFICATION_ACTIVE_PATH) == CWMP_OK)
{
cwmp_add_notification(UCI_NOTIFICATION_ACTIVE_PATH,name);
}
else if(cwmp_check_notification(name,UCI_NOTIFICATION_ACTIVE_PATH) == CWMP_CHILD_FOUND)
{
cwmp_delete_notification(UCI_NOTIFICATION_ACTIVE_PATH,name);
cwmp_add_notification(UCI_NOTIFICATION_ACTIVE_PATH,name);
}
}
}
}
else
{
error = FAULT_CPE_INVALID_PARAMETER_NAME_IDX;
}
return error;
}
int cwmp_apply_passive_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change)
{
int error = FAULT_CPE_NO_FAULT_IDX,i;
if(node != NULL)
{
if(node->active_notify.force_enabled)
{
error = FAULT_CPE_NOTIFICATION_REJECTED_IDX;
}
else
{
if(notification_change == xsd__boolean__true_)
{
if(cwmp_check_notification(name,UCI_NOTIFICATION_ACTIVE_PATH) == CWMP_CHILD_FOUND ||
cwmp_check_notification(name,UCI_NOTIFICATION_ACTIVE_PATH) == CWMP_EXACT_FOUND )
{
cwmp_delete_notification(UCI_NOTIFICATION_ACTIVE_PATH,name);
}
if(cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_CHILD_FOUND||
cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_EXACT_FOUND)
{
cwmp_delete_notification(UCI_NOTIFICATION_DENIED_PATH,name);
}
if(cwmp_check_notification(name,UCI_NOTIFICATION_PASSIVE_PATH) == CWMP_OK)
{
cwmp_add_notification(UCI_NOTIFICATION_PASSIVE_PATH,name);
}
else if(cwmp_check_notification(name,UCI_NOTIFICATION_PASSIVE_PATH) == CWMP_CHILD_FOUND)
{
cwmp_delete_notification(UCI_NOTIFICATION_PASSIVE_PATH,name);
cwmp_add_notification(UCI_NOTIFICATION_PASSIVE_PATH,name);
}
}
}
}
else
{
error = FAULT_CPE_INVALID_PARAMETER_NAME_IDX;
}
return error;
}
int cwmp_off_notification(struct dm_node *node,char *name, enum xsd__boolean notification_change)
{
int error = FAULT_CPE_NO_FAULT_IDX,i;
if(node != NULL)
{
if(node->active_notify.force_enabled)
{
error = FAULT_CPE_NOTIFICATION_REJECTED_IDX;
}
else
{
if(notification_change == xsd__boolean__true_)
{
switch(cwmp_check_notification(name,UCI_NOTIFICATION_PASSIVE_PATH))
{
case CWMP_EXACT_FOUND:
case CWMP_CHILD_FOUND:
cwmp_delete_notification(UCI_NOTIFICATION_PASSIVE_PATH,name);
break;
case CWMP_PARENT_FOUND:
if(cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_OK)
{
cwmp_add_notification(UCI_NOTIFICATION_DENIED_PATH,name);
}
break;
}
switch(cwmp_check_notification(name,UCI_NOTIFICATION_ACTIVE_PATH))
{
case CWMP_EXACT_FOUND:
case CWMP_CHILD_FOUND:
cwmp_delete_notification(UCI_NOTIFICATION_ACTIVE_PATH,name);
break;
case CWMP_PARENT_FOUND:
if(cwmp_check_notification(name,UCI_NOTIFICATION_DENIED_PATH) == CWMP_OK)
{
cwmp_add_notification(UCI_NOTIFICATION_DENIED_PATH,name);
}
break;
}
for(i=0;i<COUNT_ACCESSLIST;i++)
{
switch(cwmp_check_notification(name,ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH))
{
case CWMP_EXACT_FOUND:
case CWMP_CHILD_FOUND:
cwmp_delete_notification(ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH,name);
break;
case CWMP_PARENT_FOUND:
break;
}
}
}
}
}
else
{
error = FAULT_CPE_INVALID_PARAMETER_NAME_IDX;
}
return error;
}
int cwmp_add_in_accesslist(char *name, enum xsd__boolean access_list_change, char *accessList)
{
int i;
bool found = FALSE;
for(i=0;i<COUNT_ACCESSLIST;i++)
{
if(strcmp(accessList,ACCESSLIST_CONST_ARRAY[i].NAME) == 0)
{
found = TRUE;
break;
}
}
if(!found)
{
return FAULT_CPE_INVALID_ARGUMENTS_IDX;
}
if(access_list_change == xsd__boolean__true_)
{
if(cwmp_check_notification(name,ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH) == CWMP_OK)
{
cwmp_add_notification(ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH,name);
return FAULT_CPE_NO_FAULT_IDX;
}
if(cwmp_check_notification(name,ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH) == CWMP_CHILD_FOUND)
{
cwmp_delete_notification(ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH,name);
cwmp_add_notification(ACCESSLIST_CONST_ARRAY[i].UCI_ACCESSLIST_PATH,name);
return FAULT_CPE_NO_FAULT_IDX;
}
}
return FAULT_CPE_NO_FAULT_IDX;
}

208
src/SetParameterValues.c Normal file
View file

@ -0,0 +1,208 @@
/*
SetParameterValues.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 20011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "dm.h"
#include "dm_rpc.h"
LIST_HEAD(list_dm_set_handler);
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterValues (struct session *session);
int cwmp_rpc_cpe_setParameterValues (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterValues_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterValues_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_rpc_cpe_setParameterValues_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int cwmp_dm_setParameterValues(struct cwmp *cwmp, struct dm_set_handler *dm_set_handler, char *path, char *value);
int dm_run_queue_cmd_handler_at_end_session (struct cwmp *cwmp, struct dm_set_handler *dm_set_handler);
int cwmp_reboot(struct cwmp *cwmp,void *v);
int dm_cwmp_config_reload (struct cwmp *cwmp, void *v );
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe);
static int check_duplicated_parameter_name (struct cwmp1__ParameterValueStruct **ptr_ParameterValueStruct, int size);
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterValues (struct session *session)
{
struct rpc_cpe *rpc_cpe;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_cpe = cwmp_add_session_rpc_cpe (session);
if (rpc_cpe == NULL)
{
return NULL;
}
soap_methods = &(rpc_cpe->soap_methods);
rpc_cpe->method_data = (void *) calloc (1,sizeof(struct _cwmp1__SetParameterValues));
rpc_cpe->method = cwmp_rpc_cpe_setParameterValues;
rpc_cpe->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__SetParameterValuesResponse));
rpc_cpe->method_response_data_init = cwmp_rpc_cpe_setParameterValues_response_data_init;
rpc_cpe->method_response = cwmp_rpc_cpe_setParameterValues_response;
rpc_cpe->method_end = cwmp_rpc_cpe_setParameterValues_end;
rpc_cpe->destructor = cwmp_session_rpc_cpe_destructor;
soap_methods->envelope = "cwmp:SetParameterValues";
soap_methods->envelope_response = "cwmp:SetParameterValuesResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__SetParameterValuesResponse;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__SetParameterValuesResponse;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__SetParameterValues;
return rpc_cpe;
}
int cwmp_rpc_cpe_setParameterValues (struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
struct _cwmp1__SetParameterValues *p_soap_cwmp1__SetParameterValues;
struct _cwmp1__SetParameterValuesResponse *p_soap_cwmp1__SetParameterValuesResponse;
struct cwmp1ParameterValueList *ParameterList;
struct cwmp1__ParameterValueStruct **ptr_ParameterValueStruct,*ParameterValueStruct;
char *parameter_key,buf[128];
int i,n,size,error;
struct dm_set_handler *dm_set_handler;
struct rpc_cpe *rpc_cpe_fault;
dm_set_handler = calloc(1,sizeof(struct dm_set_handler));
if (dm_set_handler == NULL)
{
return FAULT_CPE_INTERNAL_ERROR_IDX;
}
list_add_tail(&(dm_set_handler->list),&(list_dm_set_handler));
INIT_LIST_HEAD (&(dm_set_handler->cmd_list));
INIT_LIST_HEAD (&(dm_set_handler->cancel_list));
INIT_LIST_HEAD (&(dm_set_handler->service_list));
p_soap_cwmp1__SetParameterValues = (struct _cwmp1__SetParameterValues *)this->method_data;
p_soap_cwmp1__SetParameterValuesResponse = (struct _cwmp1__SetParameterValuesResponse *)this->method_response_data;
size = p_soap_cwmp1__SetParameterValues->ParameterList->__size;
ptr_ParameterValueStruct = p_soap_cwmp1__SetParameterValues->ParameterList->__ptrParameterValueStruct;
parameter_key = p_soap_cwmp1__SetParameterValues->ParameterKey;
if (error = check_duplicated_parameter_name (ptr_ParameterValueStruct, size))
{
if (cwmp_add_session_rpc_cpe_Fault(session,FAULT_CPE_INVALID_ARGUMENTS_IDX)==NULL)
{
return CWMP_GEN_ERR;
}
return CWMP_FAULT_CPE;
}
for (i=0;i<size;i++,ptr_ParameterValueStruct++)
{
ParameterValueStruct = *ptr_ParameterValueStruct;
CWMP_LOG(INFO,"param[%d] Name = %s, Value = %s",i,ParameterValueStruct->Name,(strlen(ParameterValueStruct->Value)<1000)?ParameterValueStruct->Value:"(Unable to display big stings)");
error = cwmp_dm_setParameterValues(cwmp, dm_set_handler, ParameterValueStruct->Name, ParameterValueStruct->Value);
if (error != FAULT_CPE_NO_FAULT_IDX)
{
if (dm_set_handler->uci)
{
CWMP_LOG(INFO,"RUN uci revert"); /* TODO to be removed*/
uci_revert_value();
}
dm_run_queue_cancel_handler(dm_set_handler);
dm_free_dm_set_handler_queues(dm_set_handler);
if (dm_set_handler!=NULL)
{
list_del(&(dm_set_handler->list));
free(dm_set_handler);
}
if ((rpc_cpe_fault = cwmp_add_session_rpc_cpe_Fault(session,error))==NULL)
{
return CWMP_GEN_ERR;
}
cwmp_rpc_cpe_Fault_parameter_cause(rpc_cpe_fault,ParameterValueStruct->Name);
return CWMP_FAULT_CPE;
}
}
dm_run_queue_cmd_handler(dm_set_handler,FALSE);
p_soap_cwmp1__SetParameterValuesResponse->Status = _cwmp1__SetParameterValuesResponse_Status__0;
CWMP_LOG(INFO,"RUN uci commit");
sprintf(buf,"%s=%s",UCI_ACS_PARAMETERKEY_PATH,parameter_key);
uci_set_value (buf);
uci_commit_value();
if (dm_set_handler->cwmp_reload==TRUE)
{
CWMP_LOG(INFO,"Add cwmp config reload at the end of the session");
add_session_end_func(session,dm_cwmp_config_reload,NULL,FALSE);
p_soap_cwmp1__SetParameterValuesResponse->Status = _cwmp1__SetParameterValuesResponse_Status__1;
}
if (dm_set_handler->reboot_required==TRUE)
{
CWMP_LOG(INFO,"Add reboot at the end of the session");
add_session_end_func(session,cwmp_reboot,NULL,TRUE);
p_soap_cwmp1__SetParameterValuesResponse->Status = _cwmp1__SetParameterValuesResponse_Status__1;
}
if (dm_set_handler->cmd_list.next!=&(dm_set_handler->cmd_list) ||
(dm_set_handler->service_list.next!=&(dm_set_handler->service_list) && dm_set_handler->reboot_required==FALSE))
{
add_session_end_func(session,dm_run_queue_cmd_handler_at_end_session,dm_set_handler,FALSE);
p_soap_cwmp1__SetParameterValuesResponse->Status = _cwmp1__SetParameterValuesResponse_Status__1;
return CWMP_OK;
}
dm_free_dm_set_handler_queues(dm_set_handler);
if (dm_set_handler!=NULL)
{
list_del(&(dm_set_handler->list));
free(dm_set_handler);
}
return CWMP_OK;
}
int cwmp_rpc_cpe_setParameterValues_response_data_init(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
int cwmp_rpc_cpe_setParameterValues_response(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
int error;
CWMP_LOG (INFO,"Trying to send SetParameterValues response to the ACS");
error = cwmp_soap_send_rpc_cpe_response (cwmp, session, this);
return error;
}
int cwmp_rpc_cpe_setParameterValues_end(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this)
{
return CWMP_OK;
}
static int check_duplicated_parameter_name (struct cwmp1__ParameterValueStruct **ptr_ParameterValueStruct, int size)
{
struct cwmp1__ParameterValueStruct **p, **q, *pvs, *qvs;
int i,j;
for (i=0,p=ptr_ParameterValueStruct;i<(size-1);i++,p++)
{
pvs = *p;
for (j=i+1,q=p+1;j<size;j++,q++)
{
qvs = *q;
if (strcmp(pvs->Name,qvs->Name)==0)
{
return CWMP_GEN_ERR;
}
}
}
return CWMP_OK;
}

120
src/TransferComplete.c Normal file
View file

@ -0,0 +1,120 @@
/*
TransferComplete.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "list.h"
#include "backupSession.h"
int cwmp_rpc_acs_transferComplete_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_transferComplete_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_transferComplete_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_transferComplete_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_rpc_acs_transferComplete_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int cwmp_session_rpc_acs_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *rpc_acs);
void soap_serialize__cwmp1__TransferComplete(struct soap *soap, const struct _cwmp1__TransferComplete *a);
int soap_put__cwmp1__TransferComplete(struct soap *soap, const struct _cwmp1__TransferComplete *a, const char *tag, const char *type);
struct _cwmp1__TransferCompleteResponse * soap_get__cwmp1__TransferCompleteResponse(struct soap *soap, struct _cwmp1__TransferCompleteResponse *p, const char *tag, const char *type);
struct rpc_acs *cwmp_add_session_rpc_acs (struct session *session);
void backup_session_delete_rpc(char *name, char *commandKey, int status);
static struct _cwmp1__TransferComplete *pcwmp1__TransferComplete_data;
struct _cwmp1__TransferComplete *cwmp_set_data_rpc_acs_transferComplete ()
{
pcwmp1__TransferComplete_data = calloc (1,sizeof(struct _cwmp1__TransferComplete));
return pcwmp1__TransferComplete_data;
}
struct rpc_acs *cwmp_add_session_rpc_acs_transferComplete (struct session *session)
{
struct rpc_acs *rpc_acs;
struct soap_cwmp1_methods__rpc *soap_methods;
rpc_acs = cwmp_add_session_rpc_acs (session);
if (rpc_acs == NULL)
{
return NULL;
}
soap_methods = &(rpc_acs->soap_methods);
rpc_acs->method_data = (void *) pcwmp1__TransferComplete_data;
rpc_acs->method_data_init = cwmp_rpc_acs_transferComplete_data_init;
rpc_acs->method_remote_call = cwmp_rpc_acs_transferComplete_remote_call;
rpc_acs->method_response_data = (void *) calloc (1,sizeof(struct _cwmp1__TransferCompleteResponse));
rpc_acs->method_response = cwmp_rpc_acs_transferComplete_response;
rpc_acs->method_end = cwmp_rpc_acs_transferComplete_end;
rpc_acs->destructor = cwmp_rpc_acs_transferComplete_destructor;
rpc_acs->type = RPC_ACS_TRANSFERCOMPLETE_IDX;
soap_methods->envelope = "cwmp:TransferComplete";
soap_methods->envelope_response = "cwmp:TransferCompleteResponse";
soap_methods->soap_serialize_cwmp1__send_data = (void *) soap_serialize__cwmp1__TransferComplete;
soap_methods->soap_put_cwmp1__send_data = (void *) soap_put__cwmp1__TransferComplete;
soap_methods->soap_get_cwmp1__rpc_received_data = (void *) soap_get__cwmp1__TransferCompleteResponse;
return rpc_acs;
}
int cwmp_rpc_acs_transferComplete_data_init (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_transferComplete_remote_call (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
CWMP_LOG (INFO,"Trying to call the TransferComplete remote method");
cwmp_soap_call_rpc_acs (cwmp, session, this);
return CWMP_OK;
}
int cwmp_rpc_acs_transferComplete_response (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_transferComplete_end (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
return CWMP_OK;
}
int cwmp_rpc_acs_transferComplete_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *this)
{
struct _cwmp1__TransferComplete *p;
p = (struct _cwmp1__TransferComplete *) this->method_data;
backup_session_delete_rpc("TransferComplete", p->CommandKey, RPC_NO_STATUS);
if (p!=NULL)
{
if (p->CommandKey!=NULL)
{
free(p->CommandKey);
}
if (p->FaultStruct!=NULL)
{
if (p->FaultStruct->FaultCode!=NULL)
{
free(p->FaultStruct->FaultCode);
}
if (p->FaultStruct->FaultString!=NULL)
{
free(p->FaultStruct->FaultString);
}
free(p->FaultStruct);
}
}
cwmp_session_rpc_acs_destructor (cwmp, session, this);
return CWMP_OK;
}

1379
src/backupSession.c Normal file

File diff suppressed because it is too large Load diff

1099
src/config.c Normal file

File diff suppressed because it is too large Load diff

25
src/config/cwmp Normal file
View file

@ -0,0 +1,25 @@
config 'cwmp' 'acs'
option 'url' 'http://192.168.1.238:8080/openacs/acs'
option 'userid' 'inteno'
option 'passwd' 'inteno'
option 'periodic_inform_enable' 'true'
option 'periodic_inform_interval' '1800'
option 'ParameterKey' ''
option 'dhcp_discovery' 'disable'
config 'cwmp' 'cpe'
option 'log_to_console' 'disable'
option 'log_to_file' 'enable'
option 'log_severity' 'INFO'
option 'log_file_name' '/var/log/cwmpd.log'
option 'log_max_size' '102400'
option 'userid' 'cpeinteno'
option 'passwd' 'cpeinteno'
option 'port' '7547'
config 'cwmp' 'dm'
list 'xml' '/etc/cwmpd/dm/tr098.xml'
config 'cwmp' 'notification'
config 'cwmp' 'accesslist'

135
src/connectionRequest.c Normal file
View file

@ -0,0 +1,135 @@
/*
connectionRequest.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "cwmp.h"
#include "httpda.h"
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key);
static bool get_connection_request = FALSE;
void *thread_connection_request_listener (void *v)
{
struct cwmp *cwmp = (struct cwmp *) v;
struct event_container *event_container;
struct soap soap;
SOAP_SOCKET m,s;
int port,valid_socket;
port = cwmp->conf.connection_request_port;
soap_init(&soap);
soap_register_plugin(&soap, http_da);
soap.send_timeout = 30;
soap.recv_timeout = 30;
soap.accept_timeout = 864000;
m = soap_bind(&soap, NULL, port, 100);
if (!soap_valid_socket(m))
{
CWMP_LOG(ERROR,"Soap socket bind error in the connection request listener thread. Quit the thread!");
soap_destroy(&soap);
soap_end(&soap);
soap_done(&soap);
return NULL;
}
CWMP_LOG(INFO,"Bind the connection request listener, port=%d.",port);
for (;;)
{
get_connection_request = FALSE;
s = soap_accept(&soap);
soap_valid_socket(s);
soap_serve(cwmp,&soap);
soap_closesock(&soap);
soap_end(&soap);
if (!get_connection_request)
{
continue;
}
CWMP_LOG(INFO,"Connection Request thread: add connection request event in the queue");
pthread_mutex_lock (&(cwmp->mutex_session_queue));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_6CONNECTION_REQUEST, "");
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
pthread_cond_signal(&(cwmp->threshold_session_send));
}
soap_done(&soap);
return CWMP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 soap_serve_request(struct cwmp *cwmp, struct soap *soap)
{
char *userid,*passwd;
char *authrealm = "Inteno CWMP";
userid = cwmp->conf.cpe_userid;
passwd = cwmp->conf.cpe_passwd;
if (userid==NULL || passwd==NULL)
{
return soap->error=503;
}
if (soap->authrealm && soap->userid)
{
if (!strcmp(soap->authrealm, authrealm) && !strcmp(soap->userid, userid))
{
if (!http_da_verify_get(soap, passwd)) // HTTP POST DA verification
{
soap_end_send(soap);
get_connection_request = TRUE;
return SOAP_OK;
}
}
}
soap->authrealm = authrealm; // realm to send to client
return soap->error=401; // Not authorized, challenge with digest authentication
}
SOAP_FMAC5 int SOAP_FMAC6 soap_serve(struct cwmp *cwmp, struct soap *soap)
{
static int cr_request = 0;
static time_t restrict_start_time = 0;
time_t current_time;
current_time = time(NULL);
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;
soap->error = 503;
return soap_send_fault(soap);
}
}
soap_begin_recv(soap);
if (soap_serve_request(cwmp,soap) ||
soap_response(soap, SOAP_OK) ||
soap_end_send(soap))
{
return soap_send_fault(soap);
}
return SOAP_OK;
}

684
src/cwmp.c Normal file
View file

@ -0,0 +1,684 @@
/*
cwmp.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <pthread.h>
#include <signal.h>
#include "cwmp.h"
#include "backupSession.h"
#define CWMP_DAEMON_MULTITHREAD 1/* TODO KMD need for debug*/
struct cwmp cwmp_main;
static pthread_mutex_t thread_sync_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t thread_sync_cond = PTHREAD_COND_INITIALIZER;
static bool thread_sync_wait = TRUE;
struct rpc_acs *cwmp_add_session_rpc_acs_inform (struct session *session);
struct rpc_cpe *cwmp_soap_receive_rpc_cpe (struct cwmp *cwmp,struct session *session);
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key);
struct paramater_container *cwmp_add_parameter_container (struct cwmp *cwmp, struct event_container *event_container, char *name);
void backup_session_move_inform_to_inform_send ();
void backup_session_move_inform_to_inform_queue ();
void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_container);
void *cwmp_schedule_session (void *v);
void *thread_event_periodic (void *v);
void *thread_connection_request_listener (void *v);
void *thread_cwmp_rpc_cpe_scheduleInform (void *v);
void *thread_cwmp_rpc_cpe_download (void *v);
void *thread_kernel_api_cwmp_value_change_parameters (void *v);
void *thread_lib_api_cwmp_value_change_parameters (void *v);
struct rpc_acs *cwmp_add_session_rpc_acs (struct session *session)
{
struct rpc_acs *rpc_acs;
rpc_acs = calloc (1,sizeof(struct rpc_acs));
if (rpc_acs==NULL)
{
return NULL;
}
list_add_tail (&(rpc_acs->list), &(session->head_rpc_acs));
return rpc_acs;
}
struct rpc_cpe *cwmp_add_session_rpc_cpe (struct session *session)
{
struct rpc_cpe *rpc_cpe;
rpc_cpe = calloc (1,sizeof(struct rpc_cpe));
if (rpc_cpe==NULL)
{
return NULL;
}
list_add_tail (&(rpc_cpe->list), &(session->head_rpc_cpe));
return rpc_cpe;
}
struct rpc_acs *cwmp_add_session_rpc_acs_head (struct session *session)
{
struct rpc_acs *rpc_acs;
rpc_acs = calloc (1,sizeof(struct rpc_acs));
if (rpc_acs==NULL)
{
return NULL;
}
list_add (&(rpc_acs->list), &(session->head_rpc_acs));
return rpc_acs;
}
int cwmp_session_rpc_cpe_destructor (struct cwmp *cwmp, struct session *session, struct rpc_cpe *rpc_cpe)
{
if (rpc_cpe == NULL)
{
return CWMP_OK;
}
if (rpc_cpe->method_data!=NULL)
{
free (rpc_cpe->method_data);
}
if (rpc_cpe->method_response_data!=NULL)
{
free (rpc_cpe->method_response_data);
}
list_del(&(rpc_cpe->list));
free (rpc_cpe);
return CWMP_OK;
}
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 cwmp_session_rpc_acs_destructor (struct cwmp *cwmp, struct session *session, struct rpc_acs *rpc_acs)
{
if (rpc_acs == NULL)
{
return CWMP_OK;
}
if (rpc_acs->method_data!=NULL)
{
free (rpc_acs->method_data);
}
if (rpc_acs->method_response_data!=NULL)
{
free (rpc_acs->method_response_data);
}
list_del(&(rpc_acs->list));
free (rpc_acs);
return CWMP_OK;
}
void thread_sync()
{
pthread_mutex_lock(&thread_sync_mutex);
thread_sync_wait = FALSE;
pthread_cond_signal(&thread_sync_cond);
pthread_mutex_unlock(&thread_sync_mutex);
}
void thread_wait_sync()
{
pthread_mutex_lock(&thread_sync_mutex);
if(thread_sync_wait)
{
pthread_cond_wait(&thread_sync_cond,&thread_sync_mutex);
}
thread_sync_wait = TRUE;
pthread_mutex_unlock(&thread_sync_mutex);
}
void *cwmp_schedule_session (void *v)
{
struct list_head *ilist;
struct session *session;
int t,error = CWMP_OK;
static struct timespec time_to_wait = {0, 0};
bool retry = FALSE;
struct cwmp *cwmp = (struct cwmp *) v;
thread_sync();
while (1)
{
pthread_mutex_lock (&(cwmp->mutex_session_send));
ilist = (&(cwmp->head_session_queue))->next;
while ((ilist == &(cwmp->head_session_queue)) || retry)
{
t = cwmp_get_retry_interval(cwmp);
time_to_wait.tv_sec = time(NULL) + t;
CWMP_LOG(INFO,"Waiting the next session");
pthread_cond_timedwait(&(cwmp->threshold_session_send), &(cwmp->mutex_session_send), &time_to_wait);
ilist = (&(cwmp->head_session_queue))->next;
retry = FALSE;
}
session = list_entry(ilist, struct session, list);
cwmp_prepare_session_to_session_send (cwmp,session);
if (error = cwmp_move_session_to_session_send (cwmp, session))
{
CWMP_LOG(EMERG,"FATAL error in the mutex process in the session shceduler!");
exit(EXIT_FAILURE);
}
error = cwmp_schedule_rpc (cwmp,session);
run_session_end_func(cwmp,&(session->head_session_end_func));
if (session->error == CWMP_RETRY_SESSION)
{
error = cwmp_move_session_to_session_queue (cwmp, session);
CWMP_LOG(INFO,"Retry session, retry count = %d, retry in %ds",cwmp->retry_count_session,cwmp_get_retry_interval(cwmp));
retry = TRUE;
pthread_mutex_unlock (&(cwmp->mutex_session_send));
continue;
}
cwmp_session_destructor (cwmp, session);
cwmp->session_send = NULL;
cwmp->retry_count_session = 0;
pthread_mutex_unlock (&(cwmp->mutex_session_send));
# if !CWMP_DAEMON_MULTITHREAD /* TODO KMD need for debug*/
break;
#endif
}
return CWMP_OK;
}
int cwmp_schedule_rpc (struct cwmp *cwmp, struct session *session)
{
struct list_head *ilist;
struct rpc_acs *rpc_acs;
struct rpc_cpe *rpc_cpe;
int error=0,e;
cwmp_session_soap_init(session);
while (1)
{
session->error = CWMP_OK;
__list_for_each(ilist, &(session->head_rpc_acs))
{
rpc_acs = list_entry (ilist, struct rpc_acs, list);
if (!(error = rpc_acs->method_data_init (cwmp, session, rpc_acs)))
{
rpc_acs->method_remote_call(cwmp, session, rpc_acs);
if (rpc_acs->error==CWMP_SUCCESS_RPC && session->error!=CWMP_RETRY_SESSION)
{
error = rpc_acs->method_response (cwmp, session, rpc_acs);
}
}
if (e = rpc_acs->method_end (cwmp, session, rpc_acs))
{
error = e;
}
cwmp_session_soap_destroy_end (session);
if (error || session->error==CWMP_RETRY_SESSION)
{
session->error = CWMP_RETRY_SESSION;
goto end_rpc_sheculer;
}
ilist = ilist->prev;
if (error = rpc_acs->destructor (cwmp, session, rpc_acs))
{
session->error = CWMP_RETRY_SESSION;
goto end_rpc_sheculer;
}
if (session->hold_request)
{
break;
}
}
while (1)
{
session->error = CWMP_OK;
cwmp_soap_send_http_empty (cwmp,session);
if (session->error == CWMP_RETRY_SESSION)
{
goto end_rpc_sheculer;
}
session->error = CWMP_OK;
e = cwmp_soap_recv_http_empty (cwmp,session);
if (session->error == CWMP_RETRY_SESSION)
{
goto end_rpc_sheculer;
}
else if (e == CWMP_UNAUTHORIZED_401)
{
CWMP_LOG(INFO,"Receive http 401: need authentication");
cwmp_session_soap_destroy_end (session);
continue;
}
else if (session->error == CWMP_CONTINUE_SESSION ||
session->error == CWMP_SUCCESS_SESSION)
{
break;
}
session->error = CWMP_RETRY_SESSION;
goto end_rpc_sheculer;
}
if (session->error == CWMP_CONTINUE_SESSION)
{
while (1)
{
rpc_cpe = cwmp_soap_receive_rpc_cpe (cwmp, session);
if (rpc_cpe == NULL)
{
session->error = CWMP_RETRY_SESSION;
goto end_rpc_sheculer;
}
while (1)
{
if (!(error = rpc_cpe->method(cwmp, session, rpc_cpe)))
{
if (!(error = rpc_cpe->method_response_data_init(cwmp, session, rpc_cpe)))
{
while (1)
{
cwmp_session_soap_destroy_end (session);
if (error = rpc_cpe->method_response(cwmp, session, rpc_cpe))
{
session->error = CWMP_RETRY_SESSION;
break;
}
session->error = CWMP_OK;
e = cwmp_soap_recv_http_empty (cwmp,session);
if (session->error == CWMP_RETRY_SESSION ||
session->error == CWMP_CONTINUE_SESSION ||
session->error == CWMP_SUCCESS_SESSION)
{
break;
}
else if (e == CWMP_UNAUTHORIZED_401)
{
CWMP_LOG(INFO,"Receive http 401: need authentication");
continue;
}
session->error = CWMP_RETRY_SESSION;
break;
}
}
else if(error != CWMP_FAULT_CPE)
{
session->error = CWMP_RETRY_SESSION;
}
}
else if(error != CWMP_FAULT_CPE)
{
session->error = CWMP_RETRY_SESSION;
}
if (rpc_cpe->method_end(cwmp, session, rpc_cpe) ||
rpc_cpe->destructor(cwmp, session, rpc_cpe))
{
session->error = CWMP_RETRY_SESSION;
}
if (session->error == CWMP_RETRY_SESSION)
{
goto end_rpc_sheculer;
}
ilist = session->head_rpc_cpe.next;
if (ilist == &(session->head_rpc_cpe))
{
break;
}
rpc_cpe = list_entry(ilist, struct rpc_cpe, list);
}
if (session->error != CWMP_CONTINUE_SESSION)
{
break;
}
}
}
if (session->head_rpc_acs.next==&(session->head_rpc_acs))
{
break;
}
}
end_rpc_sheculer:
cwmp_session_done(session);
return session->error;
}
int cwmp_prepare_session_to_session_send (struct cwmp *cwmp, struct session *session)
{
cwmp_root_cause_event_api_value_change (cwmp,session);
return CWMP_OK;
}
int cwmp_move_session_to_session_send (struct cwmp *cwmp, struct session *session)
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
if (cwmp->session_send != NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return cwmp->error = CWMP_MUTEX_ERR;
}
list_del (&(session->list));
strcpy (session->acs_url, cwmp->conf.acsurl);
cwmp->session_send = session;
cwmp->head_event_container = NULL;
backup_session_move_inform_to_inform_send ();
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_OK;
}
int cwmp_move_session_to_session_queue (struct cwmp *cwmp, struct session *session)
{
struct list_head *ilist,*jlist;
struct rpc_acs *rpc_acs,*queue_rpc_acs;
struct event_container *event_container_old, *event_container_new;
struct paramater_container *paramater_container_old, *paramater_container_new;
struct session *session_queue;
bool dup;
pthread_mutex_lock (&(cwmp->mutex_session_queue));
cwmp->retry_count_session ++;
cwmp->session_send = NULL;
if (cwmp->head_session_queue.next == &(cwmp->head_session_queue))
{
list_add_tail (&(session->list), &(cwmp->head_session_queue));
session->hold_request = 0;
session->digest_auth = 0;
cwmp->head_event_container = &(session->head_event_container);
if (session->head_rpc_acs.next != &(session->head_rpc_acs))
{
rpc_acs = list_entry(session->head_rpc_acs.next, struct rpc_acs, list);
if (rpc_acs->type != RPC_ACS_INFORM_IDX)
{
if (cwmp_add_session_rpc_acs_inform (session) == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
}
}
else
{
if (cwmp_add_session_rpc_acs_inform (session) == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
}
backup_session_move_inform_to_inform_queue ();
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_OK;
}
__list_for_each(ilist, &(session->head_event_container))
{
event_container_old = list_entry (ilist, struct event_container, list);
event_container_new = cwmp_add_event_container (cwmp, event_container_old->idx, event_container_old->event.CommandKey);
if (event_container_new == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
__list_for_each(jlist, &(event_container_old->head_paramater_container))
{
paramater_container_old = list_entry(jlist,struct paramater_container, list);
paramater_container_new = cwmp_add_parameter_container (cwmp,event_container_new, paramater_container_old->paramater.Name);
}
cwmp_save_event_container (cwmp,event_container_new);
}
session_queue = list_entry(cwmp->head_event_container,struct session, head_event_container);
__list_for_each(ilist, &(session->head_rpc_acs))
{
rpc_acs = list_entry(ilist, struct rpc_acs, list);
dup = FALSE;
__list_for_each(jlist, &(session_queue->head_rpc_acs))
{
queue_rpc_acs = list_entry(jlist, struct rpc_acs, list);
if (queue_rpc_acs->type == rpc_acs->type &&
(rpc_acs->type == RPC_ACS_INFORM_IDX ||
rpc_acs->type == RPC_ACS_GETRPCMETHODS_IDX))
{
dup = TRUE;
break;
}
}
if (dup)
{
continue;
}
ilist = ilist->prev;
list_del(&(rpc_acs->list));
list_add_tail (&(rpc_acs->list), &(session_queue->head_rpc_acs));
}
cwmp_session_destructor (cwmp, session);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_OK;
}
int cwmp_session_destructor (struct cwmp *cwmp, struct session *session)
{
struct rpc_acs *rpc_acs;
struct rpc_cpe *rpc_cpe;
struct session_end_func *session_end_func;
while (session->head_rpc_acs.next != &(session->head_rpc_acs))
{
rpc_acs = list_entry(session->head_rpc_acs.next, struct rpc_acs, list);
rpc_acs->destructor (cwmp, session, rpc_acs);
}
while (session->head_rpc_cpe.next != &(session->head_rpc_cpe))
{
rpc_cpe = list_entry(session->head_rpc_cpe.next, struct rpc_cpe, list);
rpc_cpe->destructor (cwmp, session, rpc_cpe);
}
while (session->head_session_end_func.next != &(session->head_session_end_func))
{
session_end_func = list_entry(session->head_session_end_func.next, struct session_end_func, list);
list_del (&(session_end_func->list));
free (session_end_func);
}
if (session->list.next != LIST_POISON1 && session->list.prev != LIST_POISON2)
{
list_del (&(session->list));
}
free (session);
return CWMP_OK;
}
struct session *cwmp_add_queue_session (struct cwmp *cwmp)
{
struct session *session;
session = calloc (1,sizeof(struct session));
if (session==NULL)
{
return NULL;
}
list_add_tail (&(session->list), &(cwmp->head_session_queue));
INIT_LIST_HEAD (&(session->head_event_container));
INIT_LIST_HEAD (&(session->head_session_end_func));
INIT_LIST_HEAD (&(session->head_rpc_acs));
INIT_LIST_HEAD (&(session->head_rpc_cpe));
if (cwmp_add_session_rpc_acs_inform (session) == NULL)
{
free (session);
return NULL;
}
return session;
}
int add_session_end_func (struct session *session, int (*func)(struct cwmp *cwmp, void *input),void *input, bool end)
{
struct session_end_func *session_end_func;
struct list_head *ilist;
__list_for_each(ilist,&(session->head_session_end_func))
{
session_end_func = list_entry(ilist, struct session_end_func, list);
if ((session_end_func->func==func) &&
(session_end_func->input==input))
{
return CWMP_OK;
}
}
session_end_func = calloc(1,sizeof(struct session_end_func));
session_end_func->func = func;
session_end_func->input = input;
if (end==TRUE)
{
list_add_tail(&(session_end_func->list),&(session->head_session_end_func));
}
else
{
list_add(&(session_end_func->list),&(session->head_session_end_func));
}
return CWMP_OK;
}
int run_session_end_func (struct cwmp *cwmp, struct list_head *head_func)
{
struct list_head *ilist;
struct session_end_func *session_end_func;
int error = CWMP_OK;
__list_for_each(ilist,head_func)
{
session_end_func = list_entry(ilist, struct session_end_func, list);
error = session_end_func->func(cwmp,session_end_func->input);
ilist = ilist->prev;
list_del(&(session_end_func->list));
free (session_end_func);
}
return error;
}
int cwmp_apply_acs_changes (struct cwmp *cwmp)
{
int error;
if (error = cwmp_config_reload(cwmp))
{
return error;
}
if (error = cwmp_root_cause_events(cwmp))
{
return error;
}
return CWMP_OK;
}
int main(int argc, char **argv)
{
struct cwmp *cwmp = &cwmp_main;
int error;
pthread_t session_scheduler_thread;
pthread_t periodic_event_thread;
pthread_t connection_request_thread;
pthread_t scheduleInform_thread;
pthread_t download_thread;
pthread_t kernel_value_change_thread;
pthread_t lib_value_change_thread;
if (error = cwmp_init(argc, argv, cwmp))
{
return error;
}
CWMP_LOG(INFO,"STARTING CWMP");
if (error = load_dm_list(UCI_DM_XML_FILE_LIST))
{
return error;
}
if (error = cwmp_load_saved_session(cwmp, NULL, ALL))
{
return error;
}
if (error = cwmp_root_cause_events(cwmp))
{
return error;
}
# if !CWMP_DAEMON_MULTITHREAD /* TODO KMD need for debug*/
cwmp_schedule_session(cwmp);
#else
error = pthread_create(&session_scheduler_thread, NULL, &cwmp_schedule_session, (void *)cwmp);
if (error<0)
{
CWMP_LOG(EMERG,"FATAL error when creating the session scheduler thread!");
exit(EXIT_FAILURE);
}
error = pthread_create(&periodic_event_thread, NULL, &thread_event_periodic, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error error when creating the periodic event thread!");
}
error = pthread_create(&connection_request_thread, NULL, &thread_connection_request_listener, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the connection request thread!");
}
error = pthread_create(&scheduleInform_thread, NULL, &thread_cwmp_rpc_cpe_scheduleInform, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the scheduled inform thread!");
}
thread_wait_sync();
error = pthread_create(&download_thread, NULL, &thread_cwmp_rpc_cpe_download, (void *)cwmp);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the download thread!");
}
error = pthread_create(&kernel_value_change_thread, NULL, &thread_kernel_api_cwmp_value_change_parameters, NULL);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the kernel value change thread!");
}
error = pthread_create(&lib_value_change_thread, NULL, &thread_lib_api_cwmp_value_change_parameters, NULL);
if (error<0)
{
CWMP_LOG(ERROR,"Error when creating the lib/cli value change thread!");
}
pthread_join(session_scheduler_thread, NULL);
pthread_join(periodic_event_thread, NULL);
pthread_join(connection_request_thread, NULL);
pthread_join(scheduleInform_thread, NULL);
pthread_join(download_thread, NULL);
pthread_join(kernel_value_change_thread, NULL);
pthread_join(lib_value_change_thread, NULL);
#endif
CWMP_LOG(INFO,"EXIT CWMP");
return CWMP_OK;
}

287
src/cwmp_api.c Normal file
View file

@ -0,0 +1,287 @@
/*
cwmp.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <linux/netlink.h>
#include <stdarg.h>
#include "soapH.h"
#include "cwmp.h"
#include "dm.h"
#include "dm_rpc.h"
#include "cwmp_kernel.h"
#include "cwmp_lib.h"
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key);
extern struct cwmp cwmp_main;
struct api_value_change_thread_input {
struct cwmp *cwmp;
char *path;
struct sub_path *sub_path;
int sub_path_size;
};
void *thread_api_cwmp_value_change_parameters (void *v)
{
struct api_value_change_thread_input *t_input;
struct cwmp *cwmp;
struct event_container *event_container;
int error,i,n=0;
bool is_actif;
t_input = (struct api_value_change_thread_input *)v;
cwmp = t_input->cwmp;
pthread_mutex_lock (&(cwmp->api_value_change.mutex));
error = cwmp_dm_getParameterPaths_by_correspondence(cwmp,t_input->path,t_input->sub_path,t_input->sub_path_size,&(cwmp->api_value_change.parameter_list),&n,FALSE,TRUE,&is_actif);
cwmp->api_value_change.parameter_size += n;
if (error==FAULT_CPE_NO_FAULT_IDX && is_actif)
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return NULL;
}
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
pthread_cond_signal(&(cwmp->threshold_session_send));
}
for (i=0;i<t_input->sub_path_size;i++)
{
if (t_input->sub_path[i].dm_indice.indice!=NULL)
{
free(t_input->sub_path[i].dm_indice.indice);
}
}
free(t_input->sub_path);
if (t_input->path!=NULL)
{
free(t_input->path);
}
free(t_input);
pthread_mutex_unlock (&(cwmp->api_value_change.mutex));
return NULL;
}
int api_cwmp_value_change_parameters (int argc, char **argv)
{
struct cwmp *cwmp = &cwmp_main;
struct api_value_change_thread_input *t_input;
va_list args;
pthread_t thread;
int error;
if (argc < 1)
{
return CWMP_OK;
}
t_input = calloc (1,sizeof(struct api_value_change_thread_input));
t_input->sub_path = calloc (DM_MAX_INDICE,sizeof(struct sub_path));
t_input->cwmp = cwmp;
cwmp_dm_get_sub_indice_path(argc,argv,&(t_input->path),t_input->sub_path,&(t_input->sub_path_size));
error = pthread_create(&thread, NULL, &thread_api_cwmp_value_change_parameters, (void *)t_input);
if (error<0)
{
free (t_input->sub_path);
free (t_input);
CWMP_LOG(ERROR,"Error when creating a value change api thread!");
}
return CWMP_OK;
}
/* kernel api */
void *thread_kernel_api_cwmp_value_change_parameters (void *v)
{
int i, argc, sock_fd;
char **argv;
struct sockaddr_nl src_addr, dest_addr;
struct nlmsghdr *nlh = NULL;
struct iovec iov;
struct msghdr msg;
sock_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_USER);
if(sock_fd<0)
{
CWMP_LOG(ERROR,"Error when creating NetLink socket to kernel: Quit kernel value change thread!");
return NULL;
}
memset(&src_addr, 0, sizeof(src_addr));
src_addr.nl_family = AF_NETLINK;
src_addr.nl_pid = getpid();
bind(sock_fd, (struct sockaddr*)&src_addr, sizeof(src_addr));
memset(&dest_addr, 0, sizeof(dest_addr));
dest_addr.nl_family = AF_NETLINK;
dest_addr.nl_pid = 0; /* For Linux Kernel */
dest_addr.nl_groups = 0; /* unicast */
nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(NETLINK_MAX_PAYLOAD));
argv = calloc ((DM_MAX_INDICE+1),sizeof(char *));
while (1)
{
memset(nlh, 0, NLMSG_SPACE(NETLINK_MAX_PAYLOAD));
nlh->nlmsg_len = NLMSG_SPACE(NETLINK_MAX_PAYLOAD);
nlh->nlmsg_pid = getpid();
nlh->nlmsg_flags = 0;
iov.iov_base = (void *)nlh;
iov.iov_len = nlh->nlmsg_len;
msg.msg_name = (void *)&dest_addr;
msg.msg_namelen = sizeof(dest_addr);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
strcpy(NLMSG_DATA(nlh), NETLINK_CWMP_ID);
sendmsg(sock_fd,&msg,0);
argc = 0;
while (argc<(DM_MAX_INDICE+1))
{
memset(nlh, 0, NLMSG_SPACE(NETLINK_MAX_PAYLOAD));
nlh->nlmsg_len = NLMSG_SPACE(NETLINK_MAX_PAYLOAD);
nlh->nlmsg_pid = getpid();
nlh->nlmsg_flags = 0;
iov.iov_base = (void *)nlh;
iov.iov_len = nlh->nlmsg_len;
msg.msg_name = (void *)&dest_addr;
msg.msg_namelen = sizeof(dest_addr);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
/* Read message from kernel */
recvmsg(sock_fd, &msg, 0);
if (strcmp(NLMSG_DATA(nlh),NETLINK_END_DATA)==0)
{
break;
}
if (strcmp(NLMSG_DATA(nlh),NETLINK_NULL)==0)
{
argv[argc] = NULL;
}
else
{
argv[argc] = strdup (NLMSG_DATA(nlh));
}
argc++;
}
CWMP_LOG(INFO,"Receive Parameter Value change from Kernel space");
api_cwmp_value_change_parameters(argc,argv);
for (i=0;i<argc;i++)
{
free(argv[i]);
}
}
free(argv);
close(sock_fd);
return NULL;
}
void *thread_lib_api_cwmp_value_change_parameters (void *v)
{
char buffer[1024],**argv;
FILE *fp;
socklen_t fromlen;
int argc, size=1023;
register int i, s, ns, len;
struct sockaddr_un saun, fsaun;
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
CWMP_LOG(ERROR,"Error when creating process socket listener: Quit lib value change thread!");
return NULL;
}
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, AF_UNIX_ADDRESS);
unlink(AF_UNIX_ADDRESS);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (bind(s, (const struct sockaddr *) &saun, len) < 0)
{
CWMP_LOG(ERROR,"Error when binding process socket: Quit lib value change thread!");
return NULL;
}
/*
* Listen on the socket.
*/
if (listen(s, 5) < 0) {
CWMP_LOG(ERROR,"Error when listening process socket: Quit lib value change thread!");
return NULL;
}
argv = calloc ((DM_MAX_INDICE+1),sizeof(char *));
while (1)
{
fromlen = sizeof(fsaun);
if ((ns = accept(s, (struct sockaddr *) &fsaun, &fromlen)) < 0)
{
CWMP_LOG(ERROR,"Error when accepting process socket");
continue;
}
fp = fdopen(ns, "r");
argc = 0;
while (fgets(buffer,sizeof(buffer),fp))
{
buffer[strlen(buffer)-1] = 0;
if (strcmp(buffer,AF_UNIX_END_DATA)==0)
{
break;
}
if (strcmp(buffer,AF_UNIX_NULL)==0)
{
argv[argc] = NULL;
}
else
{
argv[argc] = strdup(buffer);
}
argc++;
}
CWMP_LOG(INFO,"Receive Parameter Value change from other process");
api_cwmp_value_change_parameters(argc,argv);
for (i=0;i<argc;i++)
{
if (argv[i]!=NULL)
{
free(argv[i]);
}
}
}
free(argv);
close(s);
return NULL;
}

71
src/cwmp_lib.c Normal file
View file

@ -0,0 +1,71 @@
/*
cwmp_lib.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdarg.h>
#include "cwmp_lib.h"
int lib_api_cwmp_value_change_call (int count, ...)
{
FILE *fp;
register int i, s, len;
struct sockaddr_un saun;
va_list args;
char *str,buf[256];
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf("[CWMP] Error when creating process from other process: Quit\r\n");
return 1;
}
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, AF_UNIX_ADDRESS);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (connect(s, (struct sockaddr *) &saun, len) < 0)
{
printf("[CWMP] Error when creating socket from other process: Quit\r\n");
return 1;
}
va_start(args, count);
for (i=0;i<count;i++)
{
str = (char *) va_arg(args, char *);
if (str==NULL)
{
str = AF_UNIX_NULL;
}
sprintf(buf,"%s\n",str);
str = buf;
send(s, str, strlen(str), 0);
}
va_end(args);
sprintf(buf,"%s\n",AF_UNIX_END_DATA);
send(s, buf, strlen(buf), 0);
close(s);
return 0;
}

61
src/cwmp_value_change.c Executable file
View file

@ -0,0 +1,61 @@
/*
cwmp_value_change.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdarg.h>
#include "cwmp_lib.h"
int main (int argc, char **argv)
{
FILE *fp;
register int i, s, len;
struct sockaddr_un saun;
char buf[256];
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
printf("[CWMP] Error when creating process from api CLI: Quit\r\n");
return 1;
}
saun.sun_family = AF_UNIX;
strcpy(saun.sun_path, AF_UNIX_ADDRESS);
len = sizeof(saun.sun_family) + strlen(saun.sun_path);
if (connect(s, (const struct sockaddr *) &saun, len) < 0)
{
printf("[CWMP] Error when creating socket from api CLI: Quit\r\n");
return 1;
}
printf("[CWMP] Send Value change to the cwmp client from api CLI\r\n");
for (i=1;i<argc;i++)
{
sprintf(buf,"%s\n",argv[i]);
send(s, buf, strlen(buf), 0);
}
sprintf(buf,"%s\n",AF_UNIX_END_DATA);
send(s, buf, strlen(buf), 0);
close(s);
return 0;
}

2004
src/dm.c Normal file

File diff suppressed because it is too large Load diff

View file

1337
src/dm/xml/tr098.xml Normal file

File diff suppressed because it is too large Load diff

1748
src/dm_rpc.c Normal file

File diff suppressed because it is too large Load diff

485
src/event.c Normal file
View file

@ -0,0 +1,485 @@
/*
event.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <pthread.h>
#include "cwmp.h"
#include "backupSession.h"
#include "dm.h"
#include "dm_rpc.h"
struct rpc_acs *cwmp_add_session_rpc_acs_getRPCMethods (struct session *session);
struct rpc_acs *cwmp_add_session_rpc_acs_transferComplete (struct session *session);
struct session *cwmp_add_queue_session (struct cwmp *cwmp);
void backup_session_insert_rpc(char *name, char *commandKey, int status);
void backup_session_delete_rpc(char *name, char *commandKey, int status);
void backup_session_insert_event(char *name, char *commandKey, int id, int rpc_status);
void backup_session_insert_parameter(char *name, char *value, char *parent,char *parent_name, int id, char *commandKey);
int cwmp_scheduleInform_remove_all();
int cwmp_scheduledDownload_remove_all();
const struct EVENT_CONST_STRUCT EVENT_CONST [] = {
[EVENT_IDX_0BOOTSTRAP] = {"0 BOOTSTRAP", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_1BOOT] = {"1 BOOT", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL},
[EVENT_IDX_2PERIODIC] = {"2 PERIODIC", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_3SCHEDULED] = {"3 SCHEDULED", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_4VALUE_CHANGE] = {"4 VALUE CHANGE", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL},
[EVENT_IDX_5KICKED] = {"5 KICKED", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_6CONNECTION_REQUEST] = {"6 CONNECTION REQUEST", EVENT_TYPE_SINGLE, 0},
[EVENT_IDX_7TRANSFER_COMPLETE] = {"7 TRANSFER COMPLETE", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_8DIAGNOSTICS_COMPLETE] = {"8 DIAGNOSTICS COMPLETE", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL},
[EVENT_IDX_9REQUEST_DOWNLOAD] = {"9 REQUEST DOWNLOAD", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_10AUTONOMOUS_TRANSFER_COMPLETE] = {"10 AUTONOMOUS TRANSFER COMPLETE", EVENT_TYPE_SINGLE, EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_M_Reboot] = {"M Reboot", EVENT_TYPE_MULTIPLE,EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_M_ScheduleInform] = {"M ScheduleInform", EVENT_TYPE_MULTIPLE,EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_M_Download] = {"M Download", EVENT_TYPE_MULTIPLE,EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT},
[EVENT_IDX_M_Upload] = {"M Upload", EVENT_TYPE_MULTIPLE,EVENT_RETRY_AFTER_TRANSMIT_FAIL|EVENT_RETRY_AFTER_REBOOT}
};
void cwmp_save_event_container (struct cwmp *cwmp,struct event_container *event_container)
{
struct cwmp1__EventStruct *pEventStruct;
struct list_head *ilist;
struct paramater_container *paramater_container;
struct cwmp1__ParameterValueStruct *ptr_ParameterValueStruct;
char section[256];
pEventStruct = &(event_container->event);
if (EVENT_CONST[event_container->idx].RETRY != 0)
{
backup_session_insert_rpc("Inform",NULL,RPC_QUEUE);
backup_session_insert_event(pEventStruct->EventCode, pEventStruct->CommandKey, event_container->id, RPC_QUEUE);
__list_for_each(ilist,&(event_container->head_paramater_container))
{
paramater_container = list_entry(ilist, struct paramater_container, list);
ptr_ParameterValueStruct = &(paramater_container->paramater);
backup_session_insert_parameter(ptr_ParameterValueStruct->Name,NULL,"event",pEventStruct->EventCode,event_container->id,pEventStruct->CommandKey);
}
}
return;
}
struct event_container *cwmp_add_event_container (struct cwmp *cwmp, int event_idx, char *command_key)
{
static unsigned int id;
struct event_container *event_container;
struct session *session;
struct list_head *ilist;
if (cwmp->head_event_container == NULL)
{
session = cwmp_add_queue_session(cwmp);
if (session == NULL)
{
return NULL;
}
cwmp->head_event_container = &(session->head_event_container);
}
session = list_entry (cwmp->head_event_container, struct session,head_event_container);
__list_for_each(ilist, cwmp->head_event_container)
{
event_container = list_entry (ilist, struct event_container, list);
if (event_container->idx==event_idx &&
EVENT_CONST[event_idx].TYPE==EVENT_TYPE_SINGLE)
{
return event_container;
}
if(event_container->idx > event_idx)
{
break;
}
}
event_container = calloc (1,sizeof(struct event_container));
if (event_container==NULL)
{
return NULL;
}
INIT_LIST_HEAD (&(event_container->head_paramater_container));
list_add (&(event_container->list), ilist->prev);
event_container->event.EventCode = strdup(EVENT_CONST[event_idx].CODE);
event_container->event.CommandKey = strdup(command_key);
if((id<0) || (id>=MAX_INT_ID) )
{
id=0;
}
id++;
event_container->id = id;
event_container->idx = event_idx;
session->event_size++;
return event_container;
}
struct paramater_container *cwmp_add_parameter_container
(struct cwmp *cwmp,
struct event_container *event_container,
char *name)
{
struct paramater_container *paramater_container;
struct cwmp1__ParameterValueStruct *ptr_ParameterValueStruct;
struct list_head *ilist;
struct session *session;
__list_for_each(ilist,&(event_container->head_paramater_container))
{
paramater_container = list_entry(ilist, struct paramater_container, list);
ptr_ParameterValueStruct = &(paramater_container->paramater);
if(strcmp(ptr_ParameterValueStruct->Name,name)==0)
{
return paramater_container;
}
}
paramater_container = calloc (1, sizeof(struct paramater_container));
if(paramater_container == NULL)
{
return NULL;
}
paramater_container->paramater.Name = strdup(name);
list_add_tail(&(paramater_container->list), &(event_container->head_paramater_container));
session = list_entry (cwmp->head_event_container, struct session,head_event_container);
session->parameter_size++;
return paramater_container;
}
int cwmp_root_cause_event_boot (struct cwmp *cwmp)
{
struct event_container *event_container;
if (cwmp->env.boot == CWMP_START_BOOT)
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
cwmp->env.boot = 0;
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_1BOOT, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
return CWMP_OK;
}
int event_remove_all_event_container(struct session *session, int rem_from)
{
struct cwmp1__EventStruct *eventStruct;
struct event_container *event_container;
struct paramater_container *paramater_container;
struct cwmp1__ParameterValueStruct *paramater;
while (session->head_event_container.next!=&(session->head_event_container))
{
event_container = list_entry(session->head_event_container.next, struct event_container, list);
eventStruct = &(event_container->event);
if (eventStruct->EventCode!=NULL)
{
free (eventStruct->EventCode);
}
if (eventStruct->CommandKey!=NULL)
{
free (eventStruct->CommandKey);
}
while (event_container->head_paramater_container.next!=&(event_container->head_paramater_container))
{
paramater_container = list_entry(event_container->head_paramater_container.next, struct paramater_container, list);
paramater = &(paramater_container->paramater);
if (paramater->Name!=NULL)
{
free (paramater->Name);
}
if (paramater->Value!=NULL)
{
free(paramater->Value);
}
list_del(&(paramater_container->list));
free(paramater_container);
}
list_del(&(event_container->list));
free (event_container);
}
session->event_size = 0;
session->parameter_size = 0;
backup_session_delete_rpc("Inform",NULL,rem_from);
return CWMP_OK;
}
int cwmp_root_cause_event_bootstrap (struct cwmp *cwmp)
{
char *acsurl = NULL;
int error,cmp=0;
struct event_container *event_container;
struct session *session;
error = cwmp_load_saved_session(cwmp, &acsurl, ACS);
if(acsurl == NULL)
{
save_acs_bkp_config (cwmp);
}
if (acsurl == NULL || ((acsurl != NULL)&&(cmp = strcmp(cwmp->conf.acsurl,acsurl))))
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
if (cwmp->head_event_container!=NULL && cwmp->head_session_queue.next!=&(cwmp->head_session_queue))
{
session = list_entry(cwmp->head_event_container,struct session, head_event_container);
event_remove_all_event_container (session,RPC_QUEUE);
}
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_0BOOTSTRAP, "");
if (acsurl != NULL)
{
free(acsurl);
}
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
cwmp_save_event_container (cwmp,event_container);
cwmp_scheduleInform_remove_all();
cwmp_scheduledDownload_remove_all();
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
if (cmp)
{
struct paramater_container *paramater_container;
pthread_mutex_lock (&(cwmp->mutex_session_queue));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
paramater_container = cwmp_add_parameter_container (cwmp,event_container, "InternetGatewayDevice.ManagementServer.URL");
cwmp_save_event_container (cwmp,event_container);
save_acs_bkp_config (cwmp);
cwmp_scheduleInform_remove_all();
cwmp_scheduledDownload_remove_all();
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
return CWMP_OK;
}
int cwmp_root_cause_TransferComplete (struct cwmp *cwmp)
{
struct event_container *event_container;
struct session *session;
struct rpc_acs *rpc_acs;
struct _cwmp1__TransferComplete *p;
pthread_mutex_lock (&(cwmp->mutex_session_queue));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_7TRANSFER_COMPLETE, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
session = list_entry (cwmp->head_event_container, struct session,head_event_container);
if((rpc_acs = cwmp_add_session_rpc_acs_transferComplete (session)) == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
p = (struct _cwmp1__TransferComplete *) rpc_acs->method_data;
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_M_Download, p->CommandKey);
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_OK;
}
int cwmp_root_cause_getRPCMethod (struct cwmp *cwmp)
{
char acsurl[256];
int error,cmp=0;
struct event_container *event_container;
struct session *session;
if (cwmp->env.periodic == CWMP_START_PERIODIC)
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
cwmp->env.periodic = 0;
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_2PERIODIC, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
cwmp_save_event_container (cwmp,event_container);
session = list_entry (cwmp->head_event_container, struct session,head_event_container);
if(cwmp_add_session_rpc_acs_getRPCMethods (session) == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
return CWMP_OK;
}
int cwmp_root_cause_event_iccu_value_change (struct cwmp *cwmp)
{
struct event_container *event_container;
if (cwmp->env.iccu == CWMP_START_ICCU)
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
cwmp->env.iccu = 0;
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
cwmp_add_parameter_container (cwmp, event_container, "InternetGatewayDevice.ManagementServer.ConnectionRequestURL");
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
return CWMP_OK;
}
int cwmp_root_cause_event_api_value_change(struct cwmp *cwmp, struct session *session)
{
struct event_container *event_container;
struct list_head *ilist;
if (cwmp->api_value_change.parameter_list.next != &(cwmp->api_value_change.parameter_list))
{
pthread_mutex_lock (&(cwmp->mutex_session_queue));
pthread_mutex_lock (&(cwmp->api_value_change.mutex));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_4VALUE_CHANGE, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->api_value_change.mutex));
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
return CWMP_MEM_ERR;
}
__list_for_each(ilist,&(cwmp->api_value_change.parameter_list))
{
struct handler_ParameterValueStruct *handler_ParameterValueStruct;
handler_ParameterValueStruct = list_entry(ilist,struct handler_ParameterValueStruct,list);
cwmp_add_parameter_container (cwmp, event_container, handler_ParameterValueStruct->ParameterValueStruct->Name);
ilist = ilist->prev;
list_del(&(handler_ParameterValueStruct->list));
free (handler_ParameterValueStruct->ParameterValueStruct->Name);
free (handler_ParameterValueStruct->ParameterValueStruct);
free (handler_ParameterValueStruct);
}
cwmp->api_value_change.parameter_size = 0;
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->api_value_change.mutex));
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
}
return CWMP_OK;
}
void *thread_event_periodic (void *v)
{
struct cwmp *cwmp = (struct cwmp *) v;
struct event_container *event_container;
static int periodic_interval;
static bool periodic_enable;
static struct timespec periodic_timeout = {0, 0};
periodic_interval = cwmp->conf.period;
periodic_enable = cwmp->conf.periodic_enable;
for(;;)
{
pthread_mutex_lock (&(cwmp->mutex_periodic));
periodic_timeout.tv_sec = time(NULL) + periodic_interval;
if (cwmp->conf.periodic_enable)
{
pthread_cond_timedwait(&(cwmp->threshold_periodic), &(cwmp->mutex_periodic), &periodic_timeout);
}
else
{
pthread_cond_wait(&(cwmp->threshold_periodic), &(cwmp->mutex_periodic));
}
pthread_mutex_unlock (&(cwmp->mutex_periodic));
if (periodic_interval != cwmp->conf.period || periodic_enable != cwmp->conf.periodic_enable)
{
periodic_enable = cwmp->conf.periodic_enable;
periodic_interval = cwmp->conf.period;
continue;
}
CWMP_LOG(INFO,"Periodic thread: add periodic event in the queue");
pthread_mutex_lock (&(cwmp->mutex_session_queue));
event_container = cwmp_add_event_container (cwmp, EVENT_IDX_2PERIODIC, "");
if (event_container == NULL)
{
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
continue;
}
cwmp_save_event_container (cwmp,event_container);
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
pthread_cond_signal(&(cwmp->threshold_session_send));
}
return CWMP_OK;
}
int cwmp_root_cause_event_periodic (struct cwmp *cwmp)
{
static int period = 0;
static bool periodic_enable = FALSE;
if (period==cwmp->conf.period && periodic_enable==cwmp->conf.periodic_enable)
{
return CWMP_OK;
}
period = cwmp->conf.period;
periodic_enable = cwmp->conf.periodic_enable;
CWMP_LOG(INFO,periodic_enable?"Periodic event is enabled. Interval period = %ds":"Periodic event is disabled", period);
pthread_cond_signal(&(cwmp->threshold_periodic));
return CWMP_OK;
}
int cwmp_root_cause_events (struct cwmp *cwmp)
{
int error;
if (error = cwmp_root_cause_event_bootstrap(cwmp))
{
return error;
}
if (error = cwmp_root_cause_event_boot(cwmp))
{
return error;
}
if (error = cwmp_root_cause_event_iccu_value_change(cwmp))
{
return error;
}
if (error = cwmp_root_cause_getRPCMethod(cwmp))
{
return error;
}
if (error = cwmp_root_cause_event_periodic(cwmp))
{
return error;
}
return CWMP_OK;
}

710
src/httpda.c Normal file
View file

@ -0,0 +1,710 @@
/*
httpda.c
gSOAP HTTP Digest Authentication plugin.
Supports both Basic and Digest authentication.
gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------
*/
#include "httpda.h"
#ifdef __cplusplus
extern "C" {
#endif
const char http_da_id[12] = HTTP_DA_ID;
/* session database and lock */
static struct http_da_session *http_da_session = NULL;
static MUTEX_TYPE http_da_session_lock;
#define HTTP_DA_NONCELEN 21
#define HTTP_DA_OPAQUELEN 9
/******************************************************************************\
*
* Forward decls
*
\******************************************************************************/
static int http_da_init(struct soap *soap, struct http_da_data *data);
static int http_da_copy(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src);
static void http_da_delete(struct soap *soap, struct soap_plugin *p);
static int http_da_post_header(struct soap *soap, const char *key, const char *val);
static int http_da_parse_header(struct soap *soap, const char *key, const char *val);
static int http_da_prepareinit(struct soap *soap);
static int http_da_preparesend(struct soap *soap, const char *buf, size_t len);
static int http_da_preparerecv(struct soap *soap, const char *buf, size_t len);
static int http_da_disconnect(struct soap *soap);
static int http_da_verify_method(struct soap *soap, char *method, char *passwd);
static void http_da_session_start(const char *realm, const char *nonce, const char *opaque);
static int http_da_session_update(const char *realm, const char *nonce, const char *opaque, const char *cnonce, const char *ncount);
static void http_da_session_cleanup();
void http_da_calc_nonce(struct soap *soap, char nonce[HTTP_DA_NONCELEN]);
void http_da_calc_opaque(struct soap *soap, char opaque[HTTP_DA_OPAQUELEN]);
static void http_da_calc_HA1(struct soap *soap, void **context, char *alg, char *userid, char *realm, char *passwd, char *nonce, char *cnonce, char HA1hex[33]);
static void http_da_calc_response(struct soap *soap, void **context, char HA1hex[33], char *nonce, char *ncount, char *cnonce, char *qop, char *method, char *uri, char entityHAhex[33], char response[33]);
/******************************************************************************\
*
* Plugin registry
*
\******************************************************************************/
int http_da(struct soap *soap, struct soap_plugin *p, void *arg)
{
p->id = http_da_id;
p->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_da_data));
p->fcopy = http_da_copy;
p->fdelete = http_da_delete;
if (p->data)
{
if (http_da_init(soap, (struct http_da_data*)p->data))
{
SOAP_FREE(soap, p->data);
return SOAP_EOM;
}
}
return SOAP_OK;
}
static int http_da_init(struct soap *soap, struct http_da_data *data)
{
data->fposthdr = soap->fposthdr;
soap->fposthdr = http_da_post_header;
data->fparsehdr = soap->fparsehdr;
soap->fparsehdr = http_da_parse_header;
data->fprepareinit = soap->fprepareinit;
soap->fprepareinit = http_da_prepareinit;
data->context = NULL;
memset(data->digest, 0, sizeof(data->digest));
return SOAP_OK;
}
static int http_da_copy(struct soap *soap, struct soap_plugin *dst, struct soap_plugin *src)
{
*dst = *src;
dst->data = (void*)SOAP_MALLOC(soap, sizeof(struct http_da_data));
memcpy(dst->data, src->data, sizeof(struct http_da_data));
((struct http_da_data*)dst->data)->context = NULL;
memset(((struct http_da_data*)dst->data)->digest, 0, sizeof(((struct http_da_data*)dst->data)->digest));
((struct http_da_data*)dst->data)->nonce = NULL;
((struct http_da_data*)dst->data)->opaque = NULL;
((struct http_da_data*)dst->data)->qop = NULL;
((struct http_da_data*)dst->data)->alg = NULL;
((struct http_da_data*)dst->data)->nc = 0;
((struct http_da_data*)dst->data)->ncount = NULL;
((struct http_da_data*)dst->data)->cnonce = NULL;
((struct http_da_data*)dst->data)->response = NULL;
return SOAP_OK;
}
static void http_da_delete(struct soap *soap, struct soap_plugin *p)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (data)
{
if (data->context)
md5_handler(soap, &data->context, MD5_DELETE, NULL, 0);
SOAP_FREE(soap, data);
}
}
/******************************************************************************\
*
* Callbacks
*
\******************************************************************************/
static int http_da_post_header(struct soap *soap, const char *key, const char *val)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
/* client's HTTP Authorization response */
if (key && !strcmp(key, "Authorization"))
{
char HA1[33], entityHAhex[33], response[33];
char cnonce[HTTP_DA_NONCELEN];
char ncount[9];
char *qop, *method;
md5_handler(soap, &data->context, MD5_FINAL, data->digest, 0);
http_da_calc_nonce(soap, cnonce);
http_da_calc_HA1(soap, &data->context, data->alg, soap->userid, soap->authrealm, soap->passwd, data->nonce, cnonce, HA1);
if (data->qop && !soap_tag_cmp(data->qop, "*auth-int*"))
{
qop = "auth-int";
soap_s2hex(soap, (unsigned char*)data->digest, entityHAhex, 16);
}
else if (data->qop)
qop = "auth";
else
qop = NULL;
if (soap->status == SOAP_GET)
method = "GET";
else
method = "POST";
sprintf(ncount, "%8.8lx", data->nc++);
http_da_calc_response(soap, &data->context, HA1, data->nonce, ncount, cnonce, qop, method, soap->path, entityHAhex, response);
sprintf(soap->tmpbuf, "Digest realm=\"%s\", username=\"%s\", nonce=\"%s\", uri=\"%s\", nc=%s, cnonce=\"%s\", response=\"%s\"", soap->authrealm, soap->userid, data->nonce, soap->path, ncount, cnonce, response);
if (data->opaque)
sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ", opaque=\"%s\"", data->opaque);
if (qop)
sprintf(soap->tmpbuf + strlen(soap->tmpbuf), ", qop=\"%s\"", qop);
return data->fposthdr(soap, key, soap->tmpbuf);
}
/* server's HTTP Authorization response */
if (key && !strcmp(key, "WWW-Authenticate"))
{
char nonce[HTTP_DA_NONCELEN];
char opaque[HTTP_DA_OPAQUELEN];
http_da_calc_nonce(soap, nonce);
http_da_calc_opaque(soap, opaque);
http_da_session_start(soap->authrealm, nonce, opaque);
sprintf(soap->tmpbuf, "Digest realm=\"%s\", qop=\"auth,auth-int\", nonce=\"%s\", opaque=\"%s\"", soap->authrealm, nonce, opaque);
return data->fposthdr(soap, key, soap->tmpbuf);
}
return data->fposthdr(soap, key, val);
}
static int http_da_parse_header(struct soap *soap, const char *key, const char *val)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
/* check if server received Authorization Digest HTTP header from client */
if (!soap_tag_cmp(key, "Authorization") && !soap_tag_cmp(val, "Digest *"))
{
soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "realm"));
soap->userid = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "username"));
soap->passwd = NULL;
data->nonce = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "nonce"));
data->opaque = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "opaque"));
data->qop = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "qop"));
data->alg = NULL;
data->ncount = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "nc"));
data->cnonce = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "cnonce"));
data->response = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "response"));
if (data->qop && !soap_tag_cmp(data->qop, "auth-int"))
{
if (soap->fpreparerecv != http_da_preparerecv)
{
data->fpreparerecv = soap->fpreparerecv;
soap->fpreparerecv = http_da_preparerecv;
}
if (soap->fdisconnect != http_da_disconnect)
{
data->fdisconnect = soap->fdisconnect;
soap->fdisconnect = http_da_disconnect;
}
md5_handler(soap, &data->context, MD5_INIT, NULL, 0);
}
return SOAP_OK;
}
/* check if client received WWW-Authenticate Digest HTTP header from server */
if (!soap_tag_cmp(key, "WWW-Authenticate") && !soap_tag_cmp(val, "Digest *"))
{
soap->authrealm = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "realm"));
data->nonce = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "nonce"));
data->opaque = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "opaque"));
data->qop = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "qop"));
data->alg = soap_strdup(soap, soap_get_header_attribute(soap, val + 7, "algorithm"));
data->nc = 1;
data->ncount = NULL;
data->cnonce = NULL;
data->response = NULL;
return SOAP_OK;
}
return data->fparsehdr(soap, key, val);
}
static int http_da_prepareinit(struct soap *soap)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && (soap->mode & (SOAP_ENC_DIME | SOAP_ENC_MIME)))
{ /* TODO: handle attachments automatically, does not work yet */
soap->mode &= ~SOAP_IO;
soap->mode |= SOAP_IO_STORE;
}
else
{
if (soap->fpreparerecv == http_da_preparerecv)
soap->fpreparerecv = data->fpreparerecv;
if (soap->fdisconnect == http_da_disconnect)
soap->fdisconnect = data->fdisconnect;
if (soap->userid && soap->passwd)
{
md5_handler(soap, &data->context, MD5_INIT, NULL, 0);
if (soap->fpreparesend != http_da_preparesend)
{
data->fpreparesend = soap->fpreparesend;
soap->fpreparesend = http_da_preparesend;
}
}
if (data->fprepareinit)
return data->fprepareinit(soap);
}
return SOAP_OK;
}
static int http_da_preparesend(struct soap *soap, const char *buf, size_t len)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
md5_handler(soap, &data->context, MD5_UPDATE, (char*)buf, len);
if (data->fpreparesend)
return data->fpreparesend(soap, buf, len);
return SOAP_OK;
}
static int http_da_preparerecv(struct soap *soap, const char *buf, size_t len)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
md5_handler(soap, &data->context, MD5_UPDATE, (char*)buf, len);
if (data->fpreparerecv)
return data->fpreparerecv(soap, buf, len);
return SOAP_OK;
}
static int http_da_disconnect(struct soap *soap)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return SOAP_PLUGIN_ERROR;
md5_handler(soap, &data->context, MD5_FINAL, data->digest, 0);
soap->fpreparerecv = data->fpreparerecv;
soap->fdisconnect = data->fdisconnect;
if (soap->fdisconnect)
return soap->fdisconnect(soap);
return SOAP_OK;
}
/******************************************************************************\
*
* Client-side digest authentication state management
*
\******************************************************************************/
void http_da_save(struct soap *soap, struct http_da_info *info, const char *realm, const char *userid, const char *passwd)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return;
info->authrealm = soap->authrealm = soap_strdup(NULL, realm);
info->userid = soap->userid = soap_strdup(NULL, userid);
info->passwd = soap->passwd = soap_strdup(NULL, passwd);
info->nonce = soap_strdup(NULL, data->nonce);
info->opaque = soap_strdup(NULL, data->opaque);
info->qop = soap_strdup(NULL, data->qop);
info->alg = soap_strdup(NULL, data->alg);
}
void http_da_restore(struct soap *soap, struct http_da_info *info)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return;
soap->authrealm = info->authrealm;
soap->userid = info->userid;
soap->passwd = info->passwd;
data->nonce = info->nonce;
data->opaque = info->opaque;
data->qop = info->qop;
data->alg = info->alg;
}
void http_da_release(struct soap *soap, struct http_da_info *info)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
if (!data)
return;
soap->authrealm = NULL;
soap->userid = NULL;
soap->passwd = NULL;
data->nonce = NULL;
data->opaque = NULL;
data->qop = NULL;
data->alg = NULL;
if (info->authrealm)
{
free(info->authrealm);
info->authrealm = NULL;
}
if (info->userid)
{
free(info->userid);
info->userid = NULL;
}
if (info->passwd)
{
free(info->passwd);
info->passwd = NULL;
}
if (info->nonce)
{
free(info->nonce);
info->nonce = NULL;
}
if (info->opaque)
{
free(info->opaque);
info->opaque = NULL;
}
if (info->qop)
{
free(info->qop);
info->qop = NULL;
}
if (info->alg)
{
free(info->alg);
info->alg = NULL;
}
}
/******************************************************************************\
*
* Server-side digest authentication verification
*
\******************************************************************************/
int http_da_verify_post(struct soap *soap, char *passwd)
{
return http_da_verify_method(soap, "POST", passwd);
}
int http_da_verify_get(struct soap *soap, char *passwd)
{
return http_da_verify_method(soap, "GET", passwd);
}
static int http_da_verify_method(struct soap *soap, char *method, char *passwd)
{
struct http_da_data *data = (struct http_da_data*)soap_lookup_plugin(soap, http_da_id);
char HA1[33], entityHAhex[33], response[33];
if (!data)
return SOAP_ERR;
/* reject if none or basic authentication was used */
if (!soap->authrealm
|| !soap->userid
|| soap->passwd) /* passwd is set when basic auth is used */
return SOAP_ERR;
/* require at least qop="auth" to prevent replay attacks */
if (!data->qop)
return SOAP_ERR;
if (http_da_session_update(soap->authrealm, data->nonce, data->opaque, data->cnonce, data->ncount))
return SOAP_ERR;
http_da_calc_HA1(soap, &data->context, NULL, soap->userid, soap->authrealm, passwd, data->nonce, data->cnonce, HA1);
if (!soap_tag_cmp(data->qop, "auth-int"))
soap_s2hex(soap, (unsigned char*)data->digest, entityHAhex, 16);
http_da_calc_response(soap, &data->context, HA1, data->nonce, data->ncount, data->cnonce, data->qop, method, soap->path, entityHAhex, response);
#ifdef SOAP_DEBUG
fprintf(stderr, "Debug message: verifying client response=%s with calculated digest=%s\n", data->response, response);
#endif
/* check digest response values */
if (strcmp(data->response, response))
return SOAP_ERR;
return SOAP_OK;
}
/******************************************************************************\
*
* Digest authentication session database management
*
\******************************************************************************/
static void http_da_session_start(const char *realm, const char *nonce, const char *opaque)
{
struct http_da_session *session;
time_t now = time(NULL);
if (now % 10 == 0) /* don't do this all the time to improve efficiency */
http_da_session_cleanup();
#ifdef SOAP_DEBUG
fprintf(stderr, "Starting session realm=%s nonce=%s\n", realm, nonce);
#endif
MUTEX_LOCK(http_da_session_lock);
session = (struct http_da_session*)malloc(sizeof(struct http_da_session));
if (session)
{
session->next = http_da_session;
session->modified = now;
session->realm = soap_strdup(NULL, realm);
session->nonce = soap_strdup(NULL, nonce);
session->opaque = soap_strdup(NULL, opaque);
session->nc = 0;
http_da_session = session;
}
MUTEX_UNLOCK(http_da_session_lock);
}
static int http_da_session_update(const char *realm, const char *nonce, const char *opaque, const char *cnonce, const char *ncount)
{
struct http_da_session *session;
if (!realm || !nonce || !opaque || !cnonce || !ncount)
return SOAP_ERR;
#ifdef SOAP_DEBUG
fprintf(stderr, "Debug message: updating session realm=%s nonce=%s\n", realm, nonce);
#endif
MUTEX_LOCK(http_da_session_lock);
for (session = http_da_session; session; session = session->next)
if (!strcmp(session->realm, realm) && !strcmp(session->nonce, nonce) && !strcmp(session->opaque, opaque))
break;
if (session)
{
unsigned long nc = soap_strtoul(ncount, NULL, 16);
if (session->nc >= nc)
{
session->modified = 0; /* replay attack: terminate session */
session = NULL;
}
else
{
session->nc = nc;
session->modified = time(NULL);
}
}
MUTEX_UNLOCK(http_da_session_lock);
if (!session)
return SOAP_ERR;
return SOAP_OK;
}
static void http_da_session_cleanup()
{
struct http_da_session **session;
time_t now = time(NULL);
MUTEX_LOCK(http_da_session_lock);
session = &http_da_session;
while (*session)
{
if ((*session)->modified + HTTP_DA_SESSION_TIMEOUT < now)
{
struct http_da_session *p = *session;
#ifdef SOAP_DEBUG
fprintf(stderr, "Deleting session realm=%s nonce=%s\n", p->realm, p->nonce);
#endif
if (p->realm)
free(p->realm);
if (p->nonce)
free(p->nonce);
if (p->opaque)
free(p->opaque);
*session = p->next;
free(p);
}
else
session = &(*session)->next;
}
MUTEX_UNLOCK(http_da_session_lock);
}
/******************************************************************************\
*
* Calculate hex nonce and opaque values
*
\******************************************************************************/
void http_da_calc_nonce(struct soap *soap, char nonce[HTTP_DA_NONCELEN])
{
static short count = 0xCA53;
sprintf(nonce, "%8.8x%4.4hx%8.8x", (int)time(NULL), count++, soap_random);
}
void http_da_calc_opaque(struct soap *soap, char opaque[HTTP_DA_OPAQUELEN])
{
sprintf(opaque, "%8.8x", soap_random);
}
/******************************************************************************\
*
* Calculate HA1, HA2, and response digest as per RFC 2617 specification
*
\******************************************************************************/
static void http_da_calc_HA1(struct soap *soap, void **context, char *alg, char *userid, char *realm, char *passwd, char *nonce, char *cnonce, char HA1hex[33])
{
char HA1[16];
md5_handler(soap, context, MD5_INIT, NULL, 0);
md5_handler(soap, context, MD5_UPDATE, userid, strlen(userid));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, realm, strlen(realm));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, passwd, strlen(passwd));
md5_handler(soap, context, MD5_FINAL, HA1, 0);
if (alg && !soap_tag_cmp(alg, "MD5-sess"))
{
md5_handler(soap, context, MD5_INIT, NULL, 0);
md5_handler(soap, context, MD5_UPDATE, HA1, 16);
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, nonce, strlen(nonce));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, cnonce, strlen(cnonce));
md5_handler(soap, context, MD5_FINAL, HA1, 0);
};
soap_s2hex(soap, (unsigned char*)HA1, HA1hex, 16);
};
static void http_da_calc_response(struct soap *soap, void **context, char HA1hex[33], char *nonce, char *ncount, char *cnonce, char *qop, char *method, char *uri, char entityHAhex[33], char response[33])
{
char HA2[16], HA2hex[33], responseHA[16];
md5_handler(soap, context, MD5_INIT, NULL, 0);
md5_handler(soap, context, MD5_UPDATE, method, strlen(method));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, uri, strlen(uri));
if (!soap_tag_cmp(qop, "auth-int"))
{
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, entityHAhex, 32);
}
md5_handler(soap, context, MD5_FINAL, HA2, 0);
soap_s2hex(soap, (unsigned char*)HA2, HA2hex, 16);
md5_handler(soap, context, MD5_INIT, NULL, 0);
md5_handler(soap, context, MD5_UPDATE, HA1hex, 32);
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, nonce, strlen(nonce));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
if (qop && *qop)
{
md5_handler(soap, context, MD5_UPDATE, ncount, strlen(ncount));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, cnonce, strlen(cnonce));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
md5_handler(soap, context, MD5_UPDATE, qop, strlen(qop));
md5_handler(soap, context, MD5_UPDATE, ":", 1);
}
md5_handler(soap, context, MD5_UPDATE, HA2hex, 32);
md5_handler(soap, context, MD5_FINAL, responseHA, 0);
soap_s2hex(soap, (unsigned char*)responseHA, response, 16);
}
#ifdef __cplusplus
}
#endif

34
src/inc/backupSession.h Normal file
View file

@ -0,0 +1,34 @@
/*
backupSession.h
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#define RPC_NO_STATUS -1
#define RPC_QUEUE 0
#define RPC_SEND 1
typedef struct attribute
{
long int id;
char *name;
char *status;
char *commandKey;
char *url;
} attribute;
typedef enum backup_loading {
ALL,
ACS
} backup_loading;

1258
src/inc/cwmp-1-1.h Normal file

File diff suppressed because it is too large Load diff

348
src/inc/cwmp.h Normal file
View file

@ -0,0 +1,348 @@
/*
cwmp.h
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include "soapH.h"
#include "list.h"
#define DEFAULT_LOG_FILE_SIZE 10240
#define DEFAULT_LOG_FILE_NAME "/var/log/cwmpd.log"
#define EMERG 0
#define ALERT 1
#define CRITIC 2
#define ERROR 3
#define WARNING 4
#define NOTICE 5
#define INFO 6
#define DEBUG 7
#define EVENT_RETRY_AFTER_TRANSMIT_FAIL 0x1
#define EVENT_RETRY_AFTER_REBOOT 0x2
#define EVENT_RETRY_AFTER_BOOTSTRAP 0x4
#define EVENT_TYPE_SINGLE 0x0
#define EVENT_TYPE_MULTIPLE 0x1
#define EVENT_IDX_0BOOTSTRAP 0
#define EVENT_IDX_1BOOT 1
#define EVENT_IDX_2PERIODIC 2
#define EVENT_IDX_3SCHEDULED 3
#define EVENT_IDX_4VALUE_CHANGE 4
#define EVENT_IDX_5KICKED 5
#define EVENT_IDX_6CONNECTION_REQUEST 6
#define EVENT_IDX_7TRANSFER_COMPLETE 7
#define EVENT_IDX_8DIAGNOSTICS_COMPLETE 8
#define EVENT_IDX_9REQUEST_DOWNLOAD 9
#define EVENT_IDX_10AUTONOMOUS_TRANSFER_COMPLETE 10
#define EVENT_IDX_M_Reboot 11
#define EVENT_IDX_M_ScheduleInform 12
#define EVENT_IDX_M_Download 13
#define EVENT_IDX_M_Upload 14
#define MAX_SIZE_RPC_METHODS_RESPONSE 14
#define MAX_INT32 2147483646
#define MAX_INT_ID MAX_INT32
#define MIN_INT_ID 836464
#define PERIOD_INFORM_MIN 100
#define PERIOD_INFORM_DEFAULT 86400
#define CONNECTION_REQUEST_RESTRICT_PERIOD 10
#define CONNECTION_REQUEST_RESTRICT_REQUEST 5
#define RPC_ACS_INFORM_IDX 1
#define RPC_ACS_GETRPCMETHODS_IDX 2
#define RPC_ACS_TRANSFERCOMPLETE_IDX 3
#define FAULT_CPE_ARRAY_SIZE 21
#define FAULT_CPE_NO_FAULT_IDX 0
#define FAULT_CPE_METHOD_NOT_SUPPORTED_IDX 1
#define FAULT_CPE_REQUEST_DENIED_IDX 2
#define FAULT_CPE_INTERNAL_ERROR_IDX 3
#define FAULT_CPE_INVALID_ARGUMENTS_IDX 4
#define FAULT_CPE_RESOURCES_EXCEEDED_IDX 5
#define FAULT_CPE_INVALID_PARAMETER_NAME_IDX 6
#define FAULT_CPE_INVALID_PARAMETER_TYPE_IDX 7
#define FAULT_CPE_INVALID_PARAMETER_VALUE_IDX 8
#define FAULT_CPE_NON_WRITABLE_PARAMETER_IDX 9
#define FAULT_CPE_NOTIFICATION_REJECTED_IDX 10
#define FAULT_CPE_DOWNLOAD_FAILURE_IDX 11
#define FAULT_CPE_UPLOAD_FAILURE_IDX 12
#define FAULT_CPE_FILE_TRANSFER_AUTHENTICATION_FAILURE_IDX 13
#define FAULT_CPE_FILE_TRANSFER_UNSUPPORTED_PROTOCOL_IDX 14
#define FAULT_CPE_DOWNLOAD_FAIL_MULTICAST_GROUP_IDX 15
#define FAULT_CPE_DOWNLOAD_FAIL_CONTACT_SERVER_IDX 16
#define FAULT_CPE_DOWNLOAD_FAIL_ACCESS_FILE_IDX 17
#define FAULT_CPE_DOWNLOAD_FAIL_COMPLETE_DOWNLOAD_IDX 18
#define FAULT_CPE_DOWNLOAD_FAIL_FILE_CORRUPTED_IDX 19
#define FAULT_CPE_DOWNLOAD_FAIL_FILE_AUTHENTICATION_IDX 20
#define CWMP_START_BOOT 1
#define CWMP_START_PERIODIC 2
#define CWMP_START_ICCU 3
#define CWMP_OK 0 /* No Error */
#define CWMP_GEN_ERR 1 /* General Error */
#define CWMP_MEM_ERR 2 /* Memory Error */
#define CWMP_OWF_ERR 3 /* Open Writing File Error */
#define CWMP_ORF_ERR 4 /* Open Reading File Error */
#define CWMP_MUTEX_ERR 5
#define CWMP_FAIL_RPC 6
#define CWMP_RETRY_RPC 7
#define CWMP_SUCCESS_RPC 8
#define CWMP_UNAUTHORIZED_401 9
#define CWMP_GET_RETRY_8005 10
#define CWMP_RETRY_SESSION 11
#define CWMP_CONTINUE_SESSION 12
#define CWMP_SUCCESS_SESSION 13
#define CWMP_FAULT_CPE 14
#define CWMP_EXACT_FOUND 15
#define CWMP_CHILD_FOUND 16
#define CWMP_PARENT_FOUND 17
#define MAX_EVENTS 64
#define SOAP_TIMEOUT 30
#define DEFAULT_ACSURL "http://192.168.1.1:8080/openacs/acs"
#define DEFAULT_CONNECTION_REQUEST_PORT 7547
#define COUNT_RPC_CPE 17
#define COUNT_EVENT 15
#define COUNT_ACCESSLIST 1
#define DOWNLOADED_CONFIG_FILE "/tmp/configuration.cfg"
#define DOWNLOADED_FIRMWARE_FILE "/tmp/firmware.img"
#define DOWNLOADED_LAST_VALID_FIRMWARE_FILE "/tmp/valid_firmware.img"
#define DOWNLOADED_WEBCONTENT_FILE "/tmp/webcontent.ipk"
#define UCI_DM_XML_FILE_LIST "cwmp.dm.xml"
#define UCI_DHCP_DISCOVERY_PATH "cwmp.acs.dhcp_discovery"
#define UCI_DHCP_ACS_URL_PATH "provisioning.iup.tr069url"
#define UCI_STATE_CONNECTION_REQUEST_URL_PATH "cwmp.acs.cr_url"
#define UCI_ACS_URL_PATH "cwmp.acs.url"
#define UCI_PERIODIC_INFORM_INTERVAL_PATH "cwmp.acs.periodic_inform_interval"
#define UCI_PERIODIC_INFORM_ENABLE_PATH "cwmp.acs.periodic_inform_enable"
#define UCI_ACS_USERID_PATH "cwmp.acs.userid"
#define UCI_ACS_PASSWD_PATH "cwmp.acs.passwd"
#define UCI_ACS_PARAMETERKEY_PATH "cwmp.acs.ParameterKey"
#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"
#define UCI_CPE_PORT_PATH "cwmp.cpe.port"
#define UCI_NOTIFICATION_PASSIVE_PATH "cwmp.notification.passive"
#define UCI_NOTIFICATION_ACTIVE_PATH "cwmp.notification.active"
#define UCI_NOTIFICATION_DENIED_PATH "cwmp.notification.deny"
#define UCI_CPE_LOG_FILE_NAME "cwmp.cpe.log_file_name"
#define UCI_CPE_LOG_MAX_SIZE "cwmp.cpe.log_max_size"
#define UCI_CPE_ENABLE_STDOUT_LOG "cwmp.cpe.log_to_console"
#define UCI_CPE_ENABLE_FILE_LOG "cwmp.cpe.log_to_file"
#define UCI_TRACK_CONF "ucitrack"
#define UCI_TRACK_INIT "init"
#define UCI_TRACK_AFFECTS "affects"
#define UCI_TRACK_CONF_CWMP "cwmp"
#define FIRMWARE_FILE_TYPE "1 Firmware Upgrade Image"
#define WEB_CONTENT_FILE_TYPE "2 Web Content"
#define CONFIGURATION_FILE_TYPE "3 Vendor Configuration File"
#define DOWNLOAD_PROTOCOL_HTTP "http://"
#define DOWNLOAD_PROTOCOL_FTP "ftp://"
#define MAX_DOWNLOAD_QUEUE 10
#define ENABLE_CHECK_SIZE 0x0
#define DISABLE_CHECK_SIZE 0x1
#define ENCODING_STYLE_URL "http://schemas.xmlsoap.org/soap/encoding/"
typedef enum bool {
FALSE,
TRUE
} bool;
typedef struct config {
char *acsurl;
char *confFile;
char *acs_userid;
char *acs_passwd;
char *cpe_userid;
char *cpe_passwd;
int connection_request_port;
int period;
bool periodic_enable;
} config;
typedef struct env {
unsigned short boot;
unsigned short periodic;
unsigned short iccu;
long int max_firmware_size;
} env;
typedef struct api_value_change {
struct list_head parameter_list;
int parameter_size;
pthread_mutex_t mutex;
} api_value_change;
typedef struct cwmp {
struct env env;
struct config conf;
struct list_head head_session_queue;
pthread_mutex_t mutex_session_queue;
struct session *session_send;
pthread_mutex_t mutex_session_send;
pthread_cond_t threshold_session_send;
pthread_mutex_t mutex_periodic;
pthread_cond_t threshold_periodic;
int retry_count_session;
struct list_head *head_event_container;
struct api_value_change api_value_change;
int error;
} cwmp;
typedef struct session {
struct list_head list;
char acs_url[256];
struct list_head head_event_container;
int event_size;
int parameter_size;
unsigned int single_event_flag;
struct list_head head_rpc_cpe;
struct list_head head_rpc_acs;
struct list_head head_session_end_func;
struct soap soap;
bool hold_request;
bool digest_auth;
int error;
} session;
typedef struct session_end_func {
struct list_head list;
int (*func)(struct cwmp *cwmp, void *input);
void *input;
} session_end_func;
typedef struct event_container {
struct list_head list;
struct cwmp1__EventStruct event;
struct list_head head_paramater_container;
int id;
int idx;
} event_container;
typedef struct paramater_container {
struct list_head list;
struct cwmp1__ParameterValueStruct paramater;
} paramater_container;
typedef struct soap_cwmp1_methods__rpc
{
void (*soap_serialize_cwmp1__send_data)(struct soap *soap, void *data);
int (*soap_put_cwmp1__send_data)(struct soap *soap, void *data, char *envelope, char *action);
void *(*soap_get_cwmp1__rpc_received_data)(struct soap *, void *data, char *envelope_response, char *action);
char *envelope;
char *envelope_response;
} soap_cwmp1_methods__rpc;
typedef struct fault
{
int code_idx;
char *parameter_cause;
} fault;
typedef struct rpc_acs {
struct list_head list;
void *method_data;
int (*method_data_init)(struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int (*method_remote_call)(struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
void *method_response_data;
int (*method_response)(struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int (*method_end)(struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
int (*destructor)(struct cwmp *cwmp, struct session *session, struct rpc_acs *this);
struct soap_cwmp1_methods__rpc soap_methods;
struct fault fault;
int type;
int error;
} rpc_acs;
typedef struct rpc_cpe {
struct list_head list;
void *method_data;
int (*method)(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
void *method_response_data;
int (*method_response_data_init)(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int (*method_response)(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int (*method_end)(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
int (*destructor)(struct cwmp *cwmp, struct session *session, struct rpc_cpe *this);
struct soap_cwmp1_methods__rpc soap_methods;
struct fault fault;
int error;
} rpc_cpe;
typedef struct CPE_METHOD_CONSTRUCTORS
{
char *METHOD;
struct rpc_cpe *(*CONSTRUCTOR)(struct session *session);
} CPE_METHOD_CONSTRUCTORS;
typedef struct FAULT_CPE
{
char *CODE;
int TYPE;
char *DESCRIPTION;
} FAULT_CPE;
typedef struct EVENT_CONST_STRUCT
{
char *CODE;
unsigned int TYPE;
unsigned short RETRY;
} EVENT_CONST_STRUCT;
typedef struct schedule_inform {
struct list_head list;
time_t scheduled_time;
char *commandKey;
} schedule_inform;
typedef struct download {
struct list_head list;
time_t scheduled_time;
char *CommandKey;
char *FileType;
char *URL;
char *Username;
char *Password;
} download;
struct download_end_func {
int (*func)(struct cwmp *cwmp, void *input);
void *input;
};
#define sizearray(a) (sizeof(a) / sizeof((a)[0]))
typedef struct config_uci_list {
struct list_head list;
char *value;
} config_uci_list;
typedef struct ACCESSLIST_CONST_STRUCT
{
char *NAME;
char *UCI_ACCESSLIST_PATH;
} ACCESSLIST_CONST_STRUCT;
#ifdef WITH_CWMP_DEBUG
# ifndef CWMP_LOG
# define CWMP_LOG(SEV,MESSAGE,args...) puts_log(SEV,MESSAGE,##args);
# endif
#else
# define CWMP_LOG(SEV,MESSAGE,args...)
#endif

11
src/inc/cwmpBinding.nsmap Normal file
View file

@ -0,0 +1,11 @@
#include "soapH.h"
SOAP_NMAC struct Namespace namespaces[] =
{
{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
{"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/", "http://www.w3.org/*/soap-encoding", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},
{"cwmp", "urn:dslforum-org:cwmp-1-0", "urn:dslforum-org:cwmp*", NULL},
{NULL, NULL, NULL, NULL}
};

8
src/inc/cwmp_kernel.h Normal file
View file

@ -0,0 +1,8 @@
#define NETLINK_MAX_PAYLOAD 1024
#define NETLINK_USER 31
#define NETLINK_CWMP_ID "NETLINK_CWMP_ID"
#define NETLINK_END_DATA "END_DATA"
#define NETLINK_NULL "NULL"
int kernel_api_cwmp_value_change_call (int count, ...);

6
src/inc/cwmp_lib.h Normal file
View file

@ -0,0 +1,6 @@
#define AF_UNIX_ADDRESS ".AF_UNIX_CWMP_ID"
#define AF_UNIX_END_DATA "END_DATA"
#define AF_UNIX_NULL "NULL"
int lib_api_cwmp_value_change_call (int count, ...);

227
src/inc/dm.h Normal file
View file

@ -0,0 +1,227 @@
/*
dm.h
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <linux/types.h>
#define DM_OK 0
#define DM_ERR 1
#define DM_GEN_ERR 2
#define DM_MEM_ERR 3
#define DM_ORF_ERR 4
#define NODE_PATH_SIZE 16
#define INDEX_PATH_SIZE 8
#define COUNT_TYPE_VALUES 44
#define SYSTEM_CMD_TIMEOUT 10
#define TYPE_VALUE_string_IDX 0
#define TYPE_VALUE_int_IDX 1
#define TYPE_VALUE_unsignedInt_IDX 2
#define TYPE_VALUE_boolean_IDX 3
#define TYPE_VALUE_dateTime_IDX 4
#define TYPE_VALUE_base64Binary_IDX 5
#define TYPE_VALUE_integer_IDX 6
#define TYPE_VALUE_unsignedByte_IDX 7
#define TYPE_VALUE_unsignedLong_IDX 8
#define TYPE_VALUE_unsignedShort_IDX 9
#define TYPE_VALUE_anyURI_IDX 10
#define TYPE_VALUE_byte_IDX 11
#define TYPE_VALUE_date_IDX 12
#define TYPE_VALUE_time_IDX 13
#define TYPE_VALUE_decimal_IDX 14
#define TYPE_VALUE_double_IDX 15
#define TYPE_VALUE_duration_IDX 16
#define TYPE_VALUE_ENTITIES_IDX 17
#define TYPE_VALUE_ENTITY_IDX 18
#define TYPE_VALUE_float_IDX 19
#define TYPE_VALUE_gDay_IDX 20
#define TYPE_VALUE_gMonth_IDX 21
#define TYPE_VALUE_gMonthDay_IDX 22
#define TYPE_VALUE_gYear_IDX 23
#define TYPE_VALUE_gYearMonth_IDX 24
#define TYPE_VALUE_hexBinary_IDX 25
#define TYPE_VALUE_ID_IDX 26
#define TYPE_VALUE_IDREF_IDX 27
#define TYPE_VALUE_IDREFS_IDX 28
#define TYPE_VALUE_language_IDX 29
#define TYPE_VALUE_long_IDX 30
#define TYPE_VALUE_Name_IDX 31
#define TYPE_VALUE_NCName_IDX 32
#define TYPE_VALUE_negativeInteger_IDX 33
#define TYPE_VALUE_NMTOKEN_IDX 34
#define TYPE_VALUE_NMTOKENS_IDX 35
#define TYPE_VALUE_nonNegativeInteger_IDX 36
#define TYPE_VALUE_nonPositiveInteger_IDX 37
#define TYPE_VALUE_normalizedString_IDX 38
#define TYPE_VALUE_NOTATION_IDX 39
#define TYPE_VALUE_positiveInteger_IDX 40
#define TYPE_VALUE_QName_IDX 41
#define TYPE_VALUE_short_IDX 42
#define TYPE_VALUE_token_IDX 43
typedef struct dm_notification {
__u8 can_deny :1;
__u8 force_enabled :1;
__u8 force_default_enabled :1;
} dm_notification;
typedef enum node_type {
DM_OBJECT,
DM_INSTANCE,
DM_PARAMETER
} node_type;
typedef enum param_type {
DM_SYSTEM,
DM_UCI,
DM_STRING,
DM_DEBUG,
DM_CORRESPONDENCE,
DM_DEFAULT_VALUE,
DM_REGEXP
} param_type;
typedef enum action_type {
DM_APPLY,
DM_GET,
DM_SET,
DM_CANCEL,
DM_ADD,
DM_DEL
} action_type;
typedef enum permission {
DM_READ,
DM_READ_WRITE,
DM_CREATE,
DM_PRESENT
} permission;
typedef struct dm_data {
unsigned short line_size;
unsigned short column_size;
char ***data;
} dm_data;
typedef struct dm_map {
unsigned short size;
char **map;
} dm_map;
typedef struct dm_uci {
__u8 reboot_required;
__u8 end_session;
char *cmd;
} dm_uci;
typedef struct dm_system {
__u8 type;
__u8 reboot_required;
__u8 end_session;
struct dm_map *dm_map;
char *cmd;
} dm_system;
typedef struct dm_correspondence {
struct dm_data *dm_data;
struct dm_map *dm_map;
} dm_correspondence;
typedef struct dm_debug {
char *data;
} dm_debug;
typedef struct data_handler {
enum param_type type;
void *handler;
} data_handler;
struct list_data_handler {
struct list_head list;
struct data_handler *data_handler;
} list_data_handler;
typedef struct dm_node {
struct list_head list;
char *name;
struct data_handler **data_handler;
__u8 type:4;
__u8 permission:4;
__u8 size_data_handler;
struct dm_notification active_notify;
/* the position of above parameters should be the same of struct dm_node_leaf*/
struct list_head head_child;
} dm_node;
typedef struct dm_node_leaf {
struct list_head list;
char *name;
struct data_handler **data_handler;
__u8 type:4;
__u8 permission:4;
__u8 size_data_handler;
struct dm_notification active_notify;
/* the position of above parameters should be the same of struct dm_node*/
__u8 value_type;
} dm_node_leaf;
typedef struct forced_inform_parameter {
char *name;
struct list_head list;
struct dm_node_leaf *node;
} _forced_inform_parameter;
enum dm_data_type {
DM_XML_DATA,
DM_SYSTEM_DATA
};
typedef struct dm_index_path {
struct dm_map *map;
struct dm_data *data;
enum dm_data_type data_type;
char *index;
int indice;
struct dm_node_path *node_path;
} dm_index_path;
typedef struct dm_node_path {
struct dm_node *node;
struct dm_index_path *index_path;
} dm_node_path;
typedef struct dm_rpc {
void *input;
int (*method)(struct dm_node *node, struct dm_rpc *dm_rpc, struct dm_node_path *node_path, int pos_np, struct dm_index_path *index_path, int pos_xp);
bool subtree;
} dm_rpc;
#ifdef WITH_DM_DEBUG
# ifndef DM_LOG
# define DM_LOG(SEV,MESSAGE,args...) puts_log(SEV,MESSAGE,##args);
# endif
#else
# define DM_LOG(SEV,MESSAGE,args...)
#endif
#ifdef WITH_DM_XML_DEBUG
# ifndef DM_XML_LOG
# define DM_XML_LOG(SEV,MESSAGE,args...) puts_log(SEV,MESSAGE,##args);
# define DM_XML_GET_HANDLER_DEBUG(NODE,INDEX_PATH,POS_XP) dm_get_handler_debug(NODE,INDEX_PATH,POS_XP);
# endif
#else
# define DM_XML_LOG(SEV,MESSAGE,args...)
# define DM_XML_GET_HANDLER_DEBUG(NODE,INDEX_PATH,POS_XP)
#endif

121
src/inc/dm_rpc.h Normal file
View file

@ -0,0 +1,121 @@
/*
dm_rpc.h
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
typedef struct dm_indice {
int type;
char *indice;
} dm_indice;
typedef struct sub_path {
char *name;
struct dm_node *node;
struct dm_indice dm_indice;
} sub_path;
typedef struct dm_input_getParameterValues {
int *n;
struct list_head *list;
} dm_input_getParameterValues;
typedef struct dm_input_getParameterNames {
int *n;
struct list_head *list;
enum xsd__boolean NextLevel;
} dm_input_getParameterNames;
typedef struct dm_input_getParameterAttributes {
int *n;
struct list_head *list;
} dm_input_getParameterAttributes;
typedef struct dm_input_setParameterAttributes {
struct cwmp1__SetParameterAttributesStruct *ParameterAttributesStruct;
} dm_input_setParameterAttributes;
typedef struct dm_input_getParameterPaths_by_correspondence {
struct list_head *list;
struct list_head *elist;
int *n;
struct dm_node *prefix_node;
struct sub_path *sub_path;
int sub_path_size;
bool get_value;
bool get_attribute;
bool is_actif;
} dm_input_getParameterPaths_by_correspondence;
typedef struct dm_input_setParameterValues {
char *value;
struct dm_set_handler *dm_set_handler;
} dm_input_setParameterValues;
typedef struct dm_input_addObject {
int *n;
char *path;
struct dm_set_handler *dm_set_handler;
} dm_input_addObject;
typedef struct dm_input_deleteObject {
char *path;
struct dm_set_handler *dm_set_handler;
} dm_input_deleteObject;
typedef struct handler_ParameterInfoStruct {
struct list_head list;
struct cwmp1__ParameterInfoStruct *ParameterInfoStruct;
} handler_ParameterInfoStruct;
typedef struct handler_ParameterValueStruct {
struct list_head list;
struct cwmp1__ParameterValueStruct *ParameterValueStruct;
} handler_ParameterValueStruct;
typedef struct dm_set_handler {
struct list_head list;
struct list_head cmd_list;
struct list_head cancel_list;
struct list_head service_list;
bool reboot_required;
bool cwmp_reload;
bool uci;
} dm_set_handler;
typedef struct service_handler {
struct list_head list;
char *service;
} service_handler;
typedef struct cmd_handler {
struct list_head list;
char *cmd;
enum param_type type;
__u8 end_session;
} cmd_handler;
typedef struct cancel_handler {
struct list_head list;
char *cmd;
} cancel_handler;
typedef struct handler_ParameterAttributeStruct {
struct list_head list;
struct cwmp1__ParameterAttributeStruct *ParameterAttributeStruct;
} handler_ParameterAttributeStruct;
#define DM_INDICE_INDEX 1
#define DM_INDICE_CORRESPONDENCE 2
#define DM_MAX_INDICE 16

121
src/inc/httpda.h Normal file
View file

@ -0,0 +1,121 @@
/*
httpda.h
gSOAP HTTP Digest Authentication plugin.
Supports both Basic and Digest authentication.
gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------
*/
#ifndef HTTPDA_H
#define HTTPDA_H
#include "stdsoap2.h"
#include "md5evp.h" /* requires MD5 */
#include "threads.h" /* mutex for multi-threaded server implementations */
#ifdef __cplusplus
extern "C" {
#endif
#define HTTP_DA_ID "HTTP-DA-1.0" /* plugin identification */
#define HTTP_DA_SESSION_TIMEOUT (600) /* sessions time out after ten minutes */
extern const char http_da_id[];
struct http_da_data
{
int (*fposthdr)(struct soap*, const char*, const char*);
int (*fparsehdr)(struct soap*, const char*, const char*);
int (*fprepareinit)(struct soap*);
int (*fpreparesend)(struct soap*, const char*, size_t);
int (*fpreparerecv)(struct soap*, const char*, size_t);
int (*fdisconnect)(struct soap*);
void *context; /* ptr to MD5 context for MD5 handler */
char digest[16]; /* MD5 entity body digest */
char *nonce; /* client/server-side copy of server's nonce value */
char *opaque; /* client/server-side copy of server's opaque value */
char *qop; /* client/server-side copy of server's qop value(s) */
char *alg; /* client-side: server's algorithm value */
unsigned long nc; /* client-side: generated nonce count */
char *ncount; /* server-side: client's nonce count */
char *cnonce; /* server-side: client's nonce */
char *response; /* server-side: client's response digest key */
};
struct http_da_session
{
struct http_da_session *next;
time_t modified;
char *realm;
char *nonce;
char *opaque;
unsigned long nc;
};
int http_da(struct soap *soap, struct soap_plugin *p, void *arg);
int http_da_verify_post(struct soap *soap, char *passwd);
int http_da_verify_get(struct soap *soap, char *passwd);
struct http_da_info
{
char *authrealm;
char *userid;
char *passwd;
char *nonce;
char *opaque;
char *qop;
char *alg;
};
void http_da_save(struct soap *soap, struct http_da_info *info, const char *realm, const char *userid, const char *passwd);
void http_da_restore(struct soap *soap, struct http_da_info *info);
void http_da_release(struct soap *soap, struct http_da_info *info);
#ifdef __cplusplus
}
#endif
#endif

471
src/inc/list.h Normal file
View file

@ -0,0 +1,471 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
/*
* These are non-NULL pointers that will result in page faults
* under normal circumstances, used to verify that nobody uses
* non-initialized list entries.
*/
#define LIST_POISON1 ((void *) 0x00100100)
#define LIST_POISON2 ((void *) 0x00200200)
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
#define INIT_LIST_HEAD(ptr) do { \
(ptr)->next = (ptr); (ptr)->prev = (ptr); \
} while (0)
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}
/**
* list_add - add a new entry
* @new: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
static inline void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
/*
* Delete a list entry by making the prev/next entries
* point to each other.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_del(struct list_head * prev, struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
/**
* list_del - deletes entry from list.
* @entry: the element to delete from the list.
* Note: list_empty on entry does not return true after this, the entry is
* in an undefined state.
*/
static inline void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
entry->next = LIST_POISON1;
entry->prev = LIST_POISON2;
}
/**
* list_del_init - deletes entry from list and reinitialize it.
* @entry: the element to delete from the list.
*/
static inline void list_del_init(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}
/**
* list_move - delete from one list and add as another's head
* @list: the entry to move
* @head: the head that will precede our entry
*/
static inline void list_move(struct list_head *list, struct list_head *head)
{
__list_del(list->prev, list->next);
list_add(list, head);
}
/**
* list_move_tail - delete from one list and add as another's tail
* @list: the entry to move
* @head: the head that will follow our entry
*/
static inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
list_add_tail(list, head);
}
/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
static inline int list_empty(const struct list_head *head)
{
return head->next == head;
}
/**
* list_empty_careful - tests whether a list is
* empty _and_ checks that no other CPU might be
* in the process of still modifying either member
*
* NOTE: using list_empty_careful() without synchronization
* can only be safe if the only activity that can happen
* to the list entry is list_del_init(). Eg. it cannot be used
* if another CPU could re-list_add() it.
*
* @head: the list to test.
*/
static inline int list_empty_careful(const struct list_head *head)
{
struct list_head *next = head->next;
return (next == head) && (next == head->prev);
}
static inline void __list_splice(struct list_head *list,
struct list_head *head)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
/**
* list_splice - join two lists
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
static inline void list_splice(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
__list_splice(list, head);
}
/**
* list_splice_init - join two lists and reinitialise the emptied list.
* @list: the new list to add.
* @head: the place to add it in the first list.
*
* The list at @list is reinitialised
*/
static inline void list_splice_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head);
INIT_LIST_HEAD(list);
}
}
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
/**
* container_of - cast a member of a structure out to the containing structure
*
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
for (pos = (head)->next; prefetch(pos->next), pos != (head); \
pos = pos->next)
/**
* __list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
*
* This variant differs from list_for_each() in that it's the
* simplest possible list iteration code, no prefetching is done.
* Use this for code that knows the list to be very short (empty
* or 1 entry) most of the time.
*/
#define __list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
/**
* list_for_each_prev - iterate over a list backwards
* @pos: the &struct list_head to use as a loop counter.
* @head: the head for your list.
*/
#define list_for_each_prev(pos, head) \
for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
pos = pos->prev)
/**
* list_for_each_safe - iterate over a list safe against removal of list entry
* @pos: the &struct list_head to use as a loop counter.
* @n: another &struct list_head to use as temporary storage
* @head: the head for your list.
*/
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
/**
* list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop counter.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
* list_for_each_entry_reverse - iterate backwards over list of given type.
* @pos: the type * to use as a loop counter.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \
prefetch(pos->member.prev), &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
/**
* list_prepare_entry - prepare a pos entry for use as a start point in
* list_for_each_entry_continue
* @pos: the type * to use as a start point
* @head: the head of the list
* @member: the name of the list_struct within the struct.
*/
#define list_prepare_entry(pos, head, member) \
((pos) ? : list_entry(head, typeof(*pos), member))
/**
* list_for_each_entry_continue - iterate over list of given type
* continuing after existing point
* @pos: the type * to use as a loop counter.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_continue(pos, head, member) \
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @pos: the type * to use as a loop counter.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
/*
* Double linked lists with a single pointer list head.
* Mostly useful for hash tables where the two pointer list head is
* too wasteful.
* You lose the ability to access the tail in O(1).
*/
struct hlist_head {
struct hlist_node *first;
};
struct hlist_node {
struct hlist_node *next, **pprev;
};
#define HLIST_HEAD_INIT { .first = NULL }
#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)
static inline int hlist_unhashed(const struct hlist_node *h)
{
return !h->pprev;
}
static inline int hlist_empty(const struct hlist_head *h)
{
return !h->first;
}
static inline void __hlist_del(struct hlist_node *n)
{
struct hlist_node *next = n->next;
struct hlist_node **pprev = n->pprev;
*pprev = next;
if (next)
next->pprev = pprev;
}
static inline void hlist_del(struct hlist_node *n)
{
__hlist_del(n);
n->next = LIST_POISON1;
n->pprev = LIST_POISON2;
}
static inline void hlist_del_init(struct hlist_node *n)
{
if (n->pprev) {
__hlist_del(n);
INIT_HLIST_NODE(n);
}
}
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
{
struct hlist_node *first = h->first;
n->next = first;
if (first)
first->pprev = &n->next;
h->first = n;
n->pprev = &h->first;
}
/* next must be != NULL */
static inline void hlist_add_before(struct hlist_node *n,
struct hlist_node *next)
{
n->pprev = next->pprev;
n->next = next;
next->pprev = &n->next;
*(n->pprev) = n;
}
static inline void hlist_add_after(struct hlist_node *n,
struct hlist_node *next)
{
next->next = n->next;
n->next = next;
next->pprev = &n->next;
if(next->next)
next->next->pprev = &next->next;
}
#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
#define hlist_for_each(pos, head) \
for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \
pos = pos->next)
#define hlist_for_each_safe(pos, n, head) \
for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \
pos = n)
/**
* hlist_for_each_entry - iterate over list of given type
* @tpos: the type * to use as a loop counter.
* @pos: the &struct hlist_node to use as a loop counter.
* @head: the head for your list.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry(tpos, pos, head, member) \
for (pos = (head)->first; \
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
* @tpos: the type * to use as a loop counter.
* @pos: the &struct hlist_node to use as a loop counter.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_continue(tpos, pos, member) \
for (pos = (pos)->next; \
pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_from - iterate over a hlist continuing from existing point
* @tpos: the type * to use as a loop counter.
* @pos: the &struct hlist_node to use as a loop counter.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_from(tpos, pos, member) \
for (; pos && ({ prefetch(pos->next); 1;}) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = pos->next)
/**
* hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @tpos: the type * to use as a loop counter.
* @pos: the &struct hlist_node to use as a loop counter.
* @n: another &struct hlist_node to use as temporary storage
* @head: the head for your list.
* @member: the name of the hlist_node within the struct.
*/
#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
for (pos = (head)->first; \
pos && ({ n = pos->next; 1; }) && \
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
pos = n)
#endif

81
src/inc/md5evp.h Normal file
View file

@ -0,0 +1,81 @@
/*
md5evp.h
gSOAP HTTP Content-MD5 digest plugin.
gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------
Defines MD5 handler using EVP interface (e.g. using OpenSSL)
int md5_handler(struct soap *soap, void **context, enum md5_action action, char *buf, size_t len)
context can be set and passed to subsequent calls. Parameters:
action =
MD5_INIT: init context
MD5_UPDATE: update context with data from buf with size len
MD5_FINAL: fill buf with 16 bytes MD5 hash value
MD5_DELETE: delete context
buf input data, output MD5 128 bit hash value
len length of input data
*/
#ifndef MD5EVP_H
#define MD5EVP_H
#include "stdsoap2.h"
#include <openssl/evp.h>
#ifdef __cplusplus
extern "C" {
#endif
enum md5_action { MD5_INIT, MD5_UPDATE, MD5_FINAL, MD5_DELETE };
int md5_handler(struct soap *soap, void **context, enum md5_action action, char *buf, size_t len);
#ifdef __cplusplus
}
#endif
#endif

1532
src/inc/soapH.h Normal file

File diff suppressed because it is too large Load diff

1060
src/inc/soapStub.h Normal file

File diff suppressed because it is too large Load diff

2317
src/inc/stdsoap2.h Normal file

File diff suppressed because it is too large Load diff

123
src/inc/threads.h Normal file
View file

@ -0,0 +1,123 @@
/*
threads.h
gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------
*/
#ifndef THREADS_H
#define THREADS_H
#ifndef WIN32
# include <unistd.h> /* defines _POSIX_THREADS if pthreads are available */
#else
# define ssize_t int
# include <io.h>
# include <sys/types.h>
# include <process.h>
# include <windows.h>
#endif
#if defined(_POSIX_THREADS) || defined(_SC_THREADS)
# include <pthread.h>
#endif
/******************************************************************************\
*
* Threads
*
\******************************************************************************/
#if defined(WIN32)
# define THREAD_TYPE HANDLE
# define THREAD_ID GetCurrentThreadId()
# define THREAD_CREATE(x,y,z) *(x) = (HANDLE)_beginthread((y), 8*4096, (z))
# define THREAD_DETACH(x)
# define THREAD_JOIN(x) WaitForSingleObject((x), INFINITE)
# define THREAD_EXIT _endthread()
# define MUTEX_TYPE HANDLE
# define MUTEX_SETUP(x) (x) = CreateMutex(NULL, FALSE, NULL)
# define MUTEX_CLEANUP(x) CloseHandle(x)
# define MUTEX_LOCK(x) WaitForSingleObject((x), INFINITE)
# define MUTEX_UNLOCK(x) ReleaseMutex(x)
# define COND_SETUP(x) emulate_pthread_cond_init(&(x))
# define COND_CLEANUP(x) emulate_pthread_cond_destroy(&(x))
# define COND_SIGNAL(x) emulate_pthread_cond_signal(&(x))
# define COND_WAIT(x,y) emulate_pthread_cond_wait(&(x), &(y))
typedef struct
{ u_int waiters_count_;
CRITICAL_SECTION waiters_count_lock_;
HANDLE signal_event_;
} COND_TYPE;
#ifdef __cplusplus
extern "C" {
#endif
int emulate_pthread_cond_init(COND_TYPE*);
int emulate_pthread_cond_destroy(COND_TYPE*);
int emulate_pthread_cond_signal(COND_TYPE*);
int emulate_pthread_cond_wait(COND_TYPE*, MUTEX_TYPE*);
#ifdef __cplusplus
}
#endif
#elif defined(_POSIX_THREADS) || defined(_SC_THREADS)
# define THREAD_TYPE pthread_t
# define THREAD_ID pthread_self()
# define THREAD_CREATE(x,y,z) pthread_create((x), NULL, (y), (z))
# define THREAD_DETACH(x) pthread_detach((x))
# define THREAD_JOIN(x) pthread_join((x), NULL)
# define THREAD_EXIT pthread_exit(NULL)
# define MUTEX_TYPE pthread_mutex_t
# define MUTEX_SETUP(x) pthread_mutex_init(&(x), NULL)
# define MUTEX_CLEANUP(x) pthread_mutex_destroy(&(x))
# define MUTEX_LOCK(x) pthread_mutex_lock(&(x))
# define MUTEX_UNLOCK(x) pthread_mutex_unlock(&(x))
# define COND_TYPE pthread_cond_t
# define COND_SETUP(x) pthread_cond_init(&(x), NULL)
# define COND_CLEANUP(x) pthread_cond_destroy(&(x))
# define COND_SIGNAL(x) pthread_cond_signal(&(x))
# define COND_WAIT(x,y) pthread_cond_wait(&(x), &(y))
#else
# error "No POSIX threads detected: we need thread and mutex operations. See for example OpenSSL /threads/th-lock.c on how to implement mutex on your platform"
#endif
#endif

123
src/init/cwmpd.init Normal file
View file

@ -0,0 +1,123 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 Inteno
START=99
STOP=40
EXTRA_HELP=" start [GetRPCMethods] Start cwmpd service and send GetRPCMethods"
wait_connection_acs() {
default_acs="http://192.168.1.1:8080/openacs/acs"
acs_dhcp_discovery=`uci -q get cwmp.acs.dhcp_discovery`
url=`uci -q get cwmp.acs.url`
if [ \( "_$acs_dhcp_discovery" = "_enable" \) -o \( "_$url" = "_" \) ];then
url=`uci -P /var/state -q get provisioning.iup.tr069url`
elif [ "_$url" != "_" ];then
url=`uci -q get cwmp.acs.url`
else
url=$default_acs
fi
dest=`echo $url|sed 's/http:\/\///g'|cut -f1 -d \/|cut -f1 -d:`
port=`echo $url|sed 's/http:\/\///g'|cut -f1 -d \/|cut -f2 -d:`
if [ "_$port" = "_" ];then
port=80
fi
i=0
result=1
until [ \( $result -eq 0 \) -o \( $i -eq 20 \) ];do
echo -e -n "" | nc $dest $port
result=$?
if [ $result -eq 1 ];then
i=`expr $i + 1`
sleep 5
fi
done
}
check_dhcp() {
i=0
dhcp_discovery=`uci -q get cwmp.acs.dhcp_discovery`
url=`uci -q get cwmp.acs.url`
if [ \( "_$acs_dhcp_discovery" = "_enable" \) -o \( "_$url" = "_" \) ]
then
while [ $i -le 10 ]
do
acs_url=`uci -P /var/state -q get provisioning.iup.tr069url`
if [ "$acs_url" != "" ]
then
echo "The acs url discovery from dhcp server is successfully done."
break
else
echo "Waiting for discovery of acs url from dhcp server ..."
sleep 10
fi
i=`expr $i + 1`
done
fi
}
start_msg="Starting cwmpd ..."
stop_msg="Stopping cwmpd ..."
check_iccu() {
echo $start_msg
check_dhcp
wait_connection_acs
iccu_url=`uci get -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_url`
iccu_change_state=`uci get -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_change_state`
if [ "_$1" = "_boot" ];then
opt=$opt"-b "
fi
if [ "_$1" = "_GetRPCMethods" ];then
opt=$opt"-g "
fi
if [ "$iccu_change_state" = "yes" ];then
opt=$opt"-c "
fi
[ -f /etc/config/cwmp ] && /usr/bin/cwmpd $opt &
rm -rf /etc/cwmpd/.iccu
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_url=$iccu_url
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_change_state=no
}
boot() {
/etc/cwmpd/scripts/iccu_enable && rm /etc/cwmpd/scripts/iccu_enable
run=$(ps aux|grep /usr/bin/cwmpd|grep -v grep|grep -v rc.common)
if [ "$run" = "" ];then
check_iccu "boot"
else
echo "cwmpd is currently running ..."
fi
}
start() {
run=$(ps aux|grep /usr/bin/cwmpd|grep -v grep|grep -v rc.common)
if [ "$run" = "" ]
then
if [ "$1" = "GetRPCMethods" ];then
check_iccu "GetRPCMethods"
else
check_iccu
fi
else
echo "cwmpd is currently running ..."
fi
}
stop() {
echo $stop_msg
for pid in `ps aux|grep /usr/bin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:`
do
if [ "_$pid" != "_" ];then
/bin/kill -9 $pid 2> /dev/null
fi
done
}
restart() {
stop
start
}

124
src/init/iccu.init Normal file
View file

@ -0,0 +1,124 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2012 Inteno
START=98
STOP=40
wait_connection_acs() {
i=0
result=1
until [ \( $result -eq 0 \) -o \( $i -eq 20 \) ];do
echo -e -n "" | nc $1 $2
result=$?
if [ $result -eq 1 ];then
i=`expr $i + 1`
sleep 5
fi
done
}
check_connection_request_url() {
cpe_port=`uci get cwmp.cpe.port`
if [ "_$cpe_port" = "_" ];then
cpe_port=7547
fi
default_acs="http://192.168.1.1:8080/openacs/acs"
acs_dhcp_discovery=`uci -q get cwmp.acs.dhcp_discovery`
url=`uci -q get cwmp.acs.url`
if [ \( "_$acs_dhcp_discovery" = "_enable" \) -o \( "_$url" = "_" \) ];then
url=`uci -P /var/state -q get provisioning.iup.tr069url`
elif [ "_$url" != "_" ];then
url=`uci -q get cwmp.acs.url`
else
url=$default_acs
fi
dest=`echo $url|sed 's/http:\/\///g'|cut -f1 -d \/|cut -f1 -d:`
port=`echo $url|sed 's/http:\/\///g'|cut -f1 -d \/|cut -f2 -d:`
if [ "_$port" = "_" ];then
port=80
fi
isIP=`echo "$dest"|grep -v -e [a-zA-Z]`
if [ "_$isIP" != "_" ];then
list=`netstat -t -n|grep $dest:$port|sed 's/\ \+/-/g'|sed 's/-$//g'`
wait_connection_acs "$dest" "$port"
list2=`netstat -t -n|grep $dest:$port|sed 's/\ \+/-/g'|sed 's/-$//g'`
else
i=0
result=1
until [ \( $result -eq 0 \) -o \( $i -eq 20 \) ];do
nslookup $dest > /dev/null
result=$?
if [ $result -eq 1 ];then
i=`expr $i + 1`
sleep 5
fi
done
if [ $result -eq 1 ];then
exit 1
fi
number_entries=`nslookup $dest|wc -l`
n=`expr $number_entries - 4`
if [ $n -lt 0 ];then
exit 1
fi
for addr in `nslookup $dest|tail -$n|grep Address|cut -f2 -d:|sed 's/^ //g'|cut -f1 -d " "`;do
list=$list`netstat -t -n|grep $addr:$port|sed 's/\ \+/-/g'|sed 's/-$//g'`
done
for addr in `nslookup $dest|tail -$n|grep Address|cut -f2 -d:|sed 's/^ //g'|cut -f1 -d " "`;do
wait_connection_acs "$addr" "$port"
list2=$list2`netstat -t -n|grep $addr:$port|sed 's/\ \+/-/g'|sed 's/-$//g'`
done
fi
for line2 in $list2;do
found=0
for line in $list;do
if [ "_$line" = "_$line2" ];then
found=1
break
fi
done
if [ $found -eq 1 ];then
continue
fi
ip=`echo $line2|cut -f4 -d -|cut -f1 -d:|uniq`
break
done
if [ "_$ip" = "_" ];then
exit 1
fi
old_cr_url=`uci get -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_url`
if [ $? -eq 0 ];then
cr_url="http://$ip:$cpe_port"
if [ "_$cr_url" != "_$old_cr_url" ];then
rm -rf /etc/cwmpd/.iccu
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_url=$cr_url
cwmp_value_change "InternetGatewayDevice.ManagementServer.ConnectionRequestURL"
if [ $? -eq 1 ];then
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_change_state=yes
else
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_change_state=no
fi
uci commit
fi
else
rm -rf /etc/cwmpd/.iccu
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_url=http://$ip:$cpe_port
uci set -q -P /etc/cwmpd/.iccu cwmp.cpe.iccu_change_state=no
uci commit
fi
}
boot() {
check_connection_request_url
}
start() {
check_connection_request_url
}
restart() {
start
}

22
src/init/iccu_enable Normal file
View file

@ -0,0 +1,22 @@
#!/bin/sh
check_network=`uci get -q ucitrack.@network[0].affects|grep iccu`
if [ "_$check_network" = "_" ];then
uci add_list ucitrack.@network[0].affects=iccu
fi
check_cwmp=`uci get -q ucitrack.@cwmp[0]`
if [ "_$check_cwmp" = "_" ];then
uci add ucitrack cwmp
uci set ucitrack.@cwmp[0].init=cwmpd
uci add_list ucitrack.@cwmp[0].affects=iccu
uci add ucitrack iccu
uci set ucitrack.@iccu[0].init=iccu
fi
uci commit
/etc/init.d/iccu enable
/etc/init.d/iccu boot
cat /etc/init.d/cwmpd|grep -v "/etc/cwmpd/scripts/iccu_enable && rm /etc/cwmpd/scripts/iccu_enable" > /etc/init.d/cwmpd.new
mv /etc/init.d/cwmpd.new /etc/init.d/cwmpd
chmod +x /etc/init.d/cwmpd

197
src/kcwmp.c Normal file
View file

@ -0,0 +1,197 @@
/*
kcwmp.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <linux/module.h>
#include <net/sock.h>
#include <linux/netlink.h>
#include <linux/skbuff.h>
#include <linux/mutex.h>
#include <linux/wait.h>
#include <stdarg.h>
#include <linux/slab.h>
#include "inc/cwmp_kernel.h"
typedef struct kernel_cwmp_input {
char **argv;
int argc;
int handler;
struct mutex mutex;
wait_queue_head_t thresholdq;
} KERNEL_CWMP_INPUT;
static struct sock *nl_sk = NULL;
static struct kernel_cwmp_input kernel_cwmp_input;
MODULE_LICENSE("INTENO");
static void kernel_api_cwmp_value_change_listener(struct sk_buff *skb)
{
struct nlmsghdr *nlh;
int pid;
struct sk_buff *skb_out;
int msg_size;
char *msg;
char *recv;
int i,res;
nlh = (struct nlmsghdr*)skb->data;
recv = (char*)nlmsg_data(nlh);
if (strcmp(recv,NETLINK_CWMP_ID)!=0)
{
return;
}
pid = nlh->nlmsg_pid; /*pid of sending process */
while (kernel_cwmp_input.argc==0)
{
if ( wait_event_interruptible( kernel_cwmp_input.thresholdq, kernel_cwmp_input.handler)) {
return ;
}
}
kernel_cwmp_input.handler = 0;
mutex_lock (&(kernel_cwmp_input.mutex));
for (i=0;i<=kernel_cwmp_input.argc;i++)
{
if (i<kernel_cwmp_input.argc)
{
msg = kernel_cwmp_input.argv[i];
}
else
{
msg = NETLINK_END_DATA;
}
msg_size = strlen(msg);
skb_out = nlmsg_new(msg_size,0);
if(!skb_out)
{
printk(KERN_ERR "Failed to allocate new skb\n");
return;
}
nlh=nlmsg_put(skb_out,0,0,NLMSG_DONE,msg_size,0);
NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
strncpy(nlmsg_data(nlh),msg,msg_size);
res=nlmsg_unicast(nl_sk,skb_out,pid);
if (i<kernel_cwmp_input.argc)
{
kfree(kernel_cwmp_input.argv[i]);
}
}
if (kernel_cwmp_input.argv!=NULL)
{
kfree(kernel_cwmp_input.argv);
kernel_cwmp_input.argv = NULL;
}
kernel_cwmp_input.argc = 0;
mutex_unlock (&(kernel_cwmp_input.mutex));
}
static int /*__init*/ kernel_api_cwmp_value_change_init(void)
{
printk(KERN_INFO "Entering kernel cwmp module: %s\n",__FUNCTION__);
memset (&kernel_cwmp_input, 0, sizeof(struct kernel_cwmp_input));
init_waitqueue_head(&kernel_cwmp_input.thresholdq);
mutex_init(&kernel_cwmp_input.mutex);
nl_sk=netlink_kernel_create(&init_net, NETLINK_USER, 0, kernel_api_cwmp_value_change_listener, NULL, THIS_MODULE);
if(!nl_sk)
{
printk(KERN_ALERT "Error creating socket.\n");
return -10;
}
return 0;
}
static void /*__exit*/ kernel_api_cwmp_value_change_exit(void)
{
printk(KERN_INFO "Exiting kernel cwmp module: %s\n",__FUNCTION__);
netlink_kernel_release(nl_sk);
}
int kernel_api_cwmp_value_change_call (int count, ...)
{
int i;
va_list args;
char *s;
if (kernel_cwmp_input.argc>0)
{
kernel_cwmp_input.handler = 1;
wake_up_interruptible(&(kernel_cwmp_input.thresholdq));
return 1;
}
mutex_lock (&(kernel_cwmp_input.mutex));
kernel_cwmp_input.argv = kmalloc(count*sizeof(char *),GFP_KERNEL);
if (kernel_cwmp_input.argv==NULL)
{
goto kernel_api_cwmp_error;
}
va_start(args, count);
for (i=0;i<count;i++)
{
s = (char *) va_arg(args, char *);
if (s==NULL)
{
s = NETLINK_NULL;
}
kernel_cwmp_input.argv[i] = kmalloc(strlen(s),GFP_KERNEL);
if (kernel_cwmp_input.argv[i]==NULL)
{
goto kernel_api_cwmp_error;
}
strcpy(kernel_cwmp_input.argv[i],s);
kernel_cwmp_input.argc++;
}
va_end(args);
mutex_unlock (&(kernel_cwmp_input.mutex));
kernel_cwmp_input.handler = 1;
wake_up_interruptible(&(kernel_cwmp_input.thresholdq));
return 1;
kernel_api_cwmp_error:
if (kernel_cwmp_input.argv!=NULL)
{
for (i=0;i<kernel_cwmp_input.argc;i++)
{
if (kernel_cwmp_input.argv[i]!=NULL)
{
kfree(kernel_cwmp_input.argv[i]);
}
}
kfree(kernel_cwmp_input.argv);
kernel_cwmp_input.argv = NULL;
}
kernel_cwmp_input.argc = 0;
mutex_unlock (&(kernel_cwmp_input.mutex));
return 1;
}
EXPORT_SYMBOL(kernel_api_cwmp_value_change_call);
module_init(kernel_api_cwmp_value_change_init); module_exit(kernel_api_cwmp_value_change_exit);

163
src/log.c Normal file
View file

@ -0,0 +1,163 @@
/*
log.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <time.h>
#include "cwmp.h"
#define DEFAULT_LOG_SEVERITY 6
static char *SEVERITY_NAMES[8] = {"[EMERG] ","[ALERT] ","[CRITIC] ","[ERROR] ","[WARNING]","[NOTICE] ","[INFO] ","[DEBUG] "};
static int log_severity = DEFAULT_LOG_SEVERITY;
static long int log_max_size = DEFAULT_LOG_FILE_SIZE;
static char log_file_name[256];
static bool enable_log_file = TRUE;
static bool enable_log_stdout = FALSE;
static pthread_mutex_t mutex_log;
int log_set_severity_idx (char *value)
{
int i;
for (i=0;i<8;i++)
{
if (strstr(SEVERITY_NAMES[i],value)!=NULL)
{
log_severity = i;
return 0;
}
}
return 1;
}
int log_set_log_file_name (char *value)
{
if(value != NULL)
{
strcpy(log_file_name,value);
}
else
{
strcpy(log_file_name,DEFAULT_LOG_FILE_NAME);
}
}
int log_set_file_max_size(char *value)
{
if(value != NULL)
{
log_max_size = atol(value);
}
}
int log_set_on_console(char *value)
{
if(strcmp(value,"enable") == 0)
{
enable_log_stdout = TRUE;
}
if(strcmp(value,"disable") == 0)
{
enable_log_stdout = FALSE;
}
}
int log_set_on_file(char *value)
{
if(strcmp(value,"enable") == 0)
{
enable_log_file = TRUE;
}
if(strcmp(value,"disable") == 0)
{
enable_log_file = FALSE;
}
}
void puts_log(int severity, const char *fmt, ...)
{
va_list args;
int i;
char buf[1024];
char buf_file[1024];
time_t t;
struct tm *Tm;
struct timeval tv;
FILE *pLog;
struct stat st;
long int size = 0;
char log_file_name_bak[256];
if (severity>log_severity)
{
return;
}
gettimeofday(&tv, 0);
t = time((time_t*)NULL);
Tm= localtime(&tv.tv_sec);
i = sprintf(buf,"%02d-%02d-%4d, %02d:%02d:%02d.%03d %s ",
Tm->tm_mday,
Tm->tm_mon+1,
Tm->tm_year+1900,
Tm->tm_hour,
Tm->tm_min,
Tm->tm_sec,
(int)tv.tv_usec%1000,
SEVERITY_NAMES[severity]);
if(strlen(log_file_name) == 0)
{
strcpy(log_file_name,DEFAULT_LOG_FILE_NAME);
}
if (stat(log_file_name, &st) == 0)
{
size = st.st_size;
}
if(enable_log_file)
{
pthread_mutex_lock (&mutex_log);
if(size >= log_max_size)
{
sprintf(log_file_name_bak,"%s.1",log_file_name);
rename(log_file_name,log_file_name_bak);
pLog = fopen(log_file_name,"w");
}
else
{
pLog = fopen(log_file_name,"a+");
}
}
va_start(args, fmt);
i += vsprintf(buf+i, fmt, args);
if(enable_log_file)
{
sprintf(buf_file,"%s\n",buf);
fputs (buf_file, pLog);
}
va_end(args);
if(enable_log_file)
{
fclose(pLog);
pthread_mutex_unlock (&mutex_log);
}
if(enable_log_stdout)
{
puts(buf);
}
}

102
src/md5evp.c Normal file
View file

@ -0,0 +1,102 @@
/*
md5evp.c
gSOAP HTTP Content-MD5 digest EVP handler for httpmd5 plugin
gSOAP XML Web services tools
Copyright (C) 2000-2005, Robert van Engelen, Genivia Inc., All Rights Reserved.
This part of the software is released under one of the following licenses:
GPL, the gSOAP public license, or Genivia's license for commercial use.
--------------------------------------------------------------------------------
gSOAP public license.
The contents of this file are subject to the gSOAP Public License Version 1.3
(the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.cs.fsu.edu/~engelen/soaplicense.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Initial Developer of the Original Code is Robert A. van Engelen.
Copyright (C) 2000-2005, Robert van Engelen, Genivia, Inc., All Rights Reserved.
--------------------------------------------------------------------------------
GPL license.
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.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed.
--------------------------------------------------------------------------------
A commercial use license is available from Genivia, Inc., contact@genivia.com
--------------------------------------------------------------------------------
*/
#include "md5evp.h"
#ifdef __cplusplus
extern "C" {
#endif
int md5_handler(struct soap *soap, void **context, enum md5_action action, char *buf, size_t len)
{
EVP_MD_CTX *ctx;
unsigned char hash[EVP_MAX_MD_SIZE];
unsigned int size;
switch (action)
{ case MD5_INIT:
#ifdef WITH_OPENSSL
OpenSSL_add_all_digests();
#endif
if (!*context)
{ *context = (void*)SOAP_MALLOC(soap, sizeof(EVP_MD_CTX));
EVP_MD_CTX_init((EVP_MD_CTX*)*context);
}
ctx = (EVP_MD_CTX*)*context;
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "-- MD5 Init %p\n", ctx));
EVP_DigestInit(ctx, EVP_md5());
break;
case MD5_UPDATE:
ctx = (EVP_MD_CTX*)*context;
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "-- MD5 Update %p --\n", ctx));
DBGMSG(TEST, buf, len);
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "\n--"));
EVP_DigestUpdate(ctx, (void*)buf, (unsigned int)len);
break;
case MD5_FINAL:
ctx = (EVP_MD_CTX*)*context;
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "-- MD5 Final %p --\n", ctx));
EVP_DigestFinal(ctx, (unsigned char*)hash, &size);
memcpy(buf, hash, 16);
break;
case MD5_DELETE:
ctx = (EVP_MD_CTX*)*context;
DBGLOG(TEST, SOAP_MESSAGE(fdebug, "-- MD5 Delete %p --\n", ctx));
if (ctx)
{ EVP_MD_CTX_cleanup(ctx);
SOAP_FREE(soap, ctx);
}
*context = NULL;
}
return SOAP_OK;
}
#ifdef __cplusplus
}
#endif

12549
src/soapC.c Normal file

File diff suppressed because it is too large Load diff

566
src/soapClient.c Normal file
View file

@ -0,0 +1,566 @@
/*
soapClient.c
cwmp service client in C
--------------------------------------------------------------------------------
cwmp service client
Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved.
Any distribution, dissemination, modification, conversion, integral or partial
reproduction, can not be made without the prior written permission of Inteno.
--------------------------------------------------------------------------------
Author contact information:
--------------------------------------------------------------------------------
*/
#include "soapH.h"
#include "cwmp.h"
#include "cwmpBinding.nsmap"
#include "httpda.h"
#ifdef __cplusplus
extern "C" {
#endif
SOAP_SOURCE_STAMP("@(#) soapClient.c ver 2.7.12 2011-10-17 13:06:56 GMT")
static struct http_da_info http_da_info;
struct rpc_cpe *cwmp_add_session_rpc_cpe_getRPCMethods (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_reboot (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_download (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterValues (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterValues (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterNames (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_factoryReset (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_scheduleInform (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_getParameterAttributes (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_setParameterAttributes (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_addObject (struct session *session);
struct rpc_cpe *cwmp_add_session_rpc_cpe_deleteObject (struct session *session);
const struct CPE_METHOD_CONSTRUCTORS CPE_METHOD_CONSTRUCTORS_ARRAY [] = {
{"GetRPCMethods", cwmp_add_session_rpc_cpe_getRPCMethods},
{"SetParameterValues", cwmp_add_session_rpc_cpe_setParameterValues},
{"GetParameterValues", cwmp_add_session_rpc_cpe_getParameterValues},
{"GetParameterNames", cwmp_add_session_rpc_cpe_getParameterNames},
{"SetParameterAttributes", cwmp_add_session_rpc_cpe_setParameterAttributes},
{"GetParameterAttributes", cwmp_add_session_rpc_cpe_getParameterAttributes},
{"AddObject", cwmp_add_session_rpc_cpe_addObject},
{"DeleteObject", cwmp_add_session_rpc_cpe_deleteObject},
{"Reboot", cwmp_add_session_rpc_cpe_reboot},
{"Download", cwmp_add_session_rpc_cpe_download},
{"Upload", NULL},
{"FactoryReset", cwmp_add_session_rpc_cpe_factoryReset},
{"GetQueuedTransfers", NULL},
{"GetAllQueuedTransfers", NULL},
{"ScheduleInform", cwmp_add_session_rpc_cpe_scheduleInform},
{"SetVouchers", NULL},
{"GetOptions", NULL}
};
struct rpc_cpe *cwmp_add_session_rpc_cpe_Fault (struct session *session, int idx);
void cwmp_session_soap_init (struct session *session)
{
soap_init2(&session->soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);
soap_set_omode(&session->soap, SOAP_XML_INDENT);
session->soap.recv_timeout = SOAP_TIMEOUT;
session->soap.send_timeout = SOAP_TIMEOUT;
session->soap.connect_timeout = SOAP_TIMEOUT;
session->soap.accept_timeout = SOAP_TIMEOUT;
if (soap_register_plugin(&session->soap, http_da))
{
CWMP_LOG (ERROR,"Failed to register HTTP authentication plugin");
}
CWMP_LOG (INFO,"Open session");
CWMP_LOG (INFO,"ACS URL: %s",session->acs_url);
}
void cwmp_session_done (struct session *session)
{
soap_done(&session->soap);
http_da_release(&session->soap, &http_da_info);
CWMP_LOG (INFO,"Close session");
}
void cwmp_session_soap_destroy_end (struct session *session)
{
soap_destroy(&session->soap);
soap_end(&session->soap);
if (session->digest_auth == TRUE)
{
http_da_restore(&session->soap, &http_da_info);
}
}
int cwmp_soap_set_header_rpc_acs (struct soap *soap)
{
static int id=MIN_INT_ID;
static char buf_id[16];
static struct SOAP_ENV__Header soap_header;
memset(&soap_header, 0, sizeof(struct SOAP_ENV__Header));
if(id>=MAX_INT_ID)
{
id=MIN_INT_ID;
}
id++;
sprintf(buf_id,"%d",id);
soap_header.ID.__item = buf_id;
soap_header.ID.SOAP_ENV__mustUnderstand = "1";
soap->header = &soap_header;
return CWMP_OK;
}
int cwmp_soap_get_header_rpc_cpe (struct soap *soap)
{
static struct SOAP_ENV__Header soap_header;
static char *buf_id=NULL;
if (soap->header == NULL)
{
soap->header = &soap_header;
return CWMP_OK;
}
memset(&soap_header, 0, sizeof(struct SOAP_ENV__Header));
if (buf_id!=NULL)
{
free(buf_id);
buf_id = NULL;
}
buf_id = strdup(soap->header->ID.__item);
soap_header.ID.__item = buf_id;
soap_header.ID.SOAP_ENV__mustUnderstand = "1";
soap->header = NULL;
return CWMP_OK;
}
SOAP_FMAC3 char * SOAP_FMAC4 soap_get_fault_code(struct soap *soap)
{
struct SOAP_ENV__Fault *soap_fault;
struct _cwmp1__Fault *fault=NULL;
struct SOAP_ENV__Detail *detail=NULL;
soap_fault = soap->fault;
if (soap_fault == NULL)
{
return NULL;
}
if (soap_fault->detail!=NULL)
{
detail = soap_fault->detail;
}
else
{
detail = soap_fault->SOAP_ENV__Detail;
}
if (detail!=NULL)
{
fault = (struct _cwmp1__Fault *) detail->fault;
if (fault!=NULL)
{
if (fault->FaultCode!=NULL)
{
return fault->FaultCode;
}
}
}
return NULL;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_call_rpc_acs
(
struct cwmp *cwmp,
struct session *session,
struct rpc_acs *rpc_acs
)
{
struct soap *soap;
struct soap_cwmp1_methods__rpc *soap_methods;
char *soap_fault_code;
int u=0,r=0;
soap_methods = &(rpc_acs->soap_methods);
soap = &(session->soap);
soap->encodingStyle = ENCODING_STYLE_URL;
while (1)
{
session->error = CWMP_OK;
cwmp_soap_set_header_rpc_acs(soap);
soap_begin(soap);
cwmp_soap_send_rpc_acs (cwmp, session, rpc_acs, soap, soap_methods);
if (rpc_acs->error != CWMP_SUCCESS_RPC)
{
session->error = CWMP_RETRY_SESSION;
break;
}
if (soap_begin_recv(soap) ||
cwmp_soap_receive_rpc_acs_response (cwmp, session, rpc_acs, soap, soap_methods))
{
if (soap->error == 401) // challenge: HTTP authentication required
{
CWMP_LOG(INFO,"Receive http 401: need authentication");
if(u>0)
{
session->error = CWMP_RETRY_SESSION;
break;
}
u++;
// to store userid and passwd
http_da_save(soap, &http_da_info, soap->authrealm, cwmp->conf.acs_userid, cwmp->conf.acs_passwd); // set userid and passwd for this realm
session->digest_auth = TRUE;
cwmp_session_soap_destroy_end(session);
}
else if ((soap_fault_code = soap_get_fault_code(soap))!=NULL)
{
if (strcmp(soap_fault_code,"8005") == 0)
{
CWMP_LOG(INFO,"Receive soap 8005: need to re-send");
if (r>5)
{
session->error = CWMP_RETRY_SESSION;
break;
}
r++;
cwmp_session_soap_destroy_end(session);
}
else if (rpc_acs->type != RPC_ACS_INFORM_IDX)
{
rpc_acs->error = CWMP_SUCCESS_RPC;
session->error = CWMP_CONTINUE_SESSION;
break;
}
else
{
session->error = CWMP_RETRY_SESSION;
break;
}
}
else
{
session->error = CWMP_RETRY_SESSION;
break;
}
}
else
{
break;
}
}
return rpc_acs->error;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_send_rpc_acs
(
struct cwmp *cwmp,
struct session *session,
struct rpc_acs *rpc_acs,
struct soap *soap,
struct soap_cwmp1_methods__rpc *soap_methods
)
{
char *soap_endpoint;
char *soap_action = "";
soap_endpoint = session->acs_url;
soap_serializeheader(soap);
soap_methods->soap_serialize_cwmp1__send_data (soap, rpc_acs->method_data);
if (soap_begin_count(soap))
{
rpc_acs->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_methods->soap_put_cwmp1__send_data(soap, rpc_acs->method_data, soap_methods->envelope,"")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
{
rpc_acs->error = CWMP_FAIL_RPC;
return soap->error;
}
}
if (soap_end_count(soap))
{
rpc_acs->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap_connect(soap, soap_endpoint, soap_action))
{
rpc_acs->error = CWMP_RETRY_RPC;
return soap->error;
}
if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_methods->soap_put_cwmp1__send_data(soap, rpc_acs->method_data, soap_methods->envelope,"")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
{
rpc_acs->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap_end_send(soap))
{
rpc_acs->error = CWMP_RETRY_RPC;
CWMP_LOG (ERROR,"Problem when trying to send SOAP RPC to the ACS");
return soap->error;
}
CWMP_LOG (INFO,"Send SOAP RPC to the ACS");
rpc_acs->error = CWMP_SUCCESS_RPC;
return soap->error;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_receive_rpc_acs_response
(
struct cwmp *cwmp,
struct session *session,
struct rpc_acs *rpc_acs,
struct soap *soap,
struct soap_cwmp1_methods__rpc *soap_methods
)
{
if (soap_envelope_begin_in(soap)
|| soap_recv_header(soap) /* KMD IN */
|| soap_body_begin_in(soap))
{
rpc_acs->error = CWMP_RETRY_RPC;
CWMP_LOG (ERROR,"Problem when receiving SOAP RPC response from the ACS");
return soap->error;
}
soap_methods->soap_get_cwmp1__rpc_received_data (soap, rpc_acs->method_response_data, soap_methods->envelope_response,"");
CWMP_LOG (INFO,"Receive SOAP RPC response from the ACS");
if (soap->error)
{
rpc_acs->error = CWMP_RETRY_RPC;
if (soap->error == SOAP_TAG_MISMATCH && soap->level == 2)
return soap_recv_fault(soap);
return soap->error;
}
if (soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
{
return soap->error;
}
session->hold_request = (soap->header==NULL) ? FALSE : soap->header->HoldRequests.__item;
rpc_acs->error = CWMP_SUCCESS_RPC;
return soap->error;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_send_http_empty (struct cwmp *cwmp, struct session *session)
{
struct soap *soap;
char *soap_action = "";
char *soap_endpoint;
soap = &(session->soap);
soap_endpoint = session->acs_url;
soap_begin(soap);
if (soap_connect(soap, soap_endpoint, soap_action) ||
soap_send(soap, "") ||
soap_end_send(soap))
{
session->error = CWMP_RETRY_SESSION;
CWMP_LOG(ERROR,"Fail when trying to send HTTP empty");
return soap->error;
}
CWMP_LOG(INFO,"Send HTTP empty");
return CWMP_OK;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_recv_http_empty (struct cwmp *cwmp, struct session *session)
{
struct soap *soap;
static int uc=0;
soap = &(session->soap);
soap_begin_recv(soap);
if (soap->error == 401) // challenge: HTTP authentication required
{
if(uc>0)
{
session->error = CWMP_RETRY_SESSION;
uc = 0;
return CWMP_UNAUTHORIZED_401;
}
uc++;
// to store userid and passwd
http_da_save(soap, &http_da_info, soap->authrealm, cwmp->conf.acs_userid, cwmp->conf.acs_passwd); // set userid and passwd for this realm
session->digest_auth = TRUE;
return CWMP_UNAUTHORIZED_401;
}
uc = 0;
if (soap->status == 204)
{
CWMP_LOG (INFO,"Receive HTTP 204 No Content");
session->error = CWMP_SUCCESS_SESSION;
session->hold_request = FALSE;
return CWMP_OK;
}
else if (soap->status == 200)
{
CWMP_LOG (INFO,"Receive HTTP 200 OK");
session->error = CWMP_CONTINUE_SESSION;
return CWMP_OK;
}
return CWMP_OK;
}
struct rpc_cpe *cwmp_soap_receive_rpc_cpe (
struct cwmp *cwmp,
struct session *session
)
{
struct soap *soap;
int i;
struct rpc_cpe *rpc_cpe=NULL;
struct soap_cwmp1_methods__rpc *soap_methods;
char *method;
struct rpc_cpe *(*constructor)(struct session *session);
soap = &(session->soap);
if (soap_envelope_begin_in(soap)||
soap_recv_header(soap) ||
soap_body_begin_in(soap))
{
CWMP_LOG (ERROR,"Problem when receiving SOAP RPC from ACS");
return NULL;
}
soap_peek_element(soap);
cwmp_soap_get_header_rpc_cpe (soap);
CWMP_LOG (INFO,"Receive SOAP RPC from ACS: %s", soap->tag);
for (i=0;i<sizearray(CPE_METHOD_CONSTRUCTORS_ARRAY);i++)
{
method = CPE_METHOD_CONSTRUCTORS_ARRAY[i].METHOD;
constructor = CPE_METHOD_CONSTRUCTORS_ARRAY[i].CONSTRUCTOR;
if (!soap_match_tag(soap, soap->tag, method))
{
if (constructor!=NULL)
{
rpc_cpe = constructor(session);
if (rpc_cpe == NULL)
{
return NULL;
}
CWMP_LOG (INFO,"%s RPC is supported",soap->tag);
}
break;
}
}
if (rpc_cpe == NULL)
{
CWMP_LOG (INFO,"%s RPC is not supported",soap->tag);
rpc_cpe = cwmp_add_session_rpc_cpe_Fault(session,FAULT_CPE_METHOD_NOT_SUPPORTED_IDX);
return rpc_cpe;
}
soap_methods = &(rpc_cpe->soap_methods);
if (!soap_methods->soap_get_cwmp1__rpc_received_data(soap, rpc_cpe->method_data, soap_methods->envelope, NULL))
{
/*error*/
}
if (soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
{
/*error*/
}
session->hold_request = (soap->header==NULL) ? FALSE : soap->header->HoldRequests.__item;
return rpc_cpe;
}
SOAP_FMAC5 int SOAP_FMAC6 cwmp_soap_send_rpc_cpe_response
(
struct cwmp *cwmp,
struct session *session,
struct rpc_cpe *rpc_cpe
)
{
char *soap_endpoint;
char *soap_action = "";
struct soap_cwmp1_methods__rpc *soap_methods;
struct soap *soap;
soap_endpoint = session->acs_url;
soap_methods = &(rpc_cpe->soap_methods);
soap = &(session->soap);
soap_begin(soap);
cwmp_soap_get_header_rpc_cpe (soap);
soap_serializeheader(soap);
soap_methods->soap_serialize_cwmp1__send_data (soap, rpc_cpe->method_response_data);
if (soap_begin_count(soap))
{
rpc_cpe->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_methods->soap_put_cwmp1__send_data(soap, rpc_cpe->method_response_data, soap_methods->envelope_response,"")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
{
rpc_cpe->error = CWMP_FAIL_RPC;
return soap->error;
}
}
if (soap_end_count(soap))
{
rpc_cpe->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap_connect(soap, soap_endpoint, soap_action))
{
rpc_cpe->error = CWMP_RETRY_RPC;
return soap->error;
}
if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_methods->soap_put_cwmp1__send_data(soap, rpc_cpe->method_response_data, soap_methods->envelope_response,"")
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
{
rpc_cpe->error = CWMP_FAIL_RPC;
return soap->error;
}
if (soap_end_send(soap))
{
CWMP_LOG (ERROR,"Problem when trying to send SOAP RPC response to the ACS");
rpc_cpe->error = CWMP_RETRY_RPC;
return soap->error;
}
CWMP_LOG (INFO,"Send SOAP RPC response to the ACS");
return CWMP_OK;
}
#ifdef __cplusplus
}
#endif
/* End of soapClient.c */

15170
src/stdsoap2.c Normal file

File diff suppressed because it is too large Load diff

97
src/wsdl/cwmp-1-1.wsdl Normal file
View file

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
CWMP XML Schema v1.1
Notice:
The DSL Forum is a non-profit corporation organized to create guidelines
For DSL network system development and deployment. This XML Schema has
been approved by members of the Forum. This document is not binding on
the DSL Forum, any of its members, or any developer or service provider.
The document is subject to change, but only with approval of members of
the Forum.
Copyright 2004-2007 Digital Subscriber Line Forum. All Rights Reserved.
DSL Forum XML Schemas may be copied, downloaded, stored on a server or
otherwise re-distributed in their entirety only. The text of this
notice must be included in all copies.
Notwithstanding anything to the contrary, the DSL Forum makes no
representation or warranty, expressed or implied, concerning this
publication, its contents or the completeness, accuracy, or applicability
of any information contained in this publication. No liability of any kind
shall be assumed by the DSL Forum as a result of reliance upon any
information contained in this publication. The DSL Forum does not assume
any responsibility to update or correct any information in this
publication.
Summary:
XML Schema for TR-069 CPE WAN Management Protocol (CWMP) v1.1 RPC requests
and responses.
Version History:
November 2006: cwmp-1-0.xsd, extracted from TR-069 Amendment 1
November 2007: cwmp-1-1.xsd, extracted from TR-069 Amendment 2
-->
<definitions name="cwmp"
targetNamespace="urn:dslforum-org:cwmp-1-1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="urn:dslforum-org:cwmp-1-1"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="urn:dslforum-org:cwmp-1-1"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<import namespace="urn:dslforum-org:cwmp-1-1"
location="cwmp-1-1.xsd"/>
<message name="InformI">
<part name="DeviceId" type="tns:DeviceIdStruct"/>
<part name="Event" type="tns:EventList"/>
<part name="MaxEnvelopesI" type="xs:unsignedInt"/>
<part name="CurrentTime" type="xs:dateTime"/>
<part name="RetryCount" type="xs:unsignedInt"/>
<part name="ParameterList" type="tns:ParameterValueList"/>
</message>
<message name="InformO">
<part name="MaxEnvelopesO" type="xs:unsignedInt"/>
</message>
<portType name="cwmpPortType">
<operation name="Inform">
<documentation>Service definition of function GetRPCMethods</documentation>
<input message="tns:InformI"/>
<output message="tns:InformO"/>
</operation>
</portType>
<binding name="cwmpBinding" type="tns:cwmpPortType">
<SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Inform">
<SOAP:operation style="rpc" soapAction=""/>
<input>
<SOAP:body use="encoded" namespace="urn:dslforum-org:cwmp-1-1" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<SOAP:body use="encoded" namespace="urn:dslforum-org:cwmp-1-1" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="cwmpService">
<documentation>Metanoia cwmp service definition</documentation>
<port name="cwmpPort" binding="tns:cwmpBinding">
<SOAP:address location="http://192.168.2.30:8080/openacs/acs"/>
</port>
</service>
</definitions>

1664
src/wsdl/cwmp-1-1.xsd Normal file

File diff suppressed because it is too large Load diff