1 /**************************************************************************//**
3 * Implementation of EVEL functions relating to Service.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * 1. Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement: This product includes
18 * software developed by the AT&T.
19 * 4. Neither the name of AT&T nor the names of its contributors may be used to
20 * endorse or promote products derived from this software without specific
21 * prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY AT&T INTELLECTUAL PROPERTY ''AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL AT&T INTELLECTUAL PROPERTY BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *****************************************************************************/
39 #include "evel_throttle.h"
41 /**************************************************************************//**
42 * Create a new Service event.
44 * @note The mandatory fields on the Service must be supplied to
45 * this factory function and are immutable once set. Optional fields
46 * have explicit setter functions, but again values may only be set
47 * once so that the event has immutable properties.
48 * @param vendor_id The vendor id to encode in the event instance id.
49 * @param event_id The vendor event id to encode in the event instance id.
50 * @returns pointer to the newly manufactured ::EVENT_SERVICE. If the event
51 * is not used (i.e. posted) it must be released using
52 * ::evel_free_service.
53 * @retval NULL Failed to create the event.
54 *****************************************************************************/
55 EVENT_SERVICE * evel_new_service(const char * const vendor_id,
56 const char * const event_id)
58 EVENT_SERVICE * event = NULL;
62 /***************************************************************************/
63 /* Check preconditions. */
64 /***************************************************************************/
65 assert(vendor_id != NULL);
66 assert(event_id != NULL);
68 /***************************************************************************/
69 /* Allocate the Service event. */
70 /***************************************************************************/
71 event = malloc(sizeof(EVENT_SERVICE));
74 log_error_state("Out of memory");
77 memset(event, 0, sizeof(EVENT_SERVICE));
78 EVEL_DEBUG("New Service event is at %lp", event);
80 /***************************************************************************/
81 /* Initialize the header & the Service fields. */
82 /***************************************************************************/
83 evel_init_header(&event->header);
84 event->header.event_domain = EVEL_DOMAIN_SERVICE;
85 event->major_version = EVEL_SERVICE_MAJOR_VERSION;
86 event->minor_version = EVEL_SERVICE_MINOR_VERSION;
87 evel_init_event_instance_id(&event->instance_id, vendor_id, event_id);
88 evel_init_option_string(&event->correlator);
89 dlist_initialize(&event->additional_fields);
90 evel_init_option_string(&event->codec);
91 evel_init_option_string(&event->callee_side_codec);
92 evel_init_option_string(&event->caller_side_codec);
93 evel_init_option_string(&event->rtcp_data);
94 evel_init_option_string(&event->adjacency_name);
95 evel_init_option_string(&event->endpoint_description);
96 evel_init_option_int(&event->endpoint_jitter);
97 evel_init_option_int(&event->endpoint_rtp_oct_disc);
98 evel_init_option_int(&event->endpoint_rtp_oct_recv);
99 evel_init_option_int(&event->endpoint_rtp_oct_sent);
100 evel_init_option_int(&event->endpoint_rtp_pkt_disc);
101 evel_init_option_int(&event->endpoint_rtp_pkt_recv);
102 evel_init_option_int(&event->endpoint_rtp_pkt_sent);
103 evel_init_option_int(&event->local_jitter);
104 evel_init_option_int(&event->local_rtp_oct_disc);
105 evel_init_option_int(&event->local_rtp_oct_recv);
106 evel_init_option_int(&event->local_rtp_oct_sent);
107 evel_init_option_int(&event->local_rtp_pkt_disc);
108 evel_init_option_int(&event->local_rtp_pkt_recv);
109 evel_init_option_int(&event->local_rtp_pkt_sent);
110 evel_init_option_double(&event->mos_cqe);
111 evel_init_option_int(&event->packets_lost);
112 evel_init_option_double(&event->packet_loss_percent);
113 evel_init_option_int(&event->r_factor);
114 evel_init_option_int(&event->round_trip_delay);
115 evel_init_option_string(&event->phone_number);
123 /**************************************************************************//**
124 * Set the Event Type property of the Service event.
126 * @note The property is treated as immutable: it is only valid to call
127 * the setter once. However, we don't assert if the caller tries to
128 * overwrite, just ignoring the update instead.
130 * @param event Pointer to the Service event.
131 * @param type The Event Type to be set. ASCIIZ string. The caller
132 * does not need to preserve the value once the function
134 *****************************************************************************/
135 void evel_service_type_set(EVENT_SERVICE * const event,
136 const char * const type)
140 /***************************************************************************/
141 /* Check preconditions and call evel_header_type_set. */
142 /***************************************************************************/
143 assert(event != NULL);
144 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
145 evel_header_type_set(&event->header, type);
150 /**************************************************************************//**
151 * Add a name/value pair to the Service, under the additionalFields array.
153 * The name and value are null delimited ASCII strings. The library takes
154 * a copy so the caller does not have to preserve values after the function
157 * @param event Pointer to the Service event.
158 * @param name ASCIIZ string with the field's name. The caller does not
159 * need to preserve the value once the function returns.
160 * @param value ASCIIZ string with the field's value. The caller does not
161 * need to preserve the value once the function returns.
162 *****************************************************************************/
163 void evel_service_addl_field_add(EVENT_SERVICE * const event,
164 const char * const name,
165 const char * const value)
167 OTHER_FIELD * nv_pair = NULL;
171 /***************************************************************************/
172 /* Check preconditions. */
173 /***************************************************************************/
174 assert(event != NULL);
175 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
176 assert(name != NULL);
177 assert(value != NULL);
179 EVEL_DEBUG("Adding name=%s value=%s", name, value);
180 nv_pair = malloc(sizeof(OTHER_FIELD));
181 assert(nv_pair != NULL);
182 nv_pair->name = strdup(name);
183 nv_pair->value = strdup(value);
184 assert(nv_pair->name != NULL);
185 assert(nv_pair->value != NULL);
187 dlist_push_last(&event->additional_fields, nv_pair);
192 /**************************************************************************//**
193 * Set the Product Id property of the Service event.
195 * @note The property is treated as immutable: it is only valid to call
196 * the setter once. However, we don't assert if the caller tries to
197 * overwrite, just ignoring the update instead.
199 * @param event Pointer to the Service event.
200 * @param product_id The vendor product id to be set. ASCIIZ string. The
201 * caller does not need to preserve the value once the
203 *****************************************************************************/
204 void evel_service_product_id_set(EVENT_SERVICE * const event,
205 const char * const product_id)
209 /***************************************************************************/
210 /* Check preconditions and call evel_set_option_string. */
211 /***************************************************************************/
212 assert(event != NULL);
213 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
214 evel_set_option_string(&event->instance_id.product_id,
221 /**************************************************************************//**
222 * Set the Subsystem Id property of the Service event.
224 * @note The property is treated as immutable: it is only valid to call
225 * the setter once. However, we don't assert if the caller tries to
226 * overwrite, just ignoring the update instead.
228 * @param event Pointer to the Service event.
229 * @param subsystem_id The vendor subsystem id to be set. ASCIIZ string. The
230 * caller does not need to preserve the value once the
232 *****************************************************************************/
233 void evel_service_subsystem_id_set(EVENT_SERVICE * const event,
234 const char * const subsystem_id)
238 /***************************************************************************/
239 /* Check preconditions and call evel_set_option_string. */
240 /***************************************************************************/
241 assert(event != NULL);
242 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
243 evel_set_option_string(&event->instance_id.subsystem_id,
250 /**************************************************************************//**
251 * Set the Friendly Name property of the Service event.
253 * @note The property is treated as immutable: it is only valid to call
254 * the setter once. However, we don't assert if the caller tries to
255 * overwrite, just ignoring the update instead.
257 * @param event Pointer to the Service event.
258 * @param friendly_name The vendor friendly name to be set. ASCIIZ string. The
259 * caller does not need to preserve the value once the
261 *****************************************************************************/
262 void evel_service_friendly_name_set(EVENT_SERVICE * const event,
263 const char * const friendly_name)
267 /***************************************************************************/
268 /* Check preconditions and call evel_set_option_string. */
269 /***************************************************************************/
270 assert(event != NULL);
271 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
272 evel_set_option_string(&event->instance_id.event_friendly_name,
279 /**************************************************************************//**
280 * Set the Correlator property of the Service event.
282 * @note The property is treated as immutable: it is only valid to call
283 * the setter once. However, we don't assert if the caller tries to
284 * overwrite, just ignoring the update instead.
286 * @param event Pointer to the Service event.
287 * @param correlator The correlator to be set. ASCIIZ string. The caller
288 * does not need to preserve the value once the function
290 *****************************************************************************/
291 void evel_service_correlator_set(EVENT_SERVICE * const event,
292 const char * const correlator)
296 /***************************************************************************/
297 /* Check preconditions and call evel_set_option_string. */
298 /***************************************************************************/
299 assert(event != NULL);
300 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
301 evel_set_option_string(&event->correlator,
308 /**************************************************************************//**
309 * Set the Codec property of the Service event.
311 * @note The property is treated as immutable: it is only valid to call
312 * the setter once. However, we don't assert if the caller tries to
313 * overwrite, just ignoring the update instead.
315 * @param event Pointer to the Service event.
316 * @param codec The codec to be set. ASCIIZ string. The caller does not
317 * need to preserve the value once the function returns.
318 *****************************************************************************/
319 void evel_service_codec_set(EVENT_SERVICE * const event,
320 const char * const codec)
324 /***************************************************************************/
325 /* Check preconditions and call evel_set_option_string. */
326 /***************************************************************************/
327 assert(event != NULL);
328 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
329 evel_set_option_string(&event->codec,
336 /**************************************************************************//**
337 * Set the Callee Side Codec property of the Service event.
339 * @note The property is treated as immutable: it is only valid to call
340 * the setter once. However, we don't assert if the caller tries to
341 * overwrite, just ignoring the update instead.
343 * @param event Pointer to the Service event.
344 * @param codec The codec to be set. ASCIIZ string. The caller does not
345 * need to preserve the value once the function returns.
346 *****************************************************************************/
347 void evel_service_callee_codec_set(EVENT_SERVICE * const event,
348 const char * const codec)
352 /***************************************************************************/
353 /* Check preconditions and call evel_set_option_string. */
354 /***************************************************************************/
355 assert(event != NULL);
356 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
357 evel_set_option_string(&event->callee_side_codec,
359 "Callee Side Codec");
364 /**************************************************************************//**
365 * Set the Caller Side Codec property of the Service event.
367 * @note The property is treated as immutable: it is only valid to call
368 * the setter once. However, we don't assert if the caller tries to
369 * overwrite, just ignoring the update instead.
371 * @param event Pointer to the Service event.
372 * @param codec The codec to be set. ASCIIZ string. The caller does not
373 * need to preserve the value once the function returns.
374 *****************************************************************************/
375 void evel_service_caller_codec_set(EVENT_SERVICE * const event,
376 const char * const codec)
380 /***************************************************************************/
381 /* Check preconditions and call evel_set_option_string. */
382 /***************************************************************************/
383 assert(event != NULL);
384 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
385 evel_set_option_string(&event->caller_side_codec,
387 "Caller Side Codec");
392 /**************************************************************************//**
393 * Set the RTCP Data property of the Service event.
395 * @note The property is treated as immutable: it is only valid to call
396 * the setter once. However, we don't assert if the caller tries to
397 * overwrite, just ignoring the update instead.
399 * @param event Pointer to the Service event.
400 * @param rtcp_data The RTCP Data to be set. ASCIIZ string. The caller
401 * does not need to preserve the value once the function
403 *****************************************************************************/
404 void evel_service_rtcp_data_set(EVENT_SERVICE * const event,
405 const char * const rtcp_data)
409 /***************************************************************************/
410 /* Check preconditions and call evel_set_option_string. */
411 /***************************************************************************/
412 assert(event != NULL);
413 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
414 evel_set_option_string(&event->rtcp_data,
421 /**************************************************************************//**
422 * Set the Adjacency Name property of the Service event.
424 * @note The property is treated as immutable: it is only valid to call
425 * the setter once. However, we don't assert if the caller tries to
426 * overwrite, just ignoring the update instead.
428 * @param event Pointer to the Service event.
429 * @param adjacency_name
430 * The adjacency name to be set. ASCIIZ string. The caller
431 * does not need to preserve the value once the function
433 *****************************************************************************/
434 void evel_service_adjacency_name_set(EVENT_SERVICE * const event,
435 const char * const adjacency_name)
439 /***************************************************************************/
440 /* Check preconditions and call evel_set_option_string. */
441 /***************************************************************************/
442 assert(event != NULL);
443 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
444 evel_set_option_string(&event->adjacency_name,
451 /**************************************************************************//**
452 * Set the Endpoint Descriptor property of the Service event.
454 * @note The property is treated as immutable: it is only valid to call
455 * the setter once. However, we don't assert if the caller tries to
456 * overwrite, just ignoring the update instead.
458 * @param event Pointer to the Service event.
459 * @param endpoint_desc The endpoint descriptor to be set.
460 *****************************************************************************/
461 void evel_service_endpoint_desc_set(
462 EVENT_SERVICE * const event,
463 const EVEL_SERVICE_ENDPOINT_DESC endpoint_desc)
467 /***************************************************************************/
468 /* Check preconditions and call evel_set_option_string. */
469 /***************************************************************************/
470 assert(event != NULL);
471 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
472 evel_set_option_string(&event->endpoint_description,
473 evel_service_endpoint_desc(endpoint_desc),
474 "Endpoint Description");
479 /**************************************************************************//**
480 * Set the Endpoint Jitter property of the Service event.
482 * @note The property is treated as immutable: it is only valid to call
483 * the setter once. However, we don't assert if the caller tries to
484 * overwrite, just ignoring the update instead.
486 * @param event Pointer to the Service event.
487 * @param jitter The jitter to be set.
488 *****************************************************************************/
489 void evel_service_endpoint_jitter_set(EVENT_SERVICE * const event,
494 /***************************************************************************/
495 /* Check preconditions and call evel_set_option_string. */
496 /***************************************************************************/
497 assert(event != NULL);
498 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
499 evel_set_option_int(&event->endpoint_jitter,
506 /**************************************************************************//**
507 * Set the Endpoint Rtp Octets Discarded property of the Service event.
509 * @note The property is treated as immutable: it is only valid to call
510 * the setter once. However, we don't assert if the caller tries to
511 * overwrite, just ignoring the update instead.
513 * @param event Pointer to the Service event.
514 * @param rtp_oct_disc The discard count.
515 *****************************************************************************/
516 void evel_service_endpoint_rtp_oct_disc_set(EVENT_SERVICE * const event,
517 const int rtp_oct_disc)
521 /***************************************************************************/
522 /* Check preconditions and call evel_set_option_string. */
523 /***************************************************************************/
524 assert(event != NULL);
525 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
526 evel_set_option_int(&event->endpoint_rtp_oct_disc,
528 "Endpoint Rtp Octets Discarded");
533 /**************************************************************************//**
534 * Set the Endpoint Rtp Octets Received property of the Service event.
536 * @note The property is treated as immutable: it is only valid to call
537 * the setter once. However, we don't assert if the caller tries to
538 * overwrite, just ignoring the update instead.
540 * @param event Pointer to the Service event.
541 * @param rtp_oct_recv The receive count.
542 *****************************************************************************/
543 void evel_service_endpoint_rtp_oct_recv_set(EVENT_SERVICE * const event,
544 const int rtp_oct_recv)
548 /***************************************************************************/
549 /* Check preconditions and call evel_set_option_string. */
550 /***************************************************************************/
551 assert(event != NULL);
552 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
553 evel_set_option_int(&event->endpoint_rtp_oct_recv,
555 "Endpoint Rtp Octets Received");
560 /**************************************************************************//**
561 * Set the Endpoint Rtp Octets Sent property of the Service event.
563 * @note The property is treated as immutable: it is only valid to call
564 * the setter once. However, we don't assert if the caller tries to
565 * overwrite, just ignoring the update instead.
567 * @param event Pointer to the Service event.
568 * @param rtp_oct_sent The send count.
569 *****************************************************************************/
570 void evel_service_endpoint_rtp_oct_sent_set(EVENT_SERVICE * const event,
571 const int rtp_oct_sent)
575 /***************************************************************************/
576 /* Check preconditions and call evel_set_option_string. */
577 /***************************************************************************/
578 assert(event != NULL);
579 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
580 evel_set_option_int(&event->endpoint_rtp_oct_sent,
582 "Endpoint Rtp Octets Sent");
587 /**************************************************************************//**
588 * Set the Endpoint Rtp Packets Discarded property of the Service event.
590 * @note The property is treated as immutable: it is only valid to call
591 * the setter once. However, we don't assert if the caller tries to
592 * overwrite, just ignoring the update instead.
594 * @param event Pointer to the Service event.
595 * @param rtp_pkt_disc The discard count.
596 *****************************************************************************/
597 void evel_service_endpoint_rtp_pkt_disc_set(EVENT_SERVICE * const event,
598 const int rtp_pkt_disc)
602 /***************************************************************************/
603 /* Check preconditions and call evel_set_option_string. */
604 /***************************************************************************/
605 assert(event != NULL);
606 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
607 evel_set_option_int(&event->endpoint_rtp_pkt_disc,
609 "Endpoint Rtp Packets Discarded");
614 /**************************************************************************//**
615 * Set the Endpoint Rtp Packets Received property of the Service event.
617 * @note The property is treated as immutable: it is only valid to call
618 * the setter once. However, we don't assert if the caller tries to
619 * overwrite, just ignoring the update instead.
621 * @param event Pointer to the Service event.
622 * @param rtp_pkt_recv The receive count.
623 *****************************************************************************/
624 void evel_service_endpoint_rtp_pkt_recv_set(EVENT_SERVICE * const event,
625 const int rtp_pkt_recv)
629 /***************************************************************************/
630 /* Check preconditions and call evel_set_option_string. */
631 /***************************************************************************/
632 assert(event != NULL);
633 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
634 evel_set_option_int(&event->endpoint_rtp_pkt_recv,
636 "Endpoint Rtp Packets Received");
641 /**************************************************************************//**
642 * Set the Endpoint Rtp Packets Sent property of the Service event.
644 * @note The property is treated as immutable: it is only valid to call
645 * the setter once. However, we don't assert if the caller tries to
646 * overwrite, just ignoring the update instead.
648 * @param event Pointer to the Service event.
649 * @param rtp_pkt_sent The send count.
650 *****************************************************************************/
651 void evel_service_endpoint_rtp_pkt_sent_set(EVENT_SERVICE * const event,
652 const int rtp_pkt_sent)
656 /***************************************************************************/
657 /* Check preconditions and call evel_set_option_string. */
658 /***************************************************************************/
659 assert(event != NULL);
660 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
661 evel_set_option_int(&event->endpoint_rtp_pkt_sent,
663 "Endpoint Rtp Packets Sent");
668 /**************************************************************************//**
669 * Set the Local Jitter property of the Service event.
671 * @note The property is treated as immutable: it is only valid to call
672 * the setter once. However, we don't assert if the caller tries to
673 * overwrite, just ignoring the update instead.
675 * @param event Pointer to the Service event.
676 * @param jitter The jitter to be set.
677 *****************************************************************************/
678 void evel_service_local_jitter_set(EVENT_SERVICE * const event,
683 /***************************************************************************/
684 /* Check preconditions and call evel_set_option_string. */
685 /***************************************************************************/
686 assert(event != NULL);
687 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
688 evel_set_option_int(&event->local_jitter,
695 /**************************************************************************//**
696 * Set the Local Rtp Octets Discarded property of the Service event.
698 * @note The property is treated as immutable: it is only valid to call
699 * the setter once. However, we don't assert if the caller tries to
700 * overwrite, just ignoring the update instead.
702 * @param event Pointer to the Service event.
703 * @param rtp_oct_disc The discard count.
704 *****************************************************************************/
705 void evel_service_local_rtp_oct_disc_set(EVENT_SERVICE * const event,
706 const int rtp_oct_disc)
710 /***************************************************************************/
711 /* Check preconditions and call evel_set_option_string. */
712 /***************************************************************************/
713 assert(event != NULL);
714 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
715 evel_set_option_int(&event->local_rtp_oct_disc,
717 "Local Rtp Octets Discarded");
722 /**************************************************************************//**
723 * Set the Local Rtp Octets Received property of the Service event.
725 * @note The property is treated as immutable: it is only valid to call
726 * the setter once. However, we don't assert if the caller tries to
727 * overwrite, just ignoring the update instead.
729 * @param event Pointer to the Service event.
730 * @param rtp_oct_recv The receive count.
731 *****************************************************************************/
732 void evel_service_local_rtp_oct_recv_set(EVENT_SERVICE * const event,
733 const int rtp_oct_recv)
737 /***************************************************************************/
738 /* Check preconditions and call evel_set_option_string. */
739 /***************************************************************************/
740 assert(event != NULL);
741 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
742 evel_set_option_int(&event->local_rtp_oct_recv,
744 "Local Rtp Octets Received");
749 /**************************************************************************//**
750 * Set the Local Rtp Octets Sent property of the Service event.
752 * @note The property is treated as immutable: it is only valid to call
753 * the setter once. However, we don't assert if the caller tries to
754 * overwrite, just ignoring the update instead.
756 * @param event Pointer to the Service event.
757 * @param rtp_oct_sent The send count.
758 *****************************************************************************/
759 void evel_service_local_rtp_oct_sent_set(EVENT_SERVICE * const event,
760 const int rtp_oct_sent)
764 /***************************************************************************/
765 /* Check preconditions and call evel_set_option_string. */
766 /***************************************************************************/
767 assert(event != NULL);
768 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
769 evel_set_option_int(&event->local_rtp_oct_sent,
771 "Local Rtp Octets Sent");
776 /**************************************************************************//**
777 * Set the Local Rtp Packets Discarded property of the Service event.
779 * @note The property is treated as immutable: it is only valid to call
780 * the setter once. However, we don't assert if the caller tries to
781 * overwrite, just ignoring the update instead.
783 * @param event Pointer to the Service event.
784 * @param rtp_pkt_disc The discard count.
785 *****************************************************************************/
786 void evel_service_local_rtp_pkt_disc_set(EVENT_SERVICE * const event,
787 const int rtp_pkt_disc)
791 /***************************************************************************/
792 /* Check preconditions and call evel_set_option_string. */
793 /***************************************************************************/
794 assert(event != NULL);
795 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
796 evel_set_option_int(&event->local_rtp_pkt_disc,
798 "Local Rtp Packets Discarded");
803 /**************************************************************************//**
804 * Set the Local Rtp Packets Received property of the Service event.
806 * @note The property is treated as immutable: it is only valid to call
807 * the setter once. However, we don't assert if the caller tries to
808 * overwrite, just ignoring the update instead.
810 * @param event Pointer to the Service event.
811 * @param rtp_pkt_recv The receive count.
812 *****************************************************************************/
813 void evel_service_local_rtp_pkt_recv_set(EVENT_SERVICE * const event,
814 const int rtp_pkt_recv)
818 /***************************************************************************/
819 /* Check preconditions and call evel_set_option_string. */
820 /***************************************************************************/
821 assert(event != NULL);
822 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
823 evel_set_option_int(&event->local_rtp_pkt_recv,
825 "Local Rtp Packets Received");
830 /**************************************************************************//**
831 * Set the Local Rtp Packets Sent property of the Service event.
833 * @note The property is treated as immutable: it is only valid to call
834 * the setter once. However, we don't assert if the caller tries to
835 * overwrite, just ignoring the update instead.
837 * @param event Pointer to the Service event.
838 * @param rtp_pkt_sent The send count.
839 *****************************************************************************/
840 void evel_service_local_rtp_pkt_sent_set(EVENT_SERVICE * const event,
841 const int rtp_pkt_sent)
845 /***************************************************************************/
846 /* Check preconditions and call evel_set_option_string. */
847 /***************************************************************************/
848 assert(event != NULL);
849 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
850 evel_set_option_int(&event->local_rtp_pkt_sent,
852 "Local Rtp Packets Sent");
857 /**************************************************************************//**
858 * Set the Mos Cqe property of the Service event.
860 * @note The property is treated as immutable: it is only valid to call
861 * the setter once. However, we don't assert if the caller tries to
862 * overwrite, just ignoring the update instead.
864 * @param event Pointer to the Service event.
865 * @param mos_cqe The mosCqe to be set.
866 *****************************************************************************/
867 void evel_service_mos_cqe_set(EVENT_SERVICE * const event,
868 const double mos_cqe)
872 /***************************************************************************/
873 /* Check preconditions and call evel_set_option_string. */
874 /***************************************************************************/
875 assert(event != NULL);
876 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
877 evel_set_option_double(&event->mos_cqe,
884 /**************************************************************************//**
885 * Set the Packets Lost property of the Service event.
887 * @note The property is treated as immutable: it is only valid to call
888 * the setter once. However, we don't assert if the caller tries to
889 * overwrite, just ignoring the update instead.
891 * @param event Pointer to the Service event.
892 * @param packets_lost The number of packets lost to be set.
893 *****************************************************************************/
894 void evel_service_packets_lost_set(EVENT_SERVICE * const event,
895 const int packets_lost)
899 /***************************************************************************/
900 /* Check preconditions and call evel_set_option_string. */
901 /***************************************************************************/
902 assert(event != NULL);
903 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
904 evel_set_option_int(&event->packets_lost,
911 /**************************************************************************//**
912 * Set the packet Loss Percent property of the Service event.
914 * @note The property is treated as immutable: it is only valid to call
915 * the setter once. However, we don't assert if the caller tries to
916 * overwrite, just ignoring the update instead.
918 * @param event Pointer to the Service event.
919 * @param packet_loss_percent
920 * The packet loss in percent.
921 *****************************************************************************/
922 void evel_service_packet_loss_percent_set(EVENT_SERVICE * const event,
923 const double packet_loss_percent)
927 /***************************************************************************/
928 /* Check preconditions and call evel_set_option_string. */
929 /***************************************************************************/
930 assert(event != NULL);
931 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
932 evel_set_option_double(&event->packet_loss_percent,
934 "Packet Loss Percent");
939 /**************************************************************************//**
940 * Set the R Factor property of the Service event.
942 * @note The property is treated as immutable: it is only valid to call
943 * the setter once. However, we don't assert if the caller tries to
944 * overwrite, just ignoring the update instead.
946 * @param event Pointer to the Service event.
947 * @param r_factor The R Factor to be set.
948 *****************************************************************************/
949 void evel_service_r_factor_set(EVENT_SERVICE * const event,
954 /***************************************************************************/
955 /* Check preconditions and call evel_set_option_string. */
956 /***************************************************************************/
957 assert(event != NULL);
958 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
959 evel_set_option_int(&event->r_factor,
966 /**************************************************************************//**
967 * Set the Round Trip Delay property of the Service event.
969 * @note The property is treated as immutable: it is only valid to call
970 * the setter once. However, we don't assert if the caller tries to
971 * overwrite, just ignoring the update instead.
973 * @param event Pointer to the Service event.
974 * @param round_trip_delay
975 * The Round trip delay to be set.
976 *****************************************************************************/
977 void evel_service_round_trip_delay_set(EVENT_SERVICE * const event,
978 const int round_trip_delay)
982 /***************************************************************************/
983 /* Check preconditions and call evel_set_option_string. */
984 /***************************************************************************/
985 assert(event != NULL);
986 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
987 evel_set_option_int(&event->round_trip_delay,
994 /**************************************************************************//**
995 * Set the Phone Number property of the Service event.
997 * @note The property is treated as immutable: it is only valid to call
998 * the setter once. However, we don't assert if the caller tries to
999 * overwrite, just ignoring the update instead.
1001 * @param event Pointer to the Service event.
1002 * @param phone_number The Phone Number to be set. ASCIIZ string. The caller
1003 * does not need to preserve the value once the function
1005 *****************************************************************************/
1006 void evel_service_phone_number_set(EVENT_SERVICE * const event,
1007 const char * const phone_number)
1011 /***************************************************************************/
1012 /* Check preconditions and call evel_set_option_string. */
1013 /***************************************************************************/
1014 assert(event != NULL);
1015 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1016 evel_set_option_string(&event->phone_number,
1023 /**************************************************************************//**
1024 * Encode the Service in JSON according to AT&T's schema for the
1027 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
1028 * @param event Pointer to the ::EVENT_HEADER to encode.
1029 *****************************************************************************/
1030 void evel_json_encode_service(EVEL_JSON_BUFFER * const jbuf,
1031 EVENT_SERVICE * const event)
1033 OTHER_FIELD * nv_pair = NULL;
1034 DLIST_ITEM * dlist_item = NULL;
1038 /***************************************************************************/
1039 /* Check preconditions. */
1040 /***************************************************************************/
1041 assert(event != NULL);
1042 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1044 evel_json_encode_header(jbuf, &event->header);
1045 evel_json_open_named_object(jbuf, "serviceEventsFields");
1047 /***************************************************************************/
1048 /* Mandatory fields */
1049 /***************************************************************************/
1050 evel_json_encode_instance_id(jbuf, &event->instance_id);
1051 evel_enc_version(jbuf,
1052 "serviceEventsFieldsVersion",
1053 event->major_version,
1054 event->minor_version);
1056 /***************************************************************************/
1057 /* Optional fields */
1058 /***************************************************************************/
1059 evel_enc_kv_opt_string(jbuf, "correlator", &event->correlator);
1061 /***************************************************************************/
1062 /* Checkpoint, so that we can wind back if all fields are suppressed. */
1063 /***************************************************************************/
1064 evel_json_checkpoint(jbuf);
1065 if (evel_json_open_opt_named_list(jbuf, "additionalFields"))
1069 dlist_item = dlist_get_first(&event->additional_fields);
1070 while (dlist_item != NULL)
1072 nv_pair = (OTHER_FIELD *) dlist_item->item;
1073 assert(nv_pair != NULL);
1075 if (!evel_throttle_suppress_nv_pair(jbuf->throttle_spec,
1079 evel_json_open_object(jbuf);
1080 evel_enc_kv_string(jbuf, "name", nv_pair->name);
1081 evel_enc_kv_string(jbuf, "value", nv_pair->value);
1082 evel_json_close_object(jbuf);
1085 dlist_item = dlist_get_next(dlist_item);
1087 evel_json_close_list(jbuf);
1089 /*************************************************************************/
1090 /* If we've not written anything, rewind to before we opened the list. */
1091 /*************************************************************************/
1094 evel_json_rewind(jbuf);
1098 /***************************************************************************/
1099 /* Optional fields within JSON equivalent object: codecSelected */
1100 /***************************************************************************/
1101 evel_json_checkpoint(jbuf);
1102 if (evel_json_open_opt_named_object(jbuf, "codecSelected"))
1105 added |= evel_enc_kv_opt_string(jbuf,
1108 evel_json_close_object(jbuf);
1110 /*************************************************************************/
1111 /* If the object is empty, rewind to before we opened it. */
1112 /*************************************************************************/
1115 evel_json_rewind(jbuf);
1119 /***************************************************************************/
1120 /* Optional fields within JSON equivalent object: codecSelectedTranscoding */
1121 /***************************************************************************/
1122 evel_json_checkpoint(jbuf);
1123 if (evel_json_open_opt_named_object(jbuf, "codecSelectedTranscoding"))
1126 added |= evel_enc_kv_opt_string(jbuf,
1128 &event->callee_side_codec);
1129 added |= evel_enc_kv_opt_string(jbuf,
1131 &event->caller_side_codec);
1132 evel_json_close_object(jbuf);
1134 /*************************************************************************/
1135 /* If the object is empty, rewind to before we opened it. */
1136 /*************************************************************************/
1139 evel_json_rewind(jbuf);
1143 /***************************************************************************/
1144 /* Optional fields within JSON equivalent object: midCallRtcp */
1145 /***************************************************************************/
1146 evel_json_checkpoint(jbuf);
1147 if (evel_json_open_opt_named_object(jbuf, "midCallRtcp"))
1150 added |= evel_enc_kv_opt_string(jbuf,
1153 evel_json_close_object(jbuf);
1155 /*************************************************************************/
1156 /* If the object is empty, rewind to before we opened it. */
1157 /*************************************************************************/
1160 evel_json_rewind(jbuf);
1164 /***************************************************************************/
1165 /* Optional fields within JSON equivalent object: endOfCallVqmSummaries */
1166 /***************************************************************************/
1167 evel_json_checkpoint(jbuf);
1168 if (evel_json_open_opt_named_object(jbuf, "endOfCallVqmSummaries"))
1171 added |= evel_enc_kv_opt_string(jbuf,
1173 &event->adjacency_name);
1174 added |= evel_enc_kv_opt_string(jbuf,
1175 "endpointDescription",
1176 &event->endpoint_description);
1177 added |= evel_enc_kv_opt_int(jbuf,
1179 &event->endpoint_jitter);
1180 added |= evel_enc_kv_opt_int(jbuf,
1181 "endpointRtpOctetsDiscarded",
1182 &event->endpoint_rtp_oct_disc);
1183 added |= evel_enc_kv_opt_int(jbuf,
1184 "endpointRtpOctetsReceived",
1185 &event->endpoint_rtp_oct_recv);
1186 added |= evel_enc_kv_opt_int(jbuf,
1187 "endpointRtpOctetsSent",
1188 &event->endpoint_rtp_oct_sent);
1189 added |= evel_enc_kv_opt_int(jbuf,
1190 "endpointRtpPacketsDiscarded",
1191 &event->endpoint_rtp_pkt_disc);
1192 added |= evel_enc_kv_opt_int(jbuf,
1193 "endpointRtpPacketsReceived",
1194 &event->endpoint_rtp_pkt_recv);
1195 added |= evel_enc_kv_opt_int(jbuf,
1196 "endpointRtpPacketsSent",
1197 &event->endpoint_rtp_pkt_sent);
1198 added |= evel_enc_kv_opt_int(jbuf,
1200 &event->local_jitter);
1201 added |= evel_enc_kv_opt_int(jbuf,
1202 "localRtpOctetsDiscarded",
1203 &event->local_rtp_oct_disc);
1204 added |= evel_enc_kv_opt_int(jbuf,
1205 "localRtpOctetsReceived",
1206 &event->local_rtp_oct_recv);
1207 added |= evel_enc_kv_opt_int(jbuf,
1208 "localRtpOctetsSent",
1209 &event->local_rtp_oct_sent);
1210 added |= evel_enc_kv_opt_int(jbuf,
1211 "localRtpPacketsDiscarded",
1212 &event->local_rtp_pkt_disc);
1213 added |= evel_enc_kv_opt_int(jbuf,
1214 "localRtpPacketsReceived",
1215 &event->local_rtp_pkt_recv);
1216 added |= evel_enc_kv_opt_int(jbuf,
1217 "localRtpPacketsSent",
1218 &event->local_rtp_pkt_sent);
1219 added |= evel_enc_kv_opt_double(jbuf,
1222 added |= evel_enc_kv_opt_int(jbuf,
1224 &event->packets_lost);
1225 added |= evel_enc_kv_opt_double(jbuf,
1226 "packetLossPercent",
1227 &event->packet_loss_percent);
1228 added |= evel_enc_kv_opt_int(jbuf,
1231 added |= evel_enc_kv_opt_int(jbuf,
1233 &event->round_trip_delay);
1234 evel_json_close_object(jbuf);
1236 /*************************************************************************/
1237 /* If the object is empty, rewind to before we opened it. */
1238 /*************************************************************************/
1241 evel_json_rewind(jbuf);
1245 /***************************************************************************/
1246 /* Optional fields within JSON equivalent object: marker */
1247 /***************************************************************************/
1248 evel_json_checkpoint(jbuf);
1249 if (evel_json_open_opt_named_object(jbuf, "marker"))
1252 added |= evel_enc_kv_opt_string(jbuf, "phoneNumber", &event->phone_number);
1253 evel_json_close_object(jbuf);
1255 /*************************************************************************/
1256 /* If the object is empty, rewind to before we opened it. */
1257 /*************************************************************************/
1260 evel_json_rewind(jbuf);
1264 evel_json_close_object(jbuf);
1269 /**************************************************************************//**
1270 * Free a Service event.
1272 * Free off the event supplied. Will free all the contained allocated memory.
1274 * @note It does not free the event itself, since that may be part of a larger
1276 *****************************************************************************/
1277 void evel_free_service(EVENT_SERVICE * const event)
1279 OTHER_FIELD * nv_pair = NULL;
1283 /***************************************************************************/
1284 /* Check preconditions. */
1285 /***************************************************************************/
1286 assert(event != NULL);
1287 assert(event->header.event_domain == EVEL_DOMAIN_SERVICE);
1289 /***************************************************************************/
1290 /* Free all internal strings then the header itself. */
1291 /***************************************************************************/
1292 nv_pair = dlist_pop_last(&event->additional_fields);
1293 while (nv_pair != NULL)
1295 EVEL_DEBUG("Freeing Other Field (%s, %s)", nv_pair->name, nv_pair->value);
1296 free(nv_pair->name);
1297 free(nv_pair->value);
1299 nv_pair = dlist_pop_last(&event->additional_fields);
1301 evel_free_option_string(&event->correlator);
1302 evel_free_option_string(&event->codec);
1303 evel_free_option_string(&event->callee_side_codec);
1304 evel_free_option_string(&event->caller_side_codec);
1305 evel_free_option_string(&event->rtcp_data);
1306 evel_free_option_string(&event->adjacency_name);
1307 evel_free_option_string(&event->endpoint_description);
1308 evel_free_option_string(&event->phone_number);
1309 evel_free_event_instance_id(&event->instance_id);
1310 evel_free_header(&event->header);