mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
chan_pjsip: Add PJSIPHangup dialplan app and manager action
See UserNote below. Exposed the existing Hangup AMI action in manager.c so we can use all of it's channel search and AMI protocol handling without duplicating that code in dialplan_functions.c. Added a lookup function to res_pjsip.c that takes in the string represenation of the pjsip_status_code enum and returns the actual status code. I.E. ast_sip_str2rc("DECLINE") returns 603. This allows the caller to specify PJSIPHangup(decline) in the dialplan, just like Hangup(call_rejected). Also extracted the XML documentation to its own file since it was almost as large as the code itself. UserNote: A new dialplan app PJSIPHangup and AMI action allows you to hang up an unanswered incoming PJSIP call with a specific SIP response code in the 400 -> 699 range.
This commit is contained in:
@@ -4527,7 +4527,9 @@ static int action_challenge(struct mansession *s, const struct message *m)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_hangup(struct mansession *s, const struct message *m)
|
||||
int ast_manager_hangup_helper(struct mansession *s,
|
||||
const struct message *m, manager_hangup_handler_t hangup_handler,
|
||||
manager_hangup_cause_validator_t cause_validator)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
int causecode = 0; /* all values <= 0 mean 'do not set hangupcause in channel' */
|
||||
@@ -4551,7 +4553,9 @@ static int action_hangup(struct mansession *s, const struct message *m)
|
||||
idText[0] = '\0';
|
||||
}
|
||||
|
||||
if (!ast_strlen_zero(cause)) {
|
||||
if (cause_validator) {
|
||||
causecode = cause_validator(name_or_regex, cause);
|
||||
} else if (!ast_strlen_zero(cause)) {
|
||||
char *endptr;
|
||||
causecode = strtol(cause, &endptr, 10);
|
||||
if (causecode < 0 || causecode > 127 || *endptr != '\0') {
|
||||
@@ -4578,7 +4582,7 @@ static int action_hangup(struct mansession *s, const struct message *m)
|
||||
ast_sockaddr_stringify_addr(&s->session->addr),
|
||||
ast_channel_name(c));
|
||||
|
||||
ast_channel_softhangup_withcause_locked(c, causecode);
|
||||
hangup_handler(c, causecode);
|
||||
c = ast_channel_unref(c);
|
||||
|
||||
astman_send_ack(s, m, "Channel Hungup");
|
||||
@@ -4624,7 +4628,7 @@ static int action_hangup(struct mansession *s, const struct message *m)
|
||||
ast_sockaddr_stringify_addr(&s->session->addr),
|
||||
ast_channel_name(c));
|
||||
|
||||
ast_channel_softhangup_withcause_locked(c, causecode);
|
||||
hangup_handler(c, causecode);
|
||||
channels_matched++;
|
||||
|
||||
astman_append(s,
|
||||
@@ -4644,6 +4648,12 @@ static int action_hangup(struct mansession *s, const struct message *m)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_hangup(struct mansession *s, const struct message *m)
|
||||
{
|
||||
return ast_manager_hangup_helper(s, m,
|
||||
ast_channel_softhangup_withcause_locked, NULL);
|
||||
}
|
||||
|
||||
static int action_setvar(struct mansession *s, const struct message *m)
|
||||
{
|
||||
struct ast_channel *c = NULL;
|
||||
|
Reference in New Issue
Block a user