aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgokuls <goksing@gmail.com>2017-07-14 16:02:58 -0400
committergokuls <goksing@gmail.com>2017-07-14 17:38:57 -0400
commit65c3a02cf2b1083debdd087fef9a656d3e3c6cea (patch)
treee9b3ea16f8c584e70a2d33a7c080b994b85e5491
parent1a92cb5c28ba17b4a57e4c02ad7223119c810c4a (diff)
Fixed bugs with VoiceQuality and TCA
Change-Id: I0d839079b3a97116db05fa261146998200eb9ae3 Signed-Off-By: Gokul Singaraju <goksing@gmail.com>
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c7
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h316
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c11
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c2
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel_strings.c4
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel_threshold_cross.c528
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/evel_voicequality.c52
-rw-r--r--vnfs/VES5.0/evel/evel-library/code/evel_library/hashtable.h62
8 files changed, 904 insertions, 78 deletions
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c
index bf8a4b2a..20b386d6 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.c
@@ -380,6 +380,13 @@ void evel_free_event(void * event)
free(evt_ptr);
break;
+ case EVEL_DOMAIN_THRESHOLD_CROSS:
+ EVEL_DEBUG("Event is a Threshold crossing at %lp", evt_ptr);
+ evel_free_threshold_cross((EVENT_THRESHOLD_CROSS *)evt_ptr);
+ memset(evt_ptr, 0, sizeof(EVENT_THRESHOLD_CROSS));
+ free(evt_ptr);
+ break;
+
default:
EVEL_ERROR("Unexpected event domain (%d)", evt_ptr->event_domain);
assert(0);
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h
index 5d63e418..be0c5f0e 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel.h
@@ -1,3 +1,5 @@
+#ifndef EVEL_INCLUDED
+#define EVEL_INCLUDED
/*************************************************************************//**
*
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
@@ -25,11 +27,8 @@
*
* Zero return value is success (::EVEL_SUCCESS), non-zero is failure and will
* be one of ::EVEL_ERR_CODES.
- *
- ****************************************************************************/
+ *****************************************************************************/
-#ifndef EVEL_INCLUDED
-#define EVEL_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
@@ -128,6 +127,7 @@ typedef enum {
EVEL_DOMAIN_STATE_CHANGE, /** A State Change event. */
EVEL_DOMAIN_SYSLOG, /** A Syslog event. */
EVEL_DOMAIN_OTHER, /** Another event. */
+ EVEL_DOMAIN_THRESHOLD_CROSS, /** A Threshold Crossing Event */
EVEL_DOMAIN_VOICE_QUALITY, /** A Voice Quality Event */
EVEL_MAX_DOMAINS /** Maximum number of recognized Event types. */
} EVEL_EVENT_DOMAINS;
@@ -1409,6 +1409,51 @@ int evel_json_encode_event(char * json,
EVENT_HEADER * event);
/**************************************************************************//**
+ * Initialize an event instance id.
+ *
+ * @param vfield Pointer to the event vnfname field being initialized.
+ * @param vendor_id The vendor id to encode in the event instance id.
+ * @param event_id The event id to encode in the event instance id.
+ *****************************************************************************/
+void evel_init_vendor_field(VENDOR_VNFNAME_FIELD * const vfield,
+ const char * const vendor_name);
+
+/**************************************************************************//**
+ * Set the Vendor module property of the Vendor.
+ *
+ * @note The property is treated as immutable: it is only valid to call
+ * the setter once. However, we don't assert if the caller tries to
+ * overwrite, just ignoring the update instead.
+ *
+ * @param vfield Pointer to the Vendor field.
+ * @param module_name The module name to be set. ASCIIZ string. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_vendor_field_module_set(VENDOR_VNFNAME_FIELD * const vfield,
+ const char * const module_name);
+/**************************************************************************//**
+ * Set the Vendor module property of the Vendor.
+ *
+ * @note The property is treated as immutable: it is only valid to call
+ * the setter once. However, we don't assert if the caller tries to
+ * overwrite, just ignoring the update instead.
+ *
+ * @param vfield Pointer to the Vendor field.
+ * @param module_name The module name to be set. ASCIIZ string. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_vendor_field_vnfname_set(VENDOR_VNFNAME_FIELD * const vfield,
+ const char * const vnfname);
+/**************************************************************************//**
+ * Free an event instance id.
+ *
+ * @param vfield Pointer to the event vnfname_field being freed.
+ *****************************************************************************/
+void evel_free_event_vendor_field(VENDOR_VNFNAME_FIELD * const vfield);
+
+/**************************************************************************//**
* Callback function to provide returned data.
*
* Copy data into the supplied buffer, write_callback::ptr, checking size
@@ -3860,38 +3905,6 @@ int evel_get_measurement_interval();
#define EVEL_VOICEQ_MINOR_VERSION 1
/**************************************************************************//**
-* Voice QUality.
-* JSON equivalent field: voiceQualityFields
-*****************************************************************************/
-
-typedef struct event_voiceQuality {
- /***************************************************************************/
- /* Header and version */
- /***************************************************************************/
- EVENT_HEADER header;
- int major_version;
- int minor_version;
-
- /***************************************************************************/
- /* Mandatory fields */
- /***************************************************************************/
-
- char *calleeSideCodec;
- char *callerSideCodec;
- char *correlator;
- char *midCallRtcp;
- VENDOR_VNFNAME_FIELD vendorVnfNameFields;
-
- /***************************************************************************/
- /* Optional fields */
- /***************************************************************************/
- EVEL_OPTION_STRING phoneNumber;
- DLIST additionalInformation;
- DLIST endOfCallVqmSummaries;
-
-} EVENT_VOICE_QUALITY;
-
-/**************************************************************************//**
* End of Call Voice Quality Metrices
* JSON equivalent field: endOfCallVqmSummaries
*****************************************************************************/
@@ -3928,6 +3941,37 @@ typedef struct end_of_call_vqm_summaries {
} END_OF_CALL_VOICE_QUALITY_METRICS;
/**************************************************************************//**
+* Voice QUality.
+* JSON equivalent field: voiceQualityFields
+*****************************************************************************/
+
+typedef struct event_voiceQuality {
+ /***************************************************************************/
+ /* Header and version */
+ /***************************************************************************/
+ EVENT_HEADER header;
+ int major_version;
+ int minor_version;
+
+ /***************************************************************************/
+ /* Mandatory fields */
+ /***************************************************************************/
+
+ char *calleeSideCodec;
+ char *callerSideCodec;
+ char *correlator;
+ char *midCallRtcp;
+ VENDOR_VNFNAME_FIELD vendorVnfNameFields;
+ END_OF_CALL_VOICE_QUALITY_METRICS *endOfCallVqmSummaries;
+
+ /***************************************************************************/
+ /* Optional fields */
+ /***************************************************************************/
+ EVEL_OPTION_STRING phoneNumber;
+ DLIST additionalInformation;
+
+} EVENT_VOICE_QUALITY;
+/**************************************************************************//**
* Voice Quality Additional Info.
* JSON equivalent field: additionalInformation
*****************************************************************************/
@@ -4123,6 +4167,206 @@ void evel_voice_quality_addl_info_add(EVENT_VOICE_QUALITY * voiceQuality, char *
/*****************************************************************************/
/*****************************************************************************/
/* */
+/* THRESHOLD CROSSING ALERT */
+/* */
+/*****************************************************************************/
+/*****************************************************************************/
+
+typedef enum evel_event_action {
+ EVEL_EVENT_ACTION_CLEAR,
+ EVEL_EVENT_ACTION_CONTINUE,
+ EVEL_EVENT_ACTION_SET,
+ EVEL_MAX_EVENT_ACTION
+}EVEL_EVENT_ACTION;
+
+typedef enum evel_alert_type {
+ EVEL_CARD_ANOMALY,
+ EVEL_ELEMENT_ANOMALY,
+ EVEL_INTERFACE_ANOMALY,
+ EVEL_SERVICE_ANOMALY,
+ EVEL_MAX_ANOMALY
+}EVEL_ALERT_TYPE;
+
+
+typedef struct perf_counter {
+ char * criticality;
+ char * name;
+ char * thresholdCrossed;
+ char * value;
+}PERF_COUNTER;
+
+
+/*****************************************************************************/
+/* Supported Threshold Crossing version. */
+/*****************************************************************************/
+#define EVEL_THRESHOLD_CROSS_MAJOR_VERSION 1
+#define EVEL_THRESHOLD_CROSS_MINOR_VERSION 1
+
+/**************************************************************************//**
+ * Threshold Crossing.
+ * JSON equivalent field: Threshold Cross Fields
+ *****************************************************************************/
+typedef struct event_threshold_cross {
+ /***************************************************************************/
+ /* Header and version */
+ /***************************************************************************/
+ EVENT_HEADER header;
+ int major_version;
+ int minor_version;
+
+ /***************************************************************************/
+ /* Mandatory fields */
+ /***************************************************************************/
+ PERF_COUNTER additionalParameters;
+ EVEL_EVENT_ACTION alertAction;
+ char * alertDescription;
+ EVEL_ALERT_TYPE alertType;
+ unsigned long long collectionTimestamp;
+ EVEL_SEVERITIES eventSeverity;
+ unsigned long long eventStartTimestamp;
+
+ /***************************************************************************/
+ /* Optional fields */
+ /***************************************************************************/
+ DLIST additional_info;
+ EVEL_OPTION_STRING alertValue;
+ DLIST alertidList;
+ EVEL_OPTION_STRING dataCollector;
+ EVEL_OPTION_STRING elementType;
+ EVEL_OPTION_STRING interfaceName;
+ EVEL_OPTION_STRING networkService;
+ EVEL_OPTION_STRING possibleRootCause;
+
+} EVENT_THRESHOLD_CROSS;
+
+
+/**************************************************************************//**
+ * Create a new Threshold Crossing Alert event.
+ *
+ * @note The mandatory fields on the TCA must be supplied to this factory
+ * function and are immutable once set. Optional fields have explicit
+ * setter functions, but again values may only be set once so that the
+ * TCA has immutable properties.
+ *
+ * @param char* tcriticality Performance Counter Criticality MAJ MIN,
+ * @param char* tname Performance Counter Threshold name
+ * @param char* tthresholdCrossed Counter Threshold crossed value
+ * @param char* tvalue Counter actual value
+ * @param EVEL_EVENT_ACTION talertAction Alert set continue or clear
+ * @param char* talertDescription
+ * @param EVEL_ALERT_TYPE talertType Kind of anamoly
+ * @param unsigned long long tcollectionTimestamp time at which alert was collected
+ * @param EVEL_SEVERITIES teventSeverity Severity of Alert
+ * @param unsigned long long teventStartTimestamp Time when this alert started
+ *
+ * @returns pointer to the newly manufactured ::EVENT_THRESHOLD_CROSS. If the
+ * event is not used it must be released using
+ * ::evel_free_threshold_cross
+ * @retval NULL Failed to create the event.
+ *****************************************************************************/
+EVENT_THRESHOLD_CROSS * evel_new_threshold_cross(
+ char * tcriticality,
+ char * tname,
+ char * tthresholdCrossed,
+ char * tvalue,
+ EVEL_EVENT_ACTION talertAction,
+ char * talertDescription,
+ EVEL_ALERT_TYPE talertType,
+ unsigned long long tcollectionTimestamp,
+ EVEL_SEVERITIES teventSeverity,
+ unsigned long long teventStartTimestamp);
+
+/**************************************************************************//**
+ * Free a Threshold cross event.
+ *
+ * Free off the Threshold crossing event supplied. Will free all the contained allocated
+ * memory.
+ *
+ * @note It does not free the Threshold Cross itself, since that may be part of a
+ * larger structure.
+ *****************************************************************************/
+void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const tcp);
+
+/**************************************************************************//**
+ * Set the Event Type property of the Threshold Cross.
+ *
+ * @note The property is treated as immutable: it is only valid to call
+ * the setter once. However, we don't assert if the caller tries to
+ * overwrite, just ignoring the update instead.
+ *
+ * @param tcp Pointer to the ::EVENT_THRESHOLD_CROSS.
+ * @param type The Event Type to be set. ASCIIZ string. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_threshold_cross_type_set(EVENT_THRESHOLD_CROSS * const tcp, char * type);
+
+/**************************************************************************//**
+ * Add an optional additional alertid value to Alert.
+ *
+ * @param alertid Adds Alert ID
+ *****************************************************************************/
+void evel_threshold_cross_alertid_add(EVENT_THRESHOLD_CROSS * const event,char * alertid);
+
+ /**************************************************************************//**
+ * Set the TCA probable Root cause.
+ *
+ * @param sheader Possible root cause to Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_possible_rootcause_set(EVENT_THRESHOLD_CROSS * const event, char * sheader);
+ /**************************************************************************//**
+ * Set the TCA networking cause.
+ *
+ * @param sheader Possible networking service value to Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_networkservice_set(EVENT_THRESHOLD_CROSS * const event, char * sheader);
+ /**************************************************************************//**
+ * Set the TCA Interface name.
+ *
+ * @param sheader Interface name to threshold
+ *****************************************************************************/
+ void evel_threshold_cross_interfacename_set(EVENT_THRESHOLD_CROSS * const event,char * sheader);
+ /**************************************************************************//**
+ * Set the TCA Data element type.
+ *
+ * @param sheader element type of Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_data_elementtype_set(EVENT_THRESHOLD_CROSS * const event,char * sheader);
+ /**************************************************************************//**
+ * Set the TCA Data collector value.
+ *
+ * @param sheader Data collector value
+ *****************************************************************************/
+ void evel_threshold_cross_data_collector_set(EVENT_THRESHOLD_CROSS * const event,char * sheader);
+ /**************************************************************************//**
+ * Set the TCA alert value.
+ *
+ * @param sheader Possible alert value
+ *****************************************************************************/
+ void evel_threshold_cross_alertvalue_set(EVENT_THRESHOLD_CROSS * const event,char * sheader);
+
+/**************************************************************************//**
+ * Add an additional field name/value pair to the THRESHOLD CROSS event.
+ *
+ * The name and value are null delimited ASCII strings. The library takes
+ * a copy so the caller does not have to preserve values after the function
+ * returns.
+ *
+ * @param state_change Pointer to the ::EVENT_THRESHOLD_CROSS.
+ * @param name ASCIIZ string with the attribute's name. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ * @param value ASCIIZ string with the attribute's value. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const tcp,
+ const char * const name,
+ const char * const value);
+
+/*****************************************************************************/
+/*****************************************************************************/
+/* */
/* LOGGING */
/* */
/*****************************************************************************/
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c
index 817e2288..6d025abe 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_event.c
@@ -20,8 +20,7 @@
* Implementation of EVEL functions relating to Event Headers - since
* Heartbeats only contain the Event Header, the Heartbeat factory function is
* here too.
- *
- ****************************************************************************/
+ *****************************************************************************/
#include <string.h>
#include <assert.h>
@@ -484,7 +483,11 @@ int evel_json_encode_event(char * json,
break;
case EVEL_DOMAIN_VOICE_QUALITY:
- evel_json_encode_other(jbuf, (EVENT_VOICE_QUALITY *)event);
+ evel_json_encode_voice_quality(jbuf, (EVENT_VOICE_QUALITY *)event);
+ break;
+
+ case EVEL_DOMAIN_THRESHOLD_CROSS:
+ evel_json_encode_threshold_cross(jbuf, (EVENT_THRESHOLD_CROSS *)event);
break;
case EVEL_DOMAIN_INTERNAL:
@@ -639,7 +642,7 @@ void evel_json_encode_vendor_field(EVEL_JSON_BUFFER * jbuf,
assert(vfield != NULL);
assert(vfield->vendorname != NULL);
- evel_json_open_named_object(jbuf, "vendorVnfNamedFields");
+ evel_json_open_named_object(jbuf, "vendorVnfNameFields");
/***************************************************************************/
/* Mandatory fields. */
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c
index 47c1cb21..caf1a1e3 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_jsonobject.c
@@ -95,8 +95,6 @@ exit_label:
EVEL_JSON_OBJECT_INSTANCE * evel_new_jsonobjinstance(const char *const yourjson)
{
EVEL_JSON_OBJECT_INSTANCE *jobjinst = NULL;
- unsigned int length;
- char *keyString = NULL;
jsmntok_t *key;
int resultCode;
jsmn_parser p;
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_strings.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_strings.c
index 2cd4ee75..96db59bd 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_strings.c
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_strings.c
@@ -236,6 +236,10 @@ char * evel_event_domain(const EVEL_EVENT_DOMAINS domain)
result = "voiceQuality";
break;
+ case EVEL_DOMAIN_THRESHOLD_CROSS:
+ result = "thresholdCrossingAlert";
+ break;
+
default:
result = NULL;
EVEL_ERROR("Unexpected domain %d", domain);
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_threshold_cross.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_threshold_cross.c
new file mode 100644
index 00000000..a0a9cc3d
--- /dev/null
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_threshold_cross.c
@@ -0,0 +1,528 @@
+/*************************************************************************//**
+ *
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ****************************************************************************/
+/**************************************************************************//**
+ * @file
+ * Implementation of EVEL functions relating to the Threshold Cross Alerts.
+ *
+ *****************************************************************************/
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include "evel.h"
+#include "evel_internal.h"
+#include "evel_throttle.h"
+
+
+/**************************************************************************//**
+ * Create a new Threshold Crossing Alert event.
+ *
+ * @note The mandatory fields on the TCA must be supplied to this factory
+ * function and are immutable once set. Optional fields have explicit
+ * setter functions, but again values may only be set once so that the
+ * TCA has immutable properties.
+ *
+ * @param char* tcriticality Performance Counter Criticality MAJ MIN,
+ * @param char* tname Performance Counter Threshold name
+ * @param char* tthresholdCrossed Counter Threshold crossed value
+ * @param char* tvalue Counter actual value
+ * @param EVEL_EVENT_ACTION talertAction Alert set continue or clear
+ * @param char* talertDescription
+ * @param EVEL_ALERT_TYPE talertType Kind of anamoly
+ * @param unsigned long long tcollectionTimestamp time at which alert was collected
+ * @param EVEL_SEVERITIES teventSeverity Severity of Alert
+ * @param unsigned long long teventStartTimestamp Time when this alert started
+ *
+ * @returns pointer to the newly manufactured ::EVENT_THRESHOLD_CROSS. If the
+ * event is not used it must be released using
+ * ::evel_free_threshold_cross
+ * @retval NULL Failed to create the event.
+ *****************************************************************************/
+EVENT_THRESHOLD_CROSS * evel_new_threshold_cross( char * tcriticality,
+ char * tname,
+ char * tthresholdCrossed,
+ char * tvalue,
+ EVEL_EVENT_ACTION talertAction,
+ char * talertDescription,
+ EVEL_ALERT_TYPE talertType,
+ unsigned long long tcollectionTimestamp,
+ EVEL_SEVERITIES teventSeverity,
+ unsigned long long teventStartTimestamp )
+{
+ EVENT_THRESHOLD_CROSS * event = NULL;
+ EVEL_ENTER();
+
+ assert( tcriticality!= NULL );
+ assert( tname!= NULL );
+ assert( tthresholdCrossed != NULL );
+ assert( tvalue!= NULL );
+ assert( talertDescription != NULL );
+
+
+ /***************************************************************************/
+ /* Allocate the Threshold crossing event. */
+ /***************************************************************************/
+ event = malloc(sizeof(EVENT_THRESHOLD_CROSS));
+ if (event == NULL)
+ {
+ log_error_state("Out of memory");
+ goto exit_label;
+ }
+ memset(event, 0, sizeof(EVENT_THRESHOLD_CROSS));
+ EVEL_DEBUG("New Threshold Cross event is at %lp", event);
+
+ /***************************************************************************/
+ /* Initialize the header & the threshold crossing fields. */
+ /***************************************************************************/
+ evel_init_header(&event->header,"thresholdCrossingAlert");
+ event->header.event_domain = EVEL_DOMAIN_THRESHOLD_CROSS;
+ event->major_version = EVEL_THRESHOLD_CROSS_MAJOR_VERSION;
+ event->minor_version = EVEL_THRESHOLD_CROSS_MINOR_VERSION;
+
+
+ event->additionalParameters.criticality = strdup(tcriticality);
+ event->additionalParameters.name = strdup(tname);
+ event->additionalParameters.thresholdCrossed = strdup(tthresholdCrossed);
+ event->additionalParameters.value = strdup(tvalue);
+ event->alertAction = talertAction;
+ event->alertDescription = strdup(talertDescription);
+ event->alertType = talertType;
+ event->collectionTimestamp = tcollectionTimestamp;
+ event->eventSeverity = teventSeverity;
+ event->eventStartTimestamp = teventStartTimestamp;
+
+ evel_init_option_string(&event->alertValue);
+ evel_init_option_string(&event->dataCollector);
+ evel_init_option_string(&event->elementType);
+ evel_init_option_string(&event->interfaceName);
+ evel_init_option_string(&event->networkService);
+ evel_init_option_string(&event->possibleRootCause);
+ dlist_initialize(&event->additional_info);
+ dlist_initialize(&event->alertidList);
+
+exit_label:
+
+ EVEL_EXIT();
+ return event;
+
+}
+
+
+/**************************************************************************//**
+ * Set the Event Type property of the TC Alert.
+ *
+ * @note The property is treated as immutable: it is only valid to call
+ * the setter once. However, we don't assert if the caller tries to
+ * overwrite, just ignoring the update instead.
+ *
+ * @param type The Event Type to be set. ASCIIZ string. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_threshold_cross_type_set(EVENT_THRESHOLD_CROSS * const event,char * type)
+{
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions and call evel_header_type_set. */
+ /***************************************************************************/
+ assert(type!=NULL);
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ evel_header_type_set(&event->header, type);
+
+ EVEL_EXIT();
+}
+
+/**************************************************************************//**
+ * Add an optional additional alertid value to Alert.
+ *
+ *****************************************************************************/
+void evel_threshold_cross_alertid_add(EVENT_THRESHOLD_CROSS * const event,char * alertid)
+{
+ char *alid=NULL;
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event != NULL);
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(alertid != NULL);
+
+ EVEL_DEBUG("Adding AlertId=%s", alertid);
+ alid = strdup(alertid);
+ assert(alid != NULL);
+
+ dlist_push_last(&event->alertidList, alid);
+
+ EVEL_EXIT();
+}
+
+/**************************************************************************//**
+ * Add an optional additional value name/value pair to the Alert.
+ *
+ * The name and value are NULL delimited ASCII strings. The library takes
+ * a copy so the caller does not have to preserve values after the function
+ * returns.
+ * @param name ASCIIZ string with the attribute's name. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ * @param value ASCIIZ string with the attribute's value. The caller
+ * does not need to preserve the value once the function
+ * returns.
+ *****************************************************************************/
+void evel_threshold_cross_addl_info_add(EVENT_THRESHOLD_CROSS * const event, const char * name, const char * value)
+{
+ OTHER_FIELD * nv_pair = NULL;
+
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event != NULL);
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(name != NULL);
+ assert(value != NULL);
+
+ EVEL_DEBUG("Adding name=%s value=%s", name, value);
+ nv_pair = malloc(sizeof(OTHER_FIELD));
+ assert(nv_pair != NULL);
+ nv_pair->name = strdup(name);
+ nv_pair->value = strdup(value);
+ assert(nv_pair->name != NULL);
+ assert(nv_pair->value != NULL);
+
+ dlist_push_last(&event->additional_info, nv_pair);
+
+ EVEL_EXIT();
+}
+
+
+/**************************************************************************//**
+ * Free a Signaling event.
+ *
+ * Free off the event supplied. Will free all the contained allocated memory.
+ *
+ * @note It does not free the event itself, since that may be part of a larger
+ * structure.
+ *****************************************************************************/
+void evel_free_threshold_cross(EVENT_THRESHOLD_CROSS * const event)
+{
+ OTHER_FIELD * addl_info = NULL;
+ char *ptr;
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. As an internal API we don't allow freeing NULL */
+ /* events as we do on the API. */
+ /***************************************************************************/
+ assert(event != NULL);
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+
+ /***************************************************************************/
+ /* Free all internal strings then the header itself. */
+ /***************************************************************************/
+ addl_info = dlist_pop_last(&event->additional_info);
+ while (addl_info != NULL)
+ {
+ EVEL_DEBUG("Freeing Additional Info (%s, %s)",
+ addl_info->name,
+ addl_info->value);
+ free(addl_info->name);
+ free(addl_info->value);
+ free(addl_info);
+ addl_info = dlist_pop_last(&event->additional_info);
+ }
+ ptr = dlist_pop_last(&event->alertidList);
+ while (ptr != NULL)
+ {
+ free(ptr);
+ ptr = dlist_pop_last(&event->alertidList);
+ }
+
+ free(event->additionalParameters.criticality);
+ free(event->additionalParameters.name);
+ free(event->additionalParameters.thresholdCrossed);
+ free(event->additionalParameters.value);
+ free(event->alertDescription);
+
+ evel_free_option_string(&event->alertValue);
+ evel_free_option_string(&event->dataCollector);
+ evel_free_option_string(&event->elementType);
+ evel_free_option_string(&event->interfaceName);
+ evel_free_option_string(&event->networkService);
+ evel_free_option_string(&event->possibleRootCause);
+ evel_free_header(&event->header);
+
+ EVEL_EXIT();
+}
+
+ /**************************************************************************//**
+ * Set the TCA probable Root cause.
+ *
+ * @param sheader Possible root cause to Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_possible_rootcause_set(EVENT_THRESHOLD_CROSS * const event, char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->possibleRootCause,
+ sheader,
+ "Rootcause value");
+
+ EVEL_EXIT();
+ }
+
+ /**************************************************************************//**
+ * Set the TCA networking cause.
+ *
+ * @param sheader Possible networking service value to Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_networkservice_set(EVENT_THRESHOLD_CROSS * const event, char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->networkService,
+ sheader,
+ "Networking service value");
+
+ EVEL_EXIT();
+ }
+
+ /**************************************************************************//**
+ * Set the TCA Interface name.
+ *
+ * @param sheader Interface name to threshold
+ *****************************************************************************/
+ void evel_threshold_cross_interfacename_set(EVENT_THRESHOLD_CROSS * const event,char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->interfaceName,
+ sheader,
+ "TCA Interface name");
+ EVEL_EXIT();
+ }
+
+ /**************************************************************************//**
+ * Set the TCA Data element type.
+ *
+ * @param sheader element type of Threshold
+ *****************************************************************************/
+ void evel_threshold_cross_data_elementtype_set(EVENT_THRESHOLD_CROSS * const event,char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->elementType,
+ sheader,
+ "TCA Element type value");
+ EVEL_EXIT();
+ }
+
+ /**************************************************************************//**
+ * Set the TCA Data collector value.
+ *
+ * @param sheader Data collector value
+ *****************************************************************************/
+ void evel_threshold_cross_data_collector_set(EVENT_THRESHOLD_CROSS * const event,char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->dataCollector,
+ sheader,
+ "Datacollector value");
+ EVEL_EXIT();
+ }
+
+
+
+ /**************************************************************************//**
+ * Set the TCA alert value.
+ *
+ * @param sheader Possible alert value
+ *****************************************************************************/
+ void evel_threshold_cross_alertvalue_set(EVENT_THRESHOLD_CROSS * const event,char * sheader)
+ {
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+ assert(sheader != NULL);
+
+ evel_set_option_string(&event->alertValue,
+ sheader,
+ "Alert value");
+ EVEL_EXIT();
+ }
+
+/**************************************************************************//**
+ * Encode the Mobile Flow GTP Per Flow Metrics as a JSON object.
+ *
+ * @param jbuf Pointer to working ::EVEL_JSON_BUFFER.
+ * @param metrics Pointer to the ::EVENT_MOBILE_FLOW to encode.
+ * @returns Number of bytes actually written.
+ *****************************************************************************/
+void evel_json_encode_perf_counter( EVEL_JSON_BUFFER * jbuf, PERF_COUNTER *pcounter)
+{
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(jbuf != NULL);
+ assert(pcounter != NULL);
+
+ evel_json_open_named_object(jbuf, "additionalParameters");
+
+ /***************************************************************************/
+ /* Mandatory parameters. */
+ /***************************************************************************/
+ evel_enc_kv_string(jbuf, "criticality", pcounter->criticality);
+ evel_enc_kv_string(jbuf, "name", pcounter->name);
+ evel_enc_kv_string(jbuf, "thresholdCrossed", pcounter->name);
+ evel_enc_kv_string(jbuf, "value", pcounter->value);
+
+ evel_json_close_object(jbuf);
+
+ EVEL_EXIT();
+}
+
+/**************************************************************************//**
+ * Encode the Signaling in JSON according to AT&T's schema for the
+ * event type.
+ *
+ * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
+ * @param event Pointer to the ::EVENT_HEADER to encode.
+ *****************************************************************************/
+void evel_json_encode_threshold_cross(EVEL_JSON_BUFFER * const jbuf,
+ EVENT_THRESHOLD_CROSS * const event)
+{
+ OTHER_FIELD * nv_pair = NULL;
+ DLIST_ITEM * dlist_item = NULL;
+
+ EVEL_ENTER();
+
+ /***************************************************************************/
+ /* Check preconditions. */
+ /***************************************************************************/
+ assert(event != NULL);
+ assert(event->header.event_domain == EVEL_DOMAIN_THRESHOLD_CROSS);
+
+ evel_json_encode_header(jbuf, &event->header);
+ evel_json_open_named_object(jbuf, "thresholdCrossingAlert");
+
+ /***************************************************************************/
+ /* Mandatory fields */
+ /***************************************************************************/
+ evel_json_encode_perf_counter(jbuf, &event->additionalParameters);
+ evel_enc_kv_int(jbuf, "alertAction", event->alertAction);
+ evel_enc_kv_string(jbuf, "alertDescription", event->alertDescription);
+ evel_enc_kv_int(jbuf, "alertType", event->alertType);
+ evel_enc_kv_ull(
+ jbuf, "collectionTimestamp", event->collectionTimestamp);
+ evel_enc_kv_int(jbuf, "eventSeverity", event->eventSeverity);
+ evel_enc_kv_ull(
+ jbuf, "eventStartTimestamp", event->eventStartTimestamp);
+
+ /***************************************************************************/
+ /* Optional fields */
+ /***************************************************************************/
+ evel_enc_kv_opt_string(jbuf, "alertValue", &event->alertValue);
+ evel_enc_kv_opt_string(jbuf, "dataCollector", &event->dataCollector);
+ evel_enc_kv_opt_string(jbuf, "elementType", &event->elementType);
+ evel_enc_kv_opt_string(jbuf, "interfaceName", &event->interfaceName);
+ evel_enc_kv_opt_string(jbuf, "networkService", &event->networkService);
+ evel_enc_kv_opt_string(jbuf, "possibleRootCause", &event->possibleRootCause);
+
+ /***************************************************************************/
+ /* Checkpoint, so that we can wind back if all fields are suppressed. */
+ /***************************************************************************/
+ evel_json_checkpoint(jbuf);
+ if (evel_json_open_opt_named_list(jbuf, "additionalFields"))
+ {
+ bool added = false;
+
+ dlist_item = dlist_get_first(&event->additional_info);
+ while (dlist_item != NULL)
+ {
+ nv_pair = (OTHER_FIELD *) dlist_item->item;
+ assert(nv_pair != NULL);
+
+ if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
+ "additionalFields",
+ nv_pair->name))
+ {
+ evel_json_open_object(jbuf);
+ evel_enc_kv_string(jbuf, "name", nv_pair->name);
+ evel_enc_kv_string(jbuf, "value", nv_pair->value);
+ evel_json_close_object(jbuf);
+ added = true;
+ }
+ dlist_item = dlist_get_next(dlist_item);
+ }
+ evel_json_close_list(jbuf);
+
+ /*************************************************************************/
+ /* If we've not written anything, rewind to before we opened the list. */
+ /*************************************************************************/
+ if (!added)
+ {
+ evel_json_rewind(jbuf);
+ }
+ }
+ evel_enc_version(jbuf,
+ "thresholdCrossingFieldsVersion",
+ event->major_version,
+ event->minor_version);
+
+ evel_json_close_object(jbuf);
+
+ EVEL_EXIT();
+}
+
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_voicequality.c b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_voicequality.c
index a71a5f61..c3826cab 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_voicequality.c
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/evel_voicequality.c
@@ -17,8 +17,7 @@
/**************************************************************************//**
* @file
* Implementation of EVEL functions relating to the Voice Quality.
- *
- ****************************************************************************/
+ *****************************************************************************/
#include <string.h>
#include <assert.h>
@@ -94,7 +93,7 @@ EVENT_VOICE_QUALITY * evel_new_voice_quality(const char * const calleeSideCodec,
voiceQuality->midCallRtcp = strdup(midCallRtcp);
evel_init_vendor_field(&voiceQuality->vendorVnfNameFields, vendorName);
dlist_initialize(&voiceQuality->additionalInformation);
- dlist_initialize(&voiceQuality->endOfCallVqmSummaries);
+ voiceQuality->endOfCallVqmSummaries = NULL;
evel_init_option_string(&voiceQuality->phoneNumber);
}
@@ -412,6 +411,7 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality,
assert(endpointDescription >= 0);
assert(mosCqe >= 1 && mosCqe <= 5);
assert(rFactor >= 0 && rFactor <= 100);
+ assert(voiceQuality->endOfCallVqmSummaries == NULL);
/***************************************************************************/
/* Allocate a container for the value and push onto the list. */
@@ -444,7 +444,7 @@ void evel_voice_quality_end_metrics_add(EVENT_VOICE_QUALITY * voiceQuality,
evel_set_option_int(&vQMetrices->rFactor, rFactor, "rFactor ");
evel_set_option_int(&vQMetrices->roundTripDelay, roundTripDelay, "Round trip delay in milliseconds ");
- dlist_push_last(&voiceQuality->endOfCallVqmSummaries, vQMetrices);
+ voiceQuality->endOfCallVqmSummaries = vQMetrices;
EVEL_EXIT();
}
@@ -520,23 +520,25 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf,
addlInfoItem = dlist_get_next(addlInfoItem);
}
evel_json_close_list(jbuf);
+ /*************************************************************************/
+ /* If we've not written anything, rewind to before we opened the list. */
+ /*************************************************************************/
+ if (!item_added)
+ {
+ evel_json_rewind(jbuf);
}
+ }
//endOfCallVqmSummaries
- evel_json_checkpoint(jbuf);
- if (evel_json_open_opt_named_list(jbuf, "endOfCallVqmSummaries"))
- {
- vQMetricsItem = dlist_get_first(&event->endOfCallVqmSummaries);
- while (vQMetricsItem != NULL)
- {
- vQMetrics = (END_OF_CALL_VOICE_QUALITY_METRICS *)vQMetricsItem->item;
- assert(vQMetrics != NULL);
+ if( event->endOfCallVqmSummaries != NULL )
+ {
+ evel_json_open_named_object(jbuf, "endOfCallVqmSummaries");
+ vQMetrics = event->endOfCallVqmSummaries;
+ assert(vQMetrics != NULL);
if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
- "endOfCallVqmSummaries",
- vQMetrics->adjacencyName))
+ "endOfCallVqmSummaries", vQMetrics->adjacencyName))
{
- evel_json_open_object(jbuf);
evel_enc_kv_string(jbuf, "adjacencyName", vQMetrics->adjacencyName);
evel_enc_kv_string(jbuf, "endpointDescription", vQMetrics->endpointDescription);
evel_enc_kv_opt_int(jbuf, "endpointJitter", &vQMetrics->endpointJitter);
@@ -559,21 +561,10 @@ void evel_json_encode_voice_quality(EVEL_JSON_BUFFER * jbuf,
evel_enc_kv_opt_int(jbuf, "rFactor", &vQMetrics->rFactor);
evel_enc_kv_opt_int(jbuf, "roundTripDelay", &vQMetrics->roundTripDelay);
- evel_json_close_object(jbuf);
- item_added = true;
}
- vQMetricsItem = dlist_get_next(vQMetricsItem);
- }
- evel_json_close_list(jbuf);
- }
- /*************************************************************************/
- /* If we've not written anything, rewind to before we opened the list. */
- /*************************************************************************/
- if (!item_added)
- {
- evel_json_rewind(jbuf);
- }
+ evel_json_close_object(jbuf);
+ }
evel_json_close_object(jbuf);
@@ -620,15 +611,14 @@ void evel_free_voice_quality(EVENT_VOICE_QUALITY * voiceQuality) {
}
//Summary Information
- vQMetrices = dlist_pop_last(&voiceQuality->endOfCallVqmSummaries);
- while (vQMetrices != NULL)
+ if(voiceQuality->endOfCallVqmSummaries != NULL)
{
+ vQMetrices = voiceQuality->endOfCallVqmSummaries;
EVEL_DEBUG("Freeing End of Call Voice Measurements Info (%s, %s)",
vQMetrices->adjacencyName,
vQMetrices->endpointDescription);
free(vQMetrices->adjacencyName);
free(vQMetrices);
- vQMetrices = dlist_pop_last(&voiceQuality->endOfCallVqmSummaries);
}
//Members
diff --git a/vnfs/VES5.0/evel/evel-library/code/evel_library/hashtable.h b/vnfs/VES5.0/evel/evel-library/code/evel_library/hashtable.h
index 3f4febef..8be17dc1 100644
--- a/vnfs/VES5.0/evel/evel-library/code/evel_library/hashtable.h
+++ b/vnfs/VES5.0/evel/evel-library/code/evel_library/hashtable.h
@@ -1,3 +1,6 @@
+#ifndef HASHTABLE_INCLUDED
+#define HASHTABLE_INCLUDED
+
/*************************************************************************//**
*
* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
@@ -15,17 +18,13 @@
*
****************************************************************************/
-#ifndef HASHTABLE_INCLUDED
-#define HASHTABLE_INCLUDED
-
/**************************************************************************//**
* @file
* A simple hashtable.
*
* @note No thread protection so you will need to use appropriate
* synchronization if use spans multiple threads.
- *
- ****************************************************************************/
+*****************************************************************************/
typedef struct entry_s {
char *key;
@@ -42,4 +41,57 @@ typedef struct hashtable_s {
struct entry_s **table;
} HASHTABLE_T;
+/**************************************************************************//**
+ * Hashtable initialization.
+ *
+ * Initialize the list supplied to be empty.
+ *
+ * @param size Size of hashtable
+
+ * @returns Hashtable pointer
+******************************************************************************/
+/* Create a new hashtable. */
+HASHTABLE_T *ht_create( size_t size );
+
+/**************************************************************************//**
+ * Hash a string for a particular hash table.
+ *
+ * Initialize the list supplied to be empty.
+ *
+ * @param hashtable Pointer to the hashtable
+ * @param key String
+
+ * @returns hashvalue
+******************************************************************************/
+size_t ht_hash( HASHTABLE_T *hashtable, char *key );
+
+/**************************************************************************//**
+ * Create a key-value pair.
+ *
+ * @param key key string
+ * @param value value string
+ *
+ * @returns hashtable entry
+******************************************************************************/
+ENTRY_T *ht_newpair( char *key, void *value );
+
+/**************************************************************************//**
+ * Insert a key-value pair into a hash table.
+ *
+ * @param key key string
+ * @param value value string
+ *
+ * @returns Nothing
+******************************************************************************/
+void ht_set( HASHTABLE_T *hashtable, char *key, void *value );
+
+/**************************************************************************//**
+ * Retrieve a key-value pair from a hash table.
+ *
+ * @param key key string
+ *
+ * @returns value string
+******************************************************************************/
+void *ht_get( HASHTABLE_T *hashtable, char *key );
+
#endif