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_next_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 = event_sequence;
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_force_option_string(&header->reporting_entity_id, openstack_vm_uuid());
184 evel_force_option_string(&header->source_id, openstack_vm_uuid());
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. Get a new 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 = event_sequence;
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;
230 /***************************************************************************/
231 /* Optional parameters. */
232 /***************************************************************************/
233 evel_init_option_string(&header->event_type);
234 evel_init_option_string(&header->nfcnaming_code);
235 evel_init_option_string(&header->nfnaming_code);
236 evel_force_option_string(&header->reporting_entity_id, openstack_vm_uuid());
237 evel_force_option_string(&header->source_id, openstack_vm_uuid());
238 evel_init_option_intheader(&header->internal_field);
239 dlist_initialize(&header->batch_events);
244 /**************************************************************************//**
245 * Set the Event Type property of the event header.
247 * @note The property is treated as immutable: it is only valid to call
248 * the setter once. However, we don't assert if the caller tries to
249 * overwrite, just ignoring the update instead.
251 * @param header Pointer to the ::EVENT_HEADER.
252 * @param type The Event Type to be set. ASCIIZ string. The caller
253 * does not need to preserve the value once the function
255 *****************************************************************************/
256 void evel_header_type_set(EVENT_HEADER * const header,
257 const char * const type)
261 /***************************************************************************/
262 /* Check preconditions. */
263 /***************************************************************************/
264 assert(header != NULL);
265 assert(type != NULL);
267 evel_set_option_string(&header->event_type, type, "Event Type");
272 /**************************************************************************//**
273 * Set the Start Epoch property of the event header.
275 * @note The Start Epoch defaults to the time of event creation.
277 * @param header Pointer to the ::EVENT_HEADER.
278 * @param start_epoch_microsec
279 * The start epoch to set, in microseconds.
280 *****************************************************************************/
281 void evel_start_epoch_set(EVENT_HEADER * const header,
282 const unsigned long long start_epoch_microsec)
286 /***************************************************************************/
287 /* Check preconditions and assign the new value. */
288 /***************************************************************************/
289 assert(header != NULL);
290 header->start_epoch_microsec = start_epoch_microsec;
295 /**************************************************************************//**
296 * Set the Last Epoch property of the event header.
298 * @note The Last Epoch defaults to the time of event creation.
300 * @param header Pointer to the ::EVENT_HEADER.
301 * @param last_epoch_microsec
302 * The last epoch to set, in microseconds.
303 *****************************************************************************/
304 void evel_last_epoch_set(EVENT_HEADER * const header,
305 const unsigned long long last_epoch_microsec)
309 /***************************************************************************/
310 /* Check preconditions and assign the new value. */
311 /***************************************************************************/
312 assert(header != NULL);
313 header->last_epoch_microsec = last_epoch_microsec;
318 /**************************************************************************//**
319 * Set the NFC Naming code property of the event header.
321 * @param header Pointer to the ::EVENT_HEADER.
322 * @param nfcnamingcode String
323 *****************************************************************************/
324 void evel_nfcnamingcode_set(EVENT_HEADER * const header,
325 const char * const nfcnam)
329 /***************************************************************************/
330 /* Check preconditions and assign the new value. */
331 /***************************************************************************/
332 assert(header != NULL);
333 assert(nfcnam != NULL);
334 evel_set_option_string(&header->nfcnaming_code, nfcnam, "NFC Naming Code");
339 /**************************************************************************//**
340 * Set the NF Naming code property of the event header.
342 * @param header Pointer to the ::EVENT_HEADER.
343 * @param nfnamingcode String
344 *****************************************************************************/
345 void evel_nfnamingcode_set(EVENT_HEADER * const header,
346 const char * const nfnam)
350 /***************************************************************************/
351 /* Check preconditions and assign the new value. */
352 /***************************************************************************/
353 assert(header != NULL);
354 assert(nfnam != NULL);
355 evel_set_option_string(&header->nfnaming_code, nfnam, "NF Naming Code");
361 /**************************************************************************//**
362 * Set the Reporting Entity Name property of the event header.
364 * @note The Reporting Entity Name defaults to the OpenStack VM Name.
366 * @param header Pointer to the ::EVENT_HEADER.
367 * @param entity_name The entity name to set.
368 *****************************************************************************/
369 void evel_reporting_entity_name_set(EVENT_HEADER * const header,
370 const char * const entity_name)
374 /***************************************************************************/
375 /* Check preconditions and assign the new value. */
376 /***************************************************************************/
377 assert(header != NULL);
378 assert(entity_name != NULL);
379 assert(header->reporting_entity_name != NULL);
381 /***************************************************************************/
382 /* Free the previously allocated memory and replace it with a copy of the */
384 /***************************************************************************/
385 free(header->reporting_entity_name);
386 header->reporting_entity_name = strdup(entity_name);
391 /**************************************************************************//**
392 * Set the Reporting Entity Id property of the event header.
394 * @note The Reporting Entity Id defaults to the OpenStack VM UUID.
396 * @param header Pointer to the ::EVENT_HEADER.
397 * @param entity_id The entity id to set.
398 *****************************************************************************/
399 void evel_reporting_entity_id_set(EVENT_HEADER * const header,
400 const char * const entity_id)
404 /***************************************************************************/
405 /* Check preconditions and assign the new value. */
406 /***************************************************************************/
407 assert(header != NULL);
408 assert(entity_id != NULL);
410 /***************************************************************************/
411 /* Free the previously allocated memory and replace it with a copy of the */
412 /* provided one. Note that evel_force_option_string strdups entity_id. */
413 /***************************************************************************/
414 evel_free_option_string(&header->reporting_entity_id);
415 evel_force_option_string(&header->reporting_entity_id, entity_id);
420 /**************************************************************************//**
421 * Encode the event as a JSON event object according to AT&T's schema.
423 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
424 * @param event Pointer to the ::EVENT_HEADER to encode.
425 *****************************************************************************/
426 void evel_json_encode_header(EVEL_JSON_BUFFER * jbuf,
427 EVENT_HEADER * event)
434 /***************************************************************************/
435 /* Check preconditions. */
436 /***************************************************************************/
437 assert(jbuf != NULL);
438 assert(jbuf->json != NULL);
439 assert(jbuf->max_size > 0);
440 assert(event != NULL);
442 domain = evel_event_domain(event->event_domain);
443 priority = evel_event_priority(event->priority);
444 evel_json_open_named_object(jbuf, "commonEventHeader");
446 /***************************************************************************/
447 /* Mandatory fields. */
448 /***************************************************************************/
449 evel_enc_kv_string(jbuf, "domain", domain);
450 evel_enc_kv_string(jbuf, "eventId", event->event_id);
451 evel_enc_kv_string(jbuf, "eventName", event->event_name);
452 evel_enc_kv_ull(jbuf, "lastEpochMicrosec", event->last_epoch_microsec);
453 evel_enc_kv_string(jbuf, "priority", priority);
455 jbuf, "reportingEntityName", event->reporting_entity_name);
456 evel_enc_kv_int(jbuf, "sequence", event->sequence);
457 evel_enc_kv_string(jbuf, "sourceName", event->source_name);
458 evel_enc_kv_ull(jbuf, "startEpochMicrosec", event->start_epoch_microsec);
460 jbuf, "version", event->major_version, event->minor_version);
462 /***************************************************************************/
463 /* Optional fields. */
464 /***************************************************************************/
465 evel_enc_kv_opt_string(jbuf, "eventType", &event->event_type);
466 evel_enc_kv_opt_string(
467 jbuf, "reportingEntityId", &event->reporting_entity_id);
468 evel_enc_kv_opt_string(jbuf, "sourceId", &event->source_id);
469 evel_enc_kv_opt_string(jbuf, "nfcNamingCode", &event->nfcnaming_code);
470 evel_enc_kv_opt_string(jbuf, "nfNamingCode", &event->nfnaming_code);
472 evel_json_close_object(jbuf);
477 /**************************************************************************//**
478 * Free an event header.
480 * Free off the event header supplied. Will free all the contained allocated
483 * @note It does not free the header itself, since that may be part of a
485 *****************************************************************************/
486 void evel_free_header(EVENT_HEADER * const event)
490 /***************************************************************************/
491 /* Check preconditions. As an internal API we don't allow freeing NULL */
492 /* events as we do on the public API. */
493 /***************************************************************************/
494 assert(event != NULL);
496 /***************************************************************************/
497 /* Free all internal strings. */
498 /***************************************************************************/
499 free(event->event_id);
500 evel_free_option_string(&event->event_type);
501 free(event->event_name);
502 evel_free_option_string(&event->reporting_entity_id);
503 free(event->reporting_entity_name);
504 evel_free_option_string(&event->source_id);
505 evel_free_option_string(&event->nfcnaming_code);
506 evel_free_option_string(&event->nfnaming_code);
507 evel_free_option_intheader(&event->internal_field);
508 free(event->source_name);
514 /**************************************************************************//**
515 * Encode the event as a JSON event object according to AT&T's schema.
517 * @param json Pointer to where to store the JSON encoded data.
518 * @param max_size Size of storage available in json_body.
519 * @param event Pointer to the ::EVENT_HEADER to encode.
520 * @returns Number of bytes actually written.
521 *****************************************************************************/
522 void evel_json_encode_eventtype(
523 EVEL_JSON_BUFFER * jbuf,
524 EVENT_HEADER * event)
526 switch (event->event_domain)
528 case EVEL_DOMAIN_HEARTBEAT:
529 evel_json_encode_header(jbuf, event);
532 case EVEL_DOMAIN_FAULT:
533 evel_json_encode_fault(jbuf, (EVENT_FAULT *)event);
536 case EVEL_DOMAIN_MEASUREMENT:
537 evel_json_encode_measurement(jbuf, (EVENT_MEASUREMENT *)event);
540 case EVEL_DOMAIN_MOBILE_FLOW:
541 evel_json_encode_mobile_flow(jbuf, (EVENT_MOBILE_FLOW *)event);
544 case EVEL_DOMAIN_REPORT:
545 evel_json_encode_report(jbuf, (EVENT_REPORT *)event);
548 case EVEL_DOMAIN_HEARTBEAT_FIELD:
549 evel_json_encode_hrtbt_field(jbuf, (EVENT_HEARTBEAT_FIELD *)event);
552 case EVEL_DOMAIN_SIPSIGNALING:
553 evel_json_encode_signaling(jbuf, (EVENT_SIGNALING *)event);
556 case EVEL_DOMAIN_STATE_CHANGE:
557 evel_json_encode_state_change(jbuf, (EVENT_STATE_CHANGE *)event);
560 case EVEL_DOMAIN_SYSLOG:
561 evel_json_encode_syslog(jbuf, (EVENT_SYSLOG *)event);
564 case EVEL_DOMAIN_OTHER:
565 evel_json_encode_other(jbuf, (EVENT_OTHER *)event);
568 case EVEL_DOMAIN_VOICE_QUALITY:
569 evel_json_encode_voice_quality(jbuf, (EVENT_VOICE_QUALITY *)event);
572 case EVEL_DOMAIN_THRESHOLD_CROSS:
573 evel_json_encode_threshold_cross(jbuf, (EVENT_THRESHOLD_CROSS *)event);
576 case EVEL_DOMAIN_INTERNAL:
578 EVEL_ERROR("Unexpected domain %d", event->event_domain);
585 /**************************************************************************//**
586 * Encode the event as a JSON event object according to AT&T's schema.
588 * @param json Pointer to where to store the JSON encoded data.
589 * @param max_size Size of storage available in json_body.
590 * @param event Pointer to the ::EVENT_HEADER to encode.
591 * @returns Number of bytes actually written.
592 *****************************************************************************/
593 int evel_json_encode_event(char * json,
595 EVENT_HEADER * event)
597 EVEL_JSON_BUFFER json_buffer;
598 EVEL_JSON_BUFFER * jbuf = &json_buffer;
599 EVEL_THROTTLE_SPEC * throttle_spec;
603 /***************************************************************************/
604 /* Get the latest throttle specification for the domain. */
605 /***************************************************************************/
606 throttle_spec = evel_get_throttle_spec(event->event_domain);
608 /***************************************************************************/
609 /* Initialize the JSON_BUFFER and open the top-level objects. */
610 /***************************************************************************/
611 evel_json_buffer_init(jbuf, json, max_size, throttle_spec);
612 evel_json_open_object(jbuf);
613 evel_json_open_named_object(jbuf, "event");
615 evel_json_encode_eventtype(jbuf, event);
617 evel_json_close_object(jbuf);
618 evel_json_close_object(jbuf);
620 /***************************************************************************/
622 /***************************************************************************/
623 assert(jbuf->depth == 0);
624 if( jbuf->offset >= max_size ){
625 EVEL_ERROR("Event exceeded size limit %d", max_size);
633 /**************************************************************************//**
634 * Encode the event as a JSON event object according to AT&T's schema.
636 * @param json Pointer to where to store the JSON encoded data.
637 * @param max_size Size of storage available in json_body.
638 * @param event Pointer to the ::EVENT_HEADER to encode.
639 * @returns Number of bytes actually written.
640 *****************************************************************************/
641 int evel_json_encode_batch_event(char * json,
643 EVENT_HEADER * event)
645 EVEL_JSON_BUFFER json_buffer;
646 EVEL_JSON_BUFFER *jbuf = &json_buffer;
647 EVEL_THROTTLE_SPEC * throttle_spec;
649 EVENT_HEADER * batch_field = NULL;
650 DLIST_ITEM * batch_field_item = NULL;
654 /***************************************************************************/
655 /* Get the latest throttle specification for the domain. */
656 /***************************************************************************/
657 throttle_spec = evel_get_throttle_spec(event->event_domain);
659 /***************************************************************************/
660 /* Initialize the JSON_BUFFER and open the top-level objects. */
661 /***************************************************************************/
662 if (event->event_domain == EVEL_DOMAIN_BATCH){
663 evel_json_buffer_init(jbuf, json, max_size, throttle_spec);
665 if(dlist_count(&event->batch_events) > 0)
667 evel_json_open_object(jbuf);
668 evel_json_open_named_list(jbuf, "eventList");
669 batch_field_item = dlist_get_first(&event->batch_events);
670 while (batch_field_item != NULL)
672 batch_field = (EVENT_HEADER *) batch_field_item->item;
673 if(batch_field != NULL){
674 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);
675 evel_json_open_object(jbuf);
676 evel_json_encode_eventtype(jbuf, batch_field);
677 evel_json_close_object(jbuf);
679 tot_size += jbuf->offset;
680 EVEL_DEBUG("Batch Event result size %d offset %d depth %d check %d", tot_size,jbuf->offset,jbuf->depth,jbuf->checkpoint);
681 if( tot_size >= max_size ){
682 EVEL_ERROR("Batch Event exceeded size limit %d", tot_size);
685 batch_field_item = dlist_get_next(batch_field_item);
688 evel_json_close_list(jbuf);
689 evel_json_close_object(jbuf);
693 /***************************************************************************/
695 /***************************************************************************/
696 //assert(jbuf->depth == 0);
704 /**************************************************************************//**
705 * Initialize an event instance id.
707 * @param vfield Pointer to the event vnfname field being initialized.
708 * @param vendor_id The vendor id to encode in the event instance id.
709 * @param event_id The event id to encode in the event instance id.
710 *****************************************************************************/
711 void evel_init_vendor_field(VENDOR_VNFNAME_FIELD * const vfield,
712 const char * const vendor_name)
716 /***************************************************************************/
717 /* Check preconditions. */
718 /***************************************************************************/
719 assert(vfield != NULL);
720 assert(vendor_name != NULL);
722 /***************************************************************************/
723 /* Store the mandatory parts. */
724 /***************************************************************************/
725 vfield->vendorname = strdup(vendor_name);
726 evel_init_option_string(&vfield->vfmodule);
727 evel_init_option_string(&vfield->vnfname);
729 /***************************************************************************/
730 /* Initialize the optional parts. */
731 /***************************************************************************/
736 /**************************************************************************//**
737 * Set the Vendor module property of the Vendor.
739 * @note The property is treated as immutable: it is only valid to call
740 * the setter once. However, we don't assert if the caller tries to
741 * overwrite, just ignoring the update instead.
743 * @param vfield Pointer to the Vendor field.
744 * @param module_name The module name to be set. ASCIIZ string. The caller
745 * does not need to preserve the value once the function
747 *****************************************************************************/
748 void evel_vendor_field_module_set(VENDOR_VNFNAME_FIELD * const vfield,
749 const char * const module_name)
753 /***************************************************************************/
754 /* Check preconditions. */
755 /***************************************************************************/
756 assert(vfield != NULL);
757 assert(module_name != NULL);
759 evel_set_option_string(&vfield->vfmodule, module_name, "Module name set");
764 /**************************************************************************//**
765 * Set the Vendor module property of the Vendor.
767 * @note The property is treated as immutable: it is only valid to call
768 * the setter once. However, we don't assert if the caller tries to
769 * overwrite, just ignoring the update instead.
771 * @param vfield Pointer to the Vendor field.
772 * @param module_name The module name to be set. ASCIIZ string. The caller
773 * does not need to preserve the value once the function
775 *****************************************************************************/
776 void evel_vendor_field_vnfname_set(VENDOR_VNFNAME_FIELD * const vfield,
777 const char * const vnfname)
781 /***************************************************************************/
782 /* Check preconditions. */
783 /***************************************************************************/
784 assert(vfield != NULL);
785 assert(vnfname != NULL);
787 evel_set_option_string(&vfield->vnfname, vnfname, "Virtual Network Function name set");
792 /**************************************************************************//**
793 * Free an event instance id.
795 * @param vfield Pointer to the event vnfname_field being freed.
796 *****************************************************************************/
797 void evel_free_event_vendor_field(VENDOR_VNFNAME_FIELD * const vfield)
801 /***************************************************************************/
802 /* Check preconditions. */
803 /***************************************************************************/
804 assert(vfield->vendorname != NULL);
806 /***************************************************************************/
807 /* Free everything. */
808 /***************************************************************************/
809 evel_free_option_string(&vfield->vfmodule);
810 evel_free_option_string(&vfield->vnfname);
811 free(vfield->vendorname);
816 /**************************************************************************//**
817 * Encode the instance id as a JSON object according to AT&T's schema.
819 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
820 * @param vfield Pointer to the ::VENDOR_VNFNAME_FIELD to encode.
821 *****************************************************************************/
822 void evel_json_encode_vendor_field(EVEL_JSON_BUFFER * jbuf,
823 VENDOR_VNFNAME_FIELD * vfield)
827 /***************************************************************************/
828 /* Check preconditions. */
829 /***************************************************************************/
830 assert(jbuf != NULL);
831 assert(jbuf->json != NULL);
832 assert(jbuf->max_size > 0);
833 assert(vfield != NULL);
834 assert(vfield->vendorname != NULL);
836 evel_json_open_named_object(jbuf, "vendorVnfNameFields");
838 /***************************************************************************/
839 /* Mandatory fields. */
840 /***************************************************************************/
841 evel_enc_kv_string(jbuf, "vendorName", vfield->vendorname);
842 evel_enc_kv_opt_string(jbuf, "vfModuleName", &vfield->vfmodule);
843 evel_enc_kv_opt_string(jbuf, "vnfName", &vfield->vnfname);
845 /***************************************************************************/
846 /* Optional fields. */
847 /***************************************************************************/
849 evel_json_close_object(jbuf);