1 /**************************************************************************//**
3 * Implementation of EVEL functions relating to Service.
8 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *****************************************************************************/
26 #include "evel_throttle.h"
28 /**************************************************************************//**
29 * Create a new Service event.
31 * @note The mandatory fields on the Service must be supplied to
32 * this factory function and are immutable once set. Optional fields
33 * have explicit setter functions, but again values may only be set
34 * once so that the event has immutable properties.
35 * @param vendor_id The vendor id to encode in the event instance id.
36 * @param event_id The vendor event id to encode in the event instance id.
37 * @returns pointer to the newly manufactured ::EVENT_SERVICE. If the event
38 * is not used (i.e. posted) it must be released using
39 * ::evel_free_service.
40 * @retval NULL Failed to create the event.
41 *****************************************************************************/
42 EVENT_SERVICE * evel_new_service(const char * const vendor_id,
43 const char * const event_id)
45 EVENT_SERVICE * event = NULL;
49 /***************************************************************************/
50 /* Check preconditions. */
51 /***************************************************************************/
52 assert(vendor_id != NULL);
53 assert(event_id != NULL);
55 /***************************************************************************/
56 /* Allocate the Service event. */
57 /***************************************************************************/
58 event = malloc(sizeof(EVENT_SERVICE));
61 log_error_state("Out of memory");
64 memset(event, 0, sizeof(EVENT_SERVICE));
65 EVEL_DEBUG("New Service event is at %lp", event);
67 /***************************************************************************/
68 /* Initialize the header & the Service fields. */
69 /***************************************************************************/
70 evel_init_header(&event->header);
71 event->header.event_domain = EVEL_DOMAIN_SERVICE;
72 event->major_version = EVEL_SERVICE_MAJOR_VERSION;
73 event->minor_version = EVEL_SERVICE_MINOR_VERSION;
74 evel_init_event_instance_id(&event->instance_id, vendor_id, event_id);
75 evel_init_option_string(&event->correlator);
76 dlist_initialize(&event->additional_fields);
77 evel_init_option_string(&event->codec);
78 evel_init_option_string(&event->callee_side_codec);
79 evel_init_option_string(&event->caller_side_codec);
80 evel_init_option_string(&event->rtcp_data);
81 evel_init_option_string(&event->adjacency_name);
82 evel_init_option_string(&event->endpoint_description);
83 evel_init_option_int(&event->endpoint_jitter);
84 evel_init_option_int(&event->endpoint_rtp_oct_disc);
85 evel_init_option_int(&event->endpoint_rtp_oct_recv);
86 evel_init_option_int(&event->endpoint_rtp_oct_sent);
87 evel_init_option_int(&event->endpoint_rtp_pkt_disc);
88 evel_init_option_int(&event->endpoint_rtp_pkt_recv);
89 evel_init_option_int(&event->endpoint_rtp_pkt_sent);
90 evel_init_option_int(&event->local_jitter);
91 evel_init_option_int(&event->local_rtp_oct_disc);
92 evel_init_option_int(&event->local_rtp_oct_recv);
93 evel_init_option_int(&event->local_rtp_oct_sent);
94 evel_init_option_int(&event->local_rtp_pkt_disc);
95 evel_init_option_int(&event->local_rtp_pkt_recv);
96 evel_init_option_int(&event->local_rtp_pkt_sent);
97 evel_init_option_double(&event->mos_cqe);
98 evel_init_option_int(&event->packets_lost);
99 evel_init_option_double(&event->packet_loss_percent);
100 evel_init_option_int(&event->r_factor);
101 evel_init_option_int(&event->round_trip_delay);
102 evel_init_option_string(&event->phone_number);
110 /**************************************************************************//**
111 * Set the Event Type property of the Service event.
113 * @note The property is treated as immutable: it is only valid to call
114 * the setter once. However, we don't assert if the caller tries to
115 * overwrite, just ignoring the update instead.
117 * @param event Pointer to the Service event.
118 * @param type The Event Type to be set. ASCIIZ string. The caller
119 * does not need to preserve the value once the function
121 *****************************************************************************/
122 void evel_service_type_set(EVENT_SERVICE * const event,
123 const char * const type)
127 /***************************************************************************/
128 /* Check preconditions and call evel_header_type_set. */
129 /***************************************************************************/
130 assert(event != NULL);
131 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
132 evel_header_type_set(&event->header, type);
137 /**************************************************************************//**
138 * Add a name/value pair to the Service, under the additionalFields array.
140 * The name and value are null delimited ASCII strings. The library takes
141 * a copy so the caller does not have to preserve values after the function
144 * @param event Pointer to the Service event.
145 * @param name ASCIIZ string with the field's name. The caller does not
146 * need to preserve the value once the function returns.
147 * @param value ASCIIZ string with the field's value. The caller does not
148 * need to preserve the value once the function returns.
149 *****************************************************************************/
150 void evel_service_addl_field_add(EVENT_SERVICE * const event,
151 const char * const name,
152 const char * const value)
154 OTHER_FIELD * nv_pair = NULL;
158 /***************************************************************************/
159 /* Check preconditions. */
160 /***************************************************************************/
161 assert(event != NULL);
162 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
163 assert(name != NULL);
164 assert(value != NULL);
166 EVEL_DEBUG("Adding name=%s value=%s", name, value);
167 nv_pair = malloc(sizeof(OTHER_FIELD));
168 assert(nv_pair != NULL);
169 nv_pair->name = strdup(name);
170 nv_pair->value = strdup(value);
171 assert(nv_pair->name != NULL);
172 assert(nv_pair->value != NULL);
174 dlist_push_last(&event->additional_fields, nv_pair);
179 /**************************************************************************//**
180 * Set the Product Id property of the Service event.
182 * @note The property is treated as immutable: it is only valid to call
183 * the setter once. However, we don't assert if the caller tries to
184 * overwrite, just ignoring the update instead.
186 * @param event Pointer to the Service event.
187 * @param product_id The vendor product id to be set. ASCIIZ string. The
188 * caller does not need to preserve the value once the
190 *****************************************************************************/
191 void evel_service_product_id_set(EVENT_SERVICE * const event,
192 const char * const product_id)
196 /***************************************************************************/
197 /* Check preconditions and call evel_set_option_string. */
198 /***************************************************************************/
199 assert(event != NULL);
200 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
201 evel_set_option_string(&event->instance_id.product_id,
208 /**************************************************************************//**
209 * Set the Subsystem Id property of the Service event.
211 * @note The property is treated as immutable: it is only valid to call
212 * the setter once. However, we don't assert if the caller tries to
213 * overwrite, just ignoring the update instead.
215 * @param event Pointer to the Service event.
216 * @param subsystem_id The vendor subsystem id to be set. ASCIIZ string. The
217 * caller does not need to preserve the value once the
219 *****************************************************************************/
220 void evel_service_subsystem_id_set(EVENT_SERVICE * const event,
221 const char * const subsystem_id)
225 /***************************************************************************/
226 /* Check preconditions and call evel_set_option_string. */
227 /***************************************************************************/
228 assert(event != NULL);
229 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
230 evel_set_option_string(&event->instance_id.subsystem_id,
237 /**************************************************************************//**
238 * Set the Friendly Name property of the Service event.
240 * @note The property is treated as immutable: it is only valid to call
241 * the setter once. However, we don't assert if the caller tries to
242 * overwrite, just ignoring the update instead.
244 * @param event Pointer to the Service event.
245 * @param friendly_name The vendor friendly name to be set. ASCIIZ string. The
246 * caller does not need to preserve the value once the
248 *****************************************************************************/
249 void evel_service_friendly_name_set(EVENT_SERVICE * const event,
250 const char * const friendly_name)
254 /***************************************************************************/
255 /* Check preconditions and call evel_set_option_string. */
256 /***************************************************************************/
257 assert(event != NULL);
258 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
259 evel_set_option_string(&event->instance_id.event_friendly_name,
266 /**************************************************************************//**
267 * Set the Correlator property of the Service event.
269 * @note The property is treated as immutable: it is only valid to call
270 * the setter once. However, we don't assert if the caller tries to
271 * overwrite, just ignoring the update instead.
273 * @param event Pointer to the Service event.
274 * @param correlator The correlator to be set. ASCIIZ string. The caller
275 * does not need to preserve the value once the function
277 *****************************************************************************/
278 void evel_service_correlator_set(EVENT_SERVICE * const event,
279 const char * const correlator)
283 /***************************************************************************/
284 /* Check preconditions and call evel_set_option_string. */
285 /***************************************************************************/
286 assert(event != NULL);
287 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
288 evel_set_option_string(&event->correlator,
295 /**************************************************************************//**
296 * Set the Codec property of the Service event.
298 * @note The property is treated as immutable: it is only valid to call
299 * the setter once. However, we don't assert if the caller tries to
300 * overwrite, just ignoring the update instead.
302 * @param event Pointer to the Service event.
303 * @param codec The codec to be set. ASCIIZ string. The caller does not
304 * need to preserve the value once the function returns.
305 *****************************************************************************/
306 void evel_service_codec_set(EVENT_SERVICE * const event,
307 const char * const codec)
311 /***************************************************************************/
312 /* Check preconditions and call evel_set_option_string. */
313 /***************************************************************************/
314 assert(event != NULL);
315 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
316 evel_set_option_string(&event->codec,
323 /**************************************************************************//**
324 * Set the Callee Side Codec property of the Service event.
326 * @note The property is treated as immutable: it is only valid to call
327 * the setter once. However, we don't assert if the caller tries to
328 * overwrite, just ignoring the update instead.
330 * @param event Pointer to the Service event.
331 * @param codec The codec to be set. ASCIIZ string. The caller does not
332 * need to preserve the value once the function returns.
333 *****************************************************************************/
334 void evel_service_callee_codec_set(EVENT_SERVICE * const event,
335 const char * const codec)
339 /***************************************************************************/
340 /* Check preconditions and call evel_set_option_string. */
341 /***************************************************************************/
342 assert(event != NULL);
343 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
344 evel_set_option_string(&event->callee_side_codec,
346 "Callee Side Codec");
351 /**************************************************************************//**
352 * Set the Caller Side Codec property of the Service event.
354 * @note The property is treated as immutable: it is only valid to call
355 * the setter once. However, we don't assert if the caller tries to
356 * overwrite, just ignoring the update instead.
358 * @param event Pointer to the Service event.
359 * @param codec The codec to be set. ASCIIZ string. The caller does not
360 * need to preserve the value once the function returns.
361 *****************************************************************************/
362 void evel_service_caller_codec_set(EVENT_SERVICE * const event,
363 const char * const codec)
367 /***************************************************************************/
368 /* Check preconditions and call evel_set_option_string. */
369 /***************************************************************************/
370 assert(event != NULL);
371 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
372 evel_set_option_string(&event->caller_side_codec,
374 "Caller Side Codec");
379 /**************************************************************************//**
380 * Set the RTCP Data property of the Service event.
382 * @note The property is treated as immutable: it is only valid to call
383 * the setter once. However, we don't assert if the caller tries to
384 * overwrite, just ignoring the update instead.
386 * @param event Pointer to the Service event.
387 * @param rtcp_data The RTCP Data to be set. ASCIIZ string. The caller
388 * does not need to preserve the value once the function
390 *****************************************************************************/
391 void evel_service_rtcp_data_set(EVENT_SERVICE * const event,
392 const char * const rtcp_data)
396 /***************************************************************************/
397 /* Check preconditions and call evel_set_option_string. */
398 /***************************************************************************/
399 assert(event != NULL);
400 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
401 evel_set_option_string(&event->rtcp_data,
408 /**************************************************************************//**
409 * Set the Adjacency Name property of the Service event.
411 * @note The property is treated as immutable: it is only valid to call
412 * the setter once. However, we don't assert if the caller tries to
413 * overwrite, just ignoring the update instead.
415 * @param event Pointer to the Service event.
416 * @param adjacency_name
417 * The adjacency name to be set. ASCIIZ string. The caller
418 * does not need to preserve the value once the function
420 *****************************************************************************/
421 void evel_service_adjacency_name_set(EVENT_SERVICE * const event,
422 const char * const adjacency_name)
426 /***************************************************************************/
427 /* Check preconditions and call evel_set_option_string. */
428 /***************************************************************************/
429 assert(event != NULL);
430 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
431 evel_set_option_string(&event->adjacency_name,
438 /**************************************************************************//**
439 * Set the Endpoint Descriptor property of the Service event.
441 * @note The property is treated as immutable: it is only valid to call
442 * the setter once. However, we don't assert if the caller tries to
443 * overwrite, just ignoring the update instead.
445 * @param event Pointer to the Service event.
446 * @param endpoint_desc The endpoint descriptor to be set.
447 *****************************************************************************/
448 void evel_service_endpoint_desc_set(
449 EVENT_SERVICE * const event,
450 const EVEL_SERVICE_ENDPOINT_DESC endpoint_desc)
454 /***************************************************************************/
455 /* Check preconditions and call evel_set_option_string. */
456 /***************************************************************************/
457 assert(event != NULL);
458 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
459 evel_set_option_string(&event->endpoint_description,
460 evel_service_endpoint_desc(endpoint_desc),
461 "Endpoint Description");
466 /**************************************************************************//**
467 * Set the Endpoint Jitter property of the Service event.
469 * @note The property is treated as immutable: it is only valid to call
470 * the setter once. However, we don't assert if the caller tries to
471 * overwrite, just ignoring the update instead.
473 * @param event Pointer to the Service event.
474 * @param jitter The jitter to be set.
475 *****************************************************************************/
476 void evel_service_endpoint_jitter_set(EVENT_SERVICE * const event,
481 /***************************************************************************/
482 /* Check preconditions and call evel_set_option_string. */
483 /***************************************************************************/
484 assert(event != NULL);
485 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
486 evel_set_option_int(&event->endpoint_jitter,
493 /**************************************************************************//**
494 * Set the Endpoint Rtp Octets Discarded property of the Service event.
496 * @note The property is treated as immutable: it is only valid to call
497 * the setter once. However, we don't assert if the caller tries to
498 * overwrite, just ignoring the update instead.
500 * @param event Pointer to the Service event.
501 * @param rtp_oct_disc The discard count.
502 *****************************************************************************/
503 void evel_service_endpoint_rtp_oct_disc_set(EVENT_SERVICE * const event,
504 const int rtp_oct_disc)
508 /***************************************************************************/
509 /* Check preconditions and call evel_set_option_string. */
510 /***************************************************************************/
511 assert(event != NULL);
512 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
513 evel_set_option_int(&event->endpoint_rtp_oct_disc,
515 "Endpoint Rtp Octets Discarded");
520 /**************************************************************************//**
521 * Set the Endpoint Rtp Octets Received property of the Service event.
523 * @note The property is treated as immutable: it is only valid to call
524 * the setter once. However, we don't assert if the caller tries to
525 * overwrite, just ignoring the update instead.
527 * @param event Pointer to the Service event.
528 * @param rtp_oct_recv The receive count.
529 *****************************************************************************/
530 void evel_service_endpoint_rtp_oct_recv_set(EVENT_SERVICE * const event,
531 const int rtp_oct_recv)
535 /***************************************************************************/
536 /* Check preconditions and call evel_set_option_string. */
537 /***************************************************************************/
538 assert(event != NULL);
539 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
540 evel_set_option_int(&event->endpoint_rtp_oct_recv,
542 "Endpoint Rtp Octets Received");
547 /**************************************************************************//**
548 * Set the Endpoint Rtp Octets Sent property of the Service event.
550 * @note The property is treated as immutable: it is only valid to call
551 * the setter once. However, we don't assert if the caller tries to
552 * overwrite, just ignoring the update instead.
554 * @param event Pointer to the Service event.
555 * @param rtp_oct_sent The send count.
556 *****************************************************************************/
557 void evel_service_endpoint_rtp_oct_sent_set(EVENT_SERVICE * const event,
558 const int rtp_oct_sent)
562 /***************************************************************************/
563 /* Check preconditions and call evel_set_option_string. */
564 /***************************************************************************/
565 assert(event != NULL);
566 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
567 evel_set_option_int(&event->endpoint_rtp_oct_sent,
569 "Endpoint Rtp Octets Sent");
574 /**************************************************************************//**
575 * Set the Endpoint Rtp Packets Discarded property of the Service event.
577 * @note The property is treated as immutable: it is only valid to call
578 * the setter once. However, we don't assert if the caller tries to
579 * overwrite, just ignoring the update instead.
581 * @param event Pointer to the Service event.
582 * @param rtp_pkt_disc The discard count.
583 *****************************************************************************/
584 void evel_service_endpoint_rtp_pkt_disc_set(EVENT_SERVICE * const event,
585 const int rtp_pkt_disc)
589 /***************************************************************************/
590 /* Check preconditions and call evel_set_option_string. */
591 /***************************************************************************/
592 assert(event != NULL);
593 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
594 evel_set_option_int(&event->endpoint_rtp_pkt_disc,
596 "Endpoint Rtp Packets Discarded");
601 /**************************************************************************//**
602 * Set the Endpoint Rtp Packets Received property of the Service event.
604 * @note The property is treated as immutable: it is only valid to call
605 * the setter once. However, we don't assert if the caller tries to
606 * overwrite, just ignoring the update instead.
608 * @param event Pointer to the Service event.
609 * @param rtp_pkt_recv The receive count.
610 *****************************************************************************/
611 void evel_service_endpoint_rtp_pkt_recv_set(EVENT_SERVICE * const event,
612 const int rtp_pkt_recv)
616 /***************************************************************************/
617 /* Check preconditions and call evel_set_option_string. */
618 /***************************************************************************/
619 assert(event != NULL);
620 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
621 evel_set_option_int(&event->endpoint_rtp_pkt_recv,
623 "Endpoint Rtp Packets Received");
628 /**************************************************************************//**
629 * Set the Endpoint Rtp Packets Sent property of the Service event.
631 * @note The property is treated as immutable: it is only valid to call
632 * the setter once. However, we don't assert if the caller tries to
633 * overwrite, just ignoring the update instead.
635 * @param event Pointer to the Service event.
636 * @param rtp_pkt_sent The send count.
637 *****************************************************************************/
638 void evel_service_endpoint_rtp_pkt_sent_set(EVENT_SERVICE * const event,
639 const int rtp_pkt_sent)
643 /***************************************************************************/
644 /* Check preconditions and call evel_set_option_string. */
645 /***************************************************************************/
646 assert(event != NULL);
647 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
648 evel_set_option_int(&event->endpoint_rtp_pkt_sent,
650 "Endpoint Rtp Packets Sent");
655 /**************************************************************************//**
656 * Set the Local Jitter property of the Service event.
658 * @note The property is treated as immutable: it is only valid to call
659 * the setter once. However, we don't assert if the caller tries to
660 * overwrite, just ignoring the update instead.
662 * @param event Pointer to the Service event.
663 * @param jitter The jitter to be set.
664 *****************************************************************************/
665 void evel_service_local_jitter_set(EVENT_SERVICE * const event,
670 /***************************************************************************/
671 /* Check preconditions and call evel_set_option_string. */
672 /***************************************************************************/
673 assert(event != NULL);
674 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
675 evel_set_option_int(&event->local_jitter,
682 /**************************************************************************//**
683 * Set the Local Rtp Octets Discarded property of the Service event.
685 * @note The property is treated as immutable: it is only valid to call
686 * the setter once. However, we don't assert if the caller tries to
687 * overwrite, just ignoring the update instead.
689 * @param event Pointer to the Service event.
690 * @param rtp_oct_disc The discard count.
691 *****************************************************************************/
692 void evel_service_local_rtp_oct_disc_set(EVENT_SERVICE * const event,
693 const int rtp_oct_disc)
697 /***************************************************************************/
698 /* Check preconditions and call evel_set_option_string. */
699 /***************************************************************************/
700 assert(event != NULL);
701 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
702 evel_set_option_int(&event->local_rtp_oct_disc,
704 "Local Rtp Octets Discarded");
709 /**************************************************************************//**
710 * Set the Local Rtp Octets Received property of the Service event.
712 * @note The property is treated as immutable: it is only valid to call
713 * the setter once. However, we don't assert if the caller tries to
714 * overwrite, just ignoring the update instead.
716 * @param event Pointer to the Service event.
717 * @param rtp_oct_recv The receive count.
718 *****************************************************************************/
719 void evel_service_local_rtp_oct_recv_set(EVENT_SERVICE * const event,
720 const int rtp_oct_recv)
724 /***************************************************************************/
725 /* Check preconditions and call evel_set_option_string. */
726 /***************************************************************************/
727 assert(event != NULL);
728 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
729 evel_set_option_int(&event->local_rtp_oct_recv,
731 "Local Rtp Octets Received");
736 /**************************************************************************//**
737 * Set the Local Rtp Octets Sent property of the Service event.
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 event Pointer to the Service event.
744 * @param rtp_oct_sent The send count.
745 *****************************************************************************/
746 void evel_service_local_rtp_oct_sent_set(EVENT_SERVICE * const event,
747 const int rtp_oct_sent)
751 /***************************************************************************/
752 /* Check preconditions and call evel_set_option_string. */
753 /***************************************************************************/
754 assert(event != NULL);
755 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
756 evel_set_option_int(&event->local_rtp_oct_sent,
758 "Local Rtp Octets Sent");
763 /**************************************************************************//**
764 * Set the Local Rtp Packets Discarded property of the Service event.
766 * @note The property is treated as immutable: it is only valid to call
767 * the setter once. However, we don't assert if the caller tries to
768 * overwrite, just ignoring the update instead.
770 * @param event Pointer to the Service event.
771 * @param rtp_pkt_disc The discard count.
772 *****************************************************************************/
773 void evel_service_local_rtp_pkt_disc_set(EVENT_SERVICE * const event,
774 const int rtp_pkt_disc)
778 /***************************************************************************/
779 /* Check preconditions and call evel_set_option_string. */
780 /***************************************************************************/
781 assert(event != NULL);
782 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
783 evel_set_option_int(&event->local_rtp_pkt_disc,
785 "Local Rtp Packets Discarded");
790 /**************************************************************************//**
791 * Set the Local Rtp Packets Received property of the Service event.
793 * @note The property is treated as immutable: it is only valid to call
794 * the setter once. However, we don't assert if the caller tries to
795 * overwrite, just ignoring the update instead.
797 * @param event Pointer to the Service event.
798 * @param rtp_pkt_recv The receive count.
799 *****************************************************************************/
800 void evel_service_local_rtp_pkt_recv_set(EVENT_SERVICE * const event,
801 const int rtp_pkt_recv)
805 /***************************************************************************/
806 /* Check preconditions and call evel_set_option_string. */
807 /***************************************************************************/
808 assert(event != NULL);
809 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
810 evel_set_option_int(&event->local_rtp_pkt_recv,
812 "Local Rtp Packets Received");
817 /**************************************************************************//**
818 * Set the Local Rtp Packets Sent property of the Service event.
820 * @note The property is treated as immutable: it is only valid to call
821 * the setter once. However, we don't assert if the caller tries to
822 * overwrite, just ignoring the update instead.
824 * @param event Pointer to the Service event.
825 * @param rtp_pkt_sent The send count.
826 *****************************************************************************/
827 void evel_service_local_rtp_pkt_sent_set(EVENT_SERVICE * const event,
828 const int rtp_pkt_sent)
832 /***************************************************************************/
833 /* Check preconditions and call evel_set_option_string. */
834 /***************************************************************************/
835 assert(event != NULL);
836 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
837 evel_set_option_int(&event->local_rtp_pkt_sent,
839 "Local Rtp Packets Sent");
844 /**************************************************************************//**
845 * Set the Mos Cqe property of the Service event.
847 * @note The property is treated as immutable: it is only valid to call
848 * the setter once. However, we don't assert if the caller tries to
849 * overwrite, just ignoring the update instead.
851 * @param event Pointer to the Service event.
852 * @param mos_cqe The mosCqe to be set.
853 *****************************************************************************/
854 void evel_service_mos_cqe_set(EVENT_SERVICE * const event,
855 const double mos_cqe)
859 /***************************************************************************/
860 /* Check preconditions and call evel_set_option_string. */
861 /***************************************************************************/
862 assert(event != NULL);
863 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
864 evel_set_option_double(&event->mos_cqe,
871 /**************************************************************************//**
872 * Set the Packets Lost property of the Service event.
874 * @note The property is treated as immutable: it is only valid to call
875 * the setter once. However, we don't assert if the caller tries to
876 * overwrite, just ignoring the update instead.
878 * @param event Pointer to the Service event.
879 * @param packets_lost The number of packets lost to be set.
880 *****************************************************************************/
881 void evel_service_packets_lost_set(EVENT_SERVICE * const event,
882 const int packets_lost)
886 /***************************************************************************/
887 /* Check preconditions and call evel_set_option_string. */
888 /***************************************************************************/
889 assert(event != NULL);
890 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
891 evel_set_option_int(&event->packets_lost,
898 /**************************************************************************//**
899 * Set the packet Loss Percent property of the Service event.
901 * @note The property is treated as immutable: it is only valid to call
902 * the setter once. However, we don't assert if the caller tries to
903 * overwrite, just ignoring the update instead.
905 * @param event Pointer to the Service event.
906 * @param packet_loss_percent
907 * The packet loss in percent.
908 *****************************************************************************/
909 void evel_service_packet_loss_percent_set(EVENT_SERVICE * const event,
910 const double packet_loss_percent)
914 /***************************************************************************/
915 /* Check preconditions and call evel_set_option_string. */
916 /***************************************************************************/
917 assert(event != NULL);
918 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
919 evel_set_option_double(&event->packet_loss_percent,
921 "Packet Loss Percent");
926 /**************************************************************************//**
927 * Set the R Factor property of the Service event.
929 * @note The property is treated as immutable: it is only valid to call
930 * the setter once. However, we don't assert if the caller tries to
931 * overwrite, just ignoring the update instead.
933 * @param event Pointer to the Service event.
934 * @param r_factor The R Factor to be set.
935 *****************************************************************************/
936 void evel_service_r_factor_set(EVENT_SERVICE * const event,
941 /***************************************************************************/
942 /* Check preconditions and call evel_set_option_string. */
943 /***************************************************************************/
944 assert(event != NULL);
945 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
946 evel_set_option_int(&event->r_factor,
953 /**************************************************************************//**
954 * Set the Round Trip Delay property of the Service event.
956 * @note The property is treated as immutable: it is only valid to call
957 * the setter once. However, we don't assert if the caller tries to
958 * overwrite, just ignoring the update instead.
960 * @param event Pointer to the Service event.
961 * @param round_trip_delay
962 * The Round trip delay to be set.
963 *****************************************************************************/
964 void evel_service_round_trip_delay_set(EVENT_SERVICE * const event,
965 const int round_trip_delay)
969 /***************************************************************************/
970 /* Check preconditions and call evel_set_option_string. */
971 /***************************************************************************/
972 assert(event != NULL);
973 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
974 evel_set_option_int(&event->round_trip_delay,
981 /**************************************************************************//**
982 * Set the Phone Number property of the Service event.
984 * @note The property is treated as immutable: it is only valid to call
985 * the setter once. However, we don't assert if the caller tries to
986 * overwrite, just ignoring the update instead.
988 * @param event Pointer to the Service event.
989 * @param phone_number The Phone Number to be set. ASCIIZ string. The caller
990 * does not need to preserve the value once the function
992 *****************************************************************************/
993 void evel_service_phone_number_set(EVENT_SERVICE * const event,
994 const char * const phone_number)
998 /***************************************************************************/
999 /* Check preconditions and call evel_set_option_string. */
1000 /***************************************************************************/
1001 assert(event != NULL);
1002 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1003 evel_set_option_string(&event->phone_number,
1010 /**************************************************************************//**
1011 * Encode the Service in JSON according to AT&T's schema for the
1014 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
1015 * @param event Pointer to the ::EVENT_HEADER to encode.
1016 *****************************************************************************/
1017 void evel_json_encode_service(EVEL_JSON_BUFFER * const jbuf,
1018 EVENT_SERVICE * const event)
1020 OTHER_FIELD * nv_pair = NULL;
1021 DLIST_ITEM * dlist_item = NULL;
1025 /***************************************************************************/
1026 /* Check preconditions. */
1027 /***************************************************************************/
1028 assert(event != NULL);
1029 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1031 evel_json_encode_header(jbuf, &event->header);
1032 evel_json_open_named_object(jbuf, "serviceEventsFields");
1034 /***************************************************************************/
1035 /* Mandatory fields */
1036 /***************************************************************************/
1037 evel_json_encode_instance_id(jbuf, &event->instance_id);
1038 evel_enc_version(jbuf,
1039 "serviceEventsFieldsVersion",
1040 event->major_version,
1041 event->minor_version);
1043 /***************************************************************************/
1044 /* Optional fields */
1045 /***************************************************************************/
1046 evel_enc_kv_opt_string(jbuf, "correlator", &event->correlator);
1048 /***************************************************************************/
1049 /* Checkpoint, so that we can wind back if all fields are suppressed. */
1050 /***************************************************************************/
1051 evel_json_checkpoint(jbuf);
1052 if (evel_json_open_opt_named_list(jbuf, "additionalFields"))
1056 dlist_item = dlist_get_first(&event->additional_fields);
1057 while (dlist_item != NULL)
1059 nv_pair = (OTHER_FIELD *) dlist_item->item;
1060 assert(nv_pair != NULL);
1062 if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
1066 evel_json_open_object(jbuf);
1067 evel_enc_kv_string(jbuf, "name", nv_pair->name);
1068 evel_enc_kv_string(jbuf, "value", nv_pair->value);
1069 evel_json_close_object(jbuf);
1072 dlist_item = dlist_get_next(dlist_item);
1074 evel_json_close_list(jbuf);
1076 /*************************************************************************/
1077 /* If we've not written anything, rewind to before we opened the list. */
1078 /*************************************************************************/
1081 evel_json_rewind(jbuf);
1085 /***************************************************************************/
1086 /* Optional fields within JSON equivalent object: codecSelected */
1087 /***************************************************************************/
1088 evel_json_checkpoint(jbuf);
1089 if (evel_json_open_opt_named_object(jbuf, "codecSelected"))
1092 added |= evel_enc_kv_opt_string(jbuf,
1095 evel_json_close_object(jbuf);
1097 /*************************************************************************/
1098 /* If the object is empty, rewind to before we opened it. */
1099 /*************************************************************************/
1102 evel_json_rewind(jbuf);
1106 /***************************************************************************/
1107 /* Optional fields within JSON equivalent object: codecSelectedTranscoding */
1108 /***************************************************************************/
1109 evel_json_checkpoint(jbuf);
1110 if (evel_json_open_opt_named_object(jbuf, "codecSelectedTranscoding"))
1113 added |= evel_enc_kv_opt_string(jbuf,
1115 &event->callee_side_codec);
1116 added |= evel_enc_kv_opt_string(jbuf,
1118 &event->caller_side_codec);
1119 evel_json_close_object(jbuf);
1121 /*************************************************************************/
1122 /* If the object is empty, rewind to before we opened it. */
1123 /*************************************************************************/
1126 evel_json_rewind(jbuf);
1130 /***************************************************************************/
1131 /* Optional fields within JSON equivalent object: midCallRtcp */
1132 /***************************************************************************/
1133 evel_json_checkpoint(jbuf);
1134 if (evel_json_open_opt_named_object(jbuf, "midCallRtcp"))
1137 added |= evel_enc_kv_opt_string(jbuf,
1140 evel_json_close_object(jbuf);
1142 /*************************************************************************/
1143 /* If the object is empty, rewind to before we opened it. */
1144 /*************************************************************************/
1147 evel_json_rewind(jbuf);
1151 /***************************************************************************/
1152 /* Optional fields within JSON equivalent object: endOfCallVqmSummaries */
1153 /***************************************************************************/
1154 evel_json_checkpoint(jbuf);
1155 if (evel_json_open_opt_named_object(jbuf, "endOfCallVqmSummaries"))
1158 added |= evel_enc_kv_opt_string(jbuf,
1160 &event->adjacency_name);
1161 added |= evel_enc_kv_opt_string(jbuf,
1162 "endpointDescription",
1163 &event->endpoint_description);
1164 added |= evel_enc_kv_opt_int(jbuf,
1166 &event->endpoint_jitter);
1167 added |= evel_enc_kv_opt_int(jbuf,
1168 "endpointRtpOctetsDiscarded",
1169 &event->endpoint_rtp_oct_disc);
1170 added |= evel_enc_kv_opt_int(jbuf,
1171 "endpointRtpOctetsReceived",
1172 &event->endpoint_rtp_oct_recv);
1173 added |= evel_enc_kv_opt_int(jbuf,
1174 "endpointRtpOctetsSent",
1175 &event->endpoint_rtp_oct_sent);
1176 added |= evel_enc_kv_opt_int(jbuf,
1177 "endpointRtpPacketsDiscarded",
1178 &event->endpoint_rtp_pkt_disc);
1179 added |= evel_enc_kv_opt_int(jbuf,
1180 "endpointRtpPacketsReceived",
1181 &event->endpoint_rtp_pkt_recv);
1182 added |= evel_enc_kv_opt_int(jbuf,
1183 "endpointRtpPacketsSent",
1184 &event->endpoint_rtp_pkt_sent);
1185 added |= evel_enc_kv_opt_int(jbuf,
1187 &event->local_jitter);
1188 added |= evel_enc_kv_opt_int(jbuf,
1189 "localRtpOctetsDiscarded",
1190 &event->local_rtp_oct_disc);
1191 added |= evel_enc_kv_opt_int(jbuf,
1192 "localRtpOctetsReceived",
1193 &event->local_rtp_oct_recv);
1194 added |= evel_enc_kv_opt_int(jbuf,
1195 "localRtpOctetsSent",
1196 &event->local_rtp_oct_sent);
1197 added |= evel_enc_kv_opt_int(jbuf,
1198 "localRtpPacketsDiscarded",
1199 &event->local_rtp_pkt_disc);
1200 added |= evel_enc_kv_opt_int(jbuf,
1201 "localRtpPacketsReceived",
1202 &event->local_rtp_pkt_recv);
1203 added |= evel_enc_kv_opt_int(jbuf,
1204 "localRtpPacketsSent",
1205 &event->local_rtp_pkt_sent);
1206 added |= evel_enc_kv_opt_double(jbuf,
1209 added |= evel_enc_kv_opt_int(jbuf,
1211 &event->packets_lost);
1212 added |= evel_enc_kv_opt_double(jbuf,
1213 "packetLossPercent",
1214 &event->packet_loss_percent);
1215 added |= evel_enc_kv_opt_int(jbuf,
1218 added |= evel_enc_kv_opt_int(jbuf,
1220 &event->round_trip_delay);
1221 evel_json_close_object(jbuf);
1223 /*************************************************************************/
1224 /* If the object is empty, rewind to before we opened it. */
1225 /*************************************************************************/
1228 evel_json_rewind(jbuf);
1232 /***************************************************************************/
1233 /* Optional fields within JSON equivalent object: marker */
1234 /***************************************************************************/
1235 evel_json_checkpoint(jbuf);
1236 if (evel_json_open_opt_named_object(jbuf, "marker"))
1239 added |= evel_enc_kv_opt_string(jbuf, "phoneNumber", &event->phone_number);
1240 evel_json_close_object(jbuf);
1242 /*************************************************************************/
1243 /* If the object is empty, rewind to before we opened it. */
1244 /*************************************************************************/
1247 evel_json_rewind(jbuf);
1251 evel_json_close_object(jbuf);
1256 /**************************************************************************//**
1257 * Free a Service event.
1259 * Free off the event supplied. Will free all the contained allocated memory.
1261 * @note It does not free the event itself, since that may be part of a larger
1263 *****************************************************************************/
1264 void evel_free_service(EVENT_SERVICE * const event)
1266 OTHER_FIELD * nv_pair = NULL;
1270 /***************************************************************************/
1271 /* Check preconditions. */
1272 /***************************************************************************/
1273 assert(event != NULL);
1274 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1276 /***************************************************************************/
1277 /* Free all internal strings then the header itself. */
1278 /***************************************************************************/
1279 nv_pair = dlist_pop_last(&event->additional_fields);
1280 while (nv_pair != NULL)
1282 EVEL_DEBUG("Freeing Other Field (%s, %s)", nv_pair->name, nv_pair->value);
1283 free(nv_pair->name);
1284 free(nv_pair->value);
1286 nv_pair = dlist_pop_last(&event->additional_fields);
1288 evel_free_option_string(&event->correlator);
1289 evel_free_option_string(&event->codec);
1290 evel_free_option_string(&event->callee_side_codec);
1291 evel_free_option_string(&event->caller_side_codec);
1292 evel_free_option_string(&event->rtcp_data);
1293 evel_free_option_string(&event->adjacency_name);
1294 evel_free_option_string(&event->endpoint_description);
1295 evel_free_option_string(&event->phone_number);
1296 evel_free_event_instance_id(&event->instance_id);
1297 evel_free_header(&event->header);