1 /*
2  * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
3  * Copyright (C) 2010, Mathieu Parent <math.parent@gmail.com>
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  * Mathieu Parent <math.parent@gmail.com>
21  * Portions created by the Initial Developer are Copyright (C)
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *
26  * Mathieu Parent <math.parent@gmail.com>
27  *
28  *
29  * skinny_tables.h -- Skinny Call Control Protocol (SCCP) Endpoint Module
30  *
31  */
32 #ifndef _SKINNY_TABLES_H
33 #define _SKINNY_TABLES_H
34 
35 /*****************************************************************************/
36 /* SKINNY TABLES */
37 /*****************************************************************************/
38 struct skinny_table {
39 	uint32_t id;
40 	const char *name;
41 };
42 
43 #define SKINNY_DECLARE_ID2STR(func, TABLE, DEFAULT_STR) \
44 	const char *func(uint32_t id) \
45 { \
46 	const char *str = DEFAULT_STR; \
47 	uint8_t x; \
48 	\
49 	for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\
50 		if (TABLE[x].id == id) {\
51 			str = TABLE[x].name;\
52 			break;\
53 		}\
54 	}\
55 	\
56 	return str;\
57 }
58 
59 #define SKINNY_DECLARE_STR2ID(func, TABLE, DEFAULT_ID) \
60 	uint32_t func(const char *str)\
61 {\
62 	uint32_t id = (uint32_t) DEFAULT_ID;\
63 	\
64 	if (*str > 47 && *str < 58) {\
65 		id = atoi(str);\
66 	} else {\
67 		uint8_t x;\
68 		for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1 && TABLE[x].name; x++) {\
69 			if (!strcasecmp(TABLE[x].name, str)) {\
70 				id = TABLE[x].id;\
71 				break;\
72 			}\
73 		}\
74 	}\
75 	return id;\
76 }
77 
78 #define SKINNY_DECLARE_PUSH_MATCH(TABLE) \
79 	switch_console_callback_match_t *my_matches = NULL;\
80 uint8_t x;\
81 for (x = 0; x < (sizeof(TABLE) / sizeof(struct skinny_table)) - 1; x++) {\
82 	switch_console_push_match(&my_matches, TABLE[x].name);\
83 }\
84 if (my_matches) {\
85 	*matches = my_matches;\
86 	status = SWITCH_STATUS_SUCCESS;\
87 }
88 
89 
90 extern struct skinny_table SKINNY_MESSAGE_TYPES[76];
91 const char *skinny_message_type2str(uint32_t id);
92 uint32_t skinny_str2message_type(const char *str);
93 #define SKINNY_PUSH_MESSAGE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_MESSAGE_TYPES)
94 
95 extern struct skinny_table SKINNY_DEVICE_TYPES[75];
96 const char *skinny_device_type2str(uint32_t id);
97 uint32_t skinny_str2device_type(const char *str);
98 #define SKINNY_PUSH_DEVICE_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_DEVICE_TYPES)
99 
100 enum skinny_tone {
101 	SKINNY_TONE_SILENCE = 0x00,
102 	SKINNY_TONE_DIALTONE = 0x21,
103 	SKINNY_TONE_BUSYTONE = 0x23,
104 	SKINNY_TONE_ALERT = 0x24,
105 	SKINNY_TONE_REORDER = 0x25,
106 	SKINNY_TONE_CALLWAITTONE = 0x2D,
107 	SKINNY_TONE_NOTONE = 0x7F,
108 };
109 extern struct skinny_table SKINNY_TONES[9];
110 const char *skinny_tone2str(uint32_t id);
111 uint32_t skinny_str2tone(const char *str);
112 #define SKINNY_PUSH_TONES SKINNY_DECLARE_PUSH_MATCH(SKINNY_TONES)
113 
114 enum skinny_ring_type {
115 	SKINNY_RING_OFF = 1,
116 	SKINNY_RING_INSIDE = 2,
117 	SKINNY_RING_OUTSIDE = 3,
118 	SKINNY_RING_FEATURE = 4,
119 	SKINNY_RING_FLASHONLY = 5
120 };
121 extern struct skinny_table SKINNY_RING_TYPES[6];
122 const char *skinny_ring_type2str(uint32_t id);
123 uint32_t skinny_str2ring_type(const char *str);
124 #define SKINNY_PUSH_RING_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_RING_TYPES)
125 
126 enum skinny_ring_mode {
127 	SKINNY_RING_FOREVER = 1,
128 	SKINNY_RING_ONCE = 2,
129 };
130 extern struct skinny_table SKINNY_RING_MODES[3];
131 const char *skinny_ring_mode2str(uint32_t id);
132 uint32_t skinny_str2ring_mode(const char *str);
133 #define SKINNY_PUSH_RING_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_RING_MODES)
134 
135 
136 enum skinny_lamp_mode {
137 	SKINNY_LAMP_OFF = 1,
138 	SKINNY_LAMP_ON = 2,
139 	SKINNY_LAMP_WINK = 3,
140 	SKINNY_LAMP_FLASH = 4,
141 	SKINNY_LAMP_BLINK = 5,
142 };
143 extern struct skinny_table SKINNY_LAMP_MODES[6];
144 const char *skinny_lamp_mode2str(uint32_t id);
145 uint32_t skinny_str2lamp_mode(const char *str);
146 #define SKINNY_PUSH_LAMP_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_LAMP_MODES)
147 
148 enum skinny_speaker_mode {
149 	SKINNY_SPEAKER_ON = 1,
150 	SKINNY_SPEAKER_OFF = 2,
151 };
152 extern struct skinny_table SKINNY_SPEAKER_MODES[3];
153 const char *skinny_speaker_mode2str(uint32_t id);
154 uint32_t skinny_str2speaker_mode(const char *str);
155 #define SKINNY_PUSH_SPEAKER_MODES SKINNY_DECLARE_PUSH_MATCH(SKINNY_SPEAKER_MODES)
156 
157 enum skinny_call_type {
158 	SKINNY_INBOUND_CALL = 1,
159 	SKINNY_OUTBOUND_CALL = 2,
160 	SKINNY_FORWARD_CALL = 3,
161 };
162 
163 enum skinny_button_definition {
164 	SKINNY_BUTTON_UNKNOWN = 0x00,
165 	SKINNY_BUTTON_LAST_NUMBER_REDIAL = 0x01,
166 	SKINNY_BUTTON_SPEED_DIAL = 0x02,
167 	SKINNY_BUTTON_HOLD = 0x03,
168 	SKINNY_BUTTON_TRANSFER = 0x04,
169 	SKINNY_BUTTON_FORWARDALL = 0x05,
170 	SKINNY_BUTTON_LINE = 0x09,
171 	SKINNY_BUTTON_VOICEMAIL = 0x0F,
172 	SKINNY_BUTTON_PRIVACY = 0x13,
173 	SKINNY_BUTTON_SERVICE_URL = 0x14,
174 	SKINNY_BUTTON_UNDEFINED = 0xFF,
175 };
176 extern struct skinny_table SKINNY_BUTTONS[12];
177 const char *skinny_button2str(uint32_t id);
178 uint32_t skinny_str2button(const char *str);
179 #define SKINNY_PUSH_STIMULI SKINNY_DECLARE_PUSH_MATCH(SKINNY_BUTTONS)
180 
181 enum skinny_soft_key_event {
182 	SOFTKEY_REDIAL = 0x01,
183 	SOFTKEY_NEWCALL = 0x02,
184 	SOFTKEY_HOLD = 0x03,
185 	SOFTKEY_TRANSFER = 0x04,
186 	SOFTKEY_CFWDALL = 0x05,
187 	SOFTKEY_CFWDBUSY = 0x06,
188 	SOFTKEY_CFWDNOANSWER = 0x07,
189 	SOFTKEY_BACKSPACE = 0x08,
190 	SOFTKEY_ENDCALL = 0x09,
191 	SOFTKEY_RESUME = 0x0A,
192 	SOFTKEY_ANSWER = 0x0B,
193 	SOFTKEY_INFO = 0x0C,
194 	SOFTKEY_CONF = 0x0D,
195 	SOFTKEY_PARK = 0x0E,
196 	SOFTKEY_JOIN = 0x0F,
197 	SOFTKEY_MEETME = 0x10,
198 	SOFTKEY_CALLPICKUP = 0x11,
199 	SOFTKEY_GRPCALLPICKUP = 0x12,
200 	SOFTKEY_DND = 0x13,
201 	SOFTKEY_IDIVERT = 0x14,
202 };
203 extern struct skinny_table SKINNY_SOFT_KEY_EVENTS[21];
204 const char *skinny_soft_key_event2str(uint32_t id);
205 uint32_t skinny_str2soft_key_event(const char *str);
206 #define SKINNY_PUSH_SOFT_KEY_EVENTS SKINNY_DECLARE_PUSH_MATCH(SOFT_KEY_EVENTS)
207 
208 enum skinny_key_set {
209 	SKINNY_KEY_SET_ON_HOOK = 0,
210 	SKINNY_KEY_SET_CONNECTED = 1,
211 	SKINNY_KEY_SET_ON_HOLD = 2,
212 	SKINNY_KEY_SET_RING_IN = 3,
213 	SKINNY_KEY_SET_OFF_HOOK = 4,
214 	SKINNY_KEY_SET_CONNECTED_WITH_TRANSFER = 5,
215 	SKINNY_KEY_SET_DIGITS_AFTER_DIALING_FIRST_DIGIT = 6,
216 	SKINNY_KEY_SET_CONNECTED_WITH_CONFERENCE = 7,
217 	SKINNY_KEY_SET_RING_OUT = 8,
218 	SKINNY_KEY_SET_OFF_HOOK_WITH_FEATURES = 9,
219 	SKINNY_KEY_SET_IN_USE_HINT = 10,
220 };
221 extern struct skinny_table SKINNY_KEY_SETS[12];
222 const char *skinny_soft_key_set2str(uint32_t id);
223 uint32_t skinny_str2soft_key_set(const char *str);
224 #define SKINNY_PUSH_SOFT_KEY_SETS SKINNY_DECLARE_PUSH_MATCH(SKINNY_KEY_SETS)
225 
226 
227 enum skinny_call_state {
228 	SKINNY_OFF_HOOK = 1,
229 	SKINNY_ON_HOOK = 2,
230 	SKINNY_RING_OUT = 3,
231 	SKINNY_RING_IN = 4,
232 	SKINNY_CONNECTED = 5,
233 	SKINNY_BUSY = 6,
234 	SKINNY_LINE_IN_USE = 7,
235 	SKINNY_HOLD = 8,
236 	SKINNY_CALL_WAITING = 9,
237 	SKINNY_CALL_TRANSFER = 10,
238 	SKINNY_CALL_PARK = 11,
239 	SKINNY_PROCEED = 12,
240 	SKINNY_IN_USE_REMOTELY = 13,
241 	SKINNY_INVALID_NUMBER = 14
242 };
243 extern struct skinny_table SKINNY_CALL_STATES[15];
244 const char *skinny_call_state2str(uint32_t id);
245 uint32_t skinny_str2call_state(const char *str);
246 #define SKINNY_PUSH_CALL_STATES SKINNY_DECLARE_PUSH_MATCH(SKINNY_CALL_STATES)
247 
248 enum skinny_device_reset_types {
249 	SKINNY_DEVICE_RESET = 1,
250 	SKINNY_DEVICE_RESTART = 2
251 };
252 extern struct skinny_table SKINNY_DEVICE_RESET_TYPES[3];
253 const char *skinny_device_reset_type2str(uint32_t id);
254 uint32_t skinny_str2device_reset_type(const char *str);
255 #define SKINNY_PUSH_DEVICE_RESET_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_DEVICE_RESET_TYPES)
256 
257 enum skinny_accessory_types {
258 	SKINNY_ACCESSORY_NONE = 0x00,
259 	SKINNY_ACCESSORY_HEADSET = 0x01,
260 	SKINNY_ACCESSORY_HANDSET = 0x02,
261 	SKINNY_ACCESSORY_SPEAKER = 0x03
262 };
263 extern struct skinny_table SKINNY_ACCESSORY_TYPES[5];
264 const char *skinny_accessory_type2str(uint32_t id);
265 uint32_t skinny_str2accessory_type(const char *str);
266 #define SKINNY_PUSH_ACCESSORY_TYPES SKINNY_DECLARE_PUSH_MATCH(SKINNY_ACCESSORY_TYPES)
267 
268 enum skinny_accessory_states {
269 	SKINNY_ACCESSORY_STATE_NONE = 0x00,
270 	SKINNY_ACCESSORY_STATE_OFFHOOK = 0x01,
271 	SKINNY_ACCESSORY_STATE_ONHOOK = 0x02
272 };
273 extern struct skinny_table SKINNY_ACCESSORY_STATES[4];
274 const char *skinny_accessory_state2str(uint32_t id);
275 uint32_t skinny_str2accessory_state(const char *str);
276 #define SKINNY_PUSH_ACCESSORY_STATES SKINNY_DECLARE_PUSH_MATCH(SKINNY_ACCESSORY_STATES)
277 
278 enum skinny_label {
279 	SKINNY_TEXTID_EMPTY = 0,
280 	SKINNY_TEXTID_REDIAL = 1,
281 	SKINNY_TEXTID_NEWCALL = 2,
282 	SKINNY_TEXTID_HOLD = 3,
283 	SKINNY_TEXTID_TRANSFER = 4,
284 	SKINNY_TEXTID_CFWDALL = 5,
285 	SKINNY_TEXTID_CFWDBUSY = 6,
286 	SKINNY_TEXTID_CFWDNOANSWER = 7,
287 	SKINNY_TEXTID_BACKSPACE = 8,
288 	SKINNY_TEXTID_ENDCALL = 9,
289 	SKINNY_TEXTID_RESUME = 10,
290 	SKINNY_TEXTID_ANSWER = 11,
291 	SKINNY_TEXTID_INFO = 12,
292 	SKINNY_TEXTID_CONF = 13,
293 	SKINNY_TEXTID_PARK = 14,
294 	SKINNY_TEXTID_JOIN = 15,
295 	SKINNY_TEXTID_MEETME = 16,
296 	SKINNY_TEXTID_CALLPICKUP = 17,
297 	SKINNY_TEXTID_GRPCALLPICKUP = 18,
298 	SKINNY_TEXTID_YOUR_CURRENT_OPTIONS = 19,
299 	SKINNY_TEXTID_OFF_HOOK = 20,
300 	SKINNY_TEXTID_ON_HOOK = 21,
301 	SKINNY_TEXTID_RING_OUT = 22,
302 	SKINNY_TEXTID_FROM = 23,
303 	SKINNY_TEXTID_CONNECTED = 24,
304 	SKINNY_TEXTID_BUSY = 25,
305 	SKINNY_TEXTID_LINE_IN_USE = 26,
306 	SKINNY_TEXTID_CALL_WAITING = 27,
307 	SKINNY_TEXTID_CALL_TRANSFER = 28,
308 	SKINNY_TEXTID_CALL_PARK = 29,
309 	SKINNY_TEXTID_CALL_PROCEED = 30,
310 	SKINNY_TEXTID_IN_USE_REMOTE = 31,
311 	SKINNY_TEXTID_ENTER_NUMBER = 32,
312 	SKINNY_TEXTID_CALL_PARK_AT = 33,
313 	SKINNY_TEXTID_PRIMARY_ONLY = 34,
314 	SKINNY_TEXTID_TEMP_FAIL = 35,
315 	SKINNY_TEXTID_YOU_HAVE_VOICEMAIL = 36,
316 	SKINNY_TEXTID_FORWARDED_TO = 37,
317 	SKINNY_TEXTID_CAN_NOT_COMPLETE_CONFERENCE = 38,
318 	SKINNY_TEXTID_NO_CONFERENCE_BRIDGE = 39,
319 	SKINNY_TEXTID_CAN_NOT_HOLD_PRIMARY_CONTROL = 40,
320 	SKINNY_TEXTID_INVALID_CONFERENCE_PARTICIPANT = 41,
321 	SKINNY_TEXTID_IN_CONFERENCE_ALREADY = 42,
322 	SKINNY_TEXTID_NO_PARTICIPANT_INFO = 43,
323 	SKINNY_TEXTID_EXCEED_MAXIMUM_PARTIES = 44,
324 	SKINNY_TEXTID_KEY_IS_NOT_ACTIVE = 45,
325 	SKINNY_TEXTID_ERROR_NO_LICENSE = 46,
326 	SKINNY_TEXTID_ERROR_DBCONFIG = 47,
327 	SKINNY_TEXTID_ERROR_DATABASE = 48,
328 	SKINNY_TEXTID_ERROR_PASS_LIMIT = 49,
329 	SKINNY_TEXTID_ERROR_UNKNOWN = 50,
330 	SKINNY_TEXTID_ERROR_MISMATCH = 51,
331 	SKINNY_TEXTID_CONFERENCE = 52,
332 	SKINNY_TEXTID_PARK_NUMBER = 53,
333 	SKINNY_TEXTID_PRIVATE = 54,
334 	SKINNY_TEXTID_NOT_ENOUGH_BANDWIDTH = 55,
335 	SKINNY_TEXTID_UNKNOWN_NUMBER = 56,
336 	SKINNY_TEXTID_RMLSTC = 57,
337 	SKINNY_TEXTID_VOICEMAIL = 58,
338 	SKINNY_TEXTID_IMMDIV = 59,
339 	SKINNY_TEXTID_INTRCPT = 60,
340 	SKINNY_TEXTID_SETWTCH = 61,
341 	SKINNY_TEXTID_TRNSFVM = 62,
342 	SKINNY_TEXTID_DND = 63,
343 	SKINNY_TEXTID_DIVALL = 64,
344 	SKINNY_TEXTID_CALLBACK = 65,
345 	SKINNY_TEXTID_NETWORK_CONGESTION_REROUTING = 66,
346 	SKINNY_TEXTID_BARGE = 67,
347 	SKINNY_TEXTID_FAILED_TO_SETUP_BARGE = 68,
348 	SKINNY_TEXTID_ANOTHER_BARGE_EXISTS = 69,
349 	SKINNY_TEXTID_INCOMPATIBLE_DEVICE_TYPE = 70,
350 	SKINNY_TEXTID_NO_PARK_NUMBER_AVAILABLE = 71,
351 	SKINNY_TEXTID_CALLPARK_REVERSION = 72,
352 	SKINNY_TEXTID_SERVICE_IS_NOT_ACTIVE = 73,
353 	SKINNY_TEXTID_HIGH_TRAFFIC_TRY_AGAIN_LATER = 74,
354 	SKINNY_TEXTID_QRT = 75,
355 	SKINNY_TEXTID_MCID = 76,
356 	SKINNY_TEXTID_DIRTRFR = 77,
357 	SKINNY_TEXTID_SELECT = 78,
358 	SKINNY_TEXTID_CONFLIST = 79,
359 	SKINNY_TEXTID_IDIVERT = 80,
360 	SKINNY_TEXTID_CBARGE = 81,
361 	SKINNY_TEXTID_CAN_NOT_COMPLETE_TRANSFER = 82,
362 	SKINNY_TEXTID_CAN_NOT_JOIN_CALLS = 83,
363 	SKINNY_TEXTID_MCID_SUCCESSFUL = 84,
364 	SKINNY_TEXTID_NUMBER_NOT_CONFIGURED = 85,
365 	SKINNY_TEXTID_SECURITY_ERROR = 86,
366 	SKINNY_TEXTID_VIDEO_BANDWIDTH_UNAVAILABLE = 87,
367 	SKINNY_TEXTID_VIDMODE = 88,
368 	SKINNY_TEXTID_MAX_CALL_DURATION_TIMEOUT = 89,
369 	SKINNY_TEXTID_MAX_HOLD_DURATION_TIMEOUT = 90,
370 	SKINNY_TEXTID_OPICKUP = 91,
371 	SKINNY_TEXTID_EXTERNAL_TRANSFER_RESTRICTED = 97,
372 	SKINNY_TEXTID_MAC_ADDRESS = 101,
373 	SKINNY_TEXTID_HOST_NAME = 102,
374 	SKINNY_TEXTID_DOMAIN_NAME = 103,
375 	SKINNY_TEXTID_IP_ADDRESS = 104,
376 	SKINNY_TEXTID_SUBNET_MASK = 105,
377 	SKINNY_TEXTID_TFTP_SERVER_1 = 106,
378 	SKINNY_TEXTID_DEFAULT_ROUTER_1 = 107,
379 	SKINNY_TEXTID_DEFAULT_ROUTER_2 = 108,
380 	SKINNY_TEXTID_DEFAULT_ROUTER_3 = 109,
381 	SKINNY_TEXTID_DEFAULT_ROUTER_4 = 110,
382 	SKINNY_TEXTID_DEFAULT_ROUTER_5 = 111,
383 	SKINNY_TEXTID_DNS_SERVER_1 = 112,
384 	SKINNY_TEXTID_DNS_SERVER_2 = 113,
385 	SKINNY_TEXTID_DNS_SERVER_3 = 114,
386 	SKINNY_TEXTID_DNS_SERVER_4 = 115,
387 	SKINNY_TEXTID_DNS_SERVER_5 = 116,
388 	SKINNY_TEXTID_OPERATIONAL_VLAN_ID = 117,
389 	SKINNY_TEXTID_ADMIN_VLAN_ID = 118,
390 	SKINNY_TEXTID_CALL_MANAGER_1 = 119,
391 	SKINNY_TEXTID_CALL_MANAGER_2 = 120,
392 	SKINNY_TEXTID_CALL_MANAGER_3 = 121,
393 	SKINNY_TEXTID_CALL_MANAGER_4 = 122,
394 	SKINNY_TEXTID_CALL_MANAGER_5 = 123,
395 	SKINNY_TEXTID_INFORMATION_URL = 124,
396 	SKINNY_TEXTID_DIRECTORIES_URL = 125,
397 	SKINNY_TEXTID_MESSAGES_URL = 126,
398 	SKINNY_TEXTID_SERVICES_URL = 127
399 };
400 extern struct skinny_table SKINNY_TEXTIDS[128];
401 const char *skinny_textid2str(uint32_t id);
402 uint32_t skinny_str2textid(const char *str);
403 #define SKINNY_PUSH_TEXTIDS SKINNY_DECLARE_PUSH_MATCH(SKINNY_TEXTIDS)
404 
405 
406 #endif /* _SKINNY_TABLES_H */
407 
408 /* For Emacs:
409  * Local Variables:
410  * mode:c
411  * indent-tabs-mode:t
412  * tab-width:4
413  * c-basic-offset:4
414  * End:
415  * For VIM:
416  * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
417  */
418 
419