Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
sig_pri.c File Reference

PRI signaling module. More...

#include "asterisk.h"
#include <errno.h>
#include <ctype.h>
#include <signal.h>
#include "asterisk/utils.h"
#include "asterisk/options.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/file.h"
#include "asterisk/callerid.h"
#include "asterisk/say.h"
#include "asterisk/manager.h"
#include "asterisk/astdb.h"
#include "asterisk/causes.h"
#include "asterisk/musiconhold.h"
#include "asterisk/cli.h"
#include "asterisk/transcap.h"
#include "asterisk/features.h"
#include "asterisk/aoc.h"
#include "asterisk/bridge.h"
#include "asterisk/stasis_channels.h"
#include "sig_pri.h"

Go to the source code of this file.

Data Structures

struct  sig_pri_cc_agent_prv
 
struct  sig_pri_cc_monitor_instance
 
struct  xfer_rsp_data
 

Macros

#define DCHAN_AVAILABLE   (DCHAN_NOTINALARM | DCHAN_UP)
 
#define DCHAN_NOTINALARM   (1 << 0)
 
#define DCHAN_UP   (1 << 1)
 
#define PRI_CHANNEL(p)   ((p) & 0xff)
 
#define PRI_CIS_CALL   (1 << 17) /* Call is using the D channel only. */
 
#define PRI_EXPLICIT   (1 << 16)
 
#define PRI_HELD_CALL   (1 << 18)
 
#define PRI_SPAN(p)   (((p) >> 8) & 0xff)
 
#define SIG_PRI_SC_HEADER   "%-4s %4s %-4s %-4s %-10s %-4s %s\n"
 
#define SIG_PRI_SC_LINE   "%4d %4d %-4s %-4s %-10s %-4s %s"
 

Typedefs

