1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 ****************************************************************************/
17 /**************************************************************************//**
19 * Implementation of EVEL functions to convert common enum types to strings.
21 ****************************************************************************/
27 #include "evel_internal.h"
29 /**************************************************************************//**
30 * Map an ::EVEL_COUNTER_CRITICALITIES enum value to the equivalent string.
32 * @param criticality The criticality to convert.
33 * @returns The equivalent string.
34 *****************************************************************************/
35 char * evel_criticality(const EVEL_COUNTER_CRITICALITIES criticality)
43 case EVEL_COUNTER_CRITICALITY_CRIT:
47 case EVEL_COUNTER_CRITICALITY_MAJ:
52 EVEL_ERROR("Unexpected counter criticality %d", criticality);
61 /**************************************************************************//**
62 * Map an ::EVEL_SEVERITIES enum value to the equivalent string.
64 * @param severity The severity to convert.
65 * @returns The equivalent string.
66 *****************************************************************************/
67 char * evel_severity(const EVEL_SEVERITIES severity)
75 case EVEL_SEVERITY_CRITICAL:
79 case EVEL_SEVERITY_MAJOR:
83 case EVEL_SEVERITY_MINOR:
87 case EVEL_SEVERITY_WARNING:
91 case EVEL_SEVERITY_NORMAL:
96 EVEL_ERROR("Unexpected event severity %d", severity);
105 /**************************************************************************//**
106 * Map an ::EVEL_ALERT_ACTIONS enum value to the equivalent string.
108 * @param alert_action The alert_action to convert.
109 * @returns The equivalent string.
110 *****************************************************************************/
111 char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action)
117 switch (alert_action)
119 case EVEL_ALERT_ACTION_CLEAR:
123 case EVEL_ALERT_ACTION_CONT:
127 case EVEL_ALERT_ACTION_SET:
132 EVEL_ERROR("Unexpected alert action %d", alert_action);
141 /**************************************************************************//**
142 * Map an ::EVEL_ALERT_TYPES enum value to the equivalent string.
144 * @param alert_type The alert_type to convert.
145 * @returns The equivalent string.
146 *****************************************************************************/
147 char * evel_alert_type(const EVEL_ALERT_TYPES alert_type)
155 case EVEL_ALERT_TYPE_CARD:
156 result = "CARD-ANOMALY";
159 case EVEL_ALERT_TYPE_ELEMENT:
160 result = "ELEMENT-ANOMALY";
163 case EVEL_ALERT_TYPE_INTERFACE:
164 result = "INTERFACE-ANOMALY";
167 case EVEL_ALERT_TYPE_SERVICE:
168 result = "SERVICE-ANOMALY";
172 EVEL_ERROR("Unexpected alert type %d", alert_type);
181 /**************************************************************************//**
182 * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string.
184 * @param domain The domain to convert.
185 * @returns The equivalent string.
186 *****************************************************************************/
187 char * evel_event_domain(const EVEL_EVENT_DOMAINS domain)
195 case EVEL_DOMAIN_HEARTBEAT:
196 result = "heartbeat";
199 case EVEL_DOMAIN_FAULT:
203 case EVEL_DOMAIN_MEASUREMENT:
204 result = "measurementsForVfScaling";
207 case EVEL_DOMAIN_REPORT:
208 result = "measurementsForVfReporting";
211 case EVEL_DOMAIN_MOBILE_FLOW:
212 result = "mobileFlow";
215 case EVEL_DOMAIN_HEARTBEAT_FIELD:
216 result = "heartbeat";
219 case EVEL_DOMAIN_SIPSIGNALING:
220 result = "sipSignaling";
223 case EVEL_DOMAIN_STATE_CHANGE:
224 result = "stateChange";
227 case EVEL_DOMAIN_SYSLOG:
231 case EVEL_DOMAIN_OTHER:
235 case EVEL_DOMAIN_VOICE_QUALITY:
236 result = "voiceQuality";
241 EVEL_ERROR("Unexpected domain %d", domain);
250 /**************************************************************************//**
251 * Map an ::EVEL_EVENT_PRIORITIES enum value to the equivalent string.
253 * @param priority The priority to convert.
254 * @returns The equivalent string.
255 *****************************************************************************/
256 char * evel_event_priority(const EVEL_EVENT_PRIORITIES priority)
264 case EVEL_PRIORITY_HIGH:
268 case EVEL_PRIORITY_MEDIUM:
272 case EVEL_PRIORITY_NORMAL:
276 case EVEL_PRIORITY_LOW:
282 EVEL_ERROR("Unexpected priority %d", priority);
291 /**************************************************************************//**
292 * Map an ::EVEL_SOURCE_TYPES enum value to the equivalent string.
294 * @param source_type The source type to convert.
295 * @returns The equivalent string.
296 *****************************************************************************/
297 char * evel_source_type(const EVEL_SOURCE_TYPES source_type)
305 case EVEL_SOURCE_OTHER:
309 case EVEL_SOURCE_ROUTER:
313 case EVEL_SOURCE_SWITCH:
317 case EVEL_SOURCE_HOST:
321 case EVEL_SOURCE_CARD:
325 case EVEL_SOURCE_PORT:
329 case EVEL_SOURCE_SLOT_THRESHOLD:
330 result = "slotThreshold";
333 case EVEL_SOURCE_PORT_THRESHOLD:
334 result = "portThreshold";
337 case EVEL_SOURCE_VIRTUAL_MACHINE:
338 result = "virtualMachine";
341 case EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION:
342 result = "virtualNetworkFunction";
347 EVEL_ERROR("Unexpected Event Source Type %d", (int) source_type);
356 /**************************************************************************//**
357 * Map an ::EVEL_VF_STATUSES enum value to the equivalent string.
359 * @param vf_status The vf_status to convert.
360 * @returns The equivalent string.
361 *****************************************************************************/
362 char * evel_vf_status(const EVEL_VF_STATUSES vf_status)
370 case EVEL_VF_STATUS_ACTIVE:
374 case EVEL_VF_STATUS_IDLE:
378 case EVEL_VF_STATUS_PREP_TERMINATE:
379 result = "Preparing to terminate";
382 case EVEL_VF_STATUS_READY_TERMINATE:
383 result = "Ready to terminate";
386 case EVEL_VF_STATUS_REQ_TERMINATE:
387 result = "Requesting termination";
392 EVEL_ERROR("Unexpected VF Status %d", vf_status);
401 /**************************************************************************//**
402 * Convert a ::EVEL_ENTITY_STATE to it's string form for JSON encoding.
404 * @param state The entity state to encode.
406 * @returns the corresponding string
407 *****************************************************************************/
408 char * evel_entity_state(const EVEL_ENTITY_STATE state)
416 case EVEL_ENTITY_STATE_IN_SERVICE:
417 result = "inService";
420 case EVEL_ENTITY_STATE_MAINTENANCE:
421 result = "maintenance";
424 case EVEL_ENTITY_STATE_OUT_OF_SERVICE:
425 result = "outOfService";
429 EVEL_ERROR("Unexpected entity state %d", state);
438 /**************************************************************************//**
439 * Convert a ::EVEL_SERVICE_ENDPOINT_DESC to string form for JSON encoding.
441 * @param endpoint_desc endpoint description to encode.
443 * @returns the corresponding string
444 *****************************************************************************/
445 char * evel_service_endpoint_desc(const EVEL_ENTITY_STATE endpoint_desc)
451 switch (endpoint_desc)
453 case EVEL_SERVICE_ENDPOINT_CALLEE:
457 case EVEL_SERVICE_ENDPOINT_CALLER:
462 EVEL_ERROR("Unexpected endpoint description %d", endpoint_desc);