1 /**************************************************************************//**
3 * Implementation of EVEL functions relating to the Mobile Flow.
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 *****************************************************************************/
28 #include "evel_internal.h"
30 /*****************************************************************************/
31 /* Array of strings to use when encoding TCP flags. */
32 /*****************************************************************************/
33 static char * evel_tcp_flag_strings[EVEL_MAX_TCP_FLAGS] = {
45 /*****************************************************************************/
46 /* Array of strings to use when encoding QCI COS. */
47 /*****************************************************************************/
48 static char * evel_qci_cos_strings[EVEL_MAX_QCI_COS_TYPES] = {
68 /*****************************************************************************/
69 /* Local prototypes */
70 /*****************************************************************************/
71 void evel_json_encode_mobile_flow_gtp_flow_metrics(
72 EVEL_JSON_BUFFER * jbuf,
73 MOBILE_GTP_PER_FLOW_METRICS * metrics);
75 /**************************************************************************//**
76 * Create a new Mobile Flow event.
78 * @note The mandatory fields on the Mobile Flow must be supplied to this
79 * factory function and are immutable once set. Optional fields have
80 * explicit setter functions, but again values may only be set once so
81 * that the Mobile Flow has immutable properties.
82 * @param flow_direction Flow direction.
83 * @param gtp_per_flow_metrics GTP per-flow metrics.
84 * @param ip_protocol_type IP protocol type.
85 * @param ip_version IP protocol version.
86 * @param other_endpoint_ip_address IP address of the other endpoint.
87 * @param other_endpoint_port IP port of the other endpoint.
88 * @param reporting_endpoint_ip_addr IP address of the reporting endpoint.
89 * @param reporting_endpoint_port IP port of the reporting endpoint.
90 * @returns pointer to the newly manufactured ::EVENT_MOBILE_FLOW. If the
91 * event is not used (i.e. posted) it must be released using
92 * ::evel_free_mobile_flow.
93 * @retval NULL Failed to create the event.
94 *****************************************************************************/
95 EVENT_MOBILE_FLOW * evel_new_mobile_flow(
96 const char * const flow_direction,
97 MOBILE_GTP_PER_FLOW_METRICS * gtp_per_flow_metrics,
98 const char * const ip_protocol_type,
99 const char * const ip_version,
100 const char * const other_endpoint_ip_address,
101 int other_endpoint_port,
102 const char * const reporting_endpoint_ip_addr,
103 int reporting_endpoint_port)
105 EVENT_MOBILE_FLOW * mobile_flow = NULL;
108 /***************************************************************************/
109 /* Check preconditions. */
110 /***************************************************************************/
111 assert(flow_direction != NULL);
112 assert(gtp_per_flow_metrics != NULL);
113 assert(ip_protocol_type != NULL);
114 assert(ip_version != NULL);
115 assert(other_endpoint_ip_address != NULL);
116 assert(other_endpoint_port > 0);
117 assert(reporting_endpoint_ip_addr != NULL);
118 assert(reporting_endpoint_port > 0);
120 /***************************************************************************/
121 /* Allocate the Mobile Flow. */
122 /***************************************************************************/
123 mobile_flow = malloc(sizeof(EVENT_MOBILE_FLOW));
124 if (mobile_flow == NULL)
126 log_error_state("Out of memory");
129 memset(mobile_flow, 0, sizeof(EVENT_MOBILE_FLOW));
130 EVEL_DEBUG("New Mobile Flow is at %lp", mobile_flow);
132 /***************************************************************************/
133 /* Initialize the header & the Mobile Flow fields. Optional string values */
134 /* are uninitialized (NULL). */
135 /***************************************************************************/
136 evel_init_header(&mobile_flow->header);
137 mobile_flow->header.event_domain = EVEL_DOMAIN_MOBILE_FLOW;
138 mobile_flow->major_version = EVEL_MOBILE_FLOW_MAJOR_VERSION;
139 mobile_flow->minor_version = EVEL_MOBILE_FLOW_MINOR_VERSION;
140 mobile_flow->flow_direction = strdup(flow_direction);
141 mobile_flow->gtp_per_flow_metrics = gtp_per_flow_metrics;
142 mobile_flow->ip_protocol_type = strdup(ip_protocol_type);
143 mobile_flow->ip_version = strdup(ip_version);
144 mobile_flow->other_endpoint_ip_address = strdup(other_endpoint_ip_address);
145 mobile_flow->other_endpoint_port = other_endpoint_port;
146 mobile_flow->reporting_endpoint_ip_addr = strdup(reporting_endpoint_ip_addr);
147 mobile_flow->reporting_endpoint_port = reporting_endpoint_port;
148 evel_init_option_string(&mobile_flow->application_type);
149 evel_init_option_string(&mobile_flow->app_protocol_type);
150 evel_init_option_string(&mobile_flow->app_protocol_version);
151 evel_init_option_string(&mobile_flow->cid);
152 evel_init_option_string(&mobile_flow->connection_type);
153 evel_init_option_string(&mobile_flow->ecgi);
154 evel_init_option_string(&mobile_flow->gtp_protocol_type);
155 evel_init_option_string(&mobile_flow->gtp_version);
156 evel_init_option_string(&mobile_flow->http_header);
157 evel_init_option_string(&mobile_flow->imei);
158 evel_init_option_string(&mobile_flow->imsi);
159 evel_init_option_string(&mobile_flow->lac);
160 evel_init_option_string(&mobile_flow->mcc);
161 evel_init_option_string(&mobile_flow->mnc);
162 evel_init_option_string(&mobile_flow->msisdn);
163 evel_init_option_string(&mobile_flow->other_functional_role);
164 evel_init_option_string(&mobile_flow->rac);
165 evel_init_option_string(&mobile_flow->radio_access_technology);
166 evel_init_option_string(&mobile_flow->sac);
167 evel_init_option_int(&mobile_flow->sampling_algorithm);
168 evel_init_option_string(&mobile_flow->tac);
169 evel_init_option_string(&mobile_flow->tunnel_id);
170 evel_init_option_string(&mobile_flow->vlan_id);
177 /**************************************************************************//**
178 * Set the Event Type property of the Mobile Flow.
180 * @note The property is treated as immutable: it is only valid to call
181 * the setter once. However, we don't assert if the caller tries to
182 * overwrite, just ignoring the update instead.
184 * @param mobile_flow Pointer to the Mobile Flow.
185 * @param type The Event Type to be set. ASCIIZ string. The caller
186 * does not need to preserve the value once the function
188 *****************************************************************************/
189 void evel_mobile_flow_type_set(EVENT_MOBILE_FLOW * mobile_flow,
190 const char * const type)
194 /***************************************************************************/
195 /* Check preconditions and call evel_header_type_set. */
196 /***************************************************************************/
197 assert(mobile_flow != NULL);
198 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
199 evel_header_type_set(&mobile_flow->header, type);
204 /**************************************************************************//**
205 * Set the Application Type property of the Mobile Flow.
207 * @note The property is treated as immutable: it is only valid to call
208 * the setter once. However, we don't assert if the caller tries to
209 * overwrite, just ignoring the update instead.
211 * @param mobile_flow Pointer to the Mobile Flow.
212 * @param type The Application Type to be set. ASCIIZ string. The caller
213 * does not need to preserve the value once the function
215 *****************************************************************************/
216 void evel_mobile_flow_app_type_set(EVENT_MOBILE_FLOW * mobile_flow,
217 const char * const type)
221 /***************************************************************************/
222 /* Check preconditions. */
223 /***************************************************************************/
224 assert(mobile_flow != NULL);
225 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
226 assert(type != NULL);
228 evel_set_option_string(&mobile_flow->application_type,
234 /**************************************************************************//**
235 * Set the Application Protocol Type property of the Mobile Flow.
237 * @note The property is treated as immutable: it is only valid to call
238 * the setter once. However, we don't assert if the caller tries to
239 * overwrite, just ignoring the update instead.
241 * @param mobile_flow Pointer to the Mobile Flow.
242 * @param type The Application Protocol Type to be set. ASCIIZ string.
243 * The caller does not need to preserve the value once the
245 *****************************************************************************/
246 void evel_mobile_flow_app_prot_type_set(EVENT_MOBILE_FLOW * mobile_flow,
247 const char * const type)
251 /***************************************************************************/
252 /* Check preconditions. */
253 /***************************************************************************/
254 assert(mobile_flow != NULL);
255 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
256 assert(type != NULL);
258 evel_set_option_string(&mobile_flow->app_protocol_type,
260 "Application Protocol Type");
264 /**************************************************************************//**
265 * Set the Application Protocol Version property of the Mobile Flow.
267 * @note The property is treated as immutable: it is only valid to call
268 * the setter once. However, we don't assert if the caller tries to
269 * overwrite, just ignoring the update instead.
271 * @param mobile_flow Pointer to the Mobile Flow.
272 * @param version The Application Protocol Version to be set. ASCIIZ
273 * string. The caller does not need to preserve the value
274 * once the function returns.
275 *****************************************************************************/
276 void evel_mobile_flow_app_prot_ver_set(EVENT_MOBILE_FLOW * mobile_flow,
277 const char * const version)
281 /***************************************************************************/
282 /* Check preconditions. */
283 /***************************************************************************/
284 assert(mobile_flow != NULL);
285 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
286 assert(version != NULL);
288 evel_set_option_string(&mobile_flow->app_protocol_version,
290 "Application Protocol Version");
294 /**************************************************************************//**
295 * Set the CID property of the Mobile Flow.
297 * @note The property is treated as immutable: it is only valid to call
298 * the setter once. However, we don't assert if the caller tries to
299 * overwrite, just ignoring the update instead.
301 * @param mobile_flow Pointer to the Mobile Flow.
302 * @param cid The CID to be set. ASCIIZ string. The caller does not
303 * need to preserve the value once the function returns.
304 *****************************************************************************/
305 void evel_mobile_flow_cid_set(EVENT_MOBILE_FLOW * mobile_flow,
306 const char * const cid)
310 /***************************************************************************/
311 /* Check preconditions. */
312 /***************************************************************************/
313 assert(mobile_flow != NULL);
314 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
317 evel_set_option_string(&mobile_flow->cid,
323 /**************************************************************************//**
324 * Set the Connection Type property of the Mobile Flow.
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 mobile_flow Pointer to the Mobile Flow.
331 * @param type The Connection Type to be set. ASCIIZ string. The caller
332 * does not need to preserve the value once the function
334 *****************************************************************************/
335 void evel_mobile_flow_con_type_set(EVENT_MOBILE_FLOW * mobile_flow,
336 const char * const type)
340 /***************************************************************************/
341 /* Check preconditions. */
342 /***************************************************************************/
343 assert(mobile_flow != NULL);
344 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
345 assert(type != NULL);
347 evel_set_option_string(&mobile_flow->connection_type,
353 /**************************************************************************//**
354 * Set the ECGI property of the Mobile Flow.
356 * @note The property is treated as immutable: it is only valid to call
357 * the setter once. However, we don't assert if the caller tries to
358 * overwrite, just ignoring the update instead.
360 * @param mobile_flow Pointer to the Mobile Flow.
361 * @param ecgi The ECGI to be set. ASCIIZ string. The caller does not
362 * need to preserve the value once the function returns.
363 *****************************************************************************/
364 void evel_mobile_flow_ecgi_set(EVENT_MOBILE_FLOW * mobile_flow,
365 const char * const ecgi)
369 /***************************************************************************/
370 /* Check preconditions. */
371 /***************************************************************************/
372 assert(mobile_flow != NULL);
373 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
374 assert(ecgi != NULL);
376 evel_set_option_string(&mobile_flow->ecgi,
382 /**************************************************************************//**
383 * Set the GTP Protocol Type property of the Mobile Flow.
385 * @note The property is treated as immutable: it is only valid to call
386 * the setter once. However, we don't assert if the caller tries to
387 * overwrite, just ignoring the update instead.
389 * @param mobile_flow Pointer to the Mobile Flow.
390 * @param type The GTP Protocol Type to be set. ASCIIZ string. The
391 * caller does not need to preserve the value once the
393 *****************************************************************************/
394 void evel_mobile_flow_gtp_prot_type_set(EVENT_MOBILE_FLOW * mobile_flow,
395 const char * const type)
399 /***************************************************************************/
400 /* Check preconditions. */
401 /***************************************************************************/
402 assert(mobile_flow != NULL);
403 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
404 assert(type != NULL);
406 evel_set_option_string(&mobile_flow->gtp_protocol_type,
408 "GTP Protocol Type");
412 /**************************************************************************//**
413 * Set the GTP Protocol Version property of the Mobile Flow.
415 * @note The property is treated as immutable: it is only valid to call
416 * the setter once. However, we don't assert if the caller tries to
417 * overwrite, just ignoring the update instead.
419 * @param mobile_flow Pointer to the Mobile Flow.
420 * @param version The GTP Protocol Version to be set. ASCIIZ string. The
421 * caller does not need to preserve the value once the
423 *****************************************************************************/
424 void evel_mobile_flow_gtp_prot_ver_set(EVENT_MOBILE_FLOW * mobile_flow,
425 const char * const version)
429 /***************************************************************************/
430 /* Check preconditions. */
431 /***************************************************************************/
432 assert(mobile_flow != NULL);
433 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
434 assert(version != NULL);
436 evel_set_option_string(&mobile_flow->gtp_version,
438 "GTP Protocol Version");
442 /**************************************************************************//**
443 * Set the HTTP Header property of the Mobile Flow.
445 * @note The property is treated as immutable: it is only valid to call
446 * the setter once. However, we don't assert if the caller tries to
447 * overwrite, just ignoring the update instead.
449 * @param mobile_flow Pointer to the Mobile Flow.
450 * @param header The HTTP header to be set. ASCIIZ string. The caller does
451 * not need to preserve the value once the function returns.
452 *****************************************************************************/
453 void evel_mobile_flow_http_header_set(EVENT_MOBILE_FLOW * mobile_flow,
454 const char * const header)
458 /***************************************************************************/
459 /* Check preconditions. */
460 /***************************************************************************/
461 assert(mobile_flow != NULL);
462 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
463 assert(header != NULL);
465 evel_set_option_string(&mobile_flow->http_header,
471 /**************************************************************************//**
472 * Set the IMEI property of the Mobile Flow.
474 * @note The property is treated as immutable: it is only valid to call
475 * the setter once. However, we don't assert if the caller tries to
476 * overwrite, just ignoring the update instead.
478 * @param mobile_flow Pointer to the Mobile Flow.
479 * @param imei The IMEI to be set. ASCIIZ string. The caller does not
480 * need to preserve the value once the function returns.
481 *****************************************************************************/
482 void evel_mobile_flow_imei_set(EVENT_MOBILE_FLOW * mobile_flow,
483 const char * const imei)
487 /***************************************************************************/
488 /* Check preconditions. */
489 /***************************************************************************/
490 assert(mobile_flow != NULL);
491 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
492 assert(imei != NULL);
494 evel_set_option_string(&mobile_flow->imei,
500 /**************************************************************************//**
501 * Set the IMSI property of the Mobile Flow.
503 * @note The property is treated as immutable: it is only valid to call
504 * the setter once. However, we don't assert if the caller tries to
505 * overwrite, just ignoring the update instead.
507 * @param mobile_flow Pointer to the Mobile Flow.
508 * @param imsi The IMSI to be set. ASCIIZ string. The caller does not
509 * need to preserve the value once the function returns.
510 *****************************************************************************/
511 void evel_mobile_flow_imsi_set(EVENT_MOBILE_FLOW * mobile_flow,
512 const char * const imsi)
516 /***************************************************************************/
517 /* Check preconditions. */
518 /***************************************************************************/
519 assert(mobile_flow != NULL);
520 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
521 assert(imsi != NULL);
523 evel_set_option_string(&mobile_flow->imsi,
529 /**************************************************************************//**
530 * Set the LAC property of the Mobile Flow.
532 * @note The property is treated as immutable: it is only valid to call
533 * the setter once. However, we don't assert if the caller tries to
534 * overwrite, just ignoring the update instead.
536 * @param mobile_flow Pointer to the Mobile Flow.
537 * @param lac The LAC to be set. ASCIIZ string. The caller does not
538 * need to preserve the value once the function returns.
539 *****************************************************************************/
540 void evel_mobile_flow_lac_set(EVENT_MOBILE_FLOW * mobile_flow,
541 const char * const lac)
545 /***************************************************************************/
546 /* Check preconditions. */
547 /***************************************************************************/
548 assert(mobile_flow != NULL);
549 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
552 evel_set_option_string(&mobile_flow->lac,
558 /**************************************************************************//**
559 * Set the MCC property of the Mobile Flow.
561 * @note The property is treated as immutable: it is only valid to call
562 * the setter once. However, we don't assert if the caller tries to
563 * overwrite, just ignoring the update instead.
565 * @param mobile_flow Pointer to the Mobile Flow.
566 * @param mcc The MCC to be set. ASCIIZ string. The caller does not
567 * need to preserve the value once the function returns.
568 *****************************************************************************/
569 void evel_mobile_flow_mcc_set(EVENT_MOBILE_FLOW * mobile_flow,
570 const char * const mcc)
574 /***************************************************************************/
575 /* Check preconditions. */
576 /***************************************************************************/
577 assert(mobile_flow != NULL);
578 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
581 evel_set_option_string(&mobile_flow->mcc,
587 /**************************************************************************//**
588 * Set the MNC property of the Mobile Flow.
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 mobile_flow Pointer to the Mobile Flow.
595 * @param mnc The MNC to be set. ASCIIZ string. The caller does not
596 * need to preserve the value once the function returns.
597 *****************************************************************************/
598 void evel_mobile_flow_mnc_set(EVENT_MOBILE_FLOW * mobile_flow,
599 const char * const mnc)
603 /***************************************************************************/
604 /* Check preconditions. */
605 /***************************************************************************/
606 assert(mobile_flow != NULL);
607 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
610 evel_set_option_string(&mobile_flow->mnc,
616 /**************************************************************************//**
617 * Set the MSISDN property of the Mobile Flow.
619 * @note The property is treated as immutable: it is only valid to call
620 * the setter once. However, we don't assert if the caller tries to
621 * overwrite, just ignoring the update instead.
623 * @param mobile_flow Pointer to the Mobile Flow.
624 * @param msisdn The MSISDN to be set. ASCIIZ string. The caller does not
625 * need to preserve the value once the function returns.
626 *****************************************************************************/
627 void evel_mobile_flow_msisdn_set(EVENT_MOBILE_FLOW * mobile_flow,
628 const char * const msisdn)
632 /***************************************************************************/
633 /* Check preconditions. */
634 /***************************************************************************/
635 assert(mobile_flow != NULL);
636 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
637 assert(msisdn != NULL);
639 evel_set_option_string(&mobile_flow->msisdn,
645 /**************************************************************************//**
646 * Set the Other Functional Role property of the Mobile Flow.
648 * @note The property is treated as immutable: it is only valid to call
649 * the setter once. However, we don't assert if the caller tries to
650 * overwrite, just ignoring the update instead.
652 * @param mobile_flow Pointer to the Mobile Flow.
653 * @param role The Other Functional Role to be set. ASCIIZ string. The
654 * caller does not need to preserve the value once the
656 *****************************************************************************/
657 void evel_mobile_flow_other_func_role_set(EVENT_MOBILE_FLOW * mobile_flow,
658 const char * const role)
662 /***************************************************************************/
663 /* Check preconditions. */
664 /***************************************************************************/
665 assert(mobile_flow != NULL);
666 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
667 assert(role != NULL);
669 evel_set_option_string(&mobile_flow->other_functional_role,
671 "Other Functional Role");
675 /**************************************************************************//**
676 * Set the RAC property of the Mobile Flow.
678 * @note The property is treated as immutable: it is only valid to call
679 * the setter once. However, we don't assert if the caller tries to
680 * overwrite, just ignoring the update instead.
682 * @param mobile_flow Pointer to the Mobile Flow.
683 * @param rac The RAC to be set. ASCIIZ string. The caller does not
684 * need to preserve the value once the function returns.
685 *****************************************************************************/
686 void evel_mobile_flow_rac_set(EVENT_MOBILE_FLOW * mobile_flow,
687 const char * const rac)
691 /***************************************************************************/
692 /* Check preconditions. */
693 /***************************************************************************/
694 assert(mobile_flow != NULL);
695 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
698 evel_set_option_string(&mobile_flow->rac,
704 /**************************************************************************//**
705 * Set the Radio Access Technology property of the Mobile Flow.
707 * @note The property is treated as immutable: it is only valid to call
708 * the setter once. However, we don't assert if the caller tries to
709 * overwrite, just ignoring the update instead.
711 * @param mobile_flow Pointer to the Mobile Flow.
712 * @param tech The Radio Access Technology to be set. ASCIIZ string. The
713 * caller does not need to preserve the value once the
715 *****************************************************************************/
716 void evel_mobile_flow_radio_acc_tech_set(EVENT_MOBILE_FLOW * mobile_flow,
717 const char * const tech)
721 /***************************************************************************/
722 /* Check preconditions. */
723 /***************************************************************************/
724 assert(mobile_flow != NULL);
725 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
726 assert(tech != NULL);
728 evel_set_option_string(&mobile_flow->radio_access_technology,
730 "Radio Access Technology");
734 /**************************************************************************//**
735 * Set the SAC property of the Mobile Flow.
737 * @note The property is treated as immutable: it is only valid to call
738 * the setter once. However, we don't assert if the caller tries to
739 * overwrite, just ignoring the update instead.
741 * @param mobile_flow Pointer to the Mobile Flow.
742 * @param sac The SAC to be set. ASCIIZ string. The caller does not
743 * need to preserve the value once the function returns.
744 *****************************************************************************/
745 void evel_mobile_flow_sac_set(EVENT_MOBILE_FLOW * mobile_flow,
746 const char * const sac)
750 /***************************************************************************/
751 /* Check preconditions. */
752 /***************************************************************************/
753 assert(mobile_flow != NULL);
754 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
757 evel_set_option_string(&mobile_flow->sac,
763 /**************************************************************************//**
764 * Set the Sampling Algorithm property of the Mobile Flow.
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 mobile_flow Pointer to the Mobile Flow.
771 * @param algorithm The Sampling Algorithm to be set.
772 *****************************************************************************/
773 void evel_mobile_flow_samp_alg_set(EVENT_MOBILE_FLOW * mobile_flow,
778 /***************************************************************************/
779 /* Check preconditions. */
780 /***************************************************************************/
781 assert(mobile_flow != NULL);
782 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
783 assert(algorithm >= 0);
785 evel_set_option_int(&mobile_flow->sampling_algorithm,
787 "Sampling Algorithm");
791 /**************************************************************************//**
792 * Set the TAC property of the Mobile Flow.
794 * @note The property is treated as immutable: it is only valid to call
795 * the setter once. However, we don't assert if the caller tries to
796 * overwrite, just ignoring the update instead.
798 * @param mobile_flow Pointer to the Mobile Flow.
799 * @param tac The TAC to be set. ASCIIZ string. The caller does not
800 * need to preserve the value once the function returns.
801 *****************************************************************************/
802 void evel_mobile_flow_tac_set(EVENT_MOBILE_FLOW * mobile_flow,
803 const char * const tac)
807 /***************************************************************************/
808 /* Check preconditions. */
809 /***************************************************************************/
810 assert(mobile_flow != NULL);
811 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
814 evel_set_option_string(&mobile_flow->tac,
820 /**************************************************************************//**
821 * Set the Tunnel ID property of the Mobile Flow.
823 * @note The property is treated as immutable: it is only valid to call
824 * the setter once. However, we don't assert if the caller tries to
825 * overwrite, just ignoring the update instead.
827 * @param mobile_flow Pointer to the Mobile Flow.
828 * @param tunnel_id The Tunnel ID to be set. ASCIIZ string. The caller does
829 * not need to preserve the value once the function returns.
830 *****************************************************************************/
831 void evel_mobile_flow_tunnel_id_set(EVENT_MOBILE_FLOW * mobile_flow,
832 const char * const tunnel_id)
836 /***************************************************************************/
837 /* Check preconditions. */
838 /***************************************************************************/
839 assert(mobile_flow != NULL);
840 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
841 assert(tunnel_id != NULL);
843 evel_set_option_string(&mobile_flow->tunnel_id,
849 /**************************************************************************//**
850 * Set the VLAN ID property of the Mobile Flow.
852 * @note The property is treated as immutable: it is only valid to call
853 * the setter once. However, we don't assert if the caller tries to
854 * overwrite, just ignoring the update instead.
856 * @param mobile_flow Pointer to the Mobile Flow.
857 * @param vlan_id The VLAN ID to be set. ASCIIZ string. The caller does
858 * not need to preserve the value once the function returns.
859 *****************************************************************************/
860 void evel_mobile_flow_vlan_id_set(EVENT_MOBILE_FLOW * mobile_flow,
861 const char * const vlan_id)
865 /***************************************************************************/
866 /* Check preconditions. */
867 /***************************************************************************/
868 assert(mobile_flow != NULL);
869 assert(mobile_flow->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
870 assert(vlan_id != NULL);
872 evel_set_option_string(&mobile_flow->vlan_id,
878 /**************************************************************************//**
879 * Encode the Mobile Flow in JSON according to AT&T's schema for the event
882 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
883 * @param event Pointer to the ::EVENT_HEADER to encode.
884 *****************************************************************************/
885 void evel_json_encode_mobile_flow(EVEL_JSON_BUFFER * jbuf,
886 EVENT_MOBILE_FLOW * event)
890 /***************************************************************************/
891 /* Check preconditions. */
892 /***************************************************************************/
893 assert(event != NULL);
894 assert(event->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
896 evel_json_encode_header(jbuf, &event->header);
897 evel_json_open_named_object(jbuf, "mobileFlowFields");
899 /***************************************************************************/
900 /* Mandatory parameters. */
901 /***************************************************************************/
902 evel_enc_kv_string(jbuf, "flowDirection", event->flow_direction);
903 evel_json_encode_mobile_flow_gtp_flow_metrics(
904 jbuf, event->gtp_per_flow_metrics);
905 evel_enc_kv_string(jbuf, "ipProtocolType", event->ip_protocol_type);
906 evel_enc_kv_string(jbuf, "ipVersion", event->ip_version);
908 jbuf, "otherEndpointIpAddress", event->other_endpoint_ip_address);
909 evel_enc_kv_int(jbuf, "otherEndpointPort", event->other_endpoint_port);
911 jbuf, "reportingEndpointIpAddr", event->reporting_endpoint_ip_addr);
913 jbuf, "reportingEndpointPort", event->reporting_endpoint_port);
915 /***************************************************************************/
916 /* Optional parameters. */
917 /***************************************************************************/
918 evel_enc_kv_opt_string(jbuf, "applicationType", &event->application_type);
919 evel_enc_kv_opt_string(jbuf, "appProtocolType", &event->app_protocol_type);
920 evel_enc_kv_opt_string(
921 jbuf, "appProtocolVersion", &event->app_protocol_version);
922 evel_enc_kv_opt_string(jbuf, "cid", &event->cid);
923 evel_enc_kv_opt_string(jbuf, "connectionType", &event->connection_type);
924 evel_enc_kv_opt_string(jbuf, "ecgi", &event->ecgi);
925 evel_enc_kv_opt_string(jbuf, "gtpProtocolType", &event->gtp_protocol_type);
926 evel_enc_kv_opt_string(jbuf, "gtpVersion", &event->gtp_version);
927 evel_enc_kv_opt_string(jbuf, "httpHeader", &event->http_header);
928 evel_enc_kv_opt_string(jbuf, "imei", &event->imei);
929 evel_enc_kv_opt_string(jbuf, "imsi", &event->imsi);
930 evel_enc_kv_opt_string(jbuf, "lac", &event->lac);
931 evel_enc_kv_opt_string(jbuf, "mcc", &event->mcc);
932 evel_enc_kv_opt_string(jbuf, "mnc", &event->mnc);
933 evel_enc_kv_opt_string(jbuf, "msisdn", &event->msisdn);
934 evel_enc_kv_opt_string(
935 jbuf, "otherFunctionalRole", &event->other_functional_role);
936 evel_enc_kv_opt_string(jbuf, "rac", &event->rac);
937 evel_enc_kv_opt_string(
938 jbuf, "radioAccessTechnology", &event->radio_access_technology);
939 evel_enc_kv_opt_string(jbuf, "sac", &event->sac);
940 evel_enc_kv_opt_int(jbuf, "samplingAlgorithm", &event->sampling_algorithm);
941 evel_enc_kv_opt_string(jbuf, "tac", &event->tac);
942 evel_enc_kv_opt_string(jbuf, "tunnelId", &event->tunnel_id);
943 evel_enc_kv_opt_string(jbuf, "vlanId", &event->vlan_id);
945 /***************************************************************************/
947 /***************************************************************************/
948 evel_enc_version(jbuf,
949 "mobileFlowFieldsVersion",
950 event->major_version,
951 event->minor_version);
953 evel_json_close_object(jbuf);
958 /**************************************************************************//**
959 * Free a Mobile Flow.
961 * Free off the Mobile Flow supplied. Will free all the contained allocated
964 * @note It does not free the Mobile Flow itself, since that may be part of a
966 *****************************************************************************/
967 void evel_free_mobile_flow(EVENT_MOBILE_FLOW * event)
971 /***************************************************************************/
972 /* Check preconditions. As an internal API we don't allow freeing NULL */
973 /* events as we do on the public API. */
974 /***************************************************************************/
975 assert(event != NULL);
976 assert(event->header.event_domain == EVEL_DOMAIN_MOBILE_FLOW);
978 /***************************************************************************/
979 /* Free all internal strings then the header itself. */
980 /***************************************************************************/
981 free(event->flow_direction);
983 evel_free_mobile_gtp_flow_metrics(event->gtp_per_flow_metrics);
984 free(event->gtp_per_flow_metrics);
985 free(event->ip_protocol_type);
986 free(event->ip_version);
987 free(event->other_endpoint_ip_address);
988 free(event->reporting_endpoint_ip_addr);
989 evel_free_option_string(&event->application_type);
990 evel_free_option_string(&event->app_protocol_type);
991 evel_free_option_string(&event->app_protocol_version);
992 evel_free_option_string(&event->cid);
993 evel_free_option_string(&event->connection_type);
994 evel_free_option_string(&event->ecgi);
995 evel_free_option_string(&event->gtp_protocol_type);
996 evel_free_option_string(&event->gtp_version);
997 evel_free_option_string(&event->http_header);
998 evel_free_option_string(&event->imei);
999 evel_free_option_string(&event->imsi);
1000 evel_free_option_string(&event->lac);
1001 evel_free_option_string(&event->mcc);
1002 evel_free_option_string(&event->mnc);
1003 evel_free_option_string(&event->msisdn);
1004 evel_free_option_string(&event->other_functional_role);
1005 evel_free_option_string(&event->rac);
1006 evel_free_option_string(&event->radio_access_technology);
1007 evel_free_option_string(&event->sac);
1008 evel_free_option_string(&event->tac);
1009 evel_free_option_string(&event->tunnel_id);
1010 evel_free_option_string(&event->vlan_id);
1012 evel_free_header(&event->header);
1017 /**************************************************************************//**
1018 * Create a new Mobile GTP Per Flow Metrics.
1020 * @note The mandatory fields on the Mobile GTP Per Flow Metrics must be
1021 * supplied to this factory function and are immutable once set.
1022 * Optional fields have explicit setter functions, but again values
1023 * may only be set once so that the Mobile GTP Per Flow Metrics has
1024 * immutable properties.
1026 * @param avg_bit_error_rate Average bit error rate.
1027 * @param avg_packet_delay_variation Average delay or jitter in ms.
1028 * @param avg_packet_latency Average delivery latency.
1029 * @param avg_receive_throughput Average receive throughput.
1030 * @param avg_transmit_throughput Average transmit throughput.
1031 * @param flow_activation_epoch Time the connection is activated.
1032 * @param flow_activation_microsec Microseconds for the start of the flow
1034 * @param flow_deactivation_epoch Time for the end of the connection.
1035 * @param flow_deactivation_microsec Microseconds for the end of the flow
1037 * @param flow_deactivation_time Transmission time of the first packet.
1038 * @param flow_status Connection status.
1039 * @param max_packet_delay_variation Maximum packet delay or jitter in ms.
1040 * @param num_activation_failures Number of failed activation requests.
1041 * @param num_bit_errors Number of errored bits.
1042 * @param num_bytes_received Number of bytes received.
1043 * @param num_bytes_transmitted Number of bytes transmitted.
1044 * @param num_dropped_packets Number of received packets dropped.
1045 * @param num_l7_bytes_received Number of tunneled Layer 7 bytes
1047 * @param num_l7_bytes_transmitted Number of tunneled Layer 7 bytes
1049 * @param num_lost_packets Number of lost packets.
1050 * @param num_out_of_order_packets Number of out-of-order packets.
1051 * @param num_packet_errors Number of errored packets.
1052 * @param num_packets_received_excl_retrans Number of packets received,
1053 * excluding retransmits.
1054 * @param num_packets_received_incl_retrans Number of packets received.
1055 * @param num_packets_transmitted_incl_retrans Number of packets
1057 * @param num_retries Number of packet retries.
1058 * @param num_timeouts Number of packet timeouts.
1059 * @param num_tunneled_l7_bytes_received Number of tunneled Layer 7 bytes
1060 * received, excluding retransmits.
1061 * @param round_trip_time Round trip time.
1062 * @param time_to_first_byte Time in ms between connection
1063 * activation and first byte received.
1065 * @returns pointer to the newly manufactured ::MOBILE_GTP_PER_FLOW_METRICS.
1066 * If the structure is not used it must be released using
1067 * ::evel_free_mobile_gtp_flow_metrics.
1068 * @retval NULL Failed to create the event.
1069 *****************************************************************************/
1070 MOBILE_GTP_PER_FLOW_METRICS * evel_new_mobile_gtp_flow_metrics(
1071 double avg_bit_error_rate,
1072 double avg_packet_delay_variation,
1073 int avg_packet_latency,
1074 int avg_receive_throughput,
1075 int avg_transmit_throughput,
1076 int flow_activation_epoch,
1077 int flow_activation_microsec,
1078 int flow_deactivation_epoch,
1079 int flow_deactivation_microsec,
1080 time_t flow_deactivation_time,
1081 const char * const flow_status,
1082 int max_packet_delay_variation,
1083 int num_activation_failures,
1085 int num_bytes_received,
1086 int num_bytes_transmitted,
1087 int num_dropped_packets,
1088 int num_l7_bytes_received,
1089 int num_l7_bytes_transmitted,
1090 int num_lost_packets,
1091 int num_out_of_order_packets,
1092 int num_packet_errors,
1093 int num_packets_received_excl_retrans,
1094 int num_packets_received_incl_retrans,
1095 int num_packets_transmitted_incl_retrans,
1098 int num_tunneled_l7_bytes_received,
1099 int round_trip_time,
1100 int time_to_first_byte)
1102 MOBILE_GTP_PER_FLOW_METRICS * metrics = NULL;
1107 /***************************************************************************/
1108 /* Check preconditions. */
1109 /***************************************************************************/
1110 assert(avg_bit_error_rate >= 0.0);
1111 assert(avg_packet_delay_variation >= 0.0);
1112 assert(avg_packet_latency >= 0);
1113 assert(avg_receive_throughput >= 0);
1114 assert(avg_transmit_throughput >= 0);
1115 assert(flow_activation_epoch > 0);
1116 assert(flow_activation_microsec >= 0);
1117 assert(flow_deactivation_epoch > 0);
1118 assert(flow_deactivation_microsec >= 0);
1119 assert(flow_status != NULL);
1120 assert(max_packet_delay_variation >= 0);
1121 assert(num_activation_failures >= 0);
1122 assert(num_bit_errors >= 0);
1123 assert(num_bytes_received >= 0);
1124 assert(num_bytes_transmitted >= 0);
1125 assert(num_dropped_packets >= 0);
1126 assert(num_l7_bytes_received >= 0);
1127 assert(num_l7_bytes_transmitted >= 0);
1128 assert(num_lost_packets >= 0);
1129 assert(num_out_of_order_packets >= 0);
1130 assert(num_packet_errors >= 0);
1131 assert(num_packets_received_excl_retrans >= 0);
1132 assert(num_packets_received_incl_retrans >= 0);
1133 assert(num_packets_transmitted_incl_retrans >= 0);
1134 assert(num_retries >= 0);
1135 assert(num_timeouts >= 0);
1136 assert(num_tunneled_l7_bytes_received >= 0);
1137 assert(round_trip_time >= 0);
1138 assert(time_to_first_byte >= 0);
1140 /***************************************************************************/
1141 /* Allocate the Mobile Flow GTP Per Flow Metrics. */
1142 /***************************************************************************/
1143 metrics = malloc(sizeof(MOBILE_GTP_PER_FLOW_METRICS));
1144 if (metrics == NULL)
1146 log_error_state("Out of memory");
1149 memset(metrics, 0, sizeof(MOBILE_GTP_PER_FLOW_METRICS));
1150 EVEL_DEBUG("New Mobile Flow GTP Per Flow Metrics is at %lp", metrics);
1152 /***************************************************************************/
1153 /* Initialize the Mobile Flow GTP Per Flow Metrics fields. Optional */
1154 /* string values are uninitialized (NULL). */
1155 /***************************************************************************/
1156 metrics->avg_bit_error_rate = avg_bit_error_rate;
1157 metrics->avg_packet_delay_variation = avg_packet_delay_variation;
1158 metrics->avg_packet_latency = avg_packet_latency;
1159 metrics->avg_receive_throughput = avg_receive_throughput;
1160 metrics->avg_transmit_throughput = avg_transmit_throughput;
1161 metrics->flow_activation_epoch = flow_activation_epoch;
1162 metrics->flow_activation_microsec = flow_activation_microsec;
1163 metrics->flow_deactivation_epoch = flow_deactivation_epoch;
1164 metrics->flow_deactivation_microsec = flow_deactivation_microsec;
1165 metrics->flow_deactivation_time = flow_deactivation_time;
1166 metrics->flow_status = strdup(flow_status);
1167 metrics->max_packet_delay_variation = max_packet_delay_variation;
1168 metrics->num_activation_failures = num_activation_failures;
1169 metrics->num_bit_errors = num_bit_errors;
1170 metrics->num_bytes_received = num_bytes_received;
1171 metrics->num_bytes_transmitted = num_bytes_transmitted;
1172 metrics->num_dropped_packets = num_dropped_packets;
1173 metrics->num_l7_bytes_received = num_l7_bytes_received;
1174 metrics->num_l7_bytes_transmitted = num_l7_bytes_transmitted;
1175 metrics->num_lost_packets = num_lost_packets;
1176 metrics->num_out_of_order_packets = num_out_of_order_packets;
1177 metrics->num_packet_errors = num_packet_errors;
1178 metrics->num_packets_received_excl_retrans =
1179 num_packets_received_excl_retrans;
1180 metrics->num_packets_received_incl_retrans =
1181 num_packets_received_incl_retrans;
1182 metrics->num_packets_transmitted_incl_retrans =
1183 num_packets_transmitted_incl_retrans;
1184 metrics->num_retries = num_retries;
1185 metrics->num_timeouts = num_timeouts;
1186 metrics->num_tunneled_l7_bytes_received = num_tunneled_l7_bytes_received;
1187 metrics->round_trip_time = round_trip_time;
1188 metrics->time_to_first_byte = time_to_first_byte;
1189 for (ii = 0; ii < EVEL_TOS_SUPPORTED; ii++)
1191 evel_init_option_int(&metrics->ip_tos_counts[ii]);
1193 for (ii = 0; ii < EVEL_MAX_TCP_FLAGS; ii++)
1195 evel_init_option_int(&metrics->tcp_flag_counts[ii]);
1197 for (ii = 0; ii < EVEL_MAX_QCI_COS_TYPES; ii++)
1199 evel_init_option_int(&metrics->qci_cos_counts[ii]);
1201 evel_init_option_int(&metrics->dur_connection_failed_status);
1202 evel_init_option_int(&metrics->dur_tunnel_failed_status);
1203 evel_init_option_string(&metrics->flow_activated_by);
1204 evel_init_option_time(&metrics->flow_activation_time);
1205 evel_init_option_string(&metrics->flow_deactivated_by);
1206 evel_init_option_string(&metrics->gtp_connection_status);
1207 evel_init_option_string(&metrics->gtp_tunnel_status);
1208 evel_init_option_int(&metrics->large_packet_rtt);
1209 evel_init_option_double(&metrics->large_packet_threshold);
1210 evel_init_option_int(&metrics->max_receive_bit_rate);
1211 evel_init_option_int(&metrics->max_transmit_bit_rate);
1212 evel_init_option_int(&metrics->num_gtp_echo_failures);
1213 evel_init_option_int(&metrics->num_gtp_tunnel_errors);
1214 evel_init_option_int(&metrics->num_http_errors);
1221 /**************************************************************************//**
1222 * Set the Duration of Connection Failed Status property of the Mobile GTP Per
1225 * @note The property is treated as immutable: it is only valid to call
1226 * the setter once. However, we don't assert if the caller tries to
1227 * overwrite, just ignoring the update instead.
1229 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1230 * @param duration The Duration of Connection Failed Status to be set.
1231 *****************************************************************************/
1232 void evel_mobile_gtp_metrics_dur_con_fail_set(
1233 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1238 /***************************************************************************/
1239 /* Check preconditions. */
1240 /***************************************************************************/
1241 assert(metrics != NULL);
1242 assert(duration >= 0);
1244 evel_set_option_int(&metrics->dur_connection_failed_status,
1246 "Duration of Connection Failed Status");
1250 /**************************************************************************//**
1251 * Set the Duration of Tunnel Failed Status property of the Mobile GTP Per Flow
1254 * @note The property is treated as immutable: it is only valid to call
1255 * the setter once. However, we don't assert if the caller tries to
1256 * overwrite, just ignoring the update instead.
1258 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1259 * @param duration The Duration of Tunnel Failed Status to be set.
1260 *****************************************************************************/
1261 void evel_mobile_gtp_metrics_dur_tun_fail_set(
1262 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1267 /***************************************************************************/
1268 /* Check preconditions. */
1269 /***************************************************************************/
1270 assert(metrics != NULL);
1271 assert(duration >= 0);
1273 evel_set_option_int(&metrics->dur_tunnel_failed_status,
1275 "Duration of Tunnel Failed Status");
1279 /**************************************************************************//**
1280 * Set the Activated By property of the Mobile GTP Per Flow metrics.
1282 * @note The property is treated as immutable: it is only valid to call
1283 * the setter once. However, we don't assert if the caller tries to
1284 * overwrite, just ignoring the update instead.
1286 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1287 * @param act_by The Activated By to be set. ASCIIZ string. The caller
1288 * does not need to preserve the value once the function
1290 *****************************************************************************/
1291 void evel_mobile_gtp_metrics_act_by_set(MOBILE_GTP_PER_FLOW_METRICS * metrics,
1292 const char * const act_by)
1296 /***************************************************************************/
1297 /* Check preconditions. */
1298 /***************************************************************************/
1299 assert(metrics != NULL);
1300 assert(act_by != NULL);
1302 evel_set_option_string(&metrics->flow_activated_by,
1308 /**************************************************************************//**
1309 * Set the Activation Time property of the Mobile GTP Per Flow metrics.
1311 * @note The property is treated as immutable: it is only valid to call
1312 * the setter once. However, we don't assert if the caller tries to
1313 * overwrite, just ignoring the update instead.
1315 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1316 * @param act_time The Activation Time to be set. ASCIIZ string. The caller
1317 * does not need to preserve the value once the function
1319 *****************************************************************************/
1320 void evel_mobile_gtp_metrics_act_time_set(
1321 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1326 /***************************************************************************/
1327 /* Check preconditions. */
1328 /***************************************************************************/
1329 assert(metrics != NULL);
1330 assert(act_time > 0);
1332 evel_set_option_time(&metrics->flow_activation_time,
1338 /**************************************************************************//**
1339 * Set the Deactivated By property of the Mobile GTP Per Flow metrics.
1341 * @note The property is treated as immutable: it is only valid to call
1342 * the setter once. However, we don't assert if the caller tries to
1343 * overwrite, just ignoring the update instead.
1345 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1346 * @param deact_by The Deactivated By to be set. ASCIIZ string. The caller
1347 * does not need to preserve the value once the function
1349 *****************************************************************************/
1350 void evel_mobile_gtp_metrics_deact_by_set(
1351 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1352 const char * const deact_by)
1356 /***************************************************************************/
1357 /* Check preconditions. */
1358 /***************************************************************************/
1359 assert(metrics != NULL);
1360 assert(deact_by != NULL);
1362 evel_set_option_string(&metrics->flow_deactivated_by,
1368 /**************************************************************************//**
1369 * Set the GTP Connection Status property of the Mobile GTP Per Flow metrics.
1371 * @note The property is treated as immutable: it is only valid to call
1372 * the setter once. However, we don't assert if the caller tries to
1373 * overwrite, just ignoring the update instead.
1375 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1376 * @param status The GTP Connection Status to be set. ASCIIZ string. The
1377 * caller does not need to preserve the value once the
1379 *****************************************************************************/
1380 void evel_mobile_gtp_metrics_con_status_set(
1381 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1382 const char * const status)
1386 /***************************************************************************/
1387 /* Check preconditions. */
1388 /***************************************************************************/
1389 assert(metrics != NULL);
1390 assert(status != NULL);
1392 evel_set_option_string(&metrics->gtp_connection_status,
1394 "GTP Connection Status");
1398 /**************************************************************************//**
1399 * Set the GTP Tunnel Status property of the Mobile GTP Per Flow metrics.
1401 * @note The property is treated as immutable: it is only valid to call
1402 * the setter once. However, we don't assert if the caller tries to
1403 * overwrite, just ignoring the update instead.
1405 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1406 * @param status The GTP Tunnel Status to be set. ASCIIZ string. The
1407 * caller does not need to preserve the value once the
1409 *****************************************************************************/
1410 void evel_mobile_gtp_metrics_tun_status_set(
1411 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1412 const char * const status)
1416 /***************************************************************************/
1417 /* Check preconditions. */
1418 /***************************************************************************/
1419 assert(metrics != NULL);
1420 assert(status != NULL);
1422 evel_set_option_string(&metrics->gtp_tunnel_status,
1424 "GTP Tunnel Status");
1428 /**************************************************************************//**
1429 * Set an IP Type-of-Service count property of the Mobile GTP Per Flow metrics.
1431 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1432 * @param index The index of the IP Type-of-Service.
1433 * @param count The count.
1434 *****************************************************************************/
1435 void evel_mobile_gtp_metrics_iptos_set(MOBILE_GTP_PER_FLOW_METRICS * metrics,
1441 /***************************************************************************/
1442 /* Check preconditions. */
1443 /***************************************************************************/
1444 assert(metrics != NULL);
1446 assert(index < EVEL_TOS_SUPPORTED);
1448 assert(count <= 255);
1450 EVEL_DEBUG("IP Type-of-Service %d", index);
1451 evel_set_option_int(&metrics->ip_tos_counts[index],
1453 "IP Type-of-Service");
1457 /**************************************************************************//**
1458 * Set the Large Packet Round-Trip Time property of the Mobile GTP Per Flow
1461 * @note The property is treated as immutable: it is only valid to call
1462 * the setter once. However, we don't assert if the caller tries to
1463 * overwrite, just ignoring the update instead.
1465 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1466 * @param rtt The Large Packet Round-Trip Time to be set.
1467 *****************************************************************************/
1468 void evel_mobile_gtp_metrics_large_pkt_rtt_set(
1469 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1474 /***************************************************************************/
1475 /* Check preconditions. */
1476 /***************************************************************************/
1477 assert(metrics != NULL);
1480 evel_set_option_int(&metrics->large_packet_rtt,
1482 "Large Packet Round-Trip Time");
1486 /**************************************************************************//**
1487 * Set the Large Packet Threshold property of the Mobile GTP Per Flow Metrics.
1489 * @note The property is treated as immutable: it is only valid to call
1490 * the setter once. However, we don't assert if the caller tries to
1491 * overwrite, just ignoring the update instead.
1493 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1494 * @param threshold The Large Packet Threshold to be set.
1495 *****************************************************************************/
1496 void evel_mobile_gtp_metrics_large_pkt_thresh_set(
1497 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1502 /***************************************************************************/
1503 /* Check preconditions. */
1504 /***************************************************************************/
1505 assert(metrics != NULL);
1506 assert(threshold >= 0.0);
1508 evel_set_option_double(&metrics->large_packet_threshold,
1510 "Large Packet Threshold");
1514 /**************************************************************************//**
1515 * Set the Max Receive Bit Rate property of the Mobile GTP Per Flow Metrics.
1517 * @note The property is treated as immutable: it is only valid to call
1518 * the setter once. However, we don't assert if the caller tries to
1519 * overwrite, just ignoring the update instead.
1521 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1522 * @param rate The Max Receive Bit Rate to be set.
1523 *****************************************************************************/
1524 void evel_mobile_gtp_metrics_max_rcv_bit_rate_set(
1525 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1530 /***************************************************************************/
1531 /* Check preconditions. */
1532 /***************************************************************************/
1533 assert(metrics != NULL);
1536 evel_set_option_int(&metrics->max_receive_bit_rate,
1538 "Max Receive Bit Rate");
1542 /**************************************************************************//**
1543 * Set the Max Transmit Bit Rate property of the Mobile GTP Per Flow Metrics.
1545 * @note The property is treated as immutable: it is only valid to call
1546 * the setter once. However, we don't assert if the caller tries to
1547 * overwrite, just ignoring the update instead.
1549 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1550 * @param rate The Max Transmit Bit Rate to be set.
1551 *****************************************************************************/
1552 void evel_mobile_gtp_metrics_max_trx_bit_rate_set(
1553 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1558 /***************************************************************************/
1559 /* Check preconditions. */
1560 /***************************************************************************/
1561 assert(metrics != NULL);
1564 evel_set_option_int(&metrics->max_transmit_bit_rate,
1566 "Max Transmit Bit Rate");
1570 /**************************************************************************//**
1571 * Set the Number of GTP Echo Failures property of the Mobile GTP Per Flow
1574 * @note The property is treated as immutable: it is only valid to call
1575 * the setter once. However, we don't assert if the caller tries to
1576 * overwrite, just ignoring the update instead.
1578 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1579 * @param num The Number of GTP Echo Failures to be set.
1580 *****************************************************************************/
1581 void evel_mobile_gtp_metrics_num_echo_fail_set(
1582 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1587 /***************************************************************************/
1588 /* Check preconditions. */
1589 /***************************************************************************/
1590 assert(metrics != NULL);
1593 evel_set_option_int(&metrics->num_gtp_echo_failures,
1595 "Number of GTP Echo Failures");
1599 /**************************************************************************//**
1600 * Set the Number of GTP Tunnel Errors property of the Mobile GTP Per Flow
1603 * @note The property is treated as immutable: it is only valid to call
1604 * the setter once. However, we don't assert if the caller tries to
1605 * overwrite, just ignoring the update instead.
1607 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1608 * @param num The Number of GTP Tunnel Errors to be set.
1609 *****************************************************************************/
1610 void evel_mobile_gtp_metrics_num_tun_fail_set(
1611 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1616 /***************************************************************************/
1617 /* Check preconditions. */
1618 /***************************************************************************/
1619 assert(metrics != NULL);
1622 evel_set_option_int(&metrics->num_gtp_tunnel_errors,
1624 "Number of GTP Tunnel Errors");
1628 /**************************************************************************//**
1629 * Set the Number of HTTP Errors property of the Mobile GTP Per Flow Metrics.
1631 * @note The property is treated as immutable: it is only valid to call
1632 * the setter once. However, we don't assert if the caller tries to
1633 * overwrite, just ignoring the update instead.
1635 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1636 * @param num The Number of HTTP Errors to be set.
1637 *****************************************************************************/
1638 void evel_mobile_gtp_metrics_num_http_errors_set(
1639 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1644 /***************************************************************************/
1645 /* Check preconditions. */
1646 /***************************************************************************/
1647 assert(metrics != NULL);
1650 evel_set_option_int(&metrics->num_http_errors,
1652 "Number of HTTP Errors");
1656 /**************************************************************************//**
1657 * Add a TCP flag count to the metrics.
1659 * @note The property is treated as immutable: it is only valid to call
1660 * the setter once. However, we don't assert if the caller tries to
1661 * overwrite, just ignoring the update instead.
1663 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1664 * @param tcp_flag The TCP flag to be updated.
1665 * @param count The associated flag count, which must be nonzero.
1666 *****************************************************************************/
1667 void evel_mobile_gtp_metrics_tcp_flag_count_add(
1668 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1669 const EVEL_TCP_FLAGS tcp_flag,
1674 /***************************************************************************/
1675 /* Check preconditions. */
1676 /***************************************************************************/
1677 assert(metrics != NULL);
1678 assert(tcp_flag >= 0);
1679 assert(tcp_flag < EVEL_MAX_TCP_FLAGS);
1682 EVEL_DEBUG("TCP Flag: %d", tcp_flag);
1683 evel_set_option_int(&metrics->tcp_flag_counts[tcp_flag],
1689 /**************************************************************************//**
1690 * Add a QCI COS count to the metrics.
1692 * @note The property is treated as immutable: it is only valid to call
1693 * the setter once. However, we don't assert if the caller tries to
1694 * overwrite, just ignoring the update instead.
1696 * @param metrics Pointer to the Mobile GTP Per Flow Metrics.
1697 * @param qci_cos The QCI COS count to be updated.
1698 * @param count The associated QCI COS count.
1699 *****************************************************************************/
1700 void evel_mobile_gtp_metrics_qci_cos_count_add(
1701 MOBILE_GTP_PER_FLOW_METRICS * metrics,
1702 const EVEL_QCI_COS_TYPES qci_cos,
1707 /***************************************************************************/
1708 /* Check preconditions. */
1709 /***************************************************************************/
1710 assert(metrics != NULL);
1711 assert(qci_cos >= 0);
1712 assert(qci_cos < EVEL_MAX_QCI_COS_TYPES);
1715 EVEL_DEBUG("QCI COS: %d", qci_cos);
1716 evel_set_option_int(&metrics->qci_cos_counts[qci_cos],
1722 /**************************************************************************//**
1723 * Encode the Mobile Flow GTP Per Flow Metrics as a JSON object.
1725 * @param jbuf Pointer to working ::EVEL_JSON_BUFFER.
1726 * @param metrics Pointer to the ::EVENT_MOBILE_FLOW to encode.
1727 * @returns Number of bytes actually written.
1728 *****************************************************************************/
1729 void evel_json_encode_mobile_flow_gtp_flow_metrics(
1730 EVEL_JSON_BUFFER * jbuf,
1731 MOBILE_GTP_PER_FLOW_METRICS * metrics)
1735 bool found_tcp_flag;
1740 /***************************************************************************/
1741 /* Check preconditions. */
1742 /***************************************************************************/
1743 assert(jbuf != NULL);
1744 assert(metrics != NULL);
1746 evel_json_open_named_object(jbuf, "gtpPerFlowMetrics");
1748 /***************************************************************************/
1749 /* Mandatory parameters. */
1750 /***************************************************************************/
1751 evel_enc_kv_double(jbuf, "avgBitErrorRate", metrics->avg_bit_error_rate);
1753 jbuf, "avgPacketDelayVariation", metrics->avg_packet_delay_variation);
1754 evel_enc_kv_int(jbuf, "avgPacketLatency", metrics->avg_packet_latency);
1756 jbuf, "avgReceiveThroughput", metrics->avg_receive_throughput);
1758 jbuf, "avgTransmitThroughput", metrics->avg_transmit_throughput);
1759 evel_enc_kv_int(jbuf, "flowActivationEpoch", metrics->flow_activation_epoch);
1761 jbuf, "flowActivationMicrosec", metrics->flow_activation_microsec);
1763 jbuf, "flowDeactivationEpoch", metrics->flow_deactivation_epoch);
1765 jbuf, "flowDeactivationMicrosec", metrics->flow_deactivation_microsec);
1767 jbuf, "flowDeactivationTime", &metrics->flow_deactivation_time);
1768 evel_enc_kv_string(jbuf, "flowStatus", metrics->flow_status);
1770 jbuf, "maxPacketDelayVariation", metrics->max_packet_delay_variation);
1772 jbuf, "numActivationFailures", metrics->num_activation_failures);
1773 evel_enc_kv_int(jbuf, "numBitErrors", metrics->num_bit_errors);
1774 evel_enc_kv_int(jbuf, "numBytesReceived", metrics->num_bytes_received);
1775 evel_enc_kv_int(jbuf, "numBytesTransmitted", metrics->num_bytes_transmitted);
1776 evel_enc_kv_int(jbuf, "numDroppedPackets", metrics->num_dropped_packets);
1777 evel_enc_kv_int(jbuf, "numL7BytesReceived", metrics->num_l7_bytes_received);
1779 jbuf, "numL7BytesTransmitted", metrics->num_l7_bytes_transmitted);
1780 evel_enc_kv_int(jbuf, "numLostPackets", metrics->num_lost_packets);
1782 jbuf, "numOutOfOrderPackets", metrics->num_out_of_order_packets);
1783 evel_enc_kv_int(jbuf, "numPacketErrors", metrics->num_packet_errors);
1784 evel_enc_kv_int(jbuf,
1785 "numPacketsReceivedExclRetrans",
1786 metrics->num_packets_received_excl_retrans);
1787 evel_enc_kv_int(jbuf,
1788 "numPacketsReceivedInclRetrans",
1789 metrics->num_packets_received_incl_retrans);
1790 evel_enc_kv_int(jbuf,
1791 "numPacketsTransmittedInclRetrans",
1792 metrics->num_packets_transmitted_incl_retrans);
1793 evel_enc_kv_int(jbuf, "numRetries", metrics->num_retries);
1794 evel_enc_kv_int(jbuf, "numTimeouts", metrics->num_timeouts);
1795 evel_enc_kv_int(jbuf,
1796 "numTunneledL7BytesReceived",
1797 metrics->num_tunneled_l7_bytes_received);
1798 evel_enc_kv_int(jbuf, "roundTripTime", metrics->round_trip_time);
1799 evel_enc_kv_int(jbuf, "timeToFirstByte", metrics->time_to_first_byte);
1801 /***************************************************************************/
1802 /* Optional parameters. */
1803 /***************************************************************************/
1804 found_ip_tos = false;
1805 for (index = 0; index < EVEL_TOS_SUPPORTED; index++)
1807 if (metrics->ip_tos_counts[index].is_set)
1809 found_ip_tos = true;
1816 evel_json_open_named_list(jbuf, "ipTosCountList");
1817 for (index = 0; index < EVEL_TOS_SUPPORTED; index++)
1819 if (metrics->ip_tos_counts[index].is_set)
1821 evel_enc_list_item(jbuf,
1824 metrics->ip_tos_counts[index].value);
1827 evel_json_close_list(jbuf);
1832 evel_json_open_named_list(jbuf, "ipTosList");
1833 for (index = 0; index < EVEL_TOS_SUPPORTED; index++)
1835 if (metrics->ip_tos_counts[index].is_set)
1837 evel_enc_list_item(jbuf, "\"%d\"", index);
1840 evel_json_close_list(jbuf);
1843 /***************************************************************************/
1844 /* Make some compile-time assertions about EVEL_TCP_FLAGS. If you update */
1845 /* these, make sure you update evel_tcp_flag_strings to match the enum. */
1846 /***************************************************************************/
1847 EVEL_CT_ASSERT(EVEL_TCP_NS == 0);
1848 EVEL_CT_ASSERT(EVEL_TCP_CWR == 1);
1849 EVEL_CT_ASSERT(EVEL_TCP_ECE == 2);
1850 EVEL_CT_ASSERT(EVEL_TCP_URG == 3);
1851 EVEL_CT_ASSERT(EVEL_TCP_ACK == 4);
1852 EVEL_CT_ASSERT(EVEL_TCP_PSH == 5);
1853 EVEL_CT_ASSERT(EVEL_TCP_RST == 6);
1854 EVEL_CT_ASSERT(EVEL_TCP_SYN == 7);
1855 EVEL_CT_ASSERT(EVEL_TCP_FIN == 8);
1856 EVEL_CT_ASSERT(EVEL_MAX_TCP_FLAGS == 9);
1858 found_tcp_flag = false;
1859 for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++)
1861 if (metrics->tcp_flag_counts[index].is_set)
1863 found_tcp_flag = true;
1870 evel_json_open_named_list(jbuf, "tcpFlagList");
1871 for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++)
1873 if (metrics->tcp_flag_counts[index].is_set)
1875 evel_enc_list_item(jbuf,
1877 evel_tcp_flag_strings[index]);
1880 evel_json_close_list(jbuf);
1885 evel_json_open_named_list(jbuf, "tcpFlagCountList");
1886 for (index = 0; index < EVEL_MAX_TCP_FLAGS; index++)
1888 if (metrics->tcp_flag_counts[index].is_set)
1890 evel_enc_list_item(jbuf,
1892 evel_tcp_flag_strings[index],
1893 metrics->tcp_flag_counts[index].value);
1896 evel_json_close_list(jbuf);
1899 /***************************************************************************/
1900 /* Make some compile-time assertions about EVEL_QCI_COS_TYPES. If you */
1901 /* update these, make sure you update evel_qci_cos_strings to match the */
1903 /***************************************************************************/
1904 EVEL_CT_ASSERT(EVEL_QCI_COS_UMTS_CONVERSATIONAL ==0);
1905 EVEL_CT_ASSERT(EVEL_QCI_COS_UMTS_STREAMING == 1);
1906 EVEL_CT_ASSERT(EVEL_QCI_COS_UMTS_INTERACTIVE == 2);
1907 EVEL_CT_ASSERT(EVEL_QCI_COS_UMTS_BACKGROUND == 3);
1908 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_1 == 4);
1909 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_2 == 5);
1910 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_3 == 6);
1911 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_4 == 7);
1912 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_65 == 8);
1913 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_66 == 9);
1914 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_5 == 10);
1915 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_6 == 11);
1916 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_7 == 12);
1917 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_8 == 13);
1918 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_9 == 14);
1919 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_69 == 15);
1920 EVEL_CT_ASSERT(EVEL_QCI_COS_LTE_70 == 16);
1921 EVEL_CT_ASSERT(EVEL_MAX_QCI_COS_TYPES == 17);
1923 found_qci_cos = false;
1924 for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++)
1926 if (metrics->qci_cos_counts[index].is_set)
1928 found_qci_cos = true;
1935 evel_json_open_named_list(jbuf, "mobileQciCosList");
1936 for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++)
1938 if (metrics->qci_cos_counts[index].is_set)
1940 evel_enc_list_item(jbuf,
1942 evel_qci_cos_strings[index]);
1945 evel_json_close_list(jbuf);
1950 evel_json_open_named_list(jbuf, "mobileQciCosCountList");
1951 for (index = 0; index < EVEL_MAX_QCI_COS_TYPES; index++)
1953 if (metrics->qci_cos_counts[index].is_set)
1955 evel_enc_list_item(jbuf,
1957 evel_qci_cos_strings[index],
1958 metrics->qci_cos_counts[index].value);
1961 evel_json_close_list(jbuf);
1964 evel_enc_kv_opt_int(
1965 jbuf, "durConnectionFailedStatus", &metrics->dur_connection_failed_status);
1966 evel_enc_kv_opt_int(
1967 jbuf, "durTunnelFailedStatus", &metrics->dur_tunnel_failed_status);
1968 evel_enc_kv_opt_string(jbuf, "flowActivatedBy", &metrics->flow_activated_by);
1969 evel_enc_kv_opt_time(
1970 jbuf, "flowActivationTime", &metrics->flow_activation_time);
1971 evel_enc_kv_opt_string(
1972 jbuf, "flowDeactivatedBy", &metrics->flow_deactivated_by);
1973 evel_enc_kv_opt_string(
1974 jbuf, "gtpConnectionStatus", &metrics->gtp_connection_status);
1975 evel_enc_kv_opt_string(jbuf, "gtpTunnelStatus", &metrics->gtp_tunnel_status);
1976 evel_enc_kv_opt_int(jbuf, "largePacketRtt", &metrics->large_packet_rtt);
1977 evel_enc_kv_opt_double(
1978 jbuf, "largePacketThreshold", &metrics->large_packet_threshold);
1979 evel_enc_kv_opt_int(
1980 jbuf, "maxReceiveBitRate", &metrics->max_receive_bit_rate);
1981 evel_enc_kv_opt_int(
1982 jbuf, "maxTransmitBitRate", &metrics->max_transmit_bit_rate);
1983 evel_enc_kv_opt_int(
1984 jbuf, "numGtpEchoFailures", &metrics->num_gtp_echo_failures);
1985 evel_enc_kv_opt_int(
1986 jbuf, "numGtpTunnelErrors", &metrics->num_gtp_tunnel_errors);
1987 evel_enc_kv_opt_int(jbuf, "numHttpErrors", &metrics->num_http_errors);
1989 evel_json_close_object(jbuf);
1994 /**************************************************************************//**
1995 * Free a Mobile GTP Per Flow Metrics.
1997 * Free off the Mobile GTP Per Flow Metrics supplied. Will free all the
1998 * contained allocated memory.
2000 * @note It does not free the Mobile GTP Per Flow Metrics itself, since that
2001 * may be part of a larger structure.
2002 *****************************************************************************/
2003 void evel_free_mobile_gtp_flow_metrics(MOBILE_GTP_PER_FLOW_METRICS * metrics)
2007 /***************************************************************************/
2008 /* Check preconditions. */
2009 /***************************************************************************/
2010 assert(metrics != NULL);
2012 /***************************************************************************/
2013 /* Free all internal strings. */
2014 /***************************************************************************/
2015 free(metrics->flow_status);
2017 evel_free_option_string(&metrics->flow_activated_by);
2018 evel_free_option_string(&metrics->flow_deactivated_by);
2019 evel_free_option_string(&metrics->gtp_connection_status);
2020 evel_free_option_string(&metrics->gtp_tunnel_status);