The *MYSTERIOUS* extension 's'

[quote=“dgarstang”]sigh Yes. I am dialling a non existent extension.

That-is-what-the-s-extention-is-supposed-to-handle.

“This is the start extension. If a call comes in on a given context that does not have an extension associated with it, the call will begin at this extension”[/quote]

Obviously, it does not work the way you are trying to use it, correct? The wiki is a community built collection of information, not always accurate. You are welcome to update the wiki with the appropriate information that makes this clear to you, just as you are welcome to change the source of Asterisk to perform the way you want it to (provided you do not violate the GPL).

Stop trying to fit square pegs through round holes.

I don’t see it like that. The configurations that I have tried have been as simple as I can possibly make them, based on what I have read at various locations. The only thing that I can assume is that all these sources of information are leaving out some vital piece of information, and are over-simplifying the examples.

Indeed, this may be the case. But what is your point?

You have been given examples here that will work, been offered direct support and given the opportunity to ask questions to lots of different folks, some of whom have responded. If you refuse to take recommendations on board (which is the whole point of this forum), then you will be the one to lose out and end up failing at your Asterisk project. Your choice.

Here is an example (simplified) of a live working extensions.conf and AEL setup to do call processing with an ‘s’ extension, where an IPKALL number is forwarded to a SIP URI ipkall@mydomain.com:

[quote=“/etc/asterisk/extensions.conf”][default] exten => ipkall,1,Goto(us_menu|s|1)[/quote]

[quote=“/etc/asterisk/extensions.ael”][code]// Context used to manage incoming personal calls from the US
context us_menu {
s => {
Ringing();
Wait(2);
Set(TIMEOUT(digit)=2);
Set(TIMEOUT(response)=10);
Set(PRESSED_DIGITS=0);
Answer();
Wait(1);
Answer();
Macro(lookup-cli);
AGI(create_tts.pl|‘Hello ${cli_name} Welcome to the home of blah, blah, blah’);
Background(${TTS_FILE});
AGI(create_tts.pl|‘To speak with joe blow please press one, to speak with jane blow please press two, to speak to the kids please press 3’);
Background(${TTS_FILE});
};

    1 => {
            Macro(dial-usr|joeblow);
    };

    2 => {
            Macro(dial-usr|janeblow);
    };

    3 => {
            Playback(lots-o-monkeys);
            Hangup();
    };

    t => {
            goto us_menu|s|13;
    };

    i => {
            Playback(invalid);
            goto us_menu|s|13;
    };

};[/code][/quote]

Now, keep in mind you could use pattern matching and wildcards (‘.’) to create a similar dialplan:

voip-info.org/wiki/index.php … n+Patterns

[quote=“dgarstang”]sigh Yes. I am dialling a non existent extension.

That-is-what-the-s-extention-is-supposed-to-handle.

“This is the start extension. If a call comes in on a given context that does not have an extension associated with it, the call will begin at this extension”[/quote]

Wow, check back in and this thread is going on and on.

dgarstang, I believe your assumption above is incorrect. To asterisk there is a difference between an incorrect extension and no extension associated with a given context. While I admit I am still new to asterisk, I did take a little time yseterday and read some of the source code. If I understood it properly, the s extension is called when the extension string is empty or it is explicitly defined as s (i.e. a goto command where you can define context and extension in the call), not after a failed match. Macros are a little different as they are fixed to go to the s extension in the macro, that seems to be hard coded in the code.

sweazle: If that’s true, then i’ve hit a wall. The polycom phones I am using can’t send an empty Number/To: field.