typedef enum sig_pri_moh_state(* sig_pri_moh_fsm_state) (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 

Enumerations

enum  SIG_PRI_CALL_OPT_ARGS { OPT_ARG_KEYPAD = 0, OPT_ARG_AOC_REQUEST, OPT_ARG_ARRAY_SIZE }
 
enum  SIG_PRI_CALL_OPT_FLAGS { OPT_KEYPAD = (1 << 0), OPT_REVERSE_CHARGE = (1 << 1), OPT_AOC_REQUEST = (1 << 2) }
 

Functions

static void apply_plan_to_existing_number (char *buf, size_t size, const struct sig_pri_span *pri, const char *number, int plan)
 
static void apply_plan_to_number (char *buf, size_t size, const struct sig_pri_span *pri, const char *number, int plan)
 
static unsigned char ast_pri_pack_hex_char (char c)
 
static int ast_pri_pack_hex_string (unsigned char *dst, char *src, int maxlen)
 
static int ast_to_pri_char_set (enum AST_PARTY_CHAR_SET ast_char_set)
 
static int ast_to_pri_presentation (int ast_presentation)
 
static int ast_to_pri_reason (enum AST_REDIRECTING_REASON ast_reason)
 
static void build_status (char *s, size_t len, int status, int active)
 
static char * dialplan2str (int dialplan)
 
static void * do_idle_thread (void *v_pvt)
 
static ast_callid func_pri_dchannel_chanpos_callid (struct sig_pri_span *pri, int chanpos)
 
static ast_callid func_pri_dchannel_new_callid (void)
 
static struct ast_manager_event_blobmcid_to_ami (struct stasis_message *msg)
 
static void party_json_to_ami (struct ast_str **msg, const char *prefix, struct ast_json *party)
 
static void party_name_json_to_ami (struct ast_str **msg, const char *prefix, struct ast_json *name)
 
static void party_number_json_to_ami (struct ast_str **msg, const char *prefix, struct ast_json *number)
 
static void party_subaddress_json_to_ami (struct ast_str **msg, const char *prefix, struct ast_json *subaddress)
 
static int pri_active_dchan_index (struct sig_pri_span *pri)
 
static void pri_check_restart (struct sig_pri_span *pri)
 
static void * pri_dchannel (void *vpri)
 
static void pri_destroy_later (struct sig_pri_span *pri)
 
void pri_event_alarm (struct sig_pri_span *pri, int index, int before_start_pri)
 
void pri_event_noalarm (struct sig_pri_span *pri, int index, int before_start_pri)
 
static void pri_find_dchan (struct sig_pri_span *pri)
 
static int pri_find_empty_chan (struct sig_pri_span *pri, int backwards)
 
static int pri_find_empty_nobch (struct sig_pri_span *pri)
 
static int pri_find_fixup_principle (struct sig_pri_span *pri, int channel, q931_call *call)
 
static int pri_find_principle (struct sig_pri_span *pri, int channel, q931_call *call)
 
static int pri_find_principle_by_call (struct sig_pri_span *pri, q931_call *call)
 
static int pri_fixup_principle (struct sig_pri_span *pri, int principle, q931_call *call)
 
static void pri_grab (struct sig_pri_chan *p, struct sig_pri_span *pri)
 
int pri_is_up (struct sig_pri_span *pri)
 
int pri_maintenance_bservice (struct pri *pri, struct sig_pri_chan *p, int changestatus)
 
static const char * pri_order (int level)
 
static void pri_queue_control (struct sig_pri_span *pri, int chanpos, int subclass)
 
static void pri_queue_frame (struct sig_pri_span *pri, int chanpos, struct ast_frame *frame)
 
static void pri_queue_pvt_cause_data (struct sig_pri_span *pri, int chanpos, const char *cause, int ast_cause)
 
static void pri_rel (struct sig_pri_span *pri)
 
int pri_send_callrerouting_facility_exec (struct sig_pri_chan *p, enum ast_channel_state chanstate, const char *destination, const char *original, const char *reason)
 
int pri_send_keypad_facility_exec (struct sig_pri_chan *p, const char *digits)
 
static void * pri_ss_thread (void *data)
 
static enum AST_PARTY_CHAR_SET pri_to_ast_char_set (int pri_char_set)
 
static int pri_to_ast_presentation (int pri_presentation)
 
static enum AST_REDIRECTING_REASON pri_to_ast_reason (int pri_reason)
 
static unsigned int PVT_TO_CHANNEL (struct sig_pri_chan *p)
 
static char * redirectingreason2str (int redirectingreason)
 
static void send_mcid (struct ast_channel *chan, struct ast_party_id *caller, struct ast_party_id *connected)
 
static void setup_incoming_channel (struct sig_pri_span *pri, int chanpos, pri_event *ev)
 
static void sig_pri_ami_channel_event (struct sig_pri_chan *p)
 
int sig_pri_ami_show_spans (struct mansession *s, const char *show_cmd, struct sig_pri_span *pri, const int *dchannels, const char *action_id)
 Output AMI show spans response events for the given PRI span. More...
 
int sig_pri_answer (struct sig_pri_chan *p, struct ast_channel *ast)
 
static enum ast_aoc_s_charged_item sig_pri_aoc_charged_item_to_ast (enum PRI_AOC_CHARGED_ITEM value)
 
static enum PRI_AOC_CHARGED_ITEM sig_pri_aoc_charged_item_to_pri (enum PRI_AOC_CHARGED_ITEM value)
 
static void sig_pri_aoc_d_from_ast (struct sig_pri_chan *pvt, struct ast_aoc_decoded *decoded)
 
static void sig_pri_aoc_d_from_pri (const struct pri_subcmd_aoc_d *aoc_d, struct ast_channel *owner, int passthrough)
 
static void sig_pri_aoc_e_from_ast (struct sig_pri_chan *pvt, struct ast_aoc_decoded *decoded)
 
static void sig_pri_aoc_e_from_pri (const struct pri_subcmd_aoc_e *aoc_e, struct ast_channel *owner, int passthrough)
 
static int sig_pri_aoc_multiplier_from_ast (enum ast_aoc_currency_multiplier mult)
 
static int sig_pri_aoc_multiplier_from_pri (const int mult)
 
static void sig_pri_aoc_request_from_pri (const struct pri_subcmd_aoc_request *aoc_request, struct sig_pri_chan *pvt, q931_call *call)
 
static void sig_pri_aoc_s_from_ast (struct sig_pri_chan *pvt, struct ast_aoc_decoded *decoded)
 
static void sig_pri_aoc_s_from_pri (const struct pri_subcmd_aoc_s *aoc_s, struct ast_channel *owner, int passthrough)
 
static enum ast_aoc_time_scale sig_pri_aoc_scale_to_ast (enum PRI_AOC_TIME_SCALE value)
 
static enum PRI_AOC_TIME_SCALE sig_pri_aoc_scale_to_pri (enum ast_aoc_time_scale value)
 
static int sig_pri_attempt_transfer (struct sig_pri_span *pri, q931_call *call_1_pri, int call_1_held, q931_call *call_2_pri, int call_2_held, struct xfer_rsp_data *xfer_data)
 
int sig_pri_available (struct sig_pri_chan **pvt, int is_specific_channel)
 
static int sig_pri_available_check (struct sig_pri_chan *pvt)
 
int sig_pri_call (struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1)
 
static const char * sig_pri_call_level2str (enum sig_pri_call_level level)
 
int sig_pri_cc_agent_callee_available (struct ast_cc_agent *agent)
 Alert the caller that it is time to try recalling. More...
 
static int sig_pri_cc_agent_cmp_cc_id (void *obj, void *arg, int flags)
 
void sig_pri_cc_agent_destructor (struct ast_cc_agent *agent)
 Destroy private data on the agent. More...
 
int sig_pri_cc_agent_init (struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan)
 PRI CC agent initialization. More...
 
int sig_pri_cc_agent_party_b_free (struct ast_cc_agent *agent)
 Let the caller know that the callee has become free but that the caller cannot attempt to call back because he is either busy or there is congestion on his line. More...
 
void sig_pri_cc_agent_req_rsp (struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
 Response to a CC request. More...
 
int sig_pri_cc_agent_start_monitoring (struct ast_cc_agent *agent)
 Begin monitoring a busy device. More...
 
int sig_pri_cc_agent_start_offer_timer (struct ast_cc_agent *agent)
 Start the offer timer. More...
 
int sig_pri_cc_agent_status_req (struct ast_cc_agent *agent)
 Request the status of the agent's device. More...
 
int sig_pri_cc_agent_stop_offer_timer (struct ast_cc_agent *agent)
 Stop the offer timer. More...
 
int sig_pri_cc_agent_stop_ringing (struct ast_cc_agent *agent)
 Request for an agent's phone to stop ringing. More...
 
static int sig_pri_cc_available (struct sig_pri_span *pri, int chanpos, long cc_id, enum ast_cc_service_type service)
 
static void sig_pri_cc_generic_check (struct sig_pri_span *pri, int chanpos, enum ast_cc_service_type service)
 
static void sig_pri_cc_link_canceled (struct sig_pri_span *pri, long cc_id, int is_agent)
 
int sig_pri_cc_monitor_cancel_available_timer (struct ast_cc_monitor *monitor, int *sched_id)
 Cancel the running available timer. More...
 
static int sig_pri_cc_monitor_cmp_cc_id (void *obj, void *arg, int flags)
 
void sig_pri_cc_monitor_destructor (void *monitor_pvt)
 Destroy PRI private data on the monitor. More...
 
static int sig_pri_cc_monitor_instance_cmp_fn (void *obj, void *arg, int flags)
 
static void sig_pri_cc_monitor_instance_destroy (void *data)
 
static int sig_pri_cc_monitor_instance_hash_fn (const void *obj, const int flags)
 
static struct sig_pri_cc_monitor_instancesig_pri_cc_monitor_instance_init (int core_id, struct sig_pri_span *pri, long cc_id, const char *device_name)
 
int sig_pri_cc_monitor_req_cc (struct ast_cc_monitor *monitor, int *available_timer_id)
 Request CCSS. More...
 
int sig_pri_cc_monitor_status_rsp (struct ast_cc_monitor *monitor, enum ast_device_state devstate)
 Status response to an ast_cc_monitor_status_request(). More...
 
int sig_pri_cc_monitor_suspend (struct ast_cc_monitor *monitor)
 Suspend monitoring. More...
 
int sig_pri_cc_monitor_unsuspend (struct ast_cc_monitor *monitor)
 Unsuspend monitoring. More...
 
void sig_pri_chan_alarm_notify (struct sig_pri_chan *p, int noalarm)
 Notify new alarm status. More...
 
void sig_pri_chan_delete (struct sig_pri_chan *doomed)
 Delete the sig_pri private channel structure. More...
 
struct sig_pri_chansig_pri_chan_new (void *pvt_data, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup)
 
void sig_pri_cli_show_channels (int fd, struct sig_pri_span *pri)
 
void sig_pri_cli_show_channels_header (int fd)
 
void sig_pri_cli_show_span (int fd, int *dchannels, struct sig_pri_span *pri)
 
void sig_pri_cli_show_spans (int fd, int span, struct sig_pri_span *pri)
 
static int sig_pri_cmp_pri_chans (const void *left, const void *right)
 
static struct sig_pri_chansig_pri_cw_available (struct sig_pri_span *pri)
 
static void sig_pri_deadlock_avoidance_private (struct sig_pri_chan *p)
 
void sig_pri_dial_complete (struct sig_pri_chan *pvt, struct ast_channel *ast)
 DTMF dial string complete. More...
 
static void sig_pri_dial_digits (struct sig_pri_chan *p, const char *dial_string)
 
int sig_pri_digit_begin (struct sig_pri_chan *pvt, struct ast_channel *ast, char digit)
 
static void sig_pri_dsp_reset_and_flush_digits (struct sig_pri_chan *p)
 
void sig_pri_extract_called_num_subaddr (struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size)
 Extract the called number and subaddress from the dial string. More...
 
static struct ast_cc_agentsig_pri_find_cc_agent_by_cc_id (struct sig_pri_span *pri, long cc_id)
 
static struct sig_pri_cc_monitor_instancesig_pri_find_cc_monitor_by_cc_id (struct sig_pri_span *pri, long cc_id)
 
void sig_pri_fixup (struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan)
 
static void sig_pri_fixup_chans (struct sig_pri_chan *old_chan, struct sig_pri_chan *new_chan)
 
static const char * sig_pri_get_orig_dialstring (struct sig_pri_chan *p)
 
static void sig_pri_handle_cis_subcmds (struct sig_pri_span *pri, int event_id, const struct pri_subcommands *subcmds, q931_call *call_rsp)
 
static void sig_pri_handle_dchan_exception (struct sig_pri_span *pri, int index)
 
static int sig_pri_handle_hold (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_hold_ack (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_hold_rej (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_retrieve (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_retrieve_ack (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_retrieve_rej (struct sig_pri_span *pri, pri_event *ev)
 
static void sig_pri_handle_setup (struct sig_pri_span *pri, pri_event *e)
 
static void sig_pri_handle_subcmds (struct sig_pri_span *pri, int chanpos, int event_id, const struct pri_subcommands *subcmds, q931_call *call_rsp)
 
int sig_pri_hangup (struct sig_pri_chan *p, struct ast_channel *ast)
 
int sig_pri_indicate (struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
 
static void sig_pri_init_config (struct sig_pri_chan *pvt, struct sig_pri_span *pri)
 
void sig_pri_init_pri (struct sig_pri_span *pri)
 
int sig_pri_is_alarm_ignored (struct sig_pri_span *pri)
 Determine if layer 1 alarms are ignored. More...
 
int sig_pri_is_chan_available (struct sig_pri_chan *pvt)
 Determine if a private channel structure is available. More...
 
static int sig_pri_is_chan_in_use (struct sig_pri_chan *pvt)
 
static int sig_pri_is_cis_call (int channel)
 
static void sig_pri_kill_call (struct sig_pri_span *pri, q931_call *call, int cause)
 
int sig_pri_load (const char *cc_type_name)
 Load the sig_pri submodule. More...
 
static void sig_pri_lock_owner (struct sig_pri_span *pri, int chanpos)
 
static void sig_pri_lock_private (struct sig_pri_chan *p)
 
static void sig_pri_make_cc_dialstring (struct sig_pri_chan *p, char *buf, size_t buf_size)
 
static void sig_pri_mcid_event (struct sig_pri_span *pri, const struct pri_subcmd_mcid_req *mcid, struct ast_channel *owner)
 
static const char * sig_pri_moh_event_str (enum sig_pri_moh_event event)
 
static void sig_pri_moh_fsm_event (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_hold (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_hold_req (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_idle (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_moh (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_notify (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_pend_hold (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_pend_unhold (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_retrieve_fail (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_fsm_retrieve_req (struct ast_channel *chan, struct sig_pri_chan *pvt, enum sig_pri_moh_event event)
 
static enum sig_pri_moh_state sig_pri_moh_retrieve_call (struct sig_pri_chan *pvt)
 
static const char * sig_pri_moh_state_str (enum sig_pri_moh_state state)
 
static int sig_pri_msn_match (const char *msn_patterns, const char *exten)
 
static void sig_pri_mwi_cache_update (struct sig_pri_span *pri)
 
static void sig_pri_mwi_event_cb (void *userdata, struct stasis_subscription *sub, struct stasis_message *msg)
 
static struct ast_channelsig_pri_new_ast_channel (struct sig_pri_chan *p, int state, enum sig_pri_law law, int transfercapability, char *exten, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
 
static void sig_pri_open_media (struct sig_pri_chan *p)
 
static void sig_pri_party_id_convert (struct ast_party_id *ast_id, const struct pri_party_id *pri_id, struct sig_pri_span *pri)
 
static void sig_pri_party_id_from_ast (struct pri_party_id *pri_id, const struct ast_party_id *ast_id)
 
static void sig_pri_party_name_convert (struct ast_party_name *ast_name, const struct pri_party_name *pri_name)
 
static void sig_pri_party_name_from_ast (struct pri_party_name *pri_name, const struct ast_party_name *ast_name)
 
static void sig_pri_party_number_convert (struct ast_party_number *ast_number, const struct pri_party_number *pri_number, struct sig_pri_span *pri)
 
static void sig_pri_party_number_from_ast (struct pri_party_number *pri_number, const struct ast_party_number *ast_number)
 
static void sig_pri_party_subaddress_from_ast (struct pri_party_subaddress *pri_subaddress, const struct ast_party_subaddress *ast_subaddress)
 
static int sig_pri_play_tone (struct sig_pri_chan *p, enum sig_pri_tone tone)
 
static void sig_pri_queue_hangup (struct sig_pri_span *pri, int chanpos)
 
static void sig_pri_queue_hold (struct sig_pri_span *pri, int chanpos)
 
static void sig_pri_queue_unhold (struct sig_pri_span *pri, int chanpos)
 
static void sig_pri_redirecting_convert (struct ast_party_redirecting *ast_redirecting, const struct pri_party_redirecting *pri_redirecting, const struct ast_party_redirecting *ast_guide, struct sig_pri_span *pri)
 
static void sig_pri_redirecting_update (struct sig_pri_chan *pvt, struct ast_channel *ast)
 
struct ast_channelsig_pri_request (struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int transfercapability)
 
static void sig_pri_send_aoce_termination_request (struct sig_pri_span *pri, int chanpos, unsigned int ms)
 
static void sig_pri_send_mwi_indication (struct sig_pri_span *pri, const char *vm_number, const char *vm_box, const char *mbox_id, int num_messages)
 
void sig_pri_sendtext (struct sig_pri_chan *p, const char *text)
 Send display text. More...
 
void sig_pri_set_alarm (struct sig_pri_chan *p, int in_alarm)
 
static void sig_pri_set_caller_id (struct sig_pri_chan *p)
 
static void sig_pri_set_dialing (struct sig_pri_chan *p, int is_dialing)
 
static void sig_pri_set_digital (struct sig_pri_chan *p, int is_digital)
 
static void sig_pri_set_dnid (struct sig_pri_chan *p, const char *dnid)
 
static int sig_pri_set_echocanceller (struct sig_pri_chan *p, int enable)
 
static void sig_pri_set_outgoing (struct sig_pri_chan *p, int is_outgoing)
 
static void sig_pri_set_rdnis (struct sig_pri_chan *p, const char *rdnis)
 
static void sig_pri_set_subaddress (struct ast_party_subaddress *ast_subaddress, const struct pri_party_subaddress *pri_subaddress)
 
static void sig_pri_sort_pri_chans (struct sig_pri_span *pri)
 
static void sig_pri_span_devstate_changed (struct sig_pri_span *pri)
 
int sig_pri_start_pri (struct sig_pri_span *pri)
 
void sig_pri_stop_pri (struct sig_pri_span *pri)
 Stop PRI span. More...
 
static void sig_pri_transfer_rsp (struct xfer_rsp_data *rsp, int is_successful)
 
void sig_pri_unload (void)
 Unload the sig_pri submodule. More...
 
static void sig_pri_unlock_private (struct sig_pri_chan *p)
 
 STASIS_MESSAGE_TYPE_DEFN_LOCAL (mcid_type,.to_ami=mcid_to_ami,)
 

Variables

static int pri_gendigittimeout = 8000
 
static int pri_matchdigittimeout = 3000
 
static const struct ast_app_option sig_pri_call_opts [128] = { [ 'K' ] = { .flag = OPT_KEYPAD , .arg_index = OPT_ARG_KEYPAD + 1 }, [ 'R' ] = { .flag = OPT_REVERSE_CHARGE }, [ 'A' ] = { .flag = OPT_AOC_REQUEST , .arg_index = OPT_ARG_AOC_REQUEST + 1 }, }
 
static struct ao2_containersig_pri_cc_monitors
 
static const char * sig_pri_cc_type_name
 
static const sig_pri_moh_fsm_state sig_pri_moh_fsm [SIG_PRI_MOH_STATE_NUM]
 

Detailed Description

PRI signaling module.

Author
Matthew Fredrickson cresl.nosp@m.in@d.nosp@m.igium.nosp@m..com

Definition in file sig_pri.c.

Function Documentation

int sig_pri_ami_show_spans ( struct mansession s,
const char *  show_cmd,
struct sig_pri_span pri,
const int *  dchannels,
const char *  action_id 
)

Output AMI show spans response events for the given PRI span.

Since
10.0
Parameters
show_cmdAMI command name
sAMI session to output span information.
priPRI span control structure.
dchannelsArray of D channel channel numbers.
action_idAction ID line to use.
Returns
Number of D channels on this span.

Definition at line 7540 of file sig_pri.c.

References astman_append(), sig_pri_span::dchanavail, sig_pri_span::dchans, sig_pri_span::pri, and sig_pri_span::span.

7541 {
7542  int count;
7543  int x;
7544 
7545  count = 0;
7546  for (x = 0; x < ARRAY_LEN(pri->dchans); ++x) {
7547  if (pri->dchans[x]) {
7548  ++count;
7549 
7550  astman_append(s,
7551  "Event: %s\r\n"
7552  "Span: %d\r\n"
7553  "DChannel: %d\r\n"
7554  "Order: %s\r\n"
7555  "Active: %s\r\n"
7556  "Alarm: %s\r\n"
7557  "Up: %s\r\n"
7558  "%s"
7559  "\r\n",
7560  show_cmd,
7561  pri->span,
7562  dchannels[x],
7563  pri_order(x),
7564  (pri->dchans[x] == pri->pri) ? "Yes" : "No",
7565  (pri->dchanavail[x] & DCHAN_NOTINALARM) ? "No" : "Yes",
7566  (pri->dchanavail[x] & DCHAN_UP) ? "Yes" : "No",
7567  action_id
7568  );
7569  }
7570  }
7571  return count;
7572 }
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3310
int dchanavail[SIG_PRI_NUM_DCHANS]
Definition: sig_pri.h:590
struct pri * dchans[SIG_PRI_NUM_DCHANS]
Definition: sig_pri.h:601
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_call ( struct sig_pri_chan p,
struct ast_channel ast,
const char *  rdest,
int  timeout,
int  layer1 
)
Note
Parsing must remain in sync with sig_pri_extract_called_num_subaddr().

Definition at line 7780 of file sig_pri.c.

References ao2_ref, sig_pri_span::append_msn_to_user_tag, AST_APP_ARG, ast_app_parse_options(), ast_cc_get_monitor_by_recall_core_id(), ast_cc_is_recall(), ast_channel_get_device_name(), AST_CHANNEL_NAME, ast_copy_string(), ast_debug, AST_DECLARE_APP_ARGS, AST_NONSTANDARD_APP_ARGS, ast_party_subaddress_init(), ast_setstate(), AST_STATE_DIALING, AST_STATE_DOWN, AST_STATE_RESERVED, ast_strdup, ast_transfercapability2str(), sig_pri_chan::call, sig_pri_chan::call_level, sig_pri_cc_monitor_instance::cc_id, sig_pri_chan::channel, sig_pri_chan::deferred_digits, sig_pri_span::dialplan, sig_pri_span::facilityenable, sig_pri_chan::hidecalleridname, ast_party_caller::id, sig_pri_span::initial_user_tag, sig_pri_span::internationalprefix, sig_pri_chan::is_call_waiting, sig_pri_span::localdialplan, ast_party_id::name, sig_pri_span::nationalprefix, sig_pri_chan::no_dialed_digits, sig_pri_span::nodetype, ast_party_id::number, pbx_builtin_getvar_helper(), ast_party_number::plan, ast_party_number::presentation, sig_pri_cc_monitor_instance::pri, sig_pri_span::pri, sig_pri_chan::priexclusive, ast_cc_monitor::private_data, S_COR, SIG_PRI_CALL_LEVEL_SETUP, sig_pri_cc_type_name, ast_party_name::str, ast_party_number::str, ast_party_subaddress::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_subaddress::type, sig_pri_chan::use_callingpres, sig_pri_chan::user_tag, ast_party_name::valid, ast_party_number::valid, and ast_party_subaddress::valid.

7781 {
7782  char dest[256]; /* must be same length as p->dialdest */
7783  struct ast_party_subaddress dialed_subaddress; /* Called subaddress */
7784  struct pri_sr *sr;
7785  char *c, *l, *n, *s;
7786 #ifdef SUPPORT_USERUSER
7787  const char *useruser;
7788 #endif
7789  int core_id;
7790  int pridialplan;
7791  int dp_strip;
7792  int prilocaldialplan;
7793  int ldp_strip;
7794  int exclusive;
7795 #if defined(HAVE_PRI_SETUP_KEYPAD)
7796  const char *keypad;
7797 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
7798  AST_DECLARE_APP_ARGS(args,
7799  AST_APP_ARG(group); /* channel/group token */
7800  AST_APP_ARG(ext); /* extension token */
7801  AST_APP_ARG(opts); /* options token */
7802  AST_APP_ARG(other); /* Any remining unused arguments */
7803  );
7804  struct ast_flags opts;
7805  char *opt_args[OPT_ARG_ARRAY_SIZE];
7806  struct ast_party_id connected_id = ast_channel_connected_effective_id(ast);
7807 
7808  ast_debug(1, "CALLER NAME: %s NUM: %s\n",
7809  S_COR(connected_id.name.valid, connected_id.name.str, ""),
7810  S_COR(connected_id.number.valid, connected_id.number.str, ""));
7811 
7812  if (!p->pri) {
7813  ast_log(LOG_ERROR, "Could not find pri on channel %d\n", p->channel);
7814  return -1;
7815  }
7816 
7818  ast_log(LOG_WARNING, "sig_pri_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
7819  return -1;
7820  }
7821 
7822  p->dialdest[0] = '\0';
7823  sig_pri_set_outgoing(p, 1);
7824 
7825  ast_copy_string(dest, rdest, sizeof(dest));
7826  AST_NONSTANDARD_APP_ARGS(args, dest, '/');
7827  if (ast_app_parse_options(sig_pri_call_opts, &opts, opt_args, args.opts)) {
7828  /* General invalid option syntax. */
7829  return -1;
7830  }
7831 
7832  c = args.ext;
7833  if (!c) {
7834  c = "";
7835  }
7836 
7837  /* setup dialed_subaddress if found */
7838  ast_party_subaddress_init(&dialed_subaddress);
7839  s = strchr(c, ':');
7840  if (s) {
7841  *s = '\0';
7842  s++;
7843  /* prefix */
7844  /* 'n' = NSAP */
7845  /* 'u' = User Specified */
7846  /* Default = NSAP */
7847  switch (*s) {
7848  case 'U':
7849  case 'u':
7850  s++;
7851  dialed_subaddress.type = 2;
7852  break;
7853  case 'N':
7854  case 'n':
7855  s++;
7856  /* default already covered with ast_party_subaddress_init */
7857  break;
7858  }
7859  dialed_subaddress.str = s;
7860  dialed_subaddress.valid = 1;
7861  }
7862 
7863  l = NULL;
7864  n = NULL;
7865  if (!p->hidecallerid) {
7866  if (connected_id.number.valid) {
7867  /* If we get to the end of this loop without breaking, there's no
7868  * calleridnum. This is done instead of testing for "unknown" or
7869  * the thousands of other ways that the calleridnum could be
7870  * invalid. */
7871  for (l = connected_id.number.str; l && *l; l++) {
7872  if (strchr("0123456789", *l)) {
7873  l = connected_id.number.str;
7874  break;
7875  }
7876  }
7877  } else {
7878  l = NULL;
7879  }
7880  if (!p->hidecalleridname) {
7881  n = connected_id.name.valid ? connected_id.name.str : NULL;
7882  }
7883  }
7884 
7885  if (strlen(c) < p->stripmsd) {
7886  ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
7887  return -1;
7888  }
7889 
7890  /* Extract any 'w' deferred digits. */
7891  s = strchr(c + p->stripmsd, 'w');
7892  if (s) {
7893  *s++ = '\0';
7894  ast_copy_string(p->deferred_digits, s, sizeof(p->deferred_digits));
7895  /*
7896  * Since we have a 'w', this means that there will not be any
7897  * more normal dialed digits. Therefore, the sending complete
7898  * ie needs to be sent with any normal digits.
7899  */
7900  } else {
7901  p->deferred_digits[0] = '\0';
7902  }
7903 
7904  pri_grab(p, p->pri);
7905  if (!(p->call = pri_new_call(p->pri->pri))) {
7906  ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel);
7907  pri_rel(p->pri);
7908  return -1;
7909  }
7910  if (!(sr = pri_sr_new())) {
7911  ast_log(LOG_WARNING, "Failed to allocate setup request on channel %d\n",
7912  p->channel);
7913  pri_destroycall(p->pri->pri, p->call);
7914  p->call = NULL;
7915  pri_rel(p->pri);
7916  return -1;
7917  }
7918 
7919  sig_pri_set_digital(p, IS_DIGITAL(ast_channel_transfercapability(ast))); /* push up to parent for EC */
7920 
7921 #if defined(HAVE_PRI_CALL_WAITING)
7922  if (p->is_call_waiting) {
7923  /*
7924  * Indicate that this is a call waiting call.
7925  * i.e., Normal call but with no B channel.
7926  */
7927  pri_sr_set_channel(sr, 0, 0, 1);
7928  } else
7929 #endif /* defined(HAVE_PRI_CALL_WAITING) */
7930  {
7931  /* Should the picked channel be used exclusively? */
7932  if (p->priexclusive || p->pri->nodetype == PRI_NETWORK) {
7933  exclusive = 1;
7934  } else {
7935  exclusive = 0;
7936  }
7937  pri_sr_set_channel(sr, PVT_TO_CHANNEL(p), exclusive, 1);
7938  }
7939 
7940  pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast_channel_transfercapability(ast),
7941  (p->digital ? -1 : layer1));
7942 
7943  if (p->pri->facilityenable)
7944  pri_facility_enable(p->pri->pri);
7945 
7946  ast_verb(3, "Requested transfer capability: 0x%02hx - %s\n", ast_channel_transfercapability(ast), ast_transfercapability2str(ast_channel_transfercapability(ast)));
7947  dp_strip = 0;
7948  pridialplan = p->pri->dialplan - 1;
7949  if (pridialplan == -2 || pridialplan == -3) { /* compute dynamically */
7950  if (strncmp(c + p->stripmsd, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) {
7951  if (pridialplan == -2) {
7952  dp_strip = strlen(p->pri->internationalprefix);
7953  }
7954  pridialplan = PRI_INTERNATIONAL_ISDN;
7955  } else if (strncmp(c + p->stripmsd, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) {
7956  if (pridialplan == -2) {
7957  dp_strip = strlen(p->pri->nationalprefix);
7958  }
7959  pridialplan = PRI_NATIONAL_ISDN;
7960  } else {
7961  pridialplan = PRI_LOCAL_ISDN;
7962  }
7963  }
7964  while (c[p->stripmsd] > '9' && c[p->stripmsd] != '*' && c[p->stripmsd] != '#') {
7965  switch (c[p->stripmsd]) {
7966  case 'U':
7967  pridialplan = (PRI_TON_UNKNOWN << 4) | (pridialplan & 0xf);
7968  break;
7969  case 'I':
7970  pridialplan = (PRI_TON_INTERNATIONAL << 4) | (pridialplan & 0xf);
7971  break;
7972  case 'N':
7973  pridialplan = (PRI_TON_NATIONAL << 4) | (pridialplan & 0xf);
7974  break;
7975  case 'L':
7976  pridialplan = (PRI_TON_NET_SPECIFIC << 4) | (pridialplan & 0xf);
7977  break;
7978  case 'S':
7979  pridialplan = (PRI_TON_SUBSCRIBER << 4) | (pridialplan & 0xf);
7980  break;
7981  case 'V':
7982  pridialplan = (PRI_TON_ABBREVIATED << 4) | (pridialplan & 0xf);
7983  break;
7984  case 'R':
7985  pridialplan = (PRI_TON_RESERVED << 4) | (pridialplan & 0xf);
7986  break;
7987  case 'u':
7988  pridialplan = PRI_NPI_UNKNOWN | (pridialplan & 0xf0);
7989  break;
7990  case 'e':
7991  pridialplan = PRI_NPI_E163_E164 | (pridialplan & 0xf0);
7992  break;
7993  case 'x':
7994  pridialplan = PRI_NPI_X121 | (pridialplan & 0xf0);
7995  break;
7996  case 'f':
7997  pridialplan = PRI_NPI_F69 | (pridialplan & 0xf0);
7998  break;
7999  case 'n':
8000  pridialplan = PRI_NPI_NATIONAL | (pridialplan & 0xf0);
8001  break;
8002  case 'p':
8003  pridialplan = PRI_NPI_PRIVATE | (pridialplan & 0xf0);
8004  break;
8005  case 'r':
8006  pridialplan = PRI_NPI_RESERVED | (pridialplan & 0xf0);
8007  break;
8008  default:
8009  if (isalpha(c[p->stripmsd])) {
8010  ast_log(LOG_WARNING, "Unrecognized pridialplan %s modifier: %c\n",
8011  c[p->stripmsd] > 'Z' ? "NPI" : "TON", c[p->stripmsd]);
8012  }
8013  break;
8014  }
8015  c++;
8016  }
8017 #if defined(HAVE_PRI_SETUP_KEYPAD)
8018  if (ast_test_flag(&opts, OPT_KEYPAD)
8019  && !ast_strlen_zero(opt_args[OPT_ARG_KEYPAD])) {
8020  /* We have a keypad facility digits option with digits. */
8021  keypad = opt_args[OPT_ARG_KEYPAD];
8022  pri_sr_set_keypad_digits(sr, keypad);
8023  } else {
8024  keypad = NULL;
8025  }
8026  if (!keypad || !ast_strlen_zero(c + p->stripmsd + dp_strip))
8027 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */
8028  {
8029  char *called = c + p->stripmsd + dp_strip;
8030 
8031  pri_sr_set_called(sr, called, pridialplan, s ? 1 : 0);
8032 #if defined(HAVE_PRI_SETUP_ACK_INBAND)
8033  p->no_dialed_digits = !called[0];
8034 #endif /* defined(HAVE_PRI_SETUP_ACK_INBAND) */
8035  }
8036 
8037 #if defined(HAVE_PRI_SUBADDR)
8038  if (dialed_subaddress.valid) {
8039  struct pri_party_subaddress subaddress;
8040 
8041  memset(&subaddress, 0, sizeof(subaddress));
8042  sig_pri_party_subaddress_from_ast(&subaddress, &dialed_subaddress);
8043  pri_sr_set_called_subaddress(sr, &subaddress);
8044  }
8045 #endif /* defined(HAVE_PRI_SUBADDR) */
8046 #if defined(HAVE_PRI_REVERSE_CHARGE)
8047  if (ast_test_flag(&opts, OPT_REVERSE_CHARGE)) {
8048  pri_sr_set_reversecharge(sr, PRI_REVERSECHARGE_REQUESTED);
8049  }
8050 #endif /* defined(HAVE_PRI_REVERSE_CHARGE) */
8051 #if defined(HAVE_PRI_AOC_EVENTS)
8052  if (ast_test_flag(&opts, OPT_AOC_REQUEST)
8053  && !ast_strlen_zero(opt_args[OPT_ARG_AOC_REQUEST])) {
8054  if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 's')) {
8055  pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_S);
8056  }
8057  if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 'd')) {
8058  pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_D);
8059  }
8060  if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 'e')) {
8061  pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_E);
8062  }
8063  }
8064 #endif /* defined(HAVE_PRI_AOC_EVENTS) */
8065 
8066  /* Setup the user tag for party id's from this device for this call. */
8067  if (p->pri->append_msn_to_user_tag) {
8068  snprintf(p->user_tag, sizeof(p->user_tag), "%s_%s", p->pri->initial_user_tag,
8069  p->pri->nodetype == PRI_NETWORK
8070  ? c + p->stripmsd + dp_strip
8071  : S_COR(ast_channel_connected(ast)->id.number.valid,
8072  ast_channel_connected(ast)->id.number.str, ""));
8073  } else {
8074  ast_copy_string(p->user_tag, p->pri->initial_user_tag, sizeof(p->user_tag));
8075  }
8076 
8077  /*
8078  * Replace the caller id tag from the channel creation
8079  * with the actual tag value.
8080  */
8081  ast_free(ast_channel_caller(ast)->id.tag);
8082  ast_channel_caller(ast)->id.tag = ast_strdup(p->user_tag);
8083 
8084  ldp_strip = 0;
8085  prilocaldialplan = p->pri->localdialplan - 1;
8086  if ((l != NULL) && (prilocaldialplan == -2 || prilocaldialplan == -3)) { /* compute dynamically */
8087  if (strncmp(l, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) {
8088  if (prilocaldialplan == -2) {
8089  ldp_strip = strlen(p->pri->internationalprefix);
8090  }
8091  prilocaldialplan = PRI_INTERNATIONAL_ISDN;
8092  } else if (strncmp(l, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) {
8093  if (prilocaldialplan == -2) {
8094  ldp_strip = strlen(p->pri->nationalprefix);
8095  }
8096  prilocaldialplan = PRI_NATIONAL_ISDN;
8097  } else {
8098  prilocaldialplan = PRI_LOCAL_ISDN;
8099  }
8100  } else if (prilocaldialplan == -1) {
8101  /* Use the numbering plan passed in. */
8102  prilocaldialplan = connected_id.number.plan;
8103  }
8104  if (l != NULL) {
8105  while (*l > '9' && *l != '*' && *l != '#') {
8106  switch (*l) {
8107  case 'U':
8108  prilocaldialplan = (PRI_TON_UNKNOWN << 4) | (prilocaldialplan & 0xf);
8109  break;
8110  case 'I':
8111  prilocaldialplan = (PRI_TON_INTERNATIONAL << 4) | (prilocaldialplan & 0xf);
8112  break;
8113  case 'N':
8114  prilocaldialplan = (PRI_TON_NATIONAL << 4) | (prilocaldialplan & 0xf);
8115  break;
8116  case 'L':
8117  prilocaldialplan = (PRI_TON_NET_SPECIFIC << 4) | (prilocaldialplan & 0xf);
8118  break;
8119  case 'S':
8120  prilocaldialplan = (PRI_TON_SUBSCRIBER << 4) | (prilocaldialplan & 0xf);
8121  break;
8122  case 'V':
8123  prilocaldialplan = (PRI_TON_ABBREVIATED << 4) | (prilocaldialplan & 0xf);
8124  break;
8125  case 'R':
8126  prilocaldialplan = (PRI_TON_RESERVED << 4) | (prilocaldialplan & 0xf);
8127  break;
8128  case 'u':
8129  prilocaldialplan = PRI_NPI_UNKNOWN | (prilocaldialplan & 0xf0);
8130  break;
8131  case 'e':
8132  prilocaldialplan = PRI_NPI_E163_E164 | (prilocaldialplan & 0xf0);
8133  break;
8134  case 'x':
8135  prilocaldialplan = PRI_NPI_X121 | (prilocaldialplan & 0xf0);
8136  break;
8137  case 'f':
8138  prilocaldialplan = PRI_NPI_F69 | (prilocaldialplan & 0xf0);
8139  break;
8140  case 'n':
8141  prilocaldialplan = PRI_NPI_NATIONAL | (prilocaldialplan & 0xf0);
8142  break;
8143  case 'p':
8144  prilocaldialplan = PRI_NPI_PRIVATE | (prilocaldialplan & 0xf0);
8145  break;
8146  case 'r':
8147  prilocaldialplan = PRI_NPI_RESERVED | (prilocaldialplan & 0xf0);
8148  break;
8149  default:
8150  if (isalpha(*l)) {
8151  ast_log(LOG_WARNING,
8152  "Unrecognized prilocaldialplan %s modifier: %c\n",
8153  *l > 'Z' ? "NPI" : "TON", *l);
8154  }
8155  break;
8156  }
8157  l++;
8158  }
8159  }
8160  pri_sr_set_caller(sr, l ? (l + ldp_strip) : NULL, n, prilocaldialplan,
8161  p->use_callingpres ? connected_id.number.presentation : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE));
8162 
8163 #if defined(HAVE_PRI_SUBADDR)
8164  if (connected_id.subaddress.valid) {
8165  struct pri_party_subaddress subaddress;
8166 
8167  memset(&subaddress, 0, sizeof(subaddress));
8168  sig_pri_party_subaddress_from_ast(&subaddress, &connected_id.subaddress);
8169  pri_sr_set_caller_subaddress(sr, &subaddress);
8170  }
8171 #endif /* defined(HAVE_PRI_SUBADDR) */
8172 
8173  sig_pri_redirecting_update(p, ast);
8174 
8175 #ifdef SUPPORT_USERUSER
8176  /* User-user info */
8177  useruser = pbx_builtin_getvar_helper(p->owner, "USERUSERINFO");
8178  if (useruser)
8179  pri_sr_set_useruser(sr, useruser);
8180 #endif
8181 
8182 #if defined(HAVE_PRI_CCSS)
8183  if (ast_cc_is_recall(ast, &core_id, sig_pri_cc_type_name)) {
8184  struct ast_cc_monitor *monitor;
8185  char device_name[AST_CHANNEL_NAME];
8186 
8187  /* This is a CC recall call. */
8188  ast_channel_get_device_name(ast, device_name, sizeof(device_name));
8189  monitor = ast_cc_get_monitor_by_recall_core_id(core_id, device_name);
8190  if (monitor) {
8191  struct sig_pri_cc_monitor_instance *instance;
8192 
8193  instance = monitor->private_data;
8194 
8195  /* If this fails then we have monitor instance ambiguity. */
8196  ast_assert(p->pri == instance->pri);
8197 
8198  if (pri_cc_call(p->pri->pri, instance->cc_id, p->call, sr)) {
8199  /* The CC recall call failed for some reason. */
8200  ast_log(LOG_WARNING, "Unable to setup CC recall call to device %s\n",
8201  device_name);
8202  ao2_ref(monitor, -1);
8203  pri_destroycall(p->pri->pri, p->call);
8204  p->call = NULL;
8205  pri_rel(p->pri);
8206  pri_sr_free(sr);
8207  return -1;
8208  }
8209  ao2_ref(monitor, -1);
8210  } else {
8211  core_id = -1;
8212  }
8213  } else
8214 #endif /* defined(HAVE_PRI_CCSS) */
8215  {
8216  core_id = -1;
8217  }
8218  if (core_id == -1 && pri_setup(p->pri->pri, p->call, sr)) {
8219  ast_log(LOG_WARNING, "Unable to setup call to %s (using %s)\n",
8220  c + p->stripmsd + dp_strip, dialplan2str(p->pri->dialplan));
8221  pri_destroycall(p->pri->pri, p->call);
8222  p->call = NULL;
8223  pri_rel(p->pri);
8224  pri_sr_free(sr);
8225  return -1;
8226  }
8228  pri_sr_free(sr);
8230  sig_pri_set_dialing(p, 1);
8231  pri_rel(p->pri);
8232  return 0;
8233 }
Information needed to identify an endpoint in a call.
Definition: channel.h:338
int nodetype
Definition: sig_pri.h:555
char user_tag[AST_MAX_EXTENSION *2]
User tag for party id's sent from this device driver.
Definition: sig_pri.h:301
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
unsigned int priexclusive
Definition: sig_pri.h:283
unsigned int use_callingpres
Definition: sig_pri.h:286
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:295
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
int facilityenable
Definition: sig_pri.h:451
char nationalprefix[10]
Definition: sig_pri.h:508
q931_call * call
Definition: sig_pri.h:356
ast_channel_state
ast_channel states
Definition: channelstate.h:35
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the subaddress information is valid/present.
Definition: channel.h:328
int dialplan
Definition: sig_pri.h:504
int localdialplan
Definition: sig_pri.h:505
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
int ast_cc_is_recall(struct ast_channel *chan, int *core_id, const char *const monitor_type)
Decide if a call to a particular channel is a CC recall.
Definition: ccss.c:3405
struct sig_pri_span * pri
Asterisk span D channel control structure.
Definition: sig_pri.c:149
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
Number structure.
Definition: app_followme.c:154
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
enum sig_pri_call_level call_level
Definition: sig_pri.h:359
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:87
char internationalprefix[10]
Definition: sig_pri.h:507
#define ast_debug(level,...)
Log a DEBUG message.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: main/app.c:3066
struct ast_party_subaddress subaddress
Subscriber subaddress.
Definition: channel.h:344
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
unsigned int hidecalleridname
Definition: sig_pri.h:281
unsigned int append_msn_to_user_tag
Definition: sig_pri.h:489
#define AST_CHANNEL_NAME
Definition: channel.h:171
char initial_user_tag[AST_MAX_EXTENSION]
Initial user tag for party id's sent from this device driver.
Definition: sig_pri.h:548
char deferred_digits[AST_MAX_EXTENSION]
Definition: sig_pri.h:312
Structure used to handle boolean flags.
Definition: utils.h:199
char * tag
User-set "tag".
Definition: channel.h:354
unsigned int is_call_waiting
TRUE if this is a call waiting call.
Definition: sig_pri.h:346
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
void ast_party_subaddress_init(struct ast_party_subaddress *init)
Initialize the given subaddress structure.
Definition: channel.c:1697
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
Definition: channel.c:7386
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Definition: channel.c:672
int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length)
Get a device name given its channel structure.
Definition: channel.c:10496
static const char * sig_pri_cc_type_name
Definition: sig_pri.c:159
void * private_data
Data that is private to a monitor technology.
Definition: ccss.h:527
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
Information needed to specify a subaddress in a call.
Definition: channel.h:307
struct ast_cc_monitor * ast_cc_get_monitor_by_recall_core_id(const int core_id, const char *const device_name)
Get the associated monitor given the device name and core_id.
Definition: ccss.c:3486
unsigned int no_dialed_digits
Definition: sig_pri.h:350
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
struct pri * pri
Definition: sig_pri.h:602
int channel
Definition: sig_pri.h:290
#define AST_APP_ARG(name)
Define an application argument.
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
int sig_pri_cc_agent_callee_available ( struct ast_cc_agent agent)

Alert the caller that it is time to try recalling.

Since
1.8
Parameters
agentCC core agent control.

The core will call this function when it receives notice that a monitored party has become available.

The agent's job is to send a message to the caller to notify it of such a change. If the agent is able to discern that the caller is currently unavailable, then the agent should react by calling the ast_cc_caller_unavailable function.

Return values
0on success.
-1on error.

Definition at line 9709 of file sig_pri.c.

References sig_pri_cc_agent_prv::cc_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9710 {
9711  struct sig_pri_cc_agent_prv *cc_pvt;
9712 
9713  cc_pvt = agent->private_data;
9714  ast_mutex_lock(&cc_pvt->pri->lock);
9715  pri_cc_remote_user_free(cc_pvt->pri->pri, cc_pvt->cc_id);
9716  ast_mutex_unlock(&cc_pvt->pri->lock);
9717  return 0;
9718 }
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
struct pri * pri
Definition: sig_pri.h:602
void sig_pri_cc_agent_destructor ( struct ast_cc_agent agent)

Destroy private data on the agent.

Since
1.8
Parameters
agentCC core agent control.

The core will call this function upon completion or failure of CC.

Note
The agent private_data pointer may be NULL if the agent constructor failed.

Definition at line 9736 of file sig_pri.c.

References sig_pri_cc_agent_prv::cc_id, sig_pri_cc_agent_prv::cc_request_response_pending, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9737 {
9738  struct sig_pri_cc_agent_prv *cc_pvt;
9739  int res;
9740 
9741  cc_pvt = agent->private_data;
9742  if (!cc_pvt) {
9743  /* The agent constructor probably failed. */
9744  return;
9745  }
9746  ast_mutex_lock(&cc_pvt->pri->lock);
9747  res = -1;
9748  if (cc_pvt->cc_request_response_pending) {
9749  res = pri_cc_req_rsp(cc_pvt->pri->pri, cc_pvt->cc_id, 2/* short_term_denial */);
9750  }
9751  if (res) {
9752  pri_cc_cancel(cc_pvt->pri->pri, cc_pvt->cc_id);
9753  }
9754  ast_mutex_unlock(&cc_pvt->pri->lock);
9755  ast_free(cc_pvt);
9756 }
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
unsigned char cc_request_response_pending
Definition: sig_pri.c:144
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_agent_init ( struct ast_cc_agent agent,
struct sig_pri_chan pvt_chan 
)

PRI CC agent initialization.

Since
1.8
Parameters
agentCC core agent control.
pvt_chanOriginal channel the agent will attempt to recall.

This callback is called when the CC core is initialized. Agents should allocate any private data necessary for the call and assign it to the private_data on the agent. Additionally, if any ast_cc_agent_flags are pertinent to the specific agent type, they should be set in this function as well.

Return values
0on success.
-1on error.

Definition at line 9423 of file sig_pri.c.

References ast_calloc, sig_pri_chan::call, sig_pri_cc_agent_prv::cc_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9424 {
9425  struct sig_pri_cc_agent_prv *cc_pvt;
9426 
9427  cc_pvt = ast_calloc(1, sizeof(*cc_pvt));
9428  if (!cc_pvt) {
9429  return -1;
9430  }
9431 
9432  ast_mutex_lock(&pvt_chan->pri->lock);
9433  cc_pvt->pri = pvt_chan->pri;
9434  cc_pvt->cc_id = pri_cc_available(pvt_chan->pri->pri, pvt_chan->call);
9435  ast_mutex_unlock(&pvt_chan->pri->lock);
9436  if (cc_pvt->cc_id == -1) {
9437  ast_free(cc_pvt);
9438  return -1;
9439  }
9440  agent->private_data = cc_pvt;
9441  return 0;
9442 }
void * private_data
Definition: ccss.h:834
q931_call * call
Definition: sig_pri.h:356
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_agent_party_b_free ( struct ast_cc_agent agent)

Let the caller know that the callee has become free but that the caller cannot attempt to call back because he is either busy or there is congestion on his line.

Since
1.8
Parameters
agentCC core agent control.

This is something that really only affects a scenario where a phone places a call over ISDN PTMP to Asterisk, who then connects over PTMP again to the ISDN network. For most agent types, there is no need to implement this callback at all because they don't really need to actually do anything in this situation. If you're having trouble understanding what the purpose of this callback is, then you can be safe simply not implementing it.

Return values
0on success.
-1on error.

Definition at line 9653 of file sig_pri.c.

References sig_pri_cc_agent_prv::cc_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9654 {
9655  struct sig_pri_cc_agent_prv *cc_pvt;
9656 
9657  cc_pvt = agent->private_data;
9658  ast_mutex_lock(&cc_pvt->pri->lock);
9659  pri_cc_b_free(cc_pvt->pri->pri, cc_pvt->cc_id);
9660  ast_mutex_unlock(&cc_pvt->pri->lock);
9661  return 0;
9662 }
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
struct pri * pri
Definition: sig_pri.h:602
void sig_pri_cc_agent_req_rsp ( struct ast_cc_agent agent,
enum ast_cc_agent_response_reason  reason 
)

Response to a CC request.

Since
1.8
Parameters
agentCC core agent control.
reasonCC request response status.

When the core receives knowledge that a called party has accepted a CC request, it will call this callback. The core may also call this if there is some error when attempting to process the incoming CC request.

The duty of this is to issue a propper response to a CC request from the caller by acknowledging receipt of that request or rejecting it.

Definition at line 9514 of file sig_pri.c.

References AST_CC_AGENT_RESPONSE_FAILURE_INVALID, AST_CC_AGENT_RESPONSE_FAILURE_TOO_MANY, AST_CC_AGENT_RESPONSE_SUCCESS, ast_cc_failed(), sig_pri_cc_agent_prv::cc_id, sig_pri_cc_agent_prv::cc_request_response_pending, ast_cc_agent::core_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, ast_cc_agent::private_data, and sig_pri_cc_type_name.

9515 {
9516  struct sig_pri_cc_agent_prv *cc_pvt;
9517  int res;
9518  int status;
9519  const char *failed_msg;
9520  static const char *failed_to_send = "Failed to send the CC request response.";
9521  static const char *not_accepted = "The core declined the CC request.";
9522 
9523  cc_pvt = agent->private_data;
9524  ast_mutex_lock(&cc_pvt->pri->lock);
9525  if (cc_pvt->cc_request_response_pending) {
9526  cc_pvt->cc_request_response_pending = 0;
9527 
9528  /* Convert core response reason to ISDN response status. */
9529  status = 2;/* short_term_denial */
9530  switch (reason) {
9532  status = 0;/* success */
9533  break;
9535  status = 2;/* short_term_denial */
9536  break;
9538  status = 5;/* queue_full */
9539  break;
9540  }
9541 
9542  res = pri_cc_req_rsp(cc_pvt->pri->pri, cc_pvt->cc_id, status);
9543  if (!status) {
9544  /* CC core request was accepted. */
9545  if (res) {
9546  failed_msg = failed_to_send;
9547  } else {
9548  failed_msg = NULL;
9549  }
9550  } else {
9551  /* CC core request was declined. */
9552  if (res) {
9553  failed_msg = failed_to_send;
9554  } else {
9555  failed_msg = not_accepted;
9556  }
9557  }
9558  } else {
9559  failed_msg = NULL;
9560  }
9561  ast_mutex_unlock(&cc_pvt->pri->lock);
9562  if (failed_msg) {
9563  ast_cc_failed(agent->core_id, "%s agent: %s", sig_pri_cc_type_name, failed_msg);
9564  }
9565 }
int ast_cc_failed(int core_id, const char *const debug,...)
Indicate failure has occurred.
Definition: ccss.c:3844
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
unsigned int core_id
Definition: ccss.h:812
unsigned char cc_request_response_pending
Definition: sig_pri.c:144
static const char * sig_pri_cc_type_name
Definition: sig_pri.c:159
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_agent_start_monitoring ( struct ast_cc_agent agent)

Begin monitoring a busy device.

Since
1.8
Parameters
agentCC core agent control.

The core will call this callback if the callee becomes available but the caller has reported that he is busy. The agent should begin monitoring the caller's device. When the caller becomes available again, the agent should call ast_cc_agent_caller_available.

Return values
0on success.
-1on error.

Definition at line 9682 of file sig_pri.c.

9683 {
9684  /* libpri already knows when and how it needs to monitor Party A. */
9685  return 0;
9686 }
int sig_pri_cc_agent_start_offer_timer ( struct ast_cc_agent agent)

Start the offer timer.

Since
1.8
Parameters
agentCC core agent control.

This is called by the core when the caller hangs up after a call for which CC may be requested. The agent should begin the timer as configured.

The primary reason why this functionality is left to the specific agent implementations is due to the differing use of schedulers throughout the code. Some channel drivers may already have a scheduler context they wish to use, and amongst those, some may use the ast_sched API while others may use the ast_sched_thread API, which are incompatible.

Return values
0on success.
-1on error.

Definition at line 9467 of file sig_pri.c.

9468 {
9469  /* libpri maintains it's own offer timer in the form of T_RETENTION. */
9470  return 0;
9471 }
int sig_pri_cc_agent_status_req ( struct ast_cc_agent agent)

Request the status of the agent's device.

Since
1.8
Parameters
agentCC core agent control.

Asynchronous request for the status of any caller which may be a valid caller for the CC transaction. Status responses should be made using the ast_cc_status_response function.

Return values
0on success.
-1on error.

Definition at line 9584 of file sig_pri.c.

References sig_pri_cc_agent_prv::cc_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9585 {
9586  struct sig_pri_cc_agent_prv *cc_pvt;
9587 
9588  cc_pvt = agent->private_data;
9589  ast_mutex_lock(&cc_pvt->pri->lock);
9590  pri_cc_status_req(cc_pvt->pri->pri, cc_pvt->cc_id);
9591  ast_mutex_unlock(&cc_pvt->pri->lock);
9592  return 0;
9593 }
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_agent_stop_offer_timer ( struct ast_cc_agent agent)

Stop the offer timer.

Since
1.8
Parameters
agentCC core agent control.

This callback is called by the CC core when the caller has requested CC.

Return values
0on success.
-1on error.

Definition at line 9488 of file sig_pri.c.

9489 {
9490  /* libpri maintains it's own offer timer in the form of T_RETENTION. */
9491  return 0;
9492 }
int sig_pri_cc_agent_stop_ringing ( struct ast_cc_agent agent)

Request for an agent's phone to stop ringing.

Since
1.8
Parameters
agentCC core agent control.

The usefulness of this is quite limited. The only specific known case for this is if Asterisk requests CC over an ISDN PTMP link as the TE side. If other phones are in the same recall group as the Asterisk server, and one of those phones picks up the recall notice, then Asterisk will receive a "stop ringing" notification from the NT side of the PTMP link. This indication needs to be passed to the phone on the other side of the Asterisk server which originally placed the call so that it will stop ringing. Since the phone may be of any type, it is necessary to have a callback that the core can know about.

Return values
0on success.
-1on error.

Definition at line 9619 of file sig_pri.c.

References sig_pri_cc_agent_prv::cc_id, sig_pri_span::lock, sig_pri_cc_agent_prv::pri, sig_pri_span::pri, and ast_cc_agent::private_data.

9620 {
9621  struct sig_pri_cc_agent_prv *cc_pvt;
9622 
9623  cc_pvt = agent->private_data;
9624  ast_mutex_lock(&cc_pvt->pri->lock);
9625  pri_cc_stop_alerting(cc_pvt->pri->pri, cc_pvt->cc_id);
9626  ast_mutex_unlock(&cc_pvt->pri->lock);
9627  return 0;
9628 }
void * private_data
Definition: ccss.h:834
ast_mutex_t lock
Definition: sig_pri.h:616
struct sig_pri_span * pri
Definition: sig_pri.c:140
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_monitor_cancel_available_timer ( struct ast_cc_monitor monitor,
int *  sched_id 
)

Cancel the running available timer.

Since
1.8
Parameters
monitorCC core monitor control.
sched_idAvailable timer scheduler id to cancel. Will never be NULL for a device monitor.

In most cases, this function will likely consist of just a call to AST_SCHED_DEL. It might have been possible to do this within the core, but unfortunately the mixture of sched_thread and sched usage in Asterisk prevents such usage.

Return values
0on success
-1on failure.

Definition at line 9962 of file sig_pri.c.

9963 {
9964  /*
9965  * libpri maintains it's own available timer as one of:
9966  * T_CCBS2/T_CCBS5/T_CCBS6/QSIG_CCBS_T2
9967  * T_CCNR2/T_CCNR5/T_CCNR6/QSIG_CCNR_T2
9968  */
9969  return 0;
9970 }
void sig_pri_cc_monitor_destructor ( void *  monitor_pvt)

Destroy PRI private data on the monitor.

Since
1.8
Parameters
monitor_pvtCC device monitor private data pointer.

Implementers of this callback are responsible for destroying all heap-allocated data in the monitor's private_data pointer, including the private_data itself.

Definition at line 9985 of file sig_pri.c.

References ao2_ref, and ao2_unlink.

9986 {
9987  struct sig_pri_cc_monitor_instance *instance;
9988 
9989  instance = monitor_pvt;
9990  if (!instance) {
9991  return;
9992  }
9993  ao2_unlink(sig_pri_cc_monitors, instance);
9994  ao2_ref(instance, -1);
9995 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static struct ao2_container * sig_pri_cc_monitors
Definition: sig_pri.c:161
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
int sig_pri_cc_monitor_req_cc ( struct ast_cc_monitor monitor,
int *  available_timer_id 
)

Request CCSS.

Since
1.8
Parameters
monitorCC core monitor control.
available_timer_idWhere to put the available timer scheduler id. Will never be NULL for a device monitor.

Perform whatever steps are necessary in order to request CC. In addition, the monitor implementation is responsible for starting the available timer in this callback. The scheduler ID for the callback must be stored in the parent_link's child_avail_id field.

Return values
0on success
-1on failure.

Definition at line 9818 of file sig_pri.c.

References sig_pri_cc_monitor_instance::cc_id, sig_pri_span::lock, sig_pri_cc_monitor_instance::pri, sig_pri_span::pri, ast_cc_monitor::private_data, and ast_cc_monitor::service_offered.

9819 {
9820  struct sig_pri_cc_monitor_instance *instance;
9821  int cc_mode;
9822  int res;
9823 
9824  switch (monitor->service_offered) {
9825  case AST_CC_CCBS:
9826  cc_mode = 0;/* CCBS */
9827  break;
9828  case AST_CC_CCNR:
9829  cc_mode = 1;/* CCNR */
9830  break;
9831  default:
9832  /* CC service not supported by ISDN. */
9833  return -1;
9834  }
9835 
9836  instance = monitor->private_data;
9837 
9838  /* libpri handles it's own available timer. */
9839  ast_mutex_lock(&instance->pri->lock);
9840  res = pri_cc_req(instance->pri->pri, instance->cc_id, cc_mode);
9841  ast_mutex_unlock(&instance->pri->lock);
9842 
9843  return res;
9844 }
struct sig_pri_span * pri
Asterisk span D channel control structure.
Definition: sig_pri.c:149
ast_mutex_t lock
Definition: sig_pri.h:616
void * private_data
Data that is private to a monitor technology.
Definition: ccss.h:527
enum ast_cc_service_type service_offered
Definition: ccss.h:498
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_monitor_status_rsp ( struct ast_cc_monitor monitor,
enum ast_device_state  devstate 
)

Status response to an ast_cc_monitor_status_request().

Since
1.8
Parameters
monitorCC core monitor control.
devstateCurrent status of a Party A device.

Alert a monitor as to the status of the agent for which the monitor had previously requested a status request.

Note
Zero or more responses may come as a result.
Return values
0on success
-1on failure.

Definition at line 9917 of file sig_pri.c.

References AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVICE_UNKNOWN, sig_pri_cc_monitor_instance::cc_id, sig_pri_span::lock, sig_pri_cc_monitor_instance::pri, sig_pri_span::pri, and ast_cc_monitor::private_data.

9918 {
9919  struct sig_pri_cc_monitor_instance *instance;
9920  int cc_status;
9921 
9922  switch (devstate) {
9923  case AST_DEVICE_UNKNOWN:
9924  case AST_DEVICE_NOT_INUSE:
9925  cc_status = 0;/* free */
9926  break;
9927  case AST_DEVICE_BUSY:
9928  case AST_DEVICE_INUSE:
9929  cc_status = 1;/* busy */
9930  break;
9931  default:
9932  /* Don't know how to interpret this device state into free/busy status. */
9933  return 0;
9934  }
9935  instance = monitor->private_data;
9936  ast_mutex_lock(&instance->pri->lock);
9937  pri_cc_status_req_rsp(instance->pri->pri, instance->cc_id, cc_status);
9938  ast_mutex_unlock(&instance->pri->lock);
9939 
9940  return 0;
9941 }
struct sig_pri_span * pri
Asterisk span D channel control structure.
Definition: sig_pri.c:149
ast_mutex_t lock
Definition: sig_pri.h:616
void * private_data
Data that is private to a monitor technology.
Definition: ccss.h:527
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_monitor_suspend ( struct ast_cc_monitor monitor)

Suspend monitoring.

Since
1.8
Parameters
monitorCC core monitor control.

Implementers must perform the necessary steps to suspend monitoring.

Return values
0on success
-1on failure.

Definition at line 9861 of file sig_pri.c.

References sig_pri_cc_monitor_instance::cc_id, sig_pri_span::lock, sig_pri_cc_monitor_instance::pri, sig_pri_span::pri, and ast_cc_monitor::private_data.

9862 {
9863  struct sig_pri_cc_monitor_instance *instance;
9864 
9865  instance = monitor->private_data;
9866  ast_mutex_lock(&instance->pri->lock);
9867  pri_cc_status(instance->pri->pri, instance->cc_id, 1/* busy */);
9868  ast_mutex_unlock(&instance->pri->lock);
9869 
9870  return 0;
9871 }
struct sig_pri_span * pri
Asterisk span D channel control structure.
Definition: sig_pri.c:149
ast_mutex_t lock
Definition: sig_pri.h:616
void * private_data
Data that is private to a monitor technology.
Definition: ccss.h:527
struct pri * pri
Definition: sig_pri.h:602
int sig_pri_cc_monitor_unsuspend ( struct ast_cc_monitor monitor)

Unsuspend monitoring.

Since
1.8
Parameters
monitorCC core monitor control.

Perform the necessary steps to unsuspend monitoring.

Return values
0on success
-1on failure.

Definition at line 9887 of file sig_pri.c.

References sig_pri_cc_monitor_instance::cc_id, sig_pri_span::lock, sig_pri_cc_monitor_instance::pri, sig_pri_span::pri, and ast_cc_monitor::private_data.

9888 {
9889  struct sig_pri_cc_monitor_instance *instance;
9890 
9891  instance = monitor->private_data;
9892  ast_mutex_lock(&instance->pri->lock);
9893  pri_cc_status(instance->pri->pri, instance->cc_id, 0/* free */);
9894  ast_mutex_unlock(&instance->pri->lock);
9895 
9896  return 0;
9897 }
struct sig_pri_span * pri
Asterisk span D channel control structure.
Definition: sig_pri.c:149
ast_mutex_t lock
Definition: sig_pri.h:616
void * private_data
Data that is private to a monitor technology.
Definition: ccss.h:527
struct pri * pri
Definition: sig_pri.h:602
void sig_pri_chan_alarm_notify ( struct sig_pri_chan p,
int  noalarm 
)

Notify new alarm status.

Parameters
pChannel private pointer.
noalarmNon-zero if not in alarm mode.
Note
Assumes the sig_pri_lock_private(p) is already obtained.

Definition at line 9163 of file sig_pri.c.

References AST_SOFTHANGUP_DEV, sig_pri_chan::call, and sig_pri_span::pri.

9164 {
9165  pri_grab(p, p->pri);
9166  sig_pri_set_alarm(p, !noalarm);
9167  if (!noalarm) {
9168  if (pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0) {
9169  /* T309 is not enabled : destroy calls when alarm occurs */
9170  if (p->call) {
9171  pri_destroycall(p->pri->pri, p->call);
9172  p->call = NULL;
9173  }
9174  if (p->owner)
9175  ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
9176  }
9177  }
9178  sig_pri_span_devstate_changed(p->pri);
9179  pri_rel(p->pri);
9180 }
q931_call * call
Definition: sig_pri.h:356
struct pri * pri
Definition: sig_pri.h:602
void sig_pri_chan_delete ( struct sig_pri_chan doomed)

Delete the sig_pri private channel structure.

Since
1.8
Parameters
doomedsig_pri private channel structure to delete.

Definition at line 9219 of file sig_pri.c.

9220 {
9221  ast_free(doomed);
9222 }
void sig_pri_dial_complete ( struct sig_pri_chan pvt,
struct ast_channel ast 
)

DTMF dial string complete.

Since
1.8.11
Parameters
pvtsig_pri private channel structure.
astAsterisk channel
Note
Channel and private lock are already held.

Definition at line 8726 of file sig_pri.c.

References AST_CONTROL_ANSWER, AST_FRAME_CONTROL, ast_queue_frame(), sig_pri_chan::call_level, sig_pri_chan::chan_pvt, ast_frame_subclass::integer, SIG_PRI_CALL_LEVEL_CONNECT, SIG_PRI_CALL_LEVEL_DEFER_DIAL, sig_pri_callbacks, and ast_frame::subclass.

8727 {
8728  /* If we just completed 'w' deferred dialing digits, we need to answer now. */
8731 
8732  sig_pri_open_media(pvt);
8733  {
8734  struct ast_frame f = {AST_FRAME_CONTROL, };
8735 
8736  if (sig_pri_callbacks.queue_control) {
8737  sig_pri_callbacks.queue_control(pvt->chan_pvt, AST_CONTROL_ANSWER);
8738  }
8739 
8741  ast_queue_frame(ast, &f);
8742  }
8743  sig_pri_set_dialing(pvt, 0);
8744  /* Enable echo cancellation if it's not on already */
8745  sig_pri_set_echocanceller(pvt, 1);
8746  }
8747 }
struct sig_pri_callback sig_pri_callbacks
Definition: chan_dahdi.c:3310
void * chan_pvt
Definition: sig_pri.h:374
struct ast_frame_subclass subclass
enum sig_pri_call_level call_level
Definition: sig_pri.h:359
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
Data structure associated with a single frame of data.
void sig_pri_extract_called_num_subaddr ( struct sig_pri_chan p,
const char *  rdest,
char *  called,
size_t  called_buff_size 
)

Extract the called number and subaddress from the dial string.

Since
1.8
Parameters
psig_pri channel structure.
rdestDial string buffer to extract called number and subaddress.
calledBuffer to fill with extracted <number>[:<subaddress>]
called_buff_sizeSize of buffer to fill.
Note
Parsing must remain in sync with sig_pri_call().

Definition at line 7694 of file sig_pri.c.

References AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_NONSTANDARD_APP_ARGS, and ast_strdupa.

7695 {
7696  char *dial;
7697  char *number;
7698  char *subaddr;
7699  AST_DECLARE_APP_ARGS(args,
7700  AST_APP_ARG(group); /* channel/group token */
7701  AST_APP_ARG(ext); /* extension token */
7702  //AST_APP_ARG(opts); /* options token */
7703  AST_APP_ARG(other); /* Any remining unused arguments */
7704  );
7705 
7706  /* Get private copy of dial string and break it up. */
7707  dial = ast_strdupa(rdest);
7708  AST_NONSTANDARD_APP_ARGS(args, dial, '/');
7709 
7710  number = args.ext;
7711  if (!number) {
7712  number = "";
7713  }
7714 
7715  /* Find and extract dialed_subaddress */
7716  subaddr = strchr(number, ':');
7717  if (subaddr) {
7718  *subaddr++ = '\0';
7719 
7720  /* Skip subaddress type prefix. */
7721  switch (*subaddr) {
7722  case 'U':
7723  case 'u':
7724  case 'N':
7725  case 'n':
7726  ++subaddr;
7727  break;
7728  default:
7729  break;
7730  }
7731  }
7732 
7733  /* Skip type-of-number/dial-plan prefix characters. */
7734  if (strlen(number) < p->stripmsd) {
7735  number = "";
7736  } else {
7737  char *deferred;
7738 
7739  number += p->stripmsd;
7740  deferred = strchr(number, 'w');
7741  if (deferred) {
7742  /* Remove any 'w' deferred digits. */
7743  *deferred = '\0';
7744  }
7745  while (isalpha(*number)) {
7746  ++number;
7747  }
7748  }
7749 
7750  /* Fill buffer with extracted number and subaddress. */
7751  if (ast_strlen_zero(subaddr)) {
7752  /* Put in called number only since there is no subaddress. */
7753  snprintf(called, called_buff_size, "%s", number);
7754  } else {
7755  /* Put in called number and subaddress. */
7756  snprintf(called, called_buff_size, "%s:%s", number, subaddr);
7757  }
7758 }
Number structure.
Definition: app_followme.c:154
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.
int sig_pri_is_alarm_ignored ( struct sig_pri_span pri)

Determine if layer 1 alarms are ignored.

Parameters
priChannel private pointer.
Returns
TRUE if the alarm is ignored.

Definition at line 9189 of file sig_pri.c.

References sig_pri_span::layer1_ignored.

9190 {
9191  return pri->layer1_ignored;
9192 }
unsigned int layer1_ignored
Definition: sig_pri.h:484
int sig_pri_is_chan_available ( struct sig_pri_chan pvt)

Determine if a private channel structure is available.

Since
1.8
Parameters
pvtChannel to determine if available.
Returns
TRUE if the channel is available.

Definition at line 1218 of file sig_pri.c.

References sig_pri_chan::service_status.

1219 {
1220  return !sig_pri_is_chan_in_use(pvt)
1221 #if defined(HAVE_PRI_SERVICE_MESSAGES)
1222  /* And not out-of-service */
1223  && !pvt->service_status
1224 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */
1225  ;
1226 }
unsigned service_status
Active SRVST_DBKEY out-of-service status value.
Definition: sig_pri.h:371
int sig_pri_load ( const char *  cc_type_name)

Load the sig_pri submodule.

Since
1.8
Parameters
cc_type_nameCC type name to use when looking up agent/monitor.
Return values
0on success.
-1on error.

Definition at line 10007 of file sig_pri.c.

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, sig_pri_cc_type_name, and STASIS_MESSAGE_TYPE_INIT.

Referenced by load_module().

10008 {
10009 #if defined(HAVE_PRI_MCID)
10010  if (STASIS_MESSAGE_TYPE_INIT(mcid_type)) {
10011  return -1;
10012  }
10013 #endif /* defined(HAVE_PRI_MCID) */
10014 
10015 #if defined(HAVE_PRI_CCSS)
10016  sig_pri_cc_type_name = cc_type_name;
10018  sig_pri_cc_monitor_instance_hash_fn, NULL, sig_pri_cc_monitor_instance_cmp_fn);
10019  if (!sig_pri_cc_monitors) {
10020  return -1;
10021  }
10022 #endif /* defined(HAVE_PRI_CCSS) */
10023  return 0;
10024 }
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
static struct ao2_container * sig_pri_cc_monitors
Definition: sig_pri.c:161
static const char * sig_pri_cc_type_name
Definition: sig_pri.c:159
void sig_pri_sendtext ( struct sig_pri_chan p,
const char *  text 
)

Send display text.

Since
10.0
Parameters
pChannel to send text over
textText to send.

Definition at line 9391 of file sig_pri.c.

References ast_copy_string(), sig_pri_chan::call, and sig_pri_span::pri.

9392 {
9393  struct pri_subcmd_display_txt display;
9394 
9395  if (p->pri && p->pri->pri) {
9396  ast_copy_string(display.text, text, sizeof(display.text));
9397  display.length = strlen(display.text);
9398  display.char_set = 0;/* unknown(0) */
9399  pri_grab(p, p->pri);
9400  pri_display_text(p->pri->pri, p->call, &display);
9401  pri_rel(p->pri);
9402  }
9403 }
q931_call * call
Definition: sig_pri.h:356
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
struct pri * pri
Definition: sig_pri.h:602
void sig_pri_stop_pri ( struct sig_pri_span pri)

Stop PRI span.

Since
1.8
Parameters
priPRI span control structure.

Definition at line 8872 of file sig_pri.c.

References ast_mwi_unsubscribe_and_join(), sig_pri_span::mbox, and sig_pri_mbox::sub.

8873 {
8874 #if defined(HAVE_PRI_MWI)
8875  int idx;
8876 #endif /* defined(HAVE_PRI_MWI) */
8877 
8878 #if defined(HAVE_PRI_MWI)
8879  for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) {
8880  if (pri->mbox[idx].sub) {
8881  pri->mbox[idx].sub = ast_mwi_unsubscribe_and_join(pri->mbox[idx].sub);
8882  }
8883  }
8884 #endif /* defined(HAVE_PRI_MWI) */
8885 }
struct sig_pri_mbox mbox[SIG_PRI_MAX_MWI_MAILBOXES]
Active MWI mailboxes.
Definition: sig_pri.h:522
struct ast_mwi_subscriber * sub
MWI mailbox event subscription.
Definition: sig_pri.h:425
void * ast_mwi_unsubscribe_and_join(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic, block until the final message is received, and then unsubscribe fr...
Definition: mwi.c:259
void sig_pri_unload ( void  )

Unload the sig_pri submodule.

Since
1.8

Definition at line 10030 of file sig_pri.c.

References ao2_ref, and STASIS_MESSAGE_TYPE_CLEANUP.

10031 {
10032 #if defined(HAVE_PRI_CCSS)
10033  if (sig_pri_cc_monitors) {
10035  sig_pri_cc_monitors = NULL;
10036  }
10037 #endif /* defined(HAVE_PRI_CCSS) */
10038 
10039 #if defined(HAVE_PRI_MCID)
10040  STASIS_MESSAGE_TYPE_CLEANUP(mcid_type);
10041 #endif /* defined(HAVE_PRI_MCID) */
10042 }
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
Definition: stasis.h:1515
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static struct ao2_container * sig_pri_cc_monitors
Definition: sig_pri.c:161

Variable Documentation

struct ao2_container* sig_pri_cc_monitors
static

Container of sig_pri monitor instances.

Definition at line 161 of file sig_pri.c.

const char* sig_pri_cc_type_name
static

Upper level agent/monitor type name.

Definition at line 159 of file sig_pri.c.

Referenced by sig_pri_call(), sig_pri_cc_agent_req_rsp(), and sig_pri_load().

const sig_pri_moh_fsm_state sig_pri_moh_fsm[SIG_PRI_MOH_STATE_NUM]
static

MOH FSM state table.

Definition at line 5213 of file sig_pri.c.