Using ast_pbx_outgoing_exten_predial

I’m trying to modify res_clioriginate.c to dial an outgoing call and place into a local extension for playing an announcement.

Using PJSIP/sip0 I’m attempting to create an outgoing call and place into

  • context: new
  • extension: 123
  • Caller ID Number: 456
  • Caller ID Name: New
  • Predial: 789
ast_pbx_outgoing_exten_predial("PJSIP", cap, "sip0", 30000, "new",
	"123", 1, NULL, AST_OUTGOING_NO_WAIT, "456", "New",
	NULL, NULL, NULL, 0, NULL, "789");

However when I run this, I get the error:

[Dec  5 17:11:18] ERROR[2903]: app_stack.c:593 gosub_exec: Attempt to reach a non-existent destination for Gosub: (Context:incoming_calls, Extension:s, Priority:789)

I’m not sure why the call hasn’t been placed into context ‘new’ as extensions.conf contains:

exten => _X!,1,Answer()
exten => _X!,2,Playback(tt-monkeys)
exten => _X!,3,Hangup()

Can anyone explain what I’m doing wrong here?

Why does the existing functionality not work? What exactly are you trying to solve?

This isn’t an end user interface. There are mailing lists and IRC channels for developers, but, as Joshua indicates, using this interface is probably over-engineered.

Have you included the function prototype?

@jcolp I’m trying to create a custom asterisk resource which can trigger an outbound test call on demand. It’s very similar in functionality to res_clioriginate except its input interface will not be cli driven and so I thought res_clioriginate was a good starting point.
What other existing functionality are you referring to?

@david551 I presume you mean

int ast_pbx_outgoing_exten_predial(const char *type, struct ast_format_cap *cap, const char *addr,
	int timeout, const char *context, const char *exten, int priority, int *reason,
	int synchronous, const char *cid_num, const char *cid_name, struct ast_variable *vars,
	const char *account, struct ast_channel **locked_channel, int early_media,
	const struct ast_assigned_ids *assignedids, const char *predial_callee);

I have no problem executing the function. I can see PJSIP SIP traffic on the console suggesting it’s worked, however the To field isn’t correct and Asterisk seems to make an outbound call to itself.

[Dec  5 17:11:18] ERROR[2903]: app_stack.c:593 gosub_exec: Attempt to reach a non-existent destination for Gosub: (Context:incoming_calls, Extension:s, Priority:789)
<--- Transmitting SIP request (1262 bytes) to TLS:a.b.c.d:5061 --->
Via: SIP/2.0/TLS;rport;branch=z9hG4bKPj2e1323ff-da41-4bf4-976a-5ecd1ded397d;alias
From: "New" <>;tag=b1230782-3b9c-4c60-80eb-905775ca2db3
To: <>
Contact: <sip:+44123456789@;transport=TLS>
Call-ID: 210b5595-2279-4c18-9556-ea9cb3bff894
CSeq: 27917 INVITE
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Security-Client: sdes-srtp;mediasec
Proxy-Require: mediasec
Require: mediasec
Security-Verify: msrp-tls;mediasec
Security-Verify: sdes-srtp;mediasec
Security-Verify: dtls-srtp;mediasec
Max-Forwards: 70
Content-Type: application/sdp
Content-Length:   358

I would have expected To to be something like:
To: <> or To: <>

Okay, so you aren’t modifying the module to add functionality. You’re using it as a base.

The API call is doing exactly what you’ve told it to do. You’ve told it to use “789” for the Gosub for pre-dial. Since you didn’t specify a context it used the one on the channel. Do you think predial means something else?

That will depend on the contacts, in the aor section, for endpoint 123. I don’t think chan_pjsip allows you to set To independent of the request URI.

I’d suggest the parameter is rather confusing, firstly because it is undocumented, and secondly because, whilst broken down context/extension/priority is used for other parameters it looks like it wants the unparsed string as would appear in the b option for dial, Does it use ^ delimiters as well?

It does as far as I know. It’s the same kind of string as used with Dial() predial handler I believe.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.