Fix ACR issues
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 22 Mar 2017 12:38:11 +0000 (21:38 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 11 May 2017 09:07:20 +0000 (18:07 +0900)
 - Change parameters related Global Command from structure to void

Change-Id: I52b3bbf5bdd9d9bdc9ef6dfd3d5729f794a9bcda
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
include/zcl/zb_zcl_type.h
lib/zbl_dbus.c
lib/zbl_dbus.h
lib/zbl_zcl.c

index 191c52abe937a38ceec799cb8a8241231b41ee82..c7e7b45ff3b50e2905222defd8c5ea7f3a6e2722 100644 (file)
@@ -150,7 +150,7 @@ typedef enum {
  *
  * @since_tizen 4.0
  */
-typedef struct discover_attribute_info_record_s* discover_attr_info_record_h;
+typedef void* discover_attr_info_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -158,7 +158,7 @@ typedef struct discover_attribute_info_record_s* discover_attr_info_record_h;
  *
  * @since_tizen 4.0
  */
-typedef struct read_structured_attribute_record_s* read_structured_attr_record_h;
+typedef void* read_structured_attr_record_h;
 
 
 /**
@@ -167,7 +167,7 @@ typedef struct read_structured_attribute_record_s* read_structured_attr_record_h
  *
  * @since_tizen 4.0
  */
-typedef struct read_attribute_status_record_s* read_attr_status_record_h;
+typedef void* read_attr_status_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -175,7 +175,7 @@ typedef struct read_attribute_status_record_s* read_attr_status_record_h;
  *
  * @since_tizen 4.0
  */
-typedef struct write_attribute_record_s* write_attr_record_h;
+typedef void* write_attr_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -183,7 +183,7 @@ typedef struct write_attribute_record_s* write_attr_record_h;
  *
  * @since_tizen 4.0
  */
-typedef struct write_attribute_status_record_s* write_attr_status_record_h;
+typedef void* write_attr_status_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -191,7 +191,7 @@ typedef struct write_attribute_status_record_s* write_attr_status_record_h;
  *
  * @since_tizen 4.0
  */
-typedef struct write_attribute_structured_status_record_s* write_attr_structured_status_record_h;
+typedef void* write_attr_structured_status_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -199,7 +199,7 @@ typedef struct write_attribute_structured_status_record_s* write_attr_structured
  *
  * @since_tizen 4.0
  */
-typedef struct write_attribute_structured_record_s* write_attr_structured_record_h;
+typedef void* write_attr_structured_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -207,7 +207,7 @@ typedef struct write_attribute_structured_record_s* write_attr_structured_record
  *
  * @since_tizen 4.0
  */
-typedef struct attribute_report_s* attr_report_h;
+typedef void* attr_report_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -215,7 +215,7 @@ typedef struct attribute_report_s* attr_report_h;
  *
  * @since_tizen 4.0
  */
-typedef struct reporting_configuration_record_s* report_config_record_h;
+typedef void* report_config_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -223,7 +223,7 @@ typedef struct reporting_configuration_record_s* report_config_record_h;
  *
  * @since_tizen 4.0
  */
-typedef struct read_reporting_configuration_record_s* read_report_config_record_h;
+typedef void* read_report_config_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -231,7 +231,7 @@ typedef struct read_reporting_configuration_record_s* read_report_config_record_
  *
  * @since_tizen 4.0
  */
-typedef struct reporting_configuration_response_record_s* report_config_response_record_h;
+typedef void* report_config_response_record_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -239,7 +239,7 @@ typedef struct reporting_configuration_response_record_s* report_config_response
  *
  * @since_tizen 4.0
  */
-typedef struct extended_attribute_infomation_s* extended_attr_info_h;
+typedef void* extended_attr_info_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -247,7 +247,7 @@ typedef struct extended_attribute_infomation_s* extended_attr_info_h;
  *
  * @since_tizen 4.0
  */
-typedef struct zb_value_s* zb_value_h;
+typedef void* zb_value_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
@@ -255,7 +255,7 @@ typedef struct zb_value_s* zb_value_h;
  *
  * @since_tizen 4.0
  */
-typedef struct attribute_array_s* attribute_array_h;
+typedef void* attribute_array_h;
 
 /**
  * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE
index 1e9973f673b5b928b93b5adf99281dc150d21fb5..be28d60b84cef3c5c156ac4e9d7a9a6be606fd48 100644 (file)
@@ -707,12 +707,12 @@ static void _zbl_signal_handler(GDBusConnection *connection,
                GVariantIter *dataType_iter = NULL;
                GVariantIter *data_iter = NULL;
 
-               attr_report_h *records = NULL;
+               struct attribute_report_s **records = NULL;
 
                g_variant_get(parameters, "(qyqaqayayi)",  &addr16, &ep,
                         &cluster_id, &attr_iter, &dataType_iter, &data_iter, &records_len);
 
-               records = calloc(records_len, sizeof(attr_report_h));
+               records = calloc(records_len, sizeof(struct attribute_report_s));
                RETM_IF(NULL == records, "calloc() Fail(%d)", errno);
                for (j = 0; j < records_len; j++) {
                        records[j] = calloc(1, sizeof(struct attribute_report_s));
@@ -2132,11 +2132,12 @@ MGMT_NWK_DISC_REQ_OUT:
                unsigned char attr_value[128];
 
                GVariantIter *iter = NULL;
-               read_attr_status_record_h records;
+               struct read_attribute_status_record_s *records = NULL;
                zb_global_record_data_s *data;
 
                data = calloc(1, sizeof(zb_global_record_data_s));
                records = calloc(1, sizeof(struct read_attribute_status_record_s));
+
                if (!records || !data) {
                        ERR("calloc() Fail(%d)", errno);
                        goto GLOBAL_READ_ATTRIBUTE_REQ_OUT;
@@ -2169,7 +2170,7 @@ MGMT_NWK_DISC_REQ_OUT:
                records->type = type;
                records->value = attr_value;
                data->type = ZB_GLOBAL_READ_ATTR;
-               data->record.read_attr = &records;
+               data->record.read_attr = (void **)&records;
                data->records_len = records_len;
 
                cb(addr16, ep, cluster_id, data, records_len, container->userdata);
@@ -2194,7 +2195,7 @@ GLOBAL_READ_ATTRIBUTE_REQ_OUT:
 
                GVariantIter *stat_iter = NULL;
                GVariantIter *attr_iter = NULL;
-               write_attr_status_record_h records;
+               struct write_attribute_status_record_s *records = NULL;
                zb_global_record_data_s *data;
 
                g_variant_get(parameters, "(qya(y)aqqi)",
@@ -2228,7 +2229,7 @@ GLOBAL_READ_ATTRIBUTE_REQ_OUT:
                        g_variant_iter_free(attr_iter);
 
                data->type = ZB_GLOBAL_WRITE_ATTR;
-               data->record.write_attr = &records;
+               data->record.write_attr = (void **)&records;
                data->records_len = records_len;
 
                cb(addr16, ep, cluster_id, data, records_len, container->userdata);
@@ -2249,7 +2250,7 @@ GLOBAL_WRITE_ATTRIBUTE_REQ_OUT:
                GVariantIter *stat_iter = NULL;
                GVariantIter *attr_iter = NULL;
                GVariantIter *dir_iter = NULL;
-               report_config_response_record_h records;
+               struct reporting_configuration_response_record_s *records = NULL;
                zb_global_record_data_s *data;
 
                g_variant_get(parameters, "(a(y)aqa(y)qiqy)",
@@ -2293,7 +2294,7 @@ GLOBAL_WRITE_ATTRIBUTE_REQ_OUT:
                        g_variant_iter_free(dir_iter);
 
                data->type = ZB_GLOBAL_CONFIG_REPORT;
-               data->record.report_config_rsp = &records;
+               data->record.report_config_rsp = (void **)&records;
                data->records_len = rec_len;
 
                cb(addr16, ep, cluster_id, data, rec_len, container->userdata);
@@ -2307,7 +2308,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                zb_zcl_global_discover_attr_rsp cb = container->cb;
                nwk_addr addr16;
                unsigned char ep;
-               discover_attr_info_record_h *records;
+               struct discover_attribute_info_record_s **records = NULL;
 
                int records_len;
                unsigned short cluster_id;
@@ -2354,7 +2355,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                if (NULL != attr_iter)
                        g_variant_iter_free(attr_iter);
 
-               cb(addr16, ep, cluster_id, discovery_complete, records, records_len,
+               cb(addr16, ep, cluster_id, discovery_complete, (void *)records, records_len,
                        container->userdata);
 
                for (j = 0; j < records_len; j++)
@@ -2423,7 +2424,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                GVariantIter *attr_iter = NULL;
                GVariantIter *type_iter = NULL;
                GVariantIter *ac_iter = NULL;
-               extended_attr_info_h *records;
+               struct extended_attribute_infomation_s **records = NULL;
 
                DBG("Will get the value now");
 
@@ -2471,7 +2472,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                if (NULL != ac_iter)
                        g_variant_iter_free(ac_iter);
 
-               cb(addr16, ep, cluster_id, discoveryComplete, records, rec_len, container->userdata);
+               cb(addr16, ep, cluster_id, discoveryComplete, (void *)records, rec_len, container->userdata);
 
                for (j = 0; j < rec_len; j++)
                        free(records[j]);
@@ -2494,7 +2495,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                GVariantIter *resp_iter = NULL;
                GVariantIter *data_iter = NULL;
 
-               report_config_record_h *records = NULL;
+               struct reporting_configuration_record_s **records = NULL;
                zb_global_record_data_s *data = NULL;
 
                g_variant_get(parameters, "(qyqqa(yyqyqqayq))",
@@ -2555,7 +2556,7 @@ GLOBAL_CONFIGURE_REPORTING_REQ_OUT:
                        g_variant_iter_free(resp_iter);
 
                data->type = ZB_GLOBAL_READ_REPORT_CONFIG;
-               data->record.report_config = records;
+               data->record.report_config = (void **)records;
                data->records_len = record_length;
 
                cb(addr16, ep, cluster_id, data, record_length, container->userdata);
@@ -5053,9 +5054,10 @@ int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest
        return result;
 }
 
-int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep,
-               unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records,
-               int records_len, zb_zcl_global_rsp cb, void *user_data)
+int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
+               unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
+               void **data, int records_len, zb_zcl_global_rsp cb,
+               void *user_data)
 {
        int sub_id, to;
        zbl_req_cb_s *container;
@@ -5064,6 +5066,8 @@ int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, u
        GVariant *variant = NULL;
        GError *dbus_err = NULL;
 
+       struct write_attribute_record_s **records = (struct write_attribute_record_s **)data;
+
 #ifdef ZB_FEATURE_GLOBAL_RSP_SYNC
        zb_event_global_default_rsp_s *global_req = NULL;
 #endif
@@ -5234,7 +5238,7 @@ int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, u
 
 int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               write_attr_record_h *records, int records_len,
+               void **data, int records_len,
                zb_zcl_global_rsp cb, void *user_data)
 {
        int sub_id, to;
@@ -5244,6 +5248,8 @@ int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_
        GVariant *variant = NULL;
        GError *dbus_err = NULL;
 
+       struct write_attribute_record_s **records = (struct write_attribute_record_s **)data;
+
 #ifdef ZB_FEATURE_GLOBAL_RSP_SYNC
        zb_event_global_default_rsp_s *global_req = NULL;
 #endif
@@ -5414,12 +5420,14 @@ int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_
 
 int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               write_attr_record_h *records, int records_len)
+               void **data, int records_len)
 {
        int result = ZIGBEE_ERROR_NONE;
        GError *dbus_err = NULL;
        GVariant *variant = NULL;
 
+       struct write_attribute_record_s **records = (struct write_attribute_record_s **)data;
+
        RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR);
        RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR);
 
@@ -5533,7 +5541,7 @@ int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
 
 int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               report_config_record_h *records, int records_len,
+               void **data, int records_len,
                zb_zcl_global_rsp cb, void *user_data)
 {
        int sub_id, to;
@@ -5543,6 +5551,9 @@ int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_
        GVariant *variant = NULL;
        GError *dbus_err = NULL;
 
+       struct reporting_configuration_record_s **records =
+               (struct reporting_configuration_record_s **)data;
+
 #ifdef ZB_FEATURE_GLOBAL_RSP_SYNC
        zb_event_global_default_rsp_s *global_req = NULL;
 #endif
@@ -5655,7 +5666,7 @@ int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_
 
 int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               read_report_config_record_h *records, int records_len,
+               void **data, int records_len,
                zb_zcl_global_rsp cb, void *user_data)
 {
        int sub_id, to;
@@ -5665,6 +5676,9 @@ int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char
        GVariant *variant = NULL;
        GError *dbus_err = NULL;
 
+       struct read_reporting_configuration_record_s **records =
+               (struct read_reporting_configuration_record_s **)data;
+
 #ifdef ZB_FEATURE_GLOBAL_RSP_SYNC
        zb_event_global_default_rsp_s *global_req = NULL;
 #endif
index f2d8634b6e81e10b5beec8c036b4ee3b5d1bbcbf..90728cebf02ef4cb2a8f25e941abe5dc6fb2e4e6 100644 (file)
@@ -103,22 +103,22 @@ int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest
                unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids,
                int attribute_ids_len, zb_zcl_global_rsp cb, void *user_data);
 int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep,
-               unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records,
+               unsigned char zcl_frame_ctl, unsigned short cluster_id, void **records,
                int records_len, zb_zcl_global_rsp cb, void *user_data);
 int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               write_attr_record_h *records, int records_len,
+               void **records, int records_len,
                zb_zcl_global_rsp cb, void *user_data);
 int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               write_attr_record_h *records, int records_len);
+               void **records, int records_len);
 int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16,
                unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl,
-               unsigned short cluster_id, report_config_record_h *records, int records_len,
+               unsigned short cluster_id, void **records, int records_len,
                zb_zcl_global_rsp cb, void *user_data);
 int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep,
                unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
-               read_report_config_record_h *records, int records_len,
+               void **records, int records_len,
                zb_zcl_global_rsp cb, void *user_data);
 int zbl_discover_attr_req(zigbee_h handle, unsigned short addr16, unsigned char src_ep,
                unsigned char dest_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id,
index 5bcfcaebf28446c2f77ccdea5b7c60cf33eed8a8..e49a9ff2c34a4d69da76df04543b48a25c6817d9 100644 (file)
@@ -437,60 +437,67 @@ API int zb_create_read_attr_status_record(read_attr_status_record_h *handle)
 
 API void zb_destroy_read_attr_status_record(read_attr_status_record_h handle)
 {
-       RET_IF(NULL == handle);
-       if (handle->value)
-               free(handle->value);
-       free(handle);
+       struct read_attribute_status_record_s* h = handle;
+       RET_IF(NULL == h);
+       if (h->value)
+               free(h->value);
+       free(h);
 }
 
 API int zb_get_id_from_read_attr_status_record(read_attr_status_record_h handle,
                unsigned short* id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_read_attr_status_record(read_attr_status_record_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_status_from_read_attr_status_record(read_attr_status_record_h handle,
                unsigned char* status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *status = handle->status;
+       *status = h->status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_status_to_read_attr_status_record(read_attr_status_record_h handle,
                unsigned char status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->status = status;
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->status = status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_type_from_read_attr_status_record(read_attr_status_record_h handle,
                unsigned char *type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *type = handle->type;
+       *type = h->type;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_type_to_read_attr_status_record(read_attr_status_record_h handle,
                unsigned char type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       struct read_attribute_status_record_s* h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -498,62 +505,64 @@ API int zb_get_value_from_read_attr_status_record(read_attr_status_record_h hand
                unsigned char type, zb_value_h value)
 {
        int len = -1;
+       struct zb_value_s *v = value;
+       struct read_attribute_status_record_s* h = handle;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
 
        len = zb_get_data_size(type);
        if (0 < len) {
-               memcpy(value->val, handle->value, len);
-               value->size = len;
-               value->type = type;
+               memcpy(v->val, h->value, len);
+               v->size = len;
+               v->type = type;
        } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
-               if (value->str) {
-                       if (value->str->v)
-                               free(value->str->v);
-                       free(value->str);
+               if (v->str) {
+                       if (v->str->v)
+                               free(v->str->v);
+                       free(v->str);
                }
-               value->str = calloc(1, sizeof(struct attribute_str_s));
-               RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               value->str->n = *handle->value;
+               v->str = calloc(1, sizeof(struct attribute_str_s));
+               RETV_IF(NULL == v->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               v->str->n = *h->value;
                /* The first 1 byte indicate invalid or length of string */
-               if (0xff == value->str->n) {
-                       free(value->str);
+               if (0xff == v->str->n) {
+                       free(v->str);
                        return ZIGBEE_ERROR_NO_DATA;
                }
-               value->str->v = calloc(value->str->n+1, 1);
-               if (NULL == value->str->v) {
-                       free(value->str);
+               v->str->v = calloc(v->str->n+1, 1);
+               if (NULL == v->str->v) {
+                       free(v->str);
                        return ZIGBEE_ERROR_OUT_OF_MEMORY;
                }
-               memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n);
+               memcpy(v->str->v, h->value+sizeof(v->str->n), v->str->n);
 
-               value->type = type;
-               value->size = value->str->n;
+               v->type = type;
+               v->size = v->str->n;
        } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
-               if (value->wstr) {
-                       if (value->wstr->v)
-                               free(value->wstr->v);
-                       free(value->wstr);
+               if (v->wstr) {
+                       if (v->wstr->v)
+                               free(v->wstr->v);
+                       free(v->wstr);
                }
-               value->wstr = calloc(1, sizeof(struct attribute_wstr_s));
-               RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               value->wstr->n = *(handle->value+1) << 8 | *handle->value;
+               v->wstr = calloc(1, sizeof(struct attribute_wstr_s));
+               RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               v->wstr->n = *(h->value+1) << 8 | *h->value;
                /* The first 2 byte indicate invalid or length of string */
-               if (0xffff == value->wstr->n) {
-                       free(value->wstr);
+               if (0xffff == v->wstr->n) {
+                       free(v->wstr);
                        return ZIGBEE_ERROR_NO_DATA;
                }
-               value->wstr->v = calloc(value->wstr->n+1, 1);
-               if (NULL == value->wstr->v) {
-                       free(value->wstr);
+               v->wstr->v = calloc(v->wstr->n+1, 1);
+               if (NULL == v->wstr->v) {
+                       free(v->wstr);
                        return ZIGBEE_ERROR_OUT_OF_MEMORY;
                }
-               memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n);
+               memcpy(v->wstr->v, h->value+sizeof(v->wstr->n), v->wstr->n);
 
-               value->type = type;
-               value->size = value->wstr->n;
+               v->type = type;
+               v->size = v->wstr->n;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -564,33 +573,35 @@ API int zb_set_value_to_read_attr_status_record(read_attr_status_record_h handle
                unsigned char type, zb_value_h value)
 {
        int len = -1;
+       struct zb_value_s *v = value;
+       struct read_attribute_status_record_s* h = handle;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       if (handle->value)
-               free(handle->value);
+       if (h->value)
+               free(h->value);
 
        len = zb_get_data_size(type);
        if (0 < len) {
-               handle->value = calloc(len, sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->value, value->val, len);
+               h->value = calloc(len, sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->value, v->val, len);
        } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
-               RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
-               handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               handle->value[0] = value->str->n;
-               memcpy(handle->value + sizeof(value->str->n),
-                       value->str->v+sizeof(value->str->n), value->str->n);
+               RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
+               h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value[0] = v->str->n;
+               memcpy(h->value + sizeof(v->str->n),
+                       v->str->v+sizeof(v->str->n), v->str->n);
        } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
-               RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
-               handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               handle->value[0] = value->wstr->n & 0xff;
-               handle->value[1] = (value->wstr->n >> 8) & 0xff ;
-               memcpy(handle->value + sizeof(value->wstr->n),
-                       value->wstr->v+sizeof(value->wstr->n), value->wstr->n);
+               RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
+               h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value[0] = v->wstr->n & 0xff;
+               h->value[1] = (v->wstr->n >> 8) & 0xff ;
+               memcpy(h->value + sizeof(v->wstr->n),
+                       v->wstr->v+sizeof(v->wstr->n), v->wstr->n);
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -608,69 +619,72 @@ API int zb_create_value(zb_value_h *handle)
 
 API void zb_destroy_value(zb_value_h handle)
 {
-       RET_IF(NULL == handle);
-       if (handle->str) {
-               if (handle->str->v)
-                       free(handle->str->v);
-               free(handle->str);
+       struct zb_value_s* h = handle;
+
+       RET_IF(NULL == h);
+       if (h->str) {
+               if (h->str->v)
+                       free(h->str->v);
+               free(h->str);
        }
-       if (handle->wstr) {
-               if (handle->wstr->v)
-                       free(handle->wstr->v);
-               free(handle->wstr);
+       if (h->wstr) {
+               if (h->wstr->v)
+                       free(h->wstr->v);
+               free(h->wstr);
        }
-       free(handle);
+       free(h);
 }
 
 API int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value,
                int count)
 {
        int len = -1;
+       struct zb_value_s* h = handle;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
 
        len = zb_get_data_size(type);
        if (0 < len) {
-               memcpy(handle->val, value, len);
-               handle->size = len;
-               handle->type = type;
+               memcpy(h->val, value, len);
+               h->size = len;
+               h->type = type;
        } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
-               if (handle->str) {
-                       if (handle->str->v)
-                               free(handle->str->v);
-                       free(handle->str);
+               if (h->str) {
+                       if (h->str->v)
+                               free(h->str->v);
+                       free(h->str);
                }
                /* string size exception case */
-               RETV_IF(0xff - 1 < handle->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
-               handle->str = malloc(sizeof(struct attribute_str_s));
-               RETV_IF(NULL == handle->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               handle->str->n = count;
+               RETV_IF(0xff - 1 < h->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+               h->str = malloc(sizeof(struct attribute_str_s));
+               RETV_IF(NULL == h->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->str->n = count;
                /* The first 1 byte indicate invalid or length of string */
-               handle->str->v = calloc(sizeof(unsigned char), handle->str->n + sizeof(handle->str->n));
-               RETV_IF(NULL == handle->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->str->v, value+sizeof(handle->str->n), handle->str->n);
+               h->str->v = calloc(sizeof(unsigned char), h->str->n + sizeof(h->str->n));
+               RETV_IF(NULL == h->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->str->v, value+sizeof(h->str->n), h->str->n);
 
-               handle->type = type;
-               handle->size = count;
+               h->type = type;
+               h->size = count;
        } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) {
-               if (handle->wstr) {
-                       if (handle->wstr->v)
-                               free(handle->wstr->v);
-                       free(handle->wstr);
+               if (h->wstr) {
+                       if (h->wstr->v)
+                               free(h->wstr->v);
+                       free(h->wstr);
                }
                /* 2 byte string size exception case */
-               RETV_IF(0xffff - 1 < handle->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
-               handle->wstr = malloc(sizeof(struct attribute_wstr_s));
-               RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               handle->wstr->n = count;
+               RETV_IF(0xffff - 1 < h->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+               h->wstr = malloc(sizeof(struct attribute_wstr_s));
+               RETV_IF(NULL == h->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->wstr->n = count;
                /* The first 2 byte indicate invalid or length of string */
-               handle->wstr->v = calloc(sizeof(unsigned char), handle->wstr->n + sizeof(handle->wstr->n));
-               RETV_IF(NULL == handle->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->wstr->v, value+sizeof(handle->wstr->n), handle->wstr->n);
+               h->wstr->v = calloc(sizeof(unsigned char), h->wstr->n + sizeof(h->wstr->n));
+               RETV_IF(NULL == h->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->wstr->v, value+sizeof(h->wstr->n), h->wstr->n);
 
-               handle->type = type;
-               handle->size = count;
+               h->type = type;
+               h->size = count;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -682,31 +696,32 @@ API int zb_get_value(zb_value_h handle, unsigned char *type, unsigned char **val
 {
        int len = -1;
        unsigned char *s = NULL;
+       struct zb_value_s* h = handle;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       len = zb_get_data_size(handle->type);
+       len = zb_get_data_size(h->type);
        if (0 < len) {
-               s = calloc(handle->size + 1 , sizeof(char));
-               memcpy(s, handle->val, len);
+               s = calloc(h->size + 1 , sizeof(char));
+               memcpy(s, h->val, len);
                *count = len;
-       } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == handle->str, ZIGBEE_ERROR_NO_DATA);
-               s = calloc(sizeof(unsigned char), handle->str->n);
+       } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == h->str, ZIGBEE_ERROR_NO_DATA);
+               s = calloc(sizeof(unsigned char), h->str->n);
                RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(s, handle->str->v+sizeof(handle->str->n), handle->str->n);
-               *count = handle->str->n;
-       } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_NO_DATA);
-               s = calloc(sizeof(unsigned char), handle->wstr->n);
+               memcpy(s, h->str->v+sizeof(h->str->n), h->str->n);
+               *count = h->str->n;
+       } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == h->wstr, ZIGBEE_ERROR_NO_DATA);
+               s = calloc(sizeof(unsigned char), h->wstr->n);
                RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(s, handle->wstr->v+sizeof(handle->wstr->n), handle->wstr->n);
-               *count = handle->wstr->n;
+               memcpy(s, h->wstr->v+sizeof(h->wstr->n), h->wstr->n);
+               *count = h->wstr->n;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
-       *type = handle->type;
+       *type = h->type;
        *value = s;
 
        return ZIGBEE_ERROR_NONE;
@@ -724,16 +739,18 @@ API int zb_create_discover_attr_info(discover_attr_info_record_h *handle)
 
 API void zb_destroy_discover_attr_info(discover_attr_info_record_h handle)
 {
-       free(handle);
+       struct discover_attribute_info_record_s *h = handle;
+       free(h);
 }
 
 API int zb_get_id_from_discover_attr_info(
                discover_attr_info_record_h handle,
                unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct discover_attribute_info_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -741,8 +758,9 @@ API int zb_set_id_to_discover_attr_info(
                discover_attr_info_record_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct discover_attribute_info_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -750,9 +768,10 @@ API int zb_get_type_from_discover_attr_info(
                discover_attr_info_record_h handle,
                unsigned char *type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct discover_attribute_info_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *type = handle->type;
+       *type = h->type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -760,8 +779,9 @@ API int zb_set_type_to_discover_attr_info(
                discover_attr_info_record_h handle,
                unsigned char type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       struct discover_attribute_info_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -777,25 +797,28 @@ API int zb_create_write_attr_record(
 
 API void zb_destroy_write_attr_record(write_attr_record_h handle)
 {
-       RET_IF(NULL == handle);
-       if (handle->value)
-               free(handle->value);
-       free(handle);
+       struct write_attribute_record_s* h = handle;
+       RET_IF(NULL == h);
+       if (h->value)
+               free(h->value);
+       free(h);
 }
 
 API int zb_set_id_to_write_attr_record(write_attr_record_h handle,
                unsigned short id)
 {
+       struct write_attribute_record_s* h = handle;
        RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_type_to_write_attr_record(write_attr_record_h handle,
                unsigned char type)
 {
+       struct write_attribute_record_s* h = handle;
        RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -803,29 +826,31 @@ API int zb_set_buf_to_write_attr_record(write_attr_record_h handle,
        unsigned char type, unsigned char *value, int count)
 {
        int len = -1;
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct write_attribute_record_s* h = handle;
+
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       if (handle->value)
-               free(handle->value);
+       if (h->value)
+               free(h->value);
 
        len = zb_get_data_size(type);
        if (0 < len) {
-               handle->value = calloc(count + 1 , sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->value, value, count);
+               h->value = calloc(count + 1 , sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->value, value, count);
        } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) {
-               handle->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 1 byte indicate invalid or length of string */
-               handle->value[0] = count & 0xff;
-               memcpy(handle->value + sizeof(unsigned char), value + sizeof(unsigned char), count);
-       } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
-               handle->value = calloc(count + sizeof(unsigned short)  + 1, sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value[0] = count & 0xff;
+               memcpy(h->value + sizeof(unsigned char), value + sizeof(unsigned char), count);
+       } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+               h->value = calloc(count + sizeof(unsigned short)  + 1, sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 2 byte indicate invalid or length of string */
-               handle->value[0] = count & 0xff;
-               handle->value[1] = (count >> 8) & 0xff ;
-               memcpy(handle->value + sizeof(unsigned short), value + sizeof(unsigned short), count);
+               h->value[0] = count & 0xff;
+               h->value[1] = (count >> 8) & 0xff ;
+               memcpy(h->value + sizeof(unsigned short), value + sizeof(unsigned short), count);
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -836,39 +861,42 @@ API int zb_set_value_to_write_attr_record(write_attr_record_h handle, zb_value_h
 {
        int len = -1;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct zb_value_s *v = value;
+       struct write_attribute_record_s* h = handle;
+
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       if (handle->value)
-               free(handle->value);
+       if (h->value)
+               free(h->value);
 
-       len = zb_get_data_size(value->type);
+       len = zb_get_data_size(v->type);
        if (0 < len) {
-               handle->value = calloc(value->size + 1 , sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->value, value->val, value->size);
-               handle->type = value->type;
-       } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
+               h->value = calloc(v->size + 1 , sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->value, v->val, v->size);
+               h->type = v->type;
+       } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
                /* 1 byte string size exception case */
-               RETV_IF(0xff - 1 < value->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
-               handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               RETV_IF(0xff - 1 < v->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+               h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 1 byte indicate invalid or length of string */
-               handle->value[0] = value->str->n & 0xff;
-               memcpy(handle->value + sizeof(value->str->n),
-                       value->str->v + sizeof(value->str->n), value->str->n);
-       } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
+               h->value[0] = v->str->n & 0xff;
+               memcpy(h->value + sizeof(v->str->n),
+                       v->str->v + sizeof(v->str->n), v->str->n);
+       } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
                /* 2 byte string size exception case */
-               RETV_IF(0xffff - 1 < value->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
-               handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               RETV_IF(0xffff - 1 < v->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE);
+               h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 2 byte indicate invalid or length of string */
-               handle->value[0] = value->wstr->n & 0xff;
-               handle->value[1] = (value->wstr->n >> 8) & 0xff ;
-               memcpy(handle->value + sizeof(value->wstr->n),
-                       value->wstr->v + sizeof(value->wstr->n), value->wstr->n);
+               h->value[0] = v->wstr->n & 0xff;
+               h->value[1] = (v->wstr->n >> 8) & 0xff ;
+               memcpy(h->value + sizeof(v->wstr->n),
+                       v->wstr->v + sizeof(v->wstr->n), v->wstr->n);
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -887,40 +915,45 @@ API int zb_create_write_attr_status(write_attr_status_record_h *handle)
 
 API void zb_destroy_write_attr_status(write_attr_status_record_h handle)
 {
-       free(handle);
+       struct write_attribute_status_record_s *h = handle;
+       free(h);
 }
 
 API int zb_get_status_from_write_attr_status(write_attr_status_record_h handle,
                unsigned char *status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct write_attribute_status_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *status = handle->status;
+       *status = h->status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_status_to_write_attr_status(write_attr_status_record_h handle,
                unsigned char status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->status = status;
+       struct write_attribute_status_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->status = status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_write_attr_status(write_attr_status_record_h handle,
                unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct write_attribute_status_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_write_attr_status(write_attr_status_record_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct write_attribute_status_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -936,46 +969,51 @@ API int zb_create_report_config_record(report_config_record_h *handle)
 
 API void zb_destroy_report_config_record(report_config_record_h handle)
 {
-       RET_IF(NULL == handle);
-       if (handle->change)
-               free(handle->change);
-       free(handle);
+       struct reporting_configuration_record_s *h = handle;
+       RET_IF(NULL == h);
+       if (h->change)
+               free(h->change);
+       free(h);
 }
 
 API int zb_get_dir_from_report_config_record(report_config_record_h handle,
                unsigned char *dir)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *dir = handle->dir;
+       *dir = h->dir;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_dir_to_report_config_record(report_config_record_h handle,
                unsigned char dir)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        if (dir == ZB_ZCL_CLIENT_TO_SERVER)
-               handle->dir = 0x00 ;
+               h->dir = 0x00 ;
        else
-               handle->dir = 0x01;
+               h->dir = 0x01;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_report_config_record(report_config_record_h handle,
                unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_report_config_record(report_config_record_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id ;
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id ;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -983,17 +1021,19 @@ API int zb_set_id_to_report_config_record(report_config_record_h handle,
 API int zb_get_type_from_report_config_record(report_config_record_h handle,
                unsigned char *type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *type = handle->type;
+       *type = h->type;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_type_to_report_config_record(report_config_record_h handle,
                unsigned char type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -1001,51 +1041,57 @@ API int zb_set_type_to_report_config_record(report_config_record_h handle,
 API int zb_get_min_i_from_report_config_record(report_config_record_h handle,
                unsigned short *min_i)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == min_i, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *min_i = handle->min_i;
+       *min_i = h->min_i;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_min_i_to_report_config_record(report_config_record_h handle,
                unsigned short min_i)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->min_i = min_i;
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->min_i = min_i;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_max_i_from_report_config_record(report_config_record_h handle,
                unsigned short *max_i)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == max_i, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *max_i = handle->max_i;
+       *max_i = h->max_i;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_max_i_to_report_config_record(report_config_record_h handle,
                unsigned short max_i)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->max_i = max_i;
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->max_i = max_i;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_timeout_from_report_config_record(report_config_record_h handle,
                unsigned short *to)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == to, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *to = handle->to;
+       *to = h->to;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_timeout_to_report_config_record(report_config_record_h handle,
                unsigned short to)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->to = to;
+       struct reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->to = to;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -1054,19 +1100,21 @@ API int zb_get_change_from_report_config_record1(report_config_record_h handle,
 {
        int len = -1;
        int data_type = DATA_TYPE_NONE;
+       struct zb_value_s *v = value;
+       struct reporting_configuration_record_s *h = handle;
 
        NOT_USED(data_type);
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
 
-       len = zb_get_data_size(handle->type);
-       data_type = zb_get_analog_or_discret(handle->type);
+       len = zb_get_data_size(h->type);
+       data_type = zb_get_analog_or_discret(h->type);
        if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
-               memcpy(value->val, handle->change, len);
-               value->type = handle->type;
-               value->size = len;
+               memcpy(v->val, h->change, len);
+               v->type = h->type;
+               v->size = len;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -1079,21 +1127,24 @@ API int zb_set_change_to_report_config_record1(report_config_record_h handle,
        int len = -1;
        int data_type = DATA_TYPE_NONE;
 
+       struct zb_value_s *v = value;
+       struct reporting_configuration_record_s *h = handle;
+
        NOT_USED(data_type);
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       if (handle->change)
-               free(handle->change);
+       if (h->change)
+               free(h->change);
 
-       len = zb_get_data_size(value->type);
-       data_type = zb_get_analog_or_discret(value->type);
+       len = zb_get_data_size(v->type);
+       data_type = zb_get_analog_or_discret(v->type);
        if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
-               handle->change = calloc(len + 1, sizeof(char));
-               RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
-               memcpy(handle->change, value->val, len);
-               handle->type = value->type;
+               h->change = calloc(len + 1, sizeof(char));
+               RETVM_IF(NULL == h->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
+               memcpy(h->change, v->val, len);
+               h->type = v->type;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -1107,20 +1158,22 @@ API int zb_get_change_from_report_config_record2(report_config_record_h handle,
        int data_type = DATA_TYPE_NONE;
        unsigned char *t = NULL;
 
+       struct reporting_configuration_record_s *h = handle;
+
        NOT_USED(data_type);
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+       RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
 
-       len = zb_get_data_size(handle->type);
-       data_type = zb_get_analog_or_discret(handle->type);
+       len = zb_get_data_size(h->type);
+       data_type = zb_get_analog_or_discret(h->type);
        if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
                t = calloc(len + 1, sizeof(char));
                RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
-               memcpy(t, handle->change, len);
+               memcpy(t, h->change, len);
                *value = t;
-               *type = handle->type;
+               *type = h->type;
                *size = len;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
@@ -1133,20 +1186,22 @@ API int zb_set_change_to_report_config_record2(
        int len = -1;
        int data_type = DATA_TYPE_NONE;
 
+       struct reporting_configuration_record_s *h = handle;
+
        NOT_USED(data_type);
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       if (handle->change)
-               free(handle->change);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       if (h->change)
+               free(h->change);
 
        len = zb_get_data_size(type);
        data_type = zb_get_analog_or_discret(type);
 
        if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
-               handle->change = calloc(len + 1, sizeof(unsigned char));
-               RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
-               memcpy(handle->change, value, len);
-               handle->type = type;
+               h->change = calloc(len + 1, sizeof(unsigned char));
+               RETVM_IF(NULL == h->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno);
+               memcpy(h->change, value, len);
+               h->type = type;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -1159,17 +1214,19 @@ API int zb_get_change_from_report_config_record3(report_config_record_h handle,
        int len = -1;
        int data_type = DATA_TYPE_NONE;
 
+       struct reporting_configuration_record_s *h = handle;
+
        NOT_USED(data_type);
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA);
+       RETV_IF(NULL == h->change, ZIGBEE_ERROR_NO_DATA);
 
-       len = zb_get_data_size(handle->type);
-       data_type = zb_get_analog_or_discret(handle->type);
+       len = zb_get_data_size(h->type);
+       data_type = zb_get_analog_or_discret(h->type);
        if (0 < len /* && DATA_TYPE_ANALOG == data_type */) {
-               memcpy(value, handle->change, len);
-               *type = handle->type;
+               memcpy(value, h->change, len);
+               *type = h->type;
                *size = len;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
@@ -1189,41 +1246,46 @@ API int zb_create_read_report_config_record(read_report_config_record_h *handle)
 
 API void zb_destroy_read_report_config_record(read_report_config_record_h handle)
 {
-       free(handle);
+       struct read_reporting_configuration_record_s *h = handle;
+       free(h);
 }
 
 API int zb_set_dir_to_read_report_config_record(read_report_config_record_h handle,
                unsigned char dir)
 {
+       struct read_reporting_configuration_record_s *h = handle;
        RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
        if (dir == ZB_ZCL_CLIENT_TO_SERVER)
-               handle->dir = 0x00;
+               h->dir = 0x00;
        else
-               handle->dir = 0x01;
+               h->dir = 0x01;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_dir_from_read_report_config_record(read_report_config_record_h handle,
                unsigned char *dir)
 {
+       struct read_reporting_configuration_record_s *h = handle;
        RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *dir = handle->dir;
+       *dir = h->dir;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_read_report_config_record(read_report_config_record_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct read_reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_read_report_config_record(read_report_config_record_h handle,
                unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       struct read_reporting_configuration_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -1241,57 +1303,64 @@ API int zb_create_report_config_response_record(
 API void zb_destroy_report_config_response_record(
                report_config_response_record_h handle)
 {
-       free(handle);
+       struct reporting_configuration_response_record_s *h = handle;
+       free(h);
 }
 
 API int zb_get_status_from_report_config_response_record(
                report_config_response_record_h handle, unsigned char *status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *status = handle->status;
+       *status = h->status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_status_to_report_config_response_record(
                report_config_response_record_h handle, unsigned char status)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->status = status;
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->status = status;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_dir_from_report_config_response_record(
                report_config_response_record_h handle, unsigned char *dir)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *dir = handle->dir;
+       *dir = h->dir;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_dir_to_report_config_response_record(
                report_config_response_record_h handle, unsigned char dir)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->dir = handle->dir;
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->dir = dir;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_id_from_report_config_response_record(
        report_config_response_record_h handle, unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_report_config_response_record(
        report_config_response_record_h handle, unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct reporting_configuration_response_record_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -1306,40 +1375,45 @@ API int zb_create_attr_report(attr_report_h *handle)
 
 API void zb_destroy_attr_report(attr_report_h handle)
 {
-       if (handle) {
-               if (handle->value)
-                       free(handle->value);
-               free(handle);
+       struct attribute_report_s *h = handle;
+       if (h) {
+               if (h->value)
+                       free(h->value);
+               free(h);
        }
 }
 
 API int zb_get_id_from_attr_report(attr_report_h handle, unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct attribute_report_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_attr_report(attr_report_h handle, unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct attribute_report_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_type_from_attr_report(attr_report_h handle, unsigned char *type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct attribute_report_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *type = handle->type;
+       *type = h->type;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_type_to_attr_report(attr_report_h handle, unsigned char type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       struct attribute_report_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
@@ -1347,61 +1421,64 @@ API int zb_get_value_from_attr_report(attr_report_h handle, zb_value_h value)
 {
        int len = -1;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA);
+       struct zb_value_s *v = value;
+       struct attribute_report_s *h = handle;
+
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == h->value, ZIGBEE_ERROR_NO_DATA);
 
-       len = zb_get_data_size(handle->type);
+       len = zb_get_data_size(h->type);
        if (0 < len) {
-               memcpy(value->val, handle->value, len);
-               value->size = len;
-               value->type = handle->type;
-       } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
-               if (value->str) {
-                       if (value->str->v)
-                               free(value->str->v);
-                       free(value->str);
+               memcpy(v->val, h->value, len);
+               v->size = len;
+               v->type = h->type;
+       } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+               if (v->str) {
+                       if (v->str->v)
+                               free(v->str->v);
+                       free(v->str);
                }
-               value->str = calloc(1, sizeof(struct attribute_str_s));
-               RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               value->str->n = *handle->value;
+               v->str = calloc(1, sizeof(struct attribute_str_s));
+               RETV_IF(NULL == v->str, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               v->str->n = *h->value;
                /* The first 1 byte indicate invalid or length of string */
-               if (0xff == value->str->n) {
-                       free(value->str);
+               if (0xff == v->str->n) {
+                       free(v->str);
                        return ZIGBEE_ERROR_NO_DATA;
                }
-               value->str->v = calloc(value->str->n+1, 1);
-               if (NULL == value->str->v) {
-                       free(value->str);
+               v->str->v = calloc(v->str->n+1, 1);
+               if (NULL == v->str->v) {
+                       free(v->str);
                        return ZIGBEE_ERROR_OUT_OF_MEMORY;
                }
-               memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n);
-
-               value->type = handle->type;
-               value->size = value->str->n;
-       } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
-               if (value->wstr) {
-                       if (value->wstr->v)
-                               free(value->wstr->v);
-                       free(value->wstr);
+               memcpy(v->str->v, h->value+sizeof(v->str->n), v->str->n);
+
+               v->type = h->type;
+               v->size = v->str->n;
+       } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+               if (v->wstr) {
+                       if (v->wstr->v)
+                               free(v->wstr->v);
+                       free(v->wstr);
                }
-               value->wstr = calloc(1, sizeof(struct attribute_wstr_s));
-               RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               value->wstr->n = *(handle->value+1) << 8 | *handle->value;
+               v->wstr = calloc(1, sizeof(struct attribute_wstr_s));
+               RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               v->wstr->n = *(h->value+1) << 8 | *h->value;
                /* The first 2 byte indicate invalid or length of string */
-               if (0xffff == value->wstr->n) {
-                       free(value->wstr);
+               if (0xffff == v->wstr->n) {
+                       free(v->wstr);
                        return ZIGBEE_ERROR_NO_DATA;
                }
-               value->wstr->v = calloc(value->wstr->n+1, 1);
-               if (NULL == value->wstr->v) {
-                       free(value->wstr);
+               v->wstr->v = calloc(v->wstr->n+1, 1);
+               if (NULL == v->wstr->v) {
+                       free(v->wstr);
                        return ZIGBEE_ERROR_OUT_OF_MEMORY;
                }
-               memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n);
+               memcpy(v->wstr->v, h->value+sizeof(v->wstr->n), v->wstr->n);
 
-               value->type = handle->type;
-               value->size = value->wstr->n;
+               v->type = h->type;
+               v->size = v->wstr->n;
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -1412,35 +1489,38 @@ API int zb_set_value_to_attr_report(attr_report_h handle, zb_value_h value)
 {
        int len = -1;
 
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct zb_value_s *v = value;
+       struct attribute_report_s *h = handle;
+
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == v, ZIGBEE_ERROR_INVALID_PARAMETER);
 
-       if (handle->value)
-               free(handle->value);
+       if (h->value)
+               free(h->value);
 
-       len = zb_get_data_size(value->type);
+       len = zb_get_data_size(v->type);
        if (0 < len) {
-               handle->value = calloc(value->size + 1 , sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
-               memcpy(handle->value, value->val, value->size);
-               handle->type = value->type;
-       } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA);
-               handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value = calloc(v->size + 1 , sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               memcpy(h->value, v->val, v->size);
+               h->type = v->type;
+       } else if (ZB_ZCL_OCTAT_STRING == h->type || ZB_ZCL_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == v->str, ZIGBEE_ERROR_NO_DATA);
+               h->value = calloc(v->str->n + sizeof(v->str->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 1 byte indicate invalid or length of string */
-               handle->value[0] = value->str->n & 0xff;
-               memcpy(handle->value + sizeof(value->str->n),
-                       value->str->v + sizeof(value->str->n), value->str->n);
-       } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) {
-               RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA);
-               handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char));
-               RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
+               h->value[0] = v->str->n & 0xff;
+               memcpy(h->value + sizeof(v->str->n),
+                       v->str->v + sizeof(v->str->n), v->str->n);
+       } else if (ZB_ZCL_LONG_OCTAT_STRING == h->type || ZB_ZCL_LONG_CHRACTER_STRING == h->type) {
+               RETV_IF(NULL == v->wstr, ZIGBEE_ERROR_NO_DATA);
+               h->value = calloc(v->wstr->n + sizeof(v->wstr->n), sizeof(char));
+               RETV_IF(NULL == h->value, ZIGBEE_ERROR_OUT_OF_MEMORY);
                /* The first 2 byte indicate invalid or length of string */
-               handle->value[0] = value->wstr->n & 0xff;
-               handle->value[1] = (value->wstr->n >> 8) & 0xff ;
-               memcpy(handle->value + sizeof(value->wstr->n),
-                       value->wstr->v + sizeof(value->wstr->n), value->wstr->n);
+               h->value[0] = v->wstr->n & 0xff;
+               h->value[1] = (v->wstr->n >> 8) & 0xff ;
+               memcpy(h->value + sizeof(v->wstr->n),
+                       v->wstr->v + sizeof(v->wstr->n), v->wstr->n);
        } else
                return ZIGBEE_ERROR_NOT_SUPPORTED;
 
@@ -1502,57 +1582,64 @@ API int zb_create_extended_attr_info(extended_attr_info_h *handle)
 
 API void zb_destroy_extended_attr_info(extended_attr_info_h handle)
 {
-       free(handle);
+       struct extended_attribute_infomation_s *h = handle;
+       free(h);
 }
 
 API int zb_get_id_from_extended_attr_info(extended_attr_info_h handle,
                unsigned short *id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *id = handle->id;
+       *id = h->id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_id_to_extended_attr_info(extended_attr_info_h handle,
                unsigned short id)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->id = id;
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->id = id;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_type_from_extended_attr_info(extended_attr_info_h handle,
                unsigned char *type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *type = handle->type;
+       *type = h->type;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_type_to_extended_attr_info(extended_attr_info_h handle,
                unsigned char type)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->type = type;
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->type = type;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_get_acl_from_extended_attr_info(extended_attr_info_h handle,
                unsigned char *acl)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
        RETV_IF(NULL == acl, ZIGBEE_ERROR_INVALID_PARAMETER);
-       *acl = handle->acl;
+       *acl = h->acl;
        return ZIGBEE_ERROR_NONE;
 }
 
 API int zb_set_acl_to_extended_attr_info(extended_attr_info_h handle,
                unsigned char acl)
 {
-       RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER);
-       handle->acl = acl;
+       struct extended_attribute_infomation_s *h = handle;
+       RETV_IF(NULL == h, ZIGBEE_ERROR_INVALID_PARAMETER);
+       h->acl = acl;
        return ZIGBEE_ERROR_NONE;
 }