1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #ifndef __FTMOD_SNG_SS7_H__
35 #define __FTMOD_SNG_SS7_H__
36
37
38
39 #include <stdio.h>
40 #include <string.h>
41 #include <stdarg.h>
42 #include <stdint.h>
43 #include <unistd.h>
44 #include <ctype.h>
45
46 #include "private/ftdm_core.h"
47
48 #include "sng_ss7.h"
49
50
51
52
53 #define MAX_NAME_LEN 10
54 #define MAX_PATH 255
55
56 #define MAX_CIC_LENGTH 5
57 #define MAX_CIC_MAP_LENGTH 1000
58
59 #define SNGSS7_EVENT_QUEUE_SIZE 100
60
61 typedef enum {
62 SNGSS7_CON_IND_EVENT = 0,
63 SNGSS7_CON_CFM_EVENT,
64 SNGSS7_CON_STA_EVENT,
65 SNGSS7_REL_IND_EVENT,
66 SNGSS7_REL_CFM_EVENT,
67 SNGSS7_DAT_IND_EVENT,
68 SNGSS7_FAC_IND_EVENT,
69 SNGSS7_FAC_CFM_EVENT,
70 SNGSS7_UMSG_IND_EVENT,
71 SNGSS7_STA_IND_EVENT
72 } sng_event_type_t;
73
74 typedef enum {
75 VOICE = 0,
76 SIG,
77 HOLE
78 } sng_ckt_type_t;
79
80 typedef enum {
81 CONFIGURED = (1 << 0),
82 ACTIVE = (1 << 1),
83 SNGSS7_PAUSED = (1 << 7)
84 } sng_flag_t;
85
86 typedef struct sng_mtp_link {
87 char name[MAX_NAME_LEN];
88 uint32_t id;
89 uint32_t flags;
90 struct {
91 uint32_t span;
92 uint32_t chan;
93 } mtp1;
94 struct {
95 uint32_t lssuLength;
96 uint32_t errorType;
97 uint32_t linkType;
98 uint32_t mtp1Id;
99 uint32_t t1;
100 uint32_t t2;
101 uint32_t t3;
102 uint32_t t4n;
103 uint32_t t4e;
104 uint32_t t5;
105 uint32_t t6;
106 uint32_t t7;
107 } mtp2;
108 struct {
109 uint32_t priority;
110 uint32_t linkType;
111 uint32_t switchType;
112 uint32_t apc;
113 uint32_t spc;
114 uint32_t ssf;
115 uint32_t slc;
116 uint32_t linkSetId;
117 uint32_t mtp2Id;
118 uint32_t t1;
119 uint32_t t2;
120 uint32_t t3;
121 uint32_t t4;
122 uint32_t t5;
123 uint32_t t6;
124 uint32_t t7;
125 uint32_t t8;
126 uint32_t t9;
127 uint32_t t10;
128 uint32_t t11;
129 uint32_t t12;
130 uint32_t t13;
131 uint32_t t14;
132 uint32_t t15;
133 uint32_t t16;
134 uint32_t t17;
135 uint32_t t18;
136 uint32_t t19;
137 uint32_t t20;
138 uint32_t t21;
139 uint32_t t22;
140 uint32_t t23;
141 uint32_t t24;
142 uint32_t t25;
143 uint32_t t27;
144 uint32_t t28;
145 uint32_t t29;
146 uint32_t t30;
147 uint32_t t31;
148 uint32_t t32;
149 uint32_t t33;
150 uint32_t t34;
151 uint32_t t35;
152 uint32_t t36;
153 uint32_t t37;
154 uint32_t tcraft;
155 uint32_t tflc;
156 uint32_t tbnd;
157 } mtp3;
158 } sng_mtp_link_t;
159
160 typedef struct sng_link_set {
161 uint32_t id;
162 char name[MAX_NAME_LEN];
163 uint32_t flags;
164 uint32_t apc;
165 uint32_t linkType;
166 uint32_t switchType;
167 uint32_t ssf;
168 uint32_t minActive;
169 uint32_t numLinks;
170 uint32_t links[16];
171 } sng_link_set_t;
172
173 typedef struct sng_route {
174 uint32_t id;
175 char name[MAX_NAME_LEN];
176 uint32_t flags;
177 uint32_t dpc;
178 uint32_t cmbLinkSetId;
179 uint32_t linkSetId;
180 uint32_t linkType;
181 uint32_t switchType;
182 uint32_t ssf;
183 uint32_t nwId;
184 uint32_t isSTP;
185 uint32_t t6;
186 uint32_t t8;
187 uint32_t t10;
188 uint32_t t11;
189 uint32_t t15;
190 uint32_t t16;
191 uint32_t t18;
192 uint32_t t19;
193 uint32_t t21;
194 uint32_t t25;
195 uint32_t t26;
196 } sng_route_t;
197
198 typedef struct sng_isup_intf {
199 uint32_t id;
200 char name[MAX_NAME_LEN];
201 uint32_t flags;
202 uint32_t spc;
203 uint32_t dpc;
204 uint32_t switchType;
205 uint32_t nwId;
206 uint32_t mtpRouteId;
207 uint32_t ssf;
208 uint32_t isap;
209 uint16_t t4;
210 uint32_t t10;
211 uint32_t t11;
212 uint32_t t18;
213 uint32_t t19;
214 uint32_t t20;
215 uint32_t t21;
216 uint32_t t22;
217 uint32_t t23;
218 uint32_t t24;
219 uint32_t t25;
220 uint32_t t26;
221 uint32_t t28;
222 uint32_t t29;
223 uint32_t t30;
224 uint32_t t32;
225 uint32_t t35;
226 uint32_t t37;
227 uint32_t t38;
228 uint32_t t39;
229 uint32_t tfgr;
230 uint32_t tpause;
231 uint32_t tstaenq;
232 } sng_isup_inf_t;
233
234 typedef struct sng_isup_ckt {
235 uint32_t id;
236 uint32_t flags;
237 uint32_t span;
238 uint32_t chan;
239 uint32_t type;
240 uint32_t cic;
241 uint32_t infId;
242 uint32_t ssf;
243 uint32_t typeCntrl;
244 void *obj;
245 uint16_t t3;
246 uint16_t t12;
247 uint16_t t13;
248 uint16_t t14;
249 uint16_t t15;
250 uint16_t t16;
251 uint16_t t17;
252 uint16_t tval;
253 } sng_isup_ckt_t;
254
255 typedef struct sng_nsap {
256 uint32_t id;
257 uint32_t flags;
258 uint32_t suId;
259 uint32_t spId;
260 uint32_t nwId;
261 uint32_t linkType;
262 uint32_t switchType;
263 uint32_t ssf;
264 } sng_nsap_t;
265
266 typedef struct sng_isap {
267 uint32_t id;
268 uint32_t suId;
269 uint32_t spId;
270 uint32_t switchType;
271 uint32_t ssf;
272 uint32_t flags;
273 uint32_t t1;
274 uint32_t t2;
275 uint32_t t5;
276 uint32_t t6;
277 uint32_t t7;
278 uint32_t t8;
279 uint32_t t9;
280 uint32_t t27;
281 uint32_t t31;
282 uint32_t t33;
283 uint32_t t34;
284 uint32_t t36;
285 uint32_t tccr;
286 uint32_t tccrt;
287 uint32_t tex;
288 uint32_t tcrm;
289 uint32_t tcra;
290 uint32_t tect;
291 uint32_t trelrsp;
292 uint32_t tfnlrelrsp;
293 } sng_isap_t;
294
295 typedef struct sng_ss7_cfg {
296 uint32_t spc;
297 char license[MAX_PATH];
298 char signature[MAX_PATH];
299 sng_mtp_link_t mtpLink[MAX_MTP_LINKS+1];
300 sng_link_set_t mtpLinkSet[MAX_MTP_LINKSETS+1];
301 sng_route_t mtpRoute[MAX_MTP_ROUTES+1];
302 sng_isup_inf_t isupIntf[MAX_ISUP_INFS+1];
303 sng_isup_ckt_t isupCkt[MAX_ISUP_CKTS+1];
304 sng_nsap_t nsap[MAX_NSAPS+1];
305 sng_isap_t isap[MAX_ISAPS+1];
306 }sng_ss7_cfg_t;
307
308 typedef struct ftdm_sngss7_data {
309 sng_ss7_cfg_t cfg;
310 int gen_config;
311 int min_digits;
312 int function_trace;
313 int function_trace_level;
314 int message_trace;
315 int message_trace_level;
316 fio_signal_cb_t sig_cb;
317 }ftdm_sngss7_data_t;
318
319 typedef struct sngss7_timer_data {
320 ftdm_timer_id_t hb_timer_id;
321 int beat;
322 int counter;
323 ftdm_sched_callback_t callback;
324 ftdm_sched_t *sched;
325 void *sngss7_info;
326 }sngss7_timer_data_t;
327
328 typedef struct sngss7_glare_data {
329 uint32_t spInstId;
330 uint32_t circuit;
331 SiConEvnt iam;
332 }sngss7_glare_data_t;
333
334 typedef struct sngss7_group_data {
335 uint32_t circuit;
336 uint32_t range;
337 uint8_t status[255];
338 uint8_t type;
339 uint8_t cause;
340 }sngss7_group_data_t;
341
342 typedef struct sngss7_chan_data {
343 ftdm_channel_t *ftdmchan;
344 sng_isup_ckt_t *circuit;
345 uint32_t base_chan;
346 uint32_t suInstId;
347 uint32_t spInstId;
348 uint32_t spId;
349 uint8_t globalFlg;
350 uint32_t flags;
351 sngss7_glare_data_t glare;
352 sngss7_timer_data_t t35;
353 }sngss7_chan_data_t;
354
355 typedef struct sngss7_span_data {
356 ftdm_sched_t *sched;
357 sngss7_group_data_t rx_grs;
358 sngss7_group_data_t rx_gra;
359 sngss7_group_data_t tx_grs;
360 sngss7_group_data_t rx_cgb;
361 sngss7_group_data_t tx_cgb;
362 sngss7_group_data_t rx_cgu;
363 sngss7_group_data_t tx_cgu;
364 ftdm_queue_t *event_queue;
365 }sngss7_span_data_t;
366
367 typedef struct sngss7_event_data
368 {
369 uint32_t event_id;
370 uint32_t spId;
371 uint32_t suId;
372 uint32_t spInstId;
373 uint32_t suInstId;
374 uint32_t circuit;
375 uint8_t globalFlg;
376 uint8_t evntType;
377 union
378 {
379 SiConEvnt siConEvnt;
380 SiCnStEvnt siCnStEvnt;
381 SiRelEvnt siRelEvnt;
382 SiInfoEvnt siInfoEvnt;
383 SiFacEvnt siFacEvnt;
384 SiStaEvnt siStaEvnt;
385 } event;
386 } sngss7_event_data_t;
387
388
389
390
391 typedef enum {
392 FLAG_RESET_RX = (1 << 0),
393 FLAG_RESET_TX = (1 << 1),
394 FLAG_RESET_SENT = (1 << 2),
395 FLAG_RESET_TX_RSP = (1 << 3),
396 FLAG_GRP_RESET_RX = (1 << 4),
397 FLAG_GRP_RESET_RX_DN = (1 << 5),
398 FLAG_GRP_RESET_RX_CMPLT = (1 << 6),
399 FLAG_GRP_RESET_BASE = (1 << 7),
400 FLAG_GRP_RESET_TX = (1 << 8),
401 FLAG_GRP_RESET_SENT = (1 << 9),
402 FLAG_GRP_RESET_TX_RSP = (1 << 10),
403 FLAG_REMOTE_REL = (1 << 11),
404 FLAG_LOCAL_REL = (1 << 12),
405 FLAG_GLARE = (1 << 13),
406 FLAG_INFID_RESUME = (1 << 14),
407 FLAG_INFID_PAUSED = (1 << 15),
408 FLAG_CKT_UCIC_BLOCK = (1 << 16),
409 FLAG_CKT_UCIC_UNBLK = (1 << 17),
410 FLAG_CKT_LC_BLOCK_RX = (1 << 18),
411 FLAG_CKT_LC_UNBLK_RX = (1 << 19),
412 FLAG_CKT_MN_BLOCK_RX = (1 << 20),
413 FLAG_CKT_MN_UNBLK_RX = (1 << 21),
414 FLAG_CKT_MN_BLOCK_TX = (1 << 22),
415 FLAG_CKT_MN_UNBLK_TX = (1 << 23),
416 FLAG_GRP_HW_BLOCK_RX = (1 << 24),
417 FLAG_GRP_HW_BLOCK_TX = (1 << 25),
418 FLAG_GRP_MN_BLOCK_RX = (1 << 26),
419 FLAG_GRP_MN_BLOCK_TX = (1 << 27),
420 FLAG_GRP_HW_UNBLK_TX = (1 << 28),
421 FLAG_GRP_MN_UNBLK_TX = (1 << 29)
422 } flag_t;
423
424
425
426 extern ftdm_sngss7_data_t g_ftdm_sngss7_data;
427 extern uint32_t sngss7_id;
428 extern ftdm_sched_t *sngss7_sched;
429 extern int cmbLinkSetId;
430
431
432
433
434 void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan);
435
436
437 void handle_sng_log(uint8_t level, char *fmt,...);
438 void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta);
439 void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
440 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
441 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
442 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
443
444
445 int ft_to_sngss7_cfg_all(void);
446 int ftmod_ss7_mtp1_gen_config(void);
447 int ftmod_ss7_mtp2_gen_config(void);
448 int ftmod_ss7_mtp3_gen_config(void);
449 int ftmod_ss7_isup_gen_config(void);
450 int ftmod_ss7_cc_gen_config(void);
451 int ftmod_ss7_mtp1_psap_config(int id);
452 int ftmod_ss7_mtp2_dlsap_config(int id);
453 int ftmod_ss7_mtp3_dlsap_config(int id);
454 int ftmod_ss7_mtp3_nsap_config(int id);
455 int ftmod_ss7_mtp3_linkset_config(int id);
456 int ftmod_ss7_mtp3_route_config(int id);
457 int ftmod_ss7_isup_nsap_config(int id);
458 int ftmod_ss7_isup_intf_config(int id);
459 int ftmod_ss7_isup_ckt_config(int id);
460 int ftmod_ss7_isup_isap_config(int id);
461 int ftmod_ss7_cc_isap_config(int id);
462
463
464 int ft_to_sngss7_activate_all(void);
465
466 int ftmod_ss7_inhibit_mtplink(uint32_t id);
467 int ftmod_ss7_uninhibit_mtplink(uint32_t id);
468 int ftmod_ss7_activate_mtplink(uint32_t id);
469 int ftmod_ss7_deactivate_mtplink(uint32_t id);
470 int ftmod_ss7_deactivate2_mtplink(uint32_t id);
471 int ftmod_ss7_activate_mtplinkSet(uint32_t id);
472 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
473 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
474 int ftmod_ss7_lpo_mtplink(uint32_t id);
475 int ftmod_ss7_lpr_mtplink(uint32_t id);
476
477
478 int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);
479 int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
480
481
482
483 void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
484 void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
485 void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
486 void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan);
487 void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan);
488 void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan);
489 void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan);
490 void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan);
491 void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan);
492 void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan);
493 void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan);
494 void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan);
495 void ft_to_sngss7_gra(ftdm_channel_t *ftdmchan);
496 void ft_to_sngss7_grs(ftdm_channel_t *ftdmchan);
497 void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
498 void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
499 void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan);
500 void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
501
502
503 void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
504 void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
505 void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
506 void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
507 void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
508 void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
509 void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt);
510 void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
511 void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
512 void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
513 void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
514
515
516 ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
517 ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
518 ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
519 ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
520 ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
521 ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt);
522 ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
523 ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
524 ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
525 ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
526
527 ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
528 ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
529 ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
530 ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
531 ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
532 ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
533 ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
534 ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
535 ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
536 ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
537 ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
538 ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
539 ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
540 ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
541 ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
542 ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
543 ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
544 ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
545
546
547 int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
548
549
550 ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
551
552
553 uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
554 uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
555 uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
556 uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
557 uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
558 int check_for_state_change(ftdm_channel_t *ftdmchan);
559 int check_cics_in_range(sngss7_chan_data_t *sngss7_info);
560 int check_for_reset(sngss7_chan_data_t *sngss7_info);
561 ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
562 unsigned long get_unique_id(void);
563
564 ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan);
565 ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
566 ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
567 ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
568
569 ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
570 ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
571 ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info);
572 ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info);
573
574
575
576 void handle_isup_t35(void *userdata);
577
578
579
580 #define SS7_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a , ##__VA_ARGS__ );
581 #define SS7_INFO(a,...) ftdm_log(FTDM_LOG_INFO,a , ##__VA_ARGS__ );
582 #define SS7_WARN(a,...) ftdm_log(FTDM_LOG_WARNING,a , ##__VA_ARGS__ );
583 #define SS7_ERROR(a,...) ftdm_log(FTDM_LOG_ERROR,a , ##__VA_ARGS__ );
584 #define SS7_CRITICAL(a,...) ftdm_log(FTDM_LOG_CRIT,a , ##__VA_ARGS__ );
585
586 #define SS7_DEBUG_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_DEBUG, msg , ##args)
587 #define SS7_INFO_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_INFO, msg , ##args)
588 #define SS7_WARN_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_WARNING, msg , ##args)
589 #define SS7_ERROR_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_ERROR, msg , ##args)
590 #define SS7_CTRIT_CHAN(fchan, msg, args...) ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args)
591
592 #ifdef KONRAD_DEVEL
593 #define SS7_DEVEL_DEBUG(a,...) ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ );
594 #else
595 #define SS7_DEVEL_DEBUG(a,...)
596 #endif
597
598 #define SS7_FUNC_TRACE_ENTER(a) if (g_ftdm_sngss7_data.function_trace) { \
599 switch (g_ftdm_sngss7_data.function_trace_level) { \
600 case 0: \
601 ftdm_log(FTDM_LOG_EMERG,"Entering %s\n", a); \
602 break; \
603 case 1: \
604 ftdm_log(FTDM_LOG_ALERT,"Entering %s\n", a); \
605 break; \
606 case 2: \
607 ftdm_log(FTDM_LOG_CRIT,"Entering %s\n", a); \
608 break; \
609 case 3: \
610 ftdm_log(FTDM_LOG_ERROR,"Entering %s\n", a); \
611 break; \
612 case 4: \
613 ftdm_log(FTDM_LOG_WARNING,"Entering %s\n", a); \
614 break; \
615 case 5: \
616 ftdm_log(FTDM_LOG_NOTICE,"Entering %s\n", a); \
617 break; \
618 case 6: \
619 ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
620 break; \
621 case 7: \
622 ftdm_log(FTDM_LOG_DEBUG,"Entering %s\n", a); \
623 break; \
624 default: \
625 ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
626 break; \
627 } \
628 }
629
630 #define SS7_FUNC_TRACE_EXIT(a) if (g_ftdm_sngss7_data.function_trace) { \
631 switch (g_ftdm_sngss7_data.function_trace_level) { \
632 case 0: \
633 ftdm_log(FTDM_LOG_EMERG,"Exitting %s\n", a); \
634 break; \
635 case 1: \
636 ftdm_log(FTDM_LOG_ALERT,"Exitting %s\n", a); \
637 break; \
638 case 2: \
639 ftdm_log(FTDM_LOG_CRIT,"Exitting %s\n", a); \
640 break; \
641 case 3: \
642 ftdm_log(FTDM_LOG_ERROR,"Exitting %s\n", a); \
643 break; \
644 case 4: \
645 ftdm_log(FTDM_LOG_WARNING,"Exitting %s\n", a); \
646 break; \
647 case 5: \
648 ftdm_log(FTDM_LOG_NOTICE,"Exitting %s\n", a); \
649 break; \
650 case 6: \
651 ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
652 break; \
653 case 7: \
654 ftdm_log(FTDM_LOG_DEBUG,"Exitting %s\n", a); \
655 break; \
656 default: \
657 ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
658 break; \
659 } \
660 }
661
662 #define SS7_MSG_TRACE(fchan, sngss7info ,msg) if (g_ftdm_sngss7_data.message_trace) { \
663 switch (g_ftdm_sngss7_data.message_trace_level) { \
664 case 0: \
665 ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
666 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
667 break; \
668 case 1: \
669 ftdm_log_chan(fchan, FTDM_LOG_ALERT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
670 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
671 break; \
672 case 2: \
673 ftdm_log_chan(fchan, FTDM_LOG_CRIT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
674 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
675 break; \
676 case 3: \
677 ftdm_log_chan(fchan, FTDM_LOG_ERROR, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
678 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
679 break; \
680 case 4: \
681 ftdm_log_chan(fchan, FTDM_LOG_WARNING, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
682 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
683 break; \
684 case 5: \
685 ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
686 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
687 break; \
688 case 6: \
689 ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
690 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
691 break; \
692 case 7: \
693 ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
694 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
695 break; \
696 default: \
697 ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
698 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
699 break; \
700 } \
701 }
702
703 #define sngss7_test_flag(obj, flag) ((obj)->flags & flag)
704 #define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag))
705 #define sngss7_set_flag(obj, flag) ((obj)->flags |= (flag))
706
707 #ifdef SS7_PRODUCTION
708 # define SS7_ASSERT \
709 SS7_INFO_CHAN(ftdmchan,"Production Mode, continuing%s\n", "");
710 #else
711 # define SS7_ASSERT \
712 SS7_ERROR_CHAN(ftdmchan, "Debugging Mode, ending%s\n", ""); \
713 *(int*)0=0;
714 #endif
715
716
717
718 #endif
719
720
721
722
723
724
725
726
727
728
729
730
731
732