1 /**************************************************************************//**
3 * Implementation of EVEL functions to convert common enum types to strings.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement: This product includes
18 * software developed by the AT&T.
19 * 4. Neither the name of AT&T nor the names of its contributors may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *****************************************************************************/
39 #include "evel_internal.h"
41 /**************************************************************************//**
42 * Map an ::EVEL_COUNTER_CRITICALITIES enum value to the equivalent string.
44 * @param criticality The criticality to convert.
45 * @returns The equivalent string.
46 *****************************************************************************/
47 char * evel_criticality(const EVEL_COUNTER_CRITICALITIES criticality)
55 case EVEL_COUNTER_CRITICALITY_CRIT:
59 case EVEL_COUNTER_CRITICALITY_MAJ:
64 EVEL_ERROR("Unexpected counter criticality %d", criticality);
73 /**************************************************************************//**
74 * Map an ::EVEL_SEVERITIES enum value to the equivalent string.
76 * @param severity The severity to convert.
77 * @returns The equivalent string.
78 *****************************************************************************/
79 char * evel_severity(const EVEL_SEVERITIES severity)
87 case EVEL_SEVERITY_CRITICAL:
91 case EVEL_SEVERITY_MAJOR:
95 case EVEL_SEVERITY_MINOR:
99 case EVEL_SEVERITY_WARNING:
103 case EVEL_SEVERITY_NORMAL:
108 EVEL_ERROR("Unexpected event severity %d", severity);
117 /**************************************************************************//**
118 * Map an ::EVEL_ALERT_ACTIONS enum value to the equivalent string.
120 * @param alert_action The alert_action to convert.
121 * @returns The equivalent string.
122 *****************************************************************************/
123 char * evel_alert_action(const EVEL_ALERT_ACTIONS alert_action)
129 switch (alert_action)
131 case EVEL_ALERT_ACTION_CLEAR:
135 case EVEL_ALERT_ACTION_CONT:
139 case EVEL_ALERT_ACTION_SET:
144 EVEL_ERROR("Unexpected alert action %d", alert_action);
153 /**************************************************************************//**
154 * Map an ::EVEL_ALERT_TYPES enum value to the equivalent string.
156 * @param alert_type The alert_type to convert.
157 * @returns The equivalent string.
158 *****************************************************************************/
159 char * evel_alert_type(const EVEL_ALERT_TYPES alert_type)
167 case EVEL_ALERT_TYPE_CARD:
168 result = "CARD-ANOMALY";
171 case EVEL_ALERT_TYPE_ELEMENT:
172 result = "ELEMENT-ANOMALY";
175 case EVEL_ALERT_TYPE_INTERFACE:
176 result = "INTERFACE-ANOMALY";
179 case EVEL_ALERT_TYPE_SERVICE:
180 result = "SERVICE-ANOMALY";
184 EVEL_ERROR("Unexpected alert type %d", alert_type);
193 /**************************************************************************//**
194 * Map an ::EVEL_EVENT_DOMAINS enum value to the equivalent string.
196 * @param domain The domain to convert.
197 * @returns The equivalent string.
198 *****************************************************************************/
199 char * evel_event_domain(const EVEL_EVENT_DOMAINS domain)
207 case EVEL_DOMAIN_HEARTBEAT:
208 result = "heartbeat";
211 case EVEL_DOMAIN_FAULT:
215 case EVEL_DOMAIN_MEASUREMENT:
216 result = "measurementsForVfScaling";
219 case EVEL_DOMAIN_REPORT:
220 result = "measurementsForVfReporting";
223 case EVEL_DOMAIN_MOBILE_FLOW:
224 result = "mobileFlow";
227 case EVEL_DOMAIN_SERVICE:
228 result = "serviceEvents";
231 case EVEL_DOMAIN_SIGNALING:
232 result = "signaling";
235 case EVEL_DOMAIN_STATE_CHANGE:
236 result = "stateChange";
239 case EVEL_DOMAIN_SYSLOG:
243 case EVEL_DOMAIN_OTHER:
249 EVEL_ERROR("Unexpected domain %d", domain);
258 /**************************************************************************//**
259 * Map an ::EVEL_EVENT_PRIORITIES enum value to the equivalent string.
261 * @param priority The priority to convert.
262 * @returns The equivalent string.
263 *****************************************************************************/
264 char * evel_event_priority(const EVEL_EVENT_PRIORITIES priority)
272 case EVEL_PRIORITY_HIGH:
276 case EVEL_PRIORITY_MEDIUM:
280 case EVEL_PRIORITY_NORMAL:
284 case EVEL_PRIORITY_LOW:
290 EVEL_ERROR("Unexpected priority %d", priority);
299 /**************************************************************************//**
300 * Map an ::EVEL_SOURCE_TYPES enum value to the equivalent string.
302 * @param source_type The source type to convert.
303 * @returns The equivalent string.
304 *****************************************************************************/
305 char * evel_source_type(const EVEL_SOURCE_TYPES source_type)
313 case EVEL_SOURCE_OTHER:
317 case EVEL_SOURCE_ROUTER:
321 case EVEL_SOURCE_SWITCH:
325 case EVEL_SOURCE_HOST:
329 case EVEL_SOURCE_CARD:
333 case EVEL_SOURCE_PORT:
337 case EVEL_SOURCE_SLOT_THRESHOLD:
338 result = "slotThreshold";
341 case EVEL_SOURCE_PORT_THRESHOLD:
342 result = "portThreshold";
345 case EVEL_SOURCE_VIRTUAL_MACHINE:
346 result = "virtualMachine";
349 case EVEL_SOURCE_VIRTUAL_NETWORK_FUNCTION:
350 result = "virtualNetworkFunction";
355 EVEL_ERROR("Unexpected Event Source Type %d", (int) source_type);
364 /**************************************************************************//**
365 * Map an ::EVEL_VF_STATUSES enum value to the equivalent string.
367 * @param vf_status The vf_status to convert.
368 * @returns The equivalent string.
369 *****************************************************************************/
370 char * evel_vf_status(const EVEL_VF_STATUSES vf_status)
378 case EVEL_VF_STATUS_ACTIVE:
382 case EVEL_VF_STATUS_IDLE:
386 case EVEL_VF_STATUS_PREP_TERMINATE:
387 result = "Preparing to terminate";
390 case EVEL_VF_STATUS_READY_TERMINATE:
391 result = "Ready to terminate";
394 case EVEL_VF_STATUS_REQ_TERMINATE:
395 result = "Requesting termination";
400 EVEL_ERROR("Unexpected VF Status %d", vf_status);
409 /**************************************************************************//**
410 * Convert a ::EVEL_ENTITY_STATE to it's string form for JSON encoding.
412 * @param state The entity state to encode.
414 * @returns the corresponding string
415 *****************************************************************************/
416 char * evel_entity_state(const EVEL_ENTITY_STATE state)
424 case EVEL_ENTITY_STATE_IN_SERVICE:
425 result = "inService";
428 case EVEL_ENTITY_STATE_MAINTENANCE:
429 result = "maintenance";
432 case EVEL_ENTITY_STATE_OUT_OF_SERVICE:
433 result = "outOfService";
437 EVEL_ERROR("Unexpected entity state %d", state);
446 /**************************************************************************//**
447 * Convert a ::EVEL_SERVICE_ENDPOINT_DESC to string form for JSON encoding.
449 * @param endpoint_desc endpoint description to encode.
451 * @returns the corresponding string
452 *****************************************************************************/
453 char * evel_service_endpoint_desc(const EVEL_ENTITY_STATE endpoint_desc)
459 switch (endpoint_desc)
461 case EVEL_SERVICE_ENDPOINT_CALLEE:
465 case EVEL_SERVICE_ENDPOINT_CALLER:
470 EVEL_ERROR("Unexpected endpoint description %d", endpoint_desc);