mirror of
https://github.com/Telecominfraproject/oopt-tai.git
synced 2026-01-27 02:21:53 +00:00
netif: add notification attribute
Signed-off-by: Wataru Ishida <ishida@nel-america.com>
This commit is contained in:
committed by
Wataru Ishida
parent
669a2d225c
commit
347fc472db
@@ -505,6 +505,15 @@ typedef enum _tai_network_interface_attr_t
|
||||
*/
|
||||
TAI_NETWORK_INTERFACE_ATTR_CURRENT_PRBS_BER,
|
||||
|
||||
/**
|
||||
* @brief Network interface generic notification
|
||||
*
|
||||
* @type #tai_notification_handler_t
|
||||
* @flags CREATE_AND_SET
|
||||
* @default NULL
|
||||
*/
|
||||
TAI_NETWORK_INTERFACE_ATTR_NOTIFY,
|
||||
|
||||
/**
|
||||
* @brief End of attributes
|
||||
*/
|
||||
|
||||
@@ -212,6 +212,36 @@ typedef struct _tai_attr_value_list_t
|
||||
uint32_t _alloced;
|
||||
} tai_attr_value_list_t;
|
||||
|
||||
// Forward declaration of tai_attribute_t for tai_notification_fn
|
||||
struct _tai_attribute_t;
|
||||
typedef struct _tai_attribute_t tai_attribute_t;
|
||||
|
||||
/**
|
||||
* @brief TAI notification callback
|
||||
*
|
||||
* @param[in] context User context
|
||||
* @param[in] oid object ID
|
||||
* @param[in] attribute Updated attribute
|
||||
*/
|
||||
typedef void (*tai_notification_fn)(
|
||||
_In_ void* context,
|
||||
_In_ tai_object_id_t oid,
|
||||
_In_ tai_attribute_t const * const attribute);
|
||||
|
||||
/**
|
||||
* @brief TAI notification handler
|
||||
*
|
||||
* Generic notification handler which can be used by any TAI objects
|
||||
*
|
||||
* The handler will be set by TAI adapter host by using TAI attribute
|
||||
* whose value type must be #tai_pointer_t #tai_notification_handler_t
|
||||
*
|
||||
*/
|
||||
typedef struct _tai_notification_handler_t {
|
||||
void* context;
|
||||
tai_notification_fn notify;
|
||||
} tai_notification_handler_t;
|
||||
|
||||
/**
|
||||
* @brief Data Type
|
||||
*
|
||||
@@ -245,7 +275,7 @@ typedef union _tai_attribute_value_t
|
||||
tai_s32_range_t s32range;
|
||||
tai_object_map_list_t objmaplist;
|
||||
tai_attr_value_list_t attrlist;
|
||||
|
||||
tai_notification_handler_t notification;
|
||||
} tai_attribute_value_t;
|
||||
|
||||
typedef struct _tai_attribute_t
|
||||
|
||||
@@ -180,6 +180,11 @@ typedef enum _tai_attr_value_type_t
|
||||
*/
|
||||
TAI_ATTR_VALUE_TYPE_ATTRLIST,
|
||||
|
||||
/*
|
||||
* @brief Attribute value is notification handler.
|
||||
*/
|
||||
TAI_ATTR_VALUE_TYPE_NOTIFICATION,
|
||||
|
||||
} tai_attr_value_type_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -383,6 +383,7 @@ tai_status_t _tai_metadata_free_attr_value(
|
||||
case TAI_ATTR_VALUE_TYPE_OID:
|
||||
case TAI_ATTR_VALUE_TYPE_U32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_S32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_NOTIFICATION:
|
||||
return TAI_STATUS_SUCCESS;
|
||||
case TAI_ATTR_VALUE_TYPE_OBJLIST:
|
||||
_TAI_META_FREE_LIST(objlist);
|
||||
@@ -455,6 +456,7 @@ static int _tai_list_size(
|
||||
case TAI_ATTR_VALUE_TYPE_OID:
|
||||
case TAI_ATTR_VALUE_TYPE_U32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_S32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_NOTIFICATION:
|
||||
return 0;
|
||||
case TAI_ATTR_VALUE_TYPE_OBJLIST:
|
||||
return value->objlist.count;
|
||||
@@ -522,6 +524,7 @@ static tai_status_t _tai_metadata_alloc_attr_value(
|
||||
case TAI_ATTR_VALUE_TYPE_OID:
|
||||
case TAI_ATTR_VALUE_TYPE_U32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_S32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_NOTIFICATION:
|
||||
return TAI_STATUS_SUCCESS;
|
||||
case TAI_ATTR_VALUE_TYPE_OBJLIST:
|
||||
_TAI_META_ALLOC_LIST(objlist, tai_object_id_t);
|
||||
@@ -636,6 +639,7 @@ static tai_status_t _tai_metadata_deepcopy_attr_value(
|
||||
case TAI_ATTR_VALUE_TYPE_OID:
|
||||
case TAI_ATTR_VALUE_TYPE_U32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_S32RANGE:
|
||||
case TAI_ATTR_VALUE_TYPE_NOTIFICATION:
|
||||
memcpy(out, in, sizeof(tai_attribute_value_t));
|
||||
break;
|
||||
case TAI_ATTR_VALUE_TYPE_OBJLIST:
|
||||
|
||||
@@ -731,6 +731,13 @@ int tai_serialize_attribute_value(
|
||||
return tai_serialize_float(ptr, n, value->flt);
|
||||
case TAI_ATTR_VALUE_TYPE_PTR:
|
||||
return tai_serialize_pointer(ptr, n, value->ptr);
|
||||
case TAI_ATTR_VALUE_TYPE_NOTIFICATION:
|
||||
_SERIALIZE(snprintf(ptr, n, "{ \"context\": \""), count, ptr, n);
|
||||
_SERIALIZE(tai_serialize_pointer(ptr, n, value->notification.context), count, ptr, n);
|
||||
_SERIALIZE(snprintf(ptr, n, "\", \"notify\": \""), count, ptr, n);
|
||||
_SERIALIZE(tai_serialize_pointer(ptr, n, value->notification.notify), count, ptr, n);
|
||||
_SERIALIZE(snprintf(ptr, n, "\"}"), count, ptr, n);
|
||||
return ptr - buffer;
|
||||
case TAI_ATTR_VALUE_TYPE_OID:
|
||||
return tai_serialize_object_id(ptr, n, value->oid);
|
||||
case TAI_ATTR_VALUE_TYPE_OBJLIST:
|
||||
|
||||
Reference in New Issue
Block a user