root/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_main.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2009, Konrad Hammel <konrad@sangoma.com>
   3  * All rights reserved.
   4  *
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  *
   9  * * Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer.
  11  *
  12  * * Redistributions in binary form must reproduce the above copyright
  13  * notice, this list of conditions and the following disclaimer in the
  14  * documentation and/or other materials provided with the distribution.
  15  *
  16  * * Neither the name of the original author; nor the names of any contributors
  17  * may be used to endorse or promote products derived from this software
  18  * without specific prior written permission.
  19  *
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 /******************************************************************************/
  34 #ifndef __FTMOD_SNG_SS7_H__
  35 #define __FTMOD_SNG_SS7_H__
  36 /******************************************************************************/
  37 
  38 /* INCLUDE ********************************************************************/
  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 /* DEFINES ********************************************************************/
  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 #define MAX_SIZEOF_SUBADDR_IE   24      /* as per Q931 4.5.9 */
  62 
  63 typedef enum {
  64         SNGSS7_CON_IND_EVENT = 0,
  65         SNGSS7_CON_CFM_EVENT,
  66         SNGSS7_CON_STA_EVENT,
  67         SNGSS7_REL_IND_EVENT,
  68         SNGSS7_REL_CFM_EVENT,
  69         SNGSS7_DAT_IND_EVENT,
  70         SNGSS7_FAC_IND_EVENT,
  71         SNGSS7_FAC_CFM_EVENT,
  72         SNGSS7_UMSG_IND_EVENT,
  73         SNGSS7_STA_IND_EVENT,
  74         SNGSS7_SUSP_IND_EVENT,
  75         SNGSS7_RESM_IND_EVENT,
  76         SNGSS7_SSP_STA_CFM_EVENT
  77 } sng_event_type_t;
  78 
  79 typedef enum {
  80         VOICE = 0,
  81         SIG,
  82         HOLE
  83 } sng_ckt_type_t;
  84 
  85 typedef enum {
  86         CONFIGURED              = (1 << 0),
  87         ACTIVE                  = (1 << 1),
  88         SNGSS7_PAUSED   = (1 << 7)
  89 } sng_flag_t;
  90 
  91 typedef enum {
  92         SNGSS7_LPA_FOR_COT              = (1 << 0),     /* send LPA when COT arrives */
  93         SNGSS7_ACM_OBCI_BITA    = (1 << 10)     /* in-band indication */
  94 } sng_intf_options_t;
  95 
  96 typedef enum {
  97         SNG_CALLED                      = 1,
  98         SNG_CALLING                     = 2
  99 } sng_addr_type_t;
 100 
 101 typedef struct sng_mtp_link {
 102         char                    name[MAX_NAME_LEN];
 103         uint32_t                id;
 104         uint32_t                flags;
 105         struct {
 106                 uint32_t        span;
 107                 uint32_t        chan;
 108         } mtp1;
 109         struct {
 110                 uint32_t        lssuLength;
 111                 uint32_t        errorType;
 112                 uint32_t        linkType;
 113                 uint32_t        mtp1Id;
 114                 uint32_t        t1;
 115                 uint32_t        t2;
 116                 uint32_t        t3;
 117                 uint32_t        t4n;
 118                 uint32_t        t4e;
 119                 uint32_t        t5;
 120                 uint32_t        t6;
 121                 uint32_t        t7;
 122         } mtp2;
 123         struct {
 124                 uint32_t        priority;
 125                 uint32_t        linkType;
 126                 uint32_t        switchType;
 127                 uint32_t        apc;
 128                 uint32_t        spc;
 129                 uint32_t        ssf;
 130                 uint32_t        slc;
 131                 uint32_t        linkSetId;
 132                 uint32_t        mtp2Id;
 133                 uint32_t        t1;
 134                 uint32_t        t2;
 135                 uint32_t        t3;
 136                 uint32_t        t4;
 137                 uint32_t        t5;
 138                 uint32_t        t6;
 139                 uint32_t        t7;
 140                 uint32_t        t8;
 141                 uint32_t        t9;
 142                 uint32_t        t10;
 143                 uint32_t        t11;
 144                 uint32_t        t12;
 145                 uint32_t        t13;
 146                 uint32_t        t14;
 147                 uint32_t        t15;
 148                 uint32_t        t16;
 149                 uint32_t        t17;
 150                 uint32_t        t18;
 151                 uint32_t        t19;
 152                 uint32_t        t20;
 153                 uint32_t        t21;
 154                 uint32_t        t22;
 155                 uint32_t        t23;
 156                 uint32_t        t24;
 157                 uint32_t        t25;
 158                 uint32_t        t27;
 159                 uint32_t        t28;
 160                 uint32_t        t29;
 161                 uint32_t        t30;
 162                 uint32_t        t31;
 163                 uint32_t        t32;
 164                 uint32_t        t33;
 165                 uint32_t        t34;
 166                 uint32_t        t35;
 167                 uint32_t        t36;
 168                 uint32_t        t37;
 169                 uint32_t        tcraft;
 170                 uint32_t        tflc;
 171                 uint32_t        tbnd;
 172         } mtp3;
 173 } sng_mtp_link_t;
 174 
 175 typedef struct sng_link_set {
 176         uint32_t                id;
 177         char                    name[MAX_NAME_LEN];
 178         uint32_t                flags;
 179         uint32_t                apc;
 180         uint32_t                linkType;
 181         uint32_t                switchType;
 182         uint32_t                ssf;
 183         uint32_t                minActive;
 184         uint32_t                numLinks;
 185         uint32_t                links[16];
 186 } sng_link_set_t;
 187 
 188 typedef struct sng_route {
 189         uint32_t                id;
 190         char                    name[MAX_NAME_LEN];
 191         uint32_t                flags;
 192         uint32_t                dpc;
 193         uint32_t                cmbLinkSetId;
 194         uint32_t                linkSetId;
 195         uint32_t                linkType;
 196         uint32_t                switchType;
 197         uint32_t                ssf;
 198         uint32_t                nwId;
 199         uint32_t                isSTP;
 200         uint32_t                t6;
 201         uint32_t                t8;
 202         uint32_t                t10;
 203         uint32_t                t11;
 204         uint32_t                t15;
 205         uint32_t                t16;
 206         uint32_t                t18;
 207         uint32_t                t19;
 208         uint32_t                t21;
 209         uint32_t                t25;
 210         uint32_t                t26;
 211 } sng_route_t;
 212 
 213 typedef struct sng_isup_intf {
 214         uint32_t                id;
 215         char                    name[MAX_NAME_LEN];
 216         uint32_t                options;
 217         uint32_t                flags;
 218         uint32_t                spc;
 219         uint32_t                dpc;
 220         uint32_t                switchType;
 221         uint32_t                nwId;
 222         uint32_t                mtpRouteId;
 223         uint32_t                ssf;
 224         uint32_t                isap;
 225         uint32_t                clg_nadi;
 226         uint32_t                cld_nadi;
 227         uint16_t                t4;
 228         uint32_t                t10;
 229         uint32_t                t11;
 230         uint32_t                t18;
 231         uint32_t                t19;
 232         uint32_t                t20;
 233         uint32_t                t21;
 234         uint32_t                t22;
 235         uint32_t                t23;
 236         uint32_t                t24;
 237         uint32_t                t25;
 238         uint32_t                t26;
 239         uint32_t                t28;
 240         uint32_t                t29;
 241         uint32_t                t30;
 242         uint32_t                t32;
 243         uint32_t                t35;
 244         uint32_t                t37;
 245         uint32_t                t38;
 246         uint32_t                t39;
 247         uint32_t                tfgr;
 248         uint32_t                tpause;
 249         uint32_t                tstaenq;
 250 } sng_isup_inf_t;
 251 
 252 typedef struct sng_isup_ckt {
 253         uint32_t                id;
 254         uint32_t                flags;
 255         uint32_t                span;
 256         uint32_t                chan;
 257         uint32_t                type;   /* VOICE/SIG/HOLE */
 258         uint32_t                cic;
 259         uint32_t                infId;
 260         uint32_t                ssf;
 261         uint32_t                typeCntrl;
 262         void                    *obj;
 263         uint16_t                t3;
 264         uint16_t                t12;
 265         uint16_t                t13;
 266         uint16_t                t14;
 267         uint16_t                t15;
 268         uint16_t                t16;
 269         uint16_t                t17;
 270         uint16_t                tval;
 271 } sng_isup_ckt_t;
 272 
 273 typedef struct sng_nsap {
 274         uint32_t                id;
 275         uint32_t                flags;
 276         uint32_t                suId;
 277         uint32_t                spId;
 278         uint32_t                nwId;
 279         uint32_t                linkType;
 280         uint32_t                switchType;
 281         uint32_t                ssf;
 282 } sng_nsap_t;
 283 
 284 typedef struct sng_isap {
 285         uint32_t                id;
 286         uint32_t                suId;
 287         uint32_t                spId;
 288         uint32_t                switchType;
 289         uint32_t                ssf;
 290         uint32_t                flags;
 291         uint32_t                t1;
 292         uint32_t                t2;
 293         uint32_t                t5;
 294         uint32_t                t6;
 295         uint32_t                t7;
 296         uint32_t                t8;
 297         uint32_t                t9;
 298         uint32_t                t27;
 299         uint32_t                t31;
 300         uint32_t                t33;
 301         uint32_t                t34;
 302         uint32_t                t36;
 303         uint32_t                tccr;
 304         uint32_t                tccrt;
 305         uint32_t                tex;
 306         uint32_t                tcrm;
 307         uint32_t                tcra;
 308         uint32_t                tect;
 309         uint32_t                trelrsp;
 310         uint32_t                tfnlrelrsp;
 311 } sng_isap_t;
 312 
 313 typedef struct sng_ss7_cfg {
 314         uint32_t                        spc;
 315         char                            license[MAX_PATH];
 316         char                            signature[MAX_PATH];
 317         sng_mtp_link_t          mtpLink[MAX_MTP_LINKS+1];
 318         sng_link_set_t          mtpLinkSet[MAX_MTP_LINKSETS+1];
 319         sng_route_t                     mtpRoute[MAX_MTP_ROUTES+1];
 320         sng_isup_inf_t          isupIntf[MAX_ISUP_INFS+1];
 321         sng_isup_ckt_t          isupCkt[MAX_ISUP_CKTS+1];
 322         sng_nsap_t                      nsap[MAX_NSAPS+1];
 323         sng_isap_t                      isap[MAX_ISAPS+1];      
 324 }sng_ss7_cfg_t;
 325 
 326 typedef struct ftdm_sngss7_data {
 327         sng_ss7_cfg_t           cfg;
 328         int                                     gen_config;
 329         int                                     min_digits;
 330         int                                     function_trace;
 331         int                                     function_trace_level;
 332         int                                     message_trace;
 333         int                                     message_trace_level;
 334         fio_signal_cb_t         sig_cb;
 335 }ftdm_sngss7_data_t;
 336 
 337 typedef struct sngss7_timer_data {
 338         ftdm_timer_id_t                 hb_timer_id;
 339         int                                             beat;
 340         int                                             counter;
 341         ftdm_sched_callback_t   callback;
 342         ftdm_sched_t                    *sched;
 343         void                                    *sngss7_info;
 344 }sngss7_timer_data_t;
 345 
 346 typedef struct sngss7_glare_data {
 347         uint32_t                                spInstId; 
 348         uint32_t                                circuit; 
 349         SiConEvnt                               iam;
 350 }sngss7_glare_data_t;
 351 
 352 typedef struct sngss7_group_data {
 353         uint32_t                                circuit;
 354         uint32_t                                range;
 355         uint8_t                                 status[255];
 356         uint8_t                                 type;
 357         uint8_t                                 cause;
 358 }sngss7_group_data_t;
 359 
 360 typedef struct sngss7_chan_data {
 361         ftdm_channel_t                  *ftdmchan;
 362         sng_isup_ckt_t                  *circuit;
 363         uint32_t                                base_chan;
 364         uint32_t                                suInstId;
 365         uint32_t                                spInstId;
 366         uint32_t                                spId;
 367         uint8_t                                 globalFlg;
 368         uint32_t                                flags;
 369         sngss7_glare_data_t             glare;
 370         sngss7_timer_data_t             t35;
 371 }sngss7_chan_data_t;
 372 
 373 typedef struct sngss7_span_data {
 374         ftdm_sched_t                    *sched;
 375         sngss7_group_data_t             rx_grs;
 376         sngss7_group_data_t             rx_gra;
 377         sngss7_group_data_t             tx_grs;
 378         sngss7_group_data_t             rx_cgb;
 379         sngss7_group_data_t             tx_cgb;
 380         sngss7_group_data_t             rx_cgu;
 381         sngss7_group_data_t             tx_cgu;
 382         sngss7_group_data_t             ucic;
 383         ftdm_queue_t                    *event_queue;
 384 }sngss7_span_data_t;
 385 
 386 typedef struct sngss7_event_data
 387 {
 388         uint32_t                event_id;
 389         uint32_t                spId;
 390         uint32_t                suId;
 391         uint32_t                spInstId;
 392         uint32_t                suInstId;
 393         uint32_t                circuit;
 394         uint8_t                 globalFlg;
 395         uint8_t                 evntType;
 396         union
 397         {
 398                 SiConEvnt       siConEvnt;
 399                 SiCnStEvnt      siCnStEvnt;
 400                 SiRelEvnt       siRelEvnt;
 401                 SiInfoEvnt      siInfoEvnt;
 402                 SiFacEvnt       siFacEvnt;
 403                 SiStaEvnt       siStaEvnt;
 404                 SiSuspEvnt      siSuspEvnt;
 405                 SiResmEvnt      siResmEvnt;
 406         } event;
 407 } sngss7_event_data_t;
 408 
 409 
 410 
 411 
 412 typedef enum {
 413         FLAG_RESET_RX                   = (1 << 0),
 414         FLAG_RESET_TX                   = (1 << 1),
 415         FLAG_RESET_SENT                 = (1 << 2),
 416         FLAG_RESET_TX_RSP               = (1 << 3),
 417         FLAG_GRP_RESET_RX               = (1 << 4),
 418         FLAG_GRP_RESET_RX_DN    = (1 << 5),
 419         FLAG_GRP_RESET_RX_CMPLT = (1 << 6),
 420         FLAG_GRP_RESET_BASE             = (1 << 7),
 421         FLAG_GRP_RESET_TX               = (1 << 8),
 422         FLAG_GRP_RESET_SENT             = (1 << 9),
 423         FLAG_GRP_RESET_TX_RSP   = (1 << 10),
 424         FLAG_REMOTE_REL                 = (1 << 11),
 425         FLAG_LOCAL_REL                  = (1 << 12),
 426         FLAG_GLARE                              = (1 << 13),
 427         FLAG_INFID_RESUME               = (1 << 14),
 428         FLAG_INFID_PAUSED               = (1 << 15),
 429         FLAG_CKT_UCIC_BLOCK             = (1 << 16),
 430         FLAG_CKT_UCIC_UNBLK             = (1 << 17),
 431         FLAG_CKT_LC_BLOCK_RX    = (1 << 18),
 432         FLAG_CKT_LC_UNBLK_RX    = (1 << 19),
 433         FLAG_CKT_MN_BLOCK_RX    = (1 << 20),
 434         FLAG_CKT_MN_UNBLK_RX    = (1 << 21),
 435         FLAG_CKT_MN_BLOCK_TX    = (1 << 22),
 436         FLAG_CKT_MN_UNBLK_TX    = (1 << 23),
 437         FLAG_GRP_HW_BLOCK_RX    = (1 << 24),
 438         FLAG_GRP_HW_BLOCK_TX    = (1 << 25),
 439         FLAG_GRP_MN_BLOCK_RX    = (1 << 26),
 440         FLAG_GRP_MN_BLOCK_TX    = (1 << 27),
 441         FLAG_GRP_HW_UNBLK_TX    = (1 << 28),
 442         FLAG_GRP_MN_UNBLK_TX    = (1 << 29)
 443 } flag_t;
 444 /******************************************************************************/
 445 
 446 /* GLOBALS ********************************************************************/
 447 extern ftdm_sngss7_data_t   g_ftdm_sngss7_data;
 448 extern uint32_t                  sngss7_id;
 449 extern ftdm_sched_t              *sngss7_sched;
 450 extern int                              cmbLinkSetId;
 451 /******************************************************************************/
 452 
 453 /* PROTOTYPES *****************************************************************/
 454 /* in ftmod_sangoma_ss7_main.c */
 455 void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t *ftdmchan);
 456 
 457 /* in ftmod_sangoma_ss7_logger.c */
 458 void handle_sng_log(uint8_t level, char *fmt,...);
 459 void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta);
 460 void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
 461 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
 462 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
 463 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
 464 
 465 /* in ftmod_sangoma_ss7_cfg.c */
 466 int ft_to_sngss7_cfg_all(void);
 467 int ftmod_ss7_mtp1_gen_config(void);
 468 int ftmod_ss7_mtp2_gen_config(void);
 469 int ftmod_ss7_mtp3_gen_config(void);
 470 int ftmod_ss7_isup_gen_config(void);
 471 int ftmod_ss7_cc_gen_config(void);
 472 int ftmod_ss7_mtp1_psap_config(int id);
 473 int ftmod_ss7_mtp2_dlsap_config(int id);
 474 int ftmod_ss7_mtp3_dlsap_config(int id);
 475 int ftmod_ss7_mtp3_nsap_config(int id);
 476 int ftmod_ss7_mtp3_linkset_config(int id);
 477 int ftmod_ss7_mtp3_route_config(int id);
 478 int ftmod_ss7_isup_nsap_config(int id);
 479 int ftmod_ss7_isup_intf_config(int id);
 480 int ftmod_ss7_isup_ckt_config(int id);
 481 int ftmod_ss7_isup_isap_config(int id);
 482 int ftmod_ss7_cc_isap_config(int id);
 483 
 484 /* in ftmod_sangoma_ss7_cntrl.c */
 485 int  ft_to_sngss7_activate_all(void);
 486 
 487 int ftmod_ss7_inhibit_mtplink(uint32_t id);
 488 int ftmod_ss7_uninhibit_mtplink(uint32_t id);
 489 int ftmod_ss7_activate_mtplink(uint32_t id);
 490 int ftmod_ss7_deactivate_mtplink(uint32_t id);
 491 int ftmod_ss7_deactivate2_mtplink(uint32_t id);
 492 int ftmod_ss7_activate_mtplinkSet(uint32_t id);
 493 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
 494 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
 495 int ftmod_ss7_lpo_mtplink(uint32_t id);
 496 int ftmod_ss7_lpr_mtplink(uint32_t id);
 497 
 498 /* in ftmod_sangoma_ss7_sta.c */
 499 int ftmod_ss7_mtplink_sta(uint32_t id, SnMngmt *cfm);
 500 int ftmod_ss7_mtplinkSet_sta(uint32_t id, SnMngmt *cfm);
 501 
 502 
 503 /* in ftmod_sangoma_ss7_out.c */
 504 void ft_to_sngss7_iam(ftdm_channel_t *ftdmchan);
 505 void ft_to_sngss7_acm(ftdm_channel_t *ftdmchan);
 506 void ft_to_sngss7_anm(ftdm_channel_t *ftdmchan);
 507 void ft_to_sngss7_rel(ftdm_channel_t *ftdmchan);
 508 void ft_to_sngss7_rlc(ftdm_channel_t *ftdmchan);
 509 void ft_to_sngss7_rsc(ftdm_channel_t *ftdmchan);
 510 void ft_to_sngss7_rsca(ftdm_channel_t *ftdmchan);
 511 void ft_to_sngss7_blo(ftdm_channel_t *ftdmchan);
 512 void ft_to_sngss7_bla(ftdm_channel_t *ftdmchan);
 513 void ft_to_sngss7_ubl(ftdm_channel_t *ftdmchan);
 514 void ft_to_sngss7_uba(ftdm_channel_t *ftdmchan);
 515 void ft_to_sngss7_lpa(ftdm_channel_t *ftdmchan);
 516 void ft_to_sngss7_gra(ftdm_channel_t *ftdmchan);
 517 void ft_to_sngss7_grs(ftdm_channel_t *ftdmchan);
 518 void ft_to_sngss7_cgba(ftdm_channel_t * ftdmchan);
 519 void ft_to_sngss7_cgua(ftdm_channel_t * ftdmchan);
 520 void ft_to_sngss7_cgb(ftdm_channel_t * ftdmchan);
 521 void ft_to_sngss7_cgu(ftdm_channel_t * ftdmchan);
 522 
 523 /* in ftmod_sangoma_ss7_in.c */
 524 void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 525 void sngss7_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
 526 void sngss7_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
 527 void sngss7_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
 528 void sngss7_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
 529 void sngss7_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
 530 void sngss7_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt);
 531 void sngss7_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
 532 void sngss7_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
 533 void sngss7_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 534 void sngss7_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
 535 void sngss7_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt);
 536 void sngss7_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt);
 537 void sngss7_ssp_sta_cfm(uint32_t infId);
 538 
 539 /* in ftmod_sangoma_ss7_handle.c */
 540 ftdm_status_t handle_con_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
 541 ftdm_status_t handle_con_sta(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiCnStEvnt *siCnStEvnt, uint8_t evntType);
 542 ftdm_status_t handle_con_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiConEvnt *siConEvnt);
 543 ftdm_status_t handle_rel_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
 544 ftdm_status_t handle_rel_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiRelEvnt *siRelEvnt);
 545 ftdm_status_t handle_dat_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiInfoEvnt *siInfoEvnt);
 546 ftdm_status_t handle_fac_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
 547 ftdm_status_t handle_fac_cfm(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t evntType, SiFacEvnt *siFacEvnt);
 548 ftdm_status_t handle_umsg_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit);
 549 ftdm_status_t handle_susp_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiSuspEvnt *siSuspEvnt);
 550 ftdm_status_t handle_resm_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, SiResmEvnt *siResmEvnt);
 551 ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 552 
 553 ftdm_status_t handle_reattempt(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 554 ftdm_status_t handle_pause(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 555 ftdm_status_t handle_resume(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 556 ftdm_status_t handle_cot_start(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 557 ftdm_status_t handle_cot_stop(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 558 ftdm_status_t handle_cot(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 559 ftdm_status_t handle_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 560 ftdm_status_t handle_local_rsc_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 561 ftdm_status_t handle_rsc_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 562 ftdm_status_t handle_grs_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 563 ftdm_status_t handle_grs_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 564 ftdm_status_t handle_blo_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 565 ftdm_status_t handle_blo_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 566 ftdm_status_t handle_ubl_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 567 ftdm_status_t handle_ubl_rsp(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 568 ftdm_status_t handle_local_blk(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 569 ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 570 ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
 571 
 572 /* in ftmod_sangoma_ss7_xml.c */
 573 int ftmod_ss7_parse_xml(ftdm_conf_parameter_t *ftdm_parameters, ftdm_span_t *span);
 574 
 575 /* in ftmod_sangoma_ss7_cli.c */
 576 ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const char *data);
 577 
 578 /* in ftmod_sangoma_ss7_support.c */
 579 uint8_t copy_cgPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
 580 uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum);
 581 uint8_t copy_cdPtyNum_from_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
 582 uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum);
 583 uint8_t copy_tknStr_from_sngss7(TknStr str, char *ftdm, TknU8 oddEven);
 584 int check_for_state_change(ftdm_channel_t *ftdmchan);
 585 int check_cics_in_range(sngss7_chan_data_t *sngss7_info);
 586 int check_for_reset(sngss7_chan_data_t *sngss7_info);
 587 ftdm_status_t extract_chan_data(uint32_t circuit, sngss7_chan_data_t **sngss7_info, ftdm_channel_t **ftdmchan);
 588 unsigned long get_unique_id(void);
 589 
 590 ftdm_status_t check_if_rx_grs_started(ftdm_span_t *ftdmspan);
 591 ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
 592 ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
 593 ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
 594 
 595 ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan);
 596 
 597 ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
 598 ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
 599 ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info);
 600 ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info);
 601 ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info);
 602 ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info);
 603 ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);
 604 
 605 ftdm_status_t encode_subAddrIE_nsap(const char *subAddr, char *subAddrIE, int type);
 606 ftdm_status_t encode_subAddrIE_nat(const char *subAddr, char *subAddrIE, int type);
 607 
 608 /* in ftmod_sangoma_ss7_timers.c */
 609 void handle_isup_t35(void *userdata);
 610 /******************************************************************************/
 611 
 612 /* MACROS *********************************************************************/
 613 #define SS7_DEBUG(a,...)        ftdm_log(FTDM_LOG_DEBUG,a , ##__VA_ARGS__ );
 614 #define SS7_INFO(a,...)  ftdm_log(FTDM_LOG_INFO,a , ##__VA_ARGS__ );
 615 #define SS7_WARN(a,...)  ftdm_log(FTDM_LOG_WARNING,a , ##__VA_ARGS__ );
 616 #define SS7_ERROR(a,...)        ftdm_log(FTDM_LOG_ERROR,a , ##__VA_ARGS__ );
 617 #define SS7_CRITICAL(a,...) ftdm_log(FTDM_LOG_CRIT,a , ##__VA_ARGS__ );
 618 
 619 #define SS7_DEBUG_CHAN(fchan, msg, args...)     ftdm_log_chan(fchan, FTDM_LOG_DEBUG, msg , ##args)
 620 #define SS7_INFO_CHAN(fchan, msg, args...)      ftdm_log_chan(fchan, FTDM_LOG_INFO, msg , ##args)
 621 #define SS7_WARN_CHAN(fchan, msg, args...)      ftdm_log_chan(fchan, FTDM_LOG_WARNING, msg , ##args)
 622 #define SS7_ERROR_CHAN(fchan, msg, args...)     ftdm_log_chan(fchan, FTDM_LOG_ERROR, msg , ##args)
 623 #define SS7_CTRIT_CHAN(fchan, msg, args...)     ftdm_log_chan(fchan, FTDM_LOG_CRIT, msg , ##args)
 624 
 625 #ifdef KONRAD_DEVEL
 626 #define SS7_DEVEL_DEBUG(a,...)   ftdm_log(FTDM_LOG_DEBUG,a,##__VA_ARGS__ );
 627 #else
 628 #define SS7_DEVEL_DEBUG(a,...)
 629 #endif
 630 
 631 #define SS7_FUNC_TRACE_ENTER(a) if (g_ftdm_sngss7_data.function_trace) { \
 632                                                                         switch (g_ftdm_sngss7_data.function_trace_level) { \
 633                                                                                 case 0: \
 634                                                                                         ftdm_log(FTDM_LOG_EMERG,"Entering %s\n", a); \
 635                                                                                         break; \
 636                                                                                 case 1: \
 637                                                                                         ftdm_log(FTDM_LOG_ALERT,"Entering %s\n", a); \
 638                                                                                         break; \
 639                                                                                 case 2: \
 640                                                                                         ftdm_log(FTDM_LOG_CRIT,"Entering %s\n", a); \
 641                                                                                         break; \
 642                                                                                 case 3: \
 643                                                                                         ftdm_log(FTDM_LOG_ERROR,"Entering %s\n", a); \
 644                                                                                         break; \
 645                                                                                 case 4: \
 646                                                                                         ftdm_log(FTDM_LOG_WARNING,"Entering %s\n", a); \
 647                                                                                         break; \
 648                                                                                 case 5: \
 649                                                                                         ftdm_log(FTDM_LOG_NOTICE,"Entering %s\n", a); \
 650                                                                                         break; \
 651                                                                                 case 6: \
 652                                                                                         ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
 653                                                                                         break; \
 654                                                                                 case 7: \
 655                                                                                         ftdm_log(FTDM_LOG_DEBUG,"Entering %s\n", a); \
 656                                                                                         break; \
 657                                                                                 default: \
 658                                                                                         ftdm_log(FTDM_LOG_INFO,"Entering %s\n", a); \
 659                                                                                         break; \
 660                                                                                 } /* switch (g_ftdm_sngss7_data.function_trace_level) */ \
 661                                                                 } /*  if(g_ftdm_sngss7_data.function_trace) */
 662 
 663 #define SS7_FUNC_TRACE_EXIT(a) if (g_ftdm_sngss7_data.function_trace) { \
 664                                                                         switch (g_ftdm_sngss7_data.function_trace_level) { \
 665                                                                                 case 0: \
 666                                                                                         ftdm_log(FTDM_LOG_EMERG,"Exitting %s\n", a); \
 667                                                                                         break; \
 668                                                                                 case 1: \
 669                                                                                         ftdm_log(FTDM_LOG_ALERT,"Exitting %s\n", a); \
 670                                                                                         break; \
 671                                                                                 case 2: \
 672                                                                                         ftdm_log(FTDM_LOG_CRIT,"Exitting %s\n", a); \
 673                                                                                         break; \
 674                                                                                 case 3: \
 675                                                                                         ftdm_log(FTDM_LOG_ERROR,"Exitting %s\n", a); \
 676                                                                                         break; \
 677                                                                                 case 4: \
 678                                                                                         ftdm_log(FTDM_LOG_WARNING,"Exitting %s\n", a); \
 679                                                                                         break; \
 680                                                                                 case 5: \
 681                                                                                         ftdm_log(FTDM_LOG_NOTICE,"Exitting %s\n", a); \
 682                                                                                         break; \
 683                                                                                 case 6: \
 684                                                                                         ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
 685                                                                                         break; \
 686                                                                                 case 7: \
 687                                                                                         ftdm_log(FTDM_LOG_DEBUG,"Exitting %s\n", a); \
 688                                                                                         break; \
 689                                                                                 default: \
 690                                                                                         ftdm_log(FTDM_LOG_INFO,"Exitting %s\n", a); \
 691                                                                                         break; \
 692                                                                                 } /* switch (g_ftdm_sngss7_data.function_trace_level) */ \
 693                                                                 } /*  if(g_ftdm_sngss7_data.function_trace) */
 694 
 695 #define SS7_MSG_TRACE(fchan, sngss7info ,msg) if (g_ftdm_sngss7_data.message_trace) { \
 696                                                                 switch (g_ftdm_sngss7_data.message_trace_level) { \
 697                                                                         case 0: \
 698                                                                                 ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 699                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 700                                                                                 break; \
 701                                                                         case 1: \
 702                                                                                 ftdm_log_chan(fchan, FTDM_LOG_ALERT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 703                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 704                                                                                 break; \
 705                                                                         case 2: \
 706                                                                                 ftdm_log_chan(fchan, FTDM_LOG_CRIT, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 707                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 708                                                                                 break; \
 709                                                                         case 3: \
 710                                                                                 ftdm_log_chan(fchan, FTDM_LOG_ERROR, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 711                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 712                                                                                 break; \
 713                                                                         case 4: \
 714                                                                                 ftdm_log_chan(fchan, FTDM_LOG_WARNING, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 715                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 716                                                                                 break; \
 717                                                                         case 5: \
 718                                                                                 ftdm_log_chan(fchan, FTDM_LOG_NOTICE, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 719                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 720                                                                                 break; \
 721                                                                         case 6: \
 722                                                                                 ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 723                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 724                                                                                 break; \
 725                                                                         case 7: \
 726                                                                                 ftdm_log_chan(fchan, FTDM_LOG_DEBUG, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 727                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 728                                                                                 break; \
 729                                                                         default: \
 730                                                                                 ftdm_log_chan(fchan, FTDM_LOG_INFO, "[CIC:%d][SPINSTID:%d][SUINSTID:%d]%s", \
 731                                                                                                                 sngss7info->circuit->cic,sngss7info->spInstId,sngss7info->suInstId, msg); \
 732                                                                                 break; \
 733                                                                         } /* switch (g_ftdm_sngss7_data.message_trace_level) */ \
 734                                                         } /* if(g_ftdm_sngss7_data.message_trace) */
 735 
 736 #define sngss7_test_flag(obj, flag)  ((obj)->flags & flag)
 737 #define sngss7_clear_flag(obj, flag) ((obj)->flags &= ~(flag))
 738 #define sngss7_set_flag(obj, flag)   ((obj)->flags |= (flag))
 739 
 740 #define sngss7_test_options(obj, option) ((obj)->options & option)
 741 #define sngss7_clear_options(obj, option) ((obj)->options &= ~(option))
 742 #define sngss7_set_options(obj, option)   ((obj)->options |= (option))
 743 
 744 
 745 #ifdef SS7_PRODUCTION
 746 # define SS7_ASSERT \
 747         SS7_INFO_CHAN(ftdmchan,"Production Mode, continuing%s\n", "");
 748 #else
 749 # define SS7_ASSERT     \
 750         SS7_ERROR_CHAN(ftdmchan, "Debugging Mode, ending%s\n", ""); \
 751         *(int*)0=0;
 752 #endif
 753 /******************************************************************************/
 754 
 755 /******************************************************************************/
 756 #endif /* __FTMOD_SNG_SS7_H__ */
 757 /******************************************************************************/
 758 
 759 /******************************************************************************/
 760 /* For Emacs:
 761  * Local Variables:
 762  * mode:c
 763  * indent-tabs-mode:t
 764  * tab-width:4
 765  * c-basic-offset:4
 766  * End:
 767  * For VIM:
 768  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 769  */
 770 /******************************************************************************/

/* [<][>][^][v][top][bottom][index][help] */