#include "asterisk/channel.h"
#include "asterisk/frame.h"
#include "asterisk/event.h"
#include "asterisk/ccss.h"
#include <libpri.h>
#include <dahdi/user.h>


Go to the source code of this file.
Data Structures | |
| struct | sig_pri_callback |
| struct | sig_pri_chan |
| struct | sig_pri_span |
Defines | |
| #define | DAHDI_CHAN_MAPPING_LOGICAL 1 |
| #define | DAHDI_CHAN_MAPPING_PHYSICAL 0 |
| #define | DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING) |
| #define | DAHDI_OVERLAPDIAL_INCOMING 2 |
| #define | DAHDI_OVERLAPDIAL_NONE 0 |
| #define | DAHDI_OVERLAPDIAL_OUTGOING 1 |
| #define | SIG_BRI (0x2000000 | DAHDI_SIG_CLEAR) |
| #define | SIG_BRI_PTMP (0X4000000 | DAHDI_SIG_CLEAR) |
| #define | SIG_PRI DAHDI_SIG_CLEAR |
| #define | SIG_PRI_AOC_GRANT_D (1 << 1) |
| #define | SIG_PRI_AOC_GRANT_E (1 << 2) |
| #define | SIG_PRI_AOC_GRANT_S (1 << 0) |
| #define | SIG_PRI_DEBUG_DEFAULT 0 |
| #define | SIG_PRI_DEBUG_INTENSE |
| #define | SIG_PRI_DEBUG_NORMAL (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE) |
| #define | SIG_PRI_MAX_CHANNELS 672 |
| #define | SIG_PRI_NUM_DCHANS 4 |
| #define | SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND) |
| SRVST_BOTH is used to indicate that both sides of the channel are out-of-service. | |
| #define | SRVST_DBKEY "service-state" |
| Persistent Service State. | |
| #define | SRVST_FAREND (1 << 1) |
| SRVST_FAREND is used to indicate that the far end was taken out-of-service. | |
| #define | SRVST_INITIALIZED 0 |
| SRVST_INITIALIZED is used to indicate a channel being out-of-service The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may mean that the channel has not yet received a RESTART message. If a channel is out-of-service with this reason a RESTART message will result in the channel being put into service. | |
| #define | SRVST_NEAREND (1 << 0) |
| SRVST_NEAREND is used to indicate that the near end was put out-of-service. | |
| #define | SRVST_TYPE_OOS "O" |
| The out-of-service SERVICE state. | |
Enumerations | |
| enum | sig_pri_law { SIG_PRI_DEFLAW = 0, SIG_PRI_ULAW, SIG_PRI_ALAW } |
| enum | sig_pri_tone { SIG_PRI_TONE_RINGTONE = 0, SIG_PRI_TONE_STUTTER, SIG_PRI_TONE_CONGESTION, SIG_PRI_TONE_DIALTONE, SIG_PRI_TONE_DIALRECALL, SIG_PRI_TONE_INFO, SIG_PRI_TONE_BUSY } |
Functions | |
| 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) |
| int | pri_is_up (struct sig_pri_span *pri) |
| int | pri_maintenance_bservice (struct pri *pri, struct sig_pri_chan *p, int changestatus) |
| 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) |
| int | sig_pri_answer (struct sig_pri_chan *p, struct ast_channel *ast) |
| int | sig_pri_available (struct sig_pri_chan **pvt, int is_specific_channel) |
| int | sig_pri_call (struct sig_pri_chan *p, struct ast_channel *ast, char *rdest, int timeout, int layer1) |
| int | sig_pri_cc_agent_callee_available (struct ast_cc_agent *agent) |
| void | sig_pri_cc_agent_destructor (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_init (struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan) |
| int | sig_pri_cc_agent_party_b_free (struct ast_cc_agent *agent) |
| void | sig_pri_cc_agent_req_ack (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_start_monitoring (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_start_offer_timer (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_status_req (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_stop_offer_timer (struct ast_cc_agent *agent) |
| int | sig_pri_cc_agent_stop_ringing (struct ast_cc_agent *agent) |
| int | sig_pri_cc_monitor_cancel_available_timer (struct ast_cc_monitor *monitor, int *sched_id) |
| void | sig_pri_cc_monitor_destructor (void *monitor_pvt) |
| int | sig_pri_cc_monitor_req_cc (struct ast_cc_monitor *monitor, int *available_timer_id) |
| int | sig_pri_cc_monitor_status_rsp (struct ast_cc_monitor *monitor, enum ast_device_state devstate) |
| int | sig_pri_cc_monitor_suspend (struct ast_cc_monitor *monitor) |
| int | sig_pri_cc_monitor_unsuspend (struct ast_cc_monitor *monitor) |
| void | sig_pri_chan_alarm_notify (struct sig_pri_chan *p, int noalarm) |
| void | sig_pri_chan_delete (struct sig_pri_chan *doomed) |
| Delete the sig_pri private channel structure. | |
| struct sig_pri_chan * | sig_pri_chan_new (void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup) |
| 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) |
| int | sig_pri_digit_begin (struct sig_pri_chan *pvt, struct ast_channel *ast, char digit) |
| 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. | |
| void | sig_pri_fixup (struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan) |
| 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) |
| void | sig_pri_init_pri (struct sig_pri_span *pri) |
| int | sig_pri_load (const char *cc_type_name) |
| Load the sig_pri submodule. | |
| struct ast_channel * | sig_pri_request (struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability) |
| int | sig_pri_start_pri (struct sig_pri_span *pri) |
| void | sig_pri_stop_pri (struct sig_pri_span *pri) |
| Stop PRI span. | |
| void | sig_pri_unload (void) |
| Unload the sig_pri submodule. | |
Variables | |
| static const char | dahdi_db [] = "dahdi/registry" |
| The AstDB family. | |
Definition in file sig_pri.h.
| #define DAHDI_CHAN_MAPPING_LOGICAL 1 |
| #define DAHDI_CHAN_MAPPING_PHYSICAL 0 |
Definition at line 140 of file sig_pri.h.
Referenced by dahdi_chan_conf_default(), and process_dahdi().
| #define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING) |
| #define DAHDI_OVERLAPDIAL_INCOMING 2 |
Definition at line 146 of file sig_pri.h.
Referenced by dahdi_handle_event(), dahdi_read(), pri_dchannel(), pri_ss_thread(), process_dahdi(), and sig_pri_cli_show_span().
| #define DAHDI_OVERLAPDIAL_NONE 0 |
| #define DAHDI_OVERLAPDIAL_OUTGOING 1 |
Definition at line 145 of file sig_pri.h.
Referenced by dahdi_read(), process_dahdi(), and sig_pri_start_pri().
| #define SIG_PRI_AOC_GRANT_D (1 << 1) |
Definition at line 67 of file sig_pri.h.
Referenced by process_dahdi(), sig_pri_handle_subcmds(), and sig_pri_indicate().
| #define SIG_PRI_AOC_GRANT_E (1 << 2) |
Definition at line 68 of file sig_pri.h.
Referenced by process_dahdi(), sig_pri_handle_subcmds(), and sig_pri_indicate().
| #define SIG_PRI_AOC_GRANT_S (1 << 0) |
Definition at line 66 of file sig_pri.h.
Referenced by process_dahdi(), sig_pri_handle_subcmds(), and sig_pri_indicate().
| #define SIG_PRI_DEBUG_DEFAULT 0 |
PRI debug message flags set on initial startup.
Definition at line 63 of file sig_pri.h.
Referenced by sig_pri_start_pri().
| #define SIG_PRI_DEBUG_INTENSE |
Value:
(PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE \ | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP)
Definition at line 53 of file sig_pri.h.
Referenced by handle_pri_debug().
| #define SIG_PRI_DEBUG_NORMAL (PRI_DEBUG_APDU | PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE | PRI_DEBUG_Q921_STATE) |
PRI debug message flags when normal PRI debugging is turned on at the command line.
Definition at line 49 of file sig_pri.h.
Referenced by handle_pri_debug().
| #define SIG_PRI_MAX_CHANNELS 672 |
| #define SIG_PRI_NUM_DCHANS 4 |
No more than 4 d-channels
Definition at line 132 of file sig_pri.h.
Referenced by __unload_module(), dahdi_pri_error(), dahdi_pri_message(), dahdi_restart(), handle_pri_debug(), handle_pri_service_generic(), handle_pri_show_debug(), mkintf(), prepare_pri(), pri_active_dchan_index(), pri_create_trunkgroup(), pri_find_dchan(), pri_is_up(), setup_dahdi_int(), sig_pri_cli_show_span(), sig_pri_cli_show_spans(), sig_pri_init_pri(), and sig_pri_start_pri().
| #define SRVST_BOTH (SRVST_NEAREND | SRVST_FAREND) |
| #define SRVST_DBKEY "service-state" |
Persistent Service State.
Definition at line 151 of file sig_pri.h.
Referenced by destroy_all_channels(), handle_pri_service_generic(), mkintf(), and pri_dchannel().
| #define SRVST_FAREND (1 << 1) |
SRVST_FAREND is used to indicate that the far end was taken out-of-service.
Definition at line 163 of file sig_pri.h.
Referenced by mkintf(), pri_check_restart(), and pri_dchannel().
| #define SRVST_INITIALIZED 0 |
SRVST_INITIALIZED is used to indicate a channel being out-of-service The SRVST_INITIALIZED is mostly used maintain backwards compatibility but also may mean that the channel has not yet received a RESTART message. If a channel is out-of-service with this reason a RESTART message will result in the channel being put into service.
| #define SRVST_NEAREND (1 << 0) |
SRVST_NEAREND is used to indicate that the near end was put out-of-service.
Definition at line 161 of file sig_pri.h.
Referenced by handle_pri_service_generic(), mkintf(), pri_check_restart(), and pri_dchannel().
| #define SRVST_TYPE_OOS "O" |
The out-of-service SERVICE state.
Definition at line 153 of file sig_pri.h.
Referenced by handle_pri_service_generic(), and pri_dchannel().
| enum sig_pri_law |
Definition at line 80 of file sig_pri.h.
00080 { 00081 SIG_PRI_DEFLAW = 0, 00082 SIG_PRI_ULAW, 00083 SIG_PRI_ALAW 00084 };
| enum sig_pri_tone |
| SIG_PRI_TONE_RINGTONE | |
| SIG_PRI_TONE_STUTTER | |
| SIG_PRI_TONE_CONGESTION | |
| SIG_PRI_TONE_DIALTONE | |
| SIG_PRI_TONE_DIALRECALL | |
| SIG_PRI_TONE_INFO | |
| SIG_PRI_TONE_BUSY |
Definition at line 70 of file sig_pri.h.
00070 { 00071 SIG_PRI_TONE_RINGTONE = 0, 00072 SIG_PRI_TONE_STUTTER, 00073 SIG_PRI_TONE_CONGESTION, 00074 SIG_PRI_TONE_DIALTONE, 00075 SIG_PRI_TONE_DIALRECALL, 00076 SIG_PRI_TONE_INFO, 00077 SIG_PRI_TONE_BUSY, 00078 };
| void pri_event_alarm | ( | struct sig_pri_span * | pri, | |
| int | index, | |||
| int | before_start_pri | |||
| ) |
Definition at line 1615 of file sig_pri.c.
References DCHAN_NOTINALARM, DCHAN_UP, sig_pri_span::dchanavail, and pri_find_dchan().
Referenced by my_handle_dchan_exception(), and prepare_pri().
01616 { 01617 pri->dchanavail[index] &= ~(DCHAN_NOTINALARM | DCHAN_UP); 01618 if (!before_start_pri) 01619 pri_find_dchan(pri); 01620 }
| void pri_event_noalarm | ( | struct sig_pri_span * | pri, | |
| int | index, | |||
| int | before_start_pri | |||
| ) |
Definition at line 1622 of file sig_pri.c.
References DCHAN_NOTINALARM, sig_pri_span::dchanavail, and sig_pri_span::dchans.
Referenced by my_handle_dchan_exception(), and prepare_pri().
01623 { 01624 pri->dchanavail[index] |= DCHAN_NOTINALARM; 01625 if (!before_start_pri) 01626 pri_restart(pri->dchans[index]); 01627 }
| int pri_is_up | ( | struct sig_pri_span * | pri | ) |
Definition at line 927 of file sig_pri.c.
References DCHAN_AVAILABLE, sig_pri_span::dchanavail, and SIG_PRI_NUM_DCHANS.
Referenced by pri_dchannel().
00928 { 00929 int x; 00930 for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { 00931 if (pri->dchanavail[x] == DCHAN_AVAILABLE) 00932 return 1; 00933 } 00934 return 0; 00935 }
| int pri_maintenance_bservice | ( | struct pri * | pri, | |
| struct sig_pri_chan * | p, | |||
| int | changestatus | |||
| ) |
Definition at line 7185 of file sig_pri.c.
References sig_pri_chan::channel, PRI_SPAN, and PVT_TO_CHANNEL().
Referenced by handle_pri_service_generic().
07186 { 07187 int channel = PVT_TO_CHANNEL(p); 07188 int span = PRI_SPAN(channel); 07189 07190 return pri_maintenance_service(pri, span, channel, changestatus); 07191 }
| 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 | |||
| ) |
Definition at line 7160 of file sig_pri.c.
References ast_log(), sig_pri_chan::call, LOG_DEBUG, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_lock_private(), sig_pri_unlock_private(), and sig_pri_span::span.
Referenced by dahdi_send_callrerouting_facility_exec().
07161 { 07162 int res = -1; 07163 07164 sig_pri_lock_private(p); 07165 07166 if (!p->pri || !p->call) { 07167 ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n"); 07168 sig_pri_unlock_private(p); 07169 return -1; 07170 } 07171 07172 if (!pri_grab(p, p->pri)) { 07173 res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason); 07174 pri_rel(p->pri); 07175 } else { 07176 ast_log(LOG_DEBUG, "Unable to grab pri to send callrerouting facility on span %d!\n", p->pri->span); 07177 } 07178 07179 sig_pri_unlock_private(p); 07180 07181 return res; 07182 }
| int pri_send_keypad_facility_exec | ( | struct sig_pri_chan * | p, | |
| const char * | digits | |||
| ) |
Definition at line 7136 of file sig_pri.c.
References ast_debug, sig_pri_chan::call, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_lock_private(), and sig_pri_unlock_private().
Referenced by dahdi_send_keypad_facility_exec().
07137 { 07138 sig_pri_lock_private(p); 07139 07140 if (!p->pri || !p->call) { 07141 ast_debug(1, "Unable to find pri or call on channel!\n"); 07142 sig_pri_unlock_private(p); 07143 return -1; 07144 } 07145 07146 if (!pri_grab(p, p->pri)) { 07147 pri_keypad_facility(p->pri->pri, p->call, digits); 07148 pri_rel(p->pri); 07149 } else { 07150 ast_debug(1, "Unable to grab pri to send keypad facility!\n"); 07151 sig_pri_unlock_private(p); 07152 return -1; 07153 } 07154 07155 sig_pri_unlock_private(p); 07156 07157 return 0; 07158 }
| int sig_pri_answer | ( | struct sig_pri_chan * | p, | |
| struct ast_channel * | ast | |||
| ) |
Definition at line 6504 of file sig_pri.c.
References ast_setstate(), AST_STATE_UP, sig_pri_chan::call, sig_pri_chan::digital, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_chan::proceeding, sig_pri_open_media(), and sig_pri_set_dialing().
Referenced by dahdi_answer().
06505 { 06506 int res = 0; 06507 /* Send a pri acknowledge */ 06508 if (!pri_grab(p, p->pri)) { 06509 #if defined(HAVE_PRI_AOC_EVENTS) 06510 if (p->aoc_s_request_invoke_id_valid) { 06511 /* if AOC-S was requested and the invoke id is still present on answer. That means 06512 * no AOC-S rate list was provided, so send a NULL response which will indicate that 06513 * AOC-S is not available */ 06514 pri_aoc_s_request_response_send(p->pri->pri, p->call, 06515 p->aoc_s_request_invoke_id, NULL); 06516 p->aoc_s_request_invoke_id_valid = 0; 06517 } 06518 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 06519 p->proceeding = 1; 06520 sig_pri_set_dialing(p, 0); 06521 sig_pri_open_media(p); 06522 res = pri_answer(p->pri->pri, p->call, 0, !p->digital); 06523 pri_rel(p->pri); 06524 } else { 06525 res = -1; 06526 } 06527 ast_setstate(ast, AST_STATE_UP); 06528 return res; 06529 }
| int sig_pri_available | ( | struct sig_pri_chan ** | pvt, | |
| int | is_specific_channel | |||
| ) |
Definition at line 6606 of file sig_pri.c.
References sig_pri_chan::pri, and sig_pri_available_check().
Referenced by available().
06607 { 06608 struct sig_pri_chan *p = *pvt; 06609 06610 if (!p->pri) { 06611 /* Something is wrong here. A PRI channel without the pri pointer? */ 06612 return 0; 06613 } 06614 06615 if ( 06616 #if defined(HAVE_PRI_CALL_WAITING) 06617 /* 06618 * Only do call waiting calls if we have any 06619 * call waiting call outstanding. We do not 06620 * want new calls to steal a B channel 06621 * freed for an earlier call waiting call. 06622 */ 06623 !p->pri->num_call_waiting_calls && 06624 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 06625 sig_pri_available_check(p)) { 06626 return 1; 06627 } 06628 06629 #if defined(HAVE_PRI_CALL_WAITING) 06630 if (!is_specific_channel) { 06631 struct sig_pri_chan *cw; 06632 06633 cw = sig_pri_cw_available(p->pri); 06634 if (cw) { 06635 /* We have a call waiting interface to use instead. */ 06636 *pvt = cw; 06637 return 1; 06638 } 06639 } 06640 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 06641 return 0; 06642 }
| int sig_pri_call | ( | struct sig_pri_chan * | p, | |
| struct ast_channel * | ast, | |||
| char * | rdest, | |||
| int | timeout, | |||
| int | layer1 | |||
| ) |
Definition at line 5863 of file sig_pri.c.
References ast_channel::_state, ao2_ref, sig_pri_span::append_msn_to_user_tag, args, AST_APP_ARG, ast_app_parse_options(), ast_assert, ast_cc_get_monitor_by_recall_core_id(), ast_cc_is_recall(), ast_channel_get_device_name(), AST_CHANNEL_NAME, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_free, ast_log(), AST_NONSTANDARD_APP_ARGS, ast_party_subaddress_init(), ast_setstate(), AST_STATE_DIALING, AST_STATE_DOWN, AST_STATE_RESERVED, ast_strdup, ast_strlen_zero(), ast_test_flag, ast_transfercapability2str(), ast_verb, sig_pri_chan::call, ast_channel::caller, sig_pri_chan::channel, ast_channel::connected, sig_pri_chan::dialdest, sig_pri_span::dialplan, dialplan2str(), sig_pri_chan::digital, ext, sig_pri_span::facilityenable, sig_pri_chan::hidecallerid, sig_pri_chan::hidecalleridname, ast_party_caller::id, ast_party_connected_line::id, sig_pri_span::initial_user_tag, sig_pri_span::internationalprefix, IS_DIGITAL, sig_pri_span::localdialplan, LOG_DEBUG, LOG_ERROR, LOG_WARNING, ast_channel::name, ast_party_id::name, sig_pri_span::nationalprefix, sig_pri_span::nodetype, ast_party_id::number, ast_party_subaddress::odd_even_indicator, OPT_AOC_REQUEST, OPT_ARG_AOC_REQUEST, OPT_ARG_ARRAY_SIZE, OPT_ARG_KEYPAD, OPT_KEYPAD, OPT_REVERSE_CHARGE, sig_pri_chan::outgoing, sig_pri_chan::owner, pbx_builtin_getvar_helper(), ast_party_number::presentation, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), PRI_TRANS_CAP_DIGITAL, sig_pri_chan::priexclusive, ast_cc_monitor::private_data, PVT_TO_CHANNEL(), S_COR, sig_pri_call_opts, sig_pri_party_subaddress_from_ast(), sig_pri_redirecting_update(), sig_pri_set_dialing(), sig_pri_set_digital(), ast_party_subaddress::str, ast_party_number::str, ast_party_name::str, sig_pri_chan::stripmsd, ast_party_id::subaddress, ast_party_id::tag, ast_channel::transfercapability, ast_party_subaddress::type, sig_pri_chan::use_callingpres, sig_pri_chan::user_tag, ast_party_subaddress::valid, ast_party_number::valid, and ast_party_name::valid.
Referenced by dahdi_call().
05864 { 05865 char dest[256]; /* must be same length as p->dialdest */ 05866 struct ast_party_subaddress dialed_subaddress; /* Called subaddress */ 05867 struct pri_sr *sr; 05868 char *c, *l, *n, *s; 05869 #ifdef SUPPORT_USERUSER 05870 const char *useruser; 05871 #endif 05872 int core_id; 05873 int pridialplan; 05874 int dp_strip; 05875 int prilocaldialplan; 05876 int ldp_strip; 05877 int exclusive; 05878 #if defined(HAVE_PRI_SETUP_KEYPAD) 05879 const char *keypad; 05880 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */ 05881 AST_DECLARE_APP_ARGS(args, 05882 AST_APP_ARG(group); /* channel/group token */ 05883 AST_APP_ARG(ext); /* extension token */ 05884 AST_APP_ARG(opts); /* options token */ 05885 AST_APP_ARG(other); /* Any remining unused arguments */ 05886 ); 05887 struct ast_flags opts; 05888 char *opt_args[OPT_ARG_ARRAY_SIZE]; 05889 05890 ast_log(LOG_DEBUG, "CALLER NAME: %s NUM: %s\n", 05891 S_COR(ast->connected.id.name.valid, ast->connected.id.name.str, ""), 05892 S_COR(ast->connected.id.number.valid, ast->connected.id.number.str, "")); 05893 05894 if (!p->pri) { 05895 ast_log(LOG_ERROR, "Could not find pri on channel %d\n", p->channel); 05896 return -1; 05897 } 05898 05899 if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) { 05900 ast_log(LOG_WARNING, "sig_pri_call called on %s, neither down nor reserved\n", ast->name); 05901 return -1; 05902 } 05903 05904 p->dialdest[0] = '\0'; 05905 p->outgoing = 1; 05906 05907 ast_copy_string(dest, rdest, sizeof(dest)); 05908 AST_NONSTANDARD_APP_ARGS(args, dest, '/'); 05909 if (ast_app_parse_options(sig_pri_call_opts, &opts, opt_args, args.opts)) { 05910 /* General invalid option syntax. */ 05911 return -1; 05912 } 05913 05914 c = args.ext; 05915 if (!c) { 05916 c = ""; 05917 } 05918 05919 /* setup dialed_subaddress if found */ 05920 ast_party_subaddress_init(&dialed_subaddress); 05921 s = strchr(c, ':'); 05922 if (s) { 05923 *s = '\0'; 05924 s++; 05925 /* prefix */ 05926 /* 'n' = NSAP */ 05927 /* 'U' = odd, 'u'= even */ 05928 /* Default = NSAP */ 05929 switch (*s) { 05930 case 'U': 05931 dialed_subaddress.odd_even_indicator = 1; 05932 /* fall through */ 05933 case 'u': 05934 s++; 05935 dialed_subaddress.type = 2; 05936 break; 05937 case 'N': 05938 case 'n': 05939 s++; 05940 /* default already covered with ast_party_subaddress_init */ 05941 break; 05942 } 05943 dialed_subaddress.str = s; 05944 dialed_subaddress.valid = 1; 05945 s = NULL; 05946 } 05947 05948 l = NULL; 05949 n = NULL; 05950 if (!p->hidecallerid) { 05951 if (ast->connected.id.number.valid) { 05952 /* If we get to the end of this loop without breaking, there's no 05953 * calleridnum. This is done instead of testing for "unknown" or 05954 * the thousands of other ways that the calleridnum could be 05955 * invalid. */ 05956 for (l = ast->connected.id.number.str; l && *l; l++) { 05957 if (strchr("0123456789", *l)) { 05958 l = ast->connected.id.number.str; 05959 break; 05960 } 05961 } 05962 } else { 05963 l = NULL; 05964 } 05965 if (!p->hidecalleridname) { 05966 n = ast->connected.id.name.valid ? ast->connected.id.name.str : NULL; 05967 } 05968 } 05969 05970 if (strlen(c) < p->stripmsd) { 05971 ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd); 05972 return -1; 05973 } 05974 if (pri_grab(p, p->pri)) { 05975 ast_log(LOG_WARNING, "Failed to grab PRI!\n"); 05976 return -1; 05977 } 05978 if (!(p->call = pri_new_call(p->pri->pri))) { 05979 ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel); 05980 pri_rel(p->pri); 05981 return -1; 05982 } 05983 if (!(sr = pri_sr_new())) { 05984 ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel); 05985 pri_destroycall(p->pri->pri, p->call); 05986 p->call = NULL; 05987 pri_rel(p->pri); 05988 return -1; 05989 } 05990 05991 sig_pri_set_digital(p, IS_DIGITAL(ast->transfercapability)); /* push up to parent for EC */ 05992 05993 #if defined(HAVE_PRI_CALL_WAITING) 05994 if (p->is_call_waiting) { 05995 /* 05996 * Indicate that this is a call waiting call. 05997 * i.e., Normal call but with no B channel. 05998 */ 05999 pri_sr_set_channel(sr, 0, 0, 1); 06000 } else 06001 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 06002 { 06003 /* Should the picked channel be used exclusively? */ 06004 if (p->priexclusive || p->pri->nodetype == PRI_NETWORK) { 06005 exclusive = 1; 06006 } else { 06007 exclusive = 0; 06008 } 06009 pri_sr_set_channel(sr, PVT_TO_CHANNEL(p), exclusive, 1); 06010 } 06011 06012 pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 06013 (p->digital ? -1 : layer1)); 06014 06015 if (p->pri->facilityenable) 06016 pri_facility_enable(p->pri->pri); 06017 06018 ast_verb(3, "Requested transfer capability: 0x%.2x - %s\n", ast->transfercapability, ast_transfercapability2str(ast->transfercapability)); 06019 dp_strip = 0; 06020 pridialplan = p->pri->dialplan - 1; 06021 if (pridialplan == -2 || pridialplan == -3) { /* compute dynamically */ 06022 if (strncmp(c + p->stripmsd, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { 06023 if (pridialplan == -2) { 06024 dp_strip = strlen(p->pri->internationalprefix); 06025 } 06026 pridialplan = PRI_INTERNATIONAL_ISDN; 06027 } else if (strncmp(c + p->stripmsd, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { 06028 if (pridialplan == -2) { 06029 dp_strip = strlen(p->pri->nationalprefix); 06030 } 06031 pridialplan = PRI_NATIONAL_ISDN; 06032 } else { 06033 pridialplan = PRI_LOCAL_ISDN; 06034 } 06035 } 06036 while (c[p->stripmsd] > '9' && c[p->stripmsd] != '*' && c[p->stripmsd] != '#') { 06037 switch (c[p->stripmsd]) { 06038 case 'U': 06039 pridialplan = (PRI_TON_UNKNOWN << 4) | (pridialplan & 0xf); 06040 break; 06041 case 'I': 06042 pridialplan = (PRI_TON_INTERNATIONAL << 4) | (pridialplan & 0xf); 06043 break; 06044 case 'N': 06045 pridialplan = (PRI_TON_NATIONAL << 4) | (pridialplan & 0xf); 06046 break; 06047 case 'L': 06048 pridialplan = (PRI_TON_NET_SPECIFIC << 4) | (pridialplan & 0xf); 06049 break; 06050 case 'S': 06051 pridialplan = (PRI_TON_SUBSCRIBER << 4) | (pridialplan & 0xf); 06052 break; 06053 case 'V': 06054 pridialplan = (PRI_TON_ABBREVIATED << 4) | (pridialplan & 0xf); 06055 break; 06056 case 'R': 06057 pridialplan = (PRI_TON_RESERVED << 4) | (pridialplan & 0xf); 06058 break; 06059 case 'u': 06060 pridialplan = PRI_NPI_UNKNOWN | (pridialplan & 0xf0); 06061 break; 06062 case 'e': 06063 pridialplan = PRI_NPI_E163_E164 | (pridialplan & 0xf0); 06064 break; 06065 case 'x': 06066 pridialplan = PRI_NPI_X121 | (pridialplan & 0xf0); 06067 break; 06068 case 'f': 06069 pridialplan = PRI_NPI_F69 | (pridialplan & 0xf0); 06070 break; 06071 case 'n': 06072 pridialplan = PRI_NPI_NATIONAL | (pridialplan & 0xf0); 06073 break; 06074 case 'p': 06075 pridialplan = PRI_NPI_PRIVATE | (pridialplan & 0xf0); 06076 break; 06077 case 'r': 06078 pridialplan = PRI_NPI_RESERVED | (pridialplan & 0xf0); 06079 break; 06080 default: 06081 if (isalpha(c[p->stripmsd])) { 06082 ast_log(LOG_WARNING, "Unrecognized pridialplan %s modifier: %c\n", 06083 c[p->stripmsd] > 'Z' ? "NPI" : "TON", c[p->stripmsd]); 06084 } 06085 break; 06086 } 06087 c++; 06088 } 06089 #if defined(HAVE_PRI_SETUP_KEYPAD) 06090 if (ast_test_flag(&opts, OPT_KEYPAD) 06091 && !ast_strlen_zero(opt_args[OPT_ARG_KEYPAD])) { 06092 /* We have a keypad facility digits option with digits. */ 06093 keypad = opt_args[OPT_ARG_KEYPAD]; 06094 pri_sr_set_keypad_digits(sr, keypad); 06095 } else { 06096 keypad = NULL; 06097 } 06098 if (!keypad || !ast_strlen_zero(c + p->stripmsd + dp_strip)) 06099 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */ 06100 { 06101 pri_sr_set_called(sr, c + p->stripmsd + dp_strip, pridialplan, s ? 1 : 0); 06102 } 06103 06104 #if defined(HAVE_PRI_SUBADDR) 06105 if (dialed_subaddress.valid) { 06106 struct pri_party_subaddress subaddress; 06107 06108 memset(&subaddress, 0, sizeof(subaddress)); 06109 sig_pri_party_subaddress_from_ast(&subaddress, &dialed_subaddress); 06110 pri_sr_set_called_subaddress(sr, &subaddress); 06111 } 06112 #endif /* defined(HAVE_PRI_SUBADDR) */ 06113 #if defined(HAVE_PRI_REVERSE_CHARGE) 06114 if (ast_test_flag(&opts, OPT_REVERSE_CHARGE)) { 06115 pri_sr_set_reversecharge(sr, PRI_REVERSECHARGE_REQUESTED); 06116 } 06117 #endif /* defined(HAVE_PRI_REVERSE_CHARGE) */ 06118 #if defined(HAVE_PRI_AOC_EVENTS) 06119 if (ast_test_flag(&opts, OPT_AOC_REQUEST) 06120 && !ast_strlen_zero(opt_args[OPT_ARG_AOC_REQUEST])) { 06121 if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 's')) { 06122 pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_S); 06123 } 06124 if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 'd')) { 06125 pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_D); 06126 } 06127 if (strchr(opt_args[OPT_ARG_AOC_REQUEST], 'e')) { 06128 pri_sr_set_aoc_charging_request(sr, PRI_AOC_REQUEST_E); 06129 } 06130 } 06131 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 06132 06133 /* Setup the user tag for party id's from this device for this call. */ 06134 if (p->pri->append_msn_to_user_tag) { 06135 snprintf(p->user_tag, sizeof(p->user_tag), "%s_%s", p->pri->initial_user_tag, 06136 p->pri->nodetype == PRI_NETWORK 06137 ? c + p->stripmsd + dp_strip 06138 : S_COR(ast->connected.id.number.valid, 06139 ast->connected.id.number.str, "")); 06140 } else { 06141 ast_copy_string(p->user_tag, p->pri->initial_user_tag, sizeof(p->user_tag)); 06142 } 06143 06144 /* 06145 * Replace the caller id tag from the channel creation 06146 * with the actual tag value. 06147 */ 06148 ast_free(ast->caller.id.tag); 06149 ast->caller.id.tag = ast_strdup(p->user_tag); 06150 06151 ldp_strip = 0; 06152 prilocaldialplan = p->pri->localdialplan - 1; 06153 if ((l != NULL) && (prilocaldialplan == -2 || prilocaldialplan == -3)) { /* compute dynamically */ 06154 if (strncmp(l, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { 06155 if (prilocaldialplan == -2) { 06156 ldp_strip = strlen(p->pri->internationalprefix); 06157 } 06158 prilocaldialplan = PRI_INTERNATIONAL_ISDN; 06159 } else if (strncmp(l, p->pri->nationalprefix, strlen(p->pri->nationalprefix)) == 0) { 06160 if (prilocaldialplan == -2) { 06161 ldp_strip = strlen(p->pri->nationalprefix); 06162 } 06163 prilocaldialplan = PRI_NATIONAL_ISDN; 06164 } else { 06165 prilocaldialplan = PRI_LOCAL_ISDN; 06166 } 06167 } 06168 if (l != NULL) { 06169 while (*l > '9' && *l != '*' && *l != '#') { 06170 switch (*l) { 06171 case 'U': 06172 prilocaldialplan = (PRI_TON_UNKNOWN << 4) | (prilocaldialplan & 0xf); 06173 break; 06174 case 'I': 06175 prilocaldialplan = (PRI_TON_INTERNATIONAL << 4) | (prilocaldialplan & 0xf); 06176 break; 06177 case 'N': 06178 prilocaldialplan = (PRI_TON_NATIONAL << 4) | (prilocaldialplan & 0xf); 06179 break; 06180 case 'L': 06181 prilocaldialplan = (PRI_TON_NET_SPECIFIC << 4) | (prilocaldialplan & 0xf); 06182 break; 06183 case 'S': 06184 prilocaldialplan = (PRI_TON_SUBSCRIBER << 4) | (prilocaldialplan & 0xf); 06185 break; 06186 case 'V': 06187 prilocaldialplan = (PRI_TON_ABBREVIATED << 4) | (prilocaldialplan & 0xf); 06188 break; 06189 case 'R': 06190 prilocaldialplan = (PRI_TON_RESERVED << 4) | (prilocaldialplan & 0xf); 06191 break; 06192 case 'u': 06193 prilocaldialplan = PRI_NPI_UNKNOWN | (prilocaldialplan & 0xf0); 06194 break; 06195 case 'e': 06196 prilocaldialplan = PRI_NPI_E163_E164 | (prilocaldialplan & 0xf0); 06197 break; 06198 case 'x': 06199 prilocaldialplan = PRI_NPI_X121 | (prilocaldialplan & 0xf0); 06200 break; 06201 case 'f': 06202 prilocaldialplan = PRI_NPI_F69 | (prilocaldialplan & 0xf0); 06203 break; 06204 case 'n': 06205 prilocaldialplan = PRI_NPI_NATIONAL | (prilocaldialplan & 0xf0); 06206 break; 06207 case 'p': 06208 prilocaldialplan = PRI_NPI_PRIVATE | (prilocaldialplan & 0xf0); 06209 break; 06210 case 'r': 06211 prilocaldialplan = PRI_NPI_RESERVED | (prilocaldialplan & 0xf0); 06212 break; 06213 default: 06214 if (isalpha(*l)) { 06215 ast_log(LOG_WARNING, 06216 "Unrecognized prilocaldialplan %s modifier: %c\n", 06217 *l > 'Z' ? "NPI" : "TON", *l); 06218 } 06219 break; 06220 } 06221 l++; 06222 } 06223 } 06224 pri_sr_set_caller(sr, l ? (l + ldp_strip) : NULL, n, prilocaldialplan, 06225 p->use_callingpres ? ast->connected.id.number.presentation : (l ? PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN : PRES_NUMBER_NOT_AVAILABLE)); 06226 06227 #if defined(HAVE_PRI_SUBADDR) 06228 if (ast->connected.id.subaddress.valid) { 06229 struct pri_party_subaddress subaddress; 06230 06231 memset(&subaddress, 0, sizeof(subaddress)); 06232 sig_pri_party_subaddress_from_ast(&subaddress, &ast->connected.id.subaddress); 06233 pri_sr_set_caller_subaddress(sr, &subaddress); 06234 } 06235 #endif /* defined(HAVE_PRI_SUBADDR) */ 06236 06237 sig_pri_redirecting_update(p, ast); 06238 06239 #ifdef SUPPORT_USERUSER 06240 /* User-user info */ 06241 useruser = pbx_builtin_getvar_helper(p->owner, "USERUSERINFO"); 06242 if (useruser) 06243 pri_sr_set_useruser(sr, useruser); 06244 #endif 06245 06246 #if defined(HAVE_PRI_CCSS) 06247 if (ast_cc_is_recall(ast, &core_id, sig_pri_cc_type_name)) { 06248 struct ast_cc_monitor *monitor; 06249 char device_name[AST_CHANNEL_NAME]; 06250 06251 /* This is a CC recall call. */ 06252 ast_channel_get_device_name(ast, device_name, sizeof(device_name)); 06253 monitor = ast_cc_get_monitor_by_recall_core_id(core_id, device_name); 06254 if (monitor) { 06255 struct sig_pri_cc_monitor_instance *instance; 06256 06257 instance = monitor->private_data; 06258 06259 /* If this fails then we have monitor instance ambiguity. */ 06260 ast_assert(p->pri == instance->pri); 06261 06262 if (pri_cc_call(p->pri->pri, instance->cc_id, p->call, sr)) { 06263 /* The CC recall call failed for some reason. */ 06264 ast_log(LOG_WARNING, "Unable to setup CC recall call to device %s\n", 06265 device_name); 06266 ao2_ref(monitor, -1); 06267 pri_rel(p->pri); 06268 pri_sr_free(sr); 06269 return -1; 06270 } 06271 ao2_ref(monitor, -1); 06272 } else { 06273 core_id = -1; 06274 } 06275 } else 06276 #endif /* defined(HAVE_PRI_CCSS) */ 06277 { 06278 core_id = -1; 06279 } 06280 if (core_id == -1 && pri_setup(p->pri->pri, p->call, sr)) { 06281 ast_log(LOG_WARNING, "Unable to setup call to %s (using %s)\n", 06282 c + p->stripmsd + dp_strip, dialplan2str(p->pri->dialplan)); 06283 pri_rel(p->pri); 06284 pri_sr_free(sr); 06285 return -1; 06286 } 06287 pri_sr_free(sr); 06288 ast_setstate(ast, AST_STATE_DIALING); 06289 sig_pri_set_dialing(p, 1); 06290 pri_rel(p->pri); 06291 return 0; 06292 }
| int sig_pri_cc_agent_callee_available | ( | struct ast_cc_agent * | agent | ) |
| void sig_pri_cc_agent_destructor | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_init | ( | struct ast_cc_agent * | agent, | |
| struct sig_pri_chan * | pvt_chan | |||
| ) |
| int sig_pri_cc_agent_party_b_free | ( | struct ast_cc_agent * | agent | ) |
| void sig_pri_cc_agent_req_ack | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_start_monitoring | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_start_offer_timer | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_status_req | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_stop_offer_timer | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_agent_stop_ringing | ( | struct ast_cc_agent * | agent | ) |
| int sig_pri_cc_monitor_cancel_available_timer | ( | struct ast_cc_monitor * | monitor, | |
| int * | sched_id | |||
| ) |
| void sig_pri_cc_monitor_destructor | ( | void * | monitor_pvt | ) |
| int sig_pri_cc_monitor_req_cc | ( | struct ast_cc_monitor * | monitor, | |
| int * | available_timer_id | |||
| ) |
| int sig_pri_cc_monitor_status_rsp | ( | struct ast_cc_monitor * | monitor, | |
| enum ast_device_state | devstate | |||
| ) |
| int sig_pri_cc_monitor_suspend | ( | struct ast_cc_monitor * | monitor | ) |
| int sig_pri_cc_monitor_unsuspend | ( | struct ast_cc_monitor * | monitor | ) |
| void sig_pri_chan_alarm_notify | ( | struct sig_pri_chan * | p, | |
| int | noalarm | |||
| ) |
Definition at line 7020 of file sig_pri.c.
References ast_channel::_softhangup, ast_log(), AST_SOFTHANGUP_DEV, sig_pri_chan::call, LOG_WARNING, sig_pri_chan::owner, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), and sig_pri_set_alarm().
Referenced by dahdi_handle_event(), handle_init_event(), and mkintf().
07021 { 07022 sig_pri_set_alarm(p, !noalarm); 07023 if (!noalarm) { 07024 if (!p->pri || !p->pri->pri || (pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0)) { 07025 /* T309 is not enabled : hangup calls when alarm occurs */ 07026 if (p->call) { 07027 if (p->pri && p->pri->pri) { 07028 if (!pri_grab(p, p->pri)) { 07029 pri_hangup(p->pri->pri, p->call, -1); 07030 pri_destroycall(p->pri->pri, p->call); 07031 p->call = NULL; 07032 pri_rel(p->pri); 07033 } else 07034 ast_log(LOG_WARNING, "Failed to grab PRI!\n"); 07035 } else 07036 ast_log(LOG_WARNING, "The PRI Call has not been destroyed\n"); 07037 } 07038 if (p->owner) 07039 p->owner->_softhangup |= AST_SOFTHANGUP_DEV; 07040 } 07041 } 07042 }
| void sig_pri_chan_delete | ( | struct sig_pri_chan * | doomed | ) |
Delete the sig_pri private channel structure.
| doomed | sig_pri private channel structure to delete. |
Definition at line 7072 of file sig_pri.c.
References ast_free.
Referenced by destroy_dahdi_pvt().
07073 { 07074 ast_free(doomed); 07075 }
| struct sig_pri_chan* sig_pri_chan_new | ( | void * | pvt_data, | |
| struct sig_pri_callback * | callback, | |||
| struct sig_pri_span * | pri, | |||
| int | logicalspan, | |||
| int | channo, | |||
| int | trunkgroup | |||
| ) | [read] |
Definition at line 7044 of file sig_pri.c.
References ast_calloc, sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::logicalspan, sig_pri_chan::mastertrunkgroup, sig_pri_chan::pri, and sig_pri_chan::prioffset.
Referenced by dahdi_new_pri_nobch_channel(), and mkintf().
07045 { 07046 struct sig_pri_chan *p; 07047 07048 p = ast_calloc(1, sizeof(*p)); 07049 if (!p) 07050 return p; 07051 07052 p->logicalspan = logicalspan; 07053 p->prioffset = channo; 07054 p->mastertrunkgroup = trunkgroup; 07055 07056 p->calls = callback; 07057 p->chan_pvt = pvt_data; 07058 07059 p->pri = pri; 07060 07061 return p; 07062 }
| void sig_pri_cli_show_span | ( | int | fd, | |
| int * | dchannels, | |||
| struct sig_pri_span * | pri | |||
| ) |
Definition at line 7108 of file sig_pri.c.
References ast_cli(), build_status(), DAHDI_OVERLAPDIAL_INCOMING, sig_pri_span::dchanavail, sig_pri_span::dchans, free, sig_pri_span::overlapdial, sig_pri_span::pri, pri_order(), SIG_PRI_NUM_DCHANS, and status.
Referenced by handle_pri_show_span().
07109 { 07110 int x; 07111 char status[256]; 07112 07113 for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { 07114 if (pri->dchans[x]) { 07115 #ifdef PRI_DUMP_INFO_STR 07116 char *info_str = NULL; 07117 #endif 07118 ast_cli(fd, "%s D-channel: %d\n", pri_order(x), dchannels[x]); 07119 build_status(status, sizeof(status), pri->dchanavail[x], pri->dchans[x] == pri->pri); 07120 ast_cli(fd, "Status: %s\n", status); 07121 #ifdef PRI_DUMP_INFO_STR 07122 info_str = pri_dump_info_str(pri->pri); 07123 if (info_str) { 07124 ast_cli(fd, "%s", info_str); 07125 free(info_str); 07126 } 07127 #else 07128 pri_dump_info(pri->pri); 07129 #endif 07130 ast_cli(fd, "Overlap Recv: %s\n\n", (pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)?"Yes":"No"); 07131 ast_cli(fd, "\n"); 07132 } 07133 } 07134 }
| void sig_pri_cli_show_spans | ( | int | fd, | |
| int | span, | |||
| struct sig_pri_span * | pri | |||
| ) |
Definition at line 7096 of file sig_pri.c.
References ast_cli(), build_status(), sig_pri_span::dchanavail, sig_pri_span::dchans, sig_pri_span::pri, SIG_PRI_NUM_DCHANS, and status.
Referenced by handle_pri_show_spans().
07097 { 07098 char status[256]; 07099 int x; 07100 for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { 07101 if (pri->dchans[x]) { 07102 build_status(status, sizeof(status), pri->dchanavail[x], pri->dchans[x] == pri->pri); 07103 ast_cli(fd, "PRI span %d/%d: %s\n", span, x, status); 07104 } 07105 } 07106 }
| int sig_pri_digit_begin | ( | struct sig_pri_chan * | pvt, | |
| struct ast_channel * | ast, | |||
| char | digit | |||
| ) |
Definition at line 6646 of file sig_pri.c.
References ast_channel::_state, ast_debug, ast_log(), AST_STATE_DIALING, sig_pri_chan::call, sig_pri_chan::dialdest, LOG_WARNING, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_chan::proceeding, sig_pri_chan::setup_ack, and sig_pri_span::span.
Referenced by dahdi_digit_begin().
06647 { 06648 if ((ast->_state == AST_STATE_DIALING) && !pvt->proceeding) { 06649 if (pvt->setup_ack) { 06650 if (!pri_grab(pvt, pvt->pri)) { 06651 pri_information(pvt->pri->pri, pvt->call, digit); 06652 pri_rel(pvt->pri); 06653 } else { 06654 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->pri->span); 06655 } 06656 } else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) { 06657 int res; 06658 ast_debug(1, "Queueing digit '%c' since setup_ack not yet received\n", digit); 06659 res = strlen(pvt->dialdest); 06660 pvt->dialdest[res++] = digit; 06661 pvt->dialdest[res] = '\0'; 06662 } 06663 return 0; 06664 } 06665 return 1; 06666 }
| 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.
| p | sig_pri channel structure. | |
| rdest | Dial string buffer to extract called number and subaddress. | |
| called | Buffer to fill with extracted <number>[:<subaddress>] | |
| called_buff_size | Size of buffer to fill. |
Definition at line 5784 of file sig_pri.c.
References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_NONSTANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ext, and sig_pri_chan::stripmsd.
Referenced by dahdi_request().
05785 { 05786 char *dial; 05787 char *number; 05788 char *subaddr; 05789 AST_DECLARE_APP_ARGS(args, 05790 AST_APP_ARG(group); /* channel/group token */ 05791 AST_APP_ARG(ext); /* extension token */ 05792 //AST_APP_ARG(opts); /* options token */ 05793 AST_APP_ARG(other); /* Any remining unused arguments */ 05794 ); 05795 05796 /* Get private copy of dial string and break it up. */ 05797 dial = ast_strdupa(rdest); 05798 AST_NONSTANDARD_APP_ARGS(args, dial, '/'); 05799 05800 number = args.ext; 05801 if (!number) { 05802 number = ""; 05803 } 05804 05805 /* Find and extract dialed_subaddress */ 05806 subaddr = strchr(number, ':'); 05807 if (subaddr) { 05808 *subaddr++ = '\0'; 05809 05810 /* Skip subaddress type prefix. */ 05811 switch (*subaddr) { 05812 case 'U': 05813 case 'u': 05814 case 'N': 05815 case 'n': 05816 ++subaddr; 05817 break; 05818 default: 05819 break; 05820 } 05821 } 05822 05823 /* Skip type-of-number/dial-plan prefix characters. */ 05824 if (strlen(number) < p->stripmsd) { 05825 number = ""; 05826 } else { 05827 number += p->stripmsd; 05828 while (isalpha(*number)) { 05829 ++number; 05830 } 05831 } 05832 05833 /* Fill buffer with extracted number and subaddress. */ 05834 if (ast_strlen_zero(subaddr)) { 05835 /* Put in called number only since there is no subaddress. */ 05836 snprintf(called, called_buff_size, "%s", number); 05837 } else { 05838 /* Put in called number and subaddress. */ 05839 snprintf(called, called_buff_size, "%s:%s", number, subaddr); 05840 } 05841 }
| void sig_pri_fixup | ( | struct ast_channel * | oldchan, | |
| struct ast_channel * | newchan, | |||
| struct sig_pri_chan * | pchan | |||
| ) |
Definition at line 7194 of file sig_pri.c.
References sig_pri_chan::owner.
Referenced by dahdi_fixup().
| int sig_pri_hangup | ( | struct sig_pri_chan * | p, | |
| struct ast_channel * | ast | |||
| ) |
Definition at line 5682 of file sig_pri.c.
References sig_pri_chan::alerting, sig_pri_chan::alreadyhungup, ast_atomic_fetchadd_int(), ast_log(), sig_pri_chan::call, cause, sig_pri_chan::channel, sig_pri_chan::cid_name, sig_pri_chan::cid_num, sig_pri_chan::cid_subaddr, sig_pri_chan::exten, ast_channel::hangupcause, LOG_DEBUG, LOG_WARNING, sig_pri_chan::outgoing, sig_pri_chan::owner, pbx_builtin_getvar_helper(), sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_chan::proceeding, sig_pri_chan::progress, sig_pri_chan::setup_ack, sig_pri_set_dialing(), sig_pri_set_digital(), sig_pri_span_devstate_changed(), sig_pri_span::span, ast_channel::tech_pvt, and sig_pri_chan::user_tag.
Referenced by dahdi_hangup().
05683 { 05684 int res; 05685 #ifdef SUPPORT_USERUSER 05686 const char *useruser = pbx_builtin_getvar_helper(ast, "USERUSERINFO"); 05687 #endif 05688 05689 ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel); 05690 if (!ast->tech_pvt) { 05691 ast_log(LOG_WARNING, "Asked to hangup channel not connected\n"); 05692 return 0; 05693 } 05694 05695 p->owner = NULL; 05696 p->outgoing = 0; 05697 sig_pri_set_digital(p, 0); /* push up to parent for EC*/ 05698 #if defined(HAVE_PRI_CALL_WAITING) 05699 if (p->is_call_waiting) { 05700 p->is_call_waiting = 0; 05701 ast_atomic_fetchadd_int(&p->pri->num_call_waiting_calls, -1); 05702 } 05703 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 05704 p->proceeding = 0; 05705 p->progress = 0; 05706 p->alerting = 0; 05707 p->setup_ack = 0; 05708 p->cid_num[0] = '\0'; 05709 p->cid_subaddr[0] = '\0'; 05710 p->cid_name[0] = '\0'; 05711 p->user_tag[0] = '\0'; 05712 p->exten[0] = '\0'; 05713 sig_pri_set_dialing(p, 0); 05714 05715 /* Make sure we have a call (or REALLY have a call in the case of a PRI) */ 05716 if (!pri_grab(p, p->pri)) { 05717 if (p->call) { 05718 if (p->alreadyhungup) { 05719 ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n"); 05720 05721 #ifdef SUPPORT_USERUSER 05722 pri_call_set_useruser(p->call, useruser); 05723 #endif 05724 05725 #if defined(HAVE_PRI_AOC_EVENTS) 05726 if (p->holding_aoce) { 05727 pri_aoc_e_send(p->pri->pri, p->call, &p->aoc_e); 05728 } 05729 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 05730 pri_hangup(p->pri->pri, p->call, -1); 05731 p->call = NULL; 05732 } else { 05733 const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE"); 05734 int icause = ast->hangupcause ? ast->hangupcause : -1; 05735 ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n"); 05736 05737 #ifdef SUPPORT_USERUSER 05738 pri_call_set_useruser(p->call, useruser); 05739 #endif 05740 05741 p->alreadyhungup = 1; 05742 if (cause) { 05743 if (atoi(cause)) 05744 icause = atoi(cause); 05745 } 05746 #if defined(HAVE_PRI_AOC_EVENTS) 05747 if (p->holding_aoce) { 05748 pri_aoc_e_send(p->pri->pri, p->call, &p->aoc_e); 05749 } 05750 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 05751 pri_hangup(p->pri->pri, p->call, icause); 05752 } 05753 } 05754 sig_pri_span_devstate_changed(p->pri); 05755 pri_rel(p->pri); 05756 res = 0; 05757 } else { 05758 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 05759 res = -1; 05760 } 05761 05762 #if defined(HAVE_PRI_AOC_EVENTS) 05763 p->aoc_s_request_invoke_id_valid = 0; 05764 p->holding_aoce = 0; 05765 p->waiting_for_aoce = 0; 05766 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 05767 ast->tech_pvt = NULL; 05768 return res; 05769 }
| int sig_pri_indicate | ( | struct sig_pri_chan * | p, | |
| struct ast_channel * | chan, | |||
| int | condition, | |||
| const void * | data, | |||
| size_t | datalen | |||
| ) |
Definition at line 6294 of file sig_pri.c.
References ast_channel::_softhangup, ast_channel::_state, sig_pri_chan::alerting, AST_AOC_D, ast_aoc_decode(), ast_aoc_destroy_decoded(), AST_AOC_E, ast_aoc_get_msg_type(), ast_aoc_get_termination_request(), AST_AOC_REQUEST, AST_AOC_S, AST_CAUSE_CONGESTION, AST_CAUSE_SWITCH_CONGESTION, AST_CAUSE_USER_BUSY, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, ast_debug, ast_log(), ast_moh_start(), ast_moh_stop(), ast_setstate(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, sig_pri_chan::call, ast_channel::connected, sig_pri_chan::digital, ast_channel::hangupcause, ast_party_connected_line::id, LOG_DEBUG, LOG_WARNING, sig_pri_chan::mohinterpret, ast_channel::name, sig_pri_chan::no_b_channel, sig_pri_chan::outgoing, sig_pri_span::pri, sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_chan::priindication_oob, sig_pri_chan::prioffset, sig_pri_chan::proceeding, sig_pri_chan::progress, PVT_TO_CHANNEL(), SIG_PRI_AOC_GRANT_D, SIG_PRI_AOC_GRANT_E, SIG_PRI_AOC_GRANT_S, sig_pri_party_id_from_ast(), sig_pri_play_tone(), sig_pri_redirecting_update(), sig_pri_set_dialing(), sig_pri_set_digital(), SIG_PRI_TONE_BUSY, SIG_PRI_TONE_CONGESTION, SIG_PRI_TONE_RINGTONE, and sig_pri_span::span.
Referenced by dahdi_indicate().
06295 { 06296 int res = -1; 06297 06298 switch (condition) { 06299 case AST_CONTROL_BUSY: 06300 if (p->priindication_oob || p->no_b_channel) { 06301 chan->hangupcause = AST_CAUSE_USER_BUSY; 06302 chan->_softhangup |= AST_SOFTHANGUP_DEV; 06303 res = 0; 06304 } else if (!p->progress && p->pri && !p->outgoing) { 06305 if (p->pri->pri) { 06306 if (!pri_grab(p, p->pri)) { 06307 #ifdef HAVE_PRI_PROG_W_CAUSE 06308 pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, PRI_CAUSE_USER_BUSY); /* cause = 17 */ 06309 #else 06310 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 06311 #endif 06312 pri_rel(p->pri); 06313 } else { 06314 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06315 } 06316 } 06317 p->progress = 1; 06318 res = sig_pri_play_tone(p, SIG_PRI_TONE_BUSY); 06319 } 06320 break; 06321 case AST_CONTROL_RINGING: 06322 if ((!p->alerting) && p->pri && !p->outgoing && (chan->_state != AST_STATE_UP)) { 06323 if (p->pri->pri) { 06324 if (!pri_grab(p, p->pri)) { 06325 pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 06326 p->no_b_channel || p->digital ? 0 : 1); 06327 pri_rel(p->pri); 06328 } else { 06329 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06330 } 06331 } 06332 p->alerting = 1; 06333 } 06334 res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE); 06335 if (chan->_state != AST_STATE_UP) { 06336 if (chan->_state != AST_STATE_RING) 06337 ast_setstate(chan, AST_STATE_RINGING); 06338 } 06339 break; 06340 case AST_CONTROL_PROCEEDING: 06341 ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name); 06342 if (!p->proceeding && p->pri && !p->outgoing) { 06343 if (p->pri->pri) { 06344 if (!pri_grab(p, p->pri)) { 06345 pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 06346 p->no_b_channel || p->digital ? 0 : 1); 06347 p->proceeding = 1; 06348 if (!p->no_b_channel && !p->digital) { 06349 sig_pri_set_dialing(p, 0); 06350 } 06351 pri_rel(p->pri); 06352 } else { 06353 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06354 } 06355 } 06356 } 06357 /* don't continue in ast_indicate */ 06358 res = 0; 06359 break; 06360 case AST_CONTROL_PROGRESS: 06361 ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name); 06362 sig_pri_set_digital(p, 0); /* Digital-only calls isn't allowing any inband progress messages */ 06363 if (!p->progress && !p->alerting && p->pri && !p->outgoing && !p->no_b_channel) { 06364 if (p->pri->pri) { 06365 if (!pri_grab(p, p->pri)) { 06366 #ifdef HAVE_PRI_PROG_W_CAUSE 06367 pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1); /* no cause at all */ 06368 #else 06369 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 06370 #endif 06371 pri_rel(p->pri); 06372 } else { 06373 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06374 } 06375 } 06376 p->progress = 1; 06377 } 06378 /* don't continue in ast_indicate */ 06379 res = 0; 06380 break; 06381 case AST_CONTROL_CONGESTION: 06382 chan->hangupcause = AST_CAUSE_CONGESTION; 06383 if (p->priindication_oob || p->no_b_channel) { 06384 chan->hangupcause = AST_CAUSE_SWITCH_CONGESTION; 06385 chan->_softhangup |= AST_SOFTHANGUP_DEV; 06386 res = 0; 06387 } else if (!p->progress && p->pri && !p->outgoing) { 06388 if (p->pri->pri) { 06389 if (!pri_grab(p, p->pri)) { 06390 #ifdef HAVE_PRI_PROG_W_CAUSE 06391 pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, PRI_CAUSE_SWITCH_CONGESTION); /* cause = 42 */ 06392 #else 06393 pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1); 06394 #endif 06395 pri_rel(p->pri); 06396 } else { 06397 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06398 } 06399 } 06400 p->progress = 1; 06401 res = sig_pri_play_tone(p, SIG_PRI_TONE_CONGESTION); 06402 } 06403 break; 06404 case AST_CONTROL_HOLD: 06405 if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { 06406 if (!pri_grab(p, p->pri)) { 06407 res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD); 06408 pri_rel(p->pri); 06409 } else { 06410 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 06411 } 06412 } else 06413 ast_moh_start(chan, data, p->mohinterpret); 06414 break; 06415 case AST_CONTROL_UNHOLD: 06416 if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) { 06417 if (!pri_grab(p, p->pri)) { 06418 res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL); 06419 pri_rel(p->pri); 06420 } 06421 } else 06422 ast_moh_stop(chan); 06423 break; 06424 case AST_CONTROL_SRCUPDATE: 06425 res = 0; 06426 break; 06427 case -1: 06428 res = sig_pri_play_tone(p, -1); 06429 break; 06430 case AST_CONTROL_CONNECTED_LINE: 06431 ast_debug(1, "Received AST_CONTROL_CONNECTED_LINE on %s\n", chan->name); 06432 if (p->pri && !pri_grab(p, p->pri)) { 06433 struct pri_party_connected_line connected; 06434 06435 memset(&connected, 0, sizeof(connected)); 06436 sig_pri_party_id_from_ast(&connected.id, &chan->connected.id); 06437 06438 pri_connected_line_update(p->pri->pri, p->call, &connected); 06439 pri_rel(p->pri); 06440 } 06441 break; 06442 case AST_CONTROL_REDIRECTING: 06443 ast_debug(1, "Received AST_CONTROL_REDIRECTING on %s\n", chan->name); 06444 if (p->pri && !pri_grab(p, p->pri)) { 06445 sig_pri_redirecting_update(p, chan); 06446 pri_rel(p->pri); 06447 } 06448 break; 06449 case AST_CONTROL_AOC: 06450 #if defined(HAVE_PRI_AOC_EVENTS) 06451 { 06452 struct ast_aoc_decoded *decoded 06453 = ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan); 06454 ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name); 06455 if (decoded && p->pri && !pri_grab(p, p->pri)) { 06456 switch (ast_aoc_get_msg_type(decoded)) { 06457 case AST_AOC_S: 06458 if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S) { 06459 sig_pri_aoc_s_from_ast(p, decoded); 06460 } 06461 break; 06462 case AST_AOC_D: 06463 if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_D) { 06464 sig_pri_aoc_d_from_ast(p, decoded); 06465 } 06466 break; 06467 case AST_AOC_E: 06468 if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_E) { 06469 sig_pri_aoc_e_from_ast(p, decoded); 06470 } 06471 /* if hangup was delayed for this AOC-E msg, waiting_for_aoc 06472 * will be set. A hangup is already occuring via a timeout during 06473 * this delay. Instead of waiting for that timeout to occur, go ahead 06474 * and initiate the softhangup since the delay is no longer necessary */ 06475 if (p->waiting_for_aoce) { 06476 p->waiting_for_aoce = 0; 06477 ast_log(LOG_DEBUG, 06478 "Received final AOC-E msg, continue with hangup on %s\n", 06479 chan->name); 06480 ast_softhangup_nolock(chan, AST_SOFTHANGUP_DEV); 06481 } 06482 break; 06483 case AST_AOC_REQUEST: 06484 /* We do not pass through AOC requests, So unless this 06485 * is an AOC termination request it will be ignored */ 06486 if (ast_aoc_get_termination_request(decoded)) { 06487 pri_hangup(p->pri->pri, p->call, -1); 06488 } 06489 break; 06490 default: 06491 break; 06492 } 06493 pri_rel(p->pri); 06494 } 06495 ast_aoc_destroy_decoded(decoded); 06496 } 06497 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 06498 break; 06499 } 06500 06501 return res; 06502 }
| void sig_pri_init_pri | ( | struct sig_pri_span * | pri | ) |
Definition at line 5669 of file sig_pri.c.
References ast_mutex_init, AST_PTHREADT_NULL, sig_pri_span::fds, sig_pri_span::lock, sig_pri_span::master, and SIG_PRI_NUM_DCHANS.
Referenced by dahdi_restart(), and load_module().
05670 { 05671 int i; 05672 05673 memset(pri, 0, sizeof(*pri)); 05674 05675 ast_mutex_init(&pri->lock); 05676 05677 pri->master = AST_PTHREADT_NULL; 05678 for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) 05679 pri->fds[i] = -1; 05680 }
| int sig_pri_load | ( | const char * | cc_type_name | ) |
Load the sig_pri submodule.
| cc_type_name | CC type name to use when looking up agent/monitor. |
| 0 | on success. | |
| -1 | on error. |
Definition at line 7769 of file sig_pri.c.
References ao2_container_alloc.
Referenced by load_module().
07770 { 07771 #if defined(HAVE_PRI_CCSS) 07772 sig_pri_cc_type_name = cc_type_name; 07773 sig_pri_cc_monitors = ao2_container_alloc(37, sig_pri_cc_monitor_instance_hash_fn, 07774 sig_pri_cc_monitor_instance_cmp_fn); 07775 if (!sig_pri_cc_monitors) { 07776 return -1; 07777 } 07778 #endif /* defined(HAVE_PRI_CCSS) */ 07779 return 0; 07780 }
| struct ast_channel* sig_pri_request | ( | struct sig_pri_chan * | p, | |
| enum sig_pri_law | law, | |||
| const struct ast_channel * | requestor, | |||
| int | transfercapability | |||
| ) | [read] |
Definition at line 913 of file sig_pri.c.
References ast_log(), AST_STATE_RESERVED, sig_pri_chan::channel, sig_pri_chan::exten, LOG_DEBUG, sig_pri_chan::outgoing, and sig_pri_new_ast_channel().
Referenced by dahdi_request(), and pri_dchannel().
00914 { 00915 struct ast_channel *ast; 00916 00917 ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel); 00918 00919 p->outgoing = 1; 00920 ast = sig_pri_new_ast_channel(p, AST_STATE_RESERVED, law, transfercapability, p->exten, requestor); 00921 if (!ast) { 00922 p->outgoing = 0; 00923 } 00924 return ast; 00925 }
| int sig_pri_start_pri | ( | struct sig_pri_span * | pri | ) |
Definition at line 6842 of file sig_pri.c.
References ARRAY_LEN, AST_EVENT_IE_CONTEXT, AST_EVENT_IE_END, AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, AST_EVENT_MWI, ast_event_subscribe(), ast_event_unsubscribe(), ast_log(), ast_mutex_init, ast_pthread_create_background, ast_str_alloca, ast_str_buffer(), ast_str_set(), ast_strip(), ast_strlen_zero(), DAHDI_CHAN_MAPPING_LOGICAL, DAHDI_OVERLAPDIAL_OUTGOING, sig_pri_span::dchans, sig_pri_span::enable_service_message_support, errno, sig_pri_span::fds, sig_pri_span::inbanddisconnect, sig_pri_span::lock, LOG_ERROR, sig_pri_span::master, sig_pri_span::nodetype, sig_pri_span::nsf, sig_pri_span::overlapdial, sig_pri_span::pri, pri_dchannel(), sig_pri_span::pritimers, sig_pri_span::qsigchannelmapping, sig_pri_span::resetpos, sig_pri_span::sig, SIG_BRI, SIG_BRI_PTMP, SIG_PRI_DEBUG_DEFAULT, SIG_PRI_NUM_DCHANS, sig_pri_sort_pri_chans(), sig_pri_span::span, strsep(), and sig_pri_span::switchtype.
Referenced by setup_dahdi_int().
06843 { 06844 int x; 06845 int i; 06846 #if defined(HAVE_PRI_MWI) 06847 char *saveptr; 06848 char *mbox_number; 06849 char *mbox_context; 06850 struct ast_str *mwi_description = ast_str_alloca(64); 06851 #endif /* defined(HAVE_PRI_MWI) */ 06852 06853 #if defined(HAVE_PRI_MWI) 06854 /* Prepare the mbox[] for use. */ 06855 for (i = 0; i < ARRAY_LEN(pri->mbox); ++i) { 06856 if (pri->mbox[i].sub) { 06857 pri->mbox[i].sub = ast_event_unsubscribe(pri->mbox[i].sub); 06858 } 06859 } 06860 #endif /* defined(HAVE_PRI_MWI) */ 06861 06862 ast_mutex_init(&pri->lock); 06863 sig_pri_sort_pri_chans(pri); 06864 06865 #if defined(HAVE_PRI_MWI) 06866 /* 06867 * Split the mwi_mailboxes configuration string into the mbox[]: 06868 * mailbox_number[@context]{,mailbox_number[@context]} 06869 */ 06870 i = 0; 06871 saveptr = pri->mwi_mailboxes; 06872 while (i < ARRAY_LEN(pri->mbox)) { 06873 mbox_number = strsep(&saveptr, ","); 06874 if (!mbox_number) { 06875 break; 06876 } 06877 /* Split the mailbox_number and context */ 06878 mbox_context = strchr(mbox_number, '@'); 06879 if (mbox_context) { 06880 *mbox_context++ = '\0'; 06881 mbox_context = ast_strip(mbox_context); 06882 } 06883 mbox_number = ast_strip(mbox_number); 06884 if (ast_strlen_zero(mbox_number)) { 06885 /* There is no mailbox number. Skip it. */ 06886 continue; 06887 } 06888 if (ast_strlen_zero(mbox_context)) { 06889 /* There was no context so use the default. */ 06890 mbox_context = "default"; 06891 } 06892 06893 /* Fill the mbox[] element. */ 06894 ast_str_set(&mwi_description, -1, "%s span %d[%d] MWI mailbox %s@%s", 06895 sig_pri_cc_type_name, pri->span, i, mbox_number, mbox_context); 06896 pri->mbox[i].sub = ast_event_subscribe(AST_EVENT_MWI, sig_pri_mwi_event_cb, 06897 ast_str_buffer(mwi_description), pri, 06898 AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mbox_number, 06899 AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, mbox_context, 06900 AST_EVENT_IE_END); 06901 if (!pri->mbox[i].sub) { 06902 ast_log(LOG_ERROR, "%s span %d could not subscribe to MWI events for %s@%s.", 06903 sig_pri_cc_type_name, pri->span, mbox_number, mbox_context); 06904 continue; 06905 } 06906 pri->mbox[i].number = mbox_number; 06907 pri->mbox[i].context = mbox_context; 06908 ++i; 06909 } 06910 #endif /* defined(HAVE_PRI_MWI) */ 06911 06912 for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) { 06913 if (pri->fds[i] == -1) { 06914 break; 06915 } 06916 06917 switch (pri->sig) { 06918 case SIG_BRI: 06919 pri->dchans[i] = pri_new_bri(pri->fds[i], 1, pri->nodetype, pri->switchtype); 06920 break; 06921 case SIG_BRI_PTMP: 06922 pri->dchans[i] = pri_new_bri(pri->fds[i], 0, pri->nodetype, pri->switchtype); 06923 break; 06924 default: 06925 pri->dchans[i] = pri_new(pri->fds[i], pri->nodetype, pri->switchtype); 06926 #if defined(HAVE_PRI_SERVICE_MESSAGES) 06927 if (pri->enable_service_message_support) { 06928 pri_set_service_message_support(pri->dchans[i], 1); 06929 } 06930 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 06931 break; 06932 } 06933 06934 pri_set_overlapdial(pri->dchans[i], (pri->overlapdial & DAHDI_OVERLAPDIAL_OUTGOING) ? 1 : 0); 06935 #ifdef HAVE_PRI_PROG_W_CAUSE 06936 pri_set_chan_mapping_logical(pri->dchans[i], pri->qsigchannelmapping == DAHDI_CHAN_MAPPING_LOGICAL); 06937 #endif 06938 #ifdef HAVE_PRI_INBANDDISCONNECT 06939 pri_set_inbanddisconnect(pri->dchans[i], pri->inbanddisconnect); 06940 #endif 06941 /* Enslave to master if appropriate */ 06942 if (i) 06943 pri_enslave(pri->dchans[0], pri->dchans[i]); 06944 if (!pri->dchans[i]) { 06945 if (pri->fds[i] > 0) 06946 close(pri->fds[i]); 06947 pri->fds[i] = -1; 06948 ast_log(LOG_ERROR, "Unable to create PRI structure\n"); 06949 return -1; 06950 } 06951 pri_set_debug(pri->dchans[i], SIG_PRI_DEBUG_DEFAULT); 06952 pri_set_nsf(pri->dchans[i], pri->nsf); 06953 #ifdef PRI_GETSET_TIMERS 06954 for (x = 0; x < PRI_MAX_TIMERS; x++) { 06955 if (pri->pritimers[x] != 0) 06956 pri_set_timer(pri->dchans[i], x, pri->pritimers[x]); 06957 } 06958 #endif 06959 } 06960 06961 /* Assume primary is the one we use */ 06962 pri->pri = pri->dchans[0]; 06963 06964 #if defined(HAVE_PRI_CALL_HOLD) 06965 pri_hold_enable(pri->pri, 1); 06966 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 06967 #if defined(HAVE_PRI_CALL_REROUTING) 06968 pri_reroute_enable(pri->pri, 1); 06969 #endif /* defined(HAVE_PRI_CALL_REROUTING) */ 06970 #if defined(HAVE_PRI_HANGUP_FIX) 06971 pri_hangup_fix_enable(pri->pri, 1); 06972 #endif /* defined(HAVE_PRI_HANGUP_FIX) */ 06973 #if defined(HAVE_PRI_CCSS) 06974 pri_cc_enable(pri->pri, 1); 06975 pri_cc_recall_mode(pri->pri, pri->cc_ptmp_recall_mode); 06976 pri_cc_retain_signaling_req(pri->pri, pri->cc_qsig_signaling_link_req); 06977 pri_cc_retain_signaling_rsp(pri->pri, pri->cc_qsig_signaling_link_rsp); 06978 #endif /* defined(HAVE_PRI_CCSS) */ 06979 #if defined(HAVE_PRI_TRANSFER) 06980 pri_transfer_enable(pri->pri, 1); 06981 #endif /* defined(HAVE_PRI_TRANSFER) */ 06982 #if defined(HAVE_PRI_AOC_EVENTS) 06983 pri_aoc_events_enable(pri->pri, 1); 06984 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 06985 #if defined(HAVE_PRI_CALL_WAITING) 06986 pri_connect_ack_enable(pri->pri, 1); 06987 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 06988 #if defined(HAVE_PRI_MCID) 06989 pri_mcid_enable(pri->pri, 1); 06990 #endif /* defined(HAVE_PRI_MCID) */ 06991 06992 pri->resetpos = -1; 06993 if (ast_pthread_create_background(&pri->master, NULL, pri_dchannel, pri)) { 06994 for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) { 06995 if (!pri->dchans[i]) 06996 break; 06997 if (pri->fds[i] > 0) 06998 close(pri->fds[i]); 06999 pri->fds[i] = -1; 07000 } 07001 ast_log(LOG_ERROR, "Unable to spawn D-channel: %s\n", strerror(errno)); 07002 return -1; 07003 } 07004 07005 #if defined(HAVE_PRI_MWI) 07006 /* 07007 * Send the initial MWI indications from the event cache for this span. 07008 * 07009 * If we were loaded after app_voicemail the event would already be in 07010 * the cache. If we were loaded before app_voicemail the event would not 07011 * be in the cache yet and app_voicemail will send the event when it 07012 * gets loaded. 07013 */ 07014 sig_pri_mwi_cache_update(pri); 07015 #endif /* defined(HAVE_PRI_MWI) */ 07016 07017 return 0; 07018 }
| void sig_pri_stop_pri | ( | struct sig_pri_span * | pri | ) |
Stop PRI span.
| pri | Asterisk D channel control structure. |
Definition at line 6777 of file sig_pri.c.
References ARRAY_LEN, and ast_event_unsubscribe().
Referenced by __unload_module().
06778 { 06779 #if defined(HAVE_PRI_MWI) 06780 int idx; 06781 #endif /* defined(HAVE_PRI_MWI) */ 06782 06783 #if defined(HAVE_PRI_MWI) 06784 for (idx = 0; idx < ARRAY_LEN(pri->mbox); ++idx) { 06785 if (pri->mbox[idx].sub) { 06786 pri->mbox[idx].sub = ast_event_unsubscribe(pri->mbox[idx].sub); 06787 } 06788 } 06789 #endif /* defined(HAVE_PRI_MWI) */ 06790 }
| void sig_pri_unload | ( | void | ) |
Unload the sig_pri submodule.
Definition at line 7788 of file sig_pri.c.
References ao2_ref.
Referenced by __unload_module().
07789 { 07790 #if defined(HAVE_PRI_CCSS) 07791 if (sig_pri_cc_monitors) { 07792 ao2_ref(sig_pri_cc_monitors, -1); 07793 sig_pri_cc_monitors = NULL; 07794 } 07795 #endif /* defined(HAVE_PRI_CCSS) */ 07796 }
const char dahdi_db[] = "dahdi/registry" [static] |
The AstDB family.
Definition at line 168 of file sig_pri.h.
Referenced by destroy_all_channels(), handle_pri_service_generic(), mkintf(), and pri_dchannel().
1.5.9