1 /*************************************************************************//**
3 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
5 * Unless otherwise specified, all software contained herein is
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
17 ****************************************************************************/
19 /**************************************************************************//**
21 * Implementation of EVEL functions relating to Event Headers - since
22 * Heartbeats only contain the Event Header, the Heartbeat factory function is
24 *****************************************************************************/
32 #include "evel_internal.h"
33 #include "evel_throttle.h"
36 /**************************************************************************//**
37 * Unique sequence number for events from this VNF.
38 *****************************************************************************/
39 static int event_sequence = 1;
41 /**************************************************************************//**
42 * Set the next event_sequence to use.
44 * @param sequence The next sequence number to use.
45 *****************************************************************************/
46 void evel_set_global_event_sequence(const int sequence)
50 EVEL_INFO("Setting event sequence to %d, was %d ", sequence, event_sequence);
51 event_sequence = sequence;
57 /**************************************************************************//**
58 * Create a new heartbeat event of given name and type.
60 * @note that the heartbeat is just a "naked" commonEventHeader!
62 * @param event_name Unique Event Name: in format
63 * {DomainAbbreviation}_{AsdcModel or ApplicationPlatform}_{DescriptionOfInfoBeingConveyed}
64 * @param event_id Uniquely identify event for correlation and analysis
66 * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is
67 * not used it must be released using ::evel_free_event
68 * @retval NULL Failed to create the event.
69 *****************************************************************************/
70 EVENT_HEADER * evel_new_heartbeat_nameid(const char* ev_name, const char *ev_id)
72 EVENT_HEADER * heartbeat = NULL;
75 assert(ev_name != NULL);
76 assert(ev_id != NULL);
78 /***************************************************************************/
79 /* Allocate the header. */
80 /***************************************************************************/
81 heartbeat = malloc(sizeof(EVENT_HEADER));
82 if (heartbeat == NULL)
84 log_error_state("Out of memory");
87 memset(heartbeat, 0, sizeof(EVENT_HEADER));
89 /***************************************************************************/
90 /* Initialize the header. Get a new event sequence number. Note that if */
91 /* any memory allocation fails in here we will fail gracefully because */
92 /* everything downstream can cope with NULLs. */
93 /***************************************************************************/
94 evel_init_header_nameid(heartbeat,ev_name,ev_id);
101 /**************************************************************************//**
102 * Create a new heartbeat event.
104 * @note that the heartbeat is just a "naked" commonEventHeader!
106 * @returns pointer to the newly manufactured ::EVENT_HEADER. If the event is
107 * not used it must be released using ::evel_free_event
108 * @retval NULL Failed to create the event.
109 *****************************************************************************/
110 EVENT_HEADER * evel_new_heartbeat()
112 EVENT_HEADER * heartbeat = NULL;
115 /***************************************************************************/
116 /* Allocate the header. */
117 /***************************************************************************/
118 heartbeat = malloc(sizeof(EVENT_HEADER));
119 if (heartbeat == NULL)
121 log_error_state("Out of memory");
124 memset(heartbeat, 0, sizeof(EVENT_HEADER));
126 /***************************************************************************/
127 /* Initialize the header. Get a new event sequence number. Note that if */
128 /* any memory allocation fails in here we will fail gracefully because */
129 /* everything downstream can cope with NULLs. */
130 /***************************************************************************/
131 evel_init_header(heartbeat,"Heartbeat");
132 evel_force_option_string(&heartbeat->event_type, "Autonomous heartbeat");
139 /**************************************************************************//**
140 * Initialize a newly created event header.
142 * @param header Pointer to the header being initialized.
143 *****************************************************************************/
144 void evel_init_header(EVENT_HEADER * const header,const char *const eventname)
146 char scratchpad[EVEL_MAX_STRING_LEN + 1] = {0};
151 assert(header != NULL);
153 gettimeofday(&tv, NULL);
155 /***************************************************************************/
156 /* Initialize the header. Get a new event sequence number. Note that if */
157 /* any memory allocation fails in here we will fail gracefully because */
158 /* everything downstream can cope with NULLs. */
159 /***************************************************************************/
160 header->event_domain = EVEL_DOMAIN_HEARTBEAT;
161 snprintf(scratchpad, EVEL_MAX_STRING_LEN, "%d", event_sequence);
162 header->event_id = strdup(scratchpad);
163 if( eventname == NULL )
164 header->event_name = strdup(functional_role);
166 header->event_name = strdup(eventname);
167 header->last_epoch_microsec = tv.tv_usec + 1000000 * tv.tv_sec;
168 header->priority = EVEL_PRIORITY_NORMAL;
169 header->reporting_entity_name = strdup(openstack_vm_name());
170 header->source_name = strdup(openstack_vm_name());
171 header->sequence = 0;
172 header->start_epoch_microsec = header->last_epoch_microsec;
173 header->major_version = EVEL_HEADER_MAJOR_VERSION;
174 header->minor_version = EVEL_HEADER_MINOR_VERSION;
177 /***************************************************************************/
178 /* Optional parameters. */
179 /***************************************************************************/
180 evel_init_option_string(&header->event_type);
181 evel_init_option_string(&header->nfcnaming_code);
182 evel_init_option_string(&header->nfnaming_code);
183 evel_init_option_string(&header->reporting_entity_id);
184 evel_init_option_string(&header->source_id);
185 evel_init_option_intheader(&header->internal_field);
186 dlist_initialize(&header->batch_events);
192 /**************************************************************************//**
193 * Initialize a newly created event header.
195 * @param header Pointer to the header being initialized.
196 * @param eventname Eventname string
197 * @param eventid Event id : unique id for classification and analysis
198 * @param header Pointer to the header being initialized.
199 *****************************************************************************/
200 void evel_init_header_nameid(EVENT_HEADER * const header,const char *const eventname, const char *eventid)
206 assert(header != NULL);
207 assert(eventname != NULL);
208 assert(eventid != NULL);
210 gettimeofday(&tv, NULL);
212 /***************************************************************************/
213 /* Initialize the header. Reset event sequence number. Note that if */
214 /* any memory allocation fails in here we will fail gracefully because */
215 /* everything downstream can cope with NULLs. */
216 /***************************************************************************/
217 header->event_domain = EVEL_DOMAIN_HEARTBEAT;
218 header->event_id = strdup(eventid);
219 header->event_name = strdup(eventname);
220 header->last_epoch_microsec = tv.tv_usec + 1000000 * tv.tv_sec;
221 header->priority = EVEL_PRIORITY_NORMAL;
222 header->reporting_entity_name = strdup(openstack_vm_name());
223 header->source_name = strdup(openstack_vm_name());
224 header->sequence = 0;
225 header->start_epoch_microsec = header->last_epoch_microsec;
226 header->major_version = EVEL_HEADER_MAJOR_VERSION;
227 header->minor_version = EVEL_HEADER_MINOR_VERSION;
229 /***************************************************************************/
230 /* Optional parameters. */
231 /***************************************************************************/
232 evel_init_option_string(&header->event_type);
233 evel_init_option_string(&header->nfcnaming_code);
234 evel_init_option_string(&header->nfnaming_code);
235 evel_init_option_string(&header->reporting_entity_id);
236 evel_init_option_string(&header->source_id);
237 evel_init_option_intheader(&header->internal_field);
238 dlist_initialize(&header->batch_events);
243 /**************************************************************************//**
244 * Set the Event Type property of the event header.
246 * @note The property is treated as immutable: it is only valid to call
247 * the setter once. However, we don't assert if the caller tries to
248 * overwrite, just ignoring the update instead.
250 * @param header Pointer to the ::EVENT_HEADER.
251 * @param type The Event Type to be set. ASCIIZ string. The caller
252 * does not need to preserve the value once the function
254 *****************************************************************************/
255 void evel_header_type_set(EVENT_HEADER * const header,
256 const char * const type)
260 /***************************************************************************/
261 /* Check preconditions. */
262 /***************************************************************************/
263 assert(header != NULL);
264 assert(type != NULL);
266 evel_set_option_string(&header->event_type, type, "Event Type");
271 /**************************************************************************//**
272 * Set the Event Sequence property of the event header.
274 * @note The Start Epoch defaults to the time of event creation.
276 * @param header Pointer to the ::EVENT_HEADER.
277 * @param start_epoch_microsec
278 * The start epoch to set, in microseconds.
279 *****************************************************************************/
280 void evel_event_sequence_set(EVENT_HEADER * const header,const int sequence_number)
284 /***************************************************************************/
285 /* Check preconditions and assign the new value. */
286 /***************************************************************************/
287 assert(header != NULL);
288 header->sequence = sequence_number;
294 /**************************************************************************//**
295 * Set the Start Epoch property of the event header.
297 * @note The Start Epoch defaults to the time of event creation.
299 * @param header Pointer to the ::EVENT_HEADER.
300 * @param start_epoch_microsec
301 * The start epoch to set, in microseconds.
302 *****************************************************************************/
303 void evel_start_epoch_set(EVENT_HEADER * const header,
304 const unsigned long long start_epoch_microsec)
308 /***************************************************************************/
309 /* Check preconditions and assign the new value. */
310 /***************************************************************************/
311 assert(header != NULL);
312 header->start_epoch_microsec = start_epoch_microsec;
317 /**************************************************************************//**
318 * Set the Last Epoch property of the event header.
320 * @note The Last Epoch defaults to the time of event creation.
322 * @param header Pointer to the ::EVENT_HEADER.
323 * @param last_epoch_microsec
324 * The last epoch to set, in microseconds.
325 *****************************************************************************/
326 void evel_last_epoch_set(EVENT_HEADER * const header,
327 const unsigned long long last_epoch_microsec)
331 /***************************************************************************/
332 /* Check preconditions and assign the new value. */
333 /***************************************************************************/
334 assert(header != NULL);
335 header->last_epoch_microsec = last_epoch_microsec;
340 /**************************************************************************//**
341 * Set the NFC Naming code property of the event header.
343 * @param header Pointer to the ::EVENT_HEADER.
344 * @param nfcnamingcode String
345 *****************************************************************************/
346 void evel_nfcnamingcode_set(EVENT_HEADER * const header,
347 const char * const nfcnam)
351 /***************************************************************************/
352 /* Check preconditions and assign the new value. */
353 /***************************************************************************/
354 assert(header != NULL);
355 assert(nfcnam != NULL);
356 evel_set_option_string(&header->nfcnaming_code, nfcnam, "NFC Naming Code");
361 /**************************************************************************//**
362 * Set the NF Naming code property of the event header.
364 * @param header Pointer to the ::EVENT_HEADER.
365 * @param nfnamingcode String
366 *****************************************************************************/
367 void evel_nfnamingcode_set(EVENT_HEADER * const header,
368 const char * const nfnam)
372 /***************************************************************************/
373 /* Check preconditions and assign the new value. */
374 /***************************************************************************/
375 assert(header != NULL);
376 assert(nfnam != NULL);
377 evel_set_option_string(&header->nfnaming_code, nfnam, "NF Naming Code");
383 /**************************************************************************//**
384 * Set the Reporting Entity Name property of the event header.
386 * @note The Reporting Entity Name defaults to the OpenStack VM Name.
388 * @param header Pointer to the ::EVENT_HEADER.
389 * @param entity_name The entity name to set.
390 *****************************************************************************/
391 void evel_reporting_entity_name_set(EVENT_HEADER * const header,
392 const char * const entity_name)
396 /***************************************************************************/
397 /* Check preconditions and assign the new value. */
398 /***************************************************************************/
399 assert(header != NULL);
400 assert(entity_name != NULL);
401 assert(header->reporting_entity_name != NULL);
403 /***************************************************************************/
404 /* Free the previously allocated memory and replace it with a copy of the */
406 /***************************************************************************/
407 free(header->reporting_entity_name);
408 header->reporting_entity_name = strdup(entity_name);
413 /**************************************************************************//**
414 * Set the Reporting Entity Id property of the event header.
416 * @note The Reporting Entity Id defaults to the OpenStack VM UUID.
418 * @param header Pointer to the ::EVENT_HEADER.
419 * @param entity_id The entity id to set.
420 *****************************************************************************/
421 void evel_reporting_entity_id_set(EVENT_HEADER * const header,
422 const char * const entity_id)
426 /***************************************************************************/
427 /* Check preconditions and assign the new value. */
428 /***************************************************************************/
429 assert(header != NULL);
430 assert(entity_id != NULL);
432 /***************************************************************************/
433 /* Free the previously allocated memory and replace it with a copy of the */
434 /* provided one. Note that evel_force_option_string strdups entity_id. */
435 /***************************************************************************/
436 evel_free_option_string(&header->reporting_entity_id);
437 evel_force_option_string(&header->reporting_entity_id, entity_id);
442 /**************************************************************************//**
443 * Encode the event as a JSON event object according to AT&T's schema.
445 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
446 * @param event Pointer to the ::EVENT_HEADER to encode.
447 *****************************************************************************/
448 void evel_json_encode_header(EVEL_JSON_BUFFER * jbuf,
449 EVENT_HEADER * event)
456 /***************************************************************************/
457 /* Check preconditions. */
458 /***************************************************************************/
459 assert(jbuf != NULL);
460 assert(jbuf->json != NULL);
461 assert(jbuf->max_size > 0);
462 assert(event != NULL);
464 domain = evel_event_domain(event->event_domain);
465 priority = evel_event_priority(event->priority);
466 evel_json_open_named_object(jbuf, "commonEventHeader");
468 /***************************************************************************/
469 /* Mandatory fields. */
470 /***************************************************************************/
471 evel_enc_kv_string(jbuf, "domain", domain);
472 evel_enc_kv_string(jbuf, "eventId", event->event_id);
473 evel_enc_kv_string(jbuf, "eventName", event->event_name);
474 evel_enc_kv_ull(jbuf, "lastEpochMicrosec", event->last_epoch_microsec);
475 evel_enc_kv_string(jbuf, "priority", priority);
477 jbuf, "reportingEntityName", event->reporting_entity_name);
478 evel_enc_kv_int(jbuf, "sequence", event->sequence);
479 evel_enc_kv_string(jbuf, "sourceName", event->source_name);
480 evel_enc_kv_ull(jbuf, "startEpochMicrosec", event->start_epoch_microsec);
482 jbuf, "version", event->major_version, event->minor_version);
484 /***************************************************************************/
485 /* Optional fields. */
486 /***************************************************************************/
487 evel_enc_kv_opt_string(jbuf, "eventType", &event->event_type);
488 evel_enc_kv_opt_string(
489 jbuf, "reportingEntityId", &event->reporting_entity_id);
490 evel_enc_kv_opt_string(jbuf, "sourceId", &event->source_id);
491 evel_enc_kv_opt_string(jbuf, "nfcNamingCode", &event->nfcnaming_code);
492 evel_enc_kv_opt_string(jbuf, "nfNamingCode", &event->nfnaming_code);
494 evel_json_close_object(jbuf);
499 /**************************************************************************//**
500 * Free an event header.
502 * Free off the event header supplied. Will free all the contained allocated
505 * @note It does not free the header itself, since that may be part of a
507 *****************************************************************************/
508 void evel_free_header(EVENT_HEADER * const event)
512 /***************************************************************************/
513 /* Check preconditions. As an internal API we don't allow freeing NULL */
514 /* events as we do on the public API. */
515 /***************************************************************************/
516 assert(event != NULL);
518 /***************************************************************************/
519 /* Free all internal strings. */
520 /***************************************************************************/
521 free(event->event_id);
522 evel_free_option_string(&event->event_type);
523 free(event->event_name);
524 evel_free_option_string(&event->reporting_entity_id);
525 free(event->reporting_entity_name);
526 evel_free_option_string(&event->source_id);
527 evel_free_option_string(&event->nfcnaming_code);
528 evel_free_option_string(&event->nfnaming_code);
529 evel_free_option_intheader(&event->internal_field);
530 free(event->source_name);
536 /**************************************************************************//**
537 * Encode the event as a JSON event object according to AT&T's schema.
539 * @param json Pointer to where to store the JSON encoded data.
540 * @param max_size Size of storage available in json_body.
541 * @param event Pointer to the ::EVENT_HEADER to encode.
542 * @returns Number of bytes actually written.
543 *****************************************************************************/
544 void evel_json_encode_eventtype(
545 EVEL_JSON_BUFFER * jbuf,
546 EVENT_HEADER * event)
548 switch (event->event_domain)
550 case EVEL_DOMAIN_HEARTBEAT:
551 evel_json_encode_header(jbuf, event);
554 case EVEL_DOMAIN_FAULT:
555 evel_json_encode_fault(jbuf, (EVENT_FAULT *)event);
558 case EVEL_DOMAIN_MEASUREMENT:
559 evel_json_encode_measurement(jbuf, (EVENT_MEASUREMENT *)event);
562 case EVEL_DOMAIN_MOBILE_FLOW:
563 evel_json_encode_mobile_flow(jbuf, (EVENT_MOBILE_FLOW *)event);
566 case EVEL_DOMAIN_REPORT:
567 evel_json_encode_report(jbuf, (EVENT_REPORT *)event);
570 case EVEL_DOMAIN_HEARTBEAT_FIELD:
571 evel_json_encode_hrtbt_field(jbuf, (EVENT_HEARTBEAT_FIELD *)event);
574 case EVEL_DOMAIN_SIPSIGNALING:
575 evel_json_encode_signaling(jbuf, (EVENT_SIGNALING *)event);
578 case EVEL_DOMAIN_STATE_CHANGE:
579 evel_json_encode_state_change(jbuf, (EVENT_STATE_CHANGE *)event);
582 case EVEL_DOMAIN_SYSLOG:
583 evel_json_encode_syslog(jbuf, (EVENT_SYSLOG *)event);
586 case EVEL_DOMAIN_OTHER:
587 evel_json_encode_other(jbuf, (EVENT_OTHER *)event);
590 case EVEL_DOMAIN_VOICE_QUALITY:
591 evel_json_encode_voice_quality(jbuf, (EVENT_VOICE_QUALITY *)event);
594 case EVEL_DOMAIN_THRESHOLD_CROSS:
595 evel_json_encode_threshold_cross(jbuf, (EVENT_THRESHOLD_CROSS *)event);
598 case EVEL_DOMAIN_INTERNAL:
600 EVEL_ERROR("Unexpected domain %d", event->event_domain);
607 /**************************************************************************//**
608 * Encode the event as a JSON event object according to AT&T's schema.
610 * @param json Pointer to where to store the JSON encoded data.
611 * @param max_size Size of storage available in json_body.
612 * @param event Pointer to the ::EVENT_HEADER to encode.
613 * @returns Number of bytes actually written.
614 *****************************************************************************/
615 int evel_json_encode_event(char * json,
617 EVENT_HEADER * event)
619 EVEL_JSON_BUFFER json_buffer;
620 EVEL_JSON_BUFFER * jbuf = &json_buffer;
621 EVEL_THROTTLE_SPEC * throttle_spec;
625 /***************************************************************************/
626 /* Get the latest throttle specification for the domain. */
627 /***************************************************************************/
628 throttle_spec = evel_get_throttle_spec(event->event_domain);
630 /***************************************************************************/
631 /* Initialize the JSON_BUFFER and open the top-level objects. */
632 /***************************************************************************/
633 evel_json_buffer_init(jbuf, json, max_size, throttle_spec);
634 evel_json_open_object(jbuf);
635 evel_json_open_named_object(jbuf, "event");
637 evel_json_encode_eventtype(jbuf, event);
639 evel_json_close_object(jbuf);
640 evel_json_close_object(jbuf);
642 /***************************************************************************/
644 /***************************************************************************/
645 assert(jbuf->depth == 0);
646 if( jbuf->offset >= max_size ){
647 EVEL_ERROR("Event exceeded size limit %d", max_size);
655 /**************************************************************************//**
656 * Encode the event as a JSON event object according to AT&T's schema.
658 * @param json Pointer to where to store the JSON encoded data.
659 * @param max_size Size of storage available in json_body.
660 * @param event Pointer to the ::EVENT_HEADER to encode.
661 * @returns Number of bytes actually written.
662 *****************************************************************************/
663 int evel_json_encode_batch_event(char * json,
665 EVENT_HEADER * event)
667 EVEL_JSON_BUFFER json_buffer;
668 EVEL_JSON_BUFFER *jbuf = &json_buffer;
669 EVEL_THROTTLE_SPEC * throttle_spec;
671 EVENT_HEADER * batch_field = NULL;
672 DLIST_ITEM * batch_field_item = NULL;
676 /***************************************************************************/
677 /* Get the latest throttle specification for the domain. */
678 /***************************************************************************/
679 throttle_spec = evel_get_throttle_spec(event->event_domain);
681 /***************************************************************************/
682 /* Initialize the JSON_BUFFER and open the top-level objects. */
683 /***************************************************************************/
684 if (event->event_domain == EVEL_DOMAIN_BATCH){
685 evel_json_buffer_init(jbuf, json, max_size, throttle_spec);
687 if(dlist_count(&event->batch_events) > 0)
689 evel_json_open_object(jbuf);
690 evel_json_open_named_list(jbuf, "eventList");
691 batch_field_item = dlist_get_first(&event->batch_events);
692 while (batch_field_item != NULL)
694 batch_field = (EVENT_HEADER *) batch_field_item->item;
695 if(batch_field != NULL){
696 EVEL_DEBUG("Batch Event %p %p added curr fsize %d offset %d depth %d check %d", batch_field_item->item, batch_field, tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint);
697 evel_json_open_object(jbuf);
698 evel_json_encode_eventtype(jbuf, batch_field);
699 evel_json_close_object(jbuf);
701 tot_size += jbuf->offset;
702 EVEL_DEBUG("Batch Event result size %d offset %d depth %d check %d", tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint);
703 if( tot_size >= max_size ){
704 EVEL_ERROR("Batch Event exceeded size limit %d", tot_size);
707 batch_field_item = dlist_get_next(batch_field_item);
710 evel_json_close_list(jbuf);
711 evel_json_close_object(jbuf);
715 /***************************************************************************/
717 /***************************************************************************/
718 //assert(jbuf->depth == 0);
726 /**************************************************************************//**
727 * Initialize an event instance id.
729 * @param vfield Pointer to the event vnfname field being initialized.
730 * @param vendor_id The vendor id to encode in the event instance id.
731 * @param event_id The event id to encode in the event instance id.
732 *****************************************************************************/
733 void evel_init_vendor_field(VENDOR_VNFNAME_FIELD * const vfield,
734 const char * const vendor_name)
738 /***************************************************************************/
739 /* Check preconditions. */
740 /***************************************************************************/
741 assert(vfield != NULL);
742 assert(vendor_name != NULL);
744 /***************************************************************************/
745 /* Store the mandatory parts. */
746 /***************************************************************************/
747 vfield->vendorname = strdup(vendor_name);
748 evel_init_option_string(&vfield->vfmodule);
749 evel_init_option_string(&vfield->vnfname);
751 /***************************************************************************/
752 /* Initialize the optional parts. */
753 /***************************************************************************/
758 /**************************************************************************//**
759 * Set the Vendor module property of the Vendor.
761 * @note The property is treated as immutable: it is only valid to call
762 * the setter once. However, we don't assert if the caller tries to
763 * overwrite, just ignoring the update instead.
765 * @param vfield Pointer to the Vendor field.
766 * @param module_name The module name to be set. ASCIIZ string. The caller
767 * does not need to preserve the value once the function
769 *****************************************************************************/
770 void evel_vendor_field_module_set(VENDOR_VNFNAME_FIELD * const vfield,
771 const char * const module_name)
775 /***************************************************************************/
776 /* Check preconditions. */
777 /***************************************************************************/
778 assert(vfield != NULL);
779 assert(module_name != NULL);
781 evel_set_option_string(&vfield->vfmodule, module_name, "Module name set");
786 /**************************************************************************//**
787 * Set the Vendor module property of the Vendor.
789 * @note The property is treated as immutable: it is only valid to call
790 * the setter once. However, we don't assert if the caller tries to
791 * overwrite, just ignoring the update instead.
793 * @param vfield Pointer to the Vendor field.
794 * @param module_name The module name to be set. ASCIIZ string. The caller
795 * does not need to preserve the value once the function
797 *****************************************************************************/
798 void evel_vendor_field_vnfname_set(VENDOR_VNFNAME_FIELD * const vfield,
799 const char * const vnfname)
803 /***************************************************************************/
804 /* Check preconditions. */
805 /***************************************************************************/
806 assert(vfield != NULL);
807 assert(vnfname != NULL);
809 evel_set_option_string(&vfield->vnfname, vnfname, "Virtual Network Function name set");
814 /**************************************************************************//**
815 * Free an event instance id.
817 * @param vfield Pointer to the event vnfname_field being freed.
818 *****************************************************************************/
819 void evel_free_event_vendor_field(VENDOR_VNFNAME_FIELD * const vfield)
823 /***************************************************************************/
824 /* Check preconditions. */
825 /***************************************************************************/
826 assert(vfield->vendorname != NULL);
828 /***************************************************************************/
829 /* Free everything. */
830 /***************************************************************************/
831 evel_free_option_string(&vfield->vfmodule);
832 evel_free_option_string(&vfield->vnfname);
833 free(vfield->vendorname);
838 /**************************************************************************//**
839 * Encode the instance id as a JSON object according to AT&T's schema.
841 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
842 * @param vfield Pointer to the ::VENDOR_VNFNAME_FIELD to encode.
843 *****************************************************************************/
844 void evel_json_encode_vendor_field(EVEL_JSON_BUFFER * jbuf,
845 VENDOR_VNFNAME_FIELD * vfield)
849 /***************************************************************************/
850 /* Check preconditions. */
851 /***************************************************************************/
852 assert(jbuf != NULL);
853 assert(jbuf->json != NULL);
854 assert(jbuf->max_size > 0);
855 assert(vfield != NULL);
856 assert(vfield->vendorname != NULL);
858 evel_json_open_named_object(jbuf, "vendorVnfNameFields");
860 /***************************************************************************/
861 /* Mandatory fields. */
862 /***************************************************************************/
863 evel_enc_kv_string(jbuf, "vendorName", vfield->vendorname);
864 evel_enc_kv_opt_string(jbuf, "vfModuleName", &vfield->vfmodule);
865 evel_enc_kv_opt_string(jbuf, "vnfName", &vfield->vnfname);
867 /***************************************************************************/
868 /* Optional fields. */
869 /***************************************************************************/
871 evel_json_close_object(jbuf);