root/src/ftmod/ftmod_sangoma_ss7/ftmod_sangoma_ss7_cntrl.c

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

DEFINITIONS

This source file includes following definitions.
  1. ft_to_sngss7_activate_all
  2. ftmod_ss7_enable_isap
  3. ftmod_ss7_enable_nsap
  4. ftmod_ss7_enable_mtpLinkSet
  5. ftmod_ss7_inhibit_mtplink
  6. ftmod_ss7_uninhibit_mtplink
  7. ftmod_ss7_activate_mtplink
  8. ftmod_ss7_deactivate_mtplink
  9. ftmod_ss7_deactivate2_mtplink
  10. ftmod_ss7_activate_mtplinkSet
  11. ftmod_ss7_deactivate_mtplinkSet
  12. ftmod_ss7_deactivate2_mtplinkSet
  13. ftmod_ss7_lpo_mtplink
  14. ftmod_ss7_lpr_mtplink

   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 /* INCLUDE ********************************************************************/
  35 #include "ftmod_sangoma_ss7_main.h"
  36 /******************************************************************************/
  37 
  38 /* DEFINES ********************************************************************/
  39 /******************************************************************************/
  40 
  41 /* GLOBALS ********************************************************************/
  42 /******************************************************************************/
  43 
  44 /* PROTOTYPES *****************************************************************/
  45 int ft_to_sngss7_activate_all(void);
  46 
  47 static int ftmod_ss7_enable_isap(int suId);
  48 static int ftmod_ss7_enable_nsap(int suId);
  49 static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId);
  50 
  51 int ftmod_ss7_inhibit_mtplink(uint32_t id);
  52 int ftmod_ss7_uninhibit_mtplink(uint32_t id);
  53 
  54 int ftmod_ss7_activate_mtplink(uint32_t id);
  55 int ftmod_ss7_deactivate_mtplink(uint32_t id);
  56 int ftmod_ss7_deactivate2_mtplink(uint32_t id);
  57 
  58 int ftmod_ss7_activate_mtplinkSet(uint32_t id);
  59 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id);
  60 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id);
  61 
  62 int ftmod_ss7_lpo_mtplink(uint32_t id);
  63 int ftmod_ss7_lpr_mtplink(uint32_t id);
  64 /******************************************************************************/
  65 
  66 /* FUNCTIONS ******************************************************************/
  67 int ft_to_sngss7_activate_all(void)
  68 {
  69         int x;
  70 
  71         x = 1;
  72         while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) {
  73                 /* check if this link has already been actived */
  74                 if (!(g_ftdm_sngss7_data.cfg.isap[x].flags & ACTIVE)) {
  75 
  76                         if (ftmod_ss7_enable_isap(x)) { 
  77                                 SS7_CRITICAL("ISAP %d Enable: NOT OK\n", x);
  78                                 return 1;
  79                         } else {
  80                                 SS7_INFO("ISAP %d Enable: OK\n", x);
  81                         }
  82 
  83                         /* set the ACTIVE flag */
  84                         g_ftdm_sngss7_data.cfg.isap[x].flags |= ACTIVE;
  85                 } /* if !ACTIVE */
  86                 
  87                 x++;
  88         } /* while (g_ftdm_sngss7_data.cfg.isap[x].id != 0) */
  89 
  90         x = 1;
  91         while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) {
  92                 /* check if this link has already been actived */
  93                 if (!(g_ftdm_sngss7_data.cfg.nsap[x].flags & ACTIVE)) {
  94 
  95                         if (ftmod_ss7_enable_nsap(x)) { 
  96                                 SS7_CRITICAL("NSAP %d Enable: NOT OK\n", x);
  97                                 return 1;
  98                         } else {
  99                                 SS7_INFO("NSAP %d Enable: OK\n", x);
 100                         }
 101 
 102                         /* set the ACTIVE flag */
 103                         g_ftdm_sngss7_data.cfg.nsap[x].flags |= ACTIVE;
 104                 } /* if !ACTIVE */
 105                 
 106                 x++;
 107         } /* while (g_ftdm_sngss7_data.cfg.nsap[x].id != 0) */
 108 
 109         x = 1;
 110         while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) {
 111                 /* check if this link has already been actived */
 112                 if (!(g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags & ACTIVE)) {
 113 
 114                         if (ftmod_ss7_enable_mtpLinkSet(x)) {   
 115                                 SS7_CRITICAL("LinkSet \"%s\" Enable: NOT OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
 116                                 return 1;
 117                         } else {
 118                                 SS7_INFO("LinkSet \"%s\" Enable: OK\n", g_ftdm_sngss7_data.cfg.mtpLinkSet[x].name);
 119                         }
 120 
 121                         /* set the ACTIVE flag */
 122                         g_ftdm_sngss7_data.cfg.mtpLinkSet[x].flags |= ACTIVE;
 123                 } /* if !ACTIVE */
 124                 
 125                 x++;
 126         } /* while (g_ftdm_sngss7_data.cfg.mtpLinkSet[x].id != 0) */
 127 
 128         return 0;
 129 }
 130 
 131 /******************************************************************************/
 132 static int ftmod_ss7_enable_isap(int suId)
 133 {
 134         CcMngmt cntrl;
 135         Pst pst;
 136 
 137         /* initalize the post structure */
 138         smPstInit(&pst);
 139 
 140         /* insert the destination Entity */
 141         pst.dstEnt = ENTCC;
 142 
 143         /* initalize the control structure */
 144         memset(&cntrl, 0x0, sizeof(CcMngmt));
 145 
 146         /* initalize the control header */
 147         smHdrInit(&cntrl.hdr);
 148 
 149         cntrl.hdr.msgType                       = TCNTRL;               /* this is a control request */
 150         cntrl.hdr.entId.ent                     = ENTCC;
 151         cntrl.hdr.entId.inst            = S_INST;
 152         cntrl.hdr.elmId.elmnt           = STISAP;
 153 
 154         cntrl.hdr.elmId.elmntInst1      = suId;                 /* this is the SAP to bind */
 155 
 156         cntrl.t.cntrl.action            = ABND_ENA;             /* bind and activate */
 157         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 158 
 159         return (sng_cntrl_cc(&pst, &cntrl));
 160 }
 161 
 162 /******************************************************************************/
 163 static int ftmod_ss7_enable_nsap(int suId)
 164 {
 165         SiMngmt cntrl;
 166         Pst pst;
 167 
 168         /* initalize the post structure */
 169         smPstInit(&pst);
 170 
 171         /* insert the destination Entity */
 172         pst.dstEnt = ENTSI;
 173 
 174         /* initalize the control structure */
 175         memset(&cntrl, 0x0, sizeof(SiMngmt));
 176 
 177         /* initalize the control header */
 178         smHdrInit(&cntrl.hdr);
 179 
 180         cntrl.hdr.msgType                       = TCNTRL;          /* this is a control request */
 181         cntrl.hdr.entId.ent                     = ENTSI;
 182         cntrl.hdr.entId.inst            = S_INST;
 183         cntrl.hdr.elmId.elmnt           = STNSAP;
 184 
 185         cntrl.t.cntrl.s.siElmnt.elmntId.sapId                           = suId; 
 186         cntrl.t.cntrl.s.siElmnt.elmntParam.nsap.nsapType        = SAP_MTP; 
 187 
 188 
 189         cntrl.t.cntrl.action            = ABND_ENA;             /* bind and activate */
 190         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 191 
 192         return (sng_cntrl_isup(&pst, &cntrl));
 193 }
 194 
 195 /******************************************************************************/
 196 static int ftmod_ss7_enable_mtpLinkSet(int lnkSetId)
 197 {
 198         SnMngmt cntrl;
 199         Pst pst;
 200 
 201         /* initalize the post structure */
 202         smPstInit(&pst);
 203 
 204         /* insert the destination Entity */
 205         pst.dstEnt = ENTSN;
 206 
 207         /* initalize the control structure */
 208         memset(&cntrl, 0x0, sizeof(SnMngmt));
 209 
 210         /* initalize the control header */
 211         smHdrInit(&cntrl.hdr);
 212 
 213         cntrl.hdr.msgType                       = TCNTRL;               /* this is a control request */
 214         cntrl.hdr.entId.ent                     = ENTSN;
 215         cntrl.hdr.entId.inst            = S_INST;
 216         cntrl.hdr.elmId.elmnt           = STLNKSET;
 217         cntrl.hdr.elmId.elmntInst1      = lnkSetId;             /* this is the linkset to bind */
 218 
 219         cntrl.t.cntrl.action            = ABND_ENA;             /* bind and activate */
 220         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 221 
 222         return (sng_cntrl_mtp3(&pst, &cntrl));
 223 }
 224 
 225 /******************************************************************************/
 226 int ftmod_ss7_inhibit_mtplink(uint32_t id)
 227 {
 228         SnMngmt cntrl;
 229         Pst pst;
 230 
 231         /* initalize the post structure */
 232         smPstInit(&pst);
 233 
 234         /* insert the destination Entity */
 235         pst.dstEnt = ENTSN;
 236 
 237         /* initalize the control structure */
 238         memset(&cntrl, 0x0, sizeof(SnMngmt));
 239 
 240         /* initalize the control header */
 241         smHdrInit(&cntrl.hdr);
 242 
 243         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 244         cntrl.hdr.entId.ent                     = ENTSN;
 245         cntrl.hdr.entId.inst            = S_INST;
 246         cntrl.hdr.elmId.elmnt           = STDLSAP;
 247         cntrl.hdr.elmId.elmntInst1      = id;           /* the DSLAP to inhibit  */
 248 
 249         cntrl.t.cntrl.action            = AINH;         /* Inhibit */
 250         cntrl.t.cntrl.subAction         = SAELMNT;      /* specificed element */
 251 
 252         return (sng_cntrl_mtp3(&pst, &cntrl));
 253 }
 254 
 255 /******************************************************************************/
 256 int ftmod_ss7_uninhibit_mtplink(uint32_t id)
 257 {
 258         SnMngmt cntrl;
 259         Pst pst;
 260 
 261         /* initalize the post structure */
 262         smPstInit(&pst);
 263 
 264         /* insert the destination Entity */
 265         pst.dstEnt = ENTSN;
 266 
 267         /* initalize the control structure */
 268         memset(&cntrl, 0x0, sizeof(SnMngmt));
 269 
 270         /* initalize the control header */
 271         smHdrInit(&cntrl.hdr);
 272 
 273         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 274         cntrl.hdr.entId.ent                     = ENTSN;
 275         cntrl.hdr.entId.inst            = S_INST;
 276         cntrl.hdr.elmId.elmnt           = STDLSAP;
 277         cntrl.hdr.elmId.elmntInst1      = id;           /* the DSLAP to inhibit  */
 278 
 279         cntrl.t.cntrl.action            = AUNINH;               /* Inhibit */
 280         cntrl.t.cntrl.subAction         = SAELMNT;      /* specificed element */
 281 
 282         return (sng_cntrl_mtp3(&pst, &cntrl));
 283 }
 284 
 285 /******************************************************************************/
 286 int ftmod_ss7_activate_mtplink(uint32_t id)
 287 {
 288         SnMngmt cntrl;
 289         Pst pst;
 290 
 291         /* initalize the post structure */
 292         smPstInit(&pst);
 293 
 294         /* insert the destination Entity */
 295         pst.dstEnt = ENTSN;
 296 
 297         /* initalize the control structure */
 298         memset(&cntrl, 0x0, sizeof(SnMngmt));
 299 
 300         /* initalize the control header */
 301         smHdrInit(&cntrl.hdr);
 302 
 303         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 304         cntrl.hdr.entId.ent                     = ENTSN;
 305         cntrl.hdr.entId.inst            = S_INST;
 306         cntrl.hdr.elmId.elmnt           = STDLSAP;
 307         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
 308 
 309         cntrl.t.cntrl.action            = AENA;         /* Activate */
 310         cntrl.t.cntrl.subAction         = SAELMNT;      /* specificed element */
 311 
 312         return (sng_cntrl_mtp3(&pst, &cntrl));
 313 }
 314 
 315 /******************************************************************************/
 316 int ftmod_ss7_deactivate_mtplink(uint32_t id)
 317 {
 318         SnMngmt cntrl;
 319         Pst pst;
 320 
 321         /* initalize the post structure */
 322         smPstInit(&pst);
 323 
 324         /* insert the destination Entity */
 325         pst.dstEnt = ENTSN;
 326 
 327         /* initalize the control structure */
 328         memset(&cntrl, 0x0, sizeof(SnMngmt));
 329 
 330         /* initalize the control header */
 331         smHdrInit(&cntrl.hdr);
 332 
 333         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 334         cntrl.hdr.entId.ent                     = ENTSN;
 335         cntrl.hdr.entId.inst            = S_INST;
 336         cntrl.hdr.elmId.elmnt           = STDLSAP;
 337         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
 338 
 339         cntrl.t.cntrl.action            = ADISIMM;      /* Deactivate */
 340         cntrl.t.cntrl.subAction         = SAELMNT;      /* specificed element */
 341 
 342         return (sng_cntrl_mtp3(&pst, &cntrl));
 343 }
 344 
 345 /******************************************************************************/
 346 int ftmod_ss7_deactivate2_mtplink(uint32_t id)
 347 {
 348         SnMngmt cntrl;
 349         Pst pst;
 350 
 351         /* initalize the post structure */
 352         smPstInit(&pst);
 353 
 354         /* insert the destination Entity */
 355         pst.dstEnt = ENTSN;
 356 
 357         /* initalize the control structure */
 358         memset(&cntrl, 0x0, sizeof(SnMngmt));
 359 
 360         /* initalize the control header */
 361         smHdrInit(&cntrl.hdr);
 362 
 363         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 364         cntrl.hdr.entId.ent                     = ENTSN;
 365         cntrl.hdr.entId.inst            = S_INST;
 366         cntrl.hdr.elmId.elmnt           = STDLSAP;
 367         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
 368 
 369         cntrl.t.cntrl.action            = ADISIMM_L2;   /* Deactivate...layer 2 only */
 370         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 371 
 372         return (sng_cntrl_mtp3(&pst, &cntrl));
 373 }
 374 
 375 /******************************************************************************/
 376 int ftmod_ss7_activate_mtplinkSet(uint32_t id)
 377 {
 378         SnMngmt cntrl;
 379         Pst pst;
 380 
 381         /* initalize the post structure */
 382         smPstInit(&pst);
 383 
 384         /* insert the destination Entity */
 385         pst.dstEnt = ENTSN;
 386 
 387         /* initalize the control structure */
 388         memset(&cntrl, 0x0, sizeof(SnMngmt));
 389 
 390         /* initalize the control header */
 391         smHdrInit(&cntrl.hdr);
 392 
 393         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 394         cntrl.hdr.entId.ent                     = ENTSN;
 395         cntrl.hdr.entId.inst            = S_INST;
 396         cntrl.hdr.elmId.elmnt           = STLNKSET;
 397         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
 398 
 399         cntrl.t.cntrl.action            = AACTLNKSET;   /* Activate */
 400         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 401 
 402         return (sng_cntrl_mtp3(&pst, &cntrl));
 403 }
 404 
 405 /******************************************************************************/
 406 int ftmod_ss7_deactivate_mtplinkSet(uint32_t id)
 407 {
 408         SnMngmt cntrl;
 409         Pst pst;
 410 
 411         /* initalize the post structure */
 412         smPstInit(&pst);
 413 
 414         /* insert the destination Entity */
 415         pst.dstEnt = ENTSN;
 416 
 417         /* initalize the control structure */
 418         memset(&cntrl, 0x0, sizeof(SnMngmt));
 419 
 420         /* initalize the control header */
 421         smHdrInit(&cntrl.hdr);
 422 
 423         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 424         cntrl.hdr.entId.ent                     = ENTSN;
 425         cntrl.hdr.entId.inst            = S_INST;
 426         cntrl.hdr.elmId.elmnt           = STLNKSET;
 427         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
 428 
 429         cntrl.t.cntrl.action            = ADEACTLNKSET; /* Activate */
 430         cntrl.t.cntrl.subAction         = SAELMNT;              /* specificed element */
 431 
 432         return (sng_cntrl_mtp3(&pst, &cntrl));
 433 }
 434 
 435 /******************************************************************************/
 436 int ftmod_ss7_deactivate2_mtplinkSet(uint32_t id)
 437 {
 438         SnMngmt cntrl;
 439         Pst pst;
 440 
 441         /* initalize the post structure */
 442         smPstInit(&pst);
 443 
 444         /* insert the destination Entity */
 445         pst.dstEnt = ENTSN;
 446 
 447         /* initalize the control structure */
 448         memset(&cntrl, 0x0, sizeof(SnMngmt));
 449 
 450         /* initalize the control header */
 451         smHdrInit(&cntrl.hdr);
 452 
 453         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 454         cntrl.hdr.entId.ent                     = ENTSN;
 455         cntrl.hdr.entId.inst            = S_INST;
 456         cntrl.hdr.elmId.elmnt           = STLNKSET;
 457         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLinkSet[id].id;
 458 
 459         cntrl.t.cntrl.action            = ADEACTLNKSET_L2;      /* Activate */
 460         cntrl.t.cntrl.subAction         = SAELMNT;                      /* specificed element */
 461 
 462         return (sng_cntrl_mtp3(&pst, &cntrl));
 463 }
 464 
 465 /******************************************************************************/
 466 int ftmod_ss7_lpo_mtplink(uint32_t id)
 467 {
 468         SnMngmt cntrl;
 469         Pst pst;
 470 
 471         /* initalize the post structure */
 472         smPstInit(&pst);
 473 
 474         /* insert the destination Entity */
 475         pst.dstEnt = ENTSN;
 476 
 477         /* initalize the control structure */
 478         memset(&cntrl, 0x0, sizeof(SnMngmt));
 479 
 480         /* initalize the control header */
 481         smHdrInit(&cntrl.hdr);
 482 
 483         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 484         cntrl.hdr.entId.ent                     = ENTSN;
 485         cntrl.hdr.entId.inst            = S_INST;
 486         cntrl.hdr.elmId.elmnt           = STDLSAP;
 487         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
 488 
 489         cntrl.t.cntrl.action            = ACTION_LPO;   /* Activate */
 490         cntrl.t.cntrl.subAction         = SAELMNT;                      /* specificed element */
 491 
 492         return (sng_cntrl_mtp3(&pst, &cntrl));
 493 }
 494 
 495 /******************************************************************************/
 496 int ftmod_ss7_lpr_mtplink(uint32_t id)
 497 {
 498         SnMngmt cntrl;
 499         Pst pst;
 500 
 501         /* initalize the post structure */
 502         smPstInit(&pst);
 503 
 504         /* insert the destination Entity */
 505         pst.dstEnt = ENTSN;
 506 
 507         /* initalize the control structure */
 508         memset(&cntrl, 0x0, sizeof(SnMngmt));
 509 
 510         /* initalize the control header */
 511         smHdrInit(&cntrl.hdr);
 512 
 513         cntrl.hdr.msgType                       = TCNTRL;       /* this is a control request */
 514         cntrl.hdr.entId.ent                     = ENTSN;
 515         cntrl.hdr.entId.inst            = S_INST;
 516         cntrl.hdr.elmId.elmnt           = STDLSAP;
 517         cntrl.hdr.elmId.elmntInst1      = g_ftdm_sngss7_data.cfg.mtpLink[id].id;
 518 
 519         cntrl.t.cntrl.action            = ACTION_LPR;   /* Activate */
 520         cntrl.t.cntrl.subAction         = SAELMNT;                      /* specificed element */
 521 
 522         return (sng_cntrl_mtp3(&pst, &cntrl));
 523 }
 524 
 525 /******************************************************************************/
 526 
 527 /******************************************************************************/
 528 /* For Emacs:
 529  * Local Variables:
 530  * mode:c
 531  * indent-tabs-mode:t
 532  * tab-width:4
 533  * c-basic-offset:4
 534  * End:
 535  * For VIM:
 536  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 537  */
 538 /******************************************************************************/
 539 

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