You are on page 1of 8

Netcwmp

Netcwmp
Netcwmp TR069 Client TR069 RPC

TR069 TR069

ACS
Linux cwmp.conf /etc cwmpd/src/cwmpd.c
main
cwmp_conf_open("/etc/cwmp.conf"); //

cwmp.conf acs_url
acs_url=http://xxx.xxx.xxx.xxx:pppp/

struct parameter_node_st
{
const char * name; //
int
rw;
//read / writable 0 1
int
type;
// string, int
size_t
value_length; //
char *
value; //
parameter_node_attr_t attr; //
parameter_node_t * parent; //
parameter_node_t * child; //
parameter_node_t * prev_sibling; //
parameter_node_t * next_sibling; //
parameter_get_handler_pt
get; //Get GetParameterValues get
NULL value NULL get
parameter_set_handler_pt
set; //Set SetParameterValues Set
NULL value NULL Set
parameter_notify_handler_pt notify; //Notify
parameter_add_handler_pt add; //Add AddObject
parameter_del_handler_pt
del; //Del DeleteObject

parameter_refresh_handler_pt

refresh; //Refresh

cwmp_uint32_t
cwmp_uint32_t
cwmp_uint32_t
cwmp_uint32_t
cwmp_uint32_t

ext0; //
ext1;
ext2;
ext3;
ext4;

};

cwmpd/src/ device.xml

<cwmp>
<model>
<object name=xxx>
<param name=xxx1 />
</object>
</model>
</cwmp>
cwmpd\src\modules\data_model.c cwmp_model_load_from_xml
device.xml
TR-098
XML
object OBJECT attribute
rw: 0 10: 1
type[ int, uint, s, s16, s32, s64, s128, s256, s1024, dt, bool, base]
int
add_func:
del_func:
refresh_func:
InternetGatewayDevice.WANDevice.{i} WANDevice WAN
WAN

param Object attribute


rw:
type:
get_func Get
set_func Set

RPC
1 libcwmp/include/cwmp/types.h
typedef int (*callback_func_t)(void *arg1, void *arg2);
typedef int (*callback_register_func_t)(cwmp_t * cwmp, callback_func_t, void * arg1, void
*arg2);
typedef int
(*parameter_get_handler_pt)(cwmp_t * cwmp, const char * param_name, char **
value, pool_t * pool);
typedef int (*parameter_set_handler_pt)(cwmp_t * cwmp, const char * param_name, const char
* value, int length, callback_register_func_t callback_reg);
typedef int
(*parameter_notify_handler_pt)(cwmp_t * cwmp, const char * param_name, const
char * value, int length, callback_register_func_t callback_reg);
typedef int
(*parameter_add_handler_pt)(cwmp_t * cwmp, parameter_node_t * param_node,
int *pinstance_number, callback_register_func_t callback_reg);
typedef int (*parameter_del_handler_pt)(cwmp_t * cwmp, parameter_node_t * param_node, int
instance_number, callback_register_func_t callback_reg);
typedef int
(*parameter_refresh_handler_pt)(cwmp_t * cwmp, parameter_node_t *
param_node, callback_register_func_t callback_reg );
2 cwmpd/src/modules Get Set
InternetGatewayDevice.DeviceInfo.ManufacturerOUI GetParameterValues
cwmpd/src/modules/InternetGatewayDevice/DeviceInfo/DeviceInfo.c
int cpe_get_igd_di_manufactureroui(cwmp_t * cwmp, const char * name, char ** value, pool_t *
pool)

{
FUNCTION_TRACE();
*value = cwmp_conf_pool_get(pool, "cwmp:cpe_oui");
return
FAULT_CODE_OK;
}
3 cwmpd/src/modules/data_model.c ModelFunction
{"cpe_get_igd_di_manufactureroui", cpe_get_igd_di_manufactureroui},
4 device.xml xml
<param name="ManufacturerOUI"
get_func="cpe_get_igd_di_manufactureroui"></param>
XML cpe_get_igd_di_manufactureroui 3
cpe_get_igd_di_manufactureroui
5 InternetGatewayDevice.c
#include "DeviceInfo/DeviceInfo.c"
6device.xml
device.xml

GetParameterValues
typedef int
(*parameter_get_handler_pt)(cwmp_t * cwmp, const char * param_name,
char ** value, pool_t * pool);
parameter_get_handler_pt

int cpe_get_igd_di_manufactureroui(cwmp_t * cwmp, const char * name, char ** value, pool_t *


pool)
{
FUNCTION_TRACE();
*value = cwmp_conf_pool_get(pool, "cwmp:cpe_oui");
return FAULT_CODE_OK;
}

libcwmp/src/cwmp.c cwmp_get_parameter_node_value
cwmp_t * cwmp cwmp_t
const char * name InternetGatewayDevice.DeviceInfo.SerialNumber
char ** value
pool_t * pool char* value
pool
malloc

int
FAULT_CODE_OK 0
FAULT_CODE libcwmp/include/cwmp/cwmp.h
Get netcwmp GetParameterValues

SetParameterValues
typedef int (*parameter_set_handler_pt)(cwmp_t * cwmp, const char * param_name, const char
* value, int length, callback_register_func_t callback_reg);

parameter_set_handler_pt
int cpe_set_igd_ms_password(cwmp_t * cwmp, const char * name, const char * value, int length,
callback_register_func_t callback_reg)
{
//save password to database or config file
return FAULT_CODE_OK;
}
cwmp_t * cwmp cwmp_t
const char * name InternetGatewayDevice.DeviceInfo.SerialNumber
const char * value
int length
callback_register_func_t callback_reg SetParameterValues
Enable
InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.Enable
SetParameterValues
int
FAULT_CODE_OK 0
FAULT_CODE libcwmp/include/cwmp/cwmp.h
Set SetParameterValues

GetParameterNames
parameter_node_t RPC

Reboot
cwmpd/src/agent.c cwmp_agent_run_tasks
case TASK_REBOOT_TAG:
{
//begin reboot system
cwmp_log_debug("reboot ...");
cwmp_event_set_value(cwmp, INFORM_MREBOOT, 1, NULL, 0, 0, 0);
cwmp_event_clear_active(cwmp);
//system("reboot"); //

Download
RPC
cwmpd/src/agent.c cwmp_agent_run_tasks
case TASK_DOWNLOAD_TAG:
{
download_arg_t * dlarg = (download_arg_t*)data;
//begin download file
time_t starttime = time(NULL);
int faultcode = 0;
faultcode = cwmp_agent_download_file(dlarg);
time_t endtime = time(NULL);
cwmp_event_set_value(cwmp, INFORM_TRANSFERCOMPLETE, 1,dlarg->cmdkey,
faultcode, starttime, endtime);
//
FREE(dlarg);
}

break;

Upload
RPC
cwmpd/src/agent.c int cwmp_agent_upload_file(upload_arg_t * ularg)

GetRPCMethods
libcwmp/src/session.c rpc_methods

Inform
libcwmp/src/session.c
cwmp_session_create_inform_parameters

HTTP

cwmp.conf acs_auth 1
acs_username acs_password

HTTPS
with-openssl openssl

./configure with-openssl=/usr/local/ssl
cwmp.conf acs_url https://xxx.xxx...
ca_file ca_file=/etc/ssl/private/ca.pem

You might also like