1 /**************************************************************************//**
3 * Implementation of EVEL functions relating to Signaling.
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 Signaling event.
44 * @note The mandatory fields on the Signaling 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_SIGNALING. If the event
51 * is not used (i.e. posted) it must be released using
52 * ::evel_free_signaling.
53 * @retval NULL Failed to create the event.
54 *****************************************************************************/
55 EVENT_SIGNALING * evel_new_signaling(const char * const vendor_id,
56 const char * const event_id)
58 EVENT_SIGNALING * event = NULL;
62 /***************************************************************************/
63 /* Check preconditions. */
64 /***************************************************************************/
65 assert(vendor_id != NULL);
66 assert(event_id != NULL);
68 /***************************************************************************/
69 /* Allocate the Signaling event. */
70 /***************************************************************************/
71 event = malloc(sizeof(EVENT_SIGNALING));
74 log_error_state("Out of memory");
77 memset(event, 0, sizeof(EVENT_SIGNALING));
78 EVEL_DEBUG("New Signaling event is at %lp", event);
80 /***************************************************************************/
81 /* Initialize the header & the Signaling fields. */
82 /***************************************************************************/
83 evel_init_header(&event->header);
84 event->header.event_domain = EVEL_DOMAIN_SIGNALING;
85 event->major_version = EVEL_SIGNALING_MAJOR_VERSION;
86 event->minor_version = EVEL_SIGNALING_MINOR_VERSION;
87 evel_init_event_instance_id(&event->instance_id, vendor_id, event_id);
88 evel_init_option_string(&event->correlator);
89 evel_init_option_string(&event->local_ip_address);
90 evel_init_option_string(&event->local_port);
91 evel_init_option_string(&event->remote_ip_address);
92 evel_init_option_string(&event->remote_port);
93 evel_init_option_string(&event->compressed_sip);
94 evel_init_option_string(&event->summary_sip);
102 /**************************************************************************//**
103 * Set the Event Type property of the Signaling event.
105 * @note The property is treated as immutable: it is only valid to call
106 * the setter once. However, we don't assert if the caller tries to
107 * overwrite, just ignoring the update instead.
109 * @param event Pointer to the Signaling event.
110 * @param type The Event Type to be set. ASCIIZ string. The caller
111 * does not need to preserve the value once the function
113 *****************************************************************************/
114 void evel_signaling_type_set(EVENT_SIGNALING * const event,
115 const char * const type)
119 /***************************************************************************/
120 /* Check preconditions and call evel_header_type_set. */
121 /***************************************************************************/
122 assert(event != NULL);
123 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
124 evel_header_type_set(&event->header, type);
129 /**************************************************************************//**
130 * Set the Local Ip Address property of the Signaling event.
132 * @note The property is treated as immutable: it is only valid to call
133 * the setter once. However, we don't assert if the caller tries to
134 * overwrite, just ignoring the update instead.
136 * @param event Pointer to the Signaling event.
137 * @param local_ip_address
138 * The Local Ip Address to be set. ASCIIZ string. The
139 * caller does not need to preserve the value once the
141 *****************************************************************************/
142 void evel_signaling_local_ip_address_set(EVENT_SIGNALING * const event,
143 const char * const local_ip_address)
147 /***************************************************************************/
148 /* Check preconditions. */
149 /***************************************************************************/
150 assert(event != NULL);
151 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
152 assert(local_ip_address != NULL);
154 evel_set_option_string(&event->local_ip_address,
161 /**************************************************************************//**
162 * Set the Local Port property of the Signaling event.
164 * @note The property is treated as immutable: it is only valid to call
165 * the setter once. However, we don't assert if the caller tries to
166 * overwrite, just ignoring the update instead.
168 * @param event Pointer to the Signaling event.
169 * @param local_port The Local Port to be set. ASCIIZ string. The caller
170 * does not need to preserve the value once the function
172 *****************************************************************************/
173 void evel_signaling_local_port_set(EVENT_SIGNALING * const event,
174 const char * const local_port)
178 /***************************************************************************/
179 /* Check preconditions. */
180 /***************************************************************************/
181 assert(event != NULL);
182 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
183 assert(local_port != NULL);
185 evel_set_option_string(&event->local_port,
192 /**************************************************************************//**
193 * Set the Remote Ip Address property of the Signaling 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 Signaling event.
200 * @param remote_ip_address
201 * The Remote Ip Address to be set. ASCIIZ string. The
202 * caller does not need to preserve the value once the
204 *****************************************************************************/
205 void evel_signaling_remote_ip_address_set(EVENT_SIGNALING * const event,
206 const char * const remote_ip_address)
210 /***************************************************************************/
211 /* Check preconditions. */
212 /***************************************************************************/
213 assert(event != NULL);
214 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
215 assert(remote_ip_address != NULL);
217 evel_set_option_string(&event->remote_ip_address,
219 "Remote Ip Address");
224 /**************************************************************************//**
225 * Set the Remote Port property of the Signaling event.
227 * @note The property is treated as immutable: it is only valid to call
228 * the setter once. However, we don't assert if the caller tries to
229 * overwrite, just ignoring the update instead.
231 * @param event Pointer to the Signaling event.
232 * @param remote_port The Remote Port to be set. ASCIIZ string. The caller
233 * does not need to preserve the value once the function
235 *****************************************************************************/
236 void evel_signaling_remote_port_set(EVENT_SIGNALING * const event,
237 const char * const remote_port)
241 /***************************************************************************/
242 /* Check preconditions. */
243 /***************************************************************************/
244 assert(event != NULL);
245 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
246 assert(remote_port != NULL);
248 evel_set_option_string(&event->remote_port,
255 /**************************************************************************//**
256 * Set the Compressed SIP property of the Signaling event.
258 * @note The property is treated as immutable: it is only valid to call
259 * the setter once. However, we don't assert if the caller tries to
260 * overwrite, just ignoring the update instead.
262 * @param event Pointer to the Signaling event.
263 * @param compressed_sip
264 * The Compressed SIP to be set. ASCIIZ string. The caller
265 * does not need to preserve the value once the function
267 *****************************************************************************/
268 void evel_signaling_compressed_sip_set(EVENT_SIGNALING * const event,
269 const char * const compressed_sip)
273 /***************************************************************************/
274 /* Check preconditions. */
275 /***************************************************************************/
276 assert(event != NULL);
277 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
278 assert(compressed_sip != NULL);
280 evel_set_option_string(&event->compressed_sip,
287 /**************************************************************************//**
288 * Set the Summary SIP property of the Signaling event.
290 * @note The property is treated as immutable: it is only valid to call
291 * the setter once. However, we don't assert if the caller tries to
292 * overwrite, just ignoring the update instead.
294 * @param event Pointer to the Signaling event.
295 * @param summary_sip The Summary SIP to be set. ASCIIZ string. The caller
296 * does not need to preserve the value once the function
298 *****************************************************************************/
299 void evel_signaling_summary_sip_set(EVENT_SIGNALING * const event,
300 const char * const summary_sip)
304 /***************************************************************************/
305 /* Check preconditions. */
306 /***************************************************************************/
307 assert(event != NULL);
308 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
309 assert(summary_sip != NULL);
311 evel_set_option_string(&event->summary_sip,
318 /**************************************************************************//**
319 * Set the Product Id property of the Signaling event.
321 * @note The property is treated as immutable: it is only valid to call
322 * the setter once. However, we don't assert if the caller tries to
323 * overwrite, just ignoring the update instead.
325 * @param event Pointer to the Signaling event.
326 * @param product_id The vendor product id to be set. ASCIIZ string. The
327 * caller does not need to preserve the value once the
329 *****************************************************************************/
330 void evel_signaling_product_id_set(EVENT_SIGNALING * const event,
331 const char * const product_id)
335 /***************************************************************************/
336 /* Check preconditions and call evel_header_type_set. */
337 /***************************************************************************/
338 assert(event != NULL);
339 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
340 evel_set_option_string(&event->instance_id.product_id,
347 /**************************************************************************//**
348 * Set the Subsystem Id property of the Signaling event.
350 * @note The property is treated as immutable: it is only valid to call
351 * the setter once. However, we don't assert if the caller tries to
352 * overwrite, just ignoring the update instead.
354 * @param event Pointer to the Signaling event.
355 * @param subsystem_id The vendor subsystem id to be set. ASCIIZ string. The
356 * caller does not need to preserve the value once the
358 *****************************************************************************/
359 void evel_signaling_subsystem_id_set(EVENT_SIGNALING * const event,
360 const char * const subsystem_id)
364 /***************************************************************************/
365 /* Check preconditions and call evel_header_type_set. */
366 /***************************************************************************/
367 assert(event != NULL);
368 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
369 evel_set_option_string(&event->instance_id.subsystem_id,
376 /**************************************************************************//**
377 * Set the Friendly Name property of the Signaling event.
379 * @note The property is treated as immutable: it is only valid to call
380 * the setter once. However, we don't assert if the caller tries to
381 * overwrite, just ignoring the update instead.
383 * @param event Pointer to the Signaling event.
384 * @param friendly_name The vendor friendly name to be set. ASCIIZ string. The
385 * caller does not need to preserve the value once the
387 *****************************************************************************/
388 void evel_signaling_friendly_name_set(EVENT_SIGNALING * const event,
389 const char * const friendly_name)
393 /***************************************************************************/
394 /* Check preconditions and call evel_header_type_set. */
395 /***************************************************************************/
396 assert(event != NULL);
397 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
398 evel_set_option_string(&event->instance_id.event_friendly_name,
405 /**************************************************************************//**
406 * Set the Correlator property of the Signaling event.
408 * @note The property is treated as immutable: it is only valid to call
409 * the setter once. However, we don't assert if the caller tries to
410 * overwrite, just ignoring the update instead.
412 * @param event Pointer to the Signaling event.
413 * @param correlator The correlator to be set. ASCIIZ string. The caller
414 * does not need to preserve the value once the function
416 *****************************************************************************/
417 void evel_signaling_correlator_set(EVENT_SIGNALING * const event,
418 const char * const correlator)
422 /***************************************************************************/
423 /* Check preconditions and call evel_header_type_set. */
424 /***************************************************************************/
425 assert(event != NULL);
426 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
427 evel_set_option_string(&event->correlator,
434 /**************************************************************************//**
435 * Encode the Signaling in JSON according to AT&T's schema for the
438 * @param jbuf Pointer to the ::EVEL_JSON_BUFFER to encode into.
439 * @param event Pointer to the ::EVENT_HEADER to encode.
440 *****************************************************************************/
441 void evel_json_encode_signaling(EVEL_JSON_BUFFER * const jbuf,
442 EVENT_SIGNALING * const event)
446 /***************************************************************************/
447 /* Check preconditions. */
448 /***************************************************************************/
449 assert(event != NULL);
450 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
452 evel_json_encode_header(jbuf, &event->header);
453 evel_json_open_named_object(jbuf, "signalingFields");
455 /***************************************************************************/
456 /* Mandatory fields */
457 /***************************************************************************/
458 evel_json_encode_instance_id(jbuf, &event->instance_id);
459 evel_enc_version(jbuf,
460 "signalingFieldsVersion",
461 event->major_version,
462 event->minor_version);
464 /***************************************************************************/
465 /* Optional fields */
466 /***************************************************************************/
467 evel_enc_kv_opt_string(jbuf, "correlator", &event->correlator);
468 evel_enc_kv_opt_string(jbuf, "localIpAddress", &event->local_ip_address);
469 evel_enc_kv_opt_string(jbuf, "localPort", &event->local_port);
470 evel_enc_kv_opt_string(jbuf, "remoteIpAddress", &event->remote_ip_address);
471 evel_enc_kv_opt_string(jbuf, "remotePort", &event->remote_port);
472 evel_enc_kv_opt_string(jbuf, "compressedSip", &event->compressed_sip);
473 evel_enc_kv_opt_string(jbuf, "summarySip", &event->summary_sip);
474 evel_json_close_object(jbuf);
479 /**************************************************************************//**
480 * Free a Signaling event.
482 * Free off the event supplied. Will free all the contained allocated memory.
484 * @note It does not free the event itself, since that may be part of a larger
486 *****************************************************************************/
487 void evel_free_signaling(EVENT_SIGNALING * const event)
491 /***************************************************************************/
492 /* Check preconditions. As an internal API we don't allow freeing NULL */
493 /* events as we do on the public API. */
494 /***************************************************************************/
495 assert(event != NULL);
496 assert(event->header.event_domain == EVEL_DOMAIN_SIGNALING);
498 evel_free_header(&event->header);
499 evel_free_event_instance_id(&event->instance_id);
500 evel_free_option_string(&event->correlator);
501 evel_free_option_string(&event->local_ip_address);
502 evel_free_option_string(&event->local_port);
503 evel_free_option_string(&event->remote_ip_address);
504 evel_free_option_string(&event->remote_port);
505 evel_free_option_string(&event->compressed_sip);
506 evel_free_option_string(&event->summary_sip);