| #ifndef __TR069_RPC__ | |
| #define __TR069_RPC__ | |
| #include "tr069_sys.h" | |
| #include<ctype.h> | |
| enum { | |
| TR069OBJ_TYPE_NORMAL, | |
| TR069OBJ_TYPE_INSTANCE | |
| }; | |
| enum { | |
| TR069_TYPE_OBJECT, | |
| TR069_TYPE_PARAMETER | |
| }; | |
| struct tr069_instance { | |
| struct tr069_instance * next; | |
| struct tr069_instance * parent; | |
| unsigned short int id; | |
| void * data; | |
| }; | |
| typedef int (*rpc_get_value)(struct tr069_instance *, char **); | |
| typedef int (*rpc_set_value)(struct tr069_instance *, char *); | |
| struct tr069_param { | |
| const char * name; | |
| int (*set_value)(struct tr069_instance *, char *); /* Callback for Set/Get Value */ | |
| int (*get_value)(struct tr069_instance *, char **); | |
| int rw; /* This param is write able? */ | |
| int type; /* This param type, like string or int or other */ | |
| int size; /* Size of param, if tr069 define */ | |
| int notification; | |
| }; | |
| struct tr069_obj { | |
| const char * name; | |
| int (*add_obj)(struct tr069_obj *, struct tr069_instance *); /* Callback for AddObj/DelObj */ | |
| int (*del_obj)(struct tr069_obj *, struct tr069_instance *); | |
| struct tr069_obj * obj_list; /* Children object list */ | |
| struct tr069_param * param_list; /* Parameter list */ | |
| struct tr069_instance * instance_list; /* Instance list, if Object have instance */ | |
| /* Type of object, like support instance or not support instance */ | |
| int type; | |
| int instance_cnt; | |
| }; | |
| typedef int (*rpc_addobj)(struct tr069_obj *, struct tr069_instance *); | |
| typedef int (*rpc_delobj)(struct tr069_obj *, struct tr069_instance *); | |
| enum { | |
| TR069_OK, | |
| TR069_9000 = 9000, | |
| TR069_9001 = 9001, | |
| TR069_9002 = 9002, | |
| TR069_9003 = 9003, | |
| TR069_9004 = 9004, | |
| TR069_9005 = 9005, | |
| TR069_9006 = 9006, | |
| }; | |
| enum { | |
| TR069_R, | |
| TR069_RW, | |
| }; | |
| enum { | |
| TR069_NOTIFICATION_OFF, | |
| TR069_PASSIVE_NOTIFICATION, | |
| TR069_ACTIVE_NOTIFICATION | |
| }; | |
| enum { | |
| TR069_UNKOWN, | |
| TR069_STRING, | |
| TR069_INT, | |
| TR069_UINT, | |
| TR069_ULONG, | |
| TR069_BOOL, | |
| TR069_DATATIME, | |
| TR069_HEX, | |
| }; | |
| enum { | |
| RPC_TYPE_INVALID, | |
| RPC_TYPE_TRANSFER_COMPLETE_RESPONSE, | |
| RPC_TYPE_FAULT, | |
| RPC_TYPE_INFORM_RESPONSE, | |
| RPC_TYPE_GET_RPC_METHOD, | |
| RPC_TYPE_GET_PARAMETER_NAME, | |
| RPC_TYPE_GET_PARAMETER_VALUE, | |
| RPC_TYPE_SET_PARAMETER_VALUE, | |
| RPC_TYPE_GET_PARAMETER_ATTR, | |
| RPC_TYPE_SET_PARAMETER_ATTR, | |
| RPC_TYPE_REBOOT, | |
| RPC_TYPE_FACTORY_RESET, | |
| RPC_TYPE_DOWNLOAD, | |
| RPC_TYPE_ADD, | |
| RPC_TYPE_DELETE, | |
| }; | |
| struct walk_context { | |
| const char * stack[30]; | |
| int index; | |
| int instance_stack[30]; | |
| int instance_index; | |
| void * userdata; | |
| char tempbuf[256]; | |
| }; | |
| #define UNKNOWN_TIME "0001-01-01T00:00:00Z" | |
| typedef int (*walk_obj_paramet_cb) (struct tr069_obj *, struct tr069_param *, struct tr069_instance *, struct walk_context *, int); | |
| int walk_obj_and_paramet(struct tr069_obj * root, | |
| struct tr069_instance * instance, walk_obj_paramet_cb callback, void * data, int flag); | |
| extern int rpc_add_obj_api(const char * path, int id, struct tr069_instance ** ppis); | |
| extern struct tr069_param * find_param(struct tr069_obj * root, const char * path); | |
| extern struct tr069_obj * find_obj(struct tr069_obj * root, const char * path); | |
| extern const char * rpc_type2string(int); | |
| // System relation... | |
| extern char * __tr069_strdup(const char *s); | |
| extern void __tr069_free(void * p); | |
| extern void * __tr069_malloc(int size); | |
| extern struct tr069_instance * top_instance(void); | |
| extern struct tr069_instance * malloc_instance(struct tr069_obj * obj, struct tr069_instance * parent, int id); | |
| extern int free_instance(struct tr069_obj * obj, struct tr069_instance * is); | |
| #endif |