#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/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 "sig_pri.h"

Go to the source code of this file.
Defines | |
| #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) |
| #define | PRI_DEADLOCK_AVOIDANCE(p) |
| #define | PRI_EXPLICIT (1 << 16) |
| #define | PRI_HELD_CALL (1 << 18) |
| #define | PRI_SPAN(p) (((p) >> 8) & 0xff) |
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_number (char *buf, size_t size, const struct sig_pri_span *pri, const char *number, const 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 int | pri_active_dchan_index (struct sig_pri_span *pri) |
| static int | pri_check_restart (struct sig_pri_span *pri) |
| static void * | pri_dchannel (void *vpri) |
| 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 int | 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_pri_call (struct sig_pri_span *pri, q931_call *call) |
| static int | pri_find_principle (struct sig_pri_span *pri, int channel, q931_call *call) |
| static int | pri_fixup_principle (struct sig_pri_span *pri, int principle, q931_call *call) |
| static int | 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 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_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) |
| int | sig_pri_answer (struct sig_pri_chan *p, struct ast_channel *ast) |
| static int | sig_pri_attempt_transfer (struct sig_pri_span *pri, q931_call *call_1, int call_1_held, q931_call *call_2, int call_2_held) |
| 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, char *rdest, int timeout, int layer1) |
| static void | sig_pri_cc_generic_check (struct sig_pri_span *pri, int chanpos, enum ast_cc_service_type service) |
| 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) |
| static int | sig_pri_cmp_pri_chans (const void *left, const void *right) |
| 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. | |
| 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_retrieve (struct sig_pri_span *pri, pri_event *ev) |
| static void | sig_pri_handle_subcmds (struct sig_pri_span *pri, int chanpos, int event_id, int channel, 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) |
| void | sig_pri_init_pri (struct sig_pri_span *pri) |
| static int | sig_pri_is_cis_call (int channel) |
| int | sig_pri_load (const char *cc_type_name) |
| Load the sig_pri submodule. | |
| 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 int | sig_pri_msn_match (const char *msn_patterns, const char *exten) |
| static struct ast_channel * | sig_pri_new_ast_channel (struct sig_pri_chan *p, int state, int ulaw, int transfercapability, char *exten, 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_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_channel * | sig_pri_request (struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability) |
| static 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_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. | |
| void | sig_pri_unload (void) |
| Unload the sig_pri submodule. | |
| static void | sig_pri_unlock_private (struct sig_pri_chan *p) |
Variables | |
| static int | pri_gendigittimeout = 8000 |
| static int | pri_matchdigittimeout = 3000 |
| static 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 }, } |
Definition in file sig_pri.c.
| #define DCHAN_AVAILABLE (DCHAN_NOTINALARM | DCHAN_UP) |
| #define DCHAN_NOTINALARM (1 << 0) |
Definition at line 90 of file sig_pri.c.
Referenced by build_status(), pri_event_alarm(), and pri_event_noalarm().
| #define DCHAN_UP (1 << 1) |
Definition at line 91 of file sig_pri.c.
Referenced by build_status(), pri_dchannel(), and pri_event_alarm().
| #define PRI_CHANNEL | ( | p | ) | ((p) & 0xff) |
Definition at line 94 of file sig_pri.c.
Referenced by pri_dchannel(), pri_find_principle(), sig_pri_handle_hold(), sig_pri_handle_retrieve(), and sig_pri_handle_subcmds().
| #define PRI_CIS_CALL (1 << 17) |
| #define PRI_DEADLOCK_AVOIDANCE | ( | p | ) |
Value:
do { \ sig_pri_unlock_private(p); \ usleep(1); \ sig_pri_lock_private(p); \ } while (0)
Definition at line 103 of file sig_pri.c.
Referenced by pri_grab(), and sig_pri_lock_owner().
| #define PRI_EXPLICIT (1 << 16) |
| #define PRI_HELD_CALL (1 << 18) |
Definition at line 98 of file sig_pri.c.
Referenced by pri_find_principle(), and sig_pri_handle_retrieve().
| #define PRI_SPAN | ( | p | ) | (((p) >> 8) & 0xff) |
Definition at line 95 of file sig_pri.c.
Referenced by pri_dchannel(), pri_find_principle(), pri_maintenance_bservice(), sig_pri_handle_hold(), and sig_pri_handle_subcmds().
Definition at line 5848 of file sig_pri.c.
05848 { 05849 OPT_ARG_KEYPAD = 0, 05850 OPT_ARG_AOC_REQUEST, 05851 05852 /* note: this entry _MUST_ be the last one in the enum */ 05853 OPT_ARG_ARRAY_SIZE, 05854 };
Definition at line 5843 of file sig_pri.c.
05843 { 05844 OPT_KEYPAD = (1 << 0), 05845 OPT_REVERSE_CHARGE = (1 << 1), /* Collect call */ 05846 OPT_AOC_REQUEST = (1 << 2), /* AOC Request */ 05847 };
| static void apply_plan_to_number | ( | char * | buf, | |
| size_t | size, | |||
| const struct sig_pri_span * | pri, | |||
| const char * | number, | |||
| const int | plan | |||
| ) | [static] |
Definition at line 1274 of file sig_pri.c.
References sig_pri_span::internationalprefix, sig_pri_span::localprefix, sig_pri_span::nationalprefix, sig_pri_span::privateprefix, and sig_pri_span::unknownprefix.
Referenced by pri_dchannel(), and sig_pri_party_number_convert().
01275 { 01276 switch (plan) { 01277 case PRI_INTERNATIONAL_ISDN: /* Q.931 dialplan == 0x11 international dialplan => prepend international prefix digits */ 01278 snprintf(buf, size, "%s%s", pri->internationalprefix, number); 01279 break; 01280 case PRI_NATIONAL_ISDN: /* Q.931 dialplan == 0x21 national dialplan => prepend national prefix digits */ 01281 snprintf(buf, size, "%s%s", pri->nationalprefix, number); 01282 break; 01283 case PRI_LOCAL_ISDN: /* Q.931 dialplan == 0x41 local dialplan => prepend local prefix digits */ 01284 snprintf(buf, size, "%s%s", pri->localprefix, number); 01285 break; 01286 case PRI_PRIVATE: /* Q.931 dialplan == 0x49 private dialplan => prepend private prefix digits */ 01287 snprintf(buf, size, "%s%s", pri->privateprefix, number); 01288 break; 01289 case PRI_UNKNOWN: /* Q.931 dialplan == 0x00 unknown dialplan => prepend unknown prefix digits */ 01290 snprintf(buf, size, "%s%s", pri->unknownprefix, number); 01291 break; 01292 default: /* other Q.931 dialplan => don't twiddle with callingnum */ 01293 snprintf(buf, size, "%s", number); 01294 break; 01295 } 01296 }
| static unsigned char ast_pri_pack_hex_char | ( | char | c | ) | [static] |
Definition at line 623 of file sig_pri.c.
Referenced by ast_pri_pack_hex_string().
00624 { 00625 unsigned char res; 00626 00627 if (c < '0') { 00628 res = 0; 00629 } else if (c < ('9' + 1)) { 00630 res = c - '0'; 00631 } else if (c < 'A') { 00632 res = 0; 00633 } else if (c < ('F' + 1)) { 00634 res = c - 'A' + 10; 00635 } else if (c < 'a') { 00636 res = 0; 00637 } else if (c < ('f' + 1)) { 00638 res = c - 'a' + 10; 00639 } else { 00640 res = 0; 00641 } 00642 return res; 00643 }
| static int ast_pri_pack_hex_string | ( | unsigned char * | dst, | |
| char * | src, | |||
| int | maxlen | |||
| ) | [static] |
Definition at line 662 of file sig_pri.c.
References ast_pri_pack_hex_char(), and len().
Referenced by sig_pri_party_subaddress_from_ast().
00663 { 00664 int res = 0; 00665 int len = strlen(src); 00666 00667 if (len > (2 * maxlen)) { 00668 len = 2 * maxlen; 00669 } 00670 00671 res = len / 2 + len % 2; 00672 00673 while (len > 1) { 00674 *dst = ast_pri_pack_hex_char(*src) << 4; 00675 src++; 00676 *dst |= ast_pri_pack_hex_char(*src); 00677 dst++, src++; 00678 len -= 2; 00679 } 00680 if (len) { /* 1 left */ 00681 *dst = ast_pri_pack_hex_char(*src) << 4; 00682 } 00683 return res; 00684 }
| static int ast_to_pri_char_set | ( | enum AST_PARTY_CHAR_SET | ast_char_set | ) | [static] |
Definition at line 525 of file sig_pri.c.
References AST_PARTY_CHAR_SET_ISO10646_BMPSTRING, AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING, AST_PARTY_CHAR_SET_ISO8859_1, AST_PARTY_CHAR_SET_ISO8859_2, AST_PARTY_CHAR_SET_ISO8859_3, AST_PARTY_CHAR_SET_ISO8859_4, AST_PARTY_CHAR_SET_ISO8859_5, AST_PARTY_CHAR_SET_ISO8859_7, AST_PARTY_CHAR_SET_UNKNOWN, and AST_PARTY_CHAR_SET_WITHDRAWN.
Referenced by sig_pri_party_name_from_ast().
00526 { 00527 int pri_char_set; 00528 00529 switch (ast_char_set) { 00530 default: 00531 case AST_PARTY_CHAR_SET_UNKNOWN: 00532 pri_char_set = PRI_CHAR_SET_UNKNOWN; 00533 break; 00534 case AST_PARTY_CHAR_SET_ISO8859_1: 00535 pri_char_set = PRI_CHAR_SET_ISO8859_1; 00536 break; 00537 case AST_PARTY_CHAR_SET_WITHDRAWN: 00538 pri_char_set = PRI_CHAR_SET_WITHDRAWN; 00539 break; 00540 case AST_PARTY_CHAR_SET_ISO8859_2: 00541 pri_char_set = PRI_CHAR_SET_ISO8859_2; 00542 break; 00543 case AST_PARTY_CHAR_SET_ISO8859_3: 00544 pri_char_set = PRI_CHAR_SET_ISO8859_3; 00545 break; 00546 case AST_PARTY_CHAR_SET_ISO8859_4: 00547 pri_char_set = PRI_CHAR_SET_ISO8859_4; 00548 break; 00549 case AST_PARTY_CHAR_SET_ISO8859_5: 00550 pri_char_set = PRI_CHAR_SET_ISO8859_5; 00551 break; 00552 case AST_PARTY_CHAR_SET_ISO8859_7: 00553 pri_char_set = PRI_CHAR_SET_ISO8859_7; 00554 break; 00555 case AST_PARTY_CHAR_SET_ISO10646_BMPSTRING: 00556 pri_char_set = PRI_CHAR_SET_ISO10646_BMPSTRING; 00557 break; 00558 case AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING: 00559 pri_char_set = PRI_CHAR_SET_ISO10646_UTF_8STRING; 00560 break; 00561 } 00562 00563 return pri_char_set; 00564 }
| static int ast_to_pri_presentation | ( | int | ast_presentation | ) | [static] |
Definition at line 426 of file sig_pri.c.
References AST_PRES_ALLOWED_NETWORK_NUMBER, AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, AST_PRES_NUMBER_NOT_AVAILABLE, AST_PRES_PROHIB_NETWORK_NUMBER, AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, and AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN.
Referenced by sig_pri_party_name_from_ast(), and sig_pri_party_number_from_ast().
00427 { 00428 int pri_presentation; 00429 00430 switch (ast_presentation) { 00431 case AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED: 00432 pri_presentation = PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 00433 break; 00434 case AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN: 00435 pri_presentation = PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN; 00436 break; 00437 case AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN: 00438 pri_presentation = PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN; 00439 break; 00440 case AST_PRES_ALLOWED_NETWORK_NUMBER: 00441 pri_presentation = PRES_ALLOWED_NETWORK_NUMBER; 00442 break; 00443 case AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED: 00444 pri_presentation = PRES_PROHIB_USER_NUMBER_NOT_SCREENED; 00445 break; 00446 case AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN: 00447 pri_presentation = PRES_PROHIB_USER_NUMBER_PASSED_SCREEN; 00448 break; 00449 case AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN: 00450 pri_presentation = PRES_PROHIB_USER_NUMBER_FAILED_SCREEN; 00451 break; 00452 case AST_PRES_PROHIB_NETWORK_NUMBER: 00453 pri_presentation = PRES_PROHIB_NETWORK_NUMBER; 00454 break; 00455 case AST_PRES_NUMBER_NOT_AVAILABLE: 00456 pri_presentation = PRES_NUMBER_NOT_AVAILABLE; 00457 break; 00458 default: 00459 pri_presentation = PRES_PROHIB_USER_NUMBER_NOT_SCREENED; 00460 break; 00461 } 00462 00463 return pri_presentation; 00464 }
| static int ast_to_pri_reason | ( | enum AST_REDIRECTING_REASON | ast_reason | ) | [static] |
Definition at line 342 of file sig_pri.c.
References AST_REDIRECTING_REASON_DEFLECTION, AST_REDIRECTING_REASON_NO_ANSWER, AST_REDIRECTING_REASON_UNCONDITIONAL, AST_REDIRECTING_REASON_UNKNOWN, and AST_REDIRECTING_REASON_USER_BUSY.
Referenced by sig_pri_redirecting_update().
00343 { 00344 int pri_reason; 00345 00346 switch (ast_reason) { 00347 case AST_REDIRECTING_REASON_USER_BUSY: 00348 pri_reason = PRI_REDIR_FORWARD_ON_BUSY; 00349 break; 00350 case AST_REDIRECTING_REASON_NO_ANSWER: 00351 pri_reason = PRI_REDIR_FORWARD_ON_NO_REPLY; 00352 break; 00353 case AST_REDIRECTING_REASON_UNCONDITIONAL: 00354 pri_reason = PRI_REDIR_UNCONDITIONAL; 00355 break; 00356 case AST_REDIRECTING_REASON_DEFLECTION: 00357 pri_reason = PRI_REDIR_DEFLECTION; 00358 break; 00359 case AST_REDIRECTING_REASON_UNKNOWN: 00360 default: 00361 pri_reason = PRI_REDIR_UNKNOWN; 00362 break; 00363 } 00364 00365 return pri_reason; 00366 }
| static void build_status | ( | char * | s, | |
| size_t | len, | |||
| int | status, | |||
| int | active | |||
| ) | [static] |
Definition at line 7077 of file sig_pri.c.
References DCHAN_NOTINALARM, and DCHAN_UP.
Referenced by sig_pri_cli_show_span(), and sig_pri_cli_show_spans().
07078 { 07079 if (!s || len < 1) { 07080 return; 07081 } 07082 s[0] = '\0'; 07083 if (!(status & DCHAN_NOTINALARM)) 07084 strncat(s, "In Alarm, ", len - strlen(s) - 1); 07085 if (status & DCHAN_UP) 07086 strncat(s, "Up", len - strlen(s) - 1); 07087 else 07088 strncat(s, "Down", len - strlen(s) - 1); 07089 if (active) 07090 strncat(s, ", Active", len - strlen(s) - 1); 07091 else 07092 strncat(s, ", Standby", len - strlen(s) - 1); 07093 s[len - 1] = '\0'; 07094 }
| static char* dialplan2str | ( | int | dialplan | ) | [static] |
Definition at line 1266 of file sig_pri.c.
Referenced by sig_pri_call().
01267 { 01268 if (dialplan == -1) { 01269 return("Dynamically set dialplan in ISDN"); 01270 } 01271 return (pri_plan2str(dialplan)); 01272 }
| static void* do_idle_thread | ( | void * | v_pvt | ) | [static] |
Definition at line 1458 of file sig_pri.c.
References ast_call(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), ast_pbx_run(), ast_read(), ast_verb, ast_waitfor(), sig_pri_chan::channel, ast_channel::context, ast_channel::exten, f, ast_frame::frametype, sig_pri_span::idlecontext, sig_pri_span::idledial, sig_pri_span::idleext, ast_frame_subclass::integer, LOG_WARNING, ast_channel::name, sig_pri_chan::owner, sig_pri_chan::pri, ast_channel::priority, and ast_frame::subclass.
Referenced by pri_dchannel().
01459 { 01460 struct sig_pri_chan *pvt = v_pvt; 01461 struct ast_channel *chan = pvt->owner; 01462 struct ast_frame *f; 01463 char ex[80]; 01464 /* Wait up to 30 seconds for an answer */ 01465 int newms, ms = 30000; 01466 01467 ast_verb(3, "Initiating idle call on channel %s\n", chan->name); 01468 snprintf(ex, sizeof(ex), "%d/%s", pvt->channel, pvt->pri->idledial); 01469 if (ast_call(chan, ex, 0)) { 01470 ast_log(LOG_WARNING, "Idle dial failed on '%s' to '%s'\n", chan->name, ex); 01471 ast_hangup(chan); 01472 return NULL; 01473 } 01474 while ((newms = ast_waitfor(chan, ms)) > 0) { 01475 f = ast_read(chan); 01476 if (!f) { 01477 /* Got hangup */ 01478 break; 01479 } 01480 if (f->frametype == AST_FRAME_CONTROL) { 01481 switch (f->subclass.integer) { 01482 case AST_CONTROL_ANSWER: 01483 /* Launch the PBX */ 01484 ast_copy_string(chan->exten, pvt->pri->idleext, sizeof(chan->exten)); 01485 ast_copy_string(chan->context, pvt->pri->idlecontext, sizeof(chan->context)); 01486 chan->priority = 1; 01487 ast_verb(4, "Idle channel '%s' answered, sending to %s@%s\n", chan->name, chan->exten, chan->context); 01488 ast_pbx_run(chan); 01489 /* It's already hungup, return immediately */ 01490 return NULL; 01491 case AST_CONTROL_BUSY: 01492 ast_verb(4, "Idle channel '%s' busy, waiting...\n", chan->name); 01493 break; 01494 case AST_CONTROL_CONGESTION: 01495 ast_verb(4, "Idle channel '%s' congested, waiting...\n", chan->name); 01496 break; 01497 }; 01498 } 01499 ast_frfree(f); 01500 ms = newms; 01501 } 01502 /* Hangup the channel since nothing happend */ 01503 ast_hangup(chan); 01504 return NULL; 01505 }
| static int pri_active_dchan_index | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 954 of file sig_pri.c.
References ast_log(), sig_pri_span::dchans, LOG_WARNING, sig_pri_span::pri, and SIG_PRI_NUM_DCHANS.
Referenced by pri_find_principle().
00955 { 00956 int x; 00957 00958 for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { 00959 if ((pri->dchans[x] == pri->pri)) 00960 return x; 00961 } 00962 00963 ast_log(LOG_WARNING, "No active dchan found!\n"); 00964 return -1; 00965 }
| static int pri_check_restart | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 1299 of file sig_pri.c.
References ast_log(), sig_pri_chan::call, sig_pri_chan::channel, sig_pri_span::lastreset, LOG_NOTICE, sig_pri_chan::no_b_channel, sig_pri_span::numchans, sig_pri_span::pri, PVT_TO_CHANNEL(), sig_pri_span::pvts, sig_pri_span::resetpos, sig_pri_span::resetting, sig_pri_chan::resetting, sig_pri_chan::service_status, sig_pri_span::span, SRVST_FAREND, and SRVST_NEAREND.
Referenced by pri_dchannel().
01300 { 01301 #if defined(HAVE_PRI_SERVICE_MESSAGES) 01302 tryanotherpos: 01303 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 01304 do { 01305 pri->resetpos++; 01306 } while (pri->resetpos < pri->numchans 01307 && (!pri->pvts[pri->resetpos] 01308 || pri->pvts[pri->resetpos]->no_b_channel 01309 || pri->pvts[pri->resetpos]->call 01310 || pri->pvts[pri->resetpos]->resetting)); 01311 if (pri->resetpos < pri->numchans) { 01312 #if defined(HAVE_PRI_SERVICE_MESSAGES) 01313 unsigned why; 01314 01315 why = pri->pvts[pri->resetpos]->service_status; 01316 if (why) { 01317 ast_log(LOG_NOTICE, "span '%d' channel '%d' out-of-service (reason: %s), not sending RESTART\n", pri->span, 01318 pri->pvts[pri->resetpos]->channel, (why & SRVST_FAREND) ? (why & SRVST_NEAREND) ? "both ends" : "far end" : "near end"); 01319 goto tryanotherpos; 01320 } 01321 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 01322 01323 /* Mark the channel as resetting and restart it */ 01324 pri->pvts[pri->resetpos]->resetting = 1; 01325 pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[pri->resetpos])); 01326 } else { 01327 pri->resetting = 0; 01328 time(&pri->lastreset); 01329 } 01330 return 0; 01331 }
| static void* pri_dchannel | ( | void * | vpri | ) | [static] |
Definition at line 4066 of file sig_pri.c.
References ast_channel::_softhangup, ast_channel::_state, sig_pri_chan::alerting, sig_pri_chan::alreadyhungup, sig_pri_span::append_msn_to_user_tag, apply_plan_to_number(), ast_atomic_fetchadd_int(), ast_bridged_channel(), ast_canmatch_extension(), AST_CAUSE_USER_BUSY, AST_CC_CCBS, AST_CC_CCNR, ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_UNHOLD, ast_copy_string(), ast_db_del(), ast_db_put(), ast_debug, ast_exists_extension(), AST_FORMAT_ULAW, AST_FRAME_DTMF, ast_hangup(), ast_log(), ast_matchmore_extension(), AST_MAX_EXTENSION, ast_mutex_lock, ast_mutex_unlock, ast_party_subaddress_free(), ast_party_subaddress_init(), ast_pbx_start(), ast_pthread_create_background, ast_pthread_create_detached, ast_shrink_phone_number(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), AST_STATE_BUSY, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_UP, ast_strlen_zero(), ast_tv(), ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_verb, ast_verbose, sig_pri_chan::call, ast_channel::caller, sig_pri_chan::callingpres, sig_pri_chan::channel, sig_pri_chan::cid_ani, sig_pri_chan::cid_ani2, sig_pri_chan::cid_name, sig_pri_chan::cid_num, sig_pri_chan::cid_subaddr, sig_pri_chan::cid_ton, sig_pri_chan::context, dahdi_db, DAHDI_OVERLAPDIAL_INCOMING, ast_channel::data, DCHAN_UP, sig_pri_span::dchanavail, sig_pri_span::dchans, sig_pri_span::debug, sig_pri_chan::dialdest, ast_channel::dialed, sig_pri_span::discardremoteholdretrieval, do_idle_thread(), errno, sig_pri_chan::exten, sig_pri_span::fds, ast_channel::hangupcause, sig_pri_span::hold_disconnect_transfer, ast_party_caller::id, sig_pri_span::idlecontext, sig_pri_span::idledial, sig_pri_span::idleext, sig_pri_chan::immediate, sig_pri_span::initial_user_tag, sig_pri_chan::isidlecall, sig_pri_chan::keypad_digits, sig_pri_span::lastreset, sig_pri_span::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, sig_pri_chan::logicalspan, sig_pri_span::minidle, sig_pri_span::minunused, sig_pri_span::msn_list, ast_channel::name, sig_pri_chan::no_b_channel, sig_pri_span::nodetype, sig_pri_span::numchans, sig_pri_chan::outgoing, sig_pri_span::overlapdial, sig_pri_chan::owner, pbx_builtin_setvar_helper(), sig_pri_chan::pri, sig_pri_span::pri, PRI_CHANNEL, pri_check_restart(), pri_find_dchan(), pri_find_empty_chan(), pri_find_empty_nobch(), pri_find_principle(), pri_fixup_principle(), pri_is_up(), pri_order(), pri_queue_control(), pri_queue_frame(), PRI_SPAN, pri_ss_thread(), sig_pri_chan::prioffset, sig_pri_chan::proceeding, sig_pri_chan::progress, PVT_TO_CHANNEL(), sig_pri_span::pvts, redirectingreason2str(), sig_pri_span::resetinterval, sig_pri_span::resetpos, sig_pri_chan::resetting, sig_pri_span::resetting, sig_pri_chan::reverse_charging_indication, S_OR, sig_pri_chan::service_status, sig_pri_chan::setup_ack, sig_pri_span::sig, SIG_BRI_PTMP, SIG_PRI_ALAW, sig_pri_attempt_transfer(), sig_pri_cc_generic_check(), sig_pri_handle_cis_subcmds(), sig_pri_handle_dchan_exception(), sig_pri_handle_hold(), sig_pri_handle_retrieve(), sig_pri_handle_subcmds(), sig_pri_is_cis_call(), sig_pri_lock_owner(), sig_pri_lock_private(), sig_pri_msn_match(), sig_pri_new_ast_channel(), sig_pri_open_media(), sig_pri_request(), sig_pri_set_alarm(), sig_pri_set_caller_id(), sig_pri_set_dialing(), sig_pri_set_dnid(), sig_pri_set_echocanceller(), sig_pri_set_rdnis(), sig_pri_set_subaddress(), sig_pri_span_devstate_changed(), SIG_PRI_ULAW, sig_pri_unlock_private(), sig_pri_span::span, SRVST_DBKEY, SRVST_FAREND, SRVST_NEAREND, SRVST_TYPE_OOS, ast_party_subaddress::str, ast_party_dialed::subaddress, ast_party_id::subaddress, sig_pri_span::switchtype, sig_pri_chan::use_callerid, and sig_pri_chan::user_tag.
Referenced by sig_pri_start_pri().
04067 { 04068 struct sig_pri_span *pri = vpri; 04069 pri_event *e; 04070 struct pollfd fds[SIG_PRI_NUM_DCHANS]; 04071 int res; 04072 int chanpos = 0; 04073 int x; 04074 struct ast_channel *c; 04075 struct timeval tv, lowest, *next; 04076 int doidling=0; 04077 char *cc; 04078 time_t t; 04079 int i, which=-1; 04080 int numdchans; 04081 pthread_t threadid; 04082 char ani2str[6]; 04083 char plancallingnum[AST_MAX_EXTENSION]; 04084 char plancallingani[AST_MAX_EXTENSION]; 04085 char calledtonstr[10]; 04086 struct timeval lastidle = { 0, 0 }; 04087 pthread_t p; 04088 struct ast_channel *idle; 04089 char idlen[80]; 04090 int nextidle = -1; 04091 int haveidles; 04092 int activeidles; 04093 04094 gettimeofday(&lastidle, NULL); 04095 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 04096 04097 if (!ast_strlen_zero(pri->idledial) && !ast_strlen_zero(pri->idleext)) { 04098 /* Need to do idle dialing, check to be sure though */ 04099 cc = strchr(pri->idleext, '@'); 04100 if (cc) { 04101 *cc = '\0'; 04102 cc++; 04103 ast_copy_string(pri->idlecontext, cc, sizeof(pri->idlecontext)); 04104 #if 0 04105 /* Extensions may not be loaded yet */ 04106 if (!ast_exists_extension(NULL, pri->idlecontext, pri->idleext, 1, NULL)) 04107 ast_log(LOG_WARNING, "Extension '%s @ %s' does not exist\n", pri->idleext, pri->idlecontext); 04108 else 04109 #endif 04110 doidling = 1; 04111 } else 04112 ast_log(LOG_WARNING, "Idle dial string '%s' lacks '@context'\n", pri->idleext); 04113 } 04114 for (;;) { 04115 for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) { 04116 if (!pri->dchans[i]) 04117 break; 04118 fds[i].fd = pri->fds[i]; 04119 fds[i].events = POLLIN | POLLPRI; 04120 fds[i].revents = 0; 04121 } 04122 numdchans = i; 04123 time(&t); 04124 ast_mutex_lock(&pri->lock); 04125 if (pri->switchtype != PRI_SWITCH_GR303_TMC && (pri->sig != SIG_BRI_PTMP) && (pri->resetinterval > 0)) { 04126 if (pri->resetting && pri_is_up(pri)) { 04127 if (pri->resetpos < 0) 04128 pri_check_restart(pri); 04129 } else { 04130 if (!pri->resetting && (t - pri->lastreset) >= pri->resetinterval) { 04131 pri->resetting = 1; 04132 pri->resetpos = -1; 04133 } 04134 } 04135 } 04136 /* Look for any idle channels if appropriate */ 04137 if (doidling && pri_is_up(pri)) { 04138 nextidle = -1; 04139 haveidles = 0; 04140 activeidles = 0; 04141 for (x = pri->numchans; x >= 0; x--) { 04142 if (pri->pvts[x] 04143 && !pri->pvts[x]->owner 04144 && !pri->pvts[x]->call 04145 && !pri->pvts[x]->no_b_channel) { 04146 if (haveidles < pri->minunused) { 04147 haveidles++; 04148 } else if (!pri->pvts[x]->resetting) { 04149 nextidle = x; 04150 break; 04151 } 04152 } else if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall) 04153 activeidles++; 04154 } 04155 if (nextidle > -1) { 04156 if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) { 04157 /* Don't create a new idle call more than once per second */ 04158 snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial); 04159 idle = sig_pri_request(pri->pvts[nextidle], AST_FORMAT_ULAW, NULL, 0); 04160 if (idle) { 04161 pri->pvts[nextidle]->isidlecall = 1; 04162 if (ast_pthread_create_background(&p, NULL, do_idle_thread, pri->pvts[nextidle])) { 04163 ast_log(LOG_WARNING, "Unable to start new thread for idle channel '%s'\n", idle->name); 04164 ast_hangup(idle); 04165 } 04166 } else 04167 ast_log(LOG_WARNING, "Unable to request channel 'DAHDI/%s' for idle call\n", idlen); 04168 gettimeofday(&lastidle, NULL); 04169 } 04170 } else if ((haveidles < pri->minunused) && 04171 (activeidles > pri->minidle)) { 04172 /* Mark something for hangup if there is something 04173 that can be hungup */ 04174 for (x = pri->numchans; x >= 0; x--) { 04175 /* find a candidate channel */ 04176 if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall) { 04177 pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 04178 haveidles++; 04179 /* Stop if we have enough idle channels or 04180 can't spare any more active idle ones */ 04181 if ((haveidles >= pri->minunused) || 04182 (activeidles <= pri->minidle)) 04183 break; 04184 } 04185 } 04186 } 04187 } 04188 /* Start with reasonable max */ 04189 if (doidling || pri->resetting) { 04190 /* 04191 * Make sure we stop at least once per second if we're 04192 * monitoring idle channels 04193 */ 04194 lowest = ast_tv(1, 0); 04195 } else { 04196 /* Don't poll for more than 60 seconds */ 04197 lowest = ast_tv(60, 0); 04198 } 04199 for (i = 0; i < SIG_PRI_NUM_DCHANS; i++) { 04200 if (!pri->dchans[i]) { 04201 /* We scanned all D channels on this span. */ 04202 break; 04203 } 04204 next = pri_schedule_next(pri->dchans[i]); 04205 if (next) { 04206 /* We need relative time here */ 04207 tv = ast_tvsub(*next, ast_tvnow()); 04208 if (tv.tv_sec < 0) { 04209 /* 04210 * A timer has already expired. 04211 * By definition zero time is the lowest so we can quit early. 04212 */ 04213 lowest = ast_tv(0, 0); 04214 break; 04215 } 04216 if (ast_tvcmp(tv, lowest) < 0) { 04217 lowest = tv; 04218 } 04219 } 04220 } 04221 ast_mutex_unlock(&pri->lock); 04222 04223 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); 04224 pthread_testcancel(); 04225 e = NULL; 04226 res = poll(fds, numdchans, lowest.tv_sec * 1000 + lowest.tv_usec / 1000); 04227 pthread_testcancel(); 04228 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL); 04229 04230 ast_mutex_lock(&pri->lock); 04231 if (!res) { 04232 for (which = 0; which < SIG_PRI_NUM_DCHANS; which++) { 04233 if (!pri->dchans[which]) 04234 break; 04235 /* Just a timeout, run the scheduler */ 04236 e = pri_schedule_run(pri->dchans[which]); 04237 if (e) 04238 break; 04239 } 04240 } else if (res > -1) { 04241 for (which = 0; which < SIG_PRI_NUM_DCHANS; which++) { 04242 if (!pri->dchans[which]) 04243 break; 04244 if (fds[which].revents & POLLPRI) { 04245 sig_pri_handle_dchan_exception(pri, which); 04246 } else if (fds[which].revents & POLLIN) { 04247 e = pri_check_event(pri->dchans[which]); 04248 } 04249 if (e) 04250 break; 04251 } 04252 } else if (errno != EINTR) 04253 ast_log(LOG_WARNING, "pri_event returned error %d (%s)\n", errno, strerror(errno)); 04254 04255 if (e) { 04256 if (pri->debug) { 04257 ast_verbose("Span: %d Processing event: %s\n", 04258 pri->span, pri_event2str(e->e)); 04259 } 04260 04261 if (e->e != PRI_EVENT_DCHAN_DOWN) { 04262 if (!(pri->dchanavail[which] & DCHAN_UP)) { 04263 ast_verb(2, "%s D-Channel on span %d up\n", pri_order(which), pri->span); 04264 } 04265 pri->dchanavail[which] |= DCHAN_UP; 04266 } else { 04267 if (pri->dchanavail[which] & DCHAN_UP) { 04268 ast_verb(2, "%s D-Channel on span %d down\n", pri_order(which), pri->span); 04269 } 04270 pri->dchanavail[which] &= ~DCHAN_UP; 04271 } 04272 04273 if ((e->e != PRI_EVENT_DCHAN_UP) && (e->e != PRI_EVENT_DCHAN_DOWN) && (pri->pri != pri->dchans[which])) 04274 /* Must be an NFAS group that has the secondary dchan active */ 04275 pri->pri = pri->dchans[which]; 04276 04277 switch (e->e) { 04278 case PRI_EVENT_DCHAN_UP: 04279 if (!pri->pri) pri_find_dchan(pri); 04280 04281 /* Note presense of D-channel */ 04282 time(&pri->lastreset); 04283 04284 /* Restart in 5 seconds */ 04285 if (pri->resetinterval > -1) { 04286 pri->lastreset -= pri->resetinterval; 04287 pri->lastreset += 5; 04288 } 04289 pri->resetting = 0; 04290 /* Take the channels from inalarm condition */ 04291 for (i = 0; i < pri->numchans; i++) { 04292 if (pri->pvts[i]) { 04293 sig_pri_set_alarm(pri->pvts[i], 0); 04294 } 04295 } 04296 sig_pri_span_devstate_changed(pri); 04297 break; 04298 case PRI_EVENT_DCHAN_DOWN: 04299 pri_find_dchan(pri); 04300 if (!pri_is_up(pri)) { 04301 pri->resetting = 0; 04302 if (pri->sig == SIG_BRI_PTMP) { 04303 /* For PTMP connections with non persistent layer 2 we want 04304 * to *not* declare inalarm unless there actually is an alarm */ 04305 break; 04306 } 04307 /* Hangup active channels and put them in alarm mode */ 04308 for (i = 0; i < pri->numchans; i++) { 04309 struct sig_pri_chan *p = pri->pvts[i]; 04310 if (p) { 04311 if (!p->pri || !p->pri->pri || pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0) { 04312 /* T309 is not enabled : hangup calls when alarm occurs */ 04313 if (p->call) { 04314 if (p->pri && p->pri->pri) { 04315 pri_hangup(p->pri->pri, p->call, -1); 04316 pri_destroycall(p->pri->pri, p->call); 04317 p->call = NULL; 04318 } else 04319 ast_log(LOG_WARNING, "The PRI Call have not been destroyed\n"); 04320 } 04321 if (p->owner) 04322 p->owner->_softhangup |= AST_SOFTHANGUP_DEV; 04323 } 04324 sig_pri_set_alarm(p, 1); 04325 } 04326 } 04327 sig_pri_span_devstate_changed(pri); 04328 } 04329 break; 04330 case PRI_EVENT_RESTART: 04331 if (e->restart.channel > -1) { 04332 chanpos = pri_find_principle(pri, e->restart.channel, NULL); 04333 if (chanpos < 0) 04334 ast_log(LOG_WARNING, "Restart requested on odd/unavailable channel number %d/%d on span %d\n", 04335 PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span); 04336 else { 04337 int skipit = 0; 04338 #if defined(HAVE_PRI_SERVICE_MESSAGES) 04339 unsigned why; 04340 04341 why = pri->pvts[chanpos]->service_status; 04342 if (why) { 04343 ast_log(LOG_NOTICE, 04344 "span '%d' channel '%d' out-of-service (reason: %s), ignoring RESTART\n", 04345 pri->span, PRI_CHANNEL(e->restart.channel), 04346 (why & SRVST_FAREND) ? (why & SRVST_NEAREND) ? "both ends" : "far end" : "near end"); 04347 skipit = 1; 04348 } 04349 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 04350 sig_pri_lock_private(pri->pvts[chanpos]); 04351 if (!skipit) { 04352 ast_verb(3, "B-channel %d/%d restarted on span %d\n", 04353 PRI_SPAN(e->restart.channel), PRI_CHANNEL(e->restart.channel), pri->span); 04354 if (pri->pvts[chanpos]->call) { 04355 pri_destroycall(pri->pri, pri->pvts[chanpos]->call); 04356 pri->pvts[chanpos]->call = NULL; 04357 } 04358 } 04359 /* Force soft hangup if appropriate */ 04360 if (pri->pvts[chanpos]->owner) 04361 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 04362 sig_pri_unlock_private(pri->pvts[chanpos]); 04363 } 04364 } else { 04365 ast_verb(3, "Restart requested on entire span %d\n", pri->span); 04366 for (x = 0; x < pri->numchans; x++) 04367 if (pri->pvts[x]) { 04368 sig_pri_lock_private(pri->pvts[x]); 04369 if (pri->pvts[x]->call) { 04370 pri_destroycall(pri->pri, pri->pvts[x]->call); 04371 pri->pvts[x]->call = NULL; 04372 } 04373 if (pri->pvts[x]->owner) 04374 pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 04375 sig_pri_unlock_private(pri->pvts[x]); 04376 } 04377 } 04378 break; 04379 case PRI_EVENT_KEYPAD_DIGIT: 04380 if (sig_pri_is_cis_call(e->digit.channel)) { 04381 sig_pri_handle_cis_subcmds(pri, e->e, e->digit.subcmds, 04382 e->digit.call); 04383 break; 04384 } 04385 chanpos = pri_find_principle(pri, e->digit.channel, e->digit.call); 04386 if (chanpos < 0) { 04387 ast_log(LOG_WARNING, "KEYPAD_DIGITs received on unconfigured channel %d/%d span %d\n", 04388 PRI_SPAN(e->digit.channel), PRI_CHANNEL(e->digit.channel), pri->span); 04389 } else { 04390 chanpos = pri_fixup_principle(pri, chanpos, e->digit.call); 04391 if (chanpos > -1) { 04392 sig_pri_lock_private(pri->pvts[chanpos]); 04393 sig_pri_handle_subcmds(pri, chanpos, e->e, e->digit.channel, 04394 e->digit.subcmds, e->digit.call); 04395 /* queue DTMF frame if the PBX for this call was already started (we're forwarding KEYPAD_DIGITs further on */ 04396 if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) 04397 && pri->pvts[chanpos]->call == e->digit.call 04398 && pri->pvts[chanpos]->owner) { 04399 /* how to do that */ 04400 int digitlen = strlen(e->digit.digits); 04401 int i; 04402 04403 for (i = 0; i < digitlen; i++) { 04404 struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->digit.digits[i], }; 04405 04406 pri_queue_frame(pri, chanpos, &f); 04407 } 04408 } 04409 sig_pri_unlock_private(pri->pvts[chanpos]); 04410 } 04411 } 04412 break; 04413 04414 case PRI_EVENT_INFO_RECEIVED: 04415 if (sig_pri_is_cis_call(e->ring.channel)) { 04416 sig_pri_handle_cis_subcmds(pri, e->e, e->ring.subcmds, 04417 e->ring.call); 04418 break; 04419 } 04420 chanpos = pri_find_principle(pri, e->ring.channel, e->ring.call); 04421 if (chanpos < 0) { 04422 ast_log(LOG_WARNING, "INFO received on unconfigured channel %d/%d span %d\n", 04423 PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); 04424 } else { 04425 chanpos = pri_fixup_principle(pri, chanpos, e->ring.call); 04426 if (chanpos > -1) { 04427 sig_pri_lock_private(pri->pvts[chanpos]); 04428 sig_pri_handle_subcmds(pri, chanpos, e->e, e->ring.channel, 04429 e->ring.subcmds, e->ring.call); 04430 /* queue DTMF frame if the PBX for this call was already started (we're forwarding INFORMATION further on */ 04431 if ((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) 04432 && pri->pvts[chanpos]->call == e->ring.call 04433 && pri->pvts[chanpos]->owner) { 04434 /* how to do that */ 04435 int digitlen = strlen(e->ring.callednum); 04436 int i; 04437 04438 for (i = 0; i < digitlen; i++) { 04439 struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = e->ring.callednum[i], }; 04440 04441 pri_queue_frame(pri, chanpos, &f); 04442 } 04443 } 04444 sig_pri_unlock_private(pri->pvts[chanpos]); 04445 } 04446 } 04447 break; 04448 #if defined(HAVE_PRI_SERVICE_MESSAGES) 04449 case PRI_EVENT_SERVICE: 04450 chanpos = pri_find_principle(pri, e->service.channel, NULL); 04451 if (chanpos < 0) { 04452 ast_log(LOG_WARNING, "Received service change status %d on unconfigured channel %d/%d span %d\n", 04453 e->service_ack.changestatus, PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span); 04454 } else { 04455 char db_chan_name[20]; 04456 char db_answer[5]; 04457 int ch; 04458 unsigned *why; 04459 04460 ch = pri->pvts[chanpos]->channel; 04461 snprintf(db_chan_name, sizeof(db_chan_name), "%s/%d:%d", dahdi_db, pri->span, ch); 04462 why = &pri->pvts[chanpos]->service_status; 04463 switch (e->service.changestatus) { 04464 case 0: /* in-service */ 04465 /* Far end wants to be in service now. */ 04466 ast_db_del(db_chan_name, SRVST_DBKEY); 04467 *why &= ~SRVST_FAREND; 04468 if (*why) { 04469 snprintf(db_answer, sizeof(db_answer), "%s:%u", 04470 SRVST_TYPE_OOS, *why); 04471 ast_db_put(db_chan_name, SRVST_DBKEY, db_answer); 04472 } else { 04473 sig_pri_span_devstate_changed(pri); 04474 } 04475 break; 04476 case 2: /* out-of-service */ 04477 /* Far end wants to be out-of-service now. */ 04478 ast_db_del(db_chan_name, SRVST_DBKEY); 04479 *why |= SRVST_FAREND; 04480 snprintf(db_answer, sizeof(db_answer), "%s:%u", SRVST_TYPE_OOS, 04481 *why); 04482 ast_db_put(db_chan_name, SRVST_DBKEY, db_answer); 04483 sig_pri_span_devstate_changed(pri); 04484 break; 04485 default: 04486 ast_log(LOG_ERROR, "Huh? changestatus is: %d\n", e->service.changestatus); 04487 break; 04488 } 04489 ast_log(LOG_NOTICE, "Channel %d/%d span %d (logical: %d) received a change of service message, status '%d'\n", 04490 PRI_SPAN(e->service.channel), PRI_CHANNEL(e->service.channel), pri->span, ch, e->service.changestatus); 04491 } 04492 break; 04493 case PRI_EVENT_SERVICE_ACK: 04494 chanpos = pri_find_principle(pri, e->service_ack.channel, NULL); 04495 if (chanpos < 0) { 04496 ast_log(LOG_WARNING, "Received service acknowledge change status '%d' on unconfigured channel %d/%d span %d\n", 04497 e->service_ack.changestatus, PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span); 04498 } else { 04499 ast_debug(2, "Channel %d/%d span %d received a change os service acknowledgement message, status '%d'\n", 04500 PRI_SPAN(e->service_ack.channel), PRI_CHANNEL(e->service_ack.channel), pri->span, e->service_ack.changestatus); 04501 } 04502 break; 04503 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 04504 case PRI_EVENT_RING: 04505 if (!ast_strlen_zero(pri->msn_list) 04506 && !sig_pri_msn_match(pri->msn_list, e->ring.callednum)) { 04507 /* The call is not for us so ignore it. */ 04508 ast_verb(3, 04509 "Ignoring call to '%s' on span %d. Its not in the MSN list: %s\n", 04510 e->ring.callednum, pri->span, pri->msn_list); 04511 pri_destroycall(pri->pri, e->ring.call); 04512 break; 04513 } 04514 if (sig_pri_is_cis_call(e->ring.channel)) { 04515 sig_pri_handle_cis_subcmds(pri, e->e, e->ring.subcmds, 04516 e->ring.call); 04517 break; 04518 } 04519 if (e->ring.channel == -1 || PRI_CHANNEL(e->ring.channel) == 0xFF) { 04520 /* Any channel requested. */ 04521 chanpos = pri_find_empty_chan(pri, 1); 04522 } else if (PRI_CHANNEL(e->ring.channel) == 0x00) { 04523 /* No channel specified. */ 04524 #if defined(HAVE_PRI_CALL_WAITING) 04525 if (!pri->allow_call_waiting_calls) 04526 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 04527 { 04528 /* We will not accept incoming call waiting calls. */ 04529 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_INCOMPATIBLE_DESTINATION); 04530 break; 04531 } 04532 #if defined(HAVE_PRI_CALL_WAITING) 04533 chanpos = pri_find_empty_nobch(pri); 04534 if (chanpos < 0) { 04535 /* We could not find/create a call interface. */ 04536 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION); 04537 break; 04538 } 04539 /* Setup the call interface to use. */ 04540 sig_pri_init_config(pri->pvts[chanpos], pri); 04541 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 04542 } else { 04543 /* A channel is specified. */ 04544 chanpos = pri_find_principle(pri, e->ring.channel, e->ring.call); 04545 } 04546 /* if no channel specified find one empty */ 04547 if (chanpos < 0) { 04548 ast_log(LOG_WARNING, "Ring requested on unconfigured channel %d/%d span %d\n", 04549 PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); 04550 } else { 04551 sig_pri_lock_private(pri->pvts[chanpos]); 04552 if (pri->pvts[chanpos]->owner) { 04553 if (pri->pvts[chanpos]->call == e->ring.call) { 04554 ast_log(LOG_WARNING, "Duplicate setup requested on channel %d/%d already in use on span %d\n", 04555 PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); 04556 sig_pri_unlock_private(pri->pvts[chanpos]); 04557 break; 04558 } else { 04559 /* This is where we handle initial glare */ 04560 ast_debug(1, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiating channel.\n", 04561 PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span); 04562 sig_pri_unlock_private(pri->pvts[chanpos]); 04563 chanpos = -1; 04564 } 04565 } 04566 if (chanpos > -1) 04567 sig_pri_unlock_private(pri->pvts[chanpos]); 04568 } 04569 if ((chanpos < 0) && (e->ring.flexible)) 04570 chanpos = pri_find_empty_chan(pri, 1); 04571 if (chanpos > -1) { 04572 sig_pri_lock_private(pri->pvts[chanpos]); 04573 pri->pvts[chanpos]->call = e->ring.call; 04574 04575 /* Use plancallingnum as a scratch buffer since it is initialized next. */ 04576 apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, 04577 e->ring.redirectingnum, e->ring.callingplanrdnis); 04578 sig_pri_set_rdnis(pri->pvts[chanpos], plancallingnum); 04579 04580 /* Setup caller-id info */ 04581 apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan); 04582 pri->pvts[chanpos]->cid_ani2 = 0; 04583 if (pri->pvts[chanpos]->use_callerid) { 04584 ast_shrink_phone_number(plancallingnum); 04585 ast_copy_string(pri->pvts[chanpos]->cid_num, plancallingnum, sizeof(pri->pvts[chanpos]->cid_num)); 04586 #ifdef PRI_ANI 04587 if (!ast_strlen_zero(e->ring.callingani)) { 04588 apply_plan_to_number(plancallingani, sizeof(plancallingani), pri, e->ring.callingani, e->ring.callingplanani); 04589 ast_shrink_phone_number(plancallingani); 04590 ast_copy_string(pri->pvts[chanpos]->cid_ani, plancallingani, sizeof(pri->pvts[chanpos]->cid_ani)); 04591 } else { 04592 pri->pvts[chanpos]->cid_ani[0] = '\0'; 04593 } 04594 #endif 04595 pri->pvts[chanpos]->cid_subaddr[0] = '\0'; 04596 #if defined(HAVE_PRI_SUBADDR) 04597 if (e->ring.calling.subaddress.valid) { 04598 struct ast_party_subaddress calling_subaddress; 04599 04600 ast_party_subaddress_init(&calling_subaddress); 04601 sig_pri_set_subaddress(&calling_subaddress, 04602 &e->ring.calling.subaddress); 04603 if (calling_subaddress.str) { 04604 ast_copy_string(pri->pvts[chanpos]->cid_subaddr, 04605 calling_subaddress.str, 04606 sizeof(pri->pvts[chanpos]->cid_subaddr)); 04607 } 04608 ast_party_subaddress_free(&calling_subaddress); 04609 } 04610 #endif /* defined(HAVE_PRI_SUBADDR) */ 04611 ast_copy_string(pri->pvts[chanpos]->cid_name, e->ring.callingname, sizeof(pri->pvts[chanpos]->cid_name)); 04612 pri->pvts[chanpos]->cid_ton = e->ring.callingplan; /* this is the callingplan (TON/NPI), e->ring.callingplan>>4 would be the TON */ 04613 pri->pvts[chanpos]->callingpres = e->ring.callingpres; 04614 if (e->ring.ani2 >= 0) { 04615 pri->pvts[chanpos]->cid_ani2 = e->ring.ani2; 04616 } 04617 } else { 04618 pri->pvts[chanpos]->cid_num[0] = '\0'; 04619 pri->pvts[chanpos]->cid_subaddr[0] = '\0'; 04620 pri->pvts[chanpos]->cid_ani[0] = '\0'; 04621 pri->pvts[chanpos]->cid_name[0] = '\0'; 04622 pri->pvts[chanpos]->cid_ton = 0; 04623 pri->pvts[chanpos]->callingpres = 0; 04624 } 04625 04626 /* Setup the user tag for party id's from this device for this call. */ 04627 if (pri->append_msn_to_user_tag) { 04628 snprintf(pri->pvts[chanpos]->user_tag, 04629 sizeof(pri->pvts[chanpos]->user_tag), "%s_%s", 04630 pri->initial_user_tag, 04631 pri->nodetype == PRI_NETWORK 04632 ? plancallingnum : e->ring.callednum); 04633 } else { 04634 ast_copy_string(pri->pvts[chanpos]->user_tag, 04635 pri->initial_user_tag, sizeof(pri->pvts[chanpos]->user_tag)); 04636 } 04637 04638 sig_pri_set_caller_id(pri->pvts[chanpos]); 04639 04640 /* Set DNID on all incoming calls -- even immediate */ 04641 sig_pri_set_dnid(pri->pvts[chanpos], e->ring.callednum); 04642 04643 /* If immediate=yes go to s|1 */ 04644 if (pri->pvts[chanpos]->immediate) { 04645 ast_verb(3, "Going to extension s|1 because of immediate=yes\n"); 04646 pri->pvts[chanpos]->exten[0] = 's'; 04647 pri->pvts[chanpos]->exten[1] = '\0'; 04648 } 04649 /* Get called number */ 04650 else if (!ast_strlen_zero(e->ring.callednum)) { 04651 ast_copy_string(pri->pvts[chanpos]->exten, e->ring.callednum, sizeof(pri->pvts[chanpos]->exten)); 04652 } else if (pri->overlapdial) 04653 pri->pvts[chanpos]->exten[0] = '\0'; 04654 else { 04655 /* Some PRI circuits are set up to send _no_ digits. Handle them as 's'. */ 04656 pri->pvts[chanpos]->exten[0] = 's'; 04657 pri->pvts[chanpos]->exten[1] = '\0'; 04658 } 04659 /* No number yet, but received "sending complete"? */ 04660 if (e->ring.complete && (ast_strlen_zero(e->ring.callednum))) { 04661 ast_verb(3, "Going to extension s|1 because of Complete received\n"); 04662 pri->pvts[chanpos]->exten[0] = 's'; 04663 pri->pvts[chanpos]->exten[1] = '\0'; 04664 } 04665 04666 /* Make sure extension exists (or in overlap dial mode, can exist) */ 04667 if (((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) || 04668 ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) { 04669 /* Setup law */ 04670 if (e->ring.complete || !(pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)) { 04671 /* Just announce proceeding */ 04672 pri->pvts[chanpos]->proceeding = 1; 04673 pri_proceeding(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 0); 04674 } else { 04675 if (pri->switchtype != PRI_SWITCH_GR303_TMC) 04676 pri_need_more_info(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1); 04677 else 04678 pri_answer(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1); 04679 } 04680 04681 /* Start PBX */ 04682 if (!e->ring.complete 04683 && (pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) 04684 && ast_matchmore_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) { 04685 /* 04686 * Release the PRI lock while we create the channel 04687 * so other threads can send D channel messages. 04688 */ 04689 ast_mutex_unlock(&pri->lock); 04690 c = sig_pri_new_ast_channel(pri->pvts[chanpos], 04691 AST_STATE_RESERVED, 04692 (e->ring.layer1 == PRI_LAYER_1_ALAW) 04693 ? SIG_PRI_ALAW : SIG_PRI_ULAW, 04694 e->ring.ctype, pri->pvts[chanpos]->exten, NULL); 04695 ast_mutex_lock(&pri->lock); 04696 if (c) { 04697 #if defined(HAVE_PRI_SUBADDR) 04698 if (e->ring.calling.subaddress.valid) { 04699 /* Set Calling Subaddress */ 04700 sig_pri_lock_owner(pri, chanpos); 04701 sig_pri_set_subaddress( 04702 &pri->pvts[chanpos]->owner->caller.id.subaddress, 04703 &e->ring.calling.subaddress); 04704 if (!e->ring.calling.subaddress.type 04705 && !ast_strlen_zero( 04706 (char *) e->ring.calling.subaddress.data)) { 04707 /* NSAP */ 04708 pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", 04709 (char *) e->ring.calling.subaddress.data); 04710 } 04711 ast_channel_unlock(c); 04712 } 04713 if (e->ring.called_subaddress.valid) { 04714 /* Set Called Subaddress */ 04715 sig_pri_lock_owner(pri, chanpos); 04716 sig_pri_set_subaddress( 04717 &pri->pvts[chanpos]->owner->dialed.subaddress, 04718 &e->ring.called_subaddress); 04719 if (!e->ring.called_subaddress.type 04720 && !ast_strlen_zero( 04721 (char *) e->ring.called_subaddress.data)) { 04722 /* NSAP */ 04723 pbx_builtin_setvar_helper(c, "CALLEDSUBADDR", 04724 (char *) e->ring.called_subaddress.data); 04725 } 04726 ast_channel_unlock(c); 04727 } 04728 #else 04729 if (!ast_strlen_zero(e->ring.callingsubaddr)) { 04730 pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr); 04731 } 04732 #endif /* !defined(HAVE_PRI_SUBADDR) */ 04733 if (e->ring.ani2 >= 0) { 04734 snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2); 04735 pbx_builtin_setvar_helper(c, "ANI2", ani2str); 04736 } 04737 04738 #ifdef SUPPORT_USERUSER 04739 if (!ast_strlen_zero(e->ring.useruserinfo)) { 04740 pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo); 04741 } 04742 #endif 04743 04744 snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan); 04745 pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr); 04746 if (e->ring.redirectingreason >= 0) { 04747 /* This is now just a status variable. Use REDIRECTING() dialplan function. */ 04748 pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason)); 04749 } 04750 #if defined(HAVE_PRI_REVERSE_CHARGE) 04751 pri->pvts[chanpos]->reverse_charging_indication = e->ring.reversecharge; 04752 #endif 04753 #if defined(HAVE_PRI_SETUP_KEYPAD) 04754 ast_copy_string(pri->pvts[chanpos]->keypad_digits, 04755 e->ring.keypad_digits, 04756 sizeof(pri->pvts[chanpos]->keypad_digits)); 04757 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */ 04758 04759 sig_pri_handle_subcmds(pri, chanpos, e->e, e->ring.channel, 04760 e->ring.subcmds, e->ring.call); 04761 04762 } 04763 if (c && !ast_pthread_create_detached(&threadid, NULL, pri_ss_thread, pri->pvts[chanpos])) { 04764 ast_verb(3, "Accepting overlap call from '%s' to '%s' on channel %d/%d, span %d\n", 04765 plancallingnum, S_OR(pri->pvts[chanpos]->exten, "<unspecified>"), 04766 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); 04767 } else { 04768 ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 04769 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); 04770 if (c) 04771 ast_hangup(c); 04772 else { 04773 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION); 04774 pri->pvts[chanpos]->call = NULL; 04775 } 04776 } 04777 } else { 04778 /* 04779 * Release the PRI lock while we create the channel 04780 * so other threads can send D channel messages. 04781 */ 04782 ast_mutex_unlock(&pri->lock); 04783 c = sig_pri_new_ast_channel(pri->pvts[chanpos], 04784 AST_STATE_RING, 04785 (e->ring.layer1 == PRI_LAYER_1_ALAW) 04786 ? SIG_PRI_ALAW : SIG_PRI_ULAW, e->ring.ctype, 04787 pri->pvts[chanpos]->exten, NULL); 04788 ast_mutex_lock(&pri->lock); 04789 if (c) { 04790 /* 04791 * It is reasonably safe to set the following 04792 * channel variables while the PRI and DAHDI private 04793 * structures are locked. The PBX has not been 04794 * started yet and it is unlikely that any other task 04795 * will do anything with the channel we have just 04796 * created. 04797 */ 04798 #if defined(HAVE_PRI_SUBADDR) 04799 if (e->ring.calling.subaddress.valid) { 04800 /* Set Calling Subaddress */ 04801 sig_pri_lock_owner(pri, chanpos); 04802 sig_pri_set_subaddress( 04803 &pri->pvts[chanpos]->owner->caller.id.subaddress, 04804 &e->ring.calling.subaddress); 04805 if (!e->ring.calling.subaddress.type 04806 && !ast_strlen_zero( 04807 (char *) e->ring.calling.subaddress.data)) { 04808 /* NSAP */ 04809 pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", 04810 (char *) e->ring.calling.subaddress.data); 04811 } 04812 ast_channel_unlock(c); 04813 } 04814 if (e->ring.called_subaddress.valid) { 04815 /* Set Called Subaddress */ 04816 sig_pri_lock_owner(pri, chanpos); 04817 sig_pri_set_subaddress( 04818 &pri->pvts[chanpos]->owner->dialed.subaddress, 04819 &e->ring.called_subaddress); 04820 if (!e->ring.called_subaddress.type 04821 && !ast_strlen_zero( 04822 (char *) e->ring.called_subaddress.data)) { 04823 /* NSAP */ 04824 pbx_builtin_setvar_helper(c, "CALLEDSUBADDR", 04825 (char *) e->ring.called_subaddress.data); 04826 } 04827 ast_channel_unlock(c); 04828 } 04829 #else 04830 if (!ast_strlen_zero(e->ring.callingsubaddr)) { 04831 pbx_builtin_setvar_helper(c, "CALLINGSUBADDR", e->ring.callingsubaddr); 04832 } 04833 #endif /* !defined(HAVE_PRI_SUBADDR) */ 04834 if (e->ring.ani2 >= 0) { 04835 snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2); 04836 pbx_builtin_setvar_helper(c, "ANI2", ani2str); 04837 } 04838 04839 #ifdef SUPPORT_USERUSER 04840 if (!ast_strlen_zero(e->ring.useruserinfo)) { 04841 pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo); 04842 } 04843 #endif 04844 04845 if (e->ring.redirectingreason >= 0) { 04846 /* This is now just a status variable. Use REDIRECTING() dialplan function. */ 04847 pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason)); 04848 } 04849 #if defined(HAVE_PRI_REVERSE_CHARGE) 04850 pri->pvts[chanpos]->reverse_charging_indication = e->ring.reversecharge; 04851 #endif 04852 #if defined(HAVE_PRI_SETUP_KEYPAD) 04853 ast_copy_string(pri->pvts[chanpos]->keypad_digits, 04854 e->ring.keypad_digits, 04855 sizeof(pri->pvts[chanpos]->keypad_digits)); 04856 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */ 04857 04858 snprintf(calledtonstr, sizeof(calledtonstr), "%d", e->ring.calledplan); 04859 pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr); 04860 04861 sig_pri_handle_subcmds(pri, chanpos, e->e, e->ring.channel, 04862 e->ring.subcmds, e->ring.call); 04863 04864 } 04865 if (c && !ast_pbx_start(c)) { 04866 ast_verb(3, "Accepting call from '%s' to '%s' on channel %d/%d, span %d\n", 04867 plancallingnum, pri->pvts[chanpos]->exten, 04868 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); 04869 sig_pri_set_echocanceller(pri->pvts[chanpos], 1); 04870 } else { 04871 ast_log(LOG_WARNING, "Unable to start PBX on channel %d/%d, span %d\n", 04872 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span); 04873 if (c) { 04874 ast_hangup(c); 04875 } else { 04876 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_SWITCH_CONGESTION); 04877 pri->pvts[chanpos]->call = NULL; 04878 } 04879 } 04880 } 04881 } else { 04882 ast_verb(3, "Extension '%s' in context '%s' from '%s' does not exist. Rejecting call on channel %d/%d, span %d\n", 04883 pri->pvts[chanpos]->exten, pri->pvts[chanpos]->context, pri->pvts[chanpos]->cid_num, pri->pvts[chanpos]->logicalspan, 04884 pri->pvts[chanpos]->prioffset, pri->span); 04885 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_UNALLOCATED); 04886 pri->pvts[chanpos]->call = NULL; 04887 pri->pvts[chanpos]->exten[0] = '\0'; 04888 } 04889 sig_pri_unlock_private(pri->pvts[chanpos]); 04890 } else { 04891 if (e->ring.flexible) 04892 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION); 04893 else 04894 pri_hangup(pri->pri, e->ring.call, PRI_CAUSE_REQUESTED_CHAN_UNAVAIL); 04895 } 04896 break; 04897 case PRI_EVENT_RINGING: 04898 if (sig_pri_is_cis_call(e->ringing.channel)) { 04899 sig_pri_handle_cis_subcmds(pri, e->e, e->ringing.subcmds, 04900 e->ringing.call); 04901 break; 04902 } 04903 chanpos = pri_find_principle(pri, e->ringing.channel, e->ringing.call); 04904 if (chanpos < 0) { 04905 ast_log(LOG_WARNING, "Ringing requested on unconfigured channel %d/%d span %d\n", 04906 PRI_SPAN(e->ringing.channel), PRI_CHANNEL(e->ringing.channel), pri->span); 04907 } else { 04908 chanpos = pri_fixup_principle(pri, chanpos, e->ringing.call); 04909 if (chanpos < 0) { 04910 ast_log(LOG_WARNING, "Ringing requested on channel %d/%d not in use on span %d\n", 04911 PRI_SPAN(e->ringing.channel), PRI_CHANNEL(e->ringing.channel), pri->span); 04912 } else { 04913 sig_pri_lock_private(pri->pvts[chanpos]); 04914 04915 sig_pri_handle_subcmds(pri, chanpos, e->e, e->ringing.channel, 04916 e->ringing.subcmds, e->ringing.call); 04917 sig_pri_cc_generic_check(pri, chanpos, AST_CC_CCNR); 04918 sig_pri_set_echocanceller(pri->pvts[chanpos], 1); 04919 pri_queue_control(pri, chanpos, AST_CONTROL_RINGING); 04920 pri->pvts[chanpos]->alerting = 1; 04921 04922 if ( 04923 #ifdef PRI_PROGRESS_MASK 04924 e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE 04925 #else 04926 e->ringing.progress == 8 04927 #endif 04928 ) { 04929 sig_pri_open_media(pri->pvts[chanpos]); 04930 } 04931 04932 04933 #ifdef SUPPORT_USERUSER 04934 if (!ast_strlen_zero(e->ringing.useruserinfo)) { 04935 struct ast_channel *owner; 04936 04937 sig_pri_lock_owner(pri, chanpos); 04938 owner = pri->pvts[chanpos]->owner; 04939 if (owner) { 04940 pbx_builtin_setvar_helper(owner, "USERUSERINFO", 04941 e->ringing.useruserinfo); 04942 ast_channel_unlock(owner); 04943 } 04944 } 04945 #endif 04946 04947 sig_pri_unlock_private(pri->pvts[chanpos]); 04948 } 04949 } 04950 break; 04951 case PRI_EVENT_PROGRESS: 04952 if (sig_pri_is_cis_call(e->proceeding.channel)) { 04953 sig_pri_handle_cis_subcmds(pri, e->e, e->proceeding.subcmds, 04954 e->proceeding.call); 04955 break; 04956 } 04957 chanpos = pri_find_principle(pri, e->proceeding.channel, e->proceeding.call); 04958 if (chanpos > -1) { 04959 sig_pri_lock_private(pri->pvts[chanpos]); 04960 sig_pri_handle_subcmds(pri, chanpos, e->e, e->proceeding.channel, 04961 e->proceeding.subcmds, e->proceeding.call); 04962 04963 if (e->proceeding.cause > -1) { 04964 ast_verb(3, "PROGRESS with cause code %d received\n", e->proceeding.cause); 04965 04966 /* Work around broken, out of spec USER_BUSY cause in a progress message */ 04967 if (e->proceeding.cause == AST_CAUSE_USER_BUSY) { 04968 if (pri->pvts[chanpos]->owner) { 04969 ast_verb(3, "PROGRESS with 'user busy' received, signaling AST_CONTROL_BUSY instead of AST_CONTROL_PROGRESS\n"); 04970 04971 pri->pvts[chanpos]->owner->hangupcause = e->proceeding.cause; 04972 pri_queue_control(pri, chanpos, AST_CONTROL_BUSY); 04973 } 04974 } 04975 } 04976 04977 if (!pri->pvts[chanpos]->progress 04978 && !pri->pvts[chanpos]->no_b_channel 04979 #ifdef PRI_PROGRESS_MASK 04980 && (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) 04981 #else 04982 && e->proceeding.progress == 8 04983 #endif 04984 ) { 04985 /* Bring voice path up */ 04986 ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n", 04987 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); 04988 pri_queue_control(pri, chanpos, AST_CONTROL_PROGRESS); 04989 pri->pvts[chanpos]->progress = 1; 04990 sig_pri_set_dialing(pri->pvts[chanpos], 0); 04991 sig_pri_open_media(pri->pvts[chanpos]); 04992 } 04993 sig_pri_unlock_private(pri->pvts[chanpos]); 04994 } 04995 break; 04996 case PRI_EVENT_PROCEEDING: 04997 if (sig_pri_is_cis_call(e->proceeding.channel)) { 04998 sig_pri_handle_cis_subcmds(pri, e->e, e->proceeding.subcmds, 04999 e->proceeding.call); 05000 break; 05001 } 05002 chanpos = pri_find_principle(pri, e->proceeding.channel, e->proceeding.call); 05003 if (chanpos > -1) { 05004 sig_pri_lock_private(pri->pvts[chanpos]); 05005 sig_pri_handle_subcmds(pri, chanpos, e->e, e->proceeding.channel, 05006 e->proceeding.subcmds, e->proceeding.call); 05007 if (!pri->pvts[chanpos]->proceeding) { 05008 ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n", 05009 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span); 05010 pri_queue_control(pri, chanpos, AST_CONTROL_PROCEEDING); 05011 pri->pvts[chanpos]->proceeding = 1; 05012 } 05013 if (!pri->pvts[chanpos]->progress 05014 && !pri->pvts[chanpos]->no_b_channel 05015 #ifdef PRI_PROGRESS_MASK 05016 && (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) 05017 #else 05018 && e->proceeding.progress == 8 05019 #endif 05020 ) { 05021 /* Bring voice path up */ 05022 pri_queue_control(pri, chanpos, AST_CONTROL_PROGRESS); 05023 pri->pvts[chanpos]->progress = 1; 05024 sig_pri_set_dialing(pri->pvts[chanpos], 0); 05025 sig_pri_open_media(pri->pvts[chanpos]); 05026 } 05027 sig_pri_unlock_private(pri->pvts[chanpos]); 05028 } 05029 break; 05030 case PRI_EVENT_FACILITY: 05031 if (!e->facility.call || sig_pri_is_cis_call(e->facility.channel)) { 05032 /* Event came in on the dummy channel or a CIS call. */ 05033 #if defined(HAVE_PRI_CALL_REROUTING) 05034 sig_pri_handle_cis_subcmds(pri, e->e, e->facility.subcmds, 05035 e->facility.subcall); 05036 #else 05037 sig_pri_handle_cis_subcmds(pri, e->e, e->facility.subcmds, 05038 e->facility.call); 05039 #endif /* !defined(HAVE_PRI_CALL_REROUTING) */ 05040 break; 05041 } 05042 chanpos = pri_find_principle(pri, e->facility.channel, e->facility.call); 05043 if (chanpos < 0) { 05044 ast_log(LOG_WARNING, "Facility requested on unconfigured channel %d/%d span %d\n", 05045 PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span); 05046 } else { 05047 chanpos = pri_fixup_principle(pri, chanpos, e->facility.call); 05048 if (chanpos < 0) { 05049 ast_log(LOG_WARNING, "Facility requested on channel %d/%d not in use on span %d\n", 05050 PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span); 05051 } else { 05052 sig_pri_lock_private(pri->pvts[chanpos]); 05053 #if defined(HAVE_PRI_CALL_REROUTING) 05054 sig_pri_handle_subcmds(pri, chanpos, e->e, e->facility.channel, 05055 e->facility.subcmds, e->facility.subcall); 05056 #else 05057 sig_pri_handle_subcmds(pri, chanpos, e->e, e->facility.channel, 05058 e->facility.subcmds, e->facility.call); 05059 #endif /* !defined(HAVE_PRI_CALL_REROUTING) */ 05060 sig_pri_unlock_private(pri->pvts[chanpos]); 05061 } 05062 } 05063 break; 05064 case PRI_EVENT_ANSWER: 05065 if (sig_pri_is_cis_call(e->answer.channel)) { 05066 sig_pri_handle_cis_subcmds(pri, e->e, e->answer.subcmds, 05067 e->answer.call); 05068 break; 05069 } 05070 chanpos = pri_find_principle(pri, e->answer.channel, e->answer.call); 05071 if (chanpos < 0) { 05072 ast_log(LOG_WARNING, "Answer on unconfigured channel %d/%d span %d\n", 05073 PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span); 05074 break; 05075 } 05076 chanpos = pri_fixup_principle(pri, chanpos, e->answer.call); 05077 if (chanpos < 0) { 05078 ast_log(LOG_WARNING, "Answer requested on channel %d/%d not in use on span %d\n", 05079 PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span); 05080 break; 05081 } 05082 #if defined(HAVE_PRI_CALL_WAITING) 05083 if (pri->pvts[chanpos]->is_call_waiting) { 05084 if (pri->pvts[chanpos]->no_b_channel) { 05085 int new_chanpos; 05086 05087 /* 05088 * Need to find a free channel now or 05089 * kill the call with PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION. 05090 */ 05091 new_chanpos = pri_find_empty_chan(pri, 1); 05092 if (new_chanpos < 0) { 05093 sig_pri_lock_private(pri->pvts[chanpos]); 05094 sig_pri_handle_subcmds(pri, chanpos, e->e, e->answer.channel, 05095 e->answer.subcmds, e->answer.call); 05096 sig_pri_cc_generic_check(pri, chanpos, AST_CC_CCBS); 05097 if (pri->pvts[chanpos]->owner) { 05098 pri->pvts[chanpos]->owner->hangupcause = PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION; 05099 switch (pri->pvts[chanpos]->owner->_state) { 05100 case AST_STATE_BUSY: 05101 case AST_STATE_UP: 05102 ast_softhangup_nolock(pri->pvts[chanpos]->owner, AST_SOFTHANGUP_DEV); 05103 break; 05104 default: 05105 pri_queue_control(pri, chanpos, AST_CONTROL_CONGESTION); 05106 break; 05107 } 05108 } else { 05109 pri->pvts[chanpos]->is_call_waiting = 0; 05110 ast_atomic_fetchadd_int(&pri->num_call_waiting_calls, -1); 05111 pri_hangup(pri->pri, e->answer.call, PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION); 05112 pri->pvts[chanpos]->call = NULL; 05113 } 05114 sig_pri_unlock_private(pri->pvts[chanpos]); 05115 break; 05116 } 05117 chanpos = pri_fixup_principle(pri, new_chanpos, e->answer.call); 05118 if (chanpos < 0) { 05119 ast_log(LOG_WARNING, 05120 "Unable to move call waiting call channel on span %d\n", 05121 pri->span); 05122 break; 05123 } 05124 } 05125 pri_connect_ack(pri->pri, e->answer.call, PVT_TO_CHANNEL(pri->pvts[chanpos])); 05126 } else { 05127 /* Call is normal so do normal CONNECT_ACKNOWLEDGE. */ 05128 pri_connect_ack(pri->pri, e->answer.call, 0); 05129 } 05130 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 05131 sig_pri_lock_private(pri->pvts[chanpos]); 05132 05133 #if defined(HAVE_PRI_CALL_WAITING) 05134 if (pri->pvts[chanpos]->is_call_waiting) { 05135 pri->pvts[chanpos]->is_call_waiting = 0; 05136 ast_atomic_fetchadd_int(&pri->num_call_waiting_calls, -1); 05137 sig_pri_span_devstate_changed(pri); 05138 } 05139 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 05140 sig_pri_handle_subcmds(pri, chanpos, e->e, e->answer.channel, 05141 e->answer.subcmds, e->answer.call); 05142 sig_pri_open_media(pri->pvts[chanpos]); 05143 pri_queue_control(pri, chanpos, AST_CONTROL_ANSWER); 05144 /* Enable echo cancellation if it's not on already */ 05145 sig_pri_set_dialing(pri->pvts[chanpos], 0); 05146 sig_pri_set_echocanceller(pri->pvts[chanpos], 1); 05147 05148 #ifdef SUPPORT_USERUSER 05149 if (!ast_strlen_zero(e->answer.useruserinfo)) { 05150 struct ast_channel *owner; 05151 05152 sig_pri_lock_owner(pri, chanpos); 05153 owner = pri->pvts[chanpos]->owner; 05154 if (owner) { 05155 pbx_builtin_setvar_helper(owner, "USERUSERINFO", 05156 e->answer.useruserinfo); 05157 ast_channel_unlock(owner); 05158 } 05159 } 05160 #endif 05161 05162 sig_pri_unlock_private(pri->pvts[chanpos]); 05163 break; 05164 #if defined(HAVE_PRI_CALL_WAITING) 05165 case PRI_EVENT_CONNECT_ACK: 05166 if (sig_pri_is_cis_call(e->connect_ack.channel)) { 05167 sig_pri_handle_cis_subcmds(pri, e->e, e->connect_ack.subcmds, 05168 e->connect_ack.call); 05169 break; 05170 } 05171 chanpos = pri_find_principle(pri, e->connect_ack.channel, 05172 e->connect_ack.call); 05173 if (chanpos < 0) { 05174 ast_log(LOG_WARNING, "Connect ACK on unconfigured channel %d/%d span %d\n", 05175 PRI_SPAN(e->connect_ack.channel), 05176 PRI_CHANNEL(e->connect_ack.channel), pri->span); 05177 break; 05178 } 05179 chanpos = pri_fixup_principle(pri, chanpos, e->connect_ack.call); 05180 if (chanpos < 0) { 05181 ast_log(LOG_WARNING, "Connect ACK requested on channel %d/%d not in use on span %d\n", 05182 PRI_SPAN(e->connect_ack.channel), 05183 PRI_CHANNEL(e->connect_ack.channel), pri->span); 05184 break; 05185 } 05186 05187 sig_pri_lock_private(pri->pvts[chanpos]); 05188 sig_pri_span_devstate_changed(pri); 05189 sig_pri_handle_subcmds(pri, chanpos, e->e, e->connect_ack.channel, 05190 e->connect_ack.subcmds, e->connect_ack.call); 05191 sig_pri_open_media(pri->pvts[chanpos]); 05192 sig_pri_unlock_private(pri->pvts[chanpos]); 05193 break; 05194 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 05195 case PRI_EVENT_HANGUP: 05196 if (sig_pri_is_cis_call(e->hangup.channel)) { 05197 sig_pri_handle_cis_subcmds(pri, e->e, e->hangup.subcmds, 05198 e->hangup.call); 05199 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05200 break; 05201 } 05202 chanpos = pri_find_principle(pri, e->hangup.channel, e->hangup.call); 05203 if (chanpos < 0) { 05204 ast_log(LOG_WARNING, "Hangup requested on unconfigured channel %d/%d span %d\n", 05205 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05206 /* 05207 * Continue hanging up the call even though 05208 * it is on an unconfigured channel. 05209 */ 05210 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05211 } else { 05212 chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call); 05213 if (chanpos > -1) { 05214 sig_pri_lock_private(pri->pvts[chanpos]); 05215 sig_pri_handle_subcmds(pri, chanpos, e->e, e->hangup.channel, 05216 e->hangup.subcmds, e->hangup.call); 05217 if (!pri->pvts[chanpos]->alreadyhungup) { 05218 /* we're calling here dahdi_hangup so once we get there we need to clear p->call after calling pri_hangup */ 05219 pri->pvts[chanpos]->alreadyhungup = 1; 05220 switch (e->hangup.cause) { 05221 case PRI_CAUSE_USER_BUSY: 05222 case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: 05223 sig_pri_cc_generic_check(pri, chanpos, AST_CC_CCBS); 05224 break; 05225 default: 05226 break; 05227 } 05228 if (pri->pvts[chanpos]->owner) { 05229 int do_hangup = 0; 05230 /* Queue a BUSY instead of a hangup if our cause is appropriate */ 05231 pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause; 05232 switch (pri->pvts[chanpos]->owner->_state) { 05233 case AST_STATE_BUSY: 05234 case AST_STATE_UP: 05235 do_hangup = 1; 05236 break; 05237 default: 05238 if (!pri->pvts[chanpos]->outgoing) { 05239 /* 05240 * The incoming call leg hung up before getting 05241 * connected so just hangup the call. 05242 */ 05243 do_hangup = 1; 05244 break; 05245 } 05246 switch (e->hangup.cause) { 05247 case PRI_CAUSE_USER_BUSY: 05248 pri_queue_control(pri, chanpos, AST_CONTROL_BUSY); 05249 break; 05250 case PRI_CAUSE_CALL_REJECTED: 05251 case PRI_CAUSE_NETWORK_OUT_OF_ORDER: 05252 case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: 05253 case PRI_CAUSE_SWITCH_CONGESTION: 05254 case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: 05255 case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: 05256 pri_queue_control(pri, chanpos, AST_CONTROL_CONGESTION); 05257 break; 05258 default: 05259 do_hangup = 1; 05260 break; 05261 } 05262 break; 05263 } 05264 05265 if (do_hangup) { 05266 #if defined(HAVE_PRI_AOC_EVENTS) 05267 if (detect_aoc_e_subcmd(e->hangup.subcmds)) { 05268 /* If a AOC-E msg was sent during the release, we must use a 05269 * AST_CONTROL_HANGUP frame to guarantee that frame gets read before hangup */ 05270 pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP); 05271 } else { 05272 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05273 } 05274 #else 05275 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05276 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 05277 } 05278 } else { 05279 /* 05280 * Continue hanging up the call even though 05281 * we do not have an owner. 05282 */ 05283 pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause); 05284 pri->pvts[chanpos]->call = NULL; 05285 } 05286 ast_verb(3, "Channel %d/%d, span %d got hangup, cause %d\n", 05287 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, e->hangup.cause); 05288 } else { 05289 /* Continue hanging up the call. */ 05290 pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause); 05291 pri->pvts[chanpos]->call = NULL; 05292 } 05293 if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) { 05294 ast_verb(3, "Forcing restart of channel %d/%d on span %d since channel reported in use\n", 05295 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05296 pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos])); 05297 pri->pvts[chanpos]->resetting = 1; 05298 } 05299 if (e->hangup.aoc_units > -1) 05300 ast_verb(3, "Channel %d/%d, span %d received AOC-E charging %d unit%s\n", 05301 pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s"); 05302 05303 #ifdef SUPPORT_USERUSER 05304 if (!ast_strlen_zero(e->hangup.useruserinfo)) { 05305 struct ast_channel *owner; 05306 05307 sig_pri_lock_owner(pri, chanpos); 05308 owner = pri->pvts[chanpos]->owner; 05309 if (owner) { 05310 pbx_builtin_setvar_helper(owner, "USERUSERINFO", 05311 e->hangup.useruserinfo); 05312 ast_channel_unlock(owner); 05313 } 05314 } 05315 #endif 05316 05317 sig_pri_unlock_private(pri->pvts[chanpos]); 05318 } else { 05319 /* 05320 * Continue hanging up the call even though 05321 * we do not remember it (if we ever did). 05322 */ 05323 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05324 } 05325 } 05326 break; 05327 case PRI_EVENT_HANGUP_REQ: 05328 if (sig_pri_is_cis_call(e->hangup.channel)) { 05329 sig_pri_handle_cis_subcmds(pri, e->e, e->hangup.subcmds, 05330 e->hangup.call); 05331 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05332 break; 05333 } 05334 chanpos = pri_find_principle(pri, e->hangup.channel, e->hangup.call); 05335 if (chanpos < 0) { 05336 ast_log(LOG_WARNING, "Hangup REQ requested on unconfigured channel %d/%d span %d\n", 05337 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05338 /* 05339 * Continue hanging up the call even though 05340 * it is on an unconfigured channel. 05341 */ 05342 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05343 } else { 05344 chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call); 05345 if (chanpos > -1) { 05346 sig_pri_lock_private(pri->pvts[chanpos]); 05347 sig_pri_handle_subcmds(pri, chanpos, e->e, e->hangup.channel, 05348 e->hangup.subcmds, e->hangup.call); 05349 #if defined(HAVE_PRI_CALL_HOLD) 05350 if (e->hangup.call_active && e->hangup.call_held 05351 && pri->hold_disconnect_transfer) { 05352 /* We are to transfer the call instead of simply hanging up. */ 05353 sig_pri_unlock_private(pri->pvts[chanpos]); 05354 if (!sig_pri_attempt_transfer(pri, e->hangup.call_active, 0, 05355 e->hangup.call_held, 1)) { 05356 break; 05357 } 05358 sig_pri_lock_private(pri->pvts[chanpos]); 05359 } 05360 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05361 switch (e->hangup.cause) { 05362 case PRI_CAUSE_USER_BUSY: 05363 case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: 05364 sig_pri_cc_generic_check(pri, chanpos, AST_CC_CCBS); 05365 break; 05366 default: 05367 break; 05368 } 05369 if (pri->pvts[chanpos]->owner) { 05370 int do_hangup = 0; 05371 05372 pri->pvts[chanpos]->owner->hangupcause = e->hangup.cause; 05373 switch (pri->pvts[chanpos]->owner->_state) { 05374 case AST_STATE_BUSY: 05375 case AST_STATE_UP: 05376 do_hangup = 1; 05377 break; 05378 default: 05379 if (!pri->pvts[chanpos]->outgoing) { 05380 /* 05381 * The incoming call leg hung up before getting 05382 * connected so just hangup the call. 05383 */ 05384 do_hangup = 1; 05385 break; 05386 } 05387 switch (e->hangup.cause) { 05388 case PRI_CAUSE_USER_BUSY: 05389 pri_queue_control(pri, chanpos, AST_CONTROL_BUSY); 05390 break; 05391 case PRI_CAUSE_CALL_REJECTED: 05392 case PRI_CAUSE_NETWORK_OUT_OF_ORDER: 05393 case PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION: 05394 case PRI_CAUSE_SWITCH_CONGESTION: 05395 case PRI_CAUSE_DESTINATION_OUT_OF_ORDER: 05396 case PRI_CAUSE_NORMAL_TEMPORARY_FAILURE: 05397 pri_queue_control(pri, chanpos, AST_CONTROL_CONGESTION); 05398 break; 05399 default: 05400 do_hangup = 1; 05401 break; 05402 } 05403 break; 05404 } 05405 05406 if (do_hangup) { 05407 #if defined(HAVE_PRI_AOC_EVENTS) 05408 if (!pri->pvts[chanpos]->holding_aoce 05409 && pri->aoce_delayhangup 05410 && ast_bridged_channel(pri->pvts[chanpos]->owner)) { 05411 sig_pri_send_aoce_termination_request(pri, chanpos, 05412 pri_get_timer(pri->pri, PRI_TIMER_T305) / 2); 05413 } else if (detect_aoc_e_subcmd(e->hangup.subcmds)) { 05414 /* If a AOC-E msg was sent during the Disconnect, we must use a AST_CONTROL_HANGUP frame 05415 * to guarantee that frame gets read before hangup */ 05416 pri_queue_control(pri, chanpos, AST_CONTROL_HANGUP); 05417 } else { 05418 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05419 } 05420 #else 05421 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05422 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 05423 } 05424 ast_verb(3, "Channel %d/%d, span %d got hangup request, cause %d\n", 05425 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span, e->hangup.cause); 05426 } else { 05427 /* 05428 * Continue hanging up the call even though 05429 * we do not have an owner. 05430 */ 05431 pri_hangup(pri->pri, pri->pvts[chanpos]->call, e->hangup.cause); 05432 pri->pvts[chanpos]->call = NULL; 05433 } 05434 if (e->hangup.cause == PRI_CAUSE_REQUESTED_CHAN_UNAVAIL) { 05435 ast_verb(3, "Forcing restart of channel %d/%d span %d since channel reported in use\n", 05436 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05437 pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos])); 05438 pri->pvts[chanpos]->resetting = 1; 05439 } 05440 05441 #ifdef SUPPORT_USERUSER 05442 if (!ast_strlen_zero(e->hangup.useruserinfo)) { 05443 struct ast_channel *owner; 05444 05445 sig_pri_lock_owner(pri, chanpos); 05446 owner = pri->pvts[chanpos]->owner; 05447 if (owner) { 05448 pbx_builtin_setvar_helper(owner, "USERUSERINFO", 05449 e->hangup.useruserinfo); 05450 ast_channel_unlock(owner); 05451 } 05452 } 05453 #endif 05454 05455 sig_pri_unlock_private(pri->pvts[chanpos]); 05456 } else { 05457 /* 05458 * Continue hanging up the call even though 05459 * we do not remember it (if we ever did). 05460 */ 05461 pri_hangup(pri->pri, e->hangup.call, e->hangup.cause); 05462 } 05463 } 05464 break; 05465 case PRI_EVENT_HANGUP_ACK: 05466 if (sig_pri_is_cis_call(e->hangup.channel)) { 05467 sig_pri_handle_cis_subcmds(pri, e->e, e->hangup.subcmds, 05468 e->hangup.call); 05469 break; 05470 } 05471 chanpos = pri_find_principle(pri, e->hangup.channel, e->hangup.call); 05472 if (chanpos < 0) { 05473 ast_log(LOG_WARNING, "Hangup ACK requested on unconfigured channel number %d/%d span %d\n", 05474 PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05475 } else { 05476 chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call); 05477 if (chanpos > -1) { 05478 sig_pri_lock_private(pri->pvts[chanpos]); 05479 pri->pvts[chanpos]->call = NULL; 05480 pri->pvts[chanpos]->resetting = 0; 05481 if (pri->pvts[chanpos]->owner) { 05482 ast_verb(3, "Channel %d/%d, span %d got hangup ACK\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span); 05483 } 05484 #ifdef SUPPORT_USERUSER 05485 if (!ast_strlen_zero(e->hangup.useruserinfo)) { 05486 struct ast_channel *owner; 05487 05488 sig_pri_lock_owner(pri, chanpos); 05489 owner = pri->pvts[chanpos]->owner; 05490 if (owner) { 05491 pbx_builtin_setvar_helper(owner, "USERUSERINFO", 05492 e->hangup.useruserinfo); 05493 ast_channel_unlock(owner); 05494 } 05495 } 05496 #endif 05497 sig_pri_unlock_private(pri->pvts[chanpos]); 05498 } 05499 } 05500 break; 05501 case PRI_EVENT_CONFIG_ERR: 05502 ast_log(LOG_WARNING, "PRI Error on span %d: %s\n", pri->span, e->err.err); 05503 break; 05504 case PRI_EVENT_RESTART_ACK: 05505 chanpos = pri_find_principle(pri, e->restartack.channel, NULL); 05506 if (chanpos < 0) { 05507 /* Sometime switches (e.g. I421 / British Telecom) don't give us the 05508 channel number, so we have to figure it out... This must be why 05509 everybody resets exactly a channel at a time. */ 05510 for (x = 0; x < pri->numchans; x++) { 05511 if (pri->pvts[x] && pri->pvts[x]->resetting) { 05512 chanpos = x; 05513 sig_pri_lock_private(pri->pvts[chanpos]); 05514 ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan, 05515 pri->pvts[chanpos]->prioffset, pri->span); 05516 if (pri->pvts[chanpos]->owner) { 05517 ast_log(LOG_WARNING, "Got restart ack on channel %d/%d with owner on span %d\n", pri->pvts[chanpos]->logicalspan, 05518 pri->pvts[chanpos]->prioffset, pri->span); 05519 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05520 } 05521 pri->pvts[chanpos]->resetting = 0; 05522 ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan, 05523 pri->pvts[chanpos]->prioffset, pri->span); 05524 sig_pri_unlock_private(pri->pvts[chanpos]); 05525 if (pri->resetting) 05526 pri_check_restart(pri); 05527 break; 05528 } 05529 } 05530 if (chanpos < 0) { 05531 ast_log(LOG_WARNING, "Restart ACK requested on strange channel %d/%d span %d\n", 05532 PRI_SPAN(e->restartack.channel), PRI_CHANNEL(e->restartack.channel), pri->span); 05533 } 05534 } else { 05535 if (pri->pvts[chanpos]) { 05536 sig_pri_lock_private(pri->pvts[chanpos]); 05537 if (pri->pvts[chanpos]->owner) { 05538 ast_log(LOG_WARNING, "Got restart ack on channel %d/%d span %d with owner\n", 05539 PRI_SPAN(e->restartack.channel), PRI_CHANNEL(e->restartack.channel), pri->span); 05540 pri->pvts[chanpos]->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05541 } 05542 pri->pvts[chanpos]->resetting = 0; 05543 ast_verb(3, "B-channel %d/%d successfully restarted on span %d\n", pri->pvts[chanpos]->logicalspan, 05544 pri->pvts[chanpos]->prioffset, pri->span); 05545 sig_pri_unlock_private(pri->pvts[chanpos]); 05546 if (pri->resetting) 05547 pri_check_restart(pri); 05548 } 05549 } 05550 break; 05551 case PRI_EVENT_SETUP_ACK: 05552 if (sig_pri_is_cis_call(e->setup_ack.channel)) { 05553 sig_pri_handle_cis_subcmds(pri, e->e, e->setup_ack.subcmds, 05554 e->setup_ack.call); 05555 break; 05556 } 05557 chanpos = pri_find_principle(pri, e->setup_ack.channel, e->setup_ack.call); 05558 if (chanpos < 0) { 05559 ast_log(LOG_WARNING, "Received SETUP_ACKNOWLEDGE on unconfigured channel %d/%d span %d\n", 05560 PRI_SPAN(e->setup_ack.channel), PRI_CHANNEL(e->setup_ack.channel), pri->span); 05561 } else { 05562 chanpos = pri_fixup_principle(pri, chanpos, e->setup_ack.call); 05563 if (chanpos > -1) { 05564 sig_pri_lock_private(pri->pvts[chanpos]); 05565 sig_pri_handle_subcmds(pri, chanpos, e->e, e->setup_ack.channel, 05566 e->setup_ack.subcmds, e->setup_ack.call); 05567 pri->pvts[chanpos]->setup_ack = 1; 05568 /* Send any queued digits */ 05569 for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) { 05570 ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]); 05571 pri_information(pri->pri, pri->pvts[chanpos]->call, 05572 pri->pvts[chanpos]->dialdest[x]); 05573 } 05574 sig_pri_unlock_private(pri->pvts[chanpos]); 05575 } else 05576 ast_log(LOG_WARNING, "Unable to move channel %d!\n", e->setup_ack.channel); 05577 } 05578 break; 05579 case PRI_EVENT_NOTIFY: 05580 if (sig_pri_is_cis_call(e->notify.channel)) { 05581 #if defined(HAVE_PRI_CALL_HOLD) 05582 sig_pri_handle_cis_subcmds(pri, e->e, e->notify.subcmds, 05583 e->notify.call); 05584 #else 05585 sig_pri_handle_cis_subcmds(pri, e->e, e->notify.subcmds, NULL); 05586 #endif /* !defined(HAVE_PRI_CALL_HOLD) */ 05587 break; 05588 } 05589 #if defined(HAVE_PRI_CALL_HOLD) 05590 chanpos = pri_find_principle(pri, e->notify.channel, e->notify.call); 05591 #else 05592 chanpos = pri_find_principle(pri, e->notify.channel, NULL); 05593 #endif /* !defined(HAVE_PRI_CALL_HOLD) */ 05594 if (chanpos < 0) { 05595 ast_log(LOG_WARNING, "Received NOTIFY on unconfigured channel %d/%d span %d\n", 05596 PRI_SPAN(e->notify.channel), PRI_CHANNEL(e->notify.channel), pri->span); 05597 } else { 05598 sig_pri_lock_private(pri->pvts[chanpos]); 05599 #if defined(HAVE_PRI_CALL_HOLD) 05600 sig_pri_handle_subcmds(pri, chanpos, e->e, e->notify.channel, 05601 e->notify.subcmds, e->notify.call); 05602 #else 05603 sig_pri_handle_subcmds(pri, chanpos, e->e, e->notify.channel, 05604 e->notify.subcmds, NULL); 05605 #endif /* !defined(HAVE_PRI_CALL_HOLD) */ 05606 switch (e->notify.info) { 05607 case PRI_NOTIFY_REMOTE_HOLD: 05608 if (!pri->discardremoteholdretrieval) { 05609 pri_queue_control(pri, chanpos, AST_CONTROL_HOLD); 05610 } 05611 break; 05612 case PRI_NOTIFY_REMOTE_RETRIEVAL: 05613 if (!pri->discardremoteholdretrieval) { 05614 pri_queue_control(pri, chanpos, AST_CONTROL_UNHOLD); 05615 } 05616 break; 05617 } 05618 sig_pri_unlock_private(pri->pvts[chanpos]); 05619 } 05620 break; 05621 #if defined(HAVE_PRI_CALL_HOLD) 05622 case PRI_EVENT_HOLD: 05623 /* We should not be getting any CIS calls with this message type. */ 05624 if (sig_pri_handle_hold(pri, e)) { 05625 pri_hold_rej(pri->pri, e->hold.call, 05626 PRI_CAUSE_RESOURCE_UNAVAIL_UNSPECIFIED); 05627 } else { 05628 pri_hold_ack(pri->pri, e->hold.call); 05629 } 05630 break; 05631 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05632 #if defined(HAVE_PRI_CALL_HOLD) 05633 case PRI_EVENT_HOLD_ACK: 05634 ast_debug(1, "Event: HOLD_ACK\n"); 05635 break; 05636 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05637 #if defined(HAVE_PRI_CALL_HOLD) 05638 case PRI_EVENT_HOLD_REJ: 05639 ast_debug(1, "Event: HOLD_REJ\n"); 05640 break; 05641 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05642 #if defined(HAVE_PRI_CALL_HOLD) 05643 case PRI_EVENT_RETRIEVE: 05644 /* We should not be getting any CIS calls with this message type. */ 05645 sig_pri_handle_retrieve(pri, e); 05646 break; 05647 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05648 #if defined(HAVE_PRI_CALL_HOLD) 05649 case PRI_EVENT_RETRIEVE_ACK: 05650 ast_debug(1, "Event: RETRIEVE_ACK\n"); 05651 break; 05652 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05653 #if defined(HAVE_PRI_CALL_HOLD) 05654 case PRI_EVENT_RETRIEVE_REJ: 05655 ast_debug(1, "Event: RETRIEVE_REJ\n"); 05656 break; 05657 #endif /* defined(HAVE_PRI_CALL_HOLD) */ 05658 default: 05659 ast_debug(1, "Event: %d\n", e->e); 05660 break; 05661 } 05662 } 05663 ast_mutex_unlock(&pri->lock); 05664 } 05665 /* Never reached */ 05666 return NULL; 05667 }
| 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 }
| static int pri_find_dchan | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 967 of file sig_pri.c.
References ast_log(), DCHAN_AVAILABLE, sig_pri_span::dchanavail, sig_pri_span::dchans, sig_pri_span::fds, LOG_NOTICE, LOG_WARNING, sig_pri_span::pri, sig_pri_span::sig, SIG_BRI_PTMP, and SIG_PRI_NUM_DCHANS.
Referenced by pri_dchannel(), and pri_event_alarm().
00968 { 00969 int oldslot = -1; 00970 struct pri *old; 00971 int newslot = -1; 00972 int x; 00973 old = pri->pri; 00974 for (x = 0; x < SIG_PRI_NUM_DCHANS; x++) { 00975 if ((pri->dchanavail[x] == DCHAN_AVAILABLE) && (newslot < 0)) 00976 newslot = x; 00977 if (pri->dchans[x] == old) { 00978 oldslot = x; 00979 } 00980 } 00981 if (newslot < 0) { 00982 newslot = 0; 00983 /* This is annoying to see on non persistent layer 2 connections. Let's not complain in that case */ 00984 if (pri->sig != SIG_BRI_PTMP) { 00985 ast_log(LOG_WARNING, "No D-channels available! Using Primary channel as D-channel anyway!\n"); 00986 } 00987 } 00988 if (old && (oldslot != newslot)) 00989 ast_log(LOG_NOTICE, "Switching from d-channel fd %d to fd %d!\n", 00990 pri->fds[oldslot], pri->fds[newslot]); 00991 pri->pri = pri->dchans[newslot]; 00992 return 0; 00993 }
| static int pri_find_empty_chan | ( | struct sig_pri_span * | pri, | |
| int | backwards | |||
| ) | [static] |
Definition at line 1365 of file sig_pri.c.
References ast_debug, sig_pri_chan::inalarm, sig_pri_chan::logicalspan, sig_pri_chan::no_b_channel, sig_pri_span::numchans, sig_pri_chan::owner, sig_pri_chan::prioffset, and sig_pri_span::pvts.
Referenced by pri_dchannel(), and sig_pri_handle_retrieve().
01366 { 01367 int x; 01368 if (backwards) 01369 x = pri->numchans; 01370 else 01371 x = 0; 01372 for (;;) { 01373 if (backwards && (x < 0)) 01374 break; 01375 if (!backwards && (x >= pri->numchans)) 01376 break; 01377 if (pri->pvts[x] 01378 && !pri->pvts[x]->no_b_channel 01379 && !pri->pvts[x]->inalarm 01380 && !pri->pvts[x]->owner) { 01381 ast_debug(1, "Found empty available channel %d/%d\n", 01382 pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset); 01383 return x; 01384 } 01385 if (backwards) 01386 x--; 01387 else 01388 x++; 01389 } 01390 return -1; 01391 }
| static int pri_find_empty_nobch | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 1406 of file sig_pri.c.
References ast_debug, sig_pri_span::calls, sig_pri_chan::inalarm, sig_pri_callback::new_nobch_intf, sig_pri_chan::no_b_channel, sig_pri_span::numchans, sig_pri_chan::owner, and sig_pri_span::pvts.
Referenced by pri_dchannel(), and sig_pri_handle_hold().
01407 { 01408 int idx; 01409 01410 for (idx = 0; idx < pri->numchans; ++idx) { 01411 if (pri->pvts[idx] 01412 && pri->pvts[idx]->no_b_channel 01413 && !pri->pvts[idx]->inalarm 01414 && !pri->pvts[idx]->owner) { 01415 ast_debug(1, "Found empty available no B channel interface\n"); 01416 return idx; 01417 } 01418 } 01419 01420 /* Need to create a new interface. */ 01421 if (pri->calls->new_nobch_intf) { 01422 idx = pri->calls->new_nobch_intf(pri); 01423 } else { 01424 idx = -1; 01425 } 01426 return idx; 01427 }
| static int pri_find_pri_call | ( | struct sig_pri_span * | pri, | |
| q931_call * | call | |||
| ) | [static] |
Definition at line 1444 of file sig_pri.c.
References sig_pri_chan::call, sig_pri_span::numchans, and sig_pri_span::pvts.
Referenced by sig_pri_attempt_transfer().
01445 { 01446 int idx; 01447 01448 for (idx = 0; idx < pri->numchans; ++idx) { 01449 if (pri->pvts[idx] && pri->pvts[idx]->call == call) { 01450 /* Found the channel */ 01451 return idx; 01452 } 01453 } 01454 return -1; 01455 }
| static int pri_find_principle | ( | struct sig_pri_span * | pri, | |
| int | channel, | |||
| q931_call * | call | |||
| ) | [static] |
Definition at line 1076 of file sig_pri.c.
References sig_pri_chan::call, sig_pri_span::dchan_logical_span, sig_pri_chan::logicalspan, sig_pri_chan::no_b_channel, sig_pri_span::numchans, pri_active_dchan_index(), PRI_CHANNEL, PRI_EXPLICIT, PRI_HELD_CALL, PRI_SPAN, sig_pri_chan::prioffset, and sig_pri_span::pvts.
Referenced by pri_dchannel(), sig_pri_handle_hold(), and sig_pri_handle_retrieve().
01077 { 01078 int x; 01079 int span; 01080 int principle; 01081 int prioffset; 01082 01083 if (channel < 0) { 01084 /* Channel is not picked yet. */ 01085 return -1; 01086 } 01087 01088 prioffset = PRI_CHANNEL(channel); 01089 if (!prioffset || (channel & PRI_HELD_CALL)) { 01090 if (!call) { 01091 /* Cannot find a call waiting call or held call without a call. */ 01092 return -1; 01093 } 01094 principle = -1; 01095 for (x = 0; x < pri->numchans; ++x) { 01096 if (pri->pvts[x] 01097 && pri->pvts[x]->call == call) { 01098 principle = x; 01099 break; 01100 } 01101 } 01102 return principle; 01103 } 01104 01105 span = PRI_SPAN(channel); 01106 if (!(channel & PRI_EXPLICIT)) { 01107 int index; 01108 01109 index = pri_active_dchan_index(pri); 01110 if (index == -1) { 01111 return -1; 01112 } 01113 span = pri->dchan_logical_span[index]; 01114 } 01115 01116 principle = -1; 01117 for (x = 0; x < pri->numchans; x++) { 01118 if (pri->pvts[x] 01119 && pri->pvts[x]->prioffset == prioffset 01120 && pri->pvts[x]->logicalspan == span 01121 && !pri->pvts[x]->no_b_channel) { 01122 principle = x; 01123 break; 01124 } 01125 } 01126 01127 return principle; 01128 }
| static int pri_fixup_principle | ( | struct sig_pri_span * | pri, | |
| int | principle, | |||
| q931_call * | call | |||
| ) | [static] |
Definition at line 1130 of file sig_pri.c.
References sig_pri_chan::alerting, sig_pri_chan::alreadyhungup, ast_log(), ast_verb, sig_pri_chan::call, sig_pri_chan::channel, sig_pri_chan::context, sig_pri_chan::digital, sig_pri_chan::hidecallerid, sig_pri_chan::hidecalleridname, sig_pri_chan::immediate, sig_pri_chan::isidlecall, sig_pri_chan::keypad_digits, LOG_WARNING, sig_pri_chan::logicalspan, sig_pri_chan::mastertrunkgroup, sig_pri_chan::mohinterpret, sig_pri_chan::no_b_channel, sig_pri_span::numchans, sig_pri_chan::outgoing, sig_pri_chan::owner, sig_pri_chan::priexclusive, sig_pri_chan::priindication_oob, sig_pri_chan::proceeding, sig_pri_chan::progress, sig_pri_span::pvts, sig_pri_chan::reverse_charging_indication, sig_pri_chan::setup_ack, sig_pri_fixup_chans(), sig_pri_chan::stripmsd, sig_pri_chan::use_callerid, sig_pri_chan::use_callingpres, and sig_pri_chan::user_tag.
Referenced by pri_dchannel(), sig_pri_handle_hold(), and sig_pri_handle_retrieve().
01131 { 01132 int x; 01133 01134 if (principle < 0 || pri->numchans <= principle) { 01135 /* Out of rannge */ 01136 return -1; 01137 } 01138 if (!call) { 01139 /* No call */ 01140 return principle; 01141 } 01142 if (pri->pvts[principle] && pri->pvts[principle]->call == call) { 01143 /* Call is already on the specified principle. */ 01144 return principle; 01145 } 01146 01147 /* Find the old principle location. */ 01148 for (x = 0; x < pri->numchans; x++) { 01149 struct sig_pri_chan *new_chan; 01150 struct sig_pri_chan *old_chan; 01151 01152 if (!pri->pvts[x] || pri->pvts[x]->call != call) { 01153 continue; 01154 } 01155 01156 /* Found our call */ 01157 new_chan = pri->pvts[principle]; 01158 old_chan = pri->pvts[x]; 01159 01160 ast_verb(3, "Moving call from channel %d to channel %d\n", 01161 old_chan->channel, new_chan->channel); 01162 if (new_chan->owner) { 01163 ast_log(LOG_WARNING, 01164 "Can't fix up channel from %d to %d because %d is already in use\n", 01165 old_chan->channel, new_chan->channel, new_chan->channel); 01166 return -1; 01167 } 01168 01169 sig_pri_fixup_chans(old_chan, new_chan); 01170 01171 /* Fix it all up now */ 01172 new_chan->owner = old_chan->owner; 01173 old_chan->owner = NULL; 01174 01175 new_chan->call = old_chan->call; 01176 old_chan->call = NULL; 01177 01178 /* Transfer flags from the old channel. */ 01179 #if defined(HAVE_PRI_AOC_EVENTS) 01180 new_chan->aoc_s_request_invoke_id_valid = old_chan->aoc_s_request_invoke_id_valid; 01181 new_chan->waiting_for_aoce = old_chan->waiting_for_aoce; 01182 new_chan->holding_aoce = old_chan->holding_aoce; 01183 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 01184 new_chan->alerting = old_chan->alerting; 01185 new_chan->alreadyhungup = old_chan->alreadyhungup; 01186 new_chan->isidlecall = old_chan->isidlecall; 01187 new_chan->proceeding = old_chan->proceeding; 01188 new_chan->progress = old_chan->progress; 01189 new_chan->setup_ack = old_chan->setup_ack; 01190 new_chan->outgoing = old_chan->outgoing; 01191 new_chan->digital = old_chan->digital; 01192 #if defined(HAVE_PRI_CALL_WAITING) 01193 new_chan->is_call_waiting = old_chan->is_call_waiting; 01194 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 01195 01196 #if defined(HAVE_PRI_AOC_EVENTS) 01197 old_chan->aoc_s_request_invoke_id_valid = 0; 01198 old_chan->waiting_for_aoce = 0; 01199 old_chan->holding_aoce = 0; 01200 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 01201 old_chan->alerting = 0; 01202 old_chan->alreadyhungup = 0; 01203 old_chan->isidlecall = 0; 01204 old_chan->proceeding = 0; 01205 old_chan->progress = 0; 01206 old_chan->setup_ack = 0; 01207 old_chan->outgoing = 0; 01208 old_chan->digital = 0; 01209 #if defined(HAVE_PRI_CALL_WAITING) 01210 old_chan->is_call_waiting = 0; 01211 #endif /* defined(HAVE_PRI_CALL_WAITING) */ 01212 01213 /* More stuff to transfer to the new channel. */ 01214 #if defined(HAVE_PRI_REVERSE_CHARGE) 01215 new_chan->reverse_charging_indication = old_chan->reverse_charging_indication; 01216 #endif /* defined(HAVE_PRI_REVERSE_CHARGE) */ 01217 #if defined(HAVE_PRI_SETUP_KEYPAD) 01218 strcpy(new_chan->keypad_digits, old_chan->keypad_digits); 01219 #endif /* defined(HAVE_PRI_SETUP_KEYPAD) */ 01220 #if defined(HAVE_PRI_AOC_EVENTS) 01221 new_chan->aoc_s_request_invoke_id = old_chan->aoc_s_request_invoke_id; 01222 new_chan->aoc_e = old_chan->aoc_e; 01223 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 01224 strcpy(new_chan->user_tag, old_chan->user_tag); 01225 01226 if (new_chan->no_b_channel) { 01227 /* Copy the real channel configuration to the no B channel interface. */ 01228 new_chan->hidecallerid = old_chan->hidecallerid; 01229 new_chan->hidecalleridname = old_chan->hidecalleridname; 01230 new_chan->immediate = old_chan->immediate; 01231 new_chan->priexclusive = old_chan->priexclusive; 01232 new_chan->priindication_oob = old_chan->priindication_oob; 01233 new_chan->use_callerid = old_chan->use_callerid; 01234 new_chan->use_callingpres = old_chan->use_callingpres; 01235 new_chan->stripmsd = old_chan->stripmsd; 01236 strcpy(new_chan->context, old_chan->context); 01237 strcpy(new_chan->mohinterpret, old_chan->mohinterpret); 01238 01239 /* Become a member of the old channel span/trunk-group. */ 01240 new_chan->logicalspan = old_chan->logicalspan; 01241 new_chan->mastertrunkgroup = old_chan->mastertrunkgroup; 01242 } 01243 01244 return principle; 01245 } 01246 ast_verb(3, "Call specified, but not found.\n"); 01247 return -1; 01248 }
| static int pri_grab | ( | struct sig_pri_chan * | p, | |
| struct sig_pri_span * | pri | |||
| ) | [inline, static] |
Definition at line 283 of file sig_pri.c.
References ast_mutex_trylock, sig_pri_span::lock, sig_pri_span::master, and PRI_DEADLOCK_AVOIDANCE.
Referenced by pri_send_callrerouting_facility_exec(), pri_send_keypad_facility_exec(), pri_ss_thread(), sig_pri_answer(), sig_pri_call(), sig_pri_chan_alarm_notify(), sig_pri_digit_begin(), sig_pri_hangup(), sig_pri_indicate(), and sig_pri_new_ast_channel().
00284 { 00285 int res; 00286 /* Grab the lock first */ 00287 do { 00288 res = ast_mutex_trylock(&pri->lock); 00289 if (res) { 00290 PRI_DEADLOCK_AVOIDANCE(p); 00291 } 00292 } while (res); 00293 /* Then break the poll */ 00294 pthread_kill(pri->master, SIGURG); 00295 return 0; 00296 }
| 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 }
| static char* pri_order | ( | int | level | ) | [static] |
Definition at line 937 of file sig_pri.c.
Referenced by pri_dchannel(), and sig_pri_cli_show_span().
00938 { 00939 switch (level) { 00940 case 0: 00941 return "Primary"; 00942 case 1: 00943 return "Secondary"; 00944 case 2: 00945 return "Tertiary"; 00946 case 3: 00947 return "Quaternary"; 00948 default: 00949 return "<Unknown>"; 00950 } 00951 }
| static void pri_queue_control | ( | struct sig_pri_span * | pri, | |
| int | chanpos, | |||
| int | subclass | |||
| ) | [static] |
Definition at line 1063 of file sig_pri.c.
References AST_FRAME_CONTROL, sig_pri_chan::calls, sig_pri_chan::chan_pvt, ast_frame_subclass::integer, pri_queue_frame(), sig_pri_span::pvts, sig_pri_callback::queue_control, and ast_frame::subclass.
Referenced by pri_dchannel(), and sig_pri_handle_retrieve().
01064 { 01065 struct ast_frame f = {AST_FRAME_CONTROL, }; 01066 struct sig_pri_chan *p = pri->pvts[chanpos]; 01067 01068 if (p->calls->queue_control) { 01069 p->calls->queue_control(p->chan_pvt, subclass); 01070 } 01071 01072 f.subclass.integer = subclass; 01073 pri_queue_frame(pri, chanpos, &f); 01074 }
| static void pri_queue_frame | ( | struct sig_pri_span * | pri, | |
| int | chanpos, | |||
| struct ast_frame * | frame | |||
| ) | [static] |
Definition at line 1040 of file sig_pri.c.
References ast_channel_unlock, ast_queue_frame(), sig_pri_chan::owner, sig_pri_span::pvts, and sig_pri_lock_owner().
Referenced by pri_dchannel(), and pri_queue_control().
01041 { 01042 sig_pri_lock_owner(pri, chanpos); 01043 if (pri->pvts[chanpos]->owner) { 01044 ast_queue_frame(pri->pvts[chanpos]->owner, frame); 01045 ast_channel_unlock(pri->pvts[chanpos]->owner); 01046 } 01047 }
| static void pri_rel | ( | struct sig_pri_span * | pri | ) | [inline, static] |
Definition at line 112 of file sig_pri.c.
References ast_mutex_unlock, and sig_pri_span::lock.
Referenced by pri_send_callrerouting_facility_exec(), pri_send_keypad_facility_exec(), pri_ss_thread(), sig_pri_answer(), sig_pri_call(), sig_pri_chan_alarm_notify(), sig_pri_digit_begin(), sig_pri_hangup(), sig_pri_indicate(), and sig_pri_new_ast_channel().
00113 { 00114 ast_mutex_unlock(&pri->lock); 00115 }
| 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 }
| static void* pri_ss_thread | ( | void * | data | ) | [static] |
Definition at line 1507 of file sig_pri.c.
References sig_pri_span::append_msn_to_user_tag, AST_CAUSE_UNALLOCATED, ast_copy_string(), ast_exists_extension(), ast_free, ast_hangup(), ast_ignore_pattern(), ast_log(), ast_matchmore_extension(), AST_MAX_EXTENSION, ast_pbx_run(), ast_setstate(), AST_STATE_RING, ast_strdup, ast_strlen_zero(), ast_verb, ast_waitfordigit(), sig_pri_chan::call, ast_channel::caller, sig_pri_chan::cid_num, ast_channel::context, DAHDI_OVERLAPDIAL_INCOMING, ast_channel::dialed, ast_channel::exten, sig_pri_chan::exten, exten, ast_channel::hangupcause, ast_party_caller::id, sig_pri_span::initial_user_tag, len(), LOG_DEBUG, LOG_WARNING, ast_channel::name, sig_pri_span::nodetype, ast_party_dialed::number, sig_pri_span::overlapdial, sig_pri_chan::owner, sig_pri_span::pri, sig_pri_chan::pri, pri_gendigittimeout, pri_grab(), pri_matchdigittimeout, pri_rel(), sig_pri_chan::proceeding, PVT_TO_CHANNEL(), sig_pri_dsp_reset_and_flush_digits(), sig_pri_lock_private(), sig_pri_play_tone(), sig_pri_set_echocanceller(), SIG_PRI_TONE_DIALTONE, sig_pri_unlock_private(), sig_pri_span::span, ast_party_dialed::str, ast_party_id::tag, ast_channel::tech_pvt, and sig_pri_chan::user_tag.
Referenced by pri_dchannel().
01508 { 01509 struct sig_pri_chan *p = data; 01510 struct ast_channel *chan = p->owner; 01511 char exten[AST_MAX_EXTENSION]; 01512 int res; 01513 int len; 01514 int timeout; 01515 01516 if (!chan) { 01517 /* We lost the owner before we could get started. */ 01518 return NULL; 01519 } 01520 01521 /* 01522 * In the bizarre case where the channel has become a zombie before we 01523 * even get started here, abort safely. 01524 */ 01525 if (!chan->tech_pvt) { 01526 ast_log(LOG_WARNING, "Channel became a zombie before simple switch could be started (%s)\n", chan->name); 01527 ast_hangup(chan); 01528 return NULL; 01529 } 01530 01531 ast_verb(3, "Starting simple switch on '%s'\n", chan->name); 01532 01533 sig_pri_dsp_reset_and_flush_digits(p); 01534 01535 /* Now loop looking for an extension */ 01536 ast_copy_string(exten, p->exten, sizeof(exten)); 01537 len = strlen(exten); 01538 res = 0; 01539 while ((len < AST_MAX_EXTENSION-1) && ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) { 01540 if (len && !ast_ignore_pattern(chan->context, exten)) 01541 sig_pri_play_tone(p, -1); 01542 else 01543 sig_pri_play_tone(p, SIG_PRI_TONE_DIALTONE); 01544 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) 01545 timeout = pri_matchdigittimeout; 01546 else 01547 timeout = pri_gendigittimeout; 01548 res = ast_waitfordigit(chan, timeout); 01549 if (res < 0) { 01550 ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n"); 01551 ast_hangup(chan); 01552 return NULL; 01553 } else if (res) { 01554 exten[len++] = res; 01555 exten[len] = '\0'; 01556 } else 01557 break; 01558 } 01559 /* if no extension was received ('unspecified') on overlap call, use the 's' extension */ 01560 if (ast_strlen_zero(exten)) { 01561 ast_verb(3, "Going to extension s|1 because of empty extension received on overlap call\n"); 01562 exten[0] = 's'; 01563 exten[1] = '\0'; 01564 } else { 01565 ast_free(chan->dialed.number.str); 01566 chan->dialed.number.str = ast_strdup(exten); 01567 01568 if (p->pri->append_msn_to_user_tag && p->pri->nodetype != PRI_NETWORK) { 01569 /* 01570 * Update the user tag for party id's from this device for this call 01571 * now that we have a complete MSN from the network. 01572 */ 01573 snprintf(p->user_tag, sizeof(p->user_tag), "%s_%s", p->pri->initial_user_tag, 01574 exten); 01575 ast_free(chan->caller.id.tag); 01576 chan->caller.id.tag = ast_strdup(p->user_tag); 01577 } 01578 } 01579 sig_pri_play_tone(p, -1); 01580 if (ast_exists_extension(chan, chan->context, exten, 1, p->cid_num)) { 01581 /* Start the real PBX */ 01582 ast_copy_string(chan->exten, exten, sizeof(chan->exten)); 01583 sig_pri_dsp_reset_and_flush_digits(p); 01584 if (p->pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) { 01585 sig_pri_lock_private(p); 01586 if (p->pri->pri) { 01587 if (!pri_grab(p, p->pri)) { 01588 pri_proceeding(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 0); 01589 p->proceeding = 1; 01590 pri_rel(p->pri); 01591 } else { 01592 ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span); 01593 } 01594 } 01595 sig_pri_unlock_private(p); 01596 } 01597 01598 sig_pri_set_echocanceller(p, 1); 01599 ast_setstate(chan, AST_STATE_RING); 01600 res = ast_pbx_run(chan); 01601 if (res) { 01602 ast_log(LOG_WARNING, "PBX exited non-zero!\n"); 01603 } 01604 } else { 01605 ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context); 01606 chan->hangupcause = AST_CAUSE_UNALLOCATED; 01607 ast_hangup(chan); 01608 p->exten[0] = '\0'; 01609 /* Since we send release complete here, we won't get one */ 01610 p->call = NULL; 01611 } 01612 return NULL; 01613 }
| static enum AST_PARTY_CHAR_SET pri_to_ast_char_set | ( | int | pri_char_set | ) | [static] |
Definition at line 475 of file sig_pri.c.
References AST_PARTY_CHAR_SET_ISO10646_BMPSTRING, AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING, AST_PARTY_CHAR_SET_ISO8859_1, AST_PARTY_CHAR_SET_ISO8859_2, AST_PARTY_CHAR_SET_ISO8859_3, AST_PARTY_CHAR_SET_ISO8859_4, AST_PARTY_CHAR_SET_ISO8859_5, AST_PARTY_CHAR_SET_ISO8859_7, AST_PARTY_CHAR_SET_UNKNOWN, and AST_PARTY_CHAR_SET_WITHDRAWN.
Referenced by sig_pri_party_name_convert().
00476 { 00477 enum AST_PARTY_CHAR_SET ast_char_set; 00478 00479 switch (pri_char_set) { 00480 default: 00481 case PRI_CHAR_SET_UNKNOWN: 00482 ast_char_set = AST_PARTY_CHAR_SET_UNKNOWN; 00483 break; 00484 case PRI_CHAR_SET_ISO8859_1: 00485 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_1; 00486 break; 00487 case PRI_CHAR_SET_WITHDRAWN: 00488 ast_char_set = AST_PARTY_CHAR_SET_WITHDRAWN; 00489 break; 00490 case PRI_CHAR_SET_ISO8859_2: 00491 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_2; 00492 break; 00493 case PRI_CHAR_SET_ISO8859_3: 00494 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_3; 00495 break; 00496 case PRI_CHAR_SET_ISO8859_4: 00497 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_4; 00498 break; 00499 case PRI_CHAR_SET_ISO8859_5: 00500 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_5; 00501 break; 00502 case PRI_CHAR_SET_ISO8859_7: 00503 ast_char_set = AST_PARTY_CHAR_SET_ISO8859_7; 00504 break; 00505 case PRI_CHAR_SET_ISO10646_BMPSTRING: 00506 ast_char_set = AST_PARTY_CHAR_SET_ISO10646_BMPSTRING; 00507 break; 00508 case PRI_CHAR_SET_ISO10646_UTF_8STRING: 00509 ast_char_set = AST_PARTY_CHAR_SET_ISO10646_UTF_8STRING; 00510 break; 00511 } 00512 00513 return ast_char_set; 00514 }
| static int pri_to_ast_presentation | ( | int | pri_presentation | ) | [static] |
Definition at line 377 of file sig_pri.c.
References AST_PRES_ALLOWED_NETWORK_NUMBER, AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, AST_PRES_NUMBER_NOT_AVAILABLE, AST_PRES_PROHIB_NETWORK_NUMBER, AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED, and AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN.
Referenced by sig_pri_party_name_convert(), and sig_pri_party_number_convert().
00378 { 00379 int ast_presentation; 00380 00381 switch (pri_presentation) { 00382 case PRES_ALLOWED_USER_NUMBER_NOT_SCREENED: 00383 ast_presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 00384 break; 00385 case PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN: 00386 ast_presentation = AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN; 00387 break; 00388 case PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN: 00389 ast_presentation = AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN; 00390 break; 00391 case PRES_ALLOWED_NETWORK_NUMBER: 00392 ast_presentation = AST_PRES_ALLOWED_NETWORK_NUMBER; 00393 break; 00394 case PRES_PROHIB_USER_NUMBER_NOT_SCREENED: 00395 ast_presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED; 00396 break; 00397 case PRES_PROHIB_USER_NUMBER_PASSED_SCREEN: 00398 ast_presentation = AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN; 00399 break; 00400 case PRES_PROHIB_USER_NUMBER_FAILED_SCREEN: 00401 ast_presentation = AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN; 00402 break; 00403 case PRES_PROHIB_NETWORK_NUMBER: 00404 ast_presentation = AST_PRES_PROHIB_NETWORK_NUMBER; 00405 break; 00406 case PRES_NUMBER_NOT_AVAILABLE: 00407 ast_presentation = AST_PRES_NUMBER_NOT_AVAILABLE; 00408 break; 00409 default: 00410 ast_presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED; 00411 break; 00412 } 00413 00414 return ast_presentation; 00415 }
| static enum AST_REDIRECTING_REASON pri_to_ast_reason | ( | int | pri_reason | ) | [static] |
Definition at line 307 of file sig_pri.c.
References AST_REDIRECTING_REASON_DEFLECTION, AST_REDIRECTING_REASON_NO_ANSWER, AST_REDIRECTING_REASON_UNCONDITIONAL, AST_REDIRECTING_REASON_UNKNOWN, and AST_REDIRECTING_REASON_USER_BUSY.
Referenced by sig_pri_redirecting_convert().
00308 { 00309 enum AST_REDIRECTING_REASON ast_reason; 00310 00311 switch (pri_reason) { 00312 case PRI_REDIR_FORWARD_ON_BUSY: 00313 ast_reason = AST_REDIRECTING_REASON_USER_BUSY; 00314 break; 00315 case PRI_REDIR_FORWARD_ON_NO_REPLY: 00316 ast_reason = AST_REDIRECTING_REASON_NO_ANSWER; 00317 break; 00318 case PRI_REDIR_DEFLECTION: 00319 ast_reason = AST_REDIRECTING_REASON_DEFLECTION; 00320 break; 00321 case PRI_REDIR_UNCONDITIONAL: 00322 ast_reason = AST_REDIRECTING_REASON_UNCONDITIONAL; 00323 break; 00324 case PRI_REDIR_UNKNOWN: 00325 default: 00326 ast_reason = AST_REDIRECTING_REASON_UNKNOWN; 00327 break; 00328 } 00329 00330 return ast_reason; 00331 }
| static unsigned int PVT_TO_CHANNEL | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 117 of file sig_pri.c.
References ast_debug, sig_pri_chan::logicalspan, sig_pri_chan::mastertrunkgroup, PRI_EXPLICIT, and sig_pri_chan::prioffset.
Referenced by pri_check_restart(), pri_dchannel(), pri_maintenance_bservice(), pri_ss_thread(), sig_pri_call(), sig_pri_handle_retrieve(), and sig_pri_indicate().
00118 { 00119 int res = (((p)->prioffset) | ((p)->logicalspan << 8) | (p->mastertrunkgroup ? PRI_EXPLICIT : 0)); 00120 ast_debug(5, "prioffset: %d mastertrunkgroup: %d logicalspan: %d result: %d\n", 00121 p->prioffset, p->mastertrunkgroup, p->logicalspan, res); 00122 00123 return res; 00124 }
| static char* redirectingreason2str | ( | int | redirectingreason | ) | [static] |
Definition at line 1250 of file sig_pri.c.
Referenced by pri_dchannel().
01251 { 01252 switch (redirectingreason) { 01253 case 0: 01254 return "UNKNOWN"; 01255 case 1: 01256 return "BUSY"; 01257 case 2: 01258 return "NO_REPLY"; 01259 case 0xF: 01260 return "UNCONDITIONAL"; 01261 default: 01262 return "NOREDIRECT"; 01263 } 01264 }
| 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 }
| static int sig_pri_attempt_transfer | ( | struct sig_pri_span * | pri, | |
| q931_call * | call_1, | |||
| int | call_1_held, | |||
| q931_call * | call_2, | |||
| int | call_2_held | |||
| ) | [static] |
Definition at line 1902 of file sig_pri.c.
References ast_bridged_channel(), ast_channel_masquerade(), ast_channel_unlock, AST_CONTROL_HOLD, AST_CONTROL_UNHOLD, ast_queue_control(), ast_verb, ast_channel::name, sig_pri_chan::owner, pri_find_pri_call(), sig_pri_span::pvts, sig_pri_lock_owner(), sig_pri_lock_private(), and sig_pri_unlock_private().
Referenced by pri_dchannel(), and sig_pri_handle_subcmds().
01903 { 01904 int retval; 01905 int call_1_chanpos; 01906 int call_2_chanpos; 01907 struct ast_channel *call_1_ast; 01908 struct ast_channel *call_2_ast; 01909 struct ast_channel *bridged; 01910 01911 call_1_chanpos = pri_find_pri_call(pri, call_1); 01912 call_2_chanpos = pri_find_pri_call(pri, call_2); 01913 if (call_1_chanpos < 0 || call_2_chanpos < 0) { 01914 return -1; 01915 } 01916 01917 /* Deadlock avoidance is attempted. */ 01918 sig_pri_lock_private(pri->pvts[call_1_chanpos]); 01919 sig_pri_lock_owner(pri, call_1_chanpos); 01920 sig_pri_lock_private(pri->pvts[call_2_chanpos]); 01921 sig_pri_lock_owner(pri, call_2_chanpos); 01922 01923 call_1_ast = pri->pvts[call_1_chanpos]->owner; 01924 call_2_ast = pri->pvts[call_2_chanpos]->owner; 01925 if (!call_1_ast || !call_2_ast) { 01926 if (call_1_ast) { 01927 ast_channel_unlock(call_1_ast); 01928 } 01929 if (call_2_ast) { 01930 ast_channel_unlock(call_2_ast); 01931 } 01932 sig_pri_unlock_private(pri->pvts[call_1_chanpos]); 01933 sig_pri_unlock_private(pri->pvts[call_2_chanpos]); 01934 return -1; 01935 } 01936 01937 bridged = ast_bridged_channel(call_2_ast); 01938 if (bridged) { 01939 if (call_1_held) { 01940 ast_queue_control(call_1_ast, AST_CONTROL_UNHOLD); 01941 } 01942 if (call_2_held) { 01943 ast_queue_control(call_2_ast, AST_CONTROL_UNHOLD); 01944 } 01945 01946 ast_verb(3, "TRANSFERRING %s to %s\n", call_2_ast->name, call_1_ast->name); 01947 retval = ast_channel_masquerade(call_1_ast, bridged); 01948 } else { 01949 /* Try masquerading the other way. */ 01950 bridged = ast_bridged_channel(call_1_ast); 01951 if (bridged) { 01952 if (call_1_held) { 01953 ast_queue_control(call_1_ast, AST_CONTROL_UNHOLD); 01954 } 01955 if (call_2_held) { 01956 ast_queue_control(call_2_ast, AST_CONTROL_UNHOLD); 01957 } 01958 01959 ast_verb(3, "TRANSFERRING %s to %s\n", call_1_ast->name, call_2_ast->name); 01960 retval = ast_channel_masquerade(call_2_ast, bridged); 01961 } else { 01962 /* Could not transfer. */ 01963 retval = -1; 01964 } 01965 } 01966 if (bridged && retval) { 01967 /* Restore HOLD on held calls because masquerade failed. */ 01968 if (call_1_held) { 01969 ast_queue_control(call_1_ast, AST_CONTROL_HOLD); 01970 } 01971 if (call_2_held) { 01972 ast_queue_control(call_2_ast, AST_CONTROL_HOLD); 01973 } 01974 } 01975 01976 ast_channel_unlock(call_1_ast); 01977 ast_channel_unlock(call_2_ast); 01978 sig_pri_unlock_private(pri->pvts[call_1_chanpos]); 01979 sig_pri_unlock_private(pri->pvts[call_2_chanpos]); 01980 01981 return retval; 01982 }
| 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 }
| static int sig_pri_available_check | ( | struct sig_pri_chan * | pvt | ) | [static] |
Definition at line 6541 of file sig_pri.c.
References sig_pri_chan::call, sig_pri_chan::inalarm, sig_pri_chan::no_b_channel, sig_pri_chan::owner, sig_pri_chan::resetting, and sig_pri_chan::service_status.
Referenced by sig_pri_available().
06542 { 06543 /* 06544 * If no owner, interface has a B channel, not resetting, not already with call, 06545 * not in alarm, and in-service then available. 06546 */ 06547 if (!pvt->owner && !pvt->no_b_channel && !pvt->resetting && !pvt->call 06548 && !pvt->inalarm) { 06549 #if defined(HAVE_PRI_SERVICE_MESSAGES) 06550 if (pvt->service_status) { 06551 return 0; 06552 } 06553 #endif /* defined(HAVE_PRI_SERVICE_MESSAGES) */ 06554 return 1; 06555 } 06556 return 0; 06557 }
| 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 }
| static void sig_pri_cc_generic_check | ( | struct sig_pri_span * | pri, | |
| int | chanpos, | |||
| enum ast_cc_service_type | service | |||
| ) | [static] |
Definition at line 2246 of file sig_pri.c.
References ao2_ref, AST_CC_GENERIC_MONITOR_TYPE, ast_cc_get_current_core_id(), ast_cc_get_monitor_by_recall_core_id(), AST_CC_MONITOR_ALWAYS, AST_CC_MONITOR_GENERIC, AST_CC_MONITOR_NATIVE, AST_CC_MONITOR_NEVER, ast_channel_get_cc_config_params(), ast_channel_get_device_name(), AST_CHANNEL_NAME, ast_channel_unlock, ast_get_cc_monitor_policy(), ast_queue_cc_frame(), sig_pri_span::nodetype, sig_pri_chan::outgoing, sig_pri_chan::owner, sig_pri_span::pvts, sig_pri_span::sig, SIG_BRI_PTMP, sig_pri_get_orig_dialstring(), and sig_pri_lock_owner().
Referenced by pri_dchannel().
02247 { 02248 struct ast_channel *owner; 02249 struct ast_cc_config_params *cc_params; 02250 #if defined(HAVE_PRI_CCSS) 02251 struct ast_cc_monitor *monitor; 02252 char device_name[AST_CHANNEL_NAME]; 02253 #endif /* defined(HAVE_PRI_CCSS) */ 02254 enum ast_cc_monitor_policies monitor_policy; 02255 int core_id; 02256 02257 if (!pri->pvts[chanpos]->outgoing) { 02258 /* This is not an outgoing call so it cannot be CC monitor. */ 02259 return; 02260 } 02261 02262 sig_pri_lock_owner(pri, chanpos); 02263 owner = pri->pvts[chanpos]->owner; 02264 if (!owner) { 02265 return; 02266 } 02267 core_id = ast_cc_get_current_core_id(owner); 02268 if (core_id == -1) { 02269 /* No CC core setup */ 02270 goto done; 02271 } 02272 02273 cc_params = ast_channel_get_cc_config_params(owner); 02274 if (!cc_params) { 02275 /* Could not get CC config parameters. */ 02276 goto done; 02277 } 02278 02279 #if defined(HAVE_PRI_CCSS) 02280 ast_channel_get_device_name(owner, device_name, sizeof(device_name)); 02281 monitor = ast_cc_get_monitor_by_recall_core_id(core_id, device_name); 02282 if (monitor) { 02283 /* CC monitor is already present so no need for generic CC. */ 02284 ao2_ref(monitor, -1); 02285 goto done; 02286 } 02287 #endif /* defined(HAVE_PRI_CCSS) */ 02288 02289 monitor_policy = ast_get_cc_monitor_policy(cc_params); 02290 switch (monitor_policy) { 02291 case AST_CC_MONITOR_NEVER: 02292 /* CCSS is not enabled. */ 02293 break; 02294 case AST_CC_MONITOR_NATIVE: 02295 if (pri->sig == SIG_BRI_PTMP && pri->nodetype == PRI_NETWORK) { 02296 /* Request generic CC monitor. */ 02297 ast_queue_cc_frame(owner, AST_CC_GENERIC_MONITOR_TYPE, 02298 sig_pri_get_orig_dialstring(pri->pvts[chanpos]), service, NULL); 02299 } 02300 break; 02301 case AST_CC_MONITOR_ALWAYS: 02302 if (pri->sig == SIG_BRI_PTMP && pri->nodetype != PRI_NETWORK) { 02303 /* 02304 * Cannot monitor PTMP TE side since this is not defined. 02305 * We are playing the roll of a phone in this case and 02306 * a phone cannot monitor a party over the network without 02307 * protocol help. 02308 */ 02309 break; 02310 } 02311 /* 02312 * We are either falling back or this is a PTMP NT span. 02313 * Request generic CC monitor. 02314 */ 02315 ast_queue_cc_frame(owner, AST_CC_GENERIC_MONITOR_TYPE, 02316 sig_pri_get_orig_dialstring(pri->pvts[chanpos]), service, NULL); 02317 break; 02318 case AST_CC_MONITOR_GENERIC: 02319 if (pri->sig == SIG_BRI_PTMP && pri->nodetype == PRI_NETWORK) { 02320 /* Request generic CC monitor. */ 02321 ast_queue_cc_frame(owner, AST_CC_GENERIC_MONITOR_TYPE, 02322 sig_pri_get_orig_dialstring(pri->pvts[chanpos]), service, NULL); 02323 } 02324 break; 02325 } 02326 02327 done: 02328 ast_channel_unlock(owner); 02329 }
| 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 }
| static int sig_pri_cmp_pri_chans | ( | const void * | left, | |
| const void * | right | |||
| ) | [static] |
Definition at line 6804 of file sig_pri.c.
References sig_pri_chan::channel.
Referenced by sig_pri_sort_pri_chans().
06805 { 06806 const struct sig_pri_chan *pvt_left; 06807 const struct sig_pri_chan *pvt_right; 06808 06809 pvt_left = *(struct sig_pri_chan **) left; 06810 pvt_right = *(struct sig_pri_chan **) right; 06811 if (!pvt_left) { 06812 if (!pvt_right) { 06813 return 0; 06814 } 06815 return 1; 06816 } 06817 if (!pvt_right) { 06818 return -1; 06819 } 06820 06821 return pvt_left->channel - pvt_right->channel; 06822 }
| 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 }
| static void sig_pri_dsp_reset_and_flush_digits | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 835 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::dsp_reset_and_flush_digits.
Referenced by pri_ss_thread().
00836 { 00837 if (p->calls->dsp_reset_and_flush_digits) { 00838 p->calls->dsp_reset_and_flush_digits(p->chan_pvt); 00839 } 00840 }
| 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().
| static void sig_pri_fixup_chans | ( | struct sig_pri_chan * | old_chan, | |
| struct sig_pri_chan * | new_chan | |||
| ) | [static] |
Definition at line 850 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::fixup_chans.
Referenced by pri_fixup_principle().
00851 { 00852 if (old_chan->calls->fixup_chans) 00853 old_chan->calls->fixup_chans(old_chan->chan_pvt, new_chan->chan_pvt); 00854 }
| static const char* sig_pri_get_orig_dialstring | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 155 of file sig_pri.c.
References ast_log(), sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_callback::get_orig_dialstring, and LOG_ERROR.
Referenced by sig_pri_cc_generic_check().
00156 { 00157 if (p->calls->get_orig_dialstring) { 00158 return p->calls->get_orig_dialstring(p->chan_pvt); 00159 } 00160 ast_log(LOG_ERROR, "get_orig_dialstring callback not defined\n"); 00161 return ""; 00162 }
| 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] |
Definition at line 3345 of file sig_pri.c.
References ao2_ref, ast_cc_agent_accept_request(), ast_cc_agent_caller_available(), ast_cc_agent_caller_busy(), ast_cc_agent_status_response(), ast_cc_failed(), ast_cc_monitor_callee_available(), ast_cc_monitor_failed(), ast_cc_monitor_party_b_free(), ast_cc_monitor_request_acked(), ast_cc_monitor_status_request(), ast_cc_monitor_stop_ringing(), ast_cc_request_is_within_limits(), ast_debug, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, ast_verb, ast_cc_agent::core_id, sig_pri_span::pri, ast_cc_agent::private_data, and sig_pri_span::span.
Referenced by pri_dchannel().
03347 { 03348 int index; 03349 #if defined(HAVE_PRI_CCSS) 03350 struct ast_cc_agent *agent; 03351 struct sig_pri_cc_agent_prv *agent_prv; 03352 struct sig_pri_cc_monitor_instance *monitor; 03353 #endif /* defined(HAVE_PRI_CCSS) */ 03354 03355 if (!subcmds) { 03356 return; 03357 } 03358 for (index = 0; index < subcmds->counter_subcmd; ++index) { 03359 const struct pri_subcommand *subcmd = &subcmds->subcmd[index]; 03360 03361 switch (subcmd->cmd) { 03362 #if defined(STATUS_REQUEST_PLACE_HOLDER) 03363 case PRI_SUBCMD_STATUS_REQ: 03364 case PRI_SUBCMD_STATUS_REQ_RSP: 03365 /* Ignore for now. */ 03366 break; 03367 #endif /* defined(STATUS_REQUEST_PLACE_HOLDER) */ 03368 #if defined(HAVE_PRI_CCSS) 03369 case PRI_SUBCMD_CC_REQ: 03370 agent = sig_pri_find_cc_agent_by_cc_id(pri, subcmd->u.cc_request.cc_id); 03371 if (!agent) { 03372 pri_cc_cancel(pri->pri, subcmd->u.cc_request.cc_id); 03373 break; 03374 } 03375 if (!ast_cc_request_is_within_limits()) { 03376 if (pri_cc_req_rsp(pri->pri, subcmd->u.cc_request.cc_id, 03377 5/* queue_full */)) { 03378 pri_cc_cancel(pri->pri, subcmd->u.cc_request.cc_id); 03379 } 03380 ast_cc_failed(agent->core_id, "%s agent system CC queue full", 03381 sig_pri_cc_type_name); 03382 ao2_ref(agent, -1); 03383 break; 03384 } 03385 agent_prv = agent->private_data; 03386 agent_prv->cc_request_response_pending = 1; 03387 if (ast_cc_agent_accept_request(agent->core_id, 03388 "%s caller accepted CC offer.", sig_pri_cc_type_name)) { 03389 agent_prv->cc_request_response_pending = 0; 03390 if (pri_cc_req_rsp(pri->pri, subcmd->u.cc_request.cc_id, 03391 2/* short_term_denial */)) { 03392 pri_cc_cancel(pri->pri, subcmd->u.cc_request.cc_id); 03393 } 03394 ast_cc_failed(agent->core_id, "%s agent CC core request accept failed", 03395 sig_pri_cc_type_name); 03396 } 03397 ao2_ref(agent, -1); 03398 break; 03399 #endif /* defined(HAVE_PRI_CCSS) */ 03400 #if defined(HAVE_PRI_CCSS) 03401 case PRI_SUBCMD_CC_REQ_RSP: 03402 monitor = sig_pri_find_cc_monitor_by_cc_id(pri, 03403 subcmd->u.cc_request_rsp.cc_id); 03404 if (!monitor) { 03405 pri_cc_cancel(pri->pri, subcmd->u.cc_request_rsp.cc_id); 03406 break; 03407 } 03408 switch (subcmd->u.cc_request_rsp.status) { 03409 case 0:/* success */ 03410 ast_cc_monitor_request_acked(monitor->core_id, 03411 "%s far end accepted CC request", sig_pri_cc_type_name); 03412 break; 03413 case 1:/* timeout */ 03414 ast_verb(2, "core_id:%d %s CC request timeout\n", monitor->core_id, 03415 sig_pri_cc_type_name); 03416 ast_cc_monitor_failed(monitor->core_id, monitor->name, 03417 "%s CC request timeout", sig_pri_cc_type_name); 03418 break; 03419 case 2:/* error */ 03420 ast_verb(2, "core_id:%d %s CC request error: %s\n", monitor->core_id, 03421 sig_pri_cc_type_name, 03422 pri_facility_error2str(subcmd->u.cc_request_rsp.fail_code)); 03423 ast_cc_monitor_failed(monitor->core_id, monitor->name, 03424 "%s CC request error", sig_pri_cc_type_name); 03425 break; 03426 case 3:/* reject */ 03427 ast_verb(2, "core_id:%d %s CC request reject: %s\n", monitor->core_id, 03428 sig_pri_cc_type_name, 03429 pri_facility_reject2str(subcmd->u.cc_request_rsp.fail_code)); 03430 ast_cc_monitor_failed(monitor->core_id, monitor->name, 03431 "%s CC request reject", sig_pri_cc_type_name); 03432 break; 03433 default: 03434 ast_verb(2, "core_id:%d %s CC request unknown status %d\n", 03435 monitor->core_id, sig_pri_cc_type_name, 03436 subcmd->u.cc_request_rsp.status); 03437 ast_cc_monitor_failed(monitor->core_id, monitor->name, 03438 "%s CC request unknown status", sig_pri_cc_type_name); 03439 break; 03440 } 03441 ao2_ref(monitor, -1); 03442 break; 03443 #endif /* defined(HAVE_PRI_CCSS) */ 03444 #if defined(HAVE_PRI_CCSS) 03445 case PRI_SUBCMD_CC_REMOTE_USER_FREE: 03446 monitor = sig_pri_find_cc_monitor_by_cc_id(pri, 03447 subcmd->u.cc_remote_user_free.cc_id); 03448 if (!monitor) { 03449 pri_cc_cancel(pri->pri, subcmd->u.cc_remote_user_free.cc_id); 03450 break; 03451 } 03452 ast_cc_monitor_callee_available(monitor->core_id, 03453 "%s callee has become available", sig_pri_cc_type_name); 03454 ao2_ref(monitor, -1); 03455 break; 03456 #endif /* defined(HAVE_PRI_CCSS) */ 03457 #if defined(HAVE_PRI_CCSS) 03458 case PRI_SUBCMD_CC_B_FREE: 03459 monitor = sig_pri_find_cc_monitor_by_cc_id(pri, 03460 subcmd->u.cc_b_free.cc_id); 03461 if (!monitor) { 03462 pri_cc_cancel(pri->pri, subcmd->u.cc_b_free.cc_id); 03463 break; 03464 } 03465 ast_cc_monitor_party_b_free(monitor->core_id); 03466 ao2_ref(monitor, -1); 03467 break; 03468 #endif /* defined(HAVE_PRI_CCSS) */ 03469 #if defined(HAVE_PRI_CCSS) 03470 case PRI_SUBCMD_CC_STATUS_REQ: 03471 monitor = sig_pri_find_cc_monitor_by_cc_id(pri, 03472 subcmd->u.cc_status_req.cc_id); 03473 if (!monitor) { 03474 pri_cc_cancel(pri->pri, subcmd->u.cc_status_req.cc_id); 03475 break; 03476 } 03477 ast_cc_monitor_status_request(monitor->core_id); 03478 ao2_ref(monitor, -1); 03479 break; 03480 #endif /* defined(HAVE_PRI_CCSS) */ 03481 #if defined(HAVE_PRI_CCSS) 03482 case PRI_SUBCMD_CC_STATUS_REQ_RSP: 03483 agent = sig_pri_find_cc_agent_by_cc_id(pri, subcmd->u.cc_status_req_rsp.cc_id); 03484 if (!agent) { 03485 pri_cc_cancel(pri->pri, subcmd->u.cc_status_req_rsp.cc_id); 03486 break; 03487 } 03488 ast_cc_agent_status_response(agent->core_id, 03489 subcmd->u.cc_status_req_rsp.status ? AST_DEVICE_INUSE 03490 : AST_DEVICE_NOT_INUSE); 03491 ao2_ref(agent, -1); 03492 break; 03493 #endif /* defined(HAVE_PRI_CCSS) */ 03494 #if defined(HAVE_PRI_CCSS) 03495 case PRI_SUBCMD_CC_STATUS: 03496 agent = sig_pri_find_cc_agent_by_cc_id(pri, subcmd->u.cc_status.cc_id); 03497 if (!agent) { 03498 pri_cc_cancel(pri->pri, subcmd->u.cc_status.cc_id); 03499 break; 03500 } 03501 if (subcmd->u.cc_status.status) { 03502 ast_cc_agent_caller_busy(agent->core_id, "%s agent caller is busy", 03503 sig_pri_cc_type_name); 03504 } else { 03505 ast_cc_agent_caller_available(agent->core_id, 03506 "%s agent caller is available", sig_pri_cc_type_name); 03507 } 03508 ao2_ref(agent, -1); 03509 break; 03510 #endif /* defined(HAVE_PRI_CCSS) */ 03511 #if defined(HAVE_PRI_CCSS) 03512 case PRI_SUBCMD_CC_CANCEL: 03513 sig_pri_cc_link_canceled(pri, subcmd->u.cc_cancel.cc_id, 03514 subcmd->u.cc_cancel.is_agent); 03515 break; 03516 #endif /* defined(HAVE_PRI_CCSS) */ 03517 #if defined(HAVE_PRI_CCSS) 03518 case PRI_SUBCMD_CC_STOP_ALERTING: 03519 monitor = sig_pri_find_cc_monitor_by_cc_id(pri, 03520 subcmd->u.cc_stop_alerting.cc_id); 03521 if (!monitor) { 03522 pri_cc_cancel(pri->pri, subcmd->u.cc_stop_alerting.cc_id); 03523 break; 03524 } 03525 ast_cc_monitor_stop_ringing(monitor->core_id); 03526 ao2_ref(monitor, -1); 03527 break; 03528 #endif /* defined(HAVE_PRI_CCSS) */ 03529 #if defined(HAVE_PRI_AOC_EVENTS) 03530 case PRI_SUBCMD_AOC_E: 03531 /* Queue AST_CONTROL_AOC frame */ 03532 sig_pri_aoc_e_from_pri(&subcmd->u.aoc_e, NULL, 0); 03533 break; 03534 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03535 default: 03536 ast_debug(2, 03537 "Unknown CIS subcommand(%d) in %s event on span %d.\n", 03538 subcmd->cmd, pri_event2str(event_id), pri->span); 03539 break; 03540 } 03541 } 03542 }
| static void sig_pri_handle_dchan_exception | ( | struct sig_pri_span * | pri, | |
| int | index | |||
| ) | [static] |
Definition at line 126 of file sig_pri.c.
References sig_pri_span::calls, and sig_pri_callback::handle_dchan_exception.
Referenced by pri_dchannel().
00127 { 00128 if (pri->calls->handle_dchan_exception) 00129 pri->calls->handle_dchan_exception(pri, index); 00130 }
| static int sig_pri_handle_hold | ( | struct sig_pri_span * | pri, | |
| pri_event * | ev | |||
| ) | [static] |
Definition at line 3936 of file sig_pri.c.
References ast_bridged_channel(), ast_channel_unlock, AST_CONTROL_HOLD, AST_FRAME_CONTROL, ast_log(), ast_queue_frame(), ast_frame_subclass::integer, LOG_WARNING, sig_pri_chan::no_b_channel, sig_pri_chan::owner, PRI_CHANNEL, pri_find_empty_nobch(), pri_find_principle(), pri_fixup_principle(), PRI_SPAN, sig_pri_span::pvts, sig_pri_handle_subcmds(), sig_pri_lock_owner(), sig_pri_lock_private(), sig_pri_span_devstate_changed(), sig_pri_unlock_private(), sig_pri_span::span, and ast_frame::subclass.
Referenced by pri_dchannel().
03937 { 03938 int retval; 03939 int chanpos_old; 03940 int chanpos_new; 03941 struct ast_channel *bridged; 03942 struct ast_channel *owner; 03943 03944 chanpos_old = pri_find_principle(pri, ev->hold.channel, ev->hold.call); 03945 if (chanpos_old < 0) { 03946 ast_log(LOG_WARNING, 03947 "Received HOLD on unconfigured channel %d/%d span %d\n", 03948 PRI_SPAN(ev->hold.channel), PRI_CHANNEL(ev->hold.channel), pri->span); 03949 return -1; 03950 } 03951 if (pri->pvts[chanpos_old]->no_b_channel) { 03952 /* Call is already on hold or is call waiting call. */ 03953 return -1; 03954 } 03955 03956 sig_pri_lock_private(pri->pvts[chanpos_old]); 03957 sig_pri_lock_owner(pri, chanpos_old); 03958 owner = pri->pvts[chanpos_old]->owner; 03959 if (!owner) { 03960 retval = -1; 03961 goto done_with_private; 03962 } 03963 bridged = ast_bridged_channel(owner); 03964 if (!bridged) { 03965 /* Cannot hold a call that is not bridged. */ 03966 retval = -1; 03967 goto done_with_owner; 03968 } 03969 chanpos_new = pri_find_empty_nobch(pri); 03970 if (chanpos_new < 0) { 03971 /* No hold channel available. */ 03972 retval = -1; 03973 goto done_with_owner; 03974 } 03975 sig_pri_handle_subcmds(pri, chanpos_old, ev->e, ev->hold.channel, ev->hold.subcmds, 03976 ev->hold.call); 03977 chanpos_new = pri_fixup_principle(pri, chanpos_new, ev->hold.call); 03978 if (chanpos_new < 0) { 03979 /* Should never happen. */ 03980 retval = -1; 03981 } else { 03982 struct ast_frame f = { AST_FRAME_CONTROL, }; 03983 03984 /* 03985 * Things are in an odd state here so we cannot use pri_queue_control(). 03986 * However, we already have the owner lock so we can simply queue the frame. 03987 */ 03988 f.subclass.integer = AST_CONTROL_HOLD; 03989 ast_queue_frame(owner, &f); 03990 03991 sig_pri_span_devstate_changed(pri); 03992 retval = 0; 03993 } 03994 03995 done_with_owner:; 03996 ast_channel_unlock(owner); 03997 done_with_private:; 03998 sig_pri_unlock_private(pri->pvts[chanpos_old]); 03999 04000 return retval; 04001 }
| static void sig_pri_handle_retrieve | ( | struct sig_pri_span * | pri, | |
| pri_event * | ev | |||
| ) | [static] |
Definition at line 4017 of file sig_pri.c.
References AST_CONTROL_UNHOLD, sig_pri_span::pri, PRI_CHANNEL, pri_find_empty_chan(), pri_find_principle(), pri_fixup_principle(), PRI_HELD_CALL, pri_queue_control(), PVT_TO_CHANNEL(), sig_pri_span::pvts, pvts, sig_pri_handle_subcmds(), sig_pri_lock_private(), sig_pri_span_devstate_changed(), and sig_pri_unlock_private().
Referenced by pri_dchannel().
04018 { 04019 int chanpos; 04020 04021 if (!(ev->retrieve.channel & PRI_HELD_CALL) 04022 || pri_find_principle(pri, ev->retrieve.channel, ev->retrieve.call) < 0) { 04023 /* The call is not currently held. */ 04024 pri_retrieve_rej(pri->pri, ev->retrieve.call, 04025 PRI_CAUSE_RESOURCE_UNAVAIL_UNSPECIFIED); 04026 return; 04027 } 04028 if (PRI_CHANNEL(ev->retrieve.channel) == 0xFF) { 04029 chanpos = pri_find_empty_chan(pri, 1); 04030 } else { 04031 chanpos = pri_find_principle(pri, 04032 ev->retrieve.channel & ~PRI_HELD_CALL, ev->retrieve.call); 04033 if (ev->retrieve.flexible 04034 && (chanpos < 0 || pri->pvts[chanpos]->owner)) { 04035 /* 04036 * Channel selection is flexible and the requested channel 04037 * is bad or already in use. Pick another channel. 04038 */ 04039 chanpos = pri_find_empty_chan(pri, 1); 04040 } 04041 } 04042 if (chanpos < 0) { 04043 pri_retrieve_rej(pri->pri, ev->retrieve.call, 04044 ev->retrieve.flexible ? PRI_CAUSE_NORMAL_CIRCUIT_CONGESTION 04045 : PRI_CAUSE_REQUESTED_CHAN_UNAVAIL); 04046 return; 04047 } 04048 chanpos = pri_fixup_principle(pri, chanpos, ev->retrieve.call); 04049 if (chanpos < 0) { 04050 /* Channel is already in use. */ 04051 pri_retrieve_rej(pri->pri, ev->retrieve.call, 04052 PRI_CAUSE_REQUESTED_CHAN_UNAVAIL); 04053 return; 04054 } 04055 sig_pri_lock_private(pri->pvts[chanpos]); 04056 sig_pri_handle_subcmds(pri, chanpos, ev->e, ev->retrieve.channel, 04057 ev->retrieve.subcmds, ev->retrieve.call); 04058 pri_queue_control(pri, chanpos, AST_CONTROL_UNHOLD); 04059 sig_pri_unlock_private(pri->pvts[chanpos]); 04060 sig_pri_span_devstate_changed(pri); 04061 pri_retrieve_ack(pri->pri, ev->retrieve.call, 04062 PVT_TO_CHANNEL(pri->pvts[chanpos])); 04063 }
| static void sig_pri_handle_subcmds | ( | struct sig_pri_span * | pri, | |
| int | chanpos, | |||
| int | event_id, | |||
| int | channel, | |||
| const struct pri_subcommands * | subcmds, | |||
| q931_call * | call_rsp | |||
| ) | [static] |
Definition at line 3601 of file sig_pri.c.
References ao2_ref, ast_cc_agent_recalling(), ast_cc_agent_set_interfaces_chanvar(), AST_CC_CCBS, AST_CC_CCNR, AST_CC_NONE, ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), ast_channel_set_redirecting(), ast_channel_unlock, AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER, AST_CONTROL_BUSY, ast_copy_string(), ast_debug, ast_log(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_party_id_presentation(), ast_party_redirecting_free(), ast_party_subaddress_set(), ast_queue_control(), ast_set_callerid(), ast_setup_cc_recall_datastore(), ast_strdup, ast_string_field_set, ast_channel::caller, sig_pri_chan::callingpres, sig_pri_chan::cid_name, sig_pri_chan::cid_num, sig_pri_chan::cid_subaddr, sig_pri_chan::cid_ton, ast_cc_agent::core_id, ast_party_redirecting::from, ast_party_caller::id, ast_party_connected_line::id, LOG_ERROR, LOG_WARNING, ast_party_id::name, ast_party_id::number, sig_pri_chan::owner, ast_party_number::plan, sig_pri_span::pri, PRI_CHANNEL, PRI_SPAN, sig_pri_span::pvts, ast_channel::redirecting, S_OR, SIG_PRI_AOC_GRANT_D, SIG_PRI_AOC_GRANT_E, SIG_PRI_AOC_GRANT_S, sig_pri_attempt_transfer(), sig_pri_lock_owner(), sig_pri_lock_private(), sig_pri_party_id_convert(), sig_pri_redirecting_convert(), sig_pri_set_caller_id(), sig_pri_unlock_private(), ast_party_connected_line::source, sig_pri_span::span, ast_party_subaddress::str, ast_party_number::str, ast_party_name::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_redirecting::to, sig_pri_span::transfer, sig_pri_chan::user_tag, ast_party_subaddress::valid, and ast_party_number::valid.
Referenced by pri_dchannel(), sig_pri_handle_hold(), and sig_pri_handle_retrieve().
03603 { 03604 int index; 03605 struct ast_channel *owner; 03606 struct ast_party_redirecting ast_redirecting; 03607 03608 if (!subcmds) { 03609 return; 03610 } 03611 for (index = 0; index < subcmds->counter_subcmd; ++index) { 03612 const struct pri_subcommand *subcmd = &subcmds->subcmd[index]; 03613 03614 switch (subcmd->cmd) { 03615 case PRI_SUBCMD_CONNECTED_LINE: 03616 sig_pri_lock_owner(pri, chanpos); 03617 owner = pri->pvts[chanpos]->owner; 03618 if (owner) { 03619 struct ast_party_connected_line ast_connected; 03620 int caller_id_update; 03621 03622 /* Extract the connected line information */ 03623 ast_party_connected_line_init(&ast_connected); 03624 sig_pri_party_id_convert(&ast_connected.id, &subcmd->u.connected_line.id, 03625 pri); 03626 ast_connected.id.tag = ast_strdup(pri->pvts[chanpos]->user_tag); 03627 03628 caller_id_update = 0; 03629 if (ast_connected.id.name.str) { 03630 /* Save name for Caller-ID update */ 03631 ast_copy_string(pri->pvts[chanpos]->cid_name, 03632 ast_connected.id.name.str, sizeof(pri->pvts[chanpos]->cid_name)); 03633 caller_id_update = 1; 03634 } 03635 if (ast_connected.id.number.str) { 03636 /* Save number for Caller-ID update */ 03637 ast_copy_string(pri->pvts[chanpos]->cid_num, 03638 ast_connected.id.number.str, sizeof(pri->pvts[chanpos]->cid_num)); 03639 pri->pvts[chanpos]->cid_ton = ast_connected.id.number.plan; 03640 caller_id_update = 1; 03641 } else { 03642 ast_connected.id.number.valid = 1; 03643 ast_connected.id.number.str = ast_strdup(""); 03644 } 03645 ast_connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER; 03646 03647 pri->pvts[chanpos]->cid_subaddr[0] = '\0'; 03648 #if defined(HAVE_PRI_SUBADDR) 03649 if (ast_connected.id.subaddress.valid) { 03650 ast_party_subaddress_set(&owner->caller.id.subaddress, 03651 &ast_connected.id.subaddress); 03652 if (ast_connected.id.subaddress.str) { 03653 ast_copy_string(pri->pvts[chanpos]->cid_subaddr, 03654 ast_connected.id.subaddress.str, 03655 sizeof(pri->pvts[chanpos]->cid_subaddr)); 03656 } 03657 } 03658 #endif /* defined(HAVE_PRI_SUBADDR) */ 03659 if (caller_id_update) { 03660 pri->pvts[chanpos]->callingpres = 03661 ast_party_id_presentation(&ast_connected.id); 03662 sig_pri_set_caller_id(pri->pvts[chanpos]); 03663 ast_set_callerid(owner, S_OR(ast_connected.id.number.str, NULL), 03664 S_OR(ast_connected.id.name.str, NULL), 03665 S_OR(ast_connected.id.number.str, NULL)); 03666 } 03667 03668 /* Update the connected line information on the other channel */ 03669 if (event_id != PRI_EVENT_RING) { 03670 /* This connected_line update was not from a SETUP message. */ 03671 ast_channel_queue_connected_line_update(owner, &ast_connected, NULL); 03672 } 03673 03674 ast_party_connected_line_free(&ast_connected); 03675 ast_channel_unlock(owner); 03676 } 03677 break; 03678 case PRI_SUBCMD_REDIRECTING: 03679 sig_pri_lock_owner(pri, chanpos); 03680 owner = pri->pvts[chanpos]->owner; 03681 if (owner) { 03682 sig_pri_redirecting_convert(&ast_redirecting, &subcmd->u.redirecting, 03683 &owner->redirecting, pri); 03684 ast_redirecting.from.tag = ast_strdup(pri->pvts[chanpos]->user_tag); 03685 ast_redirecting.to.tag = ast_strdup(pri->pvts[chanpos]->user_tag); 03686 03687 /*! \todo XXX Original called data can be put in a channel data store that is inherited. */ 03688 03689 ast_channel_set_redirecting(owner, &ast_redirecting, NULL); 03690 if (event_id != PRI_EVENT_RING) { 03691 /* This redirection was not from a SETUP message. */ 03692 ast_channel_queue_redirecting_update(owner, &ast_redirecting, NULL); 03693 } 03694 ast_party_redirecting_free(&ast_redirecting); 03695 03696 ast_channel_unlock(owner); 03697 } 03698 break; 03699 #if defined(HAVE_PRI_CALL_REROUTING) 03700 case PRI_SUBCMD_REROUTING: 03701 sig_pri_lock_owner(pri, chanpos); 03702 owner = pri->pvts[chanpos]->owner; 03703 if (owner) { 03704 struct pri_party_redirecting pri_deflection; 03705 03706 if (!call_rsp) { 03707 ast_channel_unlock(owner); 03708 ast_log(LOG_WARNING, 03709 "CallRerouting/CallDeflection to '%s' without call!\n", 03710 subcmd->u.rerouting.deflection.to.number.str); 03711 break; 03712 } 03713 03714 pri_deflection = subcmd->u.rerouting.deflection; 03715 03716 ast_string_field_set(owner, call_forward, pri_deflection.to.number.str); 03717 03718 /* Adjust the deflecting to number based upon the subscription option. */ 03719 switch (subcmd->u.rerouting.subscription_option) { 03720 case 0: /* noNotification */ 03721 case 1: /* notificationWithoutDivertedToNr */ 03722 /* Delete the number because the far end is not supposed to see it. */ 03723 pri_deflection.to.number.presentation = 03724 PRI_PRES_RESTRICTED | PRI_PRES_USER_NUMBER_UNSCREENED; 03725 pri_deflection.to.number.plan = 03726 (PRI_TON_UNKNOWN << 4) | PRI_NPI_E163_E164; 03727 pri_deflection.to.number.str[0] = '\0'; 03728 break; 03729 case 2: /* notificationWithDivertedToNr */ 03730 break; 03731 case 3: /* notApplicable */ 03732 default: 03733 break; 03734 } 03735 sig_pri_redirecting_convert(&ast_redirecting, &pri_deflection, 03736 &owner->redirecting, pri); 03737 ast_redirecting.from.tag = ast_strdup(pri->pvts[chanpos]->user_tag); 03738 ast_redirecting.to.tag = ast_strdup(pri->pvts[chanpos]->user_tag); 03739 ast_channel_set_redirecting(owner, &ast_redirecting, NULL); 03740 ast_party_redirecting_free(&ast_redirecting); 03741 03742 /* 03743 * Send back positive ACK to CallRerouting/CallDeflection. 03744 * 03745 * Note: This call will be hungup by the dial application when 03746 * it processes the call_forward string set above. 03747 */ 03748 pri_rerouting_rsp(pri->pri, call_rsp, subcmd->u.rerouting.invoke_id, 03749 PRI_REROUTING_RSP_OK_CLEAR); 03750 03751 /* This line is BUSY to further attempts by this dialing attempt. */ 03752 ast_queue_control(owner, AST_CONTROL_BUSY); 03753 03754 ast_channel_unlock(owner); 03755 } 03756 break; 03757 #endif /* defined(HAVE_PRI_CALL_REROUTING) */ 03758 #if defined(HAVE_PRI_CCSS) 03759 case PRI_SUBCMD_CC_AVAILABLE: 03760 sig_pri_lock_owner(pri, chanpos); 03761 owner = pri->pvts[chanpos]->owner; 03762 if (owner) { 03763 enum ast_cc_service_type service; 03764 03765 switch (event_id) { 03766 case PRI_EVENT_RINGING: 03767 service = AST_CC_CCNR; 03768 break; 03769 case PRI_EVENT_HANGUP_REQ: 03770 /* We will assume that the cause was busy/congestion. */ 03771 service = AST_CC_CCBS; 03772 break; 03773 default: 03774 service = AST_CC_NONE; 03775 break; 03776 } 03777 if (service == AST_CC_NONE 03778 || sig_pri_cc_available(pri, chanpos, subcmd->u.cc_available.cc_id, 03779 service)) { 03780 pri_cc_cancel(pri->pri, subcmd->u.cc_available.cc_id); 03781 } 03782 ast_channel_unlock(owner); 03783 } else { 03784 /* No asterisk channel. */ 03785 pri_cc_cancel(pri->pri, subcmd->u.cc_available.cc_id); 03786 } 03787 break; 03788 #endif /* defined(HAVE_PRI_CCSS) */ 03789 #if defined(HAVE_PRI_CCSS) 03790 case PRI_SUBCMD_CC_CALL: 03791 sig_pri_lock_owner(pri, chanpos); 03792 owner = pri->pvts[chanpos]->owner; 03793 if (owner) { 03794 struct ast_cc_agent *agent; 03795 03796 agent = sig_pri_find_cc_agent_by_cc_id(pri, subcmd->u.cc_call.cc_id); 03797 if (agent) { 03798 ast_setup_cc_recall_datastore(owner, agent->core_id); 03799 ast_cc_agent_set_interfaces_chanvar(owner); 03800 ast_cc_agent_recalling(agent->core_id, 03801 "%s caller is attempting recall", sig_pri_cc_type_name); 03802 ao2_ref(agent, -1); 03803 } 03804 03805 ast_channel_unlock(owner); 03806 } 03807 break; 03808 #endif /* defined(HAVE_PRI_CCSS) */ 03809 #if defined(HAVE_PRI_CCSS) 03810 case PRI_SUBCMD_CC_CANCEL: 03811 sig_pri_cc_link_canceled(pri, subcmd->u.cc_cancel.cc_id, 03812 subcmd->u.cc_cancel.is_agent); 03813 break; 03814 #endif /* defined(HAVE_PRI_CCSS) */ 03815 #if defined(HAVE_PRI_TRANSFER) 03816 case PRI_SUBCMD_TRANSFER_CALL: 03817 if (!call_rsp) { 03818 /* Should never happen. */ 03819 ast_log(LOG_ERROR, 03820 "Call transfer subcommand without call to send response!\n"); 03821 break; 03822 } 03823 03824 sig_pri_unlock_private(pri->pvts[chanpos]); 03825 pri_transfer_rsp(pri->pri, call_rsp, subcmd->u.transfer.invoke_id, 03826 sig_pri_attempt_transfer(pri, 03827 subcmd->u.transfer.call_1, subcmd->u.transfer.is_call_1_held, 03828 subcmd->u.transfer.call_2, subcmd->u.transfer.is_call_2_held) 03829 ? 0 : 1); 03830 sig_pri_lock_private(pri->pvts[chanpos]); 03831 break; 03832 #endif /* defined(HAVE_PRI_TRANSFER) */ 03833 #if defined(HAVE_PRI_AOC_EVENTS) 03834 case PRI_SUBCMD_AOC_S: 03835 sig_pri_lock_owner(pri, chanpos); 03836 owner = pri->pvts[chanpos]->owner; 03837 if (owner) { 03838 sig_pri_aoc_s_from_pri(&subcmd->u.aoc_s, owner, 03839 (pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S)); 03840 ast_channel_unlock(owner); 03841 } 03842 break; 03843 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03844 #if defined(HAVE_PRI_AOC_EVENTS) 03845 case PRI_SUBCMD_AOC_D: 03846 sig_pri_lock_owner(pri, chanpos); 03847 owner = pri->pvts[chanpos]->owner; 03848 if (owner) { 03849 /* Queue AST_CONTROL_AOC frame on channel */ 03850 sig_pri_aoc_d_from_pri(&subcmd->u.aoc_d, owner, 03851 (pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_D)); 03852 ast_channel_unlock(owner); 03853 } 03854 break; 03855 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03856 #if defined(HAVE_PRI_AOC_EVENTS) 03857 case PRI_SUBCMD_AOC_E: 03858 sig_pri_lock_owner(pri, chanpos); 03859 owner = pri->pvts[chanpos]->owner; 03860 /* Queue AST_CONTROL_AOC frame */ 03861 sig_pri_aoc_e_from_pri(&subcmd->u.aoc_e, owner, 03862 (pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_E)); 03863 if (owner) { 03864 ast_channel_unlock(owner); 03865 } 03866 break; 03867 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03868 #if defined(HAVE_PRI_AOC_EVENTS) 03869 case PRI_SUBCMD_AOC_CHARGING_REQ: 03870 sig_pri_lock_owner(pri, chanpos); 03871 owner = pri->pvts[chanpos]->owner; 03872 if (owner) { 03873 sig_pri_aoc_request_from_pri(&subcmd->u.aoc_request, pri->pvts[chanpos], 03874 call_rsp); 03875 ast_channel_unlock(owner); 03876 } 03877 break; 03878 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03879 #if defined(HAVE_PRI_AOC_EVENTS) 03880 case PRI_SUBCMD_AOC_CHARGING_REQ_RSP: 03881 /* 03882 * An AOC request response may contain an AOC-S rate list. 03883 * If this is the case handle this just like we 03884 * would an incoming AOC-S msg. 03885 */ 03886 if (subcmd->u.aoc_request_response.valid_aoc_s) { 03887 sig_pri_lock_owner(pri, chanpos); 03888 owner = pri->pvts[chanpos]->owner; 03889 if (owner) { 03890 sig_pri_aoc_s_from_pri(&subcmd->u.aoc_request_response.aoc_s, owner, 03891 (pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S)); 03892 ast_channel_unlock(owner); 03893 } 03894 } 03895 break; 03896 #endif /* defined(HAVE_PRI_AOC_EVENTS) */ 03897 #if defined(HAVE_PRI_MCID) 03898 case PRI_SUBCMD_MCID_REQ: 03899 sig_pri_lock_owner(pri, chanpos); 03900 owner = pri->pvts[chanpos]->owner; 03901 sig_pri_mcid_event(pri, &subcmd->u.mcid_req, owner); 03902 if (owner) { 03903 ast_channel_unlock(owner); 03904 } 03905 break; 03906 #endif /* defined(HAVE_PRI_MCID) */ 03907 #if defined(HAVE_PRI_MCID) 03908 case PRI_SUBCMD_MCID_RSP: 03909 /* Ignore for now. */ 03910 break; 03911 #endif /* defined(HAVE_PRI_MCID) */ 03912 default: 03913 ast_debug(2, 03914 "Unknown call subcommand(%d) in %s event on channel %d/%d on span %d.\n", 03915 subcmd->cmd, pri_event2str(event_id), PRI_SPAN(channel), 03916 PRI_CHANNEL(channel), pri->span); 03917 break; 03918 } 03919 } 03920 }
| 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 }
| static int sig_pri_is_cis_call | ( | int | channel | ) | [static] |
Definition at line 3323 of file sig_pri.c.
References PRI_CIS_CALL.
Referenced by pri_dchannel().
03324 { 03325 return channel != -1 && (channel & PRI_CIS_CALL); 03326 }
| 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 }
| static void sig_pri_lock_owner | ( | struct sig_pri_span * | pri, | |
| int | chanpos | |||
| ) | [static] |
Definition at line 1008 of file sig_pri.c.
References ast_channel_trylock, ast_mutex_lock, ast_mutex_unlock, sig_pri_span::lock, sig_pri_chan::owner, PRI_DEADLOCK_AVOIDANCE, and sig_pri_span::pvts.
Referenced by pri_dchannel(), pri_queue_frame(), sig_pri_attempt_transfer(), sig_pri_cc_generic_check(), sig_pri_handle_hold(), and sig_pri_handle_subcmds().
01009 { 01010 for (;;) { 01011 if (!pri->pvts[chanpos]->owner) { 01012 /* There is no owner lock to get. */ 01013 break; 01014 } 01015 if (!ast_channel_trylock(pri->pvts[chanpos]->owner)) { 01016 /* We got the lock */ 01017 break; 01018 } 01019 /* We must unlock the PRI to avoid the possibility of a deadlock */ 01020 ast_mutex_unlock(&pri->lock); 01021 PRI_DEADLOCK_AVOIDANCE(pri->pvts[chanpos]); 01022 ast_mutex_lock(&pri->lock); 01023 } 01024 }
| static void sig_pri_lock_private | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 277 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::lock_private.
Referenced by pri_dchannel(), pri_send_callrerouting_facility_exec(), pri_send_keypad_facility_exec(), pri_ss_thread(), sig_pri_attempt_transfer(), sig_pri_handle_hold(), sig_pri_handle_retrieve(), and sig_pri_handle_subcmds().
00278 { 00279 if (p->calls->lock_private) 00280 p->calls->lock_private(p->chan_pvt); 00281 }
| static int sig_pri_msn_match | ( | const char * | msn_patterns, | |
| const char * | exten | |||
| ) | [static] |
Definition at line 1743 of file sig_pri.c.
References ast_extension_match(), ast_strdupa, ast_strip(), and ast_strlen_zero().
Referenced by pri_dchannel().
01744 { 01745 char *pattern; 01746 char *msn_list; 01747 char *list_tail; 01748 01749 msn_list = ast_strdupa(msn_patterns); 01750 01751 list_tail = NULL; 01752 pattern = strtok_r(msn_list, ",", &list_tail); 01753 while (pattern) { 01754 pattern = ast_strip(pattern); 01755 if (!ast_strlen_zero(pattern) && ast_extension_match(pattern, exten)) { 01756 /* Extension matched the pattern. */ 01757 return 1; 01758 } 01759 pattern = strtok_r(NULL, ",", &list_tail); 01760 } 01761 /* Did not match any pattern in the list. */ 01762 return 0; 01763 }
| static struct ast_channel* sig_pri_new_ast_channel | ( | struct sig_pri_chan * | p, | |
| int | state, | |||
| int | ulaw, | |||
| int | transfercapability, | |||
| char * | exten, | |||
| const struct ast_channel * | requestor | |||
| ) | [static, read] |
Definition at line 864 of file sig_pri.c.
References sig_pri_chan::alreadyhungup, ast_log(), AST_TRANS_CAP_DIGITAL, ast_transfercapability2str(), sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::isidlecall, LOG_WARNING, sig_pri_callback::new_ast_channel, sig_pri_chan::owner, pbx_builtin_setvar_helper(), sig_pri_chan::pri, pri_grab(), pri_rel(), sig_pri_set_digital(), sig_pri_span_devstate_changed(), and ast_channel::transfercapability.
Referenced by pri_dchannel(), and sig_pri_request().
00865 { 00866 struct ast_channel *c; 00867 00868 if (p->calls->new_ast_channel) 00869 c = p->calls->new_ast_channel(p->chan_pvt, state, ulaw, exten, requestor); 00870 else 00871 return NULL; 00872 00873 if (!p->owner) 00874 p->owner = c; 00875 p->isidlecall = 0; 00876 p->alreadyhungup = 0; 00877 c->transfercapability = transfercapability; 00878 pbx_builtin_setvar_helper(c, "TRANSFERCAPABILITY", 00879 ast_transfercapability2str(transfercapability)); 00880 if (transfercapability & AST_TRANS_CAP_DIGITAL) { 00881 sig_pri_set_digital(p, 1); 00882 } 00883 if (p->pri && !pri_grab(p, p->pri)) { 00884 sig_pri_span_devstate_changed(p->pri); 00885 pri_rel(p->pri); 00886 } else { 00887 ast_log(LOG_WARNING, "Failed to grab PRI!\n"); 00888 } 00889 00890 return c; 00891 }
| static void sig_pri_open_media | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 902 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::no_b_channel, and sig_pri_callback::open_media.
Referenced by pri_dchannel(), and sig_pri_answer().
00903 { 00904 if (p->no_b_channel) { 00905 return; 00906 } 00907 00908 if (p->calls->open_media) { 00909 p->calls->open_media(p->chan_pvt); 00910 } 00911 }
| 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] |
Definition at line 1689 of file sig_pri.c.
References ast_party_id::name, ast_party_id::number, sig_pri_party_name_convert(), sig_pri_party_number_convert(), sig_pri_set_subaddress(), and ast_party_id::subaddress.
Referenced by sig_pri_handle_subcmds(), and sig_pri_redirecting_convert().
01690 { 01691 if (pri_id->name.valid) { 01692 sig_pri_party_name_convert(&ast_id->name, &pri_id->name); 01693 } 01694 if (pri_id->number.valid) { 01695 sig_pri_party_number_convert(&ast_id->number, &pri_id->number, pri); 01696 } 01697 #if defined(HAVE_PRI_SUBADDR) 01698 if (pri_id->subaddress.valid) { 01699 sig_pri_set_subaddress(&ast_id->subaddress, &pri_id->subaddress); 01700 } 01701 #endif /* defined(HAVE_PRI_SUBADDR) */ 01702 }
| static void sig_pri_party_id_from_ast | ( | struct pri_party_id * | pri_id, | |
| const struct ast_party_id * | ast_id | |||
| ) | [static] |
Definition at line 790 of file sig_pri.c.
References ast_party_id::name, ast_party_id::number, sig_pri_party_name_from_ast(), sig_pri_party_number_from_ast(), sig_pri_party_subaddress_from_ast(), and ast_party_id::subaddress.
Referenced by sig_pri_indicate(), and sig_pri_redirecting_update().
00791 { 00792 sig_pri_party_name_from_ast(&pri_id->name, &ast_id->name); 00793 sig_pri_party_number_from_ast(&pri_id->number, &ast_id->number); 00794 #if defined(HAVE_PRI_SUBADDR) 00795 sig_pri_party_subaddress_from_ast(&pri_id->subaddress, &ast_id->subaddress); 00796 #endif /* defined(HAVE_PRI_SUBADDR) */ 00797 }
| static void sig_pri_party_name_convert | ( | struct ast_party_name * | ast_name, | |
| const struct pri_party_name * | pri_name | |||
| ) | [static] |
Definition at line 1642 of file sig_pri.c.
References ast_strdup, ast_party_name::char_set, ast_party_name::presentation, pri_to_ast_char_set(), pri_to_ast_presentation(), ast_party_name::str, and ast_party_name::valid.
Referenced by sig_pri_party_id_convert().
01643 { 01644 ast_name->str = ast_strdup(pri_name->str); 01645 ast_name->char_set = pri_to_ast_char_set(pri_name->char_set); 01646 ast_name->presentation = pri_to_ast_presentation(pri_name->presentation); 01647 ast_name->valid = 1; 01648 }
| static void sig_pri_party_name_from_ast | ( | struct pri_party_name * | pri_name, | |
| const struct ast_party_name * | ast_name | |||
| ) | [static] |
Definition at line 740 of file sig_pri.c.
References ast_copy_string(), ast_strlen_zero(), ast_to_pri_char_set(), ast_to_pri_presentation(), ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by sig_pri_party_id_from_ast().
00741 { 00742 if (!ast_name->valid) { 00743 return; 00744 } 00745 pri_name->valid = 1; 00746 pri_name->presentation = ast_to_pri_presentation(ast_name->presentation); 00747 pri_name->char_set = ast_to_pri_char_set(ast_name->char_set); 00748 if (!ast_strlen_zero(ast_name->str)) { 00749 ast_copy_string(pri_name->str, ast_name->str, sizeof(pri_name->str)); 00750 } 00751 }
| 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] |
Definition at line 1664 of file sig_pri.c.
References apply_plan_to_number(), AST_MAX_EXTENSION, ast_strdup, ast_party_number::plan, ast_party_number::presentation, pri_to_ast_presentation(), ast_party_number::str, and ast_party_number::valid.
Referenced by sig_pri_party_id_convert().
01665 { 01666 char number[AST_MAX_EXTENSION]; 01667 01668 apply_plan_to_number(number, sizeof(number), pri, pri_number->str, pri_number->plan); 01669 ast_number->str = ast_strdup(number); 01670 ast_number->plan = pri_number->plan; 01671 ast_number->presentation = pri_to_ast_presentation(pri_number->presentation); 01672 ast_number->valid = 1; 01673 }
| static void sig_pri_party_number_from_ast | ( | struct pri_party_number * | pri_number, | |
| const struct ast_party_number * | ast_number | |||
| ) | [static] |
Definition at line 765 of file sig_pri.c.
References ast_copy_string(), ast_strlen_zero(), ast_to_pri_presentation(), ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by sig_pri_party_id_from_ast().
00766 { 00767 if (!ast_number->valid) { 00768 return; 00769 } 00770 pri_number->valid = 1; 00771 pri_number->presentation = ast_to_pri_presentation(ast_number->presentation); 00772 pri_number->plan = ast_number->plan; 00773 if (!ast_strlen_zero(ast_number->str)) { 00774 ast_copy_string(pri_number->str, ast_number->str, sizeof(pri_number->str)); 00775 } 00776 }
| static void sig_pri_party_subaddress_from_ast | ( | struct pri_party_subaddress * | pri_subaddress, | |
| const struct ast_party_subaddress * | ast_subaddress | |||
| ) | [static] |
Definition at line 700 of file sig_pri.c.
References ast_copy_string(), ast_pri_pack_hex_string(), ast_strlen_zero(), ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by sig_pri_call(), and sig_pri_party_id_from_ast().
00701 { 00702 if (ast_subaddress->valid && !ast_strlen_zero(ast_subaddress->str)) { 00703 pri_subaddress->type = ast_subaddress->type; 00704 if (!ast_subaddress->type) { 00705 /* 0 = NSAP */ 00706 ast_copy_string((char *) pri_subaddress->data, ast_subaddress->str, 00707 sizeof(pri_subaddress->data)); 00708 pri_subaddress->length = strlen((char *) pri_subaddress->data); 00709 pri_subaddress->odd_even_indicator = 0; 00710 pri_subaddress->valid = 1; 00711 } else { 00712 /* 2 = User Specified */ 00713 /* 00714 * Copy HexString to packed HexData, 00715 * if odd length then right pad trailing byte with 0 00716 */ 00717 int length = ast_pri_pack_hex_string(pri_subaddress->data, 00718 ast_subaddress->str, sizeof(pri_subaddress->data)); 00719 00720 pri_subaddress->length = length; 00721 pri_subaddress->odd_even_indicator = (length & 1); 00722 pri_subaddress->valid = 1; 00723 } 00724 } 00725 }
| static int sig_pri_play_tone | ( | struct sig_pri_chan * | p, | |
| enum sig_pri_tone | tone | |||
| ) | [static] |
Definition at line 856 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::play_tone.
Referenced by pri_ss_thread(), and sig_pri_indicate().
00857 { 00858 if (p->calls->play_tone) 00859 return p->calls->play_tone(p->chan_pvt, tone); 00860 else 00861 return -1; 00862 }
| 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] |
Definition at line 1719 of file sig_pri.c.
References ast_party_redirecting_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, pri_to_ast_reason(), ast_party_redirecting::reason, sig_pri_party_id_convert(), and ast_party_redirecting::to.
Referenced by sig_pri_handle_subcmds().
01723 { 01724 ast_party_redirecting_set_init(ast_redirecting, ast_guide); 01725 01726 sig_pri_party_id_convert(&ast_redirecting->from, &pri_redirecting->from, pri); 01727 sig_pri_party_id_convert(&ast_redirecting->to, &pri_redirecting->to, pri); 01728 ast_redirecting->count = pri_redirecting->count; 01729 ast_redirecting->reason = pri_to_ast_reason(pri_redirecting->reason); 01730 }
| static void sig_pri_redirecting_update | ( | struct sig_pri_chan * | pvt, | |
| struct ast_channel * | ast | |||
| ) | [static] |
Definition at line 811 of file sig_pri.c.
References ast_to_pri_reason(), sig_pri_chan::call, ast_party_redirecting::count, ast_party_redirecting::from, sig_pri_span::pri, sig_pri_chan::pri, ast_party_redirecting::reason, ast_channel::redirecting, sig_pri_party_id_from_ast(), and ast_party_redirecting::to.
Referenced by sig_pri_call(), and sig_pri_indicate().
00812 { 00813 struct pri_party_redirecting pri_redirecting; 00814 00815 /*! \todo XXX Original called data can be put in a channel data store that is inherited. */ 00816 00817 memset(&pri_redirecting, 0, sizeof(pri_redirecting)); 00818 sig_pri_party_id_from_ast(&pri_redirecting.from, &ast->redirecting.from); 00819 sig_pri_party_id_from_ast(&pri_redirecting.to, &ast->redirecting.to); 00820 pri_redirecting.count = ast->redirecting.count; 00821 pri_redirecting.reason = ast_to_pri_reason(ast->redirecting.reason); 00822 00823 pri_redirecting_update(pvt->pri->pri, pvt->call, &pri_redirecting); 00824 }
| 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 }
| static void sig_pri_set_alarm | ( | struct sig_pri_chan * | p, | |
| int | in_alarm | |||
| ) | [static] |
Definition at line 147 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::inalarm, and sig_pri_callback::set_alarm.
Referenced by pri_dchannel(), and sig_pri_chan_alarm_notify().
00148 { 00149 p->inalarm = in_alarm; 00150 if (p->calls->set_alarm) { 00151 p->calls->set_alarm(p->chan_pvt, in_alarm); 00152 } 00153 }
| static void sig_pri_set_caller_id | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 203 of file sig_pri.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_caller_init(), ast_strlen_zero(), sig_pri_chan::callingpres, sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::cid_ani, sig_pri_chan::cid_ani2, sig_pri_chan::cid_name, sig_pri_chan::cid_num, sig_pri_chan::cid_subaddr, sig_pri_chan::cid_ton, ast_party_caller::id, ast_party_id::name, ast_party_id::number, ast_party_number::plan, ast_party_number::presentation, ast_party_name::presentation, sig_pri_callback::set_callerid, ast_party_subaddress::str, ast_party_number::str, ast_party_name::str, ast_party_id::subaddress, ast_party_id::tag, sig_pri_chan::user_tag, ast_party_subaddress::valid, ast_party_number::valid, and ast_party_name::valid.
Referenced by pri_dchannel(), and sig_pri_handle_subcmds().
00204 { 00205 struct ast_party_caller caller; 00206 00207 if (p->calls->set_callerid) { 00208 ast_party_caller_init(&caller); 00209 00210 caller.id.name.str = p->cid_name; 00211 caller.id.name.presentation = p->callingpres; 00212 caller.id.name.valid = 1; 00213 00214 caller.id.number.str = p->cid_num; 00215 caller.id.number.plan = p->cid_ton; 00216 caller.id.number.presentation = p->callingpres; 00217 caller.id.number.valid = 1; 00218 00219 if (!ast_strlen_zero(p->cid_subaddr)) { 00220 caller.id.subaddress.valid = 1; 00221 //caller.id.subaddress.type = 0;/* nsap */ 00222 //caller.id.subaddress.odd_even_indicator = 0; 00223 caller.id.subaddress.str = p->cid_subaddr; 00224 } 00225 caller.id.tag = p->user_tag; 00226 00227 caller.ani.number.str = p->cid_ani; 00228 //caller.ani.number.plan = p->xxx; 00229 //caller.ani.number.presentation = p->xxx; 00230 caller.ani.number.valid = 1; 00231 00232 caller.ani2 = p->cid_ani2; 00233 p->calls->set_callerid(p->chan_pvt, &caller); 00234 } 00235 }
| static void sig_pri_set_dialing | ( | struct sig_pri_chan * | p, | |
| int | is_dialing | |||
| ) | [static] |
Definition at line 132 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::set_dialing.
Referenced by pri_dchannel(), sig_pri_answer(), sig_pri_call(), sig_pri_hangup(), and sig_pri_indicate().
00133 { 00134 if (p->calls->set_dialing) { 00135 p->calls->set_dialing(p->chan_pvt, is_dialing); 00136 } 00137 }
| static void sig_pri_set_digital | ( | struct sig_pri_chan * | p, | |
| int | is_digital | |||
| ) | [static] |
Definition at line 139 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, sig_pri_chan::digital, and sig_pri_callback::set_digital.
Referenced by sig_pri_call(), sig_pri_hangup(), sig_pri_indicate(), and sig_pri_new_ast_channel().
00140 { 00141 p->digital = is_digital; 00142 if (p->calls->set_digital) { 00143 p->calls->set_digital(p->chan_pvt, is_digital); 00144 } 00145 }
| static void sig_pri_set_dnid | ( | struct sig_pri_chan * | p, | |
| const char * | dnid | |||
| ) | [static] |
Definition at line 247 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::set_dnid.
Referenced by pri_dchannel().
00248 { 00249 if (p->calls->set_dnid) { 00250 p->calls->set_dnid(p->chan_pvt, dnid); 00251 } 00252 }
| static int sig_pri_set_echocanceller | ( | struct sig_pri_chan * | p, | |
| int | enable | |||
| ) | [static] |
Definition at line 842 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::set_echocanceller.
Referenced by pri_dchannel(), and pri_ss_thread().
00843 { 00844 if (p->calls->set_echocanceller) 00845 return p->calls->set_echocanceller(p->chan_pvt, enable); 00846 else 00847 return -1; 00848 }
| static void sig_pri_set_rdnis | ( | struct sig_pri_chan * | p, | |
| const char * | rdnis | |||
| ) | [static] |
Definition at line 264 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::set_rdnis.
Referenced by pri_dchannel().
00265 { 00266 if (p->calls->set_rdnis) { 00267 p->calls->set_rdnis(p->chan_pvt, rdnis); 00268 } 00269 }
| static void sig_pri_set_subaddress | ( | struct ast_party_subaddress * | ast_subaddress, | |
| const struct pri_party_subaddress * | pri_subaddress | |||
| ) | [static] |
Definition at line 578 of file sig_pri.c.
References ast_free, ast_malloc, ast_party_subaddress_init(), ast_strdup, len(), ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by pri_dchannel(), and sig_pri_party_id_convert().
00579 { 00580 char *cnum, *ptr; 00581 int x, len; 00582 00583 if (ast_subaddress->str) { 00584 ast_free(ast_subaddress->str); 00585 } 00586 if (pri_subaddress->length <= 0) { 00587 ast_party_subaddress_init(ast_subaddress); 00588 return; 00589 } 00590 00591 if (!pri_subaddress->type) { 00592 /* NSAP */ 00593 ast_subaddress->str = ast_strdup((char *) pri_subaddress->data); 00594 } else { 00595 /* User Specified */ 00596 if (!(cnum = ast_malloc(2 * pri_subaddress->length + 1))) { 00597 ast_party_subaddress_init(ast_subaddress); 00598 return; 00599 } 00600 00601 ptr = cnum; 00602 len = pri_subaddress->length - 1; /* -1 account for zero based indexing */ 00603 for (x = 0; x < len; ++x) { 00604 ptr += sprintf(ptr, "%02x", pri_subaddress->data[x]); 00605 } 00606 00607 if (pri_subaddress->odd_even_indicator) { 00608 /* ODD */ 00609 sprintf(ptr, "%01x", (pri_subaddress->data[len]) >> 4); 00610 } else { 00611 /* EVEN */ 00612 sprintf(ptr, "%02x", pri_subaddress->data[len]); 00613 } 00614 ast_subaddress->str = cnum; 00615 } 00616 ast_subaddress->type = pri_subaddress->type; 00617 ast_subaddress->odd_even_indicator = pri_subaddress->odd_even_indicator; 00618 ast_subaddress->valid = 1; 00619 }
| static void sig_pri_sort_pri_chans | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 6837 of file sig_pri.c.
References sig_pri_span::numchans, sig_pri_span::pvts, and sig_pri_cmp_pri_chans().
Referenced by sig_pri_start_pri().
06838 { 06839 qsort(&pri->pvts, pri->numchans, sizeof(pri->pvts[0]), sig_pri_cmp_pri_chans); 06840 }
| static void sig_pri_span_devstate_changed | ( | struct sig_pri_span * | pri | ) | [static] |
Definition at line 187 of file sig_pri.c.
References sig_pri_span::calls, and sig_pri_callback::update_span_devstate.
Referenced by pri_dchannel(), sig_pri_handle_hold(), sig_pri_handle_retrieve(), sig_pri_hangup(), and sig_pri_new_ast_channel().
00188 { 00189 if (pri->calls->update_span_devstate) { 00190 pri->calls->update_span_devstate(pri); 00191 } 00192 }
| 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 }
| static void sig_pri_unlock_private | ( | struct sig_pri_chan * | p | ) | [static] |
Definition at line 271 of file sig_pri.c.
References sig_pri_chan::calls, sig_pri_chan::chan_pvt, and sig_pri_callback::unlock_private.
Referenced by pri_dchannel(), pri_send_callrerouting_facility_exec(), pri_send_keypad_facility_exec(), pri_ss_thread(), sig_pri_attempt_transfer(), sig_pri_handle_hold(), sig_pri_handle_retrieve(), and sig_pri_handle_subcmds().
00272 { 00273 if (p->calls->unlock_private) 00274 p->calls->unlock_private(p->chan_pvt); 00275 }
int pri_gendigittimeout = 8000 [static] |
int pri_matchdigittimeout = 3000 [static] |
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] |
1.5.9