Made chan_dahdi able to ignore incoming calls that are not in a MSN list for ISDN...
authorRichard Mudgett <rmudgett@digium.com>
Wed, 2 Sep 2009 23:25:33 +0000 (23:25 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 2 Sep 2009 23:25:33 +0000 (23:25 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@215757 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
channels/chan_dahdi.c
channels/sig_pri.c
channels/sig_pri.h
configs/chan_dahdi.conf.sample

diff --git a/CHANGES b/CHANGES
index a59aff1..533c45c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -189,6 +189,8 @@ libpri channel driver (chan_dahdi) DAHDI changes
    will update the redirecting-to presentation (COLR) when it becomes available.
  * Added Reverse Charging Indication receipt & transmission (requires latest
    LibPRI).
+ * Added the ability to ignore calls that are not in a Multiple Subscriber
+   Number (MSN) list for PTMP CPE interfaces.
 
 Asterisk Manager Interface
 --------------------------
index 57715cc..7f4c7f6 100644 (file)
@@ -10843,6 +10843,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                                                pris[span].pri.inbanddisconnect = conf->pri.pri.inbanddisconnect;
 #endif
                                                pris[span].pri.facilityenable = conf->pri.pri.facilityenable;
+                                               ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list, sizeof(pris[span].pri.msn_list));
                                                ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial, sizeof(pris[span].pri.idledial));
                                                ast_copy_string(pris[span].pri.idleext, conf->pri.pri.idleext, sizeof(pris[span].pri.idleext));
                                                ast_copy_string(pris[span].pri.internationalprefix, conf->pri.pri.internationalprefix, sizeof(pris[span].pri.internationalprefix));
@@ -15614,6 +15615,9 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
                                        ast_log(LOG_ERROR, "Unknown switchtype '%s' at line %d.\n", v->value, v->lineno);
                                        return -1;
                                }
+                       } else if (!strcasecmp(v->name, "msn")) {
+                               ast_copy_string(confp->pri.pri.msn_list, v->value,
+                                       sizeof(confp->pri.pri.msn_list));
                        } else if (!strcasecmp(v->name, "nsf")) {
                                if (!strcasecmp(v->value, "sdn"))
                                        confp->pri.pri.nsf = PRI_NSF_SDN;
index 9276ebb..7dcbd67 100644 (file)
@@ -1001,6 +1001,39 @@ void pri_event_noalarm(struct sig_pri_pri *pri, int index, int before_start_pri)
 
 /*!
  * \internal
+ * \brief Determine if the given extension matches one of the MSNs in the pattern list.
+ * \since 1.6.3
+ *
+ * \param msn_patterns Comma separated list of MSN patterns to match.
+ * \param exten Extension to match in the MSN list.
+ *
+ * \retval 1 if matches.
+ * \retval 0 if no match.
+ */
+static int sig_pri_msn_match(const char *msn_patterns, const char *exten)
+{
+       char *pattern;
+       char *msn_list;
+       char *list_tail;
+
+       msn_list = strdupa(msn_patterns);
+
+       list_tail = NULL;
+       pattern = strtok_r(msn_list, ",", &list_tail);
+       while (pattern) {
+               pattern = ast_strip(pattern);
+               if (!ast_strlen_zero(pattern) && ast_extension_match(pattern, exten)) {
+                       /* Extension matched the pattern. */
+                       return 1;
+               }
+               pattern = strtok_r(NULL, ",", &list_tail);
+       }
+       /* Did not match any pattern in the list. */
+       return 0;
+}
+
+/*!
+ * \internal
  * \brief Obtain the sig_pri owner channel lock if the owner exists.
  * \since 1.6.3
  *
@@ -1621,6 +1654,15 @@ static void *pri_dchannel(void *vpri)
                                break;
 #endif
                        case PRI_EVENT_RING:
+                               if (!ast_strlen_zero(pri->msn_list)
+                                       && !sig_pri_msn_match(pri->msn_list, e->ring.callednum)) {
+                                       /* The call is not for us so ignore it. */
+                                       ast_verb(3,
+                                               "Ignoring call to '%s' on span %d.  Its not in the MSN list: %s\n",
+                                               e->ring.callednum, pri->span, pri->msn_list);
+                                       pri_destroycall(pri->pri, e->ring.call);
+                                       break;
+                               }
                                if (e->ring.channel == -1)
                                        chanpos = pri_find_empty_chan(pri, 1);
                                else
index 91de16f..40dad9d 100644 (file)
@@ -195,6 +195,7 @@ struct sig_pri_pri {
        char privateprefix[20];                                 /*!< for private dialplans */
        char unknownprefix[20];                                 /*!< for unknown dialplans */
        long resetinterval;                                             /*!< Interval (in seconds) for resetting unused channels */
+       char msn_list[AST_MAX_EXTENSION];               /*!< Comma separated list of MSNs to handle.  Empty if disabled. */
        char idleext[AST_MAX_EXTENSION];                /*!< Where to idle extra calls */
        char idlecontext[AST_MAX_CONTEXT];              /*!< What context to use for idle */
        char idledial[AST_MAX_EXTENSION];               /*!< What to dial before dumping */
index fe81874..5f8d2b2 100644 (file)
 ;
 ;switchtype=euroisdn
 ;
+; MSNs for ISDN spans.  Asterisk will listen for the listed numbers on
+; incoming calls and ignore any calls not listed.
+; Here you can give a comma separated list of numbers or dialplan extension
+; patterns.  An empty list disables MSN matching to allow any incoming call.
+; Only set on PTMP CPE side of ISDN span if needed.
+; The default is an empty list.
+;msn=
+;
 ; Some switches (AT&T especially) require network specific facility IE.
 ; Supported values are currently 'none', 'sdn', 'megacom', 'tollfreemegacom', 'accunet'
 ;