57 #if defined(__NetBSD__) || defined(__FreeBSD__) 60 #include <sys/sysmacros.h> 76 #error "Upgrade your libpri" 82 #if !defined(LIBSS7_ABI_COMPATIBILITY) 83 #error "Upgrade your libss7" 84 #elif LIBSS7_ABI_COMPATIBILITY != 2 85 #error "Your installed libss7 is not compatible" 89 #if defined(HAVE_OPENR2) 91 #define SIG_MFCR2_MAX_CHANNELS 672 482 #define SMDI_MD_WAIT_TIMEOUT 1500 485 "0 db (CSU)/0-133 feet (DSX-1)",
486 "133-266 feet (DSX-1)",
487 "266-399 feet (DSX-1)",
488 "399-533 feet (DSX-1)",
489 "533-655 feet (DSX-1)",
501 .resync_threshold = 1000,
519 #define DEFAULT_CIDRINGS 1 521 #define AST_LAW(p) (((p)->law == DAHDI_LAW_ALAW) ? ast_format_alaw : ast_format_ulaw) 525 #define NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB)) 527 static const char tdesc[] =
"DAHDI Telephony" 528 #if defined(HAVE_PRI) || defined(HAVE_SS7) || defined(HAVE_OPENR2) 530 #if defined(HAVE_PRI) 533 #if defined(HAVE_SS7) 534 #if defined(HAVE_PRI) 539 #if defined(HAVE_OPENR2) 540 #if defined(HAVE_PRI) || defined(HAVE_SS7) 548 static const char config[] =
"chan_dahdi.conf";
551 #define NUM_SPANS DAHDI_MAX_SPANS 556 #define CHAN_PSEUDO -2 558 #define CALLPROGRESS_PROGRESS 1 559 #define CALLPROGRESS_FAX_OUTGOING 2 560 #define CALLPROGRESS_FAX_INCOMING 4 561 #define CALLPROGRESS_FAX (CALLPROGRESS_FAX_INCOMING | CALLPROGRESS_FAX_OUTGOING) 563 #define NUM_CADENCE_MAX 25 570 { { 125, 125, 2000, 4000 } },
571 { { 250, 250, 500, 1000, 250, 250, 500, 4000 } },
572 { { 125, 125, 125, 125, 125, 4000 } },
573 { { 1000, 500, 2500, 5000 } },
590 #define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \ 591 (p->sig == SIG_FXSGS) || (p->sig == SIG_PRI)) 593 #define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) ) 594 #define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) ) 601 #ifndef HAVE_DAHDI_LINEREVERSE_VMWI 615 #define REPORT_CHANNEL_ALARMS 1 616 #define REPORT_SPAN_ALARMS 2 620 static int pridebugfd = -1;
621 static char pridebugfilename[1024] =
"";
655 if (ioctl(fd, DAHDI_GETEVENT, &j) == -1)
664 i = DAHDI_IOMUX_SIGEVENT;
665 if (ioctl(fd, DAHDI_IOMUX, &i) == -1)
667 if (ioctl(fd, DAHDI_GETEVENT, &j) == -1)
673 #define READ_SIZE 160 675 #define MASK_AVAIL (1 << 0) 676 #define MASK_INUSE (1 << 1) 678 #define CALLWAITING_SILENT_SAMPLES ((300 * 8) / READ_SIZE) 679 #define CALLWAITING_REPEAT_SAMPLES ((10000 * 8) / READ_SIZE) 680 #define CALLWAITING_SUPPRESS_SAMPLES ((100 * 8) / READ_SIZE) 681 #define CIDCW_EXPIRE_SAMPLES ((500 * 8) / READ_SIZE) 682 #define MIN_MS_SINCE_FLASH ((2000) ) 683 #define DEFAULT_RINGT ((8000 * 8) / READ_SIZE) 684 #define DEFAULT_DIALTONE_DETECT_TIMEOUT ((10000 * 8) / READ_SIZE) 692 #if defined(HAVE_SS7) 698 static struct dahdi_ss7 linksets[NUM_SPANS];
700 static int cur_ss7type = -1;
701 static int cur_slc = -1;
702 static int cur_linkset = -1;
703 static int cur_pointcode = -1;
704 static int cur_cicbeginswith = -1;
705 static int cur_adjpointcode = -1;
706 static int cur_networkindicator = -1;
707 static int cur_defaultdpc = -1;
711 struct dahdi_mfcr2_conf {
712 openr2_variant_t variant;
714 int metering_pulse_timeout;
717 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 721 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 3 722 int dtmf_end_timeout;
724 signed int get_ani_first:2;
725 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 726 signed int skip_category_request:2;
728 unsigned int call_files:1;
729 unsigned int allow_collect_calls:1;
730 unsigned int charge_calls:1;
731 unsigned int accept_on_offer:1;
732 unsigned int forced_release:1;
733 unsigned int double_answer:1;
734 signed int immediate_accept:2;
735 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 736 signed int dtmf_dialing:2;
737 signed int dtmf_detection:2;
739 char logdir[OR2_MAX_PATH];
740 char r2proto_file[OR2_MAX_PATH];
741 openr2_log_level_t loglevel;
742 openr2_calling_party_category_t category;
749 openr2_context_t *protocol_context;
754 struct dahdi_mfcr2_conf conf;
757 struct r2link_entry {
758 struct dahdi_mfcr2 mfcr2;
766 static int r2links_count = 0;
774 int mastertrunkgroup;
779 static struct dahdi_pri pris[NUM_SPANS];
781 #if defined(HAVE_PRI_CCSS) 783 static const char dahdi_pri_cc_type[] =
"DAHDI/PRI";
792 #define POLARITY_IDLE 0 793 #define POLARITY_REV 1 804 #if defined(HAVE_PRI) 813 static struct dahdi_parms_pseudo {
818 } dahdi_pseudo_parms;
834 struct dahdi_pri pri;
837 #if defined(HAVE_SS7) 838 struct dahdi_ss7 ss7;
842 struct dahdi_mfcr2_conf mfcr2;
844 struct dahdi_params timing;
878 .switchtype = PRI_SWITCH_NI2,
879 .dialplan = PRI_UNKNOWN + 1,
880 .localdialplan = PRI_NATIONAL_ISDN + 1,
884 #if defined(HAVE_PRI_CCSS) 885 .cc_ptmp_recall_mode = 1,
886 .cc_qsig_signaling_link_req = 1,
887 .cc_qsig_signaling_link_rsp = 1,
893 .internationalprefix =
"",
894 .nationalprefix =
"",
902 #if defined(HAVE_SS7) 904 .called_nai = SS7_NAI_NATIONAL,
905 .calling_nai = SS7_NAI_NATIONAL,
906 .internationalprefix =
"",
907 .nationalprefix =
"",
908 .subscriberprefix =
"",
910 .networkroutedprefix =
"" 915 .variant = OR2_VAR_ITU,
916 .mfback_timeout = -1,
917 .metering_pulse_timeout = -1,
921 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 922 .skip_category_request = -1,
925 .allow_collect_calls = 0,
927 .accept_on_offer = 1,
930 .immediate_accept = -1,
931 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 933 .dtmf_detection = -1,
934 .dtmf_time_on = OR2_DEFAULT_DTMF_ON,
935 .dtmf_time_off = OR2_DEFAULT_DTMF_OFF,
937 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 3 938 .dtmf_end_timeout = -1,
942 .loglevel = OR2_LOG_ERROR | OR2_LOG_WARNING,
943 .category = OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER
947 .context =
"default",
951 .mohinterpret =
"default",
958 .dahditrcallerid = 0,
967 .echocancel.head.tap_length = 1,
975 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 978 .polarityonanswerdelay = 600,
982 .buf_policy = DAHDI_POLICY_IMMEDIATE,
1001 .ignore_failed_channels = 1,
1002 .smdi_port =
"/dev/ttyS0",
1011 const char *
data,
int *cause);
1032 .description =
tdesc,
1053 #define GET_CHANNEL(p) ((p)->channel) 1110 return DAHDI_TONE_RINGTONE;
1112 return DAHDI_TONE_STUTTER;
1114 return DAHDI_TONE_CONGESTION;
1116 return DAHDI_TONE_DIALTONE;
1118 return DAHDI_TONE_DIALRECALL;
1120 return DAHDI_TONE_INFO;
1130 switch (analogsub) {
1159 struct doomed_pri *
entry;
1165 ast_debug(4,
"Destroying span %d from doomed queue.\n",
1167 pri_destroy_span(entry->pri);
1186 static void pri_queue_for_destruction(
struct sig_pri_span *pri)
1188 struct doomed_pri *
entry;
1192 if (entry->pri == pri) {
1197 entry =
ast_calloc(
sizeof(
struct doomed_pri), 1);
1205 ast_debug(4,
"Queue span %d for destruction.\n", pri->
span);
1228 struct dahdi_dialoperation zo = {
1234 for (offset = 0; offset <
sizeof(zo.dialstr) - 1; ++offset) {
1241 if (offset >=
sizeof(zo.dialstr) - 3) {
1245 zo.dialstr[offset] =
'w';
1247 zo.dialstr[offset] =
'w';
1250 zo.dialstr[offset] = *pos++;
1254 ast_debug(1,
"Channel %d: Dial str '%s' expanded to '%s' sent to DAHDI_DIAL.\n",
1255 pvt->
channel, dial_str, zo.dialstr);
1306 struct pollfd poller;
1310 unsigned char buf[256];
1314 poller.events = POLLPRI | POLLIN;
1317 res = poll(&poller, 1, timeout);
1319 if (poller.revents & POLLPRI) {
1324 if (poller.revents & POLLIN) {
1330 res = read(p->
subs[index].
dfd, buf,
sizeof(buf));
1336 if (analog_p->
ringt > 0) {
1337 if (!(--analog_p->
ringt)) {
1364 ast_debug(1,
"CallerID number: %s, name: %s, flags=%d\n", num, name, flags);
1377 unsigned char buf[256];
1385 int checkaftercid = 0;
1386 const char *matched_context;
1390 if (ringdata ==
NULL) {
1391 ringdata = curRingData;
1399 for (receivedRingT = 0; receivedRingT <
RING_PATTERNS; receivedRingT++)
1400 ringdata[receivedRingT] = 0;
1404 ast_verb(3,
"Detecting post-CID distinctive ring\n");
1408 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
1409 res = ioctl(p->
subs[idx].
dfd, DAHDI_IOMUX, &i);
1415 if (i & DAHDI_IOMUX_SIGEVENT) {
1418 if (res == DAHDI_EVENT_NOALARM) {
1421 }
else if (res == DAHDI_EVENT_RINGOFFHOOK) {
1423 ringdata[receivedRingT] = analog_p->
ringt;
1430 if (++receivedRingT == RING_PATTERNS) {
1434 }
else if (i & DAHDI_IOMUX_READ) {
1435 res = read(p->
subs[idx].
dfd, buf,
sizeof(buf));
1437 if (
errno != ELAST) {
1444 if (analog_p->
ringt > 0) {
1445 if (!(--analog_p->
ringt)) {
1454 ast_verb(3,
"Detected ring pattern: %d,%d,%d\n", ringdata[0], ringdata[1], ringdata[2]);
1456 for (counter = 0; counter < 3; counter++) {
1460 ast_verb(3,
"Checking %d,%d,%d with +/- %d range\n",
1465 for (counter1 = 0; counter1 < 3; counter1++) {
1469 ast_verb(3,
"Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
1470 ringdata[counter1]);
1472 }
else if (ring - range <= ringdata[counter1] && ringdata[counter1] <= ring + range) {
1473 ast_verb(3,
"Ring pattern %d is in range: %d to %d\n",
1474 ringdata[counter1], ring - range, ring + range);
1482 if (distMatches == 3) {
1485 ast_verb(3,
"Matched Distinctive Ring context %s\n", matched_context);
1491 if (strcmp(p->
context, matched_context) != 0) {
1565 ast_verb(3,
"CPE supports Call Waiting Caller*ID. Sending '%s/%s'\n",
1637 ast_log(
LOG_ERROR,
"We used a sub other than SUB_REAL (incorrect assumption sir)\n");
1654 ast_debug(1,
"%s DTMF digit: 0x%02X '%c' on %s\n",
1664 struct dahdi_bufferinfo bi = {
1671 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
1709 ast_debug(1,
"Already in a fax extension, not redirecting\n");
1718 *dest = &p->
subs[idx].
f;
1748 if (!channel_string) {
1758 "DAHDIGroup: %llu\r\n" 1760 "DAHDIChannel: %s\r\n",
1781 "channel", dahdi_channel);
1807 snprintf(ch_name,
sizeof(ch_name),
"no-media (%d)", p->
channel);
1810 strcpy(ch_name,
"pseudo");
1813 snprintf(ch_name,
sizeof(ch_name),
"%d", p->
channel);
1829 static void my_ami_channel_event(
void *pvt,
struct ast_channel *chan)
1889 return p->
subs[dahdi_sub].
dfd;
1929 #if defined(HAVE_PRI) || defined(HAVE_SS7) 1930 static void my_set_digital(
void *pvt,
int is_digital)
1938 #if defined(HAVE_SS7) 1939 static void my_set_inservice(
void *pvt,
int is_inservice)
1947 #if defined(HAVE_SS7) 1948 static void my_set_locallyblocked(
void *pvt,
int is_blocked)
1956 #if defined(HAVE_SS7) 1957 static void my_set_remotelyblocked(
void *pvt,
int is_blocked)
2041 p->
owner = new_owner;
2092 for (i = 0; i < 3; i++) {
2129 int needconf = needconference;
2235 #if defined(HAVE_PRI) || defined(HAVE_SS7) 2236 static int dahdi_setlaw(
int dfd,
int law)
2239 res = ioctl(dfd, DAHDI_SETLAW, &law);
2246 #if defined(HAVE_PRI) 2285 newlaw = DAHDI_LAW_ALAW;
2288 newlaw = DAHDI_LAW_MULAW;
2298 #if defined(HAVE_PRI) || defined(HAVE_SS7) 2308 static void my_pri_ss7_open_media(
void *p)
2319 res = ioctl(dfd, DAHDI_AUDIOMODE, &set_val);
2326 res = dahdi_setlaw(dfd, pvt->
law);
2348 #if defined(HAVE_PRI) 2361 static void my_pri_dial_digits(
void *p,
const char *dial_string)
2363 char dial_str[DAHDI_MAX_DTMF_BUF];
2367 snprintf(dial_str,
sizeof(dial_str),
"T%s", dial_string);
2417 case DAHDI_EVENT_ONHOOK:
2420 case DAHDI_EVENT_RINGOFFHOOK:
2423 case DAHDI_EVENT_WINKFLASH:
2426 case DAHDI_EVENT_ALARM:
2429 case DAHDI_EVENT_NOALARM:
2432 case DAHDI_EVENT_DIALCOMPLETE:
2435 case DAHDI_EVENT_RINGERON:
2438 case DAHDI_EVENT_RINGEROFF:
2441 case DAHDI_EVENT_HOOKCOMPLETE:
2444 case DAHDI_EVENT_PULSE_START:
2447 case DAHDI_EVENT_POLARITY:
2450 case DAHDI_EVENT_RINGBEGIN:
2453 case DAHDI_EVENT_EC_DISABLED:
2456 case DAHDI_EVENT_REMOVED:
2459 case DAHDI_EVENT_NEONMWI_ACTIVE:
2462 case DAHDI_EVENT_NEONMWI_INACTIVE:
2465 #ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE 2466 case DAHDI_EVENT_TX_CED_DETECTED:
2469 case DAHDI_EVENT_RX_CED_DETECTED:
2472 case DAHDI_EVENT_EC_NLP_DISABLED:
2475 case DAHDI_EVENT_EC_NLP_ENABLED:
2479 case DAHDI_EVENT_PULSEDIGIT:
2482 case DAHDI_EVENT_DTMFDOWN:
2485 case DAHDI_EVENT_DTMFUP:
2489 switch(event & 0xFFFF0000) {
2490 case DAHDI_EVENT_PULSEDIGIT:
2491 case DAHDI_EVENT_DTMFDOWN:
2492 case DAHDI_EVENT_DTMFUP:
2534 struct dahdi_params par;
2536 memset(&par, 0,
sizeof(par));
2543 par.rxisoffhook = 0;
2553 return (par.rxbits > -1) || par.rxisoffhook;
2556 return par.rxisoffhook;
2583 int func = DAHDI_FLASH;
2650 int x = DAHDI_START;
2665 ast_log(
LOG_ERROR,
"Trying to dial_digits '%s' on channel %d subchannel %u\n",
2692 if (ioctl(p->
subs[index].
dfd, DAHDI_DIALING, &x)) {
2693 ast_debug(1,
"DAHDI_DIALING ioctl failed!\n");
2706 #if defined(HAVE_PRI) 2707 static void my_pri_fixup_chans(
void *chan_old,
void *chan_new)
2714 if (new_chan->
owner) {
2721 new_chan->
dsp = old_chan->
dsp;
2735 new_chan->
law = old_chan->
law;
2740 #if defined(HAVE_PRI) 2741 static int sig_pri_tone_to_dahditone(
enum sig_pri_tone tone)
2745 return DAHDI_TONE_RINGTONE;
2747 return DAHDI_TONE_STUTTER;
2749 return DAHDI_TONE_CONGESTION;
2751 return DAHDI_TONE_DIALTONE;
2753 return DAHDI_TONE_DIALRECALL;
2755 return DAHDI_TONE_INFO;
2757 return DAHDI_TONE_BUSY;
2764 #if defined(HAVE_PRI) 2765 static void my_handle_dchan_exception(
struct sig_pri_span *pri,
int index)
2769 ioctl(pri->
fds[index], DAHDI_GETEVENT, &x);
2771 case DAHDI_EVENT_NONE:
2773 case DAHDI_EVENT_ALARM:
2774 case DAHDI_EVENT_NOALARM:
2786 case DAHDI_EVENT_ALARM:
2789 case DAHDI_EVENT_NOALARM:
2792 case DAHDI_EVENT_REMOVED:
2793 pri_queue_for_destruction(pri);
2801 #if defined(HAVE_PRI) 2802 static int my_pri_play_tone(
void *pvt,
enum sig_pri_tone tone)
2806 return tone_zone_play_tone(p->
subs[
SUB_REAL].
dfd, sig_pri_tone_to_dahditone(tone));
2810 #if defined(HAVE_PRI) || defined(HAVE_SS7) 2821 static void my_set_callerid(
void *pvt,
const struct ast_party_caller *caller)
2836 if (caller->
id.
tag) {
2841 sizeof(p->cid_ani));
2846 #if defined(HAVE_PRI) || defined(HAVE_SS7) 2857 static void my_set_dnid(
void *pvt,
const char *
dnid)
2865 #if defined(HAVE_PRI) 2876 static void my_set_rdnis(
void *pvt,
const char *
rdnis)
2884 #if defined(HAVE_PRI) 2909 static void my_pri_make_cc_dialstring(
void *priv,
char *
buf,
size_t buf_size)
2930 snprintf(
buf, buf_size,
"%s/i%d-",
args.tech, pvt->pri->span);
2933 if (isdigit(
args.group[0]) ||
args.group[0] ==
'i' || strchr(
args.group,
'!')) {
2940 snprintf(
buf, buf_size,
"%s/i%d-%s",
args.tech, pvt->pri->span,
args.group);
2944 #if defined(HAVE_PRI) 2956 static void dahdi_pri_update_span_devstate(
struct sig_pri_span *pri)
2959 unsigned num_b_chans;
2968 for (idx = pri->
numchans; idx--;) {
2992 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER) 2996 }
else if (!in_use) {
2998 }
else if (!pri->user_busy_threshold) {
3004 if (pri->threshold_devstate != new_state) {
3005 pri->threshold_devstate = new_state;
3012 #if defined(HAVE_PRI) 3020 static void my_module_ref(
void)
3026 #if defined(HAVE_PRI) 3034 static void my_module_unref(
void)
3040 #if defined(HAVE_PRI) 3041 #if defined(HAVE_PRI_CALL_WAITING) 3042 static void my_pri_init_config(
void *priv,
struct sig_pri_span *pri);
3044 static int dahdi_new_pri_nobch_channel(
struct sig_pri_span *pri);
3049 .play_tone = my_pri_play_tone,
3055 .new_ast_channel = my_new_pri_ast_channel,
3056 .fixup_chans = my_pri_fixup_chans,
3060 .set_digital = my_set_digital,
3061 .set_callerid = my_set_callerid,
3062 .set_dnid = my_set_dnid,
3063 .set_rdnis = my_set_rdnis,
3064 .new_nobch_intf = dahdi_new_pri_nobch_channel,
3065 #if defined(HAVE_PRI_CALL_WAITING) 3066 .init_config = my_pri_init_config,
3069 .make_cc_dialstring = my_pri_make_cc_dialstring,
3070 .update_span_devstate = dahdi_pri_update_span_devstate,
3071 .module_ref = my_module_ref,
3072 .module_unref = my_module_unref,
3073 .dial_digits = my_pri_dial_digits,
3074 .open_media = my_pri_ss7_open_media,
3075 .ami_channel_event = my_ami_channel_event,
3076 .destroy_later = pri_queue_for_destruction,
3080 #if defined(HAVE_SS7) 3091 static void my_handle_link_exception(
struct sig_ss7_linkset *linkset,
int which)
3095 if (ioctl(linkset->
fds[which], DAHDI_GETEVENT, &event)) {
3097 linkset->
span, which);
3101 case DAHDI_EVENT_NONE:
3103 case DAHDI_EVENT_ALARM:
3108 case DAHDI_EVENT_NOALARM:
3121 #if defined(HAVE_SS7) 3122 static void my_ss7_set_loopback(
void *pvt,
int enable)
3133 #if defined(HAVE_SS7) 3153 if (linksets[idx].ss7.ss7 == ss7) {
3154 return &linksets[idx].ss7;
3161 #if defined(HAVE_SS7) 3203 newlaw = DAHDI_LAW_ALAW;
3206 newlaw = DAHDI_LAW_MULAW;
3213 #if defined(HAVE_SS7) 3214 static int sig_ss7_tone_to_dahditone(
enum sig_ss7_tone tone)
3218 return DAHDI_TONE_RINGTONE;
3220 return DAHDI_TONE_STUTTER;
3222 return DAHDI_TONE_CONGESTION;
3224 return DAHDI_TONE_DIALTONE;
3226 return DAHDI_TONE_DIALRECALL;
3228 return DAHDI_TONE_INFO;
3230 return DAHDI_TONE_BUSY;
3237 #if defined(HAVE_SS7) 3238 static int my_ss7_play_tone(
void *pvt,
enum sig_ss7_tone tone)
3242 return tone_zone_play_tone(p->
subs[
SUB_REAL].
dfd, sig_ss7_tone_to_dahditone(tone));
3246 #if defined(HAVE_SS7) 3254 .set_loopback = my_ss7_set_loopback,
3256 .new_ast_channel = my_new_ss7_ast_channel,
3257 .play_tone = my_ss7_play_tone,
3259 .handle_link_exception = my_handle_link_exception,
3263 .set_digital = my_set_digital,
3264 .set_inservice = my_set_inservice,
3265 .set_locallyblocked = my_set_locallyblocked,
3266 .set_remotelyblocked = my_set_remotelyblocked,
3267 .set_callerid = my_set_callerid,
3268 .set_dnid = my_set_dnid,
3269 .open_media = my_pri_ss7_open_media,
3270 .find_linkset = my_ss7_find_linkset,
3342 #define gen_pvt_field_callback(type, field) \ 3343 static type my_get_##field(void *pvt) \ 3345 struct dahdi_pvt *p = pvt; \ 3353 #undef gen_pvt_field_callback 3423 .get_firstdigit_timeout = my_get_firstdigit_timeout,
3424 .get_matchdigit_timeout = my_get_matchdigit_timeout,
3425 .get_interdigit_timeout = my_get_interdigit_timeout,
3444 "Unable to get index for '%s' on channel %d (%s(), line %lu)\n",
3539 #if defined(HAVE_PRI) 3554 static void mfcr2_queue_for_destruction(
const struct dahdi_pvt *p)
3556 const struct dahdi_mfcr2 *r2link = p->mfcr2;
3557 struct r2link_entry *cur;
3560 if (r2link == &cur->mfcr2) {
3570 static int dahdi_r2_answer(
struct dahdi_pvt *p)
3576 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 3578 int wants_double_answer =
ast_true(double_answer) ? 1 : 0;
3579 if (!double_answer) {
3582 res = openr2_chan_answer_call(p->r2chan);
3583 }
else if (wants_double_answer) {
3584 res = openr2_chan_answer_call_with_mode(p->r2chan, OR2_ANSWER_DOUBLE);
3586 res = openr2_chan_answer_call_with_mode(p->r2chan, OR2_ANSWER_SIMPLE);
3589 res = openr2_chan_answer_call(p->r2chan);
3597 static openr2_calling_party_category_t dahdi_r2_get_channel_category(
struct ast_channel *c)
3599 openr2_calling_party_category_t cat;
3603 ast_debug(1,
"No MFC/R2 category specified for chan %s, using default %s\n",
3605 return p->mfcr2_category;
3607 if ((cat = openr2_proto_get_category(catstr)) == OR2_CALLING_PARTY_CATEGORY_UNKNOWN) {
3608 ast_log(
LOG_WARNING,
"Invalid category specified '%s' for chan %s, using default %s\n",
3609 catstr,
ast_channel_name(c), openr2_proto_get_category_string(p->mfcr2_category));
3610 return p->mfcr2_category;
3612 ast_debug(1,
"Using category %s\n", catstr);
3616 static void dahdi_r2_on_call_init(openr2_chan_t *r2chan)
3618 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3627 ast_log(
LOG_ERROR,
"Collision of calls on chan %d detected!.\n", openr2_chan_get_number(r2chan));
3637 p->mfcr2_ani_index =
'\0';
3638 p->mfcr2_dnis_index =
'\0';
3639 p->mfcr2_dnis_matched = 0;
3640 p->mfcr2_answer_pending = 0;
3641 p->mfcr2_call_accepted = 0;
3643 ast_verbose(
"New MFC/R2 call detected on chan %d.\n", openr2_chan_get_number(r2chan));
3646 static void dahdi_r2_on_hardware_alarm(openr2_chan_t *r2chan,
int alarm)
3649 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3654 if (res == DAHDI_ALARM_NOTOPEN) {
3655 mfcr2_queue_for_destruction(p);
3664 static void dahdi_r2_on_os_error(openr2_chan_t *r2chan,
int errorcode)
3666 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3668 ast_log(
LOG_ERROR,
"OS error on chan %d: %s\n", openr2_chan_get_number(r2chan), strerror(errorcode));
3671 if (errorcode == ENODEV) {
3672 struct dahdi_mfcr2 *r2link = p->mfcr2;
3681 static void dahdi_r2_on_protocol_error(openr2_chan_t *r2chan, openr2_protocol_error_t reason)
3683 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3684 ast_log(
LOG_ERROR,
"MFC/R2 protocol error on chan %d: %s\n", openr2_chan_get_number(r2chan), openr2_proto_get_error(reason));
3694 static void dahdi_r2_disconnect_call(
struct dahdi_pvt *p, openr2_call_disconnect_cause_t cause)
3696 if (openr2_chan_disconnect_call(p->r2chan, cause)) {
3697 ast_log(
LOG_NOTICE,
"Bad! failed to disconnect call on channel %d with reason %s, hope for the best!\n",
3698 p->
channel, openr2_proto_get_disconnect_string(cause));
3700 openr2_chan_set_idle(p->r2chan);
3707 static void dahdi_r2_on_call_offered(openr2_chan_t *r2chan,
const char *ani,
const char *dnis, openr2_calling_party_category_t category)
3713 ast_verbose(
"MFC/R2 call offered on chan %d. ANI = %s, DNIS = %s, Category = %s\n",
3714 openr2_chan_get_number(r2chan), ani ? ani :
"(restricted)", dnis,
3715 openr2_proto_get_category_string(category));
3716 p = openr2_chan_get_client_data(r2chan);
3718 if (!p->mfcr2_allow_collect_calls && category == OR2_CALLING_PARTY_CATEGORY_COLLECT_CALL) {
3720 dahdi_r2_disconnect_call(p, OR2_CAUSE_COLLECT_CALL_REJECTED);
3721 goto dahdi_r2_on_call_offered_cleanup;
3724 p->mfcr2_recvd_category = category;
3727 ast_debug(1,
"No CID allowed in configuration, CID is being cleared!\n");
3732 if (p->
immediate || !openr2_context_get_max_dnis(openr2_chan_get_context(r2chan))) {
3733 ast_debug(1,
"Setting exten => s because of immediate or 0 DNIS configured\n");
3739 ast_log(
LOG_NOTICE,
"MFC/R2 call on channel %d requested non-existent extension '%s' in context '%s'. Rejecting call.\n",
3741 dahdi_r2_disconnect_call(p, OR2_CAUSE_UNALLOCATED_NUMBER);
3742 goto dahdi_r2_on_call_offered_cleanup;
3744 if (!p->mfcr2_accept_on_offer) {
3751 goto dahdi_r2_on_call_offered_cleanup;
3754 dahdi_r2_disconnect_call(p, OR2_CAUSE_OUT_OF_ORDER);
3755 }
else if (p->mfcr2_charge_calls) {
3756 ast_debug(1,
"Accepting MFC/R2 call with charge on chan %d\n", p->
channel);
3757 openr2_chan_accept_call(r2chan, OR2_CALL_WITH_CHARGE);
3759 ast_debug(1,
"Accepting MFC/R2 call with no charge on chan %d\n", p->
channel);
3760 openr2_chan_accept_call(r2chan, OR2_CALL_NO_CHARGE);
3763 dahdi_r2_on_call_offered_cleanup:
3767 static void dahdi_r2_on_call_end(openr2_chan_t *r2chan)
3769 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3776 static void dahdi_r2_on_call_accepted(openr2_chan_t *r2chan, openr2_call_mode_t mode)
3782 p = openr2_chan_get_client_data(r2chan);
3784 p->mfcr2_call_accepted = 1;
3786 if (OR2_DIR_BACKWARD == openr2_chan_get_direction(r2chan)) {
3787 ast_verbose(
"MFC/R2 call has been accepted on backward channel %d\n", openr2_chan_get_number(r2chan));
3792 if (!p->mfcr2_accept_on_offer) {
3793 openr2_chan_disable_read(r2chan);
3794 if (p->mfcr2_answer_pending) {
3795 ast_debug(1,
"Answering MFC/R2 call after accepting it on chan %d\n", openr2_chan_get_number(r2chan));
3798 goto dahdi_r2_on_call_accepted_cleanup;
3804 openr2_chan_disable_read(r2chan);
3805 goto dahdi_r2_on_call_accepted_cleanup;
3809 dahdi_r2_disconnect_call(p, OR2_CAUSE_OUT_OF_ORDER);
3810 goto dahdi_r2_on_call_accepted_cleanup;
3817 openr2_chan_disable_read(r2chan);
3819 dahdi_r2_on_call_accepted_cleanup:
3823 static void dahdi_r2_on_call_answered(openr2_chan_t *r2chan)
3825 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3826 ast_verbose(
"MFC/R2 call has been answered on channel %d\n", openr2_chan_get_number(r2chan));
3830 static void dahdi_r2_on_call_read(openr2_chan_t *r2chan,
const unsigned char *
buf,
int buflen)
3835 static int dahdi_r2_cause_to_ast_cause(openr2_call_disconnect_cause_t cause)
3838 case OR2_CAUSE_BUSY_NUMBER:
3840 case OR2_CAUSE_NETWORK_CONGESTION:
3842 case OR2_CAUSE_OUT_OF_ORDER:
3844 case OR2_CAUSE_UNALLOCATED_NUMBER:
3846 case OR2_CAUSE_NO_ANSWER:
3848 case OR2_CAUSE_NORMAL_CLEARING:
3850 case OR2_CAUSE_UNSPECIFIED:
3856 static void dahdi_r2_on_call_disconnect(openr2_chan_t *r2chan, openr2_call_disconnect_cause_t cause)
3858 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3861 int datalen =
sizeof(*cause_code);
3863 ast_verbose(
"MFC/R2 call disconnected on channel %d\n", openr2_chan_get_number(r2chan));
3868 dahdi_r2_disconnect_call(p, OR2_CAUSE_NORMAL_CLEARING);
3872 snprintf(cause_str,
sizeof(cause_str),
"R2 DISCONNECT (%s)", openr2_proto_get_disconnect_string(cause));
3873 datalen += strlen(cause_str);
3875 memset(cause_code, 0, datalen);
3876 cause_code->
ast_cause = dahdi_r2_cause_to_ast_cause(cause);
3888 }
else if (openr2_chan_get_direction(r2chan) == OR2_DIR_FORWARD) {
3891 case OR2_CAUSE_BUSY_NUMBER:
3894 case OR2_CAUSE_NETWORK_CONGESTION:
3895 case OR2_CAUSE_OUT_OF_ORDER:
3896 case OR2_CAUSE_UNALLOCATED_NUMBER:
3897 case OR2_CAUSE_NO_ANSWER:
3898 case OR2_CAUSE_UNSPECIFIED:
3899 case OR2_CAUSE_NORMAL_CLEARING:
3914 static void dahdi_r2_write_log(openr2_log_level_t level,
char *logmessage)
3917 case OR2_LOG_NOTICE:
3920 case OR2_LOG_WARNING:
3926 case OR2_LOG_STACK_TRACE:
3927 case OR2_LOG_MF_TRACE:
3928 case OR2_LOG_CAS_TRACE:
3930 case OR2_LOG_EX_DEBUG:
3940 static void dahdi_r2_on_line_blocked(openr2_chan_t *r2chan)
3942 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3946 ast_log(
LOG_NOTICE,
"Far end blocked on chan %d\n", openr2_chan_get_number(r2chan));
3949 static void dahdi_r2_on_line_idle(openr2_chan_t *r2chan)
3951 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3955 ast_log(
LOG_NOTICE,
"Far end unblocked on chan %d\n", openr2_chan_get_number(r2chan));
3958 static void dahdi_r2_on_context_log(openr2_context_t *r2context, openr2_log_level_t level,
const char *fmt, va_list ap)
3959 __attribute__((
format (printf, 3, 0)));
3960 static void dahdi_r2_on_context_log(openr2_context_t *r2context, openr2_log_level_t level,
const char *fmt, va_list ap)
3962 #define CONTEXT_TAG "Context - " 3964 char completemsg[
sizeof(logmsg) +
sizeof(CONTEXT_TAG) - 1];
3965 vsnprintf(logmsg,
sizeof(logmsg), fmt, ap);
3966 snprintf(completemsg,
sizeof(completemsg), CONTEXT_TAG
"%s", logmsg);
3967 dahdi_r2_write_log(level, completemsg);
3971 static void dahdi_r2_on_chan_log(openr2_chan_t *r2chan, openr2_log_level_t level,
const char *fmt, va_list ap)
3972 __attribute__((
format (printf, 3, 0)));
3973 static void dahdi_r2_on_chan_log(openr2_chan_t *r2chan, openr2_log_level_t level,
const char *fmt, va_list ap)
3975 #define CHAN_TAG "Chan " 3977 char completemsg[
sizeof(logmsg) +
sizeof(CHAN_TAG) - 1];
3978 vsnprintf(logmsg,
sizeof(logmsg), fmt, ap);
3979 snprintf(completemsg,
sizeof(completemsg), CHAN_TAG
"%d - %s", openr2_chan_get_number(r2chan), logmsg);
3980 dahdi_r2_write_log(level, completemsg);
3983 static int dahdi_r2_on_dnis_digit_received(openr2_chan_t *r2chan,
char digit)
3985 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
3992 p->mfcr2_dnis_index++;
3993 p->
exten[p->mfcr2_dnis_index] = 0;
3994 p->
rdnis[p->mfcr2_dnis_index] = 0;
3996 if ((p->mfcr2_dnis_matched ||
4005 static void dahdi_r2_on_ani_digit_received(openr2_chan_t *r2chan,
char digit)
4007 struct dahdi_pvt *p = openr2_chan_get_client_data(r2chan);
4010 p->mfcr2_ani_index++;
4011 p->
cid_num[p->mfcr2_ani_index] = 0;
4012 p->
cid_name[p->mfcr2_ani_index] = 0;
4015 static void dahdi_r2_on_billing_pulse_received(openr2_chan_t *r2chan)
4017 ast_verbose(
"MFC/R2 billing pulse received on channel %d\n", openr2_chan_get_number(r2chan));
4020 static openr2_event_interface_t dahdi_r2_event_iface = {
4021 .on_call_init = dahdi_r2_on_call_init,
4022 .on_call_offered = dahdi_r2_on_call_offered,
4023 .on_call_accepted = dahdi_r2_on_call_accepted,
4024 .on_call_answered = dahdi_r2_on_call_answered,
4025 .on_call_disconnect = dahdi_r2_on_call_disconnect,
4026 .on_call_end = dahdi_r2_on_call_end,
4027 .on_call_read = dahdi_r2_on_call_read,
4028 .on_hardware_alarm = dahdi_r2_on_hardware_alarm,
4029 .on_os_error = dahdi_r2_on_os_error,
4030 .on_protocol_error = dahdi_r2_on_protocol_error,
4031 .on_line_blocked = dahdi_r2_on_line_blocked,
4032 .on_line_idle = dahdi_r2_on_line_idle,
4034 .on_context_log = (openr2_handle_context_logging_func)dahdi_r2_on_context_log,
4035 .on_dnis_digit_received = dahdi_r2_on_dnis_digit_received,
4036 .on_ani_digit_received = dahdi_r2_on_ani_digit_received,
4038 .on_billing_pulse_received = dahdi_r2_on_billing_pulse_received
4041 static inline int16_t dahdi_r2_alaw_to_linear(uint8_t sample)
4046 static inline uint8_t dahdi_r2_linear_to_alaw(
int sample)
4051 static openr2_transcoder_interface_t dahdi_r2_transcode_iface = {
4052 dahdi_r2_alaw_to_linear,
4053 dahdi_r2_linear_to_alaw
4064 ast_debug(1,
"Swapping %d and %d\n", a, b);
4094 for (x = 0; x < strlen(fn); x++) {
4095 if (!isdigit(fn[x])) {
4106 fn =
"/dev/dahdi/channel";
4108 fd = open(fn, O_RDWR | O_NONBLOCK);
4114 if (ioctl(fd, DAHDI_SPECIFY, &chan)) {
4123 if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs) == -1) {
4142 chan_pvt->
subs[sub_num].
dfd = -1;
4145 #if defined(HAVE_PRI) 4146 static void dahdi_close_pri_fd(
struct dahdi_pri *pri,
int fd_num)
4149 pri->pri.fds[fd_num] = -1;
4153 #if defined(HAVE_SS7) 4154 static void dahdi_close_ss7_fd(
struct dahdi_ss7 *ss7,
int fd_num)
4157 ss7->ss7.fds[fd_num] = -1;
4163 return ioctl(dfd, DAHDI_SETLINEAR, &linear);
4169 struct dahdi_bufferinfo bi;
4182 res = ioctl(p->
subs[x].
dfd, DAHDI_GET_BUFINFO, &bi);
4187 res = ioctl(p->
subs[x].
dfd, DAHDI_SET_BUFINFO, &bi);
4224 return DAHDI_TONE_DTMF_BASE + (digit -
'0');
4225 else if (digit >=
'A' && digit <=
'D')
4226 return DAHDI_TONE_DTMF_A + (digit -
'A');
4227 else if (digit >=
'a' && digit <=
'd')
4228 return DAHDI_TONE_DTMF_A + (digit -
'a');
4229 else if (digit ==
'*')
4230 return DAHDI_TONE_DTMF_s;
4231 else if (digit ==
'#')
4232 return DAHDI_TONE_DTMF_p;
4271 char dial_str[] = {
'T',
digit,
'\0' };
4282 dtmf = DAHDI_FLUSH_WRITE;
4285 ast_log(
LOG_WARNING,
"Unable to flush the DAHDI write buffer to send DTMF on channel %d: %s\n",
4289 ast_debug(1,
"Channel %s started VLDTMF digit '%c'\n",
4324 ast_debug(1,
"Channel %s ending VLDTMF digit '%c'\n",
4350 "Hook Transition Complete",
4355 "Polarity Reversal",
4363 { DAHDI_ALARM_RED,
"Red Alarm" },
4364 { DAHDI_ALARM_YELLOW,
"Yellow Alarm" },
4365 { DAHDI_ALARM_BLUE,
"Blue Alarm" },
4366 { DAHDI_ALARM_RECOVER,
"Recovering" },
4367 { DAHDI_ALARM_LOOPBACK,
"Loopback" },
4368 { DAHDI_ALARM_NOTOPEN,
"Not Open" },
4369 { DAHDI_ALARM_NONE,
"None" },
4379 return alm ?
"Unknown Alarm" :
"No Alarm";
4384 static char buf[256];
4387 sprintf(buf,
"Event %d", event);
4393 static char buf[256];
4396 return "E & M Immediate";
4398 return "E & M Wink";
4402 return "Feature Group D (DTMF)";
4404 return "Feature Group D (MF)";
4406 return "Feature Groud D (MF) Tandem Access";
4408 return "Feature Group B (MF)";
4412 return "FGC/CAMA (Dialpulse)";
4414 return "FGC/CAMA (MF)";
4416 return "FXS Loopstart";
4418 return "FXS Groundstart";
4420 return "FXS Kewlstart";
4422 return "FXO Loopstart";
4424 return "FXO Groundstart";
4426 return "FXO Kewlstart";
4430 return "ISDN BRI Point to Point";
4432 return "ISDN BRI Point to MultiPoint";
4438 return "SF (Tone) Immediate";
4440 return "SF (Tone) Wink";
4442 return "SF (Tone) with Feature Group D (DTMF)";
4444 return "SF (Tone) with Feature Group D (MF)";
4446 return "SF (Tone) with Feature Group B (MF)";
4450 snprintf(buf,
sizeof(buf),
"Unknown signalling %d", sig);
4455 #define sig2str dahdi_sig2str 4461 struct dahdi_confinfo zi;
4463 memset(&zi, 0,
sizeof(zi));
4466 if (slavechannel > 0) {
4468 zi.confmode = DAHDI_CONF_DIGITALMON;
4469 zi.confno = slavechannel;
4473 zi.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER |
4474 DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER;
4476 zi.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
4479 if ((zi.confno == c->
curconf.confno) && (zi.confmode == c->
curconf.confmode))
4483 if (ioctl(c->
dfd, DAHDI_SETCONF, &zi)) {
4487 if (slavechannel < 1) {
4508 struct dahdi_confinfo zi;
4515 memset(&zi, 0,
sizeof(zi));
4516 if (ioctl(c->
dfd, DAHDI_SETCONF, &zi)) {
4533 for (x = 0; x < 3; x++) {
4541 if (useslavenative) {
4560 else if (slave->
law != p->
law) {
4566 return useslavenative;
4574 struct dahdi_confinfo zi;
4576 memset(&zi, 0,
sizeof(zi));
4592 for (x = 0; x < 3; x++) {
4635 ast_debug(1,
"Updated conferencing on %d, with %d conference users\n", p->
channel, needconf);
4644 ast_debug(1,
"Echo cancellation already on\n");
4648 ast_debug(1,
"Echo cancellation isn't required on digital connection\n");
4652 #if defined(HAVE_PRI) || defined(HAVE_SS7) 4654 #if defined(HAVE_PRI) 4665 #if defined(HAVE_SS7) 4674 "Unable to enable audio mode on channel %d (%s)\n",
4690 ast_debug(1,
"No echo cancellation requested\n");
4706 ast_debug(1,
"No echo training requested\n");
4715 struct dahdi_echocanparams ecp = { .tap_length = 0 };
4730 struct dahdi_hwgain hwgain;
4732 hwgain.newgain = gain * 10.0;
4733 hwgain.tx = tx_direction;
4734 return ioctl(fd, DAHDI_SET_HWGAIN, &hwgain) < 0;
4741 float shallow, steep;
4742 float max = SHRT_MAX;
4744 neg = (sample < 0 ? -1 : 1);
4746 shallow = neg*(max-max/drc)+(
float)sample/drc;
4747 if (fabsf(steep) < fabsf(shallow)) {
4758 static void fill_txgain(
struct dahdi_gains *g,
float gain,
float drc,
int law)
4763 float linear_gain = pow(10.0, gain / 20.0);
4766 case DAHDI_LAW_ALAW:
4767 for (j = 0; j <
ARRAY_LEN(g->txgain); j++) {
4773 k = (float)k * linear_gain;
4776 }
else if (k < -32768) {
4785 case DAHDI_LAW_MULAW:
4786 for (j = 0; j <
ARRAY_LEN(g->txgain); j++) {
4792 k = (float)k * linear_gain;
4795 }
else if (k < -32768) {
4808 static void fill_rxgain(
struct dahdi_gains *g,
float gain,
float drc,
int law)
4812 float linear_gain = pow(10.0, gain / 20.0);
4815 case DAHDI_LAW_ALAW:
4816 for (j = 0; j <
ARRAY_LEN(g->rxgain); j++) {
4822 k = (float)k * linear_gain;
4825 }
else if (k < -32768) {
4834 case DAHDI_LAW_MULAW:
4835 for (j = 0; j <
ARRAY_LEN(g->rxgain); j++) {
4841 k = (float)k * linear_gain;
4844 }
else if (k < -32768) {
4858 struct dahdi_gains g;
4861 memset(&g, 0,
sizeof(g));
4862 res = ioctl(fd, DAHDI_GETGAINS, &g);
4870 return ioctl(fd, DAHDI_SETGAINS, &g);
4875 struct dahdi_gains g;
4878 memset(&g, 0,
sizeof(g));
4879 res = ioctl(fd, DAHDI_GETGAINS, &g);
4887 return ioctl(fd, DAHDI_SETGAINS, &g);
4890 static int set_actual_gain(
int fd,
float rxgain,
float txgain,
float rxdrc,
float txdrc,
int law)
4927 res = ioctl(fd, DAHDI_HOOK, &x);
4930 if (
errno == EINPROGRESS)
4944 #if defined(HAVE_PRI) || defined(HAVE_SS7) 4946 #if defined(HAVE_PRI) 4954 #if defined(HAVE_SS7) 4978 struct dahdi_confinfo c;
4991 memset(&c, 0,
sizeof(c));
4992 c.confmode = DAHDI_CONF_NORMAL;
4998 ast_debug(1,
"Disabled conferencing\n");
5012 ast_debug(1,
"Restored conferencing\n");
5064 if (
errno == EAGAIN)
5143 #if defined(HAVE_PRI) 5150 subaddr = strchr(p->
exten,
':');
5179 x = DAHDI_FLUSH_READ | DAHDI_FLUSH_WRITE;
5194 (p->
law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW);
5200 #if defined(HAVE_SS7) 5232 openr2_calling_party_category_t chancat;
5251 chancat = dahdi_r2_get_channel_category(ast);
5252 callres = openr2_chan_make_call(p->r2chan, l, (c + p->
stripmsd), chancat);
5253 if (-1 == callres) {
5258 p->mfcr2_call_accepted = 0;
5259 p->mfcr2_progress_sent = 0;
5289 for (cur = iflist; cur; cur = cur->
next) {
5337 }
else if (iflist == pvt) {
5345 }
else if (ifend == pvt) {
5356 #if defined(HAVE_PRI) 5411 #if defined(HAVE_PRI) 5451 #if defined(HAVE_PRI) 5461 static void dahdi_unlink_pri_pvt(
struct dahdi_pvt *pvt)
5472 for (idx = 0; idx < pri->
numchans; ++idx) {
5483 #if defined(HAVE_SS7) 5493 static void dahdi_unlink_ss7_pvt(
struct dahdi_pvt *pvt)
5504 for (idx = 0; idx < ss7->
numchans; ++idx) {
5515 #if defined(HAVE_OPENR2) 5524 static void dahdi_unlink_mfcr2_pvt(
struct dahdi_pvt *pvt)
5527 struct dahdi_mfcr2 *mfcr2;
5528 int should_destroy_link = 0;
5533 openr2_chan_disable_read(pvt->r2chan);
5537 for (idx = 0; idx < mfcr2->numchans; ++idx) {
5538 if (mfcr2->pvts[idx] == pvt) {
5539 ast_debug(1,
"Removing MFC/R2 channel %d from the mfcr2 link\n", pvt->
channel);
5540 mfcr2->pvts[idx] =
NULL;
5541 mfcr2->live_chans--;
5545 if (!mfcr2->live_chans) {
5546 ast_debug(1,
"MFC/R2 link is now empty\n");
5547 should_destroy_link = 1;
5551 if (should_destroy_link) {
5552 ast_debug(1,
"MFC/R2 link is now empty\n");
5553 mfcr2_queue_for_destruction(pvt);
5581 #if defined(HAVE_PRI) 5582 dahdi_unlink_pri_pvt(p);
5584 #if defined(HAVE_SS7) 5585 dahdi_unlink_ss7_pvt(p);
5587 #if defined(HAVE_OPENR2) 5588 dahdi_unlink_mfcr2_pvt(p);
5596 #if defined(HAVE_PRI) 5597 case DAHDI_IFLIST_NO_B_CHAN:
5599 dahdi_nobch_extract(p->pri, p);
5610 #if defined(HAVE_PRI) 5615 #if defined(HAVE_SS7) 5658 for (i = 0; i < 3; i++) {
5670 #if defined(HAVE_PRI) 5686 #if defined(HAVE_PRI_SERVICE_MESSAGES) 5688 char db_chan_name[20];
5693 snprintf(db_chan_name,
sizeof(db_chan_name),
"%s/%d:%d", dahdi_db, p->
span, chan);
5694 if (!
ast_db_get(db_chan_name, SRVST_DBKEY, db_answer,
sizeof(db_answer))) {
5695 sscanf(db_answer,
"%1c:%30d", &state, &why);
5705 ast_verb(3,
"Unregistered channel %d\n", chan);
5710 #if defined(HAVE_PRI) 5713 if (!pris[span].dchannels[0]) {
5716 pri = &pris[
span].pri;
5729 #if defined(HAVE_PRI) 5730 static char *dahdi_send_keypad_facility_app =
"DAHDISendKeypadFacility";
5732 static int dahdi_send_keypad_facility_exec(
struct ast_channel *chan,
const char *digits)
5738 ast_debug(1,
"No digit string sent to application!\n");
5745 ast_debug(1,
"Unable to find technology private\n");
5755 #if defined(HAVE_PRI) 5756 #if defined(HAVE_PRI_PROG_W_CAUSE) 5757 static char *dahdi_send_callrerouting_facility_app =
"DAHDISendCallreroutingFacility";
5759 static int dahdi_send_callrerouting_facility_exec(
struct ast_channel *chan,
const char *data)
5772 ast_debug(1,
"No data sent to application!\n");
5776 ast_debug(1,
"Only DAHDI technology accepted!\n");
5781 ast_debug(1,
"Unable to find technology private\n");
5788 ast_debug(1,
"callrerouting attempted on non-ISDN channel %s\n",
5797 ast_log(
LOG_WARNING,
"callrerouting facility requires at least destination number argument\n");
5802 ast_log(
LOG_WARNING,
"Callrerouting Facility without original called number argument\n");
5807 ast_log(
LOG_NOTICE,
"Callrerouting Facility without diversion reason argument, defaulting to unknown\n");
5826 #if defined(HAVE_OPENR2) 5827 static const char *
const dahdi_accept_r2_call_app =
"DAHDIAcceptR2Call";
5829 static int dahdi_accept_r2_call_exec(
struct ast_channel *chan,
const char *data)
5832 openr2_call_mode_t accept_mode;
5842 ast_debug(1,
"No data sent to application!\n");
5847 ast_debug(1,
"Only DAHDI technology accepted!\n");
5853 ast_debug(1,
"Unable to find technology private!\n");
5861 ast_log(
LOG_WARNING,
"DAHDIAcceptR2Call requires 'yes' or 'no' for the charge parameter\n");
5866 if (!p->mfcr2 || !p->mfcr2call) {
5872 if (p->mfcr2_call_accepted) {
5877 accept_mode =
ast_true(
args.charge) ? OR2_CALL_WITH_CHARGE : OR2_CALL_NO_CHARGE;
5878 if (openr2_chan_accept_call(p->r2chan, accept_mode)) {
5889 while (maxloops > 0) {
5918 if (p->mfcr2_call_accepted) {
5920 ast_debug(1,
"Accepted MFC/R2 call!\n");
5931 static openr2_call_disconnect_cause_t dahdi_ast_cause_to_r2_cause(
int cause)
5933 openr2_call_disconnect_cause_t r2cause = OR2_CAUSE_NORMAL_CLEARING;
5938 r2cause = OR2_CAUSE_BUSY_NUMBER;
5943 r2cause = OR2_CAUSE_NETWORK_CONGESTION;
5947 r2cause = OR2_CAUSE_UNALLOCATED_NUMBER;
5952 r2cause = OR2_CAUSE_OUT_OF_ORDER;
5957 r2cause = OR2_CAUSE_NO_ANSWER;
5961 r2cause = OR2_CAUSE_NORMAL_CLEARING;
5964 ast_debug(1,
"ast cause %d resulted in openr2 cause %d/%s\n",
5965 cause, r2cause, openr2_proto_get_disconnect_string(r2cause));
5974 struct dahdi_bufferinfo bi = {
5982 if ((bpres = ioctl(p->
subs[
SUB_REAL].
dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
5999 struct dahdi_params par;
6025 #if defined(HAVE_PRI) 6088 #if defined(HAVE_SS7) 6167 ast_debug(1,
"Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
6184 ast_debug(1,
"Normal call hung up with both three way call and a call waiting call in place?\n");
6187 ast_debug(1,
"We were flipped over to the callwait, moving back and unowning.\n");
6194 ast_debug(1,
"We were in the threeway and have a callwait still. Ditching the threeway.\n");
6200 ast_debug(1,
"Call was complete, setting owner to former third call\n");
6204 ast_debug(1,
"Call was incomplete, setting owner to NULL\n");
6223 ast_debug(1,
"Call was complete, setting owner to former third call\n");
6227 ast_debug(1,
"Call was incomplete, setting owner to NULL\n");
6288 if (p->mfcr2 && p->mfcr2call && openr2_chan_get_direction(p->r2chan) != OR2_DIR_STOPPED) {
6291 if (openr2_chan_get_direction(p->r2chan) == OR2_DIR_BACKWARD && p->mfcr2_forced_release) {
6292 dahdi_r2_disconnect_call(p, OR2_CAUSE_FORCED_RELEASE);
6295 int r2cause_user = r2causestr ? atoi(r2causestr) : 0;
6296 openr2_call_disconnect_cause_t r2cause = r2cause_user ? dahdi_ast_cause_to_r2_cause(r2cause_user)
6298 dahdi_r2_disconnect_call(p, r2cause);
6300 }
else if (p->mfcr2call) {
6326 memset(&par, 0,
sizeof(par));
6331 ast_debug(1,
"Hanging up channel %d, offhook = %d\n", p->
channel, par.rxisoffhook);
6334 if ((par.rxisoffhook) && (!(p->
radio || (p->
oprmode < 0))))
6432 #if defined(HAVE_PRI) 6437 #if defined(HAVE_SS7) 6444 if (!p->mfcr2_call_accepted) {
6447 p->mfcr2_answer_pending = 1;
6448 if (p->mfcr2_charge_calls) {
6449 ast_debug(1,
"Accepting MFC/R2 call with charge before answering on chan %d\n", p->
channel);
6450 openr2_chan_accept_call(p->r2chan, OR2_CALL_WITH_CHARGE);
6452 ast_debug(1,
"Accepting MFC/R2 call with no charge before answering on chan %d\n", p->
channel);
6453 openr2_chan_accept_call(p->r2chan, OR2_CALL_NO_CHARGE);
6489 int val = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE;
6510 if (!p || !data || (*datalen < 1)) {
6527 #if defined(HAVE_PRI) 6528 #if defined(HAVE_PRI_CCSS) 6556 if (!p || !data || (datalen < 1)) {
6563 scp = (
signed char *) data;
6572 scp = (
signed char *) data;
6610 ast_debug(1,
"Set option TDD MODE, value: %s(%d) on %s\n",
6615 unsigned char mybuf[41000];
6617 int size, res, fd,
len;
6618 struct pollfd fds[1];
6621 memset(buf, 0x7f,
sizeof(mybuf));
6637 fds[0].events = POLLPRI | POLLOUT;
6639 res = poll(fds, 1, -1);
6645 if (fds[0].revents & POLLPRI)
6647 if (!(fds[0].revents & POLLOUT)) {
6651 res = write(fd, buf, size);
6653 if (res == -1)
return -1;
6677 ast_debug(1,
"Set option RELAX DTMF, value: %s(%d) on %s\n",
6682 #if defined(HAVE_PRI) 6703 oprmode = (
struct oprmode *) data;
6722 ast_debug(1,
"Set Operator Services mode, value: %d on %s/%s\n",
6775 if (!strcasecmp(data,
"rxgain")) {
6777 snprintf(buf, len,
"%f", p->
rxgain);
6779 }
else if (!strcasecmp(data,
"txgain")) {
6781 snprintf(buf, len,
"%f", p->
txgain);
6783 }
else if (!strcasecmp(data,
"dahdi_channel")) {
6785 snprintf(buf, len,
"%d", p->
channel);
6787 }
else if (!strcasecmp(data,
"dahdi_span")) {
6789 snprintf(buf, len,
"%d", p->
span);
6791 }
else if (!strcasecmp(data,
"dahdi_group")) {
6793 snprintf(buf, len,
"%llu", p->
group);
6795 }
else if (!strcasecmp(data,
"dahdi_type")) {
6798 #if defined(HAVE_OPENR2) 6803 #if defined(HAVE_PRI) 6811 #if defined(HAVE_SS7) 6822 #if defined(HAVE_PRI) 6823 #if defined(HAVE_PRI_REVERSE_CHARGE) 6824 }
else if (!strcasecmp(data,
"reversecharge")) {
6828 snprintf(buf, len,
"%d", ((
struct sig_pri_chan *) p->
sig_pvt)->reverse_charging_indication);
6837 #if defined(HAVE_PRI_SETUP_KEYPAD) 6838 }
else if (!strcasecmp(data,
"keypad_digits")) {
6852 }
else if (!strcasecmp(data,
"no_media_path")) {
6881 char policy_str[21] =
"";
6883 if ((res = sscanf(parse,
"%30d,%20s", num_buffers, policy_str)) != 2) {
6887 if (*num_buffers < 0) {
6891 if (!strcasecmp(policy_str,
"full")) {
6892 *policy = DAHDI_POLICY_WHEN_FULL;
6893 }
else if (!strcasecmp(policy_str,
"immediate")) {
6894 *policy = DAHDI_POLICY_IMMEDIATE;
6895 #if defined(HAVE_DAHDI_HALF_FULL) 6896 }
else if (!strcasecmp(policy_str,
"half")) {
6897 *policy = DAHDI_POLICY_HALF_FULL;
6917 if (!strcasecmp(data,
"buffers")) {
6918 int num_bufs, policy;
6921 struct dahdi_bufferinfo bi = {
6922 .txbufpolicy = policy,
6923 .rxbufpolicy = policy,
6925 .numbufs = num_bufs,
6929 if ((bpres = ioctl(p->
subs[
SUB_REAL].
dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
6937 }
else if (!strcasecmp(data,
"echocan_mode")) {
6938 if (!strcasecmp(value,
"on")) {
6942 }
else if (!strcasecmp(value,
"off")) {
6946 #ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE 6947 }
else if (!strcasecmp(value,
"fax")) {
6958 }
else if (!strcasecmp(value,
"voice")) {
6971 ast_log(
LOG_WARNING,
"Unsupported value '%s' provided for '%s' item.\n", value, data);
6999 if (!slave || (master->
slaves[x] == slave)) {
7040 if (!slave || !master) {
7045 if (!master->
slaves[x]) {
7046 master->
slaves[x] = slave;
7050 if (x >= MAX_SLAVES) {
7052 master->
slaves[MAX_SLAVES - 1] = slave;
7069 if (p->
owner == oldchan) {
7072 for (x = 0; x < 3; x++) {
7082 #if defined(HAVE_PRI) 7086 #if defined(HAVE_SS7) 7155 ast_verb(3,
"TRANSFERRING %s to %s\n",
7180 struct dahdi_confinfo ci;
7184 memset(&ci, 0,
sizeof(ci));
7193 ast_verb(3,
"Avoiding 3-way call when in an external conference\n");
7207 struct dahdi_spaninfo zi;
7208 struct dahdi_params params;
7210 memset(&zi, 0,
sizeof(zi));
7211 zi.spanno = p->
span;
7214 if (zi.alarms != DAHDI_ALARM_NONE)
7222 memset(¶ms, 0,
sizeof(params));
7223 if ((res = ioctl(p->
subs[
SUB_REAL].
dfd, DAHDI_GET_PARAMS, ¶ms)) >= 0)
7224 return params.chan_alarms;
7228 return DAHDI_ALARM_NONE;
7236 ast_debug(1,
"%s DTMF digit: 0x%02X '%c' on %s\n",
7253 *dest = &p->
subs[idx].
f;
7257 ast_debug(1,
"Got some DTMF, but it's for the CAS\n");
7266 *dest = &p->
subs[idx].
f;
7273 struct dahdi_bufferinfo bi = {
7280 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_SET_BUFINFO, &bi)) < 0) {
7318 ast_debug(1,
"Already in a fax extension, not redirecting\n");
7327 *dest = &p->
subs[idx].
f;
7337 "Alarm", alarm_txt);
7356 "Alarm", alarm_txt);
7366 const char *alarm_str;
7368 #if defined(HAVE_PRI) 7409 p->
subs[idx].
f.
src =
"dahdi_handle_event";
7411 f = &p->
subs[idx].
f;
7421 if (res & (DAHDI_EVENT_PULSEDIGIT | DAHDI_EVENT_DTMFUP)) {
7422 p->
pulsedial = (res & DAHDI_EVENT_PULSEDIGIT) ? 1 : 0;
7424 #if defined(HAVE_PRI) 7442 if (res & DAHDI_EVENT_DTMFDOWN) {
7443 ast_debug(1,
"DTMF Down '%c'\n", res & 0xff);
7444 #if defined(HAVE_PRI) 7459 return &p->
subs[idx].
f;
7463 case DAHDI_EVENT_EC_DISABLED:
7467 #ifdef HAVE_DAHDI_ECHOCANCEL_FAX_MODE 7468 case DAHDI_EVENT_TX_CED_DETECTED:
7469 ast_verb(3,
"Channel %d detected a CED tone towards the network.\n", p->
channel);
7471 case DAHDI_EVENT_RX_CED_DETECTED:
7472 ast_verb(3,
"Channel %d detected a CED tone from the network.\n", p->
channel);
7474 case DAHDI_EVENT_EC_NLP_DISABLED:
7475 ast_verb(3,
"Channel %d echo canceler disabled its NLP.\n", p->
channel);
7477 case DAHDI_EVENT_EC_NLP_ENABLED:
7478 ast_verb(3,
"Channel %d echo canceler enabled its NLP.\n", p->
channel);
7481 case DAHDI_EVENT_BITSCHANGED:
7487 openr2_chan_handle_cas(p->r2chan);
7493 case DAHDI_EVENT_PULSE_START:
7496 tone_zone_play_tone(p->
subs[idx].
dfd, -1);
7498 case DAHDI_EVENT_DIALCOMPLETE:
7500 #if defined(HAVE_PRI) 7505 if (ioctl(p->
subs[idx].
dfd, DAHDI_DIALING, &x) == -1) {
7506 ast_debug(1,
"DAHDI_DIALING ioctl failed on %s: %s\n",
7531 if (ioctl(p->
subs[idx].
dfd,DAHDI_DIALING,&x) == -1) {
7540 p->
dop.op = DAHDI_DIAL_OP_REPLACE;
7559 ast_debug(1,
"Done dialing, but waiting for progress detection before doing more...\n");
7584 case DAHDI_EVENT_ALARM:
7586 #if defined(HAVE_PRI) 7591 #if defined(HAVE_SS7) 7603 if (!p->pri || !p->pri->pri || pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0) {
7609 #if defined(HAVE_SS7) 7617 case DAHDI_EVENT_ONHOOK:
7646 ast_verb(3,
"Channel %d still has (callwait) call, ringing phone\n", p->
channel);
7661 unsigned int mssinceflash;
7672 if (p->
owner != ast) {
7682 ast_debug(1,
"Last flash was %u ms ago\n", mssinceflash);
7689 ast_debug(1,
"Looks like a bounced flash, hanging up both calls on %d\n", p->
channel);
7735 case DAHDI_EVENT_RINGOFFHOOK:
7764 int numchars = snprintf(p->
dop.dialstr,
sizeof(p->
dop.dialstr),
"M*0%s#", c);
7765 if (numchars >=
sizeof(p->
dop.dialstr)) {
7772 if (strlen(p->
dop.dialstr) > 4) {
7777 p->
dop.dialstr[strlen(p->
dop.dialstr)-2] =
'\0';
7786 return &p->
subs[idx].
f;
7818 p->
dop.dialstr[0] =
'\0';
7821 ast_debug(1,
"Sent FXO deferred digit string: %s\n", p->
dop.dialstr);
7826 p->
dop.dialstr[0] =
'\0';
7830 return &p->
subs[idx].
f;
7837 return &p->
subs[idx].
f;
7850 res = tone_zone_play_tone(p->
subs[
SUB_REAL].
dfd, DAHDI_TONE_DIALTONE);
7865 ast_debug(1,
"Setting IDLE polarity due " 7866 "to ring. Old polarity was %d\n",
7909 case DAHDI_EVENT_RINGBEGIN:
7920 case DAHDI_EVENT_RINGERON:
7922 case DAHDI_EVENT_NOALARM:
7924 #if defined(HAVE_PRI) 7929 #if defined(HAVE_SS7) 7940 case DAHDI_EVENT_WINKFLASH:
7942 if (p->
radio)
break;
7946 struct dahdi_params par;
7948 memset(&par, 0,
sizeof(par));
7951 if (!par.rxisoffhook)
7968 ast_debug(1,
"Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
8032 ast_debug(1,
"Flash when call not up or ringing\n");
8063 res = tone_zone_play_tone(p->
subs[
SUB_REAL].
dfd, DAHDI_TONE_DIALRECALL);
8071 res = tone_zone_play_tone(p->
subs[
SUB_REAL].
dfd, DAHDI_TONE_CONGESTION);
8087 ast_debug(1,
"Got flash with three way call up, dropping last call on %d\n", p->
channel);
8105 ast_verb(3,
"Building conference call with %s and %s\n",
8155 snprintf(p->
dop.dialstr,
sizeof(p->
dop.dialstr),
"M*%d%s#",
8164 ast_log(
LOG_WARNING,
"Received unexpected wink on channel of type SIG_FEATDMF_TA\n");
8181 p->
dop.dialstr[0] =
'\0';
8184 ast_debug(1,
"Sent deferred digit string: %s\n", p->
dop.dialstr);
8186 p->
dop.dialstr[0] =
'\0';
8192 case DAHDI_EVENT_HOOKCOMPLETE:
8210 p->
dop.dialstr[0] =
'\0';
8213 ast_debug(1,
"Sent deferred digit string: %s\n", p->
dop.dialstr);
8215 p->
dop.dialstr[0] =
'\0';
8216 p->
dop.op = DAHDI_DIAL_OP_REPLACE;
8226 ast_debug(1,
"Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->
channel);
8232 case DAHDI_EVENT_POLARITY:
8244 ast_debug(1,
"Answering on polarity switch!\n");
8259 ast_debug(1,
"Polarity Reversal event occured - DEBUG 1: channel %d, state %u, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64
"\n", p->
channel,
ast_channel_state(ast), p->
polarity, p->
answeronpolarityswitch, p->
hanguponpolarityswitch, p->
polarityonanswerdelay,
ast_tvdiff_ms(
ast_tvnow(), p->
polaritydelaytv) );
8262 ast_debug(1,
"Polarity Reversal detected and now Hanging up on channel %d\n", p->
channel);
8273 ast_debug(1,
"Polarity Reversal event occured - DEBUG 2: channel %d, state %u, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %" PRIi64
"\n", p->
channel,
ast_channel_state(ast), p->
polarity, p->
answeronpolarityswitch, p->
hanguponpolarityswitch, p->
polarityonanswerdelay,
ast_tvdiff_ms(
ast_tvnow(), p->
polaritydelaytv) );
8276 ast_debug(1,
"Dunno what to do with event %d on channel %d\n", res, p->
channel);
8278 return &p->
subs[idx].
f;
8300 p->
subs[idx].
f.
src =
"dahdi_exception";
8316 if ((res != DAHDI_EVENT_RINGEROFF) && (res != DAHDI_EVENT_RINGERON) &&
8317 (res != DAHDI_EVENT_HOOKCOMPLETE)) {
8318 ast_debug(1,
"Restoring owner of channel %d on event %d\n", p->
channel, res);
8326 case DAHDI_EVENT_ONHOOK:
8338 case DAHDI_EVENT_RINGOFFHOOK:
8346 case DAHDI_EVENT_HOOKCOMPLETE:
8347 case DAHDI_EVENT_RINGERON:
8348 case DAHDI_EVENT_RINGEROFF:
8351 case DAHDI_EVENT_WINKFLASH:
8358 if (usedindex > -1) {
8375 f = &p->
subs[idx].
f;
8381 if (ast != p->
owner) {
8385 f = &p->
subs[idx].
f;
8479 struct dahdi_params ps;
8481 memset(&ps, 0,
sizeof(ps));
8497 return &p->
subs[idx].
f;
8500 if (!(--p->
ringt)) {
8508 openr2_chan_process_event(p->r2chan);
8509 if (OR2_DIR_FORWARD == openr2_chan_get_direction(p->r2chan)) {
8513 if (p->mfcr2_call_accepted &&
8514 !p->mfcr2_progress_sent &&
8516 ast_debug(1,
"Enqueuing progress frame after R2 accept in chan %d\n", p->
channel);
8518 p->mfcr2_progress_sent = 1;
8531 return &p->
subs[idx].
f;
8540 return &p->
subs[idx].
f;
8549 return &p->
subs[idx].
f;
8558 return &p->
subs[idx].
f;
8561 if (p->mfcr2 && openr2_chan_get_read_enabled(p->r2chan)) {
8577 return &p->
subs[idx].
f;
8587 return &p->
subs[idx].
f;
8597 return &p->
subs[idx].
f;
8639 if (
errno == EAGAIN) {
8642 return &p->
subs[idx].
f;
8643 }
else if (
errno == ELAST) {
8656 if (res != (p->
subs[idx].
linear ? READ_SIZE * 2 : READ_SIZE)) {
8657 ast_debug(1,
"Short read (%d/%d), must be an event...\n", res, p->
subs[idx].
linear ? READ_SIZE * 2 : READ_SIZE);
8685 return &p->
subs[idx].
f;
8693 ast_verb(3,
"CPE does not support Call Waiting Caller*ID.\n");
8750 ast_debug(1,
"Channel driver fax CNG detection timeout on %s\n",
8795 ast_debug(1,
"Absorbing inband %s DTMF digit: 0x%02X '%c' on %s\n",
8818 ast_debug(1,
"Got 10 samples of dialtone!\n");
8822 p->
dop.dialstr[0] =
'\0';
8827 ast_debug(1,
"Sent deferred digit string: %s\n", p->
dop.dialstr);
8829 p->
dop.dialstr[0] =
'\0';
8830 p->
dop.op = DAHDI_DIAL_OP_REPLACE;
8839 f = &p->
subs[idx].
f;
8882 size = (linear ? READ_SIZE * 2 :
READ_SIZE);
8883 res = write(fd, buf, size);
8926 ast_debug(5,
"Dropping frame since I'm still dialing on %s...\n",
8932 ast_debug(5,
"Dropping frame since there is no active owner on %s...\n",
8938 ast_debug(5,
"Dropping frame since I've still got a callerid spill on %s...\n",
8980 int func = DAHDI_FLASH;
8985 #if defined(HAVE_PRI) 8991 #if defined(HAVE_SS7) 9001 if (p->mfcr2 && !p->mfcr2_call_accepted) {
9010 switch (condition) {
9012 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_BUSY);
9015 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_RINGTONE);
9073 p->
dop.dialstr[0] =
'\0';
9086 res = tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9096 #if defined(HAVE_PRI) 9111 #if defined(HAVE_PRI) 9112 }
else if (i->pri) {
9114 y = ++i->pri->new_chan_seq;
9132 for (x = 0; x < 3; ++x) {
9146 struct ast_channel *new_channel =
dahdi_new(i, state, startpbx, idx, law, assignedids, requestor, callid);
9170 #if defined(HAVE_PRI) 9189 tmp =
ast_channel_alloc(0, state, i->
cid_num, i->
cid_name, i->
accountcode, i->
exten, i->
context, assignedids, requestor, i->
amaflags,
"DAHDI/%s",
ast_str_buffer(chan_name));
9203 #if defined(HAVE_PRI) 9211 if (law == DAHDI_LAW_ALAW) {
9221 ? DAHDI_LAW_ALAW : DAHDI_LAW_MULAW;
9256 x = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE;
9257 if (ioctl(i->
subs[idx].
dfd, DAHDI_TONEDETECT, &x)) {
9275 #if defined(HAVE_PRI) || defined(HAVE_SS7) 9309 ast_channel_parkinglot_set(tmp, i->
parkinglot);
9311 ast_channel_language_set(tmp, i->
language);
9338 #if defined(HAVE_PRI) || defined(HAVE_SS7) 9367 dashptr = strrchr(device_name,
'-');
9374 for (v = i->
vars ; v ; v = v->
next)
9414 if (strchr(term, c))
9426 j = DAHDI_IOMUX_SIGEVENT;
9428 if (ioctl(p->
subs[idx].
dfd,DAHDI_IOMUX,&j) == -1)
return(-1);
9430 if (j & DAHDI_IOMUX_SIGEVENT)
break;
9433 if (ioctl(p->
subs[idx].
dfd,DAHDI_GETEVENT,&j) == -1)
return(-1);
9473 return dahdichan->
dnd;
9478 ast_verb(3,
"%s DND on channel %d\n",
9479 flag?
"Enabled" :
"Disabled",
9487 int extlen = strlen(exten);
9493 if (extlen < strlen(pickupexten) && !strncmp(pickupexten, exten, extlen)) {
9497 if (exten[0] ==
'*' && extlen < 3) {
9518 unsigned char buf[256];
9539 const char *pickupexten;
9563 ast_log(
LOG_ERROR,
"Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n");
9566 pickupexten =
ast_strdupa(pickup_cfg->pickupexten);
9591 res = tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9601 memset(dtmfbuf, 0,
sizeof(dtmfbuf));
9616 res =
my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf),
"*", 3000);
9626 if (res <= 0)
break;
9635 if ((p->
sig ==
SIG_FEATDMF) && (dtmfbuf[1] !=
'0') && (strlen(dtmfbuf) != 14))
9641 if (res <= 0)
break;
9649 res =
my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf),
"#", 3000);
9666 res =
my_getsigstr(chan, dtmfbuf + strlen(dtmfbuf),
"*", 3000);
9673 dtmfbuf[
len] =
'\0';
9682 ast_debug(1,
"waitfordigit returned < 0...\n");
9686 dtmfbuf[len++] = res;
9687 dtmfbuf[
len] =
'\0';
9699 }
else if (res < 0) {
9700 ast_debug(1,
"Got hung up before digits finished\n");
9715 if ((res > 0) && (strlen(anibuf) > 2)) {
9716 if (anibuf[strlen(anibuf) - 1] ==
'#')
9717 anibuf[strlen(anibuf) - 1] = 0;
9728 if (exten[0] ==
'*') {
9733 s1 =
strsep(&stringp,
"*");
9734 s2 =
strsep(&stringp,
"*");
9747 if (exten[0] ==
'*') {
9752 s1 =
strsep(&stringp,
"#");
9753 s2 =
strsep(&stringp,
"#");
9767 if (exten[0] ==
'*') {
9772 s1 =
strsep(&stringp,
"#");
9773 s2 =
strsep(&stringp,
"#");
9774 if (s2 && (*(s2 + 1) ==
'0')) {
9784 if (exten[0] ==
'*') {
9789 s1 =
strsep(&stringp,
"#");
9823 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
9829 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_INFO);
9837 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
9852 int is_exten_parking = 0;
9862 ast_debug(1,
"waitfordigit returned < 0...\n");
9863 res = tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9867 ast_debug(1,
"waitfordigit returned '%c' (%d), timeout = %d\n", res, res, timeout);
9872 tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9874 tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALTONE);
9885 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
9889 res = tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9891 memset(exten, 0,
sizeof(exten));
9892 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALTONE);
9896 res = tone_zone_play_tone(p->
subs[idx].
dfd, -1);
9915 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
9924 }
else if (res == 0) {
9925 ast_debug(1,
"not enough digits (and no ambiguous match)...\n");
9926 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
9930 }
else if (p->
callwaiting && !strcmp(exten,
"*70")) {
9934 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
9940 ioctl(p->
subs[idx].
dfd,DAHDI_CONFDIAG,&len);
9941 memset(exten, 0,
sizeof(exten));
9944 }
else if (!strcmp(exten, pickupexten)) {
9960 ast_debug(1,
"No call pickup possible...\n");
9961 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
9972 }
else if (!p->
hidecallerid && !strcmp(exten,
"*67")) {
9980 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
9986 memset(exten, 0,
sizeof(exten));
9988 }
else if (p->
callreturn && !strcmp(exten,
"*69")) {
9989 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
9991 }
else if (!strcmp(exten,
"*78")) {
9994 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
9996 memset(exten, 0,
sizeof(exten));
9998 }
else if (!strcmp(exten,
"*79")) {
10001 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
10003 memset(exten, 0,
sizeof(exten));
10006 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
10008 memset(exten, 0,
sizeof(exten));
10011 ast_verb(3,
"Cancelling call forwarding on channel %d\n", p->
channel);
10012 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
10015 memset(exten, 0,
sizeof(exten));
10028 if (bridge_channel) {
10047 }
else if (p->
hidecallerid && !strcmp(exten,
"*82")) {
10052 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_DIALRECALL);
10058 memset(exten, 0,
sizeof(exten));
10060 }
else if (!strcmp(exten,
"*0")) {
10067 if (nbridge && bridged) {
10070 if (nbridge && pbridge &&
10074 int func = DAHDI_FLASH;
10076 p->
dop.dialstr[0] =
'\0';
10089 tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
10091 tone_zone_play_tone(p->
subs[idx].
dfd, -1);
10101 ast_debug(1,
"Can't match %s from '%s' in context %s\n", exten,
10109 tone_zone_play_tone(p->
subs[idx].
dfd, -1);
10119 if (smdi_msg !=
NULL) {
10122 if (smdi_msg->
type ==
'B')
10124 else if (smdi_msg->
type ==
'N')
10172 "Exiting simple switch\n");
10197 ast_debug(1,
"CID got string '%s'\n", dtmfbuf);
10199 ast_debug(1,
"CID is '%s', flags %d\n", dtmfcid, flags);
10210 struct timeval start;
10221 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
10222 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_IOMUX, &i))) {
10228 if (i & DAHDI_IOMUX_SIGEVENT) {
10231 if (res == DAHDI_EVENT_NOALARM) {
10236 if (res == DAHDI_EVENT_RINGBEGIN) {
10244 }
else if (i & DAHDI_IOMUX_READ) {
10245 res = read(p->
subs[idx].
dfd, buf,
sizeof(buf));
10247 if (
errno != ELAST) {
10268 "Failed to decode CallerID on channel '%s'\n",
10273 else if (samples > (8000 * 10))
10279 ast_log(
LOG_NOTICE,
"CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
10297 "Exiting simple switch\n");
10318 for (receivedRingT = 0; receivedRingT <
ARRAY_LEN(curRingData); receivedRingT++)
10319 curRingData[receivedRingT] = 0;
10330 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
10331 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_IOMUX, &i))) {
10337 if (i & DAHDI_IOMUX_SIGEVENT) {
10340 if (res == DAHDI_EVENT_NOALARM) {
10346 curRingData[receivedRingT] = p->
ringt;
10352 if (++receivedRingT ==
ARRAY_LEN(curRingData))
10354 }
else if (i & DAHDI_IOMUX_READ) {
10355 res = read(p->
subs[idx].
dfd, buf,
sizeof(buf));
10357 if (
errno != ELAST) {
10365 if (p->
ringt > 0) {
10366 if (!(--p->
ringt)) {
10374 ast_verb(3,
"Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]);
10375 for (counter = 0; counter < 3; counter++) {
10379 for (counter1 = 0; counter1 < 3; counter1++) {
10382 ast_verb(3,
"Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
10383 curRingData[counter1]);
10387 ast_verb(3,
"Ring pattern matched in range: %d to %d\n",
10394 if (distMatches == 3) {
10412 "state, but I have nothing to do. " 10413 "Terminating simple switch, should be " 10414 "restarted by the actual ring.\n",
10423 struct timeval start;
10436 "Exiting simple switch\n");
10460 ast_debug(1,
"CID is '%s', flags %d\n",
10479 for (receivedRingT = 0; receivedRingT <
ARRAY_LEN(curRingData); receivedRingT++)
10480 curRingData[receivedRingT] = 0;
10493 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
10494 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_IOMUX, &i))) {
10500 if (i & DAHDI_IOMUX_SIGEVENT) {
10503 if (res == DAHDI_EVENT_NOALARM) {
10508 ast_debug(1,
"Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->
channel);
10517 curRingData[receivedRingT] = p->
ringt;
10523 if (++receivedRingT ==
ARRAY_LEN(curRingData))
10525 }
else if (i & DAHDI_IOMUX_READ) {
10526 res = read(p->
subs[idx].
dfd, buf,
sizeof(buf));
10528 if (
errno != ELAST) {
10536 if (p->
ringt > 0) {
10537 if (!(--p->
ringt)) {
10550 "Failed to decode CallerID on channel '%s'\n",
10555 else if (samples > (8000 * 10))
10561 ast_debug(1,
"CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
10565 for (receivedRingT = 0; receivedRingT < 3; receivedRingT++) {
10566 curRingData[receivedRingT] = 0;
10569 ast_verb(3,
"Detecting post-CID distinctive ring\n");
10571 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
10572 if ((res = ioctl(p->
subs[idx].
dfd, DAHDI_IOMUX, &i))) {
10578 if (i & DAHDI_IOMUX_SIGEVENT) {
10581 if (res == DAHDI_EVENT_NOALARM) {
10587 curRingData[receivedRingT] = p->
ringt;
10593 if (++receivedRingT ==
ARRAY_LEN(curRingData))
10595 }
else if (i & DAHDI_IOMUX_READ) {
10596 res = read(p->
subs[idx].
dfd, buf,
sizeof(buf));
10598 if (
errno != ELAST) {
10606 if (p->
ringt > 0) {
10607 if (!(--p->
ringt)) {
10617 ast_verb(3,
"Detected ring pattern: %d,%d,%d\n",curRingData[0],curRingData[1],curRingData[2]);
10619 for (counter = 0; counter < 3; counter++) {
10623 ast_verb(3,
"Checking %d,%d,%d\n",
10628 for (counter1 = 0; counter1 < 3; counter1++) {
10631 ast_verb(3,
"Pattern ignore (-1) detected, so matching pattern %d regardless.\n",
10632 curRingData[counter1]);
10637 ast_verb(3,
"Ring pattern matched in range: %d to %d\n",
10643 if (distMatches == 3) {
10690 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
10694 res = tone_zone_play_tone(p->
subs[idx].
dfd, DAHDI_TONE_CONGESTION);
10720 for (x = 0; x <
len; x++)
10730 pthread_t threadid;
10735 unsigned int spill_done = 0;
10736 int spill_result = -1;
10739 goto quit_no_clean;
10747 i = DAHDI_IOMUX_READ | DAHDI_IOMUX_SIGEVENT;
10753 if (i & DAHDI_IOMUX_SIGEVENT) {
10756 int callid_created;
10764 case DAHDI_EVENT_NEONMWI_ACTIVE:
10765 case DAHDI_EVENT_NEONMWI_INACTIVE:
10766 case DAHDI_EVENT_NONE:
10767 case DAHDI_EVENT_BITSCHANGED:
10769 case DAHDI_EVENT_NOALARM:
10778 case DAHDI_EVENT_ALARM:
10816 goto quit_no_clean;
10818 }
else if (i & DAHDI_IOMUX_READ) {
10820 if (
errno != ELAST) {
10835 }
else if (spill_result) {
10845 if (samples > (8000 * 4))
10850 if (spill_result == 1) {
10887 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 10889 if (pvt->mwisend_rpas) {
10892 }
else if (pvt->mwisend_fsk) {
10920 x = DAHDI_FLUSH_BOTH;
10924 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 10925 if (pvt->mwisend_fsk) {
10930 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 10938 struct timeval now;
10962 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 10963 if (pvt->mwisend_fsk) {
10965 gettimeofday(&now,
NULL);
10969 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 10977 if (0 < num_read) {
11030 case DAHDI_EVENT_RINGEROFF:
11047 case DAHDI_EVENT_RINGOFFHOOK:
11057 case DAHDI_EVENT_RINGERON:
11058 case DAHDI_EVENT_HOOKCOMPLETE:
11072 int destroyed_first = 0;
11073 int destroyed_last = 0;
11076 ast_debug(1,
"range: %d-%d\n", start, end);
11077 for (cur = iflist; cur; cur =
next) {
11080 int x = DAHDI_FLASH;
11082 if (cur->
channel > destroyed_last) {
11083 destroyed_last = cur->
channel;
11085 if (destroyed_first < 1 || cur->
channel < destroyed_first) {
11086 destroyed_first = cur->
channel;
11097 if (destroyed_first > start || destroyed_last < end) {
11098 ast_debug(1,
"Asked to destroy %d-%d, destroyed %d-%d,\n",
11099 start, end, destroyed_first, destroyed_last);
11104 static void dahdi_r2_destroy_nodev(
void)
11106 struct r2link_entry *cur;
11110 struct dahdi_mfcr2 *r2 = &cur->mfcr2;
11111 ast_debug(3,
"About to destroy %d DAHDI channels of MFC/R2 link.\n", r2->numchans);
11112 for (i = 0; i < r2->numchans; i++) {
11119 ast_debug(3,
"About to destroy B-channel %d.\n", channel);
11125 pthread_cancel(r2->r2master);
11126 pthread_join(r2->r2master,
NULL);
11128 openr2_context_delete(r2->protocol_context);
11158 ast_debug(1,
"channel range caps: %d - %d\n", start, end);
11160 for (cur = iflist; cur; cur = cur->
next) {
11163 "channel range %d-%d is occupied\n",
11172 struct dahdi_pri *pri = pris + x;
11174 if (!pris[x].pri.pvts[0]) {
11178 int channo = pri->dchannels[i];
11183 if (!pri->pri.fds[i]) {
11186 if (channo >= start && channo <= end) {
11188 "channel range %d-%d is occupied by span %d\n",
11189 start, end, x + 1);
11221 pthread_t threadid;
11224 int callid_created;
11229 case DAHDI_EVENT_NONE:
11230 case DAHDI_EVENT_BITSCHANGED:
11232 case DAHDI_EVENT_WINKFLASH:
11233 case DAHDI_EVENT_RINGOFFHOOK:
11235 if (i->
radio)
break;
11242 if (res && (
errno == EBUSY)) {
11256 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_RINGTONE);
11260 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_CONGESTION);
11269 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_STUTTER);
11271 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_DIALTONE);
11273 ast_log(
LOG_WARNING,
"Unable to play dialtone on channel %d, do you have defaultzone and loadzone defined?\n", i->
channel);
11276 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_CONGESTION);
11319 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_CONGESTION);
11330 res = tone_zone_play_tone(i->
subs[
SUB_REAL].
dfd, DAHDI_TONE_CONGESTION);
11336 case DAHDI_EVENT_NOALARM:
11338 #if defined(HAVE_PRI) 11345 #if defined(HAVE_SS7) 11356 case DAHDI_EVENT_ALARM:
11358 #if defined(HAVE_PRI) 11365 #if defined(HAVE_SS7) 11377 case DAHDI_EVENT_ONHOOK:
11423 case DAHDI_EVENT_POLARITY:
11437 ast_verb(2,
"Starting post polarity " 11438 "CID detection on channel %d\n",
11452 "polarity reversal on non-FXO (SIG_FXS) " 11453 "interface %d\n", i->
channel);
11456 case DAHDI_EVENT_REMOVED:
11458 "Got DAHDI_EVENT_REMOVED. Destroying channel %d\n",
11461 case DAHDI_EVENT_NEONMWI_ACTIVE:
11467 case DAHDI_EVENT_NEONMWI_INACTIVE:
11478 struct pollfd **pfds = arg;
11484 int count, res, res2, spoint, pollres=0;
11488 time_t thispass = 0, lastpass = 0;
11491 struct pollfd *pfds=
NULL;
11492 int lastalloc = -1;
11497 if (pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,
NULL)) {
11503 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,
NULL);
11509 if (!pfds || (lastalloc !=
ifcount)) {
11525 for (i = iflist; i; i = i->
next) {
11536 pfds[count].events = POLLPRI;
11537 pfds[count].revents = 0;
11541 pfds[count].events |= POLLIN;
11549 pfds[count].events = POLLPRI;
11550 pfds[count].revents = 0;
11555 pfds[count].events |= POLLIN;
11566 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,
NULL);
11567 pthread_testcancel();
11569 res = poll(pfds, count, 1000);
11570 pthread_testcancel();
11571 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,
NULL);
11584 lastpass = thispass;
11585 thispass = time(
NULL);
11587 for (i = iflist;; i = i->
next) {
11596 if (thispass != lastpass) {
11597 if (!found && ((i == last) || ((i == iflist) && !last))) {
11604 && (last->
sig & __DAHDI_SIG_FXO)
11615 ast_debug(3,
"Unable to control message waiting led on channel %d: %s\n", last->
channel, strerror(
errno));
11647 if (pollres & POLLIN) {
11663 pthread_attr_t attr;
11664 pthread_t threadid;
11667 pthread_attr_init(&attr);
11668 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
11673 memcpy(mtd->
buf, buf, res);
11686 struct timeval now;
11694 gettimeofday(&now,
NULL);
11701 pthread_t threadid;
11736 if (pollres & POLLPRI) {
11761 dahdi_r2_destroy_nodev();
11765 pthread_cleanup_pop(1);
11796 #if defined(HAVE_PRI) 11797 static int pri_resolve_span(
int *
span,
int channel,
int offset,
struct dahdi_spaninfo *si)
11802 trunkgroup = pris[*
span].mastertrunkgroup;
11811 ast_log(
LOG_WARNING,
"Channel %d on span %d configured to use nonexistent trunk group %d\n", channel, *span, trunkgroup);
11815 ast_log(
LOG_WARNING,
"Unable to use span %d implicitly since it is trunk group %d (please use spanmap)\n", *span, pris[*span].pri.
trunkgroup);
11817 }
else if (pris[*span].mastertrunkgroup) {
11818 ast_log(
LOG_WARNING,
"Unable to use span %d implicitly since it is already part of trunk group %d\n", *span, pris[*span].mastertrunkgroup);
11821 if (si->totalchans == 31) {
11823 pris[*
span].dchannels[0] = 16 + offset;
11824 }
else if (si->totalchans == 24) {
11826 pris[*
span].dchannels[0] = 24 + offset;
11827 }
else if (si->totalchans == 3) {
11829 pris[*
span].dchannels[0] = 3 + offset;
11831 ast_log(
LOG_WARNING,
"Unable to use span %d, since the D-channel cannot be located (unexpected span size of %d channels)\n", *span, si->totalchans);
11835 pris[*
span].pri.span = *span + 1;
11842 #if defined(HAVE_PRI) 11843 static int pri_create_trunkgroup(
int trunkgroup,
int *
channels)
11845 struct dahdi_spaninfo si;
11846 struct dahdi_params p;
11853 ast_log(
LOG_WARNING,
"Trunk group %d already exists on span %d, Primary d-channel %d\n", trunkgroup, x + 1, pris[x].dchannels[0]);
11860 memset(&si, 0,
sizeof(si));
11861 memset(&p, 0,
sizeof(p));
11862 fd = open(
"/dev/dahdi/channel", O_RDWR);
11868 if (ioctl(fd, DAHDI_SPECIFY, &x)) {
11873 if (ioctl(fd, DAHDI_GET_PARAMS, &p)) {
11878 if (ioctl(fd, DAHDI_SPANSTAT, &si)) {
11879 ast_log(
LOG_WARNING,
"Failed go get span information on channel %d (span %d): %s\n", channels[y], p.spanno, strerror(
errno));
11883 span = p.spanno - 1;
11889 if (pris[span].pri.
pvts[0]) {
11890 ast_log(
LOG_WARNING,
"Span %d is already provisioned with channels (implicit PRI maybe?)\n", span + 1);
11895 pris[span].pri.trunkgroup = trunkgroup;
11898 pris[ospan].dchannels[y] = channels[y];
11899 pris[span].pri.span = span + 1;
11906 #if defined(HAVE_PRI) 11907 static int pri_create_spanmap(
int span,
int trunkgroup,
int logicalspan)
11909 if (pris[span].mastertrunkgroup) {
11910 ast_log(
LOG_WARNING,
"Span %d is already part of trunk group %d, cannot add to trunk group %d\n", span + 1, pris[span].mastertrunkgroup, trunkgroup);
11913 pris[span].mastertrunkgroup = trunkgroup;
11914 pris[span].prilogicalspan = logicalspan;
11919 #if defined(HAVE_SS7) 11920 static unsigned int parse_pointcode(
const char *pcstring)
11922 unsigned int code1, code2, code3;
11925 numvals = sscanf(pcstring,
"%30d-%30d-%30d", &code1, &code2, &code3);
11929 return (code1 << 16) | (code2 << 8) | code3;
11935 #if defined(HAVE_SS7) 11936 static struct dahdi_ss7 * ss7_resolve_linkset(
int linkset)
11938 if ((linkset < 0) || (linkset >= NUM_SPANS))
11941 return &linksets[linkset - 1];
11946 static void dahdi_r2_destroy_links(
void)
11948 struct r2link_entry *cur;
11953 ast_debug(3,
"MFC/R2 link #%d queued for destruction\n", cur->mfcr2.index);
11959 dahdi_r2_destroy_nodev();
11963 #define R2_LINK_CAPACITY 30 11964 static struct r2link_entry *dahdi_r2_get_link(
const struct dahdi_chan_conf *conf)
11966 struct r2link_entry *cur =
NULL;
11974 if (memcmp(&conf->mfcr2, &cur->mfcr2.conf,
sizeof(conf->mfcr2))) {
11975 ast_debug(3,
"Need new R2 link because of: Configuration change\n");
11977 }
else if (cur->mfcr2.numchans == R2_LINK_CAPACITY) {
11978 ast_debug(3,
"Need new R2 link because of: Capacity (%d)\n", R2_LINK_CAPACITY);
11983 struct r2link_entry *
tmp =
NULL;
11984 int new_idx = r2links_count + 1;
11986 for (i = 1; i <= r2links_count; i++) {
11989 if (i == tmp->mfcr2.index) {
12004 cur->mfcr2.index = new_idx;
12007 ast_debug(3,
"Created new R2 link #%d (now have %d)\n", new_idx, r2links_count);
12014 static int dahdi_r2_set_context(
struct dahdi_mfcr2 *r2_link,
const struct dahdi_chan_conf *conf)
12016 char tmplogdir[] =
"/tmp";
12017 char logdir[OR2_MAX_PATH];
12020 r2_link->protocol_context = openr2_context_new(
NULL, &dahdi_r2_event_iface,
12021 &dahdi_r2_transcode_iface, conf->mfcr2.variant, conf->mfcr2.max_ani,
12022 conf->mfcr2.max_dnis);
12023 if (!r2_link->protocol_context) {
12026 openr2_context_set_log_level(r2_link->protocol_context, conf->mfcr2.loglevel);
12027 openr2_context_set_ani_first(r2_link->protocol_context, conf->mfcr2.get_ani_first);
12028 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 12029 openr2_context_set_skip_category_request(r2_link->protocol_context, conf->mfcr2.skip_category_request);
12031 openr2_context_set_mf_threshold(r2_link->protocol_context, threshold);
12032 openr2_context_set_mf_back_timeout(r2_link->protocol_context, conf->mfcr2.mfback_timeout);
12033 openr2_context_set_metering_pulse_timeout(r2_link->protocol_context, conf->mfcr2.metering_pulse_timeout);
12034 openr2_context_set_double_answer(r2_link->protocol_context, conf->mfcr2.double_answer);
12035 openr2_context_set_immediate_accept(r2_link->protocol_context, conf->mfcr2.immediate_accept);
12036 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 12037 openr2_context_set_dtmf_dialing(r2_link->protocol_context, conf->mfcr2.dtmf_dialing, conf->mfcr2.dtmf_time_on, conf->mfcr2.dtmf_time_off);
12038 openr2_context_set_dtmf_detection(r2_link->protocol_context, conf->mfcr2.dtmf_detection);
12040 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 3 12041 openr2_context_set_dtmf_detection_end_timeout(r2_link->protocol_context, conf->mfcr2.dtmf_end_timeout);
12044 if (openr2_context_set_log_directory(r2_link->protocol_context, tmplogdir)) {
12045 ast_log(
LOG_ERROR,
"Failed setting default MFC/R2 log directory %s\n", tmplogdir);
12048 snres = snprintf(logdir,
sizeof(logdir),
"%s/%s/%s",
ast_config_AST_LOG_DIR,
"mfcr2", conf->mfcr2.logdir);
12049 if (snres >=
sizeof(logdir)) {
12050 ast_log(
LOG_ERROR,
"MFC/R2 logging directory truncated, using %s\n", tmplogdir);
12051 if (openr2_context_set_log_directory(r2_link->protocol_context, tmplogdir)) {
12052 ast_log(
LOG_ERROR,
"Failed setting default MFC/R2 log directory %s\n", tmplogdir);
12055 if (openr2_context_set_log_directory(r2_link->protocol_context, logdir)) {
12061 if (openr2_context_configure_from_advanced_file(r2_link->protocol_context, conf->mfcr2.r2proto_file)) {
12062 ast_log(
LOG_ERROR,
"Failed to configure r2context from advanced configuration file %s\n", conf->mfcr2.r2proto_file);
12066 memcpy(&r2_link->conf, &conf->mfcr2,
sizeof(r2_link->conf));
12100 struct dahdi_bufferinfo bi;
12103 #if defined(HAVE_PRI) 12109 struct dahdi_params p;
12110 #if defined(HAVE_PRI) 12111 struct dahdi_spaninfo si;
12114 #if defined(HAVE_SS7) 12119 for (tmp = iflist;
tmp; tmp = tmp->
next) {
12121 if (tmp->
channel == channel) {
12126 if (tmp->
channel > channel) {
12134 if (!here && reloading != 1) {
12146 for (x = 0; x < 3; x++)
12153 int chan_sig = conf->
chan.
sig;
12156 if (reloading && tmp->
vars) {
12166 snprintf(fn,
sizeof(fn),
"%d", channel);
12169 while (tmp->
subs[
SUB_REAL].
dfd < 0 && reloading == 2 && count < 1000) {
12176 ast_log(
LOG_ERROR,
"Unable to open channel %d: %s\nhere = %d, tmp->channel = %d, channel = %d\n", channel, strerror(
errno), here, tmp->
channel, channel);
12180 memset(&p, 0,
sizeof(p));
12189 if (p.sigtype != (chan_sig & 0x3ffff)) {
12195 tmp->
law = p.curlaw;
12196 tmp->
span = p.spanno;
12197 #if defined(HAVE_PRI) 12198 span = p.spanno - 1;
12203 tmp->
sig = chan_sig;
12214 #if defined(HAVE_SS7) 12216 struct dahdi_ss7 *ss7;
12220 ast_log(
LOG_ERROR,
"Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(
errno));
12225 ss7 = ss7_resolve_linkset(cur_linkset);
12231 ss7->ss7.span = cur_linkset;
12232 if (cur_cicbeginswith < 0) {
12243 tmp->ss7 = &ss7->ss7;
12246 ss7_chan->
cic = cur_cicbeginswith++;
12249 ss7_chan->
dpc = cur_defaultdpc;
12251 ss7->ss7.pvts[ss7->ss7.numchans++] = ss7_chan;
12253 ast_copy_string(ss7->ss7.internationalprefix, conf->ss7.ss7.internationalprefix,
sizeof(ss7->ss7.internationalprefix));
12254 ast_copy_string(ss7->ss7.nationalprefix, conf->ss7.ss7.nationalprefix,
sizeof(ss7->ss7.nationalprefix));
12255 ast_copy_string(ss7->ss7.subscriberprefix, conf->ss7.ss7.subscriberprefix,
sizeof(ss7->ss7.subscriberprefix));
12256 ast_copy_string(ss7->ss7.unknownprefix, conf->ss7.ss7.unknownprefix,
sizeof(ss7->ss7.unknownprefix));
12257 ast_copy_string(ss7->ss7.networkroutedprefix, conf->ss7.ss7.networkroutedprefix,
sizeof(ss7->ss7.networkroutedprefix));
12259 ss7->ss7.called_nai = conf->ss7.ss7.called_nai;
12260 ss7->ss7.calling_nai = conf->ss7.ss7.calling_nai;
12265 struct dahdi_mfcr2 *r2_link;
12266 struct r2link_entry *r2_le = dahdi_r2_get_link(conf);
12267 r2_link = &r2_le->mfcr2;
12273 if (!r2_link->protocol_context && dahdi_r2_set_context(r2_link, conf)) {
12278 if (r2_link->numchans ==
ARRAY_LEN(r2_link->pvts)) {
12283 r2_link->pvts[r2_link->numchans++] =
tmp;
12284 tmp->r2chan = openr2_chan_new_from_fd(r2_link->protocol_context,
12287 if (!tmp->r2chan) {
12288 openr2_liberr_t err = openr2_context_get_last_error(r2_link->protocol_context);
12289 ast_log(
LOG_ERROR,
"Cannot create OpenR2 channel: %s\n", openr2_context_error_string(err));
12293 r2_link->live_chans++;
12294 tmp->mfcr2 = r2_link;
12295 if (conf->mfcr2.call_files) {
12296 openr2_chan_enable_call_files(tmp->r2chan);
12298 openr2_chan_set_client_data(tmp->r2chan, tmp);
12300 openr2_chan_set_logging_func(tmp->r2chan, (openr2_logging_func_t)dahdi_r2_on_chan_log);
12301 openr2_chan_set_log_level(tmp->r2chan, conf->mfcr2.loglevel);
12302 tmp->mfcr2_category = conf->mfcr2.category;
12303 tmp->mfcr2_charge_calls = conf->mfcr2.charge_calls;
12304 tmp->mfcr2_allow_collect_calls = conf->mfcr2.allow_collect_calls;
12305 tmp->mfcr2_forced_release = conf->mfcr2.forced_release;
12306 tmp->mfcr2_accept_on_offer = conf->mfcr2.accept_on_offer;
12307 tmp->mfcr2call = 0;
12308 tmp->mfcr2_dnis_index = 0;
12309 tmp->mfcr2_ani_index = 0;
12317 int myswitchtype = 0;
12321 ast_log(
LOG_ERROR,
"Unable to set clear mode on clear channel %d of span %d: %s\n", channel, p.spanno, strerror(
errno));
12325 if (span >= NUM_SPANS) {
12326 ast_log(
LOG_ERROR,
"Channel %d does not lie on a span I know of (%d)\n", channel, span);
12337 tmp->logicalspan = pris[span].prilogicalspan;
12338 pri_resolve_span(&span, channel, (channel - p.chanpos), &si);
12340 ast_log(
LOG_WARNING,
"Channel %d: Unable to find locate channel/trunk group!\n", channel);
12344 myswitchtype = conf->pri.pri.switchtype;
12349 if (pris[x].dchannels[y] == tmp->
channel) {
12355 if (!matchesdchan) {
12356 if (pris[span].pri.
nodetype && (pris[span].pri.nodetype != conf->pri.pri.nodetype)) {
12361 if (pris[span].pri.
switchtype && (pris[span].pri.switchtype != myswitchtype)) {
12366 if ((pris[span].pri.
dialplan) && (pris[span].pri.dialplan != conf->pri.pri.dialplan)) {
12367 ast_log(
LOG_ERROR,
"Span %d is already a %s dialing plan\n", span + 1, pris[span].pri.
dialplan == -1 ?
"Dynamically set dialplan in ISDN" : pri_plan2str(pris[span].pri.
dialplan));
12372 ast_log(
LOG_ERROR,
"Span %d already has idledial '%s'.\n", span + 1, conf->pri.pri.idledial);
12377 ast_log(
LOG_ERROR,
"Span %d already has idleext '%s'.\n", span + 1, conf->pri.pri.idleext);
12381 if (pris[span].pri.
minunused && (pris[span].pri.minunused != conf->pri.pri.minunused)) {
12382 ast_log(
LOG_ERROR,
"Span %d already has minunused of %d.\n", span + 1, conf->pri.pri.minunused);
12386 if (pris[span].pri.
minidle && (pris[span].pri.minidle != conf->pri.pri.minidle)) {
12387 ast_log(
LOG_ERROR,
"Span %d already has minidle of %d.\n", span + 1, conf->pri.pri.minidle);
12392 ast_log(
LOG_ERROR,
"Unable to add channel %d: Too many channels in trunk group %d!\n", channel,
12398 pri_chan =
sig_pri_chan_new(tmp, &pris[span].pri, tmp->logicalspan, p.chanpos, pris[span].mastertrunkgroup);
12404 tmp->pri = &pris[span].pri;
12418 pris[span].pri.sig = chan_sig;
12419 pris[span].pri.nodetype = conf->pri.pri.nodetype;
12420 pris[span].pri.switchtype = myswitchtype;
12421 pris[span].pri.nsf = conf->pri.pri.nsf;
12422 pris[span].pri.dialplan = conf->pri.pri.dialplan;
12423 pris[span].pri.localdialplan = conf->pri.pri.localdialplan;
12424 pris[span].pri.cpndialplan = conf->pri.pri.cpndialplan;
12425 pris[span].pri.pvts[pris[span].pri.numchans++] = tmp->
sig_pvt;
12426 pris[span].pri.minunused = conf->pri.pri.minunused;
12427 pris[span].pri.minidle = conf->pri.pri.minidle;
12428 pris[span].pri.overlapdial = conf->pri.pri.overlapdial;
12429 pris[span].pri.qsigchannelmapping = conf->pri.pri.qsigchannelmapping;
12430 pris[span].pri.discardremoteholdretrieval = conf->pri.pri.discardremoteholdretrieval;
12431 #if defined(HAVE_PRI_SERVICE_MESSAGES) 12432 pris[span].pri.enable_service_message_support = conf->pri.pri.enable_service_message_support;
12434 #ifdef HAVE_PRI_INBANDDISCONNECT 12435 pris[span].pri.inbanddisconnect = conf->pri.pri.inbanddisconnect;
12437 #if defined(HAVE_PRI_CALL_HOLD) 12438 pris[span].pri.hold_disconnect_transfer =
12439 conf->pri.pri.hold_disconnect_transfer;
12441 #if defined(HAVE_PRI_CCSS) 12442 pris[span].pri.cc_ptmp_recall_mode =
12443 conf->pri.pri.cc_ptmp_recall_mode;
12444 pris[span].pri.cc_qsig_signaling_link_req =
12445 conf->pri.pri.cc_qsig_signaling_link_req;
12446 pris[span].pri.cc_qsig_signaling_link_rsp =
12447 conf->pri.pri.cc_qsig_signaling_link_rsp;
12449 #if defined(HAVE_PRI_CALL_WAITING) 12450 pris[span].pri.max_call_waiting_calls =
12451 conf->pri.pri.max_call_waiting_calls;
12452 pris[span].pri.allow_call_waiting_calls =
12453 conf->pri.pri.allow_call_waiting_calls;
12456 pris[span].pri.facilityenable = conf->pri.pri.facilityenable;
12457 #if defined(HAVE_PRI_L2_PERSISTENCE) 12458 pris[span].pri.l2_persistence = conf->pri.pri.l2_persistence;
12460 pris[span].pri.colp_send = conf->pri.pri.colp_send;
12461 #if defined(HAVE_PRI_AOC_EVENTS) 12462 pris[span].pri.aoc_passthrough_flag = conf->pri.pri.aoc_passthrough_flag;
12463 pris[span].pri.aoce_delayhangup = conf->pri.pri.aoce_delayhangup;
12466 pris[span].pri.layer1_ignored = conf->pri.pri.layer1_ignored;
12469 pris[span].pri.layer1_ignored = 0;
12471 pris[span].pri.append_msn_to_user_tag = conf->pri.pri.append_msn_to_user_tag;
12472 pris[span].pri.inband_on_setup_ack = conf->pri.pri.inband_on_setup_ack;
12473 pris[span].pri.inband_on_proceeding = conf->pri.pri.inband_on_proceeding;
12475 ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list,
sizeof(pris[span].pri.msn_list));
12476 #if defined(HAVE_PRI_MWI) 12478 conf->pri.pri.mwi_mailboxes,
12479 sizeof(pris[span].pri.mwi_mailboxes));
12481 conf->pri.pri.mwi_vm_boxes,
12482 sizeof(pris[span].pri.mwi_vm_boxes));
12484 conf->pri.pri.mwi_vm_numbers,
12485 sizeof(pris[span].pri.mwi_vm_numbers));
12487 ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial,
sizeof(pris[span].pri.idledial));
12488 ast_copy_string(pris[span].pri.idleext, conf->pri.pri.idleext,
sizeof(pris[span].pri.idleext));
12489 ast_copy_string(pris[span].pri.internationalprefix, conf->pri.pri.internationalprefix,
sizeof(pris[span].pri.internationalprefix));
12490 ast_copy_string(pris[span].pri.nationalprefix, conf->pri.pri.nationalprefix,
sizeof(pris[span].pri.nationalprefix));
12491 ast_copy_string(pris[span].pri.localprefix, conf->pri.pri.localprefix,
sizeof(pris[span].pri.localprefix));
12492 ast_copy_string(pris[span].pri.privateprefix, conf->pri.pri.privateprefix,
sizeof(pris[span].pri.privateprefix));
12493 ast_copy_string(pris[span].pri.unknownprefix, conf->pri.pri.unknownprefix,
sizeof(pris[span].pri.unknownprefix));
12494 pris[span].pri.moh_signaling = conf->pri.pri.moh_signaling;
12495 pris[span].pri.resetinterval = conf->pri.pri.resetinterval;
12496 #if defined(HAVE_PRI_DISPLAY_TEXT) 12497 pris[span].pri.display_flags_send = conf->pri.pri.display_flags_send;
12498 pris[span].pri.display_flags_receive = conf->pri.pri.display_flags_receive;
12500 #if defined(HAVE_PRI_MCID) 12501 pris[span].pri.mcid_send = conf->pri.pri.mcid_send;
12503 pris[span].pri.force_restart_unavailable_chans = conf->pri.pri.force_restart_unavailable_chans;
12504 #if defined(HAVE_PRI_DATETIME_SEND) 12505 pris[span].pri.datetime_send = conf->pri.pri.datetime_send;
12508 for (x = 0; x < PRI_MAX_TIMERS; x++) {
12509 pris[span].pri.pritimers[x] = conf->pri.pri.pritimers[x];
12512 #if defined(HAVE_PRI_CALL_WAITING) 12536 chan_sig = tmp->
sig;
12538 memset(&p, 0,
sizeof(p));
12543 switch (chan_sig) {
12567 p.channo = channel;
12571 p.debouncetime = 5;
12573 p.channo = channel;
12575 if (conf->
timing.prewinktime >= 0)
12576 p.prewinktime = conf->
timing.prewinktime;
12577 if (conf->
timing.preflashtime >= 0)
12578 p.preflashtime = conf->
timing.preflashtime;
12579 if (conf->
timing.winktime >= 0)
12580 p.winktime = conf->
timing.winktime;
12581 if (conf->
timing.flashtime >= 0)
12582 p.flashtime = conf->
timing.flashtime;
12583 if (conf->
timing.starttime >= 0)
12584 p.starttime = conf->
timing.starttime;
12585 if (conf->
timing.rxwinktime >= 0)
12586 p.rxwinktime = conf->
timing.rxwinktime;
12587 if (conf->
timing.rxflashtime >= 0)
12588 p.rxflashtime = conf->
timing.rxflashtime;
12589 if (conf->
timing.debouncetime >= 0)
12590 p.debouncetime = conf->
timing.debouncetime;
12605 memset(&bi, 0,
sizeof(bi));
12632 if (chan_sig & __DAHDI_SIG_FXS) {
12670 ast_log(
LOG_NOTICE,
"echocancelwhenbridged requires echocancel to be enabled; ignoring\n");
12711 ast_log(
LOG_ERROR,
"Invalid SMDI port specfied, disabling SMDI support\n");
12739 #if defined(HAVE_PRI) 12756 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 12757 tmp->mwisend_setting = conf->
chan.mwisend_setting;
12758 tmp->mwisend_fsk = conf->
chan.mwisend_fsk;
12759 tmp->mwisend_rpas = conf->
chan.mwisend_rpas;
12775 tmp->
vars = tmpvar;
12802 switch (chan_sig) {
12814 if ((res =
get_alarms(tmp)) != DAHDI_ALARM_NONE) {
12816 switch (tmp->
sig) {
12822 #if defined(HAVE_SS7) 12849 switch (tmp->
sig) {
12850 #if defined(HAVE_PRI) 12853 #if defined(HAVE_PRI_SERVICE_MESSAGES) 12856 char db_chan_name[20];
12863 snprintf(db_chan_name,
sizeof(db_chan_name),
"%s/%d:%d", dahdi_db, tmp->
span, tmp->
channel);
12864 if (!
ast_db_get(db_chan_name, SRVST_DBKEY, db_answer,
sizeof(db_answer))) {
12868 if (tmp->pri->enable_service_message_support) {
12871 sscanf(db_answer,
"%1c:%30u", &state, why);
12874 *why &= (SRVST_NEAREND | SRVST_FAREND);
12884 #if defined(HAVE_SS7) 12899 switch (tmp->
sig) {
12900 #if defined(HAVE_PRI) 12920 #if defined(HAVE_SS7) 12985 if (chan_sig & __DAHDI_SIG_FXO) {
12986 memset(&p, 0,
sizeof(p));
12991 #ifdef HAVE_DAHDI_LINEREVERSE_VMWI 12992 res = ioctl(tmp->
subs[
SUB_REAL].
dfd, DAHDI_VMWI_CONFIG, &tmp->mwisend_setting);
13005 #if defined(HAVE_PRI) 13011 dahdi_pseudo_parms.buf_no = tmp->
buf_no;
13012 dahdi_pseudo_parms.buf_policy = tmp->
buf_policy;
13013 dahdi_pseudo_parms.faxbuf_no = tmp->
faxbuf_no;
13018 if (tmp && !here) {
13027 #if defined(HAVE_PRI) 13030 if (!p->pri || p->pri->
span != span) {
13033 if (!groupmatch && channelmatch == -1) {
13042 if ((p->
group & groupmatch) != groupmatch)
13048 if (channelmatch != -1) {
13049 if (p->
channel != channelmatch)
13052 *channelmatched = 1;
13069 #if defined(HAVE_PRI) 13081 #if defined(HAVE_SS7) 13098 if (p->mfcr2call) {
13111 #if defined(HAVE_PRI) 13112 #if defined(HAVE_PRI_CALL_WAITING) 13125 static void my_pri_init_config(
void *priv,
struct sig_pri_span *pri)
13129 pvt->
stripmsd = pri->ch_cfg.stripmsd;
13132 pvt->
immediate = pri->ch_cfg.immediate;
13143 #if defined(HAVE_PRI) 13156 static int dahdi_new_pri_nobch_channel(
struct sig_pri_span *pri)
13163 struct dahdi_bufferinfo bi;
13168 for (pvt_idx = 0; pvt_idx < pri->
numchans; ++pvt_idx) {
13169 if (!pri->
pvts[pvt_idx]) {
13197 pvt->
buf_no = dahdi_pseudo_parms.buf_no;
13198 pvt->
buf_policy = dahdi_pseudo_parms.buf_policy;
13199 pvt->
faxbuf_no = dahdi_pseudo_parms.faxbuf_no;
13220 pri->
pvts[pvt_idx] = chan;
13224 ast_log(
LOG_ERROR,
"Unable to open no B channel interface pseudo channel: %s\n",
13229 memset(&bi, 0,
sizeof(bi));
13235 bi.numbufs = pvt->
buf_no;
13239 "Unable to set buffer policy on no B channel interface: %s\n",
13244 "Unable to check buffer policy on no B channel interface: %s\n",
13251 pvt->
channel = nobch_channel;
13255 dahdi_nobch_insert(pri, pvt);
13269 struct dahdi_bufferinfo bi;
13300 bi.numbufs = src->
buf_no;
13337 char *subdir =
NULL;
13381 memset(param, 0,
sizeof(*param));
13384 if (strchr(
args.group,
'!') !=
NULL) {
13386 while ((s = strchr(prev,
'!')) !=
NULL) {
13390 *(prev - 1) =
'\0';
13391 subdir =
args.group;
13393 }
else if (
args.group[0] ==
'i') {
13395 res = sscanf(
args.group + 1,
"%30d", &x);
13403 s = strchr(
args.group,
'-');
13408 args.group = s + 1;
13411 if (toupper(
args.group[0]) ==
'G' || toupper(
args.group[0])==
'R') {
13413 s =
args.group + 1;
13414 res = sscanf(s,
"%30d%1c%30d", &x, ¶m->
opt, ¶m->
cadance);
13421 if (toupper(
args.group[0]) ==
'G') {
13422 if (
args.group[0] ==
'G') {
13433 if (
args.group[0] ==
'R') {
13435 p = round_robin[x] ? round_robin[x]->
prev :
ifend;
13439 p = round_robin[x] ? round_robin[x]->
next :
iflist;
13448 if (!strcasecmp(s,
"pseudo")) {
13453 res = sscanf(s,
"%30d%1c%30d", &x, ¶m->
opt, ¶m->
cadance);
13465 snprintf(path,
sizeof(path),
"/dev/dahdi/%s/%d",
13467 if (stat(path, &stbuf) < 0) {
13469 path, strerror(
errno));
13472 if (!S_ISCHR(stbuf.st_mode)) {
13483 if (param->
opt ==
'r' && res < 3) {
13493 const char *
data,
int *cause)
13499 int channelmatched = 0;
13500 int groupmatched = 0;
13501 #if defined(HAVE_PRI) || defined(HAVE_SS7) 13502 int transcapdigital = 0;
13519 while (p && !tmp) {
13531 if (p->mfcr2call) {
13533 ast_debug(1,
"Yay!, someone just beat us in the race for channel %d.\n", p->
channel);
13549 switch (start.
opt) {
13562 #if defined(HAVE_PRI) || defined(HAVE_SS7) 13589 #if defined(HAVE_SS7) 13598 #if defined(HAVE_PRI) 13601 #if defined(HAVE_PRI_CALL_WAITING) 13640 if (cause && !tmp) {
13641 if (callwait || channelmatched) {
13643 }
else if (groupmatched) {
13669 #if defined(HAVE_PRI) 13670 const char *device;
13676 if (*device !=
'I') {
13680 res = sscanf(device,
"I%30u", &span);
13681 if (res != 1 || !span || NUM_SPANS < span) {
13685 device = strchr(device,
'/');
13695 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER) 13697 if (!strcmp(device,
"congestion"))
13700 return pris[span - 1].pri.congestion_devstate;
13702 #if defined(THRESHOLD_DEVSTATE_PLACEHOLDER) 13703 else if (!strcmp(device,
"threshold")) {
13704 return pris[span - 1].pri.threshold_devstate;
13734 int groupmatched = 0;
13735 int channelmatched = 0;
13749 const char *monitor_type;
13759 #if defined(HAVE_PRI) 13765 snprintf(full_device_name,
sizeof(full_device_name),
13766 "DAHDI/I%d/congestion", p->pri->
span);
13770 #if defined(HAVE_PRI) 13775 snprintf(full_device_name,
sizeof(full_device_name),
"DAHDI/%s",
13783 dash = strrchr(full_device_name,
'-');
13788 snprintf(dialstring,
sizeof(dialstring),
"DAHDI/%s", dest);
13798 #
if defined(HAVE_PRI)
13803 monitor_type, full_device_name, dialstring,
NULL);
13811 if (p == exitpvt) {
13819 #if defined(HAVE_SS7) 13820 static void dahdi_ss7_message(
struct ss7 *ss7,
char *s)
13826 if (linksets[i].ss7.ss7 == ss7) {
13836 #if defined(HAVE_SS7) 13837 static void dahdi_ss7_error(
struct ss7 *ss7,
char *s)
13843 if (linksets[i].ss7.ss7 == ss7) {
13853 #if defined(HAVE_OPENR2) 13854 static void *mfcr2_monitor(
void *data)
13856 struct dahdi_mfcr2 *mfcr2 = data;
13864 struct pollfd pollers[ARRAY_LEN(mfcr2->pvts)];
13874 for (i = 0; i < mfcr2->numchans; i++) {
13875 pvt = mfcr2->pvts[i];
13879 openr2_chan_set_idle(pvt->r2chan);
13880 openr2_chan_handle_cas(pvt->r2chan);
13886 for (i = 0; i < mfcr2->numchans; i++) {
13887 pollers[i].revents = 0;
13888 pollers[i].events = 0;
13889 pvt = mfcr2->pvts[i];
13896 if (mfcr2->nodev) {
13899 if (!pvt->r2chan) {
13904 openr2_chan_enable_read(pvt->r2chan);
13905 pollers[i].events = POLLIN | POLLPRI;
13912 if (pollsize == 0) {
13914 ast_debug(1,
"Monitor thread going idle since everybody has an owner\n");
13917 poll(
NULL, 0, maxsleep);
13923 pthread_testcancel();
13924 res = poll(pollers, mfcr2->numchans, maxsleep);
13925 pthread_testcancel();
13926 if ((res < 0) && (
errno != EINTR)) {
13931 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
13932 for (i = 0; i < mfcr2->numchans; i++) {
13933 pvt = mfcr2->pvts[i];
13937 if (pollers[i].revents & POLLPRI || pollers[i].revents & POLLIN) {
13938 openr2_chan_process_event(pvt->r2chan);
13941 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
13948 #if defined(HAVE_PRI) 13949 static void dahdi_pri_message(
struct pri *pri,
char *s)
13955 int dchancount = 0;
13960 if (pris[x].pri.dchans[y]) {
13964 if (pris[x].pri.dchans[y] == pri) {
13975 if (1 < dchancount) {
13989 if (pridebugfd >= 0) {
13990 if (write(pridebugfd, s, strlen(s)) < 0) {
13999 #if defined(HAVE_PRI) 14000 static void dahdi_pri_error(
struct pri *pri,
char *s)
14006 int dchancount = 0;
14011 if (pris[x].pri.dchans[y]) {
14015 if (pris[x].pri.dchans[y] == pri) {
14026 if (1 < dchancount) {
14040 if (pridebugfd >= 0) {
14041 if (write(pridebugfd, s, strlen(s)) < 0) {
14050 #if defined(HAVE_PRI) 14051 static int prepare_pri(
struct dahdi_pri *pri)
14054 struct dahdi_params p;
14055 struct dahdi_bufferinfo bi;
14056 struct dahdi_spaninfo si;
14059 if (!pri->dchannels[i])
14061 if (pri->pri.fds[i] >= 0) {
14065 pri->pri.fds[i] = open(
"/dev/dahdi/channel", O_RDWR);
14066 if ((pri->pri.fds[i] < 0)) {
14068 pri->pri.fds[i], strerror(
errno));
14071 x = pri->dchannels[i];
14072 res = ioctl(pri->pri.fds[i], DAHDI_SPECIFY, &x);
14074 dahdi_close_pri_fd(pri, i);
14078 memset(&p, 0,
sizeof(p));
14079 res = ioctl(pri->pri.fds[i], DAHDI_GET_PARAMS, &p);
14081 dahdi_close_pri_fd(pri, i);
14085 if ((p.sigtype != DAHDI_SIG_HDLCFCS) && (p.sigtype != DAHDI_SIG_HARDHDLC)) {
14086 dahdi_close_pri_fd(pri, i);
14090 memset(&si, 0,
sizeof(si));
14091 res = ioctl(pri->pri.fds[i], DAHDI_SPANSTAT, &si);
14093 dahdi_close_pri_fd(pri, i);
14101 memset(&bi, 0,
sizeof(bi));
14102 bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
14103 bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
14106 if (ioctl(pri->pri.fds[i], DAHDI_SET_BUFINFO, &bi)) {
14108 dahdi_close_pri_fd(pri, i);
14111 pri->pri.dchan_logical_span[i] = pris[p.spanno - 1].prilogicalspan;
14117 #if defined(HAVE_PRI) 14118 static char *complete_span_helper(
const char *line,
const char *
word,
int pos,
int state,
int rpos)
14126 for (which = span = 0; span <
NUM_SPANS; span++) {
14127 if (pris[span].pri.pri && ++which > state) {
14138 #if defined(HAVE_PRI) 14139 static char *complete_span_4(
const char *line,
const char *word,
int pos,
int state)
14141 return complete_span_helper(line,word,pos,state,3);
14145 #if defined(HAVE_PRI) 14151 e->
command =
"pri set debug file";
14152 e->
usage =
"Usage: pri set debug file [output-file]\n" 14153 " Sends PRI debug output to the specified output file\n";
14166 ast_cli(a->
fd,
"Unable to open '%s' for writing\n", a->
argv[4]);
14172 if (pridebugfd >= 0)
14178 ast_cli(a->
fd,
"PRI debug output will be sent to '%s'\n", a->
argv[4]);
14183 #if defined(HAVE_PRI) 14184 static int action_pri_debug_file_set(
struct mansession *s,
const struct message *m)
14201 if (pridebugfd >= 0) {
14206 ast_copy_string(pridebugfilename, output_file,
sizeof(pridebugfilename));
14208 astman_send_ack(s, m,
"PRI debug output will now be sent to requested file.");
14214 #if defined(HAVE_PRI) 14215 static int action_pri_debug_file_unset(
struct mansession *s,
const struct message *m)
14219 if (pridebugfd >= 0) {
14232 #if defined(HAVE_PRI) 14241 e->
command =
"pri set debug {on|off|hex|intense|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15} span";
14243 "Usage: pri set debug {<level>|on|off|hex|intense} span <span>\n" 14244 " Enables debugging on a given PRI span\n" 14245 " Level is a bitmap of the following values:\n" 14246 " 1 General debugging incl. state changes\n" 14247 " 2 Decoded Q.931 messages\n" 14248 " 4 Decoded Q.921 messages\n" 14249 " 8 Raw hex dumps of Q.921 frames\n" 14250 " on - equivalent to 3\n" 14251 " hex - equivalent to 8\n" 14252 " intense - equivalent to 15\n";
14255 return complete_span_4(a->
line, a->
word, a->
pos, a->
n);
14261 if (!strcasecmp(a->
argv[3],
"on")) {
14263 }
else if (!strcasecmp(a->
argv[3],
"off")) {
14265 }
else if (!strcasecmp(a->
argv[3],
"intense")) {
14267 }
else if (!strcasecmp(a->
argv[3],
"hex")) {
14270 level = atoi(a->
argv[3]);
14272 span = atoi(a->
argv[5]);
14273 if ((span < 1) || (span > NUM_SPANS)) {
14274 ast_cli(a->
fd,
"Invalid span %s. Should be a number %d to %d\n", a->
argv[5], 1, NUM_SPANS);
14277 if (!pris[span-1].pri.pri) {
14278 ast_cli(a->
fd,
"No PRI running on span %d\n", span);
14283 if (level & 2) debugmask |= PRI_DEBUG_Q931_DUMP;
14284 if (level & 4) debugmask |= PRI_DEBUG_Q921_DUMP;
14285 if (level & 8) debugmask |= PRI_DEBUG_Q921_RAW;
14289 if (pris[span - 1].pri.dchans[x]) {
14290 pri_set_debug(pris[span - 1].pri.dchans[x], debugmask);
14296 if (0 <= pridebugfd) {
14299 ast_cli(a->
fd,
"Disabled PRI debug output to file '%s'\n",
14304 pris[span - 1].pri.debug = (level) ? 1 : 0;
14305 ast_cli(a->
fd,
"%s debugging on span %d\n", (level) ?
"Enabled" :
"Disabled", span);
14310 #if defined(HAVE_PRI) 14330 if (!strcasecmp(level,
"on")) {
14332 }
else if (!strcasecmp(level,
"off")) {
14334 }
else if (!strcasecmp(level,
"intense")) {
14336 }
else if (!strcasecmp(level,
"hex")) {
14339 if (sscanf(level,
"%30d", &level_val) != 1) {
14345 if (sscanf(span,
"%30d", &span_val) != 1) {
14349 if ((span_val < 1) || (span_val > NUM_SPANS)) {
14351 char id_text[256] =
"";
14354 snprintf(id_text,
sizeof(id_text),
"ActionID: %s\r\n",
id);
14359 "Message: Invalid span '%s' - Should be a number from 1 to %d\r\n" 14367 if (!pris[span_val-1].pri.pri) {
14372 if (level_val & 1) {
14375 if (level_val & 2) {
14376 debugmask |= PRI_DEBUG_Q931_DUMP;
14378 if (level_val & 4) {
14379 debugmask |= PRI_DEBUG_Q921_DUMP;
14381 if (level_val & 8) {
14382 debugmask |= PRI_DEBUG_Q921_RAW;
14387 if (pris[span_val - 1].pri.dchans[x]) {
14388 pri_set_debug(pris[span_val - 1].pri.dchans[x], debugmask);
14392 pris[span_val - 1].pri.debug = (level_val) ? 1 : 0;
14399 #if defined(HAVE_PRI) 14400 #if defined(HAVE_PRI_SERVICE_MESSAGES) 14406 int x, y, fd = a->
fd;
14407 int interfaceid = 0;
14408 char db_chan_name[20], db_answer[15];
14410 struct dahdi_pri *pri;
14414 if (strchr(a->
argv[4],
':')) {
14415 if (sscanf(a->
argv[4],
"%30d:%30d", &trunkgroup, &channel) != 2)
14417 if ((trunkgroup < 1) || (channel < 1))
14421 if (pris[x].pri.trunkgroup == trunkgroup) {
14427 ast_cli(fd,
"No such trunk group %d\n", trunkgroup);
14431 channel = atoi(a->
argv[4]);
14434 interfaceid = atoi(a->
argv[5]);
14439 if (pris[x].dchannels[y] == channel) {
14441 if (pri->pri.enable_service_message_support) {
14443 pri_maintenance_service(pri->pri.pri, interfaceid, -1, changestatus);
14447 "\n\tThis operation has not been enabled in chan_dahdi.conf, set 'service_message_support=yes' to use this operation.\n" 14448 "\tNote only 4ESS, 5ESS, and NI2 switch types are supported.\n\n");
14457 for (tmp = iflist;
tmp; tmp = tmp->
next) {
14458 if (tmp->pri && tmp->
channel == channel) {
14461 if (!tmp->pri->enable_service_message_support) {
14464 "\n\tThis operation has not been enabled in chan_dahdi.conf, set 'service_message_support=yes' to use this operation.\n" 14465 "\tNote only 4ESS, 5ESS, and NI2 switch types are supported.\n\n");
14468 snprintf(db_chan_name,
sizeof(db_chan_name),
"%s/%d:%d", dahdi_db, tmp->
span, channel);
14470 switch(changestatus) {
14474 *why &= ~SRVST_NEAREND;
14476 snprintf(db_answer,
sizeof(db_answer),
"%s:%u", SRVST_TYPE_OOS, *why);
14477 ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
14479 dahdi_pri_update_span_devstate(tmp->pri);
14486 *why |= SRVST_NEAREND;
14487 snprintf(db_answer,
sizeof(db_answer),
"%s:%u", SRVST_TYPE_OOS, *why);
14488 ast_db_put(db_chan_name, SRVST_DBKEY, db_answer);
14489 dahdi_pri_update_span_devstate(tmp->pri);
14497 pri_maintenance_bservice(tmp->pri->pri, tmp->
sig_pvt, changestatus);
14504 ast_cli(fd,
"Unable to find given channel %d, possibly not a PRI\n", channel);
14512 e->
command =
"pri service enable channel";
14514 "Usage: pri service enable channel <channel> [<interface id>]\n" 14515 " Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n" 14516 " to restore a channel to service, with optional interface id\n" 14517 " as agreed upon with remote switch operator\n";
14522 return handle_pri_service_generic(e, cmd, a, 0);
14529 e->
command =
"pri service disable channel";
14531 "Usage: pri service disable channel <chan num> [<interface id>]\n" 14532 " Send an AT&T / NFAS / CCS ANSI T1.607 maintenance message\n" 14533 " to remove a channel from service, with optional interface id\n" 14534 " as agreed upon with remote switch operator\n";
14539 return handle_pri_service_generic(e, cmd, a, 2);
14544 #if defined(HAVE_PRI) 14551 e->
command =
"pri show channels";
14553 "Usage: pri show channels\n" 14554 " Displays PRI channel information such as the current mapping\n" 14555 " of DAHDI B channels to Asterisk channel names and which calls\n" 14556 " are on hold or call-waiting. Calls on hold or call-waiting\n" 14557 " are not associated with any B channel.\n";
14567 for (span = 0; span <
NUM_SPANS; ++span) {
14568 if (pris[span].pri.pri) {
14576 #if defined(HAVE_PRI) 14583 e->
command =
"pri show spans";
14585 "Usage: pri show spans\n" 14586 " Displays PRI span information\n";
14595 for (span = 0; span <
NUM_SPANS; span++) {
14596 if (pris[span].pri.pri) {
14604 #if defined(HAVE_PRI) 14605 #define container_of(ptr, type, member) \ 14606 ((type *)((char *)(ptr) - offsetof(type, member))) 14618 static void pri_destroy_span(
struct sig_pri_span *pri)
14623 struct dahdi_pri* dahdi_pri;
14624 pthread_t master = pri->
master;
14629 ast_debug(2,
"About to destroy DAHDI channels of span %d.\n", pri->
span);
14630 for (i = 0; i < pri->
numchans; i++) {
14638 ast_debug(2,
"About to destroy B-channel %d.\n", channel);
14642 cancel_code = pthread_cancel(master);
14643 pthread_kill(master, SIGURG);
14645 "Waiting to join thread of span %d " 14646 "with pid=%p cancel_code=%d\n",
14647 pri->
span, (
void *)master, cancel_code);
14648 res = pthread_join(master,
NULL);
14657 ast_debug(4,
"closing pri_fd %d\n", i);
14658 dahdi_close_pri_fd(dahdi_pri, i);
14659 dahdi_pri->dchannels[i] = 0;
14665 static char *handle_pri_destroy_span(
struct ast_cli_entry *e,
int cmd,
14674 e->
command =
"pri destroy span";
14676 "Usage: pri destroy span <span>\n" 14677 " Destorys D-channel of span and its B-channels.\n" 14678 " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.\n";
14681 return complete_span_4(a->
line, a->
word, a->
pos, a->
n);
14687 res = sscanf(a->
argv[3],
"%30d", &span);
14688 if ((res != 1) || span < 1 || span > NUM_SPANS) {
14690 "Invalid span '%s'. Should be a number from %d to %d\n",
14691 a->
argv[3], 1, NUM_SPANS);
14694 pri = &pris[span - 1].pri;
14696 ast_cli(a->
fd,
"No PRI running on span %d\n", span);
14700 pri_destroy_span(pri);
14706 #if defined(HAVE_PRI) 14713 e->
command =
"pri show span";
14715 "Usage: pri show span <span>\n" 14716 " Displays PRI Information on a given PRI span\n";
14719 return complete_span_4(a->
line, a->
word, a->
pos, a->
n);
14724 span = atoi(a->
argv[3]);
14725 if ((span < 1) || (span > NUM_SPANS)) {
14726 ast_cli(a->
fd,
"Invalid span '%s'. Should be a number from %d to %d\n", a->
argv[3], 1, NUM_SPANS);
14729 if (!pris[span-1].pri.
pri) {
14730 ast_cli(a->
fd,
"No PRI running on span %d\n", span);
14740 #if defined(HAVE_PRI) 14750 e->
command =
"pri show debug";
14752 "Usage: pri show debug\n" 14753 " Show the debug state of pri spans\n";
14759 for (span = 0; span <
NUM_SPANS; span++) {
14760 if (pris[span].pri.
pri) {
14762 if (pris[span].pri.
dchans[x]) {
14763 debug = pri_get_debug(pris[span].pri.
dchans[x]);
14764 ast_cli(a->
fd,
"Span %d: Debug: %s\tIntense: %s\n", span+1, (debug&PRI_DEBUG_Q931_STATE)?
"Yes" :
"No" ,(debug&PRI_DEBUG_Q921_RAW)?
"Yes" :
"No" );
14772 if (pridebugfd >= 0)
14773 ast_cli(a->
fd,
"Logging PRI debug to file %s\n", pridebugfilename);
14782 #if defined(HAVE_PRI) 14787 e->
command =
"pri show version";
14789 "Usage: pri show version\n" 14790 "Show libpri version information\n";
14796 ast_cli(a->
fd,
"libpri version: %s\n", pri_get_version());
14802 #if defined(HAVE_PRI) 14804 AST_CLI_DEFINE(handle_pri_debug,
"Enables PRI debugging on a span"),
14805 #if defined(HAVE_PRI_SERVICE_MESSAGES) 14806 AST_CLI_DEFINE(handle_pri_service_enable_channel,
"Return a channel to service"),
14807 AST_CLI_DEFINE(handle_pri_service_disable_channel,
"Remove a channel from service"),
14809 AST_CLI_DEFINE(handle_pri_show_channels,
"Displays PRI channel information"),
14810 AST_CLI_DEFINE(handle_pri_show_spans,
"Displays PRI span information"),
14811 AST_CLI_DEFINE(handle_pri_show_span,
"Displays PRI span information"),
14813 AST_CLI_DEFINE(handle_pri_show_debug,
"Displays current PRI debug settings"),
14814 AST_CLI_DEFINE(handle_pri_set_debug_file,
"Sends PRI debug output to the specified file"),
14825 e->
command =
"mfcr2 show version";
14827 "Usage: mfcr2 show version\n" 14828 " Shows the version of the OpenR2 library being used.\n";
14833 ast_cli(a->
fd,
"OpenR2 version: %s, revision: %s\n", openr2_get_version(), openr2_get_revision());
14839 #define FORMAT "%4s %40s\n" 14841 int numvariants = 0;
14842 const openr2_variant_entry_t *variants;
14845 e->
command =
"mfcr2 show variants";
14847 "Usage: mfcr2 show variants\n" 14848 " Shows the list of MFC/R2 variants supported.\n";
14853 if (!(variants = openr2_proto_get_variant_list(&numvariants))) {
14854 ast_cli(a->
fd,
"Failed to get list of variants.\n");
14858 for (i = 0; i < numvariants; i++) {
14867 #define FORMAT "%4s %4s %-7.7s %-7.7s %-8.8s %-9.9s %-16.16s %-8.8s %-8.8s\n" 14868 int filtertype = 0;
14875 openr2_context_t *r2context;
14876 openr2_variant_t r2variant;
14879 e->
command =
"mfcr2 show channels [group|context]";
14881 "Usage: mfcr2 show channels [group <group> | context <context>]\n" 14882 " Shows the DAHDI channels configured with MFC/R2 signaling.\n";
14887 if (!((a->
argc == 3) || (a->
argc == 5))) {
14890 if (a->
argc == 5) {
14891 if (!strcasecmp(a->
argv[3],
"group")) {
14892 targetnum = atoi(a->
argv[4]);
14893 if ((targetnum < 0) || (targetnum > 63))
14895 targetnum = 1 << targetnum;
14897 }
else if (!strcasecmp(a->
argv[3],
"context")) {
14903 ast_cli(a->
fd,
FORMAT,
"Chan",
"Link#",
"Variant",
"Max ANI",
"Max DNIS",
"ANI First",
"Immediate Accept",
"Tx CAS",
"Rx CAS");
14905 for (p = iflist; p; p = p->
next) {
14910 switch(filtertype) {
14912 if (p->
group != targetnum) {
14925 r2context = openr2_chan_get_context(p->r2chan);
14926 r2variant = openr2_context_get_variant(r2context);
14927 snprintf(channo,
sizeof(channo),
"%d", p->
channel);
14928 snprintf(linkno,
sizeof(linkno),
"%d", p->mfcr2->index);
14929 snprintf(anino,
sizeof(anino),
"%d", openr2_context_get_max_ani(r2context));
14930 snprintf(dnisno,
sizeof(dnisno),
"%d", openr2_context_get_max_dnis(r2context));
14931 ast_cli(a->
fd,
FORMAT, channo, linkno, openr2_proto_get_variant_string(r2variant),
14932 anino, dnisno, openr2_context_get_ani_first(r2context) ?
"Yes" :
"No",
14933 openr2_context_get_immediate_accept(r2context) ?
"Yes" :
"No",
14934 openr2_chan_get_tx_cas_string(p->r2chan), openr2_chan_get_rx_cas_string(p->r2chan));
14945 char *toklevel =
NULL;
14946 char *saveptr =
NULL;
14947 char *logval =
NULL;
14948 openr2_log_level_t loglevel = OR2_LOG_NOTHING;
14949 openr2_log_level_t tmplevel = OR2_LOG_NOTHING;
14952 e->
command =
"mfcr2 set debug";
14954 "Usage: mfcr2 set debug <loglevel> <channel>\n" 14955 " Set a new logging level for the specified channel.\n" 14956 " If no channel is specified the logging level will be applied to all channels.\n";
14964 channo = (a->
argc == 5) ? atoi(a->
argv[4]) : -1;
14966 toklevel = strtok_r(logval,
",", &saveptr);
14967 if (-1 == (tmplevel = openr2_log_get_level(toklevel))) {
14968 ast_cli(a->
fd,
"Invalid MFC/R2 logging level '%s'.\n", a->
argv[3]);
14970 }
else if (OR2_LOG_NOTHING == tmplevel) {
14971 loglevel = tmplevel;
14973 loglevel |= tmplevel;
14974 while ((toklevel = strtok_r(
NULL,
",", &saveptr))) {
14975 if (-1 == (tmplevel = openr2_log_get_level(toklevel))) {
14976 ast_cli(a->
fd,
"Ignoring invalid logging level: '%s'.\n", toklevel);
14979 loglevel |= tmplevel;
14983 for (p = iflist; p; p = p->
next) {
14987 if ((channo != -1) && (p->
channel != channo )) {
14990 openr2_chan_set_log_level(p->r2chan, loglevel);
14991 if (channo != -1) {
14996 if ((channo != -1) && !p) {
14997 ast_cli(a->
fd,
"MFC/R2 channel %d not found.\n", channo);
14999 if (channo == -1) {
15000 ast_cli(a->
fd,
"MFC/R2 debugging set to '%s' for all channels.\n", a->
argv[3]);
15012 e->
command =
"mfcr2 call files [on|off]";
15014 "Usage: mfcr2 call files [on|off] <channel>\n" 15015 " Enable call files creation on the specified channel.\n" 15016 " If no channel is specified call files creation policy will be applied to all channels.\n";
15024 channo = (a->
argc == 5) ? atoi(a->
argv[4]) : -1;
15026 for (p = iflist; p; p = p->
next) {
15030 if ((channo != -1) && (p->
channel != channo )) {
15034 openr2_chan_enable_call_files(p->r2chan);
15036 openr2_chan_disable_call_files(p->r2chan);
15038 if (channo != -1) {
15040 ast_cli(a->
fd,
"MFC/R2 call files enabled for channel %d.\n", p->
channel);
15042 ast_cli(a->
fd,
"MFC/R2 call files disabled for channel %d.\n", p->
channel);
15047 if ((channo != -1) && !p) {
15048 ast_cli(a->
fd,
"MFC/R2 channel %d not found.\n", channo);
15050 if (channo == -1) {
15052 ast_cli(a->
fd,
"MFC/R2 Call files enabled for all channels.\n");
15054 ast_cli(a->
fd,
"MFC/R2 Call files disabled for all channels.\n");
15067 e->
command =
"mfcr2 set idle";
15069 "Usage: mfcr2 set idle <channel>\n" 15070 " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.\n" 15071 " Force the given channel into IDLE state.\n" 15072 " If no channel is specified, all channels will be set to IDLE.\n";
15077 channo = (a->
argc == 4) ? atoi(a->
argv[3]) : -1;
15079 for (p = iflist; p; p = p->
next) {
15083 if ((channo != -1) && (p->
channel != channo )) {
15086 openr2_chan_set_idle(p->r2chan);
15091 if (channo != -1) {
15095 if ((channo != -1) && !p) {
15096 ast_cli(a->
fd,
"MFC/R2 channel %d not found.\n", channo);
15108 e->
command =
"mfcr2 set blocked";
15110 "Usage: mfcr2 set blocked <channel>\n" 15111 " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.\n" 15112 " Force the given channel into BLOCKED state.\n" 15113 " If no channel is specified, all channels will be set to BLOCKED.\n";
15118 channo = (a->
argc == 4) ? atoi(a->
argv[3]) : -1;
15120 for (p = iflist; p; p = p->
next) {
15124 if ((channo != -1) && (p->
channel != channo )) {
15127 openr2_chan_set_blocked(p->r2chan);
15131 if (channo != -1) {
15135 if ((channo != -1) && !p) {
15136 ast_cli(a->
fd,
"MFC/R2 channel %d not found.\n", channo);
15142 static void mfcr2_show_links_of(
struct ast_cli_args *a,
struct r2links *list_head,
const char *title)
15144 #define FORMAT "%-5s %-10s %-15s %-10s %s\n" 15149 char live_chans_str[5];
15150 char channel_list[R2_LINK_CAPACITY * 4];
15151 struct r2link_entry *cur;
15153 ast_cli(a->
fd,
FORMAT,
"Index",
"Thread",
"Dahdi-Device",
"Channels",
"Channel-List");
15155 struct dahdi_mfcr2 *mfcr2 = &cur->mfcr2;
15156 const char *thread_status =
NULL;
15163 if (mfcr2->r2master == 0L) {
15164 thread_status =
"zero";
15166 thread_status =
"none";
15168 thread_status =
"created";
15170 snprintf(index,
sizeof(index),
"%d", mfcr2->index);
15171 snprintf(live_chans_str,
sizeof(live_chans_str),
"%d", mfcr2->live_chans);
15177 for (i = 0; i < mfcr2->numchans && len <
sizeof(channel_list) - 1; i++) {
15184 if (prev_channo && prev_channo == channo - 1) {
15185 prev_channo = channo;
15189 if (inside_range) {
15191 len += snprintf(channel_list + len,
sizeof(channel_list) - len - 1,
"-%d,%d", prev_channo, channo);
15193 }
else if (prev_channo) {
15195 len += snprintf(channel_list + len,
sizeof(channel_list) - len - 1,
",%d", channo);
15198 len += snprintf(channel_list + len,
sizeof(channel_list) - len - 1,
"%d", channo);
15200 prev_channo = channo;
15203 if (inside_range) {
15205 len += snprintf(channel_list + len,
sizeof(channel_list) - len - 1,
"-%d", channo);
15207 }
else if (prev_channo) {
15209 len += snprintf(channel_list + len,
sizeof(channel_list) - len - 1,
",%d", channo);
15215 (mfcr2->nodev) ?
"MISSING" :
"OK",
15228 e->
command =
"mfcr2 show links";
15230 "Usage: mfcr2 show links\n" 15231 " Shows the DAHDI MFC/R2 links.\n";
15236 if (a->
argc != 3) {
15239 mfcr2_show_links_of(a, &r2links,
"Live links\n");
15240 mfcr2_show_links_of(a, &nodev_r2links,
"Links to be removed (device missing)\n");
15247 int wanted_link_index;
15248 int found_link = 0;
15249 struct r2link_entry *cur =
NULL;
15253 e->
command =
"mfcr2 destroy link";
15255 "Usage: mfcr2 destroy link <index-number>\n" 15256 " Destorys D-channel of link and its B-channels.\n" 15257 " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.\n";
15265 res = sscanf(a->
argv[3],
"%30d", &wanted_link_index);
15266 if ((res != 1) || wanted_link_index < 1) {
15268 "Invalid link index '%s'. Should be a positive number\n", a->
argv[3]);
15273 struct dahdi_mfcr2 *mfcr2 = &cur->mfcr2;
15274 if (wanted_link_index == mfcr2->index) {
15282 if (! found_link) {
15283 ast_cli(a->
fd,
"No link found with index %d.\n", wanted_link_index);
15290 AST_CLI_DEFINE(handle_mfcr2_version,
"Show OpenR2 library version"),
15291 AST_CLI_DEFINE(handle_mfcr2_show_variants,
"Show supported MFC/R2 variants"),
15292 AST_CLI_DEFINE(handle_mfcr2_show_channels,
"Show MFC/R2 channels"),
15294 AST_CLI_DEFINE(handle_mfcr2_set_debug,
"Set MFC/R2 channel logging level"),
15295 AST_CLI_DEFINE(handle_mfcr2_call_files,
"Enable/Disable MFC/R2 call files"),
15296 AST_CLI_DEFINE(handle_mfcr2_set_idle,
"Reset MFC/R2 channel forcing it to IDLE"),
15297 AST_CLI_DEFINE(handle_mfcr2_set_blocked,
"Reset MFC/R2 channel forcing it to BLOCKED"),
15298 AST_CLI_DEFINE(handle_mfcr2_destroy_link,
"Destroy given MFC/R2 link"),
15309 e->
command =
"dahdi destroy channels";
15311 "Usage: dahdi destroy channels <from_channel> [<to_channel>]\n" 15312 " DON'T USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING. Immediately removes a given channel, whether it is in use or not\n";
15317 if ((a->
argc < 4) || a->
argc > 5) {
15320 start = atoi(a->
argv[3]);
15322 ast_cli(a->
fd,
"Invalid starting channel number %s.\n",
15326 if (a->
argc == 5) {
15327 end = atoi(a->
argv[4]);
15329 ast_cli(a->
fd,
"Invalid ending channel number %s.\n",
15339 "range end (%d) is smaller than range start (%d)\n",
15355 e->
command =
"dahdi create channels";
15356 e->
usage =
"Usage: dahdi create channels <from> [<to>] - a range of channels\n" 15357 " dahdi create channels new - add channels not yet created\n" 15358 "For ISDN and SS7 the range should include complete spans.\n";
15363 if ((a->
argc < 4) || a->
argc > 5) {
15366 if (a->
argc == 4 && !strcmp(a->
argv[3],
"new")) {
15370 start = atoi(a->
argv[3]);
15372 ast_cli(a->
fd,
"Invalid starting channel number '%s'.\n",
15376 if (a->
argc == 5) {
15377 end = atoi(a->
argv[4]);
15379 ast_cli(a->
fd,
"Invalid ending channel number '%s'.\n",
15388 "range end (%d) is smaller than range start (%d)\n",
15401 for (p = iflist; p; p = p->
next) {
15426 #if defined(HAVE_PRI) || defined(HAVE_SS7) 15433 ast_verb(1,
"Destroying channels and reloading DAHDI configuration.\n");
15435 ast_verb(4,
"Initial softhangup of all DAHDI channels complete.\n");
15437 dahdi_r2_destroy_links();
15440 #if defined(HAVE_PRI) 15443 cancel_code = pthread_cancel(pris[i].pri.
master);
15444 pthread_kill(pris[i].pri.
master, SIGURG);
15445 ast_debug(4,
"Waiting to join thread of span %d with pid=%p, cancel_code=%d\n", i, (
void *) pris[i].pri.
master, cancel_code);
15447 ast_debug(4,
"Joined thread of span %d\n", i);
15452 #if defined(HAVE_SS7) 15455 cancel_code = pthread_cancel(linksets[i].ss7.master);
15456 pthread_kill(linksets[i].ss7.master, SIGURG);
15457 ast_debug(4,
"Waiting to join thread of span %d with pid=%p, cancel_code=%d\n", i, (
void *) linksets[i].ss7.master, cancel_code);
15458 pthread_join(linksets[i].ss7.master,
NULL);
15459 ast_debug(4,
"Joined thread of span %d\n", i);
15468 ast_debug(4,
"Waiting to join monitor thread with pid=%p, cancel_code=%d\n", (
void *)
monitor_thread, cancel_code);
15469 pthread_join(monitor_thread,
NULL);
15470 ast_debug(4,
"Joined monitor thread\n");
15476 int x = DAHDI_FLASH;
15480 for (p = iflist; p; p = p->
next) {
15492 ast_verb(4,
"Final softhangup of all DAHDI channels complete.\n");
15494 memset(round_robin, 0,
sizeof(round_robin));
15502 dahdi_close_pri_fd(&(pris[i]), j);
15505 memset(pris, 0,
sizeof(pris));
15509 pri_set_error(dahdi_pri_error);
15510 pri_set_message(dahdi_pri_message);
15512 #if defined(HAVE_SS7) 15515 dahdi_close_ss7_fd(&(linksets[i]), j);
15518 memset(linksets, 0,
sizeof(linksets));
15522 ss7_set_error(dahdi_ss7_error);
15523 ss7_set_message(dahdi_ss7_message);
15543 e->
command =
"dahdi restart";
15545 "Usage: dahdi restart\n" 15546 " Restarts the DAHDI channels: destroys them all and then\n" 15547 " re-reads them from chan_dahdi.conf.\n" 15548 " Note that this will STOP any running CALL on DAHDI channels.\n" 15574 #define FORMAT "%7s %-15.15s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n" 15575 #define FORMAT2 "%7s %-15.15s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n" 15577 int filtertype = 0;
15584 e->
command =
"dahdi show channels [group|context]";
15586 "Usage: dahdi show channels [ group <group> | context <context> ]\n" 15587 " Shows a list of available channels with optional filtering\n" 15588 " <group> must be a number between 0 and 63\n";
15596 if (!((a->
argc == 3) || (a->
argc == 5))) {
15600 if (a->
argc == 5) {
15601 if (!strcasecmp(a->
argv[3],
"group")) {
15602 targetnum = atoi(a->
argv[4]);
15603 if (63 < targetnum) {
15608 }
else if (!strcasecmp(a->
argv[3],
"context")) {
15613 ast_cli(a->
fd,
FORMAT2,
"Chan",
"Extension",
"Context",
"Language",
"MOH Interpret",
"Blocked",
"In Service",
"Description");
15615 for (tmp = iflist;
tmp; tmp = tmp->
next) {
15617 switch(filtertype) {
15619 if (!(tmp->
group & targetnum)) {
15633 snprintf(tmps,
sizeof(tmps),
"%d", tmp->
channel);
15640 blockstr[2] =
'\0';
15654 struct dahdi_confinfo ci;
15655 struct dahdi_params ps;
15662 e->
command =
"dahdi show channel";
15664 "Usage: dahdi show channel <chan num>\n" 15665 " Detailed information about a given channel\n";
15674 channel = atoi(a->
argv[3]);
15677 for (tmp = iflist;
tmp; tmp = tmp->
next) {
15678 if (tmp->
channel == channel) {
15688 #if defined(HAVE_PRI) 15689 #if defined(HAVE_PRI_SUBADDR) 15698 for (v = tmp->
vars ; v ; v = v->
next)
15715 #if defined(BUSYDETECT_TONEONLY) 15716 ast_cli(a->
fd,
" Busy Detector Helper: BUSYDETECT_TONEONLY\n");
15717 #elif defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE) 15718 ast_cli(a->
fd,
" Busy Detector Helper: BUSYDETECT_COMPARE_TONE_AND_SILENCE\n");
15720 #ifdef BUSYDETECT_DEBUG 15721 ast_cli(a->
fd,
" Busy Detector Debug: Enabled\n");
15733 snprintf(hwrxgain,
sizeof(hwrxgain),
"%.1f", tmp->
hwrxgain);
15738 snprintf(hwtxgain,
sizeof(hwtxgain),
"%.1f", tmp->
hwtxgain);
15742 ast_cli(a->
fd,
"HW Gains (RX/TX): %s/%s\n", hwrxgain, hwtxgain);
15744 ast_cli(a->
fd,
"Dynamic Range Compression (RX/TX): %.2f/%.2f\n", tmp->
rxdrc, tmp->
txdrc);
15746 ast_cli(a->
fd,
"Echo Cancellation:\n");
15766 char calldir[OR2_MAX_PATH];
15767 openr2_context_t *r2context = openr2_chan_get_context(tmp->r2chan);
15768 openr2_variant_t r2variant = openr2_context_get_variant(r2context);
15769 ast_cli(a->
fd,
"MFC/R2 MF State: %s\n", openr2_chan_get_mf_state_string(tmp->r2chan));
15770 ast_cli(a->
fd,
"MFC/R2 MF Group: %s\n", openr2_chan_get_mf_group_string(tmp->r2chan));
15771 ast_cli(a->
fd,
"MFC/R2 State: %s\n", openr2_chan_get_r2_state_string(tmp->r2chan));
15772 ast_cli(a->
fd,
"MFC/R2 Call State: %s\n", openr2_chan_get_call_state_string(tmp->r2chan));
15773 ast_cli(a->
fd,
"MFC/R2 Call Files Enabled: %s\n", openr2_chan_get_call_files_enabled(tmp->r2chan) ?
"Yes" :
"No");
15774 ast_cli(a->
fd,
"MFC/R2 Variant: %s\n", openr2_proto_get_variant_string(r2variant));
15775 ast_cli(a->
fd,
"MFC/R2 Max ANI: %d\n", openr2_context_get_max_ani(r2context));
15776 ast_cli(a->
fd,
"MFC/R2 Max DNIS: %d\n", openr2_context_get_max_dnis(r2context));
15777 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 15778 ast_cli(a->
fd,
"MFC/R2 DTMF Dialing: %s\n", openr2_context_get_dtmf_dialing(r2context,
NULL,
NULL) ?
"Yes" :
"No");
15779 ast_cli(a->
fd,
"MFC/R2 DTMF Detection: %s\n", openr2_context_get_dtmf_detection(r2context) ?
"Yes" :
"No");
15781 ast_cli(a->
fd,
"MFC/R2 Get ANI First: %s\n", openr2_context_get_ani_first(r2context) ?
"Yes" :
"No");
15782 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 15783 ast_cli(a->
fd,
"MFC/R2 Skip Category Request: %s\n", openr2_context_get_skip_category_request(r2context) ?
"Yes" :
"No");
15785 ast_cli(a->
fd,
"MFC/R2 Immediate Accept: %s\n", openr2_context_get_immediate_accept(r2context) ?
"Yes" :
"No");
15786 ast_cli(a->
fd,
"MFC/R2 Accept on Offer: %s\n", tmp->mfcr2_accept_on_offer ?
"Yes" :
"No");
15787 ast_cli(a->
fd,
"MFC/R2 Charge Calls: %s\n", tmp->mfcr2_charge_calls ?
"Yes" :
"No");
15788 ast_cli(a->
fd,
"MFC/R2 Allow Collect Calls: %s\n", tmp->mfcr2_allow_collect_calls ?
"Yes" :
"No");
15789 ast_cli(a->
fd,
"MFC/R2 Forced Release: %s\n", tmp->mfcr2_forced_release ?
"Yes" :
"No");
15790 ast_cli(a->
fd,
"MFC/R2 MF Back Timeout: %dms\n", openr2_context_get_mf_back_timeout(r2context));
15791 ast_cli(a->
fd,
"MFC/R2 R2 Metering Pulse Timeout: %dms\n", openr2_context_get_metering_pulse_timeout(r2context));
15792 ast_cli(a->
fd,
"MFC/R2 Rx CAS: %s\n", openr2_chan_get_rx_cas_string(tmp->r2chan));
15793 ast_cli(a->
fd,
"MFC/R2 Tx CAS: %s\n", openr2_chan_get_tx_cas_string(tmp->r2chan));
15794 ast_cli(a->
fd,
"MFC/R2 MF Tx Signal: %d\n", openr2_chan_get_tx_mf_signal(tmp->r2chan));
15795 ast_cli(a->
fd,
"MFC/R2 MF Rx Signal: %d\n", openr2_chan_get_rx_mf_signal(tmp->r2chan));
15796 ast_cli(a->
fd,
"MFC/R2 Call Files Directory: %s\n", openr2_context_get_log_directory(r2context, calldir,
sizeof(calldir)));
15799 #if defined(HAVE_SS7) 15820 if (tmp->logicalspan)
15821 ast_cli(a->
fd,
"PRI Logical Span: %d\n", tmp->logicalspan);
15823 ast_cli(a->
fd,
"PRI Logical Span: Implicit\n");
15826 memset(&ci, 0,
sizeof(ci));
15829 memset(&ci, 0,
sizeof(ci));
15831 ast_cli(a->
fd,
"Actual Confinfo: Num/%d, Mode/0x%04x\n", ci.confno, (
unsigned)ci.confmode);
15834 ast_cli(a->
fd,
"Actual Confmute: %s\n", x ?
"Yes" :
"No");
15836 memset(&ps, 0,
sizeof(ps));
15840 ast_cli(a->
fd,
"Hookstate (FXS only): %s\n", ps.rxisoffhook ?
"Offhook" :
"Onhook");
15849 ast_cli(a->
fd,
"Unable to find given channel %d\n", channel);
15858 e->
command =
"dahdi show cadences";
15860 "Usage: dahdi show cadences\n" 15861 " Shows all cadences currently defined\n";
15868 char tmp[16], tmp2[64];
15869 snprintf(tmp,
sizeof(tmp),
"r%d: ", i + 1);
15872 for (j = 0; j < 16; j++) {
15873 if (
cadences[i].ringcadence[j] == 0)
15875 snprintf(tmp,
sizeof(tmp),
"%d",
cadences[i].ringcadence[j]);
15881 strncat(output,
",",
sizeof(output) - strlen(output) - 1);
15882 strncat(output, tmp2,
sizeof(output) - strlen(output) - 1);
15892 #define FORMAT "%-40.40s %-7.7s %-6d %-6d %-6d %-3.3s %-4.4s %-8.8s %s\n" 15893 #define FORMAT2 "%-40.40s %-7.7s %-6.6s %-6.6s %-6.6s %-3.3s %-4.4s %-8.8s %s\n" 15899 struct dahdi_spaninfo s;
15903 e->
command =
"dahdi show status";
15905 "Usage: dahdi show status\n" 15906 " Shows a list of DAHDI cards with status\n";
15911 ctl = open(
"/dev/dahdi/ctl", O_RDWR);
15913 ast_cli(a->
fd,
"No DAHDI found. Unable to open /dev/dahdi/ctl: %s\n", strerror(
errno));
15916 ast_cli(a->
fd,
FORMAT2,
"Description",
"Alarms",
"IRQ",
"bpviol",
"CRC",
"Framing",
"Coding",
"Options",
"LBO");
15918 for (span = 1; span < DAHDI_MAX_SPANS; ++span) {
15920 res = ioctl(ctl, DAHDI_SPANSTAT, &s);
15924 alarmstr[0] =
'\0';
15925 if (s.alarms > 0) {
15926 if (s.alarms & DAHDI_ALARM_BLUE)
15927 strcat(alarmstr,
"BLU/");
15928 if (s.alarms & DAHDI_ALARM_YELLOW)
15929 strcat(alarmstr,
"YEL/");
15930 if (s.alarms & DAHDI_ALARM_RED)
15931 strcat(alarmstr,
"RED/");
15932 if (s.alarms & DAHDI_ALARM_LOOPBACK)
15933 strcat(alarmstr,
"LB/");
15934 if (s.alarms & DAHDI_ALARM_RECOVER)
15935 strcat(alarmstr,
"REC/");
15936 if (s.alarms & DAHDI_ALARM_NOTOPEN)
15937 strcat(alarmstr,
"NOP/");
15938 if (!strlen(alarmstr))
15939 strcat(alarmstr,
"UUU/");
15940 if (strlen(alarmstr)) {
15942 alarmstr[strlen(alarmstr) - 1] =
'\0';
15946 strcpy(alarmstr,
"OK");
15948 strcpy(alarmstr,
"UNCONFIGURED");
15951 ast_cli(a->
fd,
FORMAT, s.desc, alarmstr, s.irqmisses, s.bpvcount, s.crc4count,
15952 s.lineconfig & DAHDI_CONFIG_D4 ?
"D4" :
15953 s.lineconfig & DAHDI_CONFIG_ESF ?
"ESF" :
15954 s.lineconfig & DAHDI_CONFIG_CCS ?
"CCS" :
15956 s.lineconfig & DAHDI_CONFIG_B8ZS ?
"B8ZS" :
15957 s.lineconfig & DAHDI_CONFIG_HDB3 ?
"HDB3" :
15958 s.lineconfig & DAHDI_CONFIG_AMI ?
"AMI" :
15960 s.lineconfig & DAHDI_CONFIG_CRC4 ?
15961 s.lineconfig & DAHDI_CONFIG_NOTOPEN ?
"CRC4/YEL" :
"CRC4" :
15962 s.lineconfig & DAHDI_CONFIG_NOTOPEN ?
"YEL" :
"",
15975 int pseudo_fd = -1;
15976 struct dahdi_versioninfo vi;
15980 e->
command =
"dahdi show version";
15982 "Usage: dahdi show version\n" 15983 " Shows the DAHDI version in use\n";
15988 if ((pseudo_fd = open(
"/dev/dahdi/ctl", O_RDONLY)) < 0) {
15989 ast_cli(a->
fd,
"Failed to open control file to get version.\n");
15993 strcpy(vi.version,
"Unknown");
15994 strcpy(vi.echo_canceller,
"Unknown");
15996 if (ioctl(pseudo_fd, DAHDI_GETVERSION, &vi))
15997 ast_cli(a->
fd,
"Failed to get DAHDI version: %s\n", strerror(
errno));
15999 ast_cli(a->
fd,
"DAHDI Version: %s Echo Canceller: %s\n", vi.version, vi.echo_canceller);
16015 e->
command =
"dahdi set hwgain {rx|tx}";
16017 "Usage: dahdi set hwgain <rx|tx> <chan#> <gain>\n" 16018 " Sets the hardware gain on a given channel and overrides the\n" 16019 " value provided at module loadtime. Changes take effect\n" 16020 " immediately whether the channel is in use or not.\n" 16022 " <rx|tx> which direction do you want to change (relative to our module)\n" 16023 " <chan num> is the channel number relative to the device\n" 16024 " <gain> is the gain in dB (e.g. -3.5 for -3.5dB)\n" 16027 " * hwgain is only supportable by hardware with analog ports because\n" 16028 " hwgain works on the analog side of an analog-digital conversion.\n";
16037 if (!strcasecmp(
"rx", a->
argv[3]))
16039 else if (!strcasecmp(
"tx", a->
argv[3]))
16044 channel = atoi(a->
argv[4]);
16045 gain = atof(a->
argv[5]);
16049 for (tmp = iflist;
tmp; tmp = tmp->
next) {
16058 ast_cli(a->
fd,
"Unable to set the hardware gain for channel %d: %s\n", channel, strerror(
errno));
16062 ast_cli(a->
fd,
"Hardware %s gain set to %.1f dB on channel %d.\n",
16063 tx ?
"tx" :
"rx", gain, channel);
16080 ast_cli(a->
fd,
"Unable to find given channel %d\n", channel);
16095 e->
command =
"dahdi set swgain {rx|tx}";
16097 "Usage: dahdi set swgain <rx|tx> <chan#> <gain>\n" 16098 " Sets the software gain on a given channel and overrides the\n" 16099 " value provided at module loadtime. Changes take effect\n" 16100 " immediately whether the channel is in use or not.\n" 16102 " <rx|tx> which direction do you want to change (relative to our module)\n" 16103 " <chan num> is the channel number relative to the device\n" 16104 " <gain> is the gain in dB (e.g. -3.5 for -3.5dB)\n";
16113 if (!strcasecmp(
"rx", a->
argv[3]))
16115 else if (!strcasecmp(
"tx", a->
argv[3]))
16120 channel = atoi(a->
argv[4]);
16121 gain = atof(a->
argv[5]);
16124 for (tmp = iflist;
tmp; tmp = tmp->
next) {
16138 ast_cli(a->
fd,
"Unable to set the software gain for channel %d\n", channel);
16143 ast_cli(a->
fd,
"Software %s gain set to %.2f dB on channel %d.\n",
16144 tx ?
"tx" :
"rx", gain, channel);
16158 ast_cli(a->
fd,
"Unable to find given channel %d\n", channel);
16171 e->
command =
"dahdi set dnd";
16173 "Usage: dahdi set dnd <chan#> <on|off>\n" 16174 " Sets/resets DND (Do Not Disturb) mode on a channel.\n" 16175 " Changes take effect immediately.\n" 16176 " <chan num> is the channel number\n" 16177 " <on|off> Enable or disable DND mode?\n" 16187 if ((channel = atoi(a->
argv[3])) <= 0) {
16188 ast_cli(a->
fd,
"Expected channel number, got '%s'\n", a->
argv[3]);
16197 ast_cli(a->
fd,
"Expected 'on' or 'off', got '%s'\n", a->
argv[4]);
16202 for (dahdi_chan = iflist; dahdi_chan; dahdi_chan = dahdi_chan->
next) {
16203 if (dahdi_chan->
channel != channel)
16213 ast_cli(a->
fd,
"Unable to find given channel %d\n", channel);
16258 for (p = iflist; p; p = p->
next) {
16280 if (sscanf(channel,
"%30d", &chan_num) != 1) {
16396 for (i = 0; i < strlen(number); i++) {
16411 int dahdichanquery;
16413 if (!dahdichannel || sscanf(dahdichannel,
"%30d", &dahdichanquery) != 1) {
16415 dahdichanquery = -1;
16420 snprintf(idText,
sizeof(idText),
"ActionID: %s\r\n",
id);
16427 for (tmp = iflist;
tmp; tmp = tmp->
next) {
16432 if (dahdichanquery > 0 && tmp->
channel != dahdichanquery)
16440 "Event: DAHDIShowChannels\r\n" 16441 "DAHDIChannel: %d\r\n" 16444 "AccountCode: %s\r\n" 16445 "Signalling: %s\r\n" 16446 "SignallingCode: %d\r\n" 16450 "Description: %s\r\n" 16460 dahdi_dnd(tmp, -1) ?
"Enabled" :
"Disabled",
16465 "Event: DAHDIShowChannels\r\n" 16466 "DAHDIChannel: %d\r\n" 16467 "Signalling: %s\r\n" 16468 "SignallingCode: %d\r\n" 16472 "Description: %s\r\n" 16477 dahdi_dnd(tmp, -1) ?
"Enabled" :
"Disabled",
16492 #if defined(HAVE_PRI) 16498 struct dahdi_pri *dspan;
16501 char action_id[256];
16502 const char *show_cmd =
"PRIShowSpans";
16506 span_query = atoi(span_str);
16512 snprintf(action_id,
sizeof(action_id),
"ActionID: %s\r\n",
id);
16514 action_id[0] =
'\0';
16520 for (idx = 0; idx <
ARRAY_LEN(pris); ++idx) {
16521 dspan = &pris[idx];
16524 if (0 < span_query && dspan->pri.span != span_query) {
16528 if (dspan->pri.pri) {
16541 #if defined(HAVE_SS7) 16542 static int linkset_addsigchan(
int sigchan)
16544 struct dahdi_ss7 *link;
16547 struct dahdi_params params;
16548 struct dahdi_bufferinfo bi;
16549 struct dahdi_spaninfo si;
16555 if (cur_ss7type < 0) {
16559 if (cur_pointcode < 0) {
16563 if (cur_adjpointcode < 0) {
16567 if (cur_defaultdpc < 0) {
16571 if (cur_networkindicator < 0) {
16575 link = ss7_resolve_linkset(cur_linkset);
16577 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
16585 curfd = link->ss7.numsigchans;
16588 link->ss7.fds[curfd] = open(
"/dev/dahdi/channel", O_RDWR, 0600);
16589 if (link->ss7.fds[curfd] < 0) {
16594 if (ioctl(link->ss7.fds[curfd], DAHDI_SPECIFY, &sigchan) == -1) {
16595 dahdi_close_ss7_fd(link, curfd);
16602 memset(¶ms, 0,
sizeof(params));
16603 res = ioctl(link->ss7.fds[curfd], DAHDI_GET_PARAMS, ¶ms);
16605 dahdi_close_ss7_fd(link, curfd);
16606 ast_log(
LOG_ERROR,
"Unable to get parameters for sigchan %d (%s)\n", sigchan,
16610 if (params.sigtype != DAHDI_SIG_HDLCFCS
16611 && params.sigtype != DAHDI_SIG_HARDHDLC
16612 && params.sigtype != DAHDI_SIG_MTP2) {
16613 dahdi_close_ss7_fd(link, curfd);
16619 memset(&bi, 0,
sizeof(bi));
16620 bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
16621 bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
16624 if (ioctl(link->ss7.fds[curfd], DAHDI_SET_BUFINFO, &bi)) {
16625 ast_log(
LOG_ERROR,
"Unable to set appropriate buffering on channel %d: %s\n",
16626 sigchan, strerror(
errno));
16627 dahdi_close_ss7_fd(link, curfd);
16632 memset(&si, 0,
sizeof(si));
16633 res = ioctl(link->ss7.fds[curfd], DAHDI_SPANSTAT, &si);
16635 dahdi_close_ss7_fd(link, curfd);
16636 ast_log(
LOG_ERROR,
"Unable to get span state for sigchan %d (%s)\n", sigchan,
16641 (params.sigtype == DAHDI_SIG_MTP2)
16642 ? SS7_TRANSPORT_DAHDIMTP2
16643 : SS7_TRANSPORT_DAHDIDCHAN,
16644 si.alarms, cur_networkindicator, cur_pointcode, cur_adjpointcode, cur_slc);
16646 dahdi_close_ss7_fd(link, curfd);
16650 ++link->ss7.numsigchans;
16656 #if defined(HAVE_SS7) 16662 e->
command =
"ss7 set debug {on|off} linkset";
16664 "Usage: ss7 set debug {on|off} linkset <linkset>\n" 16665 " Enables debugging on a given SS7 linkset\n";
16675 span = atoi(a->
argv[5]);
16676 if ((span < 1) || (span > NUM_SPANS)) {
16677 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number from %d to %d\n", a->
argv[5], 1, NUM_SPANS);
16680 if (!linksets[span-1].ss7.ss7) {
16681 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", span);
16683 if (!strcasecmp(a->
argv[3],
"on")) {
16684 linksets[span - 1].ss7.debug = 1;
16686 ast_cli(a->
fd,
"Enabled debugging on linkset %d\n", span);
16688 linksets[span - 1].ss7.debug = 0;
16689 ss7_set_debug(linksets[span-1].ss7.ss7, 0);
16690 ast_cli(a->
fd,
"Disabled debugging on linkset %d\n", span);
16698 #if defined(HAVE_SS7) 16708 e->
command =
"ss7 {block|unblock} cic";
16710 "Usage: ss7 {block|unblock} cic <linkset> <dpc> <CIC>\n" 16711 " Sends a remote {blocking|unblocking} request for the given CIC on the specified linkset\n";
16717 if (a->
argc == 6) {
16718 linkset = atoi(a->
argv[3]);
16723 if (!strcasecmp(a->
argv[1],
"block")) {
16725 }
else if (strcasecmp(a->
argv[1],
"unblock")) {
16729 if ((linkset < 1) || (linkset > NUM_SPANS)) {
16730 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
16734 if (!linksets[linkset-1].ss7.ss7) {
16735 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
16739 cic = atoi(a->
argv[5]);
16741 ast_cli(a->
fd,
"Invalid CIC specified!\n");
16745 dpc = atoi(a->
argv[4]);
16747 ast_cli(a->
fd,
"Invalid DPC specified!\n");
16751 for (i = 0; i < linksets[linkset-1].ss7.numchans; i++) {
16752 if (linksets[linkset-1].ss7.pvts[i] && linksets[linkset-1].ss7.pvts[i]->cic == cic && linksets[linkset-1].ss7.pvts[i]->dpc == dpc) {
16753 blocked = linksets[linkset-1].ss7.pvts[i]->locallyblocked;
16756 ast_cli(a->
fd,
"Unable to allocate new ss7call\n");
16758 ast_cli(a->
fd,
"Sent %sblocking request for linkset %d on CIC %d DPC %d\n", (do_block) ?
"" :
"un", linkset, cic, dpc);
16760 }
else if (!do_block && blocked) {
16761 ast_cli(a->
fd,
"CIC %d is hardware locally blocked!\n", cic);
16763 ast_cli(a->
fd,
"CIC %d %s locally blocked\n", cic, do_block ?
"already" :
"is not");
16769 ast_cli(a->
fd,
"Invalid CIC specified!\n");
16774 #if defined(HAVE_SS7) 16786 e->
command =
"ss7 {reset|block|unblock} linkset";
16788 "Usage: ss7 {reset|block|unblock} linkset <linkset number>\n" 16789 " Sends a remote {reset|blocking|unblocking} request for all CICs on the given linkset\n";
16795 if (a->
argc == 4) {
16796 linkset = atoi(a->
argv[3]);
16801 if (!strcasecmp(a->
argv[1],
"block")) {
16802 do_what = DO_BLOCK;
16803 }
else if (!strcasecmp(a->
argv[1],
"unblock")) {
16804 do_what = DO_UNBLOCK;
16805 }
else if (!strcasecmp(a->
argv[1],
"reset")) {
16806 do_what = DO_RESET;
16811 if ((linkset < 1) || (linkset > NUM_SPANS)) {
16812 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
16816 if (!linksets[linkset - 1].ss7.ss7) {
16817 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
16821 for (i = 0; i < linksets[linkset - 1].ss7.numchans; i++) {
16823 if (linksets[linkset - 1].ss7.pvts[i]) {
16828 ast_cli(a->
fd,
"Sent remote %s request on CIC %d\n",
16829 (do_what == DO_BLOCK) ?
"blocking" :
"unblocking",
16830 linksets[linkset - 1].ss7.pvts[i]->cic);
16835 linksets[linkset - 1].ss7.pvts[i]->cic,
16836 linksets[linkset - 1].ss7.pvts[i]->dpc)) {
16837 ast_cli(a->
fd,
"Sent reset request on CIC %d\n",
16838 linksets[linkset - 1].ss7.pvts[i]->cic);
16849 #if defined(HAVE_SS7) 16852 int linkset, cic, range, chanpos;
16853 int i, dpc, orient = 0;
16855 unsigned char state[255];
16859 e->
command =
"ss7 {block|unblock} group";
16861 "Usage: ss7 {block|unblock} group <linkset> <dpc> <1st. CIC> <range> [H]\n" 16862 " Sends a remote {blocking|unblocking} request for CIC range on the specified linkset\n";
16868 if (a->
argc == 7 || a->
argc == 8) {
16869 linkset = atoi(a->
argv[3]);
16874 if (!strcasecmp(a->
argv[1],
"block")) {
16876 }
else if (strcasecmp(a->
argv[1],
"unblock")) {
16880 if (a->
argc == 8) {
16881 if (!strcasecmp(a->
argv[7],
"H")) {
16888 if ((linkset < 1) || (linkset > NUM_SPANS)) {
16889 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[4], 1, NUM_SPANS);
16893 if (!linksets[linkset-1].ss7.ss7) {
16894 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
16898 cic = atoi(a->
argv[5]);
16900 ast_cli(a->
fd,
"Invalid CIC specified!\n");
16904 range = atoi(a->
argv[6]);
16906 if (range < 1 || range > (linksets[linkset - 1].ss7.type == SS7_ANSI ? 24 : 31)) {
16907 ast_cli(a->
fd,
"Invalid range specified!\n");
16911 dpc = atoi(a->
argv[4]);
16913 ast_cli(a->
fd,
"Invalid DPC specified!\n");
16924 memset(state, 0,
sizeof(state));
16925 for (i = 0; i <= range; ++i) {
16932 ast_cli(a->
fd,
"Unable allocate new ss7call\n");
16934 ast_cli(a->
fd,
"Sending remote%s %sblocking request linkset %d on CIC %d range %d\n",
16935 orient ?
" hardware" :
"", do_block ?
"" :
"un", linkset, cic, range);
16942 pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
16948 #if defined(HAVE_SS7) 16951 int linkset, cic, range;
16956 e->
command =
"ss7 reset group";
16958 "Usage: ss7 reset group <linkset> <dpc> <1st CIC> <range>\n" 16959 " Send a GRS for the given CIC range on the specified linkset\n";
16965 if (a->
argc == 7) {
16966 linkset = atoi(a->
argv[3]);
16971 if ((linkset < 1) || (linkset > NUM_SPANS)) {
16972 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[4], 1, NUM_SPANS);
16976 if (!linksets[linkset-1].ss7.ss7) {
16977 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
16981 cic = atoi(a->
argv[5]);
16984 ast_cli(a->
fd,
"Invalid CIC specified!\n");
16988 range = atoi(a->
argv[6]);
16989 if (range < 1 || range > (linksets[linkset - 1].ss7.type == SS7_ANSI ? 24 : 31)) {
16990 ast_cli(a->
fd,
"Invalid range specified!\n");
16994 dpc = atoi(a->
argv[4]);
16996 ast_cli(a->
fd,
"Invalid DPC specified!\n");
17008 ast_cli(a->
fd,
"Unable to allocate new ss7call\n");
17017 pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
17023 #if defined(HAVE_SS7) 17030 e->
command =
"ss7 show calls";
17032 "Usage: ss7 show calls <linkset>\n" 17033 " Show SS7 calls on the specified linkset\n";
17039 if (a->
argc == 4) {
17040 linkset = atoi(a->
argv[3]);
17045 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17046 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
17050 if (!linksets[linkset-1].ss7.ss7) {
17051 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17056 isup_show_calls(linksets[linkset-1].ss7.ss7, &
ast_cli, a->
fd);
17063 #if defined(HAVE_SS7) 17066 int linkset, cic, res;
17071 e->
command =
"ss7 reset cic";
17073 "Usage: ss7 reset cic <linkset> <dpc> <CIC>\n" 17074 " Send a RSC for the given CIC on the specified linkset\n";
17080 if (a->
argc == 6) {
17081 linkset = atoi(a->
argv[3]);
17086 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17087 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
17091 if (!linksets[linkset-1].ss7.ss7) {
17092 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17096 cic = atoi(a->
argv[5]);
17099 ast_cli(a->
fd,
"Invalid CIC specified!\n");
17103 dpc = atoi(a->
argv[4]);
17105 ast_cli(a->
fd,
"Invalid DPC specified!\n");
17111 ast_cli(a->
fd,
"%s RSC for linkset %d on CIC %d DPC %d\n", res ?
"Sent" :
"Failed", linkset, cic, dpc);
17117 #if defined(HAVE_SS7) 17122 unsigned int arg = 0;
17129 "Usage: ss7 mtp3 <linkset> <slc> coo|coa|cbd|cba|eco|eca|tfp|tfa|lin|lun|lia|lua|lid|lfu <arg>\n" 17130 " Send a NET MNG message\n" 17131 " WARNING!!! WARNING!!! We are not a STP, just for testing/development purposes\n";
17141 linkset = atoi(a->
argv[2]);
17142 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17143 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[2], 1, NUM_SPANS);
17146 if (!linksets[linkset-1].ss7.ss7) {
17147 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17151 slc = atoi(a->
argv[3]);
17153 if (a->
argc == 6) {
17154 arg = atoi(a->
argv[5]);
17158 res = mtp3_net_mng(linksets[linkset-1].ss7.ss7, slc, a->
argv[4], arg);
17163 pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
17172 #if defined(HAVE_SS7) 17176 unsigned int slc = 0;
17180 e->
command =
"ss7 restart mtp3";
17182 "Usage: ss7 restart mtp3 <linkset> <slc>\n" 17193 linkset = atoi(a->
argv[3]);
17194 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17195 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[2], 1, NUM_SPANS);
17198 if (!linksets[linkset-1].ss7.ss7) {
17199 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17203 slc = atoi(a->
argv[4]);
17206 mtp3_init_restart(linksets[linkset-1].ss7.ss7, slc);
17211 pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
17218 #if defined(HAVE_SS7) 17225 e->
command =
"ss7 show linkset";
17227 "Usage: ss7 show linkset <span>\n" 17228 " Shows the status of an SS7 linkset.\n";
17238 linkset = atoi(a->
argv[3]);
17239 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17240 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
17243 ss7 = &linksets[linkset - 1].ss7;
17245 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17264 #if defined(HAVE_SS7) 17271 e->
command =
"ss7 show channels";
17273 "Usage: ss7 show channels\n" 17274 " Displays SS7 channel information at a glance.\n";
17280 if (a->
argc != 3) {
17285 for (linkset = 0; linkset <
NUM_SPANS; ++linkset) {
17286 if (linksets[linkset].ss7.ss7) {
17294 #if defined(HAVE_SS7) 17297 #define FORMAT "%5s %5s %6s %12s %-12s\n" 17298 #define FORMAT2 "%5i %5i %6i %12s %-12s\n" 17299 int i, linkset, dpc = 0;
17306 e->
command =
"ss7 show cics";
17308 "Usage: ss7 show cics <linkset> [dpc]\n" 17309 " Shows the cics of an SS7 linkset.\n";
17319 linkset = atoi(a->
argv[3]);
17321 if ((linkset < 1) || (linkset > NUM_SPANS)) {
17322 ast_cli(a->
fd,
"Invalid linkset %s. Should be a number %d to %d\n", a->
argv[3], 1, NUM_SPANS);
17326 if (!linksets[linkset-1].ss7.
ss7) {
17327 ast_cli(a->
fd,
"No SS7 running on linkset %d\n", linkset);
17330 ss7 = &linksets[linkset-1].ss7;
17332 if (a->
argc == 5) {
17333 dpc = atoi(a->
argv[4]);
17335 ast_cli(a->
fd,
"Invalid DPC specified!\n");
17342 for (i = 0; i < ss7->
numchans; i++) {
17343 if (!dpc || (ss7->
pvts[i] && ss7->
pvts[i]->
dpc == dpc)) {
17351 state =
"NotInServ";
17357 strcpy(blocking,
"L:");
17359 strcat(blocking,
"M");
17361 strcat(blocking,
" ");
17365 strcat(blocking,
"H");
17367 strcat(blocking,
" ");
17370 strcpy(blocking,
" ");
17374 strcat(blocking,
" R:");
17376 strcat(blocking,
"M");
17378 strcat(blocking,
" ");
17382 strcat(blocking,
"H");
17384 strcat(blocking,
" ");
17398 #if defined(HAVE_SS7) 17403 e->
command =
"ss7 show version";
17405 "Usage: ss7 show version\n" 17406 " Show the libss7 version\n";
17412 ast_cli(a->
fd,
"libss7 version: %s\n", ss7_get_version());
17418 #if defined(HAVE_SS7) 17420 AST_CLI_DEFINE(handle_ss7_debug,
"Enables SS7 debugging on a linkset"),
17421 AST_CLI_DEFINE(handle_ss7_cic_blocking,
"Blocks/Unblocks the given CIC"),
17422 AST_CLI_DEFINE(handle_ss7_linkset_mng,
"Resets/Blocks/Unblocks all CICs on a linkset"),
17423 AST_CLI_DEFINE(handle_ss7_group_blocking,
"Blocks/Unblocks the given CIC range"),
17425 AST_CLI_DEFINE(handle_ss7_group_reset,
"Resets the given CIC range"),
17428 AST_CLI_DEFINE(handle_ss7_show_linkset,
"Shows the status of a linkset"),
17429 AST_CLI_DEFINE(handle_ss7_show_channels,
"Displays SS7 channel information"),
17436 #if defined(HAVE_PRI) 17437 #if defined(HAVE_PRI_CCSS) 17484 #if defined(HAVE_PRI) 17485 #if defined(HAVE_PRI_CCSS) 17499 static void dahdi_pri_cc_agent_destructor(
struct ast_cc_agent *agent)
17508 #if defined(HAVE_PRI) 17509 #if defined(HAVE_PRI_CCSS) 17511 .
type = dahdi_pri_cc_type,
17512 .init = dahdi_pri_cc_agent_init,
17521 .destructor = dahdi_pri_cc_agent_destructor,
17526 #if defined(HAVE_PRI) 17527 #if defined(HAVE_PRI_CCSS) 17529 .
type = dahdi_pri_cc_type,
17543 #if defined(HAVE_PRI) || defined(HAVE_SS7) 17550 pthread_cancel(pris[i].pri.
master);
17551 pthread_kill(pris[i].pri.
master, SIGURG);
17556 #ifdef HAVE_PRI_PROG_W_CAUSE 17560 #if defined(HAVE_SS7) 17563 pthread_cancel(linksets[i].ss7.master);
17564 pthread_kill(linksets[i].ss7.master, SIGURG);
17569 #if defined(HAVE_OPENR2) 17570 dahdi_r2_destroy_links();
17583 #if defined(HAVE_PRI) 17593 for (p = iflist; p; p = p->
next) {
17610 #if defined(HAVE_PRI) 17616 dahdi_close_pri_fd(&(pris[i]), j);
17620 #if defined(HAVE_PRI_CCSS) 17627 #if defined(HAVE_SS7) 17630 pthread_join(linksets[i].ss7.master,
NULL);
17633 dahdi_close_ss7_fd(&(linksets[i]), j);
17635 if (linksets[i].ss7.ss7) {
17636 ss7_destroy(linksets[i].ss7.ss7);
17637 linksets[i].ss7.ss7 =
NULL;
17653 #if defined(HAVE_PRI) || defined(HAVE_SS7) 17660 #if defined(HAVE_SS7) 17670 int x, start, finish;
17674 ast_log(
LOG_ERROR,
"Signalling must be specified before any channels are.\n");
17680 while ((chan =
strsep(&c,
","))) {
17681 if (sscanf(chan,
"%30d-%30d", &start, &finish) == 2) {
17683 }
else if (sscanf(chan,
"%30d", &start)) {
17686 }
else if (!strcasecmp(chan,
"pseudo")) {
17692 if (finish < start) {
17699 for (x = start; x <= finish; x++) {
17701 (x < conf->wanted_channels_start ||
17706 tmp =
mkintf(x, conf, reload);
17709 ast_verb(3,
"%s channel %d, %s signalling\n", reload ?
"Reconfigured" :
"Registered", x,
sig2str(tmp->
sig));
17712 (reload == 1) ?
"reconfigure" :
"register", value);
17726 #define MAX_CHANLIST_LEN 80 17731 char *
params[DAHDI_MAX_ECHOCANPARAMS + 1];
17732 unsigned int param_count;
17744 if ((x == 32) || (x == 64) || (x == 128) || (x == 256) || (x == 512) || (x == 1024))
17751 for (x = 1; x < param_count; x++) {
17758 ast_log(
LOG_WARNING,
"Invalid echocancel parameter supplied at line %u: '%s'\n", line, params[x]);
17763 ast_log(
LOG_WARNING,
"Invalid echocancel parameter supplied at line %u: '%s'\n", line, param.name);
17771 ast_log(
LOG_WARNING,
"Invalid echocancel parameter value supplied at line %u: '%s'\n", line, param.value);
17779 #if defined(HAVE_PRI) 17780 #if defined(HAVE_PRI_DISPLAY_TEXT) 17790 static unsigned long dahdi_display_text_option(
const char *
value)
17800 opt_str =
strsep(&val_str,
",");
17809 if (!strcasecmp(opt_str,
"block")) {
17810 options |= PRI_DISPLAY_OPTION_BLOCK;
17811 }
else if (!strcasecmp(opt_str,
"name_initial")) {
17812 options |= PRI_DISPLAY_OPTION_NAME_INITIAL;
17813 }
else if (!strcasecmp(opt_str,
"name_update")) {
17814 options |= PRI_DISPLAY_OPTION_NAME_UPDATE;
17815 }
else if (!strcasecmp(opt_str,
"name")) {
17816 options |= (PRI_DISPLAY_OPTION_NAME_INITIAL | PRI_DISPLAY_OPTION_NAME_UPDATE);
17817 }
else if (!strcasecmp(opt_str,
"text")) {
17818 options |= PRI_DISPLAY_OPTION_TEXT;
17826 #if defined(HAVE_PRI) 17827 #if defined(HAVE_PRI_DATETIME_SEND) 17837 static int dahdi_datetime_send_option(
const char *value)
17841 option = PRI_DATE_TIME_SEND_DEFAULT;
17844 option = PRI_DATE_TIME_SEND_NO;
17845 }
else if (!strcasecmp(value,
"date")) {
17846 option = PRI_DATE_TIME_SEND_DATE;
17847 }
else if (!strcasecmp(value,
"date_hh")) {
17848 option = PRI_DATE_TIME_SEND_DATE_HH;
17849 }
else if (!strcasecmp(value,
"date_hhmm")) {
17850 option = PRI_DATE_TIME_SEND_DATE_HHMM;
17851 }
else if (!strcasecmp(value,
"date_hhmmss")) {
17852 option = PRI_DATE_TIME_SEND_DATE_HHMMSS;
17861 #define PROC_DAHDI_OPT_NOCHAN (1 << 0) 17863 #define PROC_DAHDI_OPT_NOWARN (1 << 1) 17867 int count_pattern = 0;
17873 if (!sscanf(v->
value,
"%30d", &norval) && count_pattern == 0) {
17874 ast_log(
LOG_ERROR,
"busypattern= expects either busypattern=tonelength,quietlength or busypattern=t1length, q1length, t2length, q2length at line %d.\n", v->
lineno);
17878 busy_cadence->
pattern[count_pattern] = norval;
17881 if (count_pattern == 4) {
17885 temp = strchr(v->
value,
',');
17886 if (temp ==
NULL) {
17889 v->
value = temp + 1;
17891 busy_cadence->
length = count_pattern;
17893 if (count_pattern % 2 != 0) {
17895 ast_log(
LOG_ERROR,
"busypattern= expects either busypattern=tonelength,quietlength or busypattern=t1length, q1length, t2length, q2length at line %d.\n", v->
lineno);
17906 for (; v; v = v->
next) {
17911 if (!strcasecmp(v->
name,
"channel") || !strcasecmp(v->
name,
"channels")) {
17925 }
else if (!strcasecmp(v->
name,
"ignore_failed_channels")) {
17927 }
else if (!strcasecmp(v->
name,
"buffers")) {
17933 }
else if (!strcasecmp(v->
name,
"faxbuffers")) {
17937 }
else if (!strcasecmp(v->
name,
"dahdichan")) {
17940 }
else if (!strcasecmp(v->
name,
"usedistinctiveringdetection")) {
17942 }
else if (!strcasecmp(v->
name,
"distinctiveringaftercid")) {
17944 }
else if (!strcasecmp(v->
name,
"dring1context")) {
17946 }
else if (!strcasecmp(v->
name,
"dring2context")) {
17948 }
else if (!strcasecmp(v->
name,
"dring3context")) {
17950 }
else if (!strcasecmp(v->
name,
"dring1range")) {
17952 }
else if (!strcasecmp(v->
name,
"dring2range")) {
17954 }
else if (!strcasecmp(v->
name,
"dring3range")) {
17956 }
else if (!strcasecmp(v->
name,
"dring1")) {
17958 }
else if (!strcasecmp(v->
name,
"dring2")) {
17960 }
else if (!strcasecmp(v->
name,
"dring3")) {
17962 }
else if (!strcasecmp(v->
name,
"usecallerid")) {
17964 }
else if (!strcasecmp(v->
name,
"cidsignalling")) {
17965 if (!strcasecmp(v->
value,
"bell"))
17967 else if (!strcasecmp(v->
value,
"v23"))
17969 else if (!strcasecmp(v->
value,
"dtmf"))
17971 else if (!strcasecmp(v->
value,
"smdi"))
17973 else if (!strcasecmp(v->
value,
"v23_jp"))
17977 }
else if (!strcasecmp(v->
name,
"cidstart")) {
17978 if (!strcasecmp(v->
value,
"ring"))
17980 else if (!strcasecmp(v->
value,
"polarity_in"))
17982 else if (!strcasecmp(v->
value,
"polarity"))
17984 else if (!strcasecmp(v->
value,
"dtmf"))
17988 }
else if (!strcasecmp(v->
name,
"threewaycalling")) {
17990 }
else if (!strcasecmp(v->
name,
"cancallforward")) {
17992 }
else if (!strcasecmp(v->
name,
"relaxdtmf")) {
17997 }
else if (!strcasecmp(v->
name,
"mailbox")) {
17999 }
else if (!strcasecmp(v->
name,
"description")) {
18001 }
else if (!strcasecmp(v->
name,
"hasvoicemail")) {
18007 if (strchr(cat,
'@')) {
18011 "%s@default", cat);
18014 }
else if (!strcasecmp(v->
name,
"adsi")) {
18016 }
else if (!strcasecmp(v->
name,
"usesmdi")) {
18018 }
else if (!strcasecmp(v->
name,
"smdiport")) {
18020 }
else if (!strcasecmp(v->
name,
"transfer")) {
18022 }
else if (!strcasecmp(v->
name,
"canpark")) {
18024 }
else if (!strcasecmp(v->
name,
"echocancelwhenbridged")) {
18026 }
else if (!strcasecmp(v->
name,
"busydetect")) {
18028 }
else if (!strcasecmp(v->
name,
"busycount")) {
18030 }
else if (!strcasecmp(v->
name,
"busypattern")) {
18032 }
else if (!strcasecmp(v->
name,
"callprogress")) {
18036 }
else if (!strcasecmp(v->
name,
"waitfordialtone")) {
18038 }
else if (!strcasecmp(v->
name,
"dialtone_detect")) {
18039 if (!strcasecmp(v->
value,
"always")) {
18048 }
else if (!strcasecmp(v->
name,
"faxdetect")) {
18050 if (!strcasecmp(v->
value,
"incoming")) {
18052 }
else if (!strcasecmp(v->
value,
"outgoing")) {
18056 }
else if (!strcasecmp(v->
name,
"faxdetect_timeout")) {
18060 }
else if (!strcasecmp(v->
name,
"firstdigit_timeout")) {
18065 }
else if (!strcasecmp(v->
name,
"interdigit_timeout")) {
18070 }
else if (!strcasecmp(v->
name,
"matchdigit_timeout")) {
18075 }
else if (!strcasecmp(v->
name,
"echocancel")) {
18077 }
else if (!strcasecmp(v->
name,
"echotraining")) {
18078 if (sscanf(v->
value,
"%30d", &y) == 1) {
18079 if ((y < 10) || (y > 4000)) {
18088 }
else if (!strcasecmp(v->
name,
"hidecallerid")) {
18090 }
else if (!strcasecmp(v->
name,
"hidecalleridname")) {
18092 }
else if (!strcasecmp(v->
name,
"pulsedial")) {
18094 }
else if (!strcasecmp(v->
name,
"callreturn")) {
18096 }
else if (!strcasecmp(v->
name,
"callwaiting")) {
18098 }
else if (!strcasecmp(v->
name,
"callwaitingcallerid")) {
18100 }
else if (!strcasecmp(v->
name,
"context")) {
18102 }
else if (!strcasecmp(v->
name,
"language")) {
18104 }
else if (!strcasecmp(v->
name,
"progzone")) {
18106 }
else if (!strcasecmp(v->
name,
"mohinterpret")
18107 ||!strcasecmp(v->
name,
"musiconhold") || !strcasecmp(v->
name,
"musicclass")) {
18109 }
else if (!strcasecmp(v->
name,
"mohsuggest")) {
18111 }
else if (!strcasecmp(v->
name,
"parkinglot")) {
18113 }
else if (!strcasecmp(v->
name,
"stripmsd")) {
18114 ast_log(
LOG_NOTICE,
"Configuration option \"%s\" has been deprecated. Please use dialplan instead\n", v->
name);
18116 }
else if (!strcasecmp(v->
name,
"jitterbuffers")) {
18118 }
else if (!strcasecmp(v->
name,
"group")) {
18120 }
else if (!strcasecmp(v->
name,
"callgroup")) {
18121 if (!strcasecmp(v->
value,
"none"))
18125 }
else if (!strcasecmp(v->
name,
"pickupgroup")) {
18126 if (!strcasecmp(v->
value,
"none"))
18130 }
else if (!strcasecmp(v->
name,
"namedcallgroup")) {
18132 }
else if (!strcasecmp(v->
name,
"namedpickupgroup")) {
18134 }
else if (!strcasecmp(v->
name,
"setvar")) {
18136 char *varval =
NULL;
18138 char varname[strlen(v->
value) + 1];
18139 strcpy(varname, v->
value);
18140 if ((varval = strchr(varname,
'='))) {
18150 }
else if (!strcasecmp(v->
name,
"immediate")) {
18152 }
else if (!strcasecmp(v->
name,
"transfertobusy")) {
18154 }
else if (!strcasecmp(v->
name,
"mwimonitor")) {
18171 }
else if (!strcasecmp(v->
name,
"hwrxgain")) {
18173 if (strcasecmp(v->
value,
"disabled")) {
18180 }
else if (!strcasecmp(v->
name,
"hwtxgain")) {
18182 if (strcasecmp(v->
value,
"disabled")) {
18189 }
else if (!strcasecmp(v->
name,
"cid_rxgain")) {
18193 }
else if (!strcasecmp(v->
name,
"rxgain")) {
18197 }
else if (!strcasecmp(v->
name,
"txgain")) {
18201 }
else if (!strcasecmp(v->
name,
"txdrc")) {
18205 }
else if (!strcasecmp(v->
name,
"rxdrc")) {
18209 }
else if (!strcasecmp(v->
name,
"tonezone")) {
18213 }
else if (!strcasecmp(v->
name,
"callerid")) {
18214 if (!strcasecmp(v->
value,
"asreceived")) {
18220 }
else if (!strcasecmp(v->
name,
"fullname")) {
18222 }
else if (!strcasecmp(v->
name,
"cid_number")) {
18224 }
else if (!strcasecmp(v->
name,
"cid_tag")) {
18226 }
else if (!strcasecmp(v->
name,
"useincomingcalleridondahditransfer")) {
18228 }
else if (!strcasecmp(v->
name,
"restrictcid")) {
18230 }
else if (!strcasecmp(v->
name,
"usecallingpres")) {
18232 }
else if (!strcasecmp(v->
name,
"accountcode")) {
18234 }
else if (!strcasecmp(v->
name,
"amaflags")) {
18240 }
else if (!strcasecmp(v->
name,
"polarityonanswerdelay")) {
18242 }
else if (!strcasecmp(v->
name,
"answeronpolarityswitch")) {
18244 }
else if (!strcasecmp(v->
name,
"hanguponpolarityswitch")) {
18246 }
else if (!strcasecmp(v->
name,
"sendcalleridafter")) {
18248 }
else if (!strcasecmp(v->
name,
"mwimonitornotify")) {
18252 }
else if (!strcasecmp(v->
name,
"mwisendtype")) {
18253 #ifndef HAVE_DAHDI_LINEREVERSE_VMWI 18254 if (!strcasecmp(v->
value,
"rpas")) {
18261 memset(&confp->
chan.mwisend_setting, 0,
sizeof(confp->
chan.mwisend_setting));
18263 confp->
chan.mwisend_fsk = 0;
18265 confp->
chan.mwisend_fsk = 1;
18268 confp->
chan.mwisend_rpas = 1;
18270 confp->
chan.mwisend_rpas = 0;
18273 confp->
chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_LREV;
18276 confp->
chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_HVDC;
18279 confp->
chan.mwisend_setting.vmwi_type |= DAHDI_VMWI_HVAC;
18282 }
else if (reload != 1) {
18283 if (!strcasecmp(v->
name,
"signalling") || !strcasecmp(v->
name,
"signaling")) {
18291 if (!strcasecmp(v->
value,
"em")) {
18293 }
else if (!strcasecmp(v->
value,
"em_e1")) {
18295 }
else if (!strcasecmp(v->
value,
"em_w")) {
18297 }
else if (!strcasecmp(v->
value,
"fxs_ls")) {
18299 }
else if (!strcasecmp(v->
value,
"fxs_gs")) {
18301 }
else if (!strcasecmp(v->
value,
"fxs_ks")) {
18303 }
else if (!strcasecmp(v->
value,
"fxo_ls")) {
18305 }
else if (!strcasecmp(v->
value,
"fxo_gs")) {
18307 }
else if (!strcasecmp(v->
value,
"fxo_ks")) {
18309 }
else if (!strcasecmp(v->
value,
"fxs_rx")) {
18312 }
else if (!strcasecmp(v->
value,
"fxo_rx")) {
18315 }
else if (!strcasecmp(v->
value,
"fxs_tx")) {
18318 }
else if (!strcasecmp(v->
value,
"fxo_tx")) {
18321 }
else if (!strcasecmp(v->
value,
"em_rx")) {
18324 }
else if (!strcasecmp(v->
value,
"em_tx")) {
18327 }
else if (!strcasecmp(v->
value,
"em_rxtx")) {
18330 }
else if (!strcasecmp(v->
value,
"em_txrx")) {
18333 }
else if (!strcasecmp(v->
value,
"sf")) {
18335 }
else if (!strcasecmp(v->
value,
"sf_w")) {
18337 }
else if (!strcasecmp(v->
value,
"sf_featd")) {
18339 }
else if (!strcasecmp(v->
value,
"sf_featdmf")) {
18341 }
else if (!strcasecmp(v->
value,
"sf_featb")) {
18343 }
else if (!strcasecmp(v->
value,
"sf")) {
18345 }
else if (!strcasecmp(v->
value,
"sf_rx")) {
18348 }
else if (!strcasecmp(v->
value,
"sf_tx")) {
18351 }
else if (!strcasecmp(v->
value,
"sf_rxtx")) {
18354 }
else if (!strcasecmp(v->
value,
"sf_txrx")) {
18357 }
else if (!strcasecmp(v->
value,
"featd")) {
18359 }
else if (!strcasecmp(v->
value,
"featdmf")) {
18361 }
else if (!strcasecmp(v->
value,
"featdmf_ta")) {
18363 }
else if (!strcasecmp(v->
value,
"e911")) {
18365 }
else if (!strcasecmp(v->
value,
"fgccama")) {
18367 }
else if (!strcasecmp(v->
value,
"fgccamamf")) {
18369 }
else if (!strcasecmp(v->
value,
"featb")) {
18372 }
else if (!strcasecmp(v->
value,
"pri_net")) {
18374 confp->pri.pri.nodetype = PRI_NETWORK;
18375 }
else if (!strcasecmp(v->
value,
"pri_cpe")) {
18377 confp->pri.pri.nodetype = PRI_CPE;
18378 }
else if (!strcasecmp(v->
value,
"bri_cpe")) {
18380 confp->pri.pri.nodetype = PRI_CPE;
18381 }
else if (!strcasecmp(v->
value,
"bri_net")) {
18383 confp->pri.pri.nodetype = PRI_NETWORK;
18384 }
else if (!strcasecmp(v->
value,
"bri_cpe_ptmp")) {
18386 confp->pri.pri.nodetype = PRI_CPE;
18387 }
else if (!strcasecmp(v->
value,
"bri_net_ptmp")) {
18388 #if defined(HAVE_PRI_CALL_HOLD) 18390 confp->pri.pri.nodetype = PRI_NETWORK;
18392 ast_log(
LOG_WARNING,
"How cool would it be if someone implemented this mode! For now, sucks for you. (line %d)\n", v->
lineno);
18395 #if defined(HAVE_SS7) 18396 }
else if (!strcasecmp(v->
value,
"ss7")) {
18400 }
else if (!strcasecmp(v->
value,
"mfcr2")) {
18403 }
else if (!strcasecmp(v->
value,
"auto")) {
18411 }
else if (!strcasecmp(v->
name,
"outsignalling") || !strcasecmp(v->
name,
"outsignaling")) {
18412 if (!strcasecmp(v->
value,
"em")) {
18414 }
else if (!strcasecmp(v->
value,
"em_e1")) {
18416 }
else if (!strcasecmp(v->
value,
"em_w")) {
18418 }
else if (!strcasecmp(v->
value,
"sf")) {
18420 }
else if (!strcasecmp(v->
value,
"sf_w")) {
18422 }
else if (!strcasecmp(v->
value,
"sf_featd")) {
18424 }
else if (!strcasecmp(v->
value,
"sf_featdmf")) {
18426 }
else if (!strcasecmp(v->
value,
"sf_featb")) {
18428 }
else if (!strcasecmp(v->
value,
"sf")) {
18430 }
else if (!strcasecmp(v->
value,
"featd")) {
18432 }
else if (!strcasecmp(v->
value,
"featdmf")) {
18434 }
else if (!strcasecmp(v->
value,
"featdmf_ta")) {
18436 }
else if (!strcasecmp(v->
value,
"e911")) {
18438 }
else if (!strcasecmp(v->
value,
"fgccama")) {
18440 }
else if (!strcasecmp(v->
value,
"fgccamamf")) {
18442 }
else if (!strcasecmp(v->
value,
"featb")) {
18448 }
else if (!strcasecmp(v->
name,
"pridialplan")) {
18449 if (!strcasecmp(v->
value,
"national")) {
18450 confp->pri.pri.dialplan = PRI_NATIONAL_ISDN + 1;
18451 }
else if (!strcasecmp(v->
value,
"unknown")) {
18452 confp->pri.pri.dialplan = PRI_UNKNOWN + 1;
18453 }
else if (!strcasecmp(v->
value,
"private")) {
18454 confp->pri.pri.dialplan = PRI_PRIVATE + 1;
18455 }
else if (!strcasecmp(v->
value,
"international")) {
18456 confp->pri.pri.dialplan = PRI_INTERNATIONAL_ISDN + 1;
18457 }
else if (!strcasecmp(v->
value,
"local")) {
18458 confp->pri.pri.dialplan = PRI_LOCAL_ISDN + 1;
18459 }
else if (!strcasecmp(v->
value,
"dynamic")) {
18460 confp->pri.pri.dialplan = -1;
18461 }
else if (!strcasecmp(v->
value,
"redundant")) {
18462 confp->pri.pri.dialplan = -2;
18466 }
else if (!strcasecmp(v->
name,
"prilocaldialplan")) {
18467 if (!strcasecmp(v->
value,
"national")) {
18468 confp->pri.pri.localdialplan = PRI_NATIONAL_ISDN + 1;
18469 }
else if (!strcasecmp(v->
value,
"unknown")) {
18470 confp->pri.pri.localdialplan = PRI_UNKNOWN + 1;
18471 }
else if (!strcasecmp(v->
value,
"private")) {
18472 confp->pri.pri.localdialplan = PRI_PRIVATE + 1;
18473 }
else if (!strcasecmp(v->
value,
"international")) {
18474 confp->pri.pri.localdialplan = PRI_INTERNATIONAL_ISDN + 1;
18475 }
else if (!strcasecmp(v->
value,
"local")) {
18476 confp->pri.pri.localdialplan = PRI_LOCAL_ISDN + 1;
18477 }
else if (!strcasecmp(v->
value,
"from_channel")) {
18478 confp->pri.pri.localdialplan = 0;
18479 }
else if (!strcasecmp(v->
value,
"dynamic")) {
18480 confp->pri.pri.localdialplan = -1;
18481 }
else if (!strcasecmp(v->
value,
"redundant")) {
18482 confp->pri.pri.localdialplan = -2;
18486 }
else if (!strcasecmp(v->
name,
"pricpndialplan")) {
18487 if (!strcasecmp(v->
value,
"national")) {
18488 confp->pri.pri.cpndialplan = PRI_NATIONAL_ISDN + 1;
18489 }
else if (!strcasecmp(v->
value,
"unknown")) {
18490 confp->pri.pri.cpndialplan = PRI_UNKNOWN + 1;
18491 }
else if (!strcasecmp(v->
value,
"private")) {
18492 confp->pri.pri.cpndialplan = PRI_PRIVATE + 1;
18493 }
else if (!strcasecmp(v->
value,
"international")) {
18494 confp->pri.pri.cpndialplan = PRI_INTERNATIONAL_ISDN + 1;
18495 }
else if (!strcasecmp(v->
value,
"local")) {
18496 confp->pri.pri.cpndialplan = PRI_LOCAL_ISDN + 1;
18497 }
else if (!strcasecmp(v->
value,
"from_channel")) {
18498 confp->pri.pri.cpndialplan = 0;
18499 }
else if (!strcasecmp(v->
value,
"dynamic")) {
18500 confp->pri.pri.cpndialplan = -1;
18501 }
else if (!strcasecmp(v->
value,
"redundant")) {
18502 confp->pri.pri.cpndialplan = -2;
18506 }
else if (!strcasecmp(v->
name,
"switchtype")) {
18507 if (!strcasecmp(v->
value,
"national"))
18508 confp->pri.pri.switchtype = PRI_SWITCH_NI2;
18509 else if (!strcasecmp(v->
value,
"ni1"))
18510 confp->pri.pri.switchtype = PRI_SWITCH_NI1;
18511 else if (!strcasecmp(v->
value,
"dms100"))
18512 confp->pri.pri.switchtype = PRI_SWITCH_DMS100;
18513 else if (!strcasecmp(v->
value,
"4ess"))
18514 confp->pri.pri.switchtype = PRI_SWITCH_ATT4ESS;
18515 else if (!strcasecmp(v->
value,
"5ess"))
18516 confp->pri.pri.switchtype = PRI_SWITCH_LUCENT5E;
18517 else if (!strcasecmp(v->
value,
"euroisdn"))
18518 confp->pri.pri.switchtype = PRI_SWITCH_EUROISDN_E1;
18519 else if (!strcasecmp(v->
value,
"qsig"))
18520 confp->pri.pri.switchtype = PRI_SWITCH_QSIG;
18525 }
else if (!strcasecmp(v->
name,
"msn")) {
18527 sizeof(confp->pri.pri.msn_list));
18528 }
else if (!strcasecmp(v->
name,
"nsf")) {
18529 if (!strcasecmp(v->
value,
"sdn"))
18530 confp->pri.pri.nsf = PRI_NSF_SDN;
18531 else if (!strcasecmp(v->
value,
"megacom"))
18532 confp->pri.pri.nsf = PRI_NSF_MEGACOM;
18533 else if (!strcasecmp(v->
value,
"tollfreemegacom"))
18534 confp->pri.pri.nsf = PRI_NSF_TOLL_FREE_MEGACOM;
18535 else if (!strcasecmp(v->
value,
"accunet"))
18536 confp->pri.pri.nsf = PRI_NSF_ACCUNET;
18537 else if (!strcasecmp(v->
value,
"none"))
18538 confp->pri.pri.nsf = PRI_NSF_NONE;
18541 confp->pri.pri.nsf = PRI_NSF_NONE;
18543 }
else if (!strcasecmp(v->
name,
"priindication")) {
18544 if (!strcasecmp(v->
value,
"outofband"))
18546 else if (!strcasecmp(v->
value,
"inband"))
18549 ast_log(
LOG_WARNING,
"'%s' is not a valid pri indication value, should be 'inband' or 'outofband' at line %d.\n",
18551 }
else if (!strcasecmp(v->
name,
"priexclusive")) {
18553 }
else if (!strcasecmp(v->
name,
"internationalprefix")) {
18554 ast_copy_string(confp->pri.pri.internationalprefix, v->
value,
sizeof(confp->pri.pri.internationalprefix));
18555 }
else if (!strcasecmp(v->
name,
"nationalprefix")) {
18556 ast_copy_string(confp->pri.pri.nationalprefix, v->
value,
sizeof(confp->pri.pri.nationalprefix));
18557 }
else if (!strcasecmp(v->
name,
"localprefix")) {
18559 }
else if (!strcasecmp(v->
name,
"privateprefix")) {
18560 ast_copy_string(confp->pri.pri.privateprefix, v->
value,
sizeof(confp->pri.pri.privateprefix));
18561 }
else if (!strcasecmp(v->
name,
"unknownprefix")) {
18562 ast_copy_string(confp->pri.pri.unknownprefix, v->
value,
sizeof(confp->pri.pri.unknownprefix));
18563 }
else if (!strcasecmp(v->
name,
"resetinterval")) {
18564 if (!strcasecmp(v->
value,
"never"))
18565 confp->pri.pri.resetinterval = -1;
18566 else if (atoi(v->
value) >= 60)
18567 confp->pri.pri.resetinterval = atoi(v->
value);
18569 ast_log(
LOG_WARNING,
"'%s' is not a valid reset interval, should be >= 60 seconds or 'never' at line %d.\n",
18571 }
else if (!strcasecmp(v->
name,
"force_restart_unavailable_chans")) {
18572 confp->pri.pri.force_restart_unavailable_chans =
ast_true(v->
value);
18573 }
else if (!strcasecmp(v->
name,
"minunused")) {
18574 confp->pri.pri.minunused = atoi(v->
value);
18575 }
else if (!strcasecmp(v->
name,
"minidle")) {
18576 confp->pri.pri.minidle = atoi(v->
value);
18577 }
else if (!strcasecmp(v->
name,
"idleext")) {
18579 }
else if (!strcasecmp(v->
name,
"idledial")) {
18581 }
else if (!strcasecmp(v->
name,
"overlapdial")) {
18584 }
else if (!strcasecmp(v->
value,
"incoming")) {
18586 }
else if (!strcasecmp(v->
value,
"outgoing")) {
18593 #ifdef HAVE_PRI_PROG_W_CAUSE 18594 }
else if (!strcasecmp(v->
name,
"qsigchannelmapping")) {
18595 if (!strcasecmp(v->
value,
"logical")) {
18597 }
else if (!strcasecmp(v->
value,
"physical")) {
18603 }
else if (!strcasecmp(v->
name,
"discardremoteholdretrieval")) {
18604 confp->pri.pri.discardremoteholdretrieval =
ast_true(v->
value);
18605 #if defined(HAVE_PRI_SERVICE_MESSAGES) 18606 }
else if (!strcasecmp(v->
name,
"service_message_support")) {
18608 if ((confp->pri.pri.switchtype == PRI_SWITCH_ATT4ESS
18609 || confp->pri.pri.switchtype == PRI_SWITCH_LUCENT5E
18610 || confp->pri.pri.switchtype == PRI_SWITCH_NI2) &&
ast_true(v->
value)) {
18611 confp->pri.pri.enable_service_message_support = 1;
18613 confp->pri.pri.enable_service_message_support = 0;
18616 #ifdef HAVE_PRI_INBANDDISCONNECT 18617 }
else if (!strcasecmp(v->
name,
"inbanddisconnect")) {
18620 }
else if (!strcasecmp(v->
name,
"pritimer")) {
18621 #ifdef PRI_GETSET_TIMERS 18630 timerc =
strsep(&c,
",");
18632 timeridx = pri_timer2idx(timerc);
18634 if (timeridx < 0 || PRI_MAX_TIMERS <= timeridx) {
18636 "'%s' is not a valid ISDN timer at line %d.\n", timerc,
18638 }
else if (!timer) {
18640 "'%s' is not a valid value for ISDN timer '%s' at line %d.\n",
18643 confp->pri.pri.pritimers[timeridx] =
timer;
18647 "'%s' is not a valid ISDN timer configuration string at line %d.\n",
18651 }
else if (!strcasecmp(v->
name,
"facilityenable")) {
18653 #if defined(HAVE_PRI_AOC_EVENTS) 18654 }
else if (!strcasecmp(v->
name,
"aoc_enable")) {
18655 confp->pri.pri.aoc_passthrough_flag = 0;
18656 if (strchr(v->
value,
's') || strchr(v->
value,
'S')) {
18659 if (strchr(v->
value,
'd') || strchr(v->
value,
'D')) {
18662 if (strchr(v->
value,
'e') || strchr(v->
value,
'E')) {
18665 }
else if (!strcasecmp(v->
name,
"aoce_delayhangup")) {
18668 #if defined(HAVE_PRI_CALL_HOLD) 18669 }
else if (!strcasecmp(v->
name,
"hold_disconnect_transfer")) {
18670 confp->pri.pri.hold_disconnect_transfer =
ast_true(v->
value);
18672 }
else if (!strcasecmp(v->
name,
"moh_signaling")
18673 || !strcasecmp(v->
name,
"moh_signalling")) {
18674 if (!strcasecmp(v->
value,
"moh")) {
18676 }
else if (!strcasecmp(v->
value,
"notify")) {
18678 #if defined(HAVE_PRI_CALL_HOLD) 18679 }
else if (!strcasecmp(v->
value,
"hold")) {
18680 confp->pri.pri.moh_signaling = SIG_PRI_MOH_SIGNALING_HOLD;
18685 #if defined(HAVE_PRI_CCSS) 18686 }
else if (!strcasecmp(v->
name,
"cc_ptmp_recall_mode")) {
18687 if (!strcasecmp(v->
value,
"global")) {
18688 confp->pri.pri.cc_ptmp_recall_mode = 0;
18689 }
else if (!strcasecmp(v->
value,
"specific")) {
18690 confp->pri.pri.cc_ptmp_recall_mode = 1;
18692 confp->pri.pri.cc_ptmp_recall_mode = 1;
18694 }
else if (!strcasecmp(v->
name,
"cc_qsig_signaling_link_req")) {
18695 if (!strcasecmp(v->
value,
"release")) {
18696 confp->pri.pri.cc_qsig_signaling_link_req = 0;
18697 }
else if (!strcasecmp(v->
value,
"retain")) {
18698 confp->pri.pri.cc_qsig_signaling_link_req = 1;
18699 }
else if (!strcasecmp(v->
value,
"do_not_care")) {
18700 confp->pri.pri.cc_qsig_signaling_link_req = 2;
18702 confp->pri.pri.cc_qsig_signaling_link_req = 1;
18704 }
else if (!strcasecmp(v->
name,
"cc_qsig_signaling_link_rsp")) {
18705 if (!strcasecmp(v->
value,
"release")) {
18706 confp->pri.pri.cc_qsig_signaling_link_rsp = 0;
18707 }
else if (!strcasecmp(v->
value,
"retain")) {
18708 confp->pri.pri.cc_qsig_signaling_link_rsp = 1;
18710 confp->pri.pri.cc_qsig_signaling_link_rsp = 1;
18713 #if defined(HAVE_PRI_CALL_WAITING) 18714 }
else if (!strcasecmp(v->
name,
"max_call_waiting_calls")) {
18715 confp->pri.pri.max_call_waiting_calls = atoi(v->
value);
18716 if (confp->pri.pri.max_call_waiting_calls < 0) {
18718 confp->pri.pri.max_call_waiting_calls = 0;
18720 }
else if (!strcasecmp(v->
name,
"allow_call_waiting_calls")) {
18721 confp->pri.pri.allow_call_waiting_calls =
ast_true(v->
value);
18723 #if defined(HAVE_PRI_MWI) 18724 }
else if (!strcasecmp(v->
name,
"mwi_mailboxes")) {
18726 sizeof(confp->pri.pri.mwi_mailboxes));
18727 }
else if (!strcasecmp(v->
name,
"mwi_vm_boxes")) {
18729 sizeof(confp->pri.pri.mwi_vm_boxes));
18730 }
else if (!strcasecmp(v->
name,
"mwi_vm_numbers")) {
18732 sizeof(confp->pri.pri.mwi_vm_numbers));
18734 }
else if (!strcasecmp(v->
name,
"append_msn_to_cid_tag")) {
18735 confp->pri.pri.append_msn_to_user_tag =
ast_true(v->
value);
18736 }
else if (!strcasecmp(v->
name,
"inband_on_setup_ack")) {
18738 }
else if (!strcasecmp(v->
name,
"inband_on_proceeding")) {
18740 #if defined(HAVE_PRI_DISPLAY_TEXT) 18741 }
else if (!strcasecmp(v->
name,
"display_send")) {
18742 confp->pri.pri.display_flags_send = dahdi_display_text_option(v->
value);
18743 }
else if (!strcasecmp(v->
name,
"display_receive")) {
18744 confp->pri.pri.display_flags_receive = dahdi_display_text_option(v->
value);
18746 #if defined(HAVE_PRI_MCID) 18747 }
else if (!strcasecmp(v->
name,
"mcid_send")) {
18750 #if defined(HAVE_PRI_DATETIME_SEND) 18751 }
else if (!strcasecmp(v->
name,
"datetime_send")) {
18752 confp->pri.pri.datetime_send = dahdi_datetime_send_option(v->
value);
18754 }
else if (!strcasecmp(v->
name,
"layer1_presence")) {
18755 if (!strcasecmp(v->
value,
"required")) {
18756 confp->pri.pri.layer1_ignored = 0;
18757 }
else if (!strcasecmp(v->
value,
"ignore")) {
18758 confp->pri.pri.layer1_ignored = 1;
18761 confp->pri.pri.layer1_ignored = 0;
18763 #if defined(HAVE_PRI_L2_PERSISTENCE) 18764 }
else if (!strcasecmp(v->
name,
"layer2_persistence")) {
18765 if (!strcasecmp(v->
value,
"keep_up")) {
18766 confp->pri.pri.l2_persistence = PRI_L2_PERSISTENCE_KEEP_UP;
18767 }
else if (!strcasecmp(v->
value,
"leave_down")) {
18768 confp->pri.pri.l2_persistence = PRI_L2_PERSISTENCE_LEAVE_DOWN;
18770 confp->pri.pri.l2_persistence = PRI_L2_PERSISTENCE_DEFAULT;
18773 }
else if (!strcasecmp(v->
name,
"colp_send")) {
18774 if (!strcasecmp(v->
value,
"block")) {
18776 }
else if (!strcasecmp(v->
value,
"connect")) {
18778 }
else if (!strcasecmp(v->
value,
"update")) {
18784 #if defined(HAVE_SS7) 18785 }
else if (!strcasecmp(v->
name,
"ss7type")) {
18786 if (!strcasecmp(v->
value,
"itu")) {
18787 cur_ss7type = SS7_ITU;
18788 }
else if (!strcasecmp(v->
value,
"ansi")) {
18789 cur_ss7type = SS7_ANSI;
18793 }
else if (!strcasecmp(v->
name,
"slc")) {
18794 cur_slc = atoi(v->
value);
18795 }
else if (!strcasecmp(v->
name,
"linkset")) {
18796 cur_linkset = atoi(v->
value);
18797 }
else if (!strcasecmp(v->
name,
"pointcode")) {
18798 cur_pointcode = parse_pointcode(v->
value);
18799 }
else if (!strcasecmp(v->
name,
"adjpointcode")) {
18800 cur_adjpointcode = parse_pointcode(v->
value);
18801 }
else if (!strcasecmp(v->
name,
"defaultdpc")) {
18802 cur_defaultdpc = parse_pointcode(v->
value);
18803 }
else if (!strcasecmp(v->
name,
"cicbeginswith")) {
18804 cur_cicbeginswith = atoi(v->
value);
18805 }
else if (!strcasecmp(v->
name,
"networkindicator")) {
18806 if (!strcasecmp(v->
value,
"national")) {
18807 cur_networkindicator = SS7_NI_NAT;
18808 }
else if (!strcasecmp(v->
value,
"national_spare")) {
18809 cur_networkindicator = SS7_NI_NAT_SPARE;
18810 }
else if (!strcasecmp(v->
value,
"international")) {
18811 cur_networkindicator = SS7_NI_INT;
18812 }
else if (!strcasecmp(v->
value,
"international_spare")) {
18813 cur_networkindicator = SS7_NI_INT_SPARE;
18815 cur_networkindicator = -1;
18817 }
else if (!strcasecmp(v->
name,
"ss7_internationalprefix")) {
18818 ast_copy_string(confp->ss7.ss7.internationalprefix, v->
value,
sizeof(confp->ss7.ss7.internationalprefix));
18819 }
else if (!strcasecmp(v->
name,
"ss7_nationalprefix")) {
18820 ast_copy_string(confp->ss7.ss7.nationalprefix, v->
value,
sizeof(confp->ss7.ss7.nationalprefix));
18821 }
else if (!strcasecmp(v->
name,
"ss7_subscriberprefix")) {
18822 ast_copy_string(confp->ss7.ss7.subscriberprefix, v->
value,
sizeof(confp->ss7.ss7.subscriberprefix));
18823 }
else if (!strcasecmp(v->
name,
"ss7_unknownprefix")) {
18824 ast_copy_string(confp->ss7.ss7.unknownprefix, v->
value,
sizeof(confp->ss7.ss7.unknownprefix));
18825 }
else if (!strcasecmp(v->
name,
"ss7_networkroutedprefix")) {
18826 ast_copy_string(confp->ss7.ss7.networkroutedprefix, v->
value,
sizeof(confp->ss7.ss7.networkroutedprefix));
18827 }
else if (!strcasecmp(v->
name,
"ss7_called_nai")) {
18828 if (!strcasecmp(v->
value,
"national")) {
18829 confp->ss7.ss7.called_nai = SS7_NAI_NATIONAL;
18830 }
else if (!strcasecmp(v->
value,
"international")) {
18831 confp->ss7.ss7.called_nai = SS7_NAI_INTERNATIONAL;
18832 }
else if (!strcasecmp(v->
value,
"subscriber")) {
18833 confp->ss7.ss7.called_nai = SS7_NAI_SUBSCRIBER;
18834 }
else if (!strcasecmp(v->
value,
"unknown")) {
18835 confp->ss7.ss7.called_nai = SS7_NAI_UNKNOWN;
18836 }
else if (!strcasecmp(v->
value,
"dynamic")) {
18841 }
else if (!strcasecmp(v->
name,
"ss7_calling_nai")) {
18842 if (!strcasecmp(v->
value,
"national")) {
18843 confp->ss7.ss7.calling_nai = SS7_NAI_NATIONAL;
18844 }
else if (!strcasecmp(v->
value,
"international")) {
18845 confp->ss7.ss7.calling_nai = SS7_NAI_INTERNATIONAL;
18846 }
else if (!strcasecmp(v->
value,
"subscriber")) {
18847 confp->ss7.ss7.calling_nai = SS7_NAI_SUBSCRIBER;
18848 }
else if (!strcasecmp(v->
value,
"unknown")) {
18849 confp->ss7.ss7.calling_nai = SS7_NAI_UNKNOWN;
18850 }
else if (!strcasecmp(v->
value,
"dynamic")) {
18855 }
else if (!strcasecmp(v->
name,
"sigchan")) {
18857 sigchan = atoi(v->
value);
18858 res = linkset_addsigchan(sigchan);
18862 }
else if (!strcasecmp(v->
name,
"ss7_explicitacm")) {
18863 struct dahdi_ss7 *link;
18864 link = ss7_resolve_linkset(cur_linkset);
18866 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18874 }
else if (!strcasecmp(v->
name,
"ss7_autoacm")) {
18875 struct dahdi_ss7 *link;
18876 link = ss7_resolve_linkset(cur_linkset);
18878 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18886 }
else if (!strcasecmp(v->
name,
"ss7_initialhwblo")) {
18887 struct dahdi_ss7 *link;
18888 link = ss7_resolve_linkset(cur_linkset);
18890 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18898 }
else if (!strcasecmp(v->
name,
"ss7_use_echocontrol")) {
18899 struct dahdi_ss7 *link;
18900 link = ss7_resolve_linkset(cur_linkset);
18902 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18910 }
else if (!strcasecmp(v->
name,
"ss7_default_echocontrol")) {
18911 struct dahdi_ss7 *link;
18912 link = ss7_resolve_linkset(cur_linkset);
18914 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18922 }
else if (!strncasecmp(v->
name,
"isup_timer.", 11)) {
18923 struct dahdi_ss7 *link;
18924 link = ss7_resolve_linkset(cur_linkset);
18926 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18929 if (!link->ss7.ss7) {
18931 }
else if (!ss7_set_isup_timer(link->ss7.ss7, strstr(v->
name,
".") + 1, atoi(v->
value))) {
18934 }
else if (!strncasecmp(v->
name,
"mtp3_timer.", 11)) {
18935 struct dahdi_ss7 *link;
18936 link = ss7_resolve_linkset(cur_linkset);
18938 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18941 if (!link->ss7.ss7) {
18943 }
else if (!ss7_set_mtp3_timer(link->ss7.ss7, strstr(v->
name,
".") + 1, atoi(v->
value))) {
18946 }
else if (!strcasecmp(v->
name,
"inr_if_no_calling")) {
18947 struct dahdi_ss7 *link;
18948 link = ss7_resolve_linkset(cur_linkset);
18950 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18953 if (!link->ss7.ss7) {
18956 ss7_set_flags(link->ss7.ss7, SS7_INR_IF_NO_CALLING);
18958 ss7_clear_flags(link->ss7.ss7, SS7_INR_IF_NO_CALLING);
18960 }
else if (!strcasecmp(v->
name,
"non_isdn_access")) {
18961 struct dahdi_ss7 *link;
18962 link = ss7_resolve_linkset(cur_linkset);
18964 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18967 if (!link->ss7.ss7) {
18970 ss7_clear_flags(link->ss7.ss7, SS7_ISDN_ACCESS_INDICATOR);
18972 ss7_set_flags(link->ss7.ss7, SS7_ISDN_ACCESS_INDICATOR);
18974 }
else if (!strcasecmp(v->
name,
"sls_shift")) {
18975 struct dahdi_ss7 *link;
18976 int sls_shift = atoi(v->
value);
18978 if (sls_shift < 0 || sls_shift > 7) {
18983 link = ss7_resolve_linkset(cur_linkset);
18985 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
18988 if (!link->ss7.ss7) {
18991 ss7_set_sls_shift(link->ss7.ss7, sls_shift);
18993 }
else if (!strcasecmp(v->
name,
"cause_location")) {
18994 struct dahdi_ss7 *link;
18995 int cause_location = atoi(v->
value);
18997 if (cause_location < 0 || cause_location > 15) {
18998 ast_log(
LOG_ERROR,
"Invalid cause_location value. Must be between 0 and 15\n");
19001 link = ss7_resolve_linkset(cur_linkset);
19003 ast_log(
LOG_ERROR,
"Invalid linkset number. Must be between 1 and %d\n", NUM_SPANS + 1);
19006 if (!link->ss7.ss7) {
19009 ss7_set_cause_location(link->ss7.ss7, cause_location);
19013 }
else if (!strcasecmp(v->
name,
"mfcr2_advanced_protocol_file")) {
19015 ast_log(
LOG_WARNING,
"MFC/R2 Protocol file '%s' will be used, you only should use this if you *REALLY KNOW WHAT YOU ARE DOING*.\n", confp->mfcr2.r2proto_file);
19016 }
else if (!strcasecmp(v->
name,
"mfcr2_logdir")) {
19018 }
else if (!strcasecmp(v->
name,
"mfcr2_variant")) {
19019 confp->mfcr2.variant = openr2_proto_get_variant(v->
value);
19020 if (OR2_VAR_UNKNOWN == confp->mfcr2.variant) {
19022 confp->mfcr2.variant = OR2_VAR_ITU;
19024 }
else if (!strcasecmp(v->
name,
"mfcr2_mfback_timeout")) {
19025 confp->mfcr2.mfback_timeout = atoi(v->
value);
19026 if (!confp->mfcr2.mfback_timeout) {
19027 ast_log(
LOG_WARNING,
"MF timeout of 0? hum, I will protect you from your ignorance. Setting default.\n");
19028 confp->mfcr2.mfback_timeout = -1;
19029 }
else if (confp->mfcr2.mfback_timeout > 0 && confp->mfcr2.mfback_timeout < 500) {
19030 ast_log(
LOG_WARNING,
"MF timeout less than 500ms is not recommended, you have been warned!\n");
19032 }
else if (!strcasecmp(v->
name,
"mfcr2_metering_pulse_timeout")) {
19033 confp->mfcr2.metering_pulse_timeout = atoi(v->
value);
19034 if (confp->mfcr2.metering_pulse_timeout > 500) {
19035 ast_log(
LOG_WARNING,
"Metering pulse timeout greater than 500ms is not recommended, you have been warned!\n");
19037 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 2 19038 }
else if (!strcasecmp(v->
name,
"mfcr2_dtmf_detection")) {
19040 }
else if (!strcasecmp(v->
name,
"mfcr2_dtmf_dialing")) {
19042 }
else if (!strcasecmp(v->
name,
"mfcr2_dtmf_time_on")) {
19043 confp->mfcr2.dtmf_time_on = atoi(v->
value);
19044 }
else if (!strcasecmp(v->
name,
"mfcr2_dtmf_time_off")) {
19045 confp->mfcr2.dtmf_time_off = atoi(v->
value);
19047 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 3 19048 }
else if (!strcasecmp(v->
name,
"mfcr2_dtmf_end_timeout")) {
19049 confp->mfcr2.dtmf_end_timeout = atoi(v->
value);
19051 }
else if (!strcasecmp(v->
name,
"mfcr2_get_ani_first")) {
19053 }
else if (!strcasecmp(v->
name,
"mfcr2_double_answer")) {
19055 }
else if (!strcasecmp(v->
name,
"mfcr2_charge_calls")) {
19057 }
else if (!strcasecmp(v->
name,
"mfcr2_accept_on_offer")) {
19059 }
else if (!strcasecmp(v->
name,
"mfcr2_allow_collect_calls")) {
19060 confp->mfcr2.allow_collect_calls =
ast_true(v->
value) ? 1 : 0;
19061 }
else if (!strcasecmp(v->
name,
"mfcr2_forced_release")) {
19063 }
else if (!strcasecmp(v->
name,
"mfcr2_immediate_accept")) {
19064 confp->mfcr2.immediate_accept =
ast_true(v->
value) ? 1 : 0;
19065 #if defined(OR2_LIB_INTERFACE) && OR2_LIB_INTERFACE > 1 19066 }
else if (!strcasecmp(v->
name,
"mfcr2_skip_category")) {
19067 confp->mfcr2.skip_category_request =
ast_true(v->
value) ? 1 : 0;
19069 }
else if (!strcasecmp(v->
name,
"mfcr2_call_files")) {
19071 }
else if (!strcasecmp(v->
name,
"mfcr2_max_ani")) {
19072 confp->mfcr2.max_ani = atoi(v->
value);
19076 }
else if (!strcasecmp(v->
name,
"mfcr2_max_dnis")) {
19077 confp->mfcr2.max_dnis = atoi(v->
value);
19081 }
else if (!strcasecmp(v->
name,
"mfcr2_category")) {
19082 confp->mfcr2.category = openr2_proto_get_category(v->
value);
19083 if (OR2_CALLING_PARTY_CATEGORY_UNKNOWN == confp->mfcr2.category) {
19084 confp->mfcr2.category = OR2_CALLING_PARTY_CATEGORY_NATIONAL_SUBSCRIBER;
19085 ast_log(
LOG_WARNING,
"Invalid MFC/R2 caller category '%s' at line %d. Using national subscriber as default.\n",
19088 }
else if (!strcasecmp(v->
name,
"mfcr2_logging")) {
19089 openr2_log_level_t tmplevel;
19093 strcpy(copy, v->
value);
19096 clevel =
strsep(&logval,
",");
19097 if (-1 == (tmplevel = openr2_log_get_level(clevel))) {
19101 confp->mfcr2.loglevel |= tmplevel;
19104 }
else if (!strcasecmp(v->
name,
"cadence")) {
19106 int element_count, c[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
19108 struct dahdi_ring_cadence new_cadence;
19109 int cid_location = -1;
19110 int firstcadencepos = 0;
19111 char original_args[80];
19112 int cadence_is_ok = 1;
19116 element_count = sscanf(v->
value,
"%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d,%30d", &c[0], &c[1], &c[2], &c[3], &c[4], &c[5], &c[6], &c[7], &c[8], &c[9], &c[10], &c[11], &c[12], &c[13], &c[14], &c[15]);
19119 if (element_count % 2 == 1) {
19120 ast_log(
LOG_ERROR,
"Must be a silence duration for each ring duration: %s at line %d.\n", original_args, v->
lineno);
19130 for (i = 0; i < element_count; i++) {
19132 ast_log(
LOG_ERROR,
"Ring or silence duration cannot be zero: %s at line %d.\n", original_args, v->
lineno);
19135 }
else if (c[i] < 0) {
19138 if (cid_location == -1) {
19147 if (firstcadencepos == 0) {
19148 firstcadencepos = i;
19151 ast_log(
LOG_ERROR,
"First cadence position specified twice: %s at line %d.\n", original_args, v->
lineno);
19160 for (i = 0; i < 16; i++) {
19161 new_cadence.ringcadence[i] = c[i];
19164 if (cadence_is_ok) {
19166 if (element_count < 2) {
19169 if (cid_location == -1) {
19174 cid_location = (cid_location + 1) / 2;
19189 }
else if (!strcasecmp(v->
name,
"ringtimeout")) {
19191 }
else if (!strcasecmp(v->
name,
"prewink")) {
19193 }
else if (!strcasecmp(v->
name,
"preflash")) {
19195 }
else if (!strcasecmp(v->
name,
"wink")) {
19197 }
else if (!strcasecmp(v->
name,
"flash")) {
19199 }
else if (!strcasecmp(v->
name,
"start")) {
19201 }
else if (!strcasecmp(v->
name,
"rxwink")) {
19203 }
else if (!strcasecmp(v->
name,
"rxflash")) {
19205 }
else if (!strcasecmp(v->
name,
"debounce")) {
19207 }
else if (!strcasecmp(v->
name,
"toneduration")) {
19211 struct dahdi_dialparams dps;
19213 ctlfd = open(
"/dev/dahdi/ctl", O_RDWR);
19219 toneduration = atoi(v->
value);
19220 if (toneduration > -1) {
19221 memset(&dps, 0,
sizeof(dps));
19223 dps.dtmf_tonelen = dps.mfv1_tonelen = toneduration;
19224 res = ioctl(ctlfd, DAHDI_SET_DIALPARAMS, &dps);
19232 }
else if (!strcasecmp(v->
name,
"defaultcic")) {
19234 }
else if (!strcasecmp(v->
name,
"defaultozz")) {
19236 }
else if (!strcasecmp(v->
name,
"mwilevel")) {
19238 }
else if (!strcasecmp(v->
name,
"dtmfcidlevel")) {
19240 }
else if (!strcasecmp(v->
name,
"reportalarms")) {
19241 if (!strcasecmp(v->
value,
"all"))
19243 if (!strcasecmp(v->
value,
"none"))
19245 else if (!strcasecmp(v->
value,
"channels"))
19247 else if (!strcasecmp(v->
value,
"spans"))
19259 "Dahdichan '%s' failure ignored: ignore_failed_channels.\n",
19277 for (tmp = iflist, y=-1;
tmp; tmp = tmp->
next) {
19301 ast_verb(3,
"Automatically generated pseudo channel\n");
19367 static int had_cfg_before = 1;
19370 have_cfg_now = !!cfg;
19373 if (had_cfg_before) {
19402 have_cfg_now = !!cfg;
19404 if (had_cfg_before) {
19432 had_cfg_before = have_cfg_now;
19441 if (!strcasecmp(v->
name,
"trunkgroup")) {
19442 trunkgroup = atoi(v->
value);
19443 if (trunkgroup > 0) {
19444 if ((c = strchr(v->
value,
','))) {
19446 memset(dchannels, 0,
sizeof(dchannels));
19448 dchannels[i] = atoi(c + 1);
19449 if (dchannels[i] < 0) {
19450 ast_log(
LOG_WARNING,
"D-channel for trunk group %d must be a postiive number at line %d of chan_dahdi.conf\n", trunkgroup, v->
lineno);
19453 c = strchr(c + 1,
',');
19456 if (pri_create_trunkgroup(trunkgroup, dchannels)) {
19457 ast_log(
LOG_WARNING,
"Unable to create trunk group %d with Primary D-channel %d at line %d of chan_dahdi.conf\n", trunkgroup, dchannels[0], v->
lineno);
19459 ast_verb(2,
"Created trunk group %d with Primary D-channel %d and %d backup%s\n", trunkgroup, dchannels[0], i - 1, (i == 1) ?
"" :
"s");
19461 ast_log(
LOG_WARNING,
"Trunk group %d lacks any valid D-channels at line %d of chan_dahdi.conf\n", trunkgroup, v->
lineno);
19463 ast_log(
LOG_WARNING,
"Trunk group %d lacks a primary D-channel at line %d of chan_dahdi.conf\n", trunkgroup, v->
lineno);
19465 ast_log(
LOG_WARNING,
"Trunk group identifier must be a positive integer at line %d of chan_dahdi.conf\n", v->
lineno);
19466 }
else if (!strcasecmp(v->
name,
"spanmap")) {
19467 spanno = atoi(v->
value);
19469 if ((c = strchr(v->
value,
','))) {
19470 trunkgroup = atoi(c + 1);
19471 if (trunkgroup > 0) {
19472 if ((c = strchr(c + 1,
',')))
19473 logicalspan = atoi(c + 1);
19476 if (logicalspan >= 0) {
19477 if (pri_create_spanmap(spanno - 1, trunkgroup, logicalspan)) {
19478 ast_log(
LOG_WARNING,
"Failed to map span %d to trunk group %d (logical span %d)\n", spanno, trunkgroup, logicalspan);
19480 ast_verb(2,
"Mapped span %d to trunk group %d (logical span %d)\n", spanno, trunkgroup, logicalspan);
19482 ast_log(
LOG_WARNING,
"Logical span must be a postive number, or '0' (for unspecified) at line %d of chan_dahdi.conf\n", v->
lineno);
19519 if (!strcasecmp(cat,
"general") ||
19520 !strcasecmp(cat,
"trunkgroups") ||
19521 !strcasecmp(cat,
"globals") ||
19522 !strcasecmp(cat,
"channels")) {
19555 if (!strcasecmp(cat,
"general")) {
19582 if (pris[x].pri.
pvts[0] &&
19584 prepare_pri(pris + x);
19589 ast_verb(2,
"Starting D-Channel on span %d\n", x + 1);
19594 #if defined(HAVE_SS7) 19598 if (linksets[x].ss7.ss7) {
19603 ast_verb(2,
"Starting SS7 linkset on span %d\n", x + 1);
19610 struct r2link_entry *cur;
19614 struct dahdi_mfcr2 *r2 = &cur->mfcr2;
19617 ast_log(
LOG_ERROR,
"Unable to start R2 monitor on channel group %d\n", x + 1);
19620 ast_verb(2,
"Starting R2 monitor on channel group %d\n", x + 1);
19674 #if defined(HAVE_PRI) || defined(HAVE_SS7) 19695 memset(pris, 0,
sizeof(pris));
19699 pri_set_error(dahdi_pri_error);
19700 pri_set_message(dahdi_pri_message);
19702 #ifdef HAVE_PRI_PROG_W_CAUSE 19705 #if defined(HAVE_PRI_CCSS) 19713 #
if defined(HAVE_PRI_CCSS)
19723 #if defined(HAVE_SS7) 19724 memset(linksets, 0,
sizeof(linksets));
19728 ss7_set_error(dahdi_ss7_error);
19729 ss7_set_message(dahdi_ss7_message);
19748 #if defined(HAVE_SS7) 19757 memset(round_robin, 0,
sizeof(round_robin));
19765 #if defined(HAVE_PRI) 19779 #define END_SILENCE_LEN 400 19780 #define HEADER_MS 50 19781 #define TRAILER_MS 5 19782 #define HEADER_LEN ((HEADER_MS + TRAILER_MS) * 8) 19783 #define ASCII_BYTES_PER_CHAR 80 19785 unsigned char *
buf,*mybuf;
19787 struct pollfd fds[1];
19788 int size,res,fd,
len,x;
19810 if ((!p->
tdd) && (!p->
mate)) {
19811 #if defined(HAVE_PRI) 19812 #if defined(HAVE_PRI_DISPLAY_TEXT) 19815 sig_pri_sendtext(p->
sig_pvt, text);
19837 for (x = 0; text[x]; x++) {
19848 ast_log(
LOG_ERROR,
"TDD generate (len %d) failed!!\n", (
int)strlen(text));
19865 fds[0].events = POLLOUT | POLLPRI;
19866 fds[0].revents = 0;
19867 res = poll(fds, 1, -1);
19873 if (fds[0].revents & POLLPRI) {
19877 if (!(fds[0].revents & POLLOUT)) {
19881 res = write(fd, buf, size);
19920 .requires =
"ccss",
19921 .optional_modules =
"res_smdi",
static void my_set_outgoing(void *pvt, int is_outgoing)
int cidpos
Position in the cidspill buffer to send out next.
static void publish_span_alarm(int span, const char *alarm_txt)
void(* ast_cc_callback_fn)(struct ast_channel *chan, struct ast_cc_config_params *cc_params, const char *monitor_type, const char *const device_name, const char *const dialstring, void *private_data)
Callback made from ast_cc_callback for certain channel types.
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
A-Law to Signed linear conversion.
char defcontext[AST_MAX_CONTEXT]
Default distinctive ring context.
unsigned int outgoing
TRUE if we originated the call leg.
static struct ast_frame * dahdi_exception(struct ast_channel *ast)
unsigned int digital
TRUE if the transfer capability of the call is digital.
#define AST_CAUSE_PROTOCOL_ERROR
static void swap_subs(struct dahdi_pvt *p, int a, int b)
int ast_cc_agent_register(const struct ast_cc_agent_callbacks *callbacks)
Register a set of agent callbacks with the core.
struct ast_variable * next
int dialtone_scanning_time_elapsed
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
static int conf_del(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index)
struct ringContextData ringContext[3]
unsigned long long ast_group_t
#define dahdi_get_index(ast, p, nullok)
int matchdigit_timeout
Time (ms) to wait, in case of ambiguous match (in an analog phone)
static void dahdi_handle_dtmf(struct ast_channel *ast, int idx, struct ast_frame **dest)
void sig_pri_unload(void)
char description[32]
A description for the channel configuration.
Struct containing info for an AMI event to send out.
enum sip_cc_notify_state state
struct ast_channel * sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int transfercapability)
unsigned int priexclusive
TRUE if PRI B channels are always exclusively selected.
int presentation
Q.931 encoded presentation-indicator encoded field.
void ast_channel_pickupgroup_set(struct ast_channel *chan, ast_group_t value)
char cid_name[AST_MAX_EXTENSION]
int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor)
static struct ast_frame * dahdi_handle_event(struct ast_channel *ast)
void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
static int __unload_module(void)
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
unsigned int threewaycalling
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks to see if adding anything to this extension might match something. (exists ^ canmatch) ...
#define ast_channel_lock(chan)
#define DAHDI_OVERLAPDIAL_INCOMING
unsigned int use_callerid
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_party_dialed::@246 number
Dialed/Called number.
static const char * my_get_orig_dialstring(void *pvt)
static void handle_clear_alarms(struct dahdi_pvt *p)
#define AST_CLI_DEFINE(fn, txt,...)
int sig_pri_cc_agent_party_b_free(struct ast_cc_agent *agent)
ast_device_state
Device States.
struct dahdi_dialoperation dop
DAHDI dial operation command struct for ioctl() call.
struct ast_smdi_interface * smdi_iface
The SMDI interface to get SMDI messages from.
static void my_unlock_private(void *pvt)
void dahdi_dtmf_detect_disable(struct dahdi_pvt *p)
int sig_pri_available(struct sig_pri_chan **pvt, int is_specific_channel)
char cid_subaddr[AST_MAX_EXTENSION]
Caller ID subaddress from an incoming call.
const char * type
Type of monitor the callbacks belong to.
char * str
Subscriber phone number (Malloced)
#define CIDCW_EXPIRE_SAMPLES
General Asterisk channel transcoding definitions.
#define PROC_DAHDI_OPT_NOWARN
void ast_cc_agent_unregister(const struct ast_cc_agent_callbacks *callbacks)
Unregister a set of agent callbacks with the core.
static int dahdi_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
static int analogsub_to_dahdisub(enum analog_sub analogsub)
char fwd_st[SMDI_MAX_STATION_NUM_LEN+1]
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
unsigned int permhidecallerid
TRUE if the outgoing caller ID is blocked/restricted/hidden.
unsigned int cancallforward
TRUE if support for call forwarding enabled. Dial *72 to enable call forwarding. Dial *73 to disable ...
#define AST_LIST_LOCK(head)
Locks a list.
unsigned int priexclusive
static struct ast_jb_conf default_jbconf
Asterisk locking-related definitions:
static int num_restart_pending
void astman_append(struct mansession *s, const char *fmt,...)
int cid_ton
Caller ID Q.931 TON/NPI field values. Set by PRI. Zero otherwise.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_namedgroups * named_pickupgroups
Named pickup groups this belongs to.
int sig_pri_indicate(struct sig_pri_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
static int dahdi_sig_pri_lib_handles(int signaling)
int sig_ss7_available(struct sig_ss7_chan *p)
void * ast_mwi_unsubscribe(struct ast_mwi_subscriber *sub)
Unsubscribe from the stasis topic and MWI.
unsigned int callwaiting
TRUE if busy extensions will hear the call-waiting tone and can use hook-flash to switch between call...
int congestion_devstate
Congestion device state of the span.
static void my_deadlock_avoidance_private(void *pvt)
enum ast_transfer_result ast_bridge_transfer_attended(struct ast_channel *to_transferee, struct ast_channel *to_transfer_target)
Attended transfer.
#define REPORT_CHANNEL_ALARMS
static void my_swap_subchannels(void *pvt, enum analog_sub a, struct ast_channel *ast_a, enum analog_sub b, struct ast_channel *ast_b)
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
char * str
Subscriber phone number (Malloced)
char chan_name[AST_CHANNEL_NAME]
int callwaitcas
TRUE if Call Waiting (CW) CPE Alert Signal (CAS) is being sent.
static void dahdi_iflist_extract(struct dahdi_pvt *pvt)
static int my_on_hook(void *pvt)
int firstdigit_timeout
Time (ms) to detect first digit (in an analog phone)
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static ast_mutex_t restart_lock
int sig_ss7_reset_cic(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc)
static int dahdi_dial_str(struct dahdi_pvt *pvt, int operation, const char *dial_str)
unsigned int dialing
TRUE if in the process of dialing digits or sending something.
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
#define AST_OPTION_TXGAIN
static int is_group_or_channel_match(struct dahdi_pvt *p, int span, ast_group_t groupmatch, int *groupmatched, int channelmatch, int *channelmatched)
int ast_callerid_split(const char *src, char *name, int namelen, char *num, int numlen)
static int drc_sample(int sample, float drc)
struct dahdi_subchannel subs[3]
unsigned int use_callingpres
static void monitor_pfds_clean(void *arg)
void dahdi_master_slave_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock)
void sig_pri_cli_show_span(int fd, int *dchannels, struct sig_pri_span *pri)
static char * dahdi_restart_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
int callwaitrings
Number of call waiting rings.
void(*const lock_private)(void *pvt)
void ast_cc_config_params_destroy(struct ast_cc_config_params *params)
Free memory from CCSS configuration params.
static struct ast_cli_entry dahdi_cli[]
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static int my_is_off_hook(void *pvt)
void sig_pri_cli_show_spans(int fd, int span, struct sig_pri_span *pri)
static struct ast_manager_event_blob * dahdichannel_to_ami(struct stasis_message *msg)
static int my_stop_callwait(void *pvt)
void * analog_handle_init_event(struct analog_pvt *i, int event)
int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
#define ast_pthread_create_detached(a, b, c, d)
static enum analog_event dahdievent_to_analogevent(int event)
struct ast_party_id id
Connected party ID.
void sig_pri_cli_show_channels(int fd, struct sig_pri_span *pri)
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void sig_pri_cli_show_channels_header(int fd)
void ast_log_callid(int level, const char *file, int line, const char *function, ast_callid callid, const char *fmt,...)
Used for sending a log message with a known call_id This is a modified logger function which is funct...
void * ast_channel_tech_pvt(const struct ast_channel *chan)
static int dahdi_confmute(struct dahdi_pvt *p, int muted)
#define ast_channel_unref(c)
Decrease channel reference count.
static ast_mutex_t ss_thread_lock
#define SIG_PRI_DEBUG_NORMAL
static void * my_get_sigpvt_bridged_channel(struct ast_channel *chan)
char parkinglot[AST_MAX_EXTENSION]
unsigned int callwaitingcallerid
TRUE if send caller ID for Call Waiting.
#define AST_CAUSE_SWITCH_CONGESTION
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset)
unsigned int priindication_oob
unsigned int use_callerid
static int analog_tone_to_dahditone(enum analog_tone tone)
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
unsigned int hardwaredtmf
TRUE if DTMF detection needs to be done by hardware.
static int digit_to_dtmfindex(char digit)
char idleext[AST_MAX_EXTENSION]
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_party_name name
Subscriber name.
#define DSP_DIGITMODE_DTMF
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
int interdigit_timeout
Time (ms) to detect following digits (in an analog phone)
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
#define DSP_FEATURE_DIGIT_DETECT
int analog_hangup(struct analog_pvt *p, struct ast_channel *ast)
#define AST_CAUSE_UNALLOCATED
static int dahdi_analog_lib_handles(int signalling, int radio, int oprmode)
static void parse_busy_pattern(struct ast_variable *v, struct ast_dsp_busy_pattern *busy_cadence)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
void dahdi_ec_enable(struct dahdi_pvt *p)
void pri_event_alarm(struct sig_pri_span *pri, int index, int before_start_pri)
static struct ast_channel_tech dahdi_tech
struct stasis_cache * ast_mwi_state_cache(void)
Backend cache for ast_mwi_topic_cached().
static void my_set_pulsedial(void *pvt, int flag)
int ringt
Ring timeout timer??
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
static struct ast_frame * dahdi_read(struct ast_channel *ast)
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
char mohsuggest[MAX_MUSICCLASS]
char dnid[AST_MAX_EXTENSION]
Dialed Number Identifier.
struct ast_channel_snapshot * snapshot
Convenient Signal Processing routines.
unsigned int firstradio
TRUE if over a radio and dahdi_read() has been called.
#define CALLWAITING_SUPPRESS_SAMPLES
int sig_pri_cc_agent_stop_offer_timer(struct ast_cc_agent *agent)
enum sig_ss7_linkset::@164 state
static int my_start_cid_detect(void *pvt, int cid_signalling)
#define AST_CAUSE_NETWORK_OUT_OF_ORDER
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
static void my_start_polarityswitch(void *pvt)
#define ast_set_flag(p, flag)
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define DSP_DIGITMODE_MUTECONF
static struct dahdi_chan_conf dahdi_chan_conf_default(void)
static int parse_buffers_policy(const char *parse, int *num_buffers, int *policy)
void astman_send_list_complete_start(struct mansession *s, const struct message *m, const char *event_name, int count)
Start the list complete event.
#define TDD_BYTES_PER_CHAR
#define DEADLOCK_AVOIDANCE(lock)
char calling_st[SMDI_MAX_STATION_NUM_LEN+1]
struct dahdi_pvt * master
static const char tdesc[]
int ast_cc_is_config_param(const char *const name)
Is this a CCSS configuration parameter?
descriptor for a cli entry.
#define AST_OPTION_OPRMODE
Interface header for PRI signaling module.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
#define ASCII_BYTES_PER_CHAR
static int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *start)
Helper function for migrating select to poll.
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
struct ast_mwi_subscriber * mwi_event_sub
Opaque event subscription parameters for message waiting indication support.
void ast_callid_threadstorage_auto_clean(ast_callid callid, int callid_created)
Use in conjunction with ast_callid_threadstorage_auto. Cleans up the references and if the callid was...
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static void * analog_ss_thread(void *data)
unsigned int locallyblocked
Bitmask for the channel being locally blocked.
static int debug
Global debug status.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
static int my_play_tone(void *pvt, enum analog_sub sub, enum analog_tone tone)
static void my_set_callwaiting(void *pvt, int callwaiting_enable)
int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, int *available_timer_id)
static int usedistinctiveringdetection
#define DSP_PROGRESS_TALK
char callwait_name[AST_MAX_EXTENSION]
Call waiting name.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
#define CONFIG_STATUS_FILEINVALID
Native DAHDI bridging support.
#define DSP_FEATURE_CALL_PROGRESS
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
unsigned int inservice
TRUE if channel is out of reset and ready.
static int my_is_dialing(void *pvt, enum analog_sub sub)
struct ast_channel * owner
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
#define LINKSET_FLAG_INITIALHWBLO
static int my_set_echocanceller(void *pvt, int enable)
int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor)
#define DSP_TONE_STATE_DIALTONE
static struct ast_frame * __dahdi_exception(struct ast_channel *ast)
static struct dahdi_pvt * determine_starting_point(const char *data, struct dahdi_starting_point *param)
#define LINKSET_FLAG_USEECHOCONTROL
static ast_cond_t ss_thread_complete
Structure for variables, used for configurations and for channel variables.
static int my_allocate_sub(void *pvt, enum analog_sub analogsub)
static void release_doomed_pris(void)
int dsp_features
DSP feature flags: DSP_FEATURE_xxx.
mwisend_states mwisend_current
unsigned int dahditrcallerid
TRUE if we should use the callerid from incoming call on dahdi transfer.
struct ast_channel * owner
static int my_flash(void *pvt)
unsigned int dnd
TRUE if Do-Not-Disturb is enabled, present only for non sig_analog.
unsigned int usefaxbuffers
int law_default
Default call PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int my_dahdi_write(struct dahdi_pvt *p, unsigned char *buf, int len, int idx, int linear)
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct analog_callback analog_callbacks
void ast_dsp_digitreset(struct ast_dsp *dsp)
Reset DTMF detector.
int ast_dsp_was_muted(struct ast_dsp *dsp)
Returns true if DSP code was muting any fragment of the last processed frame. Muting (squelching) hap...
static void destroy_channel(struct dahdi_pvt *cur, int now)
int ast_callerid_callwaiting_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)
Generate Caller-ID spill but in a format suitable for Call Waiting(tm)'s Caller*ID(tm) ...
#define CID_START_POLARITY
unsigned int immediate
TRUE if the channel should be answered immediately without attempting to gather any digits...
#define SMDI_MAX_FILENAME_LEN
Structure to pass both assignedid values to channel drivers.
static int dahdi_func_write(struct ast_channel *chan, const char *function, char *data, const char *value)
Interface header for SS7 signaling module.
static int dahdi_call(struct ast_channel *ast, const char *rdest, int timeout)
int ast_ignore_pattern(const char *context, const char *pattern)
Checks to see if a number should be ignored.
void ast_channel_callgroup_set(struct ast_channel *chan, ast_group_t value)
ast_channel_state
ast_channel states
static char * alarm2str(int alm)
void analog_handle_dtmf(struct analog_pvt *p, struct ast_channel *ast, enum analog_sub idx, struct ast_frame **dest)
char * str
Subscriber name (Malloced)
static void my_hangup_polarityswitch(void *pvt)
static int dahdi_wink(struct dahdi_pvt *p, int index)
float cid_rxgain
Amount of gain to increase during caller id.
#define ANALOG_MATCH_DIGIT_TIMEOUT
Default time (ms) to wait, in case of ambiguous match.
enum sig_pri_reset_state resetting
Channel reset/restart state.
#define DAHDI_OVERLAPDIAL_OUTGOING
#define ast_cond_wait(cond, mutex)
static int my_get_callerid(void *pvt, char *namebuf, char *numbuf, enum analog_event *ev, size_t timeout)
static struct @109 alarms[]
struct ast_dsp_busy_pattern busy_cadence
Busy cadence pattern description.
#define ast_cond_init(cond, attr)
static int unalloc_sub(struct dahdi_pvt *p, int x)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ast_channel_named_pickupgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
static void dahdi_iflist_insert(struct dahdi_pvt *pvt)
unsigned char valid
TRUE if the subaddress information is valid/present.
unsigned int no_b_channel
TRUE if this interface has no B channel. (call hold and call waiting)
static void dahdi_destroy_channel_range(int start, int end)
unsigned int inalarm
TRUE if channel is associated with a link that is down.
unsigned int transfertobusy
TRUE if allowed to flash-transfer to busy channels.
int ast_parking_blind_transfer_park(struct ast_bridge_channel *parker, const char *context, const char *exten, transfer_channel_cb parked_channel_cb, struct transfer_channel_data *parked_channel_data)
Perform a blind transfer to a parking extension.
static int my_wait_event(void *pvt)
#define AST_OPTION_CC_AGENT_TYPE
The channel is not being RESTARTed.
static int copy(char *infile, char *outfile)
Utility function to copy a file.
static int my_have_progressdetect(void *pvt)
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
unsigned int usedistinctiveringdetection
int sig_pri_ami_show_spans(struct mansession *s, const char *show_cmd, struct sig_pri_span *pri, const int *dchannels, const char *action_id)
static int my_conf_add(void *pvt, enum analog_sub sub)
int ast_channel_get_up_time(struct ast_channel *chan)
Obtain how long it has been since the channel was answered.
unsigned int transfertobusy
void dahdi_ec_disable(struct dahdi_pvt *p)
static int my_get_sub_fd(void *pvt, enum analog_sub sub)
static int calc_energy(const unsigned char *buf, int len, struct ast_format *law)
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
static int attempt_transfer(struct dahdi_pvt *p)
#define CID_MWI_TYPE_MDMF_FULL
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
#define ast_mutex_lock(a)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
static int conf_add(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index, int slavechannel)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
void ast_verbose(const char *fmt,...)
#define ast_strdup(str)
A wrapper for strdup()
static int setup_dahdi(int reload)
void sig_ss7_cb_notinservice(struct ss7 *ss7, int cic, unsigned int dpc)
DAHDI internal API definitions.
static char * dahdi_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static int alloc_sub(struct dahdi_pvt *p, int x)
static void * mwi_thread(void *data)
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
#define SIG_PRI_AOC_GRANT_S
#define CALLPROGRESS_PROGRESS
#define CID_START_POLARITY_IN
int law
Active PCM encoding format: DAHDI_LAW_ALAW or DAHDI_LAW_MULAW.
static int my_wink(void *pvt, enum analog_sub sub)
char * str
Malloced subaddress string.
#define AST_CAUSE_NO_USER_RESPONSE
static struct dahdi_pvt * find_channel_from_str(const char *channel)
void dahdi_conf_update(struct dahdi_pvt *p)
static int isourconf(struct dahdi_pvt *p, struct dahdi_subchannel *c)
static void dahdi_close_sub(struct dahdi_pvt *chan_pvt, int sub_num)
unsigned int adsi
TRUE if ADSI (Analog Display Services Interface) available.
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
Common implementation-independent jitterbuffer stuff.
void ast_cli(int fd, const char *fmt,...)
static const char config[]
#define ast_cc_config_params_init()
Allocate and initialize an ast_cc_config_params structure.
ADSI Support (built upon Caller*ID)
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
int sig_ss7_cic_blocking(struct sig_ss7_linkset *linkset, int do_block, int cic)
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
unsigned int restartpending
static int action_dahdidndon(struct mansession *s, const struct message *m)
static char * dahdi_set_hwgain(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
struct dahdi_pvt * oprpeer
int ast_unregister_application(const char *app)
Unregister an application.
int ringt_base
Ring timeout base.
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
float txgain
Software Tx gain set by chan_dahdi.conf.
static char cid_num[AST_MAX_EXTENSION]
#define ast_cond_signal(cond)
static struct dahdi_pvt * ifend
int polarityonanswerdelay
struct timeval dtmfcid_delay
#define SS7_BLOCKED_HARDWARE
unsigned int hidecalleridname
TRUE if hide just the name not the number for legacy PBX use.
int analog_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, void *newp)
static struct dahdi_ring_cadence AS_RP_cadence
#define ast_verb(level,...)
#define DAHDI_OVERLAPDIAL_NONE
struct ast_smdi_md_message * ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
Get the next SMDI message from the queue.
#define REPORT_SPAN_ALARMS
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
static char defaultozz[64]
void sig_pri_extract_called_num_subaddr(struct sig_pri_chan *p, const char *rdest, char *called, size_t called_buff_size)
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
#define MAX_CALLERID_SIZE
const char *const subnames[]
static const char *const lbostr[]
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
static char * dahdi_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define ast_publish_mwi_state(mailbox, context, new_msgs, old_msgs)
Publish a MWI state update via stasis.
static void my_increase_ss_count(void)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
void callerid_get(struct callerid_state *cid, char **number, char **name, int *flags)
Extract info out of callerID state machine. Flags are listed above.
struct ast_frame_subclass subclass
unsigned int use_smdi
TRUE if SMDI (Simplified Message Desk Interface) is enabled.
struct analog_pvt * analog_new(enum analog_sigtype signallingtype, void *private_data)
unsigned int pulse
TRUE if we will pulse dial.
static int dahdi_callwait(struct ast_channel *ast)
int sig_ss7_reset_group(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc, int range)
static void dahdi_queue_frame(struct dahdi_pvt *p, struct ast_frame *f)
int(*const play_tone)(void *pvt, enum analog_sub sub, enum analog_tone tone)
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
Blob of data associated with a channel.
unsigned int cancallforward
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
int sig_pri_hangup(struct sig_pri_chan *p, struct ast_channel *ast)
#define ast_module_unref(mod)
Release a reference to the module.
static void my_set_needringing(void *pvt, int value)
pthread_cond_t ast_cond_t
#define ast_strlen_zero(foo)
enum ast_cc_monitor_policies ast_get_cc_monitor_policy(struct ast_cc_config_params *config)
Get the cc_monitor_policy.
ast_group_t pickupgroup
Bitmapped pickup groups this belongs to.
static void my_decrease_ss_count(void)
char cid_name[AST_MAX_EXTENSION]
Caller ID name from an incoming call.
int pri_send_keypad_facility_exec(struct sig_pri_chan *p, const char *digits)
struct ast_channel * owner
char finaldial[64]
Second part of SIG_FEATDMF_TA wink operation.
#define ast_pthread_create_background(a, b, c, d)
void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences)
Set number of required cadences for busy.
static void fill_rxgain(struct dahdi_gains *g, float gain, float drc, int law)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
static void my_get_and_handle_alarms(void *pvt)
#define DAHDI_CHAN_MAPPING_PHYSICAL
unsigned int hwtxgain_enabled
TRUE if hardware Tx gain set by Asterisk.
struct dahdi_params timing
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
static int my_conf_del(void *pvt, enum analog_sub sub)
int _dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok, const char *fname, unsigned long line)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
static int set_hwgain(int fd, float gain, int tx_direction)
static void wakeup_sub(struct dahdi_pvt *p, int a)
int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static int dahdi_wait_event(int fd)
Avoid the silly dahdi_waitevent which ignores a bunch of events.
struct ast_party_id id
Caller party ID.
#define CALLPROGRESS_FAX_OUTGOING
void sig_pri_init_pri(struct sig_pri_span *pri)
unsigned int remotelyblocked
Bitmask for the channel being remotely blocked.
int ast_cc_monitor_register(const struct ast_cc_monitor_callbacks *callbacks)
Register a set of monitor callbacks with the core.
static void handle_alarms(struct dahdi_pvt *p, int alms)
static enum analog_sigtype dahdisig_to_analogsig(int sig)
unsigned int answeronpolarityswitch
TRUE if we can use a polarity reversal to mark when an outgoing call is answered by the remote party...
Configuration File Parser.
static void destroy_all_channels(void)
#define NEED_MFDETECT(p)
Signaling types that need to use MF detection should be placed in this macro.
int dahdi_native_load(const struct ast_channel_tech *tech)
#define DSP_DIGITMODE_RELAXDTMF
enum analog_sigtype sigtype
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
static int restart_monitor(void)
char context[AST_MAX_CONTEXT]
static int has_voicemail(struct dahdi_pvt *p)
int dtmfcid_holdoff_state
#define EVENT_FLAG_SYSTEM
unsigned int bufferoverrideinuse
#define ast_debug(level,...)
Log a DEBUG message.
static ast_mutex_t monlock
Protect the monitoring thread, so only one process can kill or start it, and not when it's doing some...
char smdi_port[SMDI_MAX_FILENAME_LEN]
The serial port to listen for SMDI data on.
int polarity
Current line interface polarity. POLARITY_IDLE, POLARITY_REV.
unsigned int hanguponpolarityswitch
TRUE if the call will be considered "hung up" on a polarity reversal.
static int user_has_defined_cadences
unsigned int callreturn
TRUE if call return is enabled. (*69, if your dialplan doesn't catch this first)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
int sig_pri_cc_monitor_cancel_available_timer(struct ast_cc_monitor *monitor, int *sched_id)
u-Law to Signed linear conversion
unsigned int transfer
TRUE if call transfer is enabled.
#define ast_config_load(filename, flags)
Load a config file.
unsigned int use_callerid
TRUE if caller ID is used on this channel.
static int dahdi_devicestate(const char *data)
static int my_stop_cid_detect(void *pvt)
unsigned int echobreak
XXX BOOLEAN Purpose???
static int dahdi_dnd(struct dahdi_pvt *dahdichan, int flag)
enable or disable the chan_dahdi Do-Not-Disturb mode for a DAHDI channel
struct ast_cc_config_params * cc_params
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
static int dahdi_ring_phone(struct dahdi_pvt *p)
static int dahdi_cc_callback(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
Callback made when dial failed to get a channel out of dahdi_request().
struct ast_party_id ani
Automatic Number Identification (ANI)
static int my_has_voicemail(void *pvt)
static int my_get_event(void *pvt)
General Asterisk PBX channel definitions.
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
int ast_tdd_gen_ecdisa(unsigned char *outbuf, int len)
struct dahdi_pvt * slaves[MAX_SLAVES]
static void my_set_confirmanswer(void *pvt, int flag)
void ast_channel_rings_set(struct ast_channel *chan, int value)
struct mwisend_info mwisend_data
const char * ast_channel_accountcode(const struct ast_channel *chan)
static pthread_t monitor_thread
This is the thread for the monitor which checks for input on the channels which are not currently in ...
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
Asterisk file paths, configured in asterisk.conf.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
void astman_send_list_complete_end(struct mansession *s)
End the list complete event.
#define ast_mutex_trylock(a)
static int my_send_callerid(void *pvt, int cwcid, struct ast_party_caller *caller)
char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Voice mailbox location.
static int my_dsp_set_digitmode(void *pvt, enum analog_dsp_digitmode mode)
static int dahdi_fake_event(struct dahdi_pvt *p, int mode)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define DSP_TONE_STATE_RINGING
#define AST_OPTION_RELAXDTMF
int ast_variable_list_replace(struct ast_variable **head, struct ast_variable *replacement)
Replace a variable in the given list with a new value.
char echorest[20]
Filled with 'w'. XXX Purpose??
int cidlen
Length of the cidspill buffer containing samples.
struct sig_ss7_chan * sig_ss7_chan_new(void *pvt_data, struct sig_ss7_linkset *ss7)
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
static int ss_thread_count
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int sig_pri_cc_agent_stop_ringing(struct ast_cc_agent *agent)
#define AST_PTHREADT_NULL
struct dahdi_confinfo saveconf
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
struct sla_ringing_trunk * last
unsigned int mwimonitoractive
TRUE if an MWI monitor thread is currently active.
int echotraining
Echo training time. 0 = disabled.
void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which)
#define LINKSET_FLAG_EXPLICITACM
static int my_callwait(void *pvt)
void(*const handle_dchan_exception)(struct sig_pri_span *pri, int index)
int sig_ss7_find_cic(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc)
#define AST_MAX_EXTENSION
static int reset_conf(struct dahdi_pvt *p)
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define AST_CAUSE_NORMAL_CLEARING
static int my_ring(void *pvt)
void sig_ss7_cli_show_channels_header(int fd)
void ast_party_number_init(struct ast_party_number *init)
Initialize the given number structure.
static int sigtype_to_signalling(int sigtype)
#define ast_verbose_callid(callid,...)
Caller Party information.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
int cid_ani2
Automatic Number Identification code from PRI.
#define ao2_ref(o, delta)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
static int cidrings[NUM_CADENCE_MAX]
cidrings says in which pause to transmit the cid information, where the first pause is 1...
static int action_dahdidndoff(struct mansession *s, const struct message *m)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static int ringt_base
Configured ring timeout base.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define DSP_FEATURE_FAX_DETECT
#define MIN_MS_SINCE_FLASH
static void my_handle_dtmf(void *pvt, struct ast_channel *ast, enum analog_sub analog_index, struct ast_frame **dest)
long int ast_random(void)
char contextData[AST_MAX_CONTEXT]
static ast_mutex_t iflock
Protect the interface list (of dahdi_pvt's)
unsigned char * cidspill
Analog caller ID waveform sample buffer.
static int mwi_send_init(struct dahdi_pvt *pvt)
unsigned int permcallwaiting
TRUE if busy extensions will hear the call-waiting tone and can use hook-flash to switch between call...
static int dahdi_open(char *fn)
#define ast_strdupa(s)
duplicate a string in memory from the stack
void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm)
static int my_unallocate_sub(void *pvt, enum analog_sub analogsub)
struct ast_channel * owner
int ast_cc_set_param(struct ast_cc_config_params *params, const char *const name, const char *value)
set a CCSS configuration parameter, given its name
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
int analog_available(struct analog_pvt *p)
unsigned int busydetect
TRUE if busy detection is enabled. (Listens for the beep-beep busy pattern.)
static int restore_gains(struct dahdi_pvt *p)
unsigned int mwimonitor_fsk
TRUE if the FXO port monitors for fsk type MWI indications from the other end.
#define ast_malloc(len)
A wrapper for malloc()
char mohinterpret[MAX_MUSICCLASS]
static void publish_channel_alarm_clear(int channel)
static struct ao2_container * pvts
static struct channel_usage channels
static void my_set_alarm(void *pvt, int in_alarm)
#define ast_variable_new(name, value, filename)
ast_group_t ast_get_group(const char *s)
unsigned int inservice
TRUE if channel is in service.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
#define AST_CAUSE_NO_ANSWER
#define gen_pvt_field_callback(type, field)
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
static void dahdi_softhangup_all(void)
struct ast_frame * analog_exception(struct analog_pvt *p, struct ast_channel *ast)
static void dahdi_train_ec(struct dahdi_pvt *p)
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
short buffer[AST_FRIENDLY_OFFSET/2+READ_SIZE]
static int action_dahdirestart(struct mansession *s, const struct message *m)
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
struct ast_str * ast_manager_build_channel_state_string(const struct ast_channel_snapshot *snapshot)
Generate the AMI message body from a channel snapshot.
#define SMDI_MD_WAIT_TIMEOUT
An SMDI message desk message.
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
char cid_tag[AST_MAX_EXTENSION]
Caller ID tag from incoming call.
struct ast_config * ast_config_new(void)
Create a new base configuration structure.
char subscriberprefix[20]
#define AST_CAUSE_NOTDEFINED
Structure to describe a channel "technology", ie a channel driver See for examples: ...
#define AST_LIST_MOVE_CURRENT(newhead, field)
Move the current list entry to another list.
void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe value)
const char * ast_channel_exten(const struct ast_channel *chan)
static int my_check_for_conference(void *pvt)
Core PBX routines and definitions.
int ast_channel_cc_params_init(struct ast_channel *chan, const struct ast_cc_config_params *base_params)
Set up datastore with CCSS parameters for a channel.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
void ast_party_number_free(struct ast_party_number *doomed)
Destroy the party number contents.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
static void my_cancel_cidspill(void *pvt)
static char * dahdi_set_dnd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
static int bump_gains(struct dahdi_pvt *p)
#define AST_CC_GENERIC_MONITOR_TYPE
#define CONFIG_STATUS_FILEUNCHANGED
void sig_pri_chan_delete(struct sig_pri_chan *doomed)
static int load_module(void)
Load the module.
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
char cid_num[AST_MAX_EXTENSION]
char * term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout)
Colorize a specified string by adding terminal color codes.
unsigned int use_smdi
TRUE if SMDI (Simplified Message Desk Interface) is enabled.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
const char * ast_channel_uniqueid(const struct ast_channel *chan)
#define AST_OPTION_ECHOCAN
static int my_train_echocanceller(void *pvt)
#define DEFAULT_DIALTONE_DETECT_TIMEOUT
static void * do_monitor(void *data)
static int my_off_hook(void *pvt)
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
int sig_pri_cc_agent_init(struct ast_cc_agent *agent, struct sig_pri_chan *pvt_chan)
static int my_start(void *pvt)
struct ast_party_subaddress subaddress
Subscriber subaddress.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
struct timeval waitingfordt
const char * type
Type of agent the callbacks belong to.
#define AST_OPTION_DIGIT_DETECT
static struct ast_channel * my_new_analog_ast_channel(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
#define DSP_DIGITMODE_MUTEMAX
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
static void notify_message(char *mailbox, int thereornot)
Send MWI state change.
struct sig_ss7_chan * pvts[SIG_SS7_MAX_CHANNELS]
struct ast_dsp * dsp
Opaque DSP configuration structure.
int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, enum ast_device_state devstate)
int analog_ss_thread_start(struct analog_pvt *p, struct ast_channel *chan)
int busycount
Number of times to see "busy" tone before hanging up.
static int dahdi_sendtext(struct ast_channel *c, const char *text)
unsigned int destroy
TRUE if the channel is to be destroyed on hangup. (Used by pseudo channels.)
struct ast_namedgroups * ast_get_namedgroups(const char *s)
Create an ast_namedgroups set with group names from comma separated string.
static int dahdi_restart(void)
enum analog_cid_start cid_start
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
unsigned int faxhandled
TRUE if a fax tone has already been handled.
int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, const char *rdest)
int analog_call(struct analog_pvt *p, struct ast_channel *ast, const char *rdest, int timeout)
int ast_pickup_call(struct ast_channel *chan)
Pickup a call.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
#define PROC_DAHDI_OPT_NOCHAN
struct dahdi_pvt::@110 echocancel
Echo cancel parameters.
char mohinterpret[MAX_MUSICCLASS]
The configured music-on-hold class to use for calls.
int fds[SIG_SS7_NUM_DCHANS]
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
enum DAHDI_IFLIST which_iflist
char cid_num[AST_MAX_EXTENSION]
Caller ID number from an incoming call.
int analog_config_complete(struct analog_pvt *p)
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
static int send_cwcidspill(struct dahdi_pvt *p)
#define AST_OPTION_RXGAIN
struct tdd_state * tdd_new(void)
int ast_parking_is_exten_park(const char *context, const char *exten)
Determine if the context/exten is a "parking" extension.
static char * handle_dahdi_show_cadences(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int mwi_send_process_event(struct dahdi_pvt *pvt, int event)
static int my_dial_digits(void *pvt, enum analog_sub sub, struct analog_dialoperation *dop)
static int my_distinctive_ring(struct ast_channel *chan, void *pvt, int idx, int *ringdata)
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
void ast_channel_named_callgroups_set(struct ast_channel *chan, struct ast_namedgroups *value)
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
static char * dahdi_sig2str(int sig)
static struct dahdi_pvt * duplicate_pseudo(struct dahdi_pvt *src)
TTY/TDD Generation support.
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
static int dahdi_create_channel_range(int start, int end)
static void deep_copy_dahdi_chan_conf(struct dahdi_chan_conf *dest, const struct dahdi_chan_conf *src)
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int analog_answer(struct analog_pvt *p, struct ast_channel *ast)
#define SIG_SS7_NUM_DCHANS
static int my_check_waitingfordt(void *pvt)
void ast_party_name_init(struct ast_party_name *init)
Initialize the given name structure.
#define DAHDI_OVERLAPDIAL_BOTH
int sig_ss7_find_cic_range(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc)
unsigned int use_callerid
TRUE if caller ID is used on this channel.
static char * dahdi_destroy_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ani2
Automatic Number Identification 2 (Info Digits)
char dialstring[AST_CHANNEL_NAME]
static void my_set_waitingfordt(void *pvt, struct ast_channel *ast)
static void dahdi_ami_channel_event(struct dahdi_pvt *p, struct ast_channel *chan)
void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
Set expected lengths of the busy tone.
static struct dahdi_pvt * find_next_iface_in_span(struct dahdi_pvt *cur)
#define SIG_PRI_NUM_DCHANS
const ast_string_field name
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
static void process_echocancel(struct dahdi_chan_conf *confp, const char *data, unsigned int line)
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
struct sig_pri_chan * pvts[SIG_PRI_MAX_CHANNELS]
static void my_handle_notify_message(struct ast_channel *chan, void *pvt, int cid_flags, int neon_mwievent)
void analog_delete(struct analog_pvt *doomed)
Delete the analog private structure.
void ast_party_name_free(struct ast_party_name *doomed)
Destroy the party name contents.
static struct dahdi_pvt * find_channel(int channel)
static void my_set_cadence(void *pvt, int *cid_rings, struct ast_channel *ast)
#define ast_cond_destroy(cond)
char idledial[AST_MAX_EXTENSION]
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
static struct ast_channel * dahdi_new_callid_clean(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid, int callid_created)
#define DEFAULT_CIDRINGS
Typically, how many rings before we should send Caller*ID.
char * strcasestr(const char *, const char *)
const char * ast_config_AST_LOG_DIR
struct ast_format_cap * capabilities
static void my_set_inthreeway(void *pvt, enum analog_sub sub, int inthreeway)
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
char exten[AST_MAX_EXTENSION]
Extension to use in the dialplan.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7)
static int set_actual_txgain(int fd, float gain, float drc, int law)
static int restore_conference(struct dahdi_pvt *p)
#define SIG_PRI_LIB_HANDLE_CASES
struct ast_namedgroups * ast_ref_namedgroups(struct ast_namedgroups *groups)
int muting
TRUE if confrence is muted.
int ast_parking_provider_registered(void)
Check whether a parking provider is registered.
#define ast_channel_unlock(chan)
void sig_pri_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_pri_chan *pchan)
void stasis_subscription_cb_noop(void *data, struct stasis_subscription *sub, struct stasis_message *message)
Stasis subscription callback function that does nothing.
int sig_ss7_group_blocking(struct sig_ss7_linkset *linkset, int do_block, int startcic, int endcic, unsigned char state[], int type)
static void parse(struct mgcp_request *req)
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static void publish_dnd_state(int channel, const char *status)
unsigned int usedistinctiveringdetection
TRUE if distinctive rings are to be detected.
static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen)
#define AST_CAUSE_UNREGISTERED
char call_forward[AST_MAX_EXTENSION]
Accumulated call forwarding number.
static struct ast_jb_conf global_jbconf
unsigned int hidecalleridname
#define container_of(ptr, type, member)
#define ast_calloc(num, len)
A wrapper for calloc()
#define ast_pthread_create(a, b, c, d)
static int dahdi_set_hook(int fd, int hs)
void sig_pri_set_alarm(struct sig_pri_chan *p, int in_alarm)
unsigned int faxdetect_timeout
The number of seconds into call to disable fax detection. (0 = disabled)
unsigned int restrictcid
TRUE if caller ID is restricted.
static int dahdi_answer(struct ast_channel *ast)
static int get_alarms(struct dahdi_pvt *p)
unsigned int dahditrcallerid
static int dahdi_get_event(int fd)
Avoid the silly dahdi_getevent which ignores a bunch of events.
#define AST_OPTION_AUDIO_MODE
Call Completion Supplementary Services API.
#define CHANNEL_DEADLOCK_AVOIDANCE(chan)
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static void my_lock_private(void *pvt)
static void my_set_polarity(void *pvt, int value)
char context[AST_MAX_CONTEXT]
The configured context for incoming calls.
unsigned int remotelyblocked
Bitmask for the channel being remotely blocked. 1 maintenance, 2 blocked in hardware.
struct callerid_state * cs
Channel configuration from chan_dahdi.conf . This struct is used for parsing the [channels] section o...
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
void dahdi_master_slave_link(struct dahdi_pvt *slave, struct dahdi_pvt *master)
unsigned int threewaycalling
TRUE if three way calling is enabled.
int msgstate
-1 = unknown, 0 = no messages, 1 = new messages available
SMDI support for Asterisk.
#define DSP_FEATURE_BUSY_DETECT
struct stasis_message_type * ast_mwi_state_type(void)
Get the Stasis Message Bus API message type for MWI messages.
unsigned int permhidecallerid
Module has failed to load, may be in an inconsistent state.
static void fill_txgain(struct dahdi_gains *g, float gain, float drc, int law)
static char * dahdi_show_status(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
void dahdi_dtmf_detect_enable(struct dahdi_pvt *p)
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 wanted_channels_start
Don't create channels below this number.
static const char * event2str(int event)
struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS]
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src)
copy CCSS configuration parameters from one structure to another
int ast_db_get(const char *family, const char *key, char *value, int valuelen)
Get key value specified by family/key.
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
void sig_pri_cc_monitor_destructor(void *monitor_pvt)
static void publish_dahdichannel(struct ast_channel *chan, ast_group_t group, int span, const char *dahdi_channel)
Sends a DAHDIChannel channel blob used to produce DAHDIChannel AMI messages.
int sig_pri_start_pri(struct sig_pri_span *pri)
#define AST_CAUSE_INTERWORKING
struct ast_namedgroups * named_callgroups
Named call groups this belongs to.
static int mwi_send_process_buffer(struct dahdi_pvt *pvt, int num_read)
void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which)
int sig_pri_cc_agent_start_monitoring(struct ast_cc_agent *agent)
struct ast_smdi_interface * smdi_iface
The SMDI interface to get SMDI messages from.
Structure used to handle boolean flags.
static int send_callerid(struct dahdi_pvt *p)
int ast_callerid_generate(unsigned char *buf, const char *name, const char *number, struct ast_format *codec)
Generate Caller-ID spill from the "callerid" field of asterisk (in e-mail address like format) ...
static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
char networkroutedprefix[20]
#define ast_clear_flag(p, flag)
struct ast_channel * peer
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
static char cid_name[AST_MAX_EXTENSION]
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_channel_callid_set(struct ast_channel *chan, ast_callid value)
static int set_actual_rxgain(int fd, float gain, float drc, int law)
static int action_dahdishowchannels(struct mansession *s, const struct message *m)
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
unsigned int ignoredtmf
TRUE if DTMF detection is disabled.
#define CHECK_BLOCKING(c)
Set the blocking indication on the channel.
#define CALLWAITING_REPEAT_SAMPLES
int fake_event
Holding place for event injected from outside normal operation.
struct dahdi_echocanparams head
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
static int my_set_linear_mode(void *pvt, enum analog_sub sub, int linear_mode)
static int dahdi_setlinear(int dfd, int linear)
struct ast_frame ast_null_frame
unsigned int confirmanswer
TRUE if to wait for a DTMF digit to confirm answer.
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
void callerid_free(struct callerid_state *cid)
This function frees callerid_state cid.
int wanted_channels_end
Don't create channels above this number (infinity by default)
static int available(struct dahdi_pvt **pvt, int is_specific_channel)
int sig_pri_call(struct sig_pri_chan *p, struct ast_channel *ast, const char *rdest, int timeout, int layer1)
const char * ast_variable_retrieve(struct ast_config *config, const char *category, const char *variable)
void dahdi_native_unload(void)
char * tag
User-set "tag".
STASIS_MESSAGE_TYPE_DEFN_LOCAL(dahdichannel_type,.to_ami=dahdichannel_to_ami,)
static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
int ast_channel_fd(const struct ast_channel *chan, int which)
unsigned int mwimonitor_neon
TRUE if the FXO port monitors for neon type MWI indications from the other end.
#define ANALOG_FIRST_DIGIT_TIMEOUT
Default time (ms) to detect first digit.
unsigned int hidecallerid
static int my_complete_conference_update(void *pvt, int needconference)
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
int waitfordialtone
Number of milliseconds to wait for dialtone.
#define CALLPROGRESS_FAX_INCOMING
unsigned int locallyblocked
Bitmask for the channel being locally blocked.
static int my_getsigstr(struct ast_channel *chan, char *str, const char *term, int ms)
float hwtxgain
Hardware Tx gain set by chan_dahdi.conf.
Structure that contains information regarding a channel in a bridge.
void sig_ss7_chan_delete(struct sig_ss7_chan *doomed)
int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast)
char * strsep(char **str, const char *delims)
#define AST_OPTION_FAX_DETECT
static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen)
static int distinctiveringaftercid
static int save_conference(struct dahdi_pvt *p)
#define ast_channel_ref(c)
Increase channel reference count.
int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
static const char *const events[]
Standard Command Line Interface.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
struct ast_channel * sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, int transfercapability)
int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode, int cur_slc)
void sig_pri_stop_pri(struct sig_pri_span *pri)
int ast_channel_hangupcause(const struct ast_channel *chan)
int ast_db_del(const char *family, const char *key)
Delete entry in astdb.
void ast_channel_context_set(struct ast_channel *chan, const char *value)
struct dahdi_distRings drings
Distinctive Ring data.
static int dahdi_hangup(struct ast_channel *ast)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
unsigned int echocanon
TRUE if echo cancellation is turned on.
static struct ast_channel * dahdi_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
unsigned int needcongestion
static void publish_span_alarm_clear(int span)
static void my_set_ringtimeout(void *pvt, int ringt)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
unsigned int callwaitingcallerid
struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec)
Returns a timeval from sec, usec.
static struct dahdi_pvt * iflist
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
const char * ast_channel_name(const struct ast_channel *chan)
int sig_pri_digit_begin(struct sig_pri_chan *pvt, struct ast_channel *ast, char digit)
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
#define AST_CAUSE_USER_BUSY
static int check_for_conference(struct dahdi_pvt *p)
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ignore_failed_channels
int ast_callid_threadstorage_auto(ast_callid *callid)
Checks thread storage for a callid and stores a reference if it exists. If not, then a new one will b...
int ast_callerid_vmwi_generate(unsigned char *buf, int active, int type, struct ast_format *codec, const char *name, const char *number, int flags)
Generate message waiting indicator.
void sig_pri_cc_agent_destructor(struct ast_cc_agent *agent)
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
#define AST_PTHREADT_STOP
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
void sig_pri_dial_complete(struct sig_pri_chan *pvt, struct ast_channel *ast)
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Interface header for analog signaling module.
static struct ast_str * create_channel_name(struct dahdi_pvt *i)
static void my_set_dialing(void *pvt, int is_dialing)
static int dahdi_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
enum ast_pbx_result ast_pbx_run(struct ast_channel *c)
Execute the PBX in the current thread.
struct ast_variable * vars
Channel variable list with associated values to set when a channel is created.
unsigned int dialednone
TRUE if analog type line dialed no digits in Dial()
struct stasis_forward * sub
Data structure associated with a single frame of data.
static char * dahdi_create_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
unsigned int manages_span_alarms
TRUE if the channel alarms will be managed also as Span ones.
Internal Asterisk hangup causes.
unsigned int priindication_oob
TRUE if PRI congestion/busy indications are sent out-of-band.
struct ast_channel * owner
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
const char * ast_channel_language(const struct ast_channel *chan)
#define ANALOG_INTER_DIGIT_TIMEOUT
Default time (ms) to detect following digits.
struct stasis_message * stasis_cache_get(struct stasis_cache *cache, struct stasis_message_type *type, const char *id)
Retrieve an item from the cache for the ast_eid_default entity.
static int set_actual_gain(int fd, float rxgain, float txgain, float rxdrc, float txdrc, int law)
char internationalprefix[10]
enum analog_sigtype outsigmod
struct timeval polaritydelaytv
Start delay time if polarityonanswerdelay is nonzero.
Abstract JSON element (object, array, string, int, ...).
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
char callwait_num[AST_MAX_EXTENSION]
Call waiting number.
struct isup_call * ss7call
Opaque libss7 call control structure.
static void my_all_subchannels_hungup(void *pvt)
#define AST_OPTION_TONE_VERIFY
static int my_confmute(void *pvt, int mute)
static struct dahdi_pvt * round_robin[32]
int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast)
static int setup_dahdi_int(int reload, struct dahdi_chan_conf *default_conf, struct dahdi_chan_conf *base_conf, struct dahdi_chan_conf *conf)
#define DLA_UNLOCK(lock)
Deadlock avoidance unlock.
const char * ast_channel_context(const struct ast_channel *chan)
Handy terminal functions for vt* terms.
int ast_db_put(const char *family, const char *key, const char *value)
Store value addressed by family/key.
void ast_cc_monitor_unregister(const struct ast_cc_monitor_callbacks *callbacks)
Unregister a set of monitor callbacks with the core.
union ast_frame::@263 data
unsigned int echocanbridged
TRUE if echo cancellation enabled when bridged.
int polarityonanswerdelay
Minimal time period (ms) between the answer polarity switch and hangup polarity switch.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
int sig_pri_is_chan_available(struct sig_pri_chan *pvt)
static int isslavenative(struct dahdi_pvt *p, struct dahdi_pvt **out)
enum ast_frame_type frametype
float rxgain
Software Rx gain set by chan_dahdi.conf.
static void destroy_dahdi_pvt(struct dahdi_pvt *pvt)
static char * dahdi_show_version(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define DAHDI_CHAN_MAPPING_LOGICAL
#define ast_mutex_init(pmutex)
static int my_check_confirmanswer(void *pvt)
#define SIG_PRI_AOC_GRANT_E
#define ast_channel_trylock(chan)
Callbacks defined by CC monitors.
unsigned char valid
TRUE if the name information is valid/present.
int tdd_generate(struct tdd_state *tdd, unsigned char *buf, const char *string)
struct ast_namedgroups * ast_unref_namedgroups(struct ast_namedgroups *groups)
void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message.
static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame)
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int sig_pri_cc_agent_start_offer_timer(struct ast_cc_agent *agent)
#define ast_mutex_destroy(a)
struct analog_subchannel subs[3]
void tdd_free(struct tdd_state *tdd)
static struct dahdi_pvt * mkintf(int channel, const struct dahdi_chan_conf *conf, int reloading)
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
struct ast_format * format
static char defaultcic[64]
#define LINKSET_FLAG_DEFAULTECHOCONTROL
int sig_pri_load(const char *cc_type_name)
void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan)
void callerid_get_dtmf(char *cidstring, char *number, int *flags)
Get and parse DTMF-based callerid.
int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
Tells Asterisk the State for Device is changed.
#define DSP_FEATURE_WAITDIALTONE
unsigned int hanguponpolarityswitch
struct sig_pri_chan * sig_pri_chan_new(void *pvt_data, struct sig_pri_span *pri, int logicalspan, int channo, int trunkgroup)
#define AST_LIST_HEAD_INIT_VALUE
Defines initial values for a declaration of AST_LIST_HEAD.
static int my_dsp_reset_and_flush_digits(void *pvt)
const char * ast_channel_macrocontext(const struct ast_channel *chan)
void ast_shrink_phone_number(char *n)
Shrink a phone number in place to just digits (more accurately it just removes ()'s, .'s, and -'s...
struct callerid_state * callerid_new(int cid_signalling)
Create a callerID state machine.
The structure that contains MWI state.
static void my_set_new_owner(void *pvt, struct ast_channel *new_owner)
int radio
Nonzero if the signaling type is sent over a radio.
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
#define CID_START_DTMF_NOALERT
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define DEBUG_ATLEAST(level)
#define AST_CAUSE_CALL_REJECTED
unsigned int allocated
TRUE when this channel is allocated.
int sig_ss7_cb_hangup(struct ss7 *ss7, int cic, unsigned int dpc, int cause, int do_hangup)
char rdnis[AST_MAX_EXTENSION]
Redirecting Directory Number Information Service (RDNIS) number.
static struct ast_timer * timer
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
struct pri * dchans[SIG_PRI_NUM_DCHANS]
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
char context[AST_MAX_CONTEXT]
Asterisk module definitions.
static struct dahdi_pvt * handle_init_event(struct dahdi_pvt *i, int event)
int callprogress
Bitmapped call progress detection flags. CALLPROGRESS_xxx values.
float hwrxgain
Hardware Rx gain set by chan_dahdi.conf.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
static int canmatch_featurecode(const char *pickupexten, const char *exten)
char language[MAX_LANGUAGE]
Language configured for calls.
unsigned int hwrxgain_enabled
TRUE if hardware Rx gain set by Asterisk.
static int build_channels(struct dahdi_chan_conf *conf, const char *value, int reload, int lineno)
static int action_transfer(struct mansession *s, const struct message *m)
ast_group_t group
Bitmapped groups this belongs to.
struct ast_mwi_subscriber * ast_mwi_subscribe_pool(const char *mailbox, stasis_subscription_cb callback, void *data)
Add an MWI state subscriber, and stasis subscription to the mailbox.
int dialtone_detect
Number of frames to watch for dialtone in incoming calls.
static snd_pcm_format_t format
#define SS7_BLOCKED_MAINTENANCE
int ast_active_channels(void)
returns number of active/allocated channels
static int revert_fax_buffers(struct dahdi_pvt *p, struct ast_channel *ast)
unsigned int inalarm
TRUE if in an alarm condition.
Persistant data storage (akin to *doze registry)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
void sig_pri_cc_agent_req_rsp(struct ast_cc_agent *agent, enum ast_cc_agent_response_reason reason)
#define SIG_PRI_AOC_GRANT_D
static char mwimonitornotify[PATH_MAX]
static int unload_module(void)
#define DLA_LOCK(lock)
Deadlock avoidance lock.
unsigned char valid
TRUE if the number information is valid/present.
int analog_dnd(struct analog_pvt *p, int flag)
int sendcalleridafter
Send caller ID on FXS after this many rings. Set to 1 for US.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
int sig_pri_is_alarm_ignored(struct sig_pri_span *pri)
General jitterbuffer configuration.
int sig_pri_cc_agent_callee_available(struct ast_cc_agent *agent)
int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel. ...
static void my_answer_polarityswitch(void *pvt)
ast_group_t callgroup
Bitmapped call groups this belongs to.
struct ast_channel * analog_request(struct analog_pvt *p, int *callwait, const struct ast_channel *requestor)
char dialdest[256]
Delayed dialing for E911. Overlap digits for ISDN.
unsigned int permcallwaiting
char mohinterpret[MAX_MUSICCLASS]
static void publish_channel_alarm(int channel, const char *alarm_txt)
static void dahdi_close(int fd)
static struct ast_channel * dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
#define AST_CAUSE_CONGESTION
void * ss7_linkset(void *data)
#define AST_TRANS_CAP_DIGITAL
#define LINKSET_FLAG_AUTOACM
unsigned int mate
TRUE if TDD in MATE mode.
#define CANPROGRESSDETECT(p)
static int dahdi_digit_begin(struct ast_channel *ast, char digit)
#define AST_MUTEX_DEFINE_STATIC(mutex)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int action_dahdidialoffhook(struct mansession *s, const struct message *m)
unsigned char buf[READ_SIZE]
unsigned int canpark
TRUE if support for call parking is enabled.
static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct ast_variable *v, int reload, int options)
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
int fds[SIG_PRI_NUM_DCHANS]
struct distRingData ringnum[3]
static char * dahdi_set_swgain(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static void dahdi_lock_sub_owner(struct dahdi_pvt *pvt, int sub_idx)
unsigned int pulsedial
TRUE if a pulsed digit was detected. (Pulse dial phone detected)
void pri_event_noalarm(struct sig_pri_span *pri, int index, int before_start_pri)
struct dahdi_confinfo curconf
void ast_manager_publish_event(const char *type, int class_type, struct ast_json *obj)
Publish an event to AMI.
#define ast_app_separate_args(a, b, c, d)
char mohsuggest[MAX_MUSICCLASS]
Suggested music-on-hold class for peer channel to use for calls.
static int action_transferhangup(struct mansession *s, const struct message *m)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
unsigned int answeronpolarityswitch
#define ast_mutex_unlock(a)
int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int samples, struct ast_format *codec)
Read samples into the state machine.
char begindigit
DTMF digit in progress. 0 when no digit in progress.
Configuration relating to call pickup.
static struct chans chans
#define AST_APP_ARG(name)
Define an application argument.
int ast_gen_cas(unsigned char *outbuf, int sas, int len, struct ast_format *codec)
Generate a CAS (CPE Alert Signal) tone for 'n' samples.
char accountcode[AST_MAX_ACCOUNT_CODE]
int sig_pri_cc_agent_status_req(struct ast_cc_agent *agent)
void astman_send_listack(struct mansession *s, const struct message *m, char *msg, char *listflag)
Send ack in manager transaction to begin a list.
struct ast_party_number number
Subscriber phone number.
int tdd_feed(struct tdd_state *tdd, unsigned char *ubuf, int samples)
#define ast_module_ref(mod)
Hold a reference to the module.
unsigned int mwimonitor_rpas
TRUE if the FXO port monitors for rpas precursor to fsk MWI indications from the other end...
void sig_ss7_cb_call_null(struct ss7 *ss7, struct isup_call *c, int lock)
unsigned int mwisendactive
TRUE if a MWI message sending thread is active.