From pbx.c, about line 1927:

 } else {
    /* No such extension */
   if (!ast_strlen_zero(exten)) {
           /* An invalid extension */
          if (ast_exists_extension(c, c->context, "i", 1, c->callerid)) {

I am no programmer but just the comments and code imply that if the extension wasn’t found and the extension string is not 0 length then the extension is invalid, check for an ‘i’ extension. Looking at surrounding code, I see no ‘s’ calls.

If you look at channels/chan_zap.c around line 4662 you will see:

/* if no extension was received ('unspecified') on overlap call, use the 's' extension */
  if (ast_strlen_zero(exten)) {
    if (option_verbose > 2)
        ast_verbose(VERBOSE_PREFIX_3 "Going to extension s|1 because of empty extension received on overlap call\n");
         exten[0] = 's';
         exten[1] = '\0';

So in a ZAP channel, if the extension string is 0 length, go to ‘s’.

lol So all the people who kept telling me that it should work, and that it worked for them, and that there was something wrong with me because mine didn’t work… but the rest of the world’s did… well… I dare not say anything nasty.

Thanks sweazle. I guess that settles it.

And you know what? I don’t think the fact it doesn’t work with SIP channels is documented ANYWHERE

While it doesn’t appear to work with SIP I think that is really due to the way SIP works. Though I don’t know what you need the system to do, I am yet to fail to find a way to do things in asterisk. With the channel variables you can tell who is trying to call where prior to setting up the call. You may want to see if the channel variables will provide the info you need to set up any variables/accounting/records you need to prior to dialing the target.

Bingo, and this is the point that dgarstang has failed to grasp throughout this whole process. Dgarstang’s wall is in his mind, not in Asterisk, as he has been told numerous times an extension is dialed and that it must exist as a SIP URI in his dialplan and how to work with that to acheive what he needs.

Well, he may not have learnt anything from the process, but he’s certainly been responsible for what must surely be the longest thread in this forum all year - possibly ever - which is an achievement in itself, i suppose! :wink:

Huh??? Say what?

MuppetMaster, you where responsible for this quote…

and BaconButtie was responsible for this…

Come on! I’ve been receiving misinformation this entire thread! The only thing I am guilty of is continuning to ask questions when I couldn’t get it to work, because people kept telling me it did! Good grief!

MuppetMaster said:

NO! The point of the s extension is to activate when a valid extension doesn’t exist. All the documentation says this. You DO NOT need to dial a valid extension for the s extension to get the call. That’s the point. It however, the documentation doesn’t mention that it does not work with SIP channels.

Seazle: Thanks, but that won’t work. The point was to set the variables before matching a dialled number. There’s no way in Asterisk to go VAR=VAL in a context (unless it’s [global])

Let me see. It isn’t documented anywhere. I can’t get it to work, repeatedly post questions with complete examples, repeatedly get accused of being an idiot because I can’t get it work. In the end we find out it isn’t supported, and my questions therefore all along where valid, and YOU have the audacity to claim I am at fault? What is wrong with you?

[quote=“dgarstang”]Huh??? Say what?

MuppetMaster, you where responsible for this quote…

And it does work, I use it all the time. As I stated before, with SIP something is ALWAYS dialed and you have to account for that when using the ‘s’ extension. You chose to ignore simple facts. Further, you may accomplish what you set out to do, why we are this far along with no results for you astounds me.

[quote=“dgarstang”]and BaconButtie was responsible for this…

Come on! I’ve been receiving misinformation this entire thread! The only thing I am guilty of is continuning to ask questions when I couldn’t get it to work, because people kept telling me it did! Good grief![/quote]

False, you have chosen to ignore the information provided. No, re-read the thread, you will see I told you how to account for needing a SIP URI available on the Asterisk box for this to work with SIP.

It does work, it requires you to account for the fact that you have to have a SIP URI defined. This thread is your documentation.

I have not seen anyone accusing you of being an idiot. Choosing to ignor information and continue to beat your head against the wall in your head is something entirely different. Further, I even offered to help you directly by creating the extensions configuration that would work for you in your environment, and you ignored this offer of assistance.

Your issue is solveable, period. Why continue to beat your head against the ‘wall’ as opposed to trying to do what it takes to solve the problem?

As stated by others in this thread, Asterisk is highly programmable and there is not much you can not acheive if you are willing to take varying approaches to issues and find the solutions.

sigh Back to basics. How can I make asterisk execute a set of code at the beginning of a context, BEFORE matching a dialled extension on a SIP channel?

Explain from beginning to end what you are trying to do. Based on everything I have seen thus far, there is no reason for you to ‘execute a piece of code BEFORE matching an extension’, as it seems you still fail to grasp how Asterisk fundamentally works.

It does work, when you have a SIP URI defined on the system, as you may use it for IVR menus, Macros, etc.

You have to ask Digium about that. I have never seen it.

Well, just generically, why not? Why wouldn’t you want to execute a piece of code before looking for extension matches in a context? What about overriding caller id for a user?

Also, if I can’t get the s extension to work (because SIP requires an extension, and the s extension never matches), I don’t see how I can put to use any of the IVR examples I’ve seen… the ones where they have:

[mainmenu]
exten => s,1,Answe
exten => s,1,Playback(IVR-main)

Btw, I still don’t understand why ‘s’ doesn’t work. My SIP calls always have a non-empty To: field. The s extension is designed to match when there’s no extension supplied. How can it work???

It is possible to override CallerID for a user based on the way Asterisk functions today. Why would this require a new feature within Asterisk?

[quote=“dgarstang”]Also, if I can’t get the s extension to work (because SIP requires an extension, and the s extension never matches), I don’t see how I can put to use any of the IVR examples I’ve seen… the ones where they have:

[mainmenu]
exten => s,1,Answe
exten => s,1,Playback(IVR-main)
…[/quote]

You are right, no one has IVR working on Asterisk using the ‘s’ capability with Asterisk… Mind you I provided an example in this very thread that works…

The SIP Proxy within Asterisk is rejecting the call before it ever gets to the extensions, hence why you get a SIP 404 ‘not found’ error, and never see anything executing via the verbose CLI. You are trying something like 'myuname@yourdomain.com’? This is how SIP functions, hence Asterisk is behaving correctly when rejecting an empty address, as it does not exist:

networksorcery.com/enp/rfc/rfc3261.txt

[quote=“RFC3261”]If the Request-URI does not identify an address that the UAS is willing to accept requests for, it SHOULD reject the request with a 404 (Not Found) response.

If the address-of-record is not valid for the domain in the Request-URI, the registrar MUST send a 404 (Not Found) response and skip the remaining steps.

If the Request-URI indicates a resource at this proxy that does not exist, the proxy MUST return a 404 (Not Found) response.[/quote]

You really are fighting understanding how Asterisk and SIP works, aren’t you?

No, I’m just fighting to understand how the s extension works. Everything else is fine. We have several polycom phones with multiple appearances, all registering and making calls. We can place calls internally, or send them out via SER to our PSTN Gateway. We’ve been testing advanced features such as ACD Queues and so on.

Yes, it’s possible to set caller id for a user. You can set caller id in the sip.conf file for a user. Take the situation where a company (yes, REAL people want to use Asterisk and require REAL functionaliy) has two appearences on two phones. When their main number rings, it rings both phones. They want calls from these phones to show the same caller id, which is the company’s main number, NOT the number of each phone. We can set the caller id of both extensions to be the same in sip.conf. However, this breaks other functionality that allows ACD agents to log into queues, or users of these phones to check voicemail by checking their caller id. I therefore wanted to set the caller id explicitly for each phone when they dial out.

Example? Are you referring to:

Won’t work. For startes users don’t dial 9 to get an outside line. They expect to be able to dial as if there was no PBX involved.

I understand perfectly how SIP works. What I don’t understand is why the s extension which is supposed to match an invalid extension doesn’t pick it up as all the documentation say it’s supposed to.

Then why are you grappling so hard with this concept?

It is possible to change dynamically based on the programmability of Asterisk.

You have not even begun to scratch the surface of what Asterisk is capable of.

Which is easily done with the existing capabilities of Asterisk.

Easy.

[quote=“dgarstang”]Example? Are you referring to:

Why not?

This is bordering on ludicrous, this is an example only. If your users do not like 9 for an outside line, then don’t require it! The choice is yours.

Find, just do _1X. then. Why not?

Because the SIP proxy within Asterisk requires that a SIP URI exists (‘s’ does not qualify, OBVIOUSLY) otherwise it behaves per the RFC and returns a SIP 404 error message. Which is exactly the behavior you are observing and have been told how to resolve in this thread.

Give me 5 and I will post with a solution for you, since you do not seem to be creative enough to figure it out on your own.

Below you will find a working example of an /etc/asterisk/extensions.ael complete with CLI output of the results (the before and after CALLERID in bold):

Note: /etc/asterisk/sip.conf was set to a callerid of 3004 and the context for that user is test_ob.

[code]context macro-set-prs-cli {
s => {
switch (${ARG1}) {
case 3004:
SetCallerID(789012);
break;
case 3005:
SetCallerID(123456);
break;
default:
NoOp(Nothing to set…);
};
};
};

context test_ob {
_X. => {
NoOp(${CALLERID});
Macro(set-prs-cli|${CALLERIDNUM});
NoOp(${CALLID});
Dial(SIP/${EXTEN});
};
};[/code]

[quote=“Verbose Asterisk CLI”] – Executing NoOp(“SIP/3004-ab4a”, “3004”) in new stack
– Executing Macro(“SIP/3004-ab4a”, “set-prs-cli|3004”) in new stack
– Executing Goto(“SIP/3004-ab4a”, “sw-s-1-3004|1”) in new stack
– Goto (macro-set-prs-cli,sw-s-1-3004,1)
– Executing SetCallerID(“SIP/3004-ab4a”, “789012”) in new stack
– Executing Goto(“SIP/3004-ab4a”, “s|2”) in new stack
– Goto (macro-set-prs-cli,s,2)
– Executing NoOp(“SIP/3004-ab4a”, “Finish switch-s-1”) in new stack
– Executing NoOp(“SIP/3004-ab4a”, “789012”) in new stack
– Executing Dial(“SIP/3004-ab4a”, “SIP/3000”) in new stack[/quote]

Now, please try and be a bit creative here, as you may:

  • Change the dial pattern matching to what you want
  • Instead of using a switch/case go to a database for matches
  • Set everything to one (the common) CallerID with a simple SetCallerID statement without even going out to a macro
  • etc

The point is, it is possible to set variables, including caller ID, as a part of pre-call processing as shown above.

Why was this so hard?

Ok, so a call comes in and matches the _X… What happens after that? We want processing to continue, looking for other extensions to match after executing the logic within _X.