1 /*
2 * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3 * Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
4 *
5 * Version: MPL 1.1
6 *
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
11 *
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
15 * License.
16 *
17 * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
18 *
19 * The Initial Developer of the Original Code is
20 * Anthony Minessale II <anthm@freeswitch.org>
21 * Portions created by the Initial Developer are Copyright (C)
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Based on mod_skel by
25 * Anthony Minessale II <anthm@freeswitch.org>
26 *
27 * Contributor(s):
28 *
29 * Daniel Bryars <danb@aeriandi.com>
30 * Tim Brown <tim.brown@aeriandi.com>
31 * Anthony Minessale II <anthm@freeswitch.org>
32 * William King <william.king@quentustech.com>
33 * Mike Jerris <mike@jerris.com>
34 *
35 * kazoo.c -- Sends FreeSWITCH events to an AMQP broker
36 *
37 */
38 
39 #ifndef KAZOO_FIELDS_H
40 #define KAZOO_FIELDS_H
41 
42 #include <switch.h>
43 
44 #define MAX_LIST_FIELDS 25
45 
46 typedef struct kazoo_log_levels kazoo_loglevels_t;
47 typedef kazoo_loglevels_t *kazoo_loglevels_ptr;
48 
49 struct kazoo_log_levels
50 {
51 	switch_log_level_t success_log_level;
52 	switch_log_level_t failed_log_level;
53 	switch_log_level_t warn_log_level;
54 	switch_log_level_t info_log_level;
55 	switch_log_level_t time_log_level;
56 	switch_log_level_t filtered_event_log_level;
57 	switch_log_level_t filtered_field_log_level;
58 	switch_log_level_t trace_log_level;
59 	switch_log_level_t debug_log_level;
60 	switch_log_level_t error_log_level;
61 	switch_log_level_t hashing_log_level;
62 
63 };
64 
65 typedef struct kazoo_logging kazoo_logging_t;
66 typedef kazoo_logging_t *kazoo_logging_ptr;
67 
68 struct kazoo_logging
69 {
70 	kazoo_loglevels_ptr levels;
71 	const char *profile_name;
72 	const char *event_name;
73 };
74 
75 typedef struct kazoo_list_s {
76   char *value[MAX_LIST_FIELDS];
77   int size;
78 } kazoo_list_t;
79 
80 typedef enum {
81 	FILTER_COMPARE_REGEX,
82 	FILTER_COMPARE_LIST,
83 	FILTER_COMPARE_VALUE,
84 	FILTER_COMPARE_PREFIX,
85 	FILTER_COMPARE_EXISTS,
86 	FILTER_COMPARE_FIELD
87 
88 } kazoo_filter_compare_type;
89 
90 typedef enum {
91 	FILTER_EXCLUDE,
92 	FILTER_INCLUDE,
93 	FILTER_ENSURE
94 } kazoo_filter_type;
95 
96 typedef struct kazoo_filter_t {
97 	kazoo_filter_type type;
98 	kazoo_filter_compare_type compare;
99 	char* name;
100 	char* value;
101 	kazoo_list_t list;
102 	struct kazoo_filter_t* next;
103 } kazoo_filter, *kazoo_filter_ptr;
104 
105 
106 typedef enum {
107 	JSON_NONE,
108 	JSON_STRING,
109 	JSON_NUMBER,
110 	JSON_BOOLEAN,
111 	JSON_OBJECT,
112 	JSON_RAW
113 } kazoo_json_field_type;
114 
115 typedef enum {
116 	FIELD_NONE,
117 	FIELD_COPY,
118 	FIELD_STATIC,
119 	FIELD_FIRST_OF,
120 	FIELD_EXPAND,
121 	FIELD_PREFIX,
122 	FIELD_OBJECT,
123 	FIELD_GROUP,
124 	FIELD_REFERENCE
125 
126 } kazoo_field_type;
127 
128 typedef struct kazoo_field_t kazoo_field;
129 typedef kazoo_field *kazoo_field_ptr;
130 
131 typedef struct kazoo_fields_t kazoo_fields;
132 typedef kazoo_fields *kazoo_fields_ptr;
133 
134 typedef struct kazoo_definition_t kazoo_definition;
135 typedef kazoo_definition *kazoo_definition_ptr;
136 
137 struct kazoo_field_t {
138 	char* name;
139 	char* value;
140 	char* as;
141 	kazoo_list_t list;
142 	switch_bool_t exclude_prefix;
143 	kazoo_field_type in_type;
144 	kazoo_json_field_type out_type;
145 	int out_type_as_array;
146 	kazoo_filter_ptr filter;
147 
148 	kazoo_definition_ptr ref;
149 	kazoo_field_ptr next;
150 	kazoo_fields_ptr children;
151 };
152 
153 struct kazoo_fields_t {
154 	kazoo_field_ptr head;
155 	int verbose;
156 };
157 
158 
159 struct kazoo_definition_t {
160 	char* name;
161 	kazoo_field_ptr head;
162 	kazoo_filter_ptr filter;
163 };
164 
165 struct kazoo_event {
166 	kazoo_event_profile_ptr profile;
167 	char *name;
168 	kazoo_fields_ptr fields;
169 	kazoo_filter_ptr filter;
170 	kazoo_loglevels_ptr logging;
171 
172 	kazoo_event_t* next;
173 };
174 
175 struct kazoo_event_profile {
176 	char *name;
177 	kazoo_config_ptr root;
178 	switch_bool_t running;
179 	switch_memory_pool_t *pool;
180 	kazoo_filter_ptr filter;
181 	kazoo_fields_ptr fields;
182 	kazoo_event_ptr events;
183 
184 	kazoo_loglevels_ptr logging;
185 };
186 
187 struct kazoo_fetch_profile {
188 	char *name;
189 	kazoo_config_ptr root;
190 	switch_bool_t running;
191 	switch_memory_pool_t *pool;
192 	kazoo_fields_ptr fields;
193 	int fetch_timeout;
194 	switch_mutex_t *fetch_reply_mutex;
195 	switch_hash_t *fetch_reply_hash;
196 	switch_xml_binding_t *fetch_binding;
197 	switch_xml_section_t section;
198 
199 	kazoo_loglevels_ptr logging;
200 };
201 
202 #endif /* KAZOO_FIELDS_H */
203 
204