On Fri, May 27, 2005 at 08:49:37AM -0700, Kevin P. Fleming wrote:
> Luigi Rizzo wrote:
> > I notice that chan_sip.c has the option, when given a regcontext
> > argument in sip.conf, to register an entry in the dialplan of the form
> > 
> >     exten => 3456,1,Noop(3456)
> 
> Right, so in that context, you have also:
> 
> exten => _3XXX,2,Dial(SIP/${EXTEN})

but the latter you must write manually in the dialplan,
in addition to the entry in sip.conf.

I'd like to minimize the amount of replicated info in managing the config
files.
The attached (trivial) patch implements a 'regcommand' option in
sip.conf which lets you replace the default Noop(${EXTEN})
with anything you like. Most useful with something like

        regcommand=acro(newpeer,${EXTEN})

it may well be similar to the one mentioned in the other post, which
i have no access to at the momento...

cheers
luigi


A
so for each client
> Using 'regcontext' allows your dialplan to quickly know that a SIP peer 
> is not available, rather than attempting a dial (which allows the 
> dialplan to take alternative action if need be).
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev@lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.742
diff -u -r1.742 chan_sip.c
--- chan_sip.c  25 May 2005 20:03:09 -0000      1.742
+++ chan_sip.c  27 May 2005 19:06:05 -0000
@@ -273,6 +279,11 @@
 #define DEFAULT_REALM  "asterisk"
 static char global_realm[MAXHOSTNAMELEN] = DEFAULT_REALM;      /* Default 
realm */
 static char regcontext[AST_MAX_EXTENSION] = "";                /* Context for 
auto-extensions */
+/*
+ * command to register for regcontext
+ */
+static char regcommand[AST_MAX_EXTENSION] = "";
+static char *regarg = NULL;
 
 /* Expire slowly */
 #define DEFAULT_EXPIRY 900
@@ -1263,7 +1274,7 @@
                stringp = multi;
                while((ext = strsep(&stringp, "&"))) {
                        if (onoff)
-                               ast_add_extension(regcontext, 1, ext, 1, NULL, 
NULL, "Noop", strdup(peer->name), free, channeltype);
+                               ast_add_extension(regcontext, 1, ext, 1, NULL, 
NULL, regcommand, regarg, NULL, channeltype);
                        else
                                ast_context_remove_extension(regcontext, ext, 
1, NULL);
                }
@@ -10425,6 +10436,22 @@
        return peer;
 }
 
+static void init_regcommand(const char *s)
+{
+       strncpy(regcommand, s, sizeof(regcommand) - 1);
+       regarg = strchr(regcommand, '(');
+       if (regarg == NULL)
+               regarg = "";
+       else {
+               char *p;
+               *regarg++ = '\0';
+               p = strrchr(regarg, ')');
+               if (p)
+                       *p = '\0';
+       }
+}
+
+
 /*--- reload_config: Re-read SIP.conf config file ---*/
 /*     This function reloads all config data, except for
        active peers (with registrations). They will only
@@ -10446,6 +10473,7 @@
        char iabuf[INET_ADDRSTRLEN];
        struct ast_flags dummy;
        
+       init_regcommand("Noop(${EXTEN})");
        cfg = ast_config_load(config);
 
        /* We *must* have a config file otherwise stop immediately */
@@ -10560,6 +10588,8 @@
                        ast_copy_string(global_musicclass, v->value, 
sizeof(global_musicclass));
                } else if (!strcasecmp(v->name, "language")) {
                        ast_copy_string(default_language, v->value, 
sizeof(default_language));
+               } else if (!strcasecmp(v->name, "regcommand")) {
+                       init_regcommand(v->value);
                } else if (!strcasecmp(v->name, "regcontext")) {
                        ast_copy_string(regcontext, v->value, 
sizeof(regcontext));
                        /* Create context if it doesn't exist already */
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to