47 #if defined(LIBSS7_ABI_COMPATIBILITY)
48 #error "Your installed libss7 is not compatible"
76 static void sig_ss7_unlock_private(
struct sig_ss7_chan *p)
98 static void sig_ss7_set_dialing(
struct sig_ss7_chan *p,
int is_dialing)
105 static void sig_ss7_set_digital(
struct sig_ss7_chan *p,
int is_digital)
112 static void sig_ss7_set_outgoing(
struct sig_ss7_chan *p,
int is_outgoing)
120 static void sig_ss7_set_inservice(
struct sig_ss7_chan *p,
int is_inservice)
127 static void sig_ss7_set_locallyblocked(
struct sig_ss7_chan *p,
int is_blocked)
135 static void sig_ss7_set_remotelyblocked(
struct sig_ss7_chan *p,
int is_blocked)
168 static void sig_ss7_set_caller_id(
struct sig_ss7_chan *p)
177 caller.id.name.valid = 1;
179 caller.id.number.str = p->
cid_num;
180 caller.id.number.plan = p->
cid_ton;
182 caller.id.number.valid = 1;
185 caller.id.subaddress.valid = 1;
191 caller.ani.number.str = p->
cid_ani;
194 caller.ani.number.valid = 1;
211 static void sig_ss7_set_dnid(
struct sig_ss7_chan *p,
const char *dnid)
230 static int sig_ss7_set_echocanceller(
struct sig_ss7_chan *p,
int enable)
238 static void sig_ss7_loopback(
struct sig_ss7_chan *p,
int enable)
269 sig_ss7_set_digital(p, 1);
275 static void sig_ss7_handle_link_exception(
struct sig_ss7_linkset *linkset,
int which)
290 static int sig_ss7_is_chan_available(
struct sig_ss7_chan *pvt)
313 static void sig_ss7_lock_owner(
struct sig_ss7_linkset *ss7,
int chanpos)
326 sig_ss7_unlock_private(ss7->
pvts[chanpos]);
328 sig_ss7_lock_private(ss7->
pvts[chanpos]);
348 sig_ss7_lock_owner(ss7, chanpos);
369 static void sig_ss7_queue_control(
struct sig_ss7_linkset *ss7,
int chanpos,
int subclass)
379 sig_ss7_queue_frame(ss7, chanpos, &f);
397 for (i = 0; i < linkset->
numchans; i++) {
398 if (linkset->
pvts[i] && (linkset->
pvts[i]->
dpc == dpc && linkset->
pvts[i]->
cic == cic)) {
418 static int ss7_find_cic_gripe(
struct sig_ss7_linkset *linkset,
int cic,
unsigned int dpc,
const char *msg_name)
422 chanpos = ss7_find_cic(linkset, cic, dpc);
425 linkset->
span, msg_name, cic, dpc);
431 static void ss7_handle_cqm(
struct sig_ss7_linkset *linkset,
int startcic,
int endcic,
unsigned int dpc)
437 for (i = 0; i < linkset->
numchans; i++) {
438 if (linkset->
pvts[i] && (linkset->
pvts[i]->
dpc == dpc && ((linkset->
pvts[i]->
cic >= startcic) && (linkset->
pvts[i]->
cic <= endcic)))) {
439 p = linkset->
pvts[i];
440 offset = p->
cic - startcic;
443 status[offset] |= (1 << 0) | (1 << 4);
445 status[offset] |= (1 << 1) | (1 << 5);
448 status[offset] |= (1 << 3);
450 status[offset] |= (1 << 2);
452 status[offset] |= 0x3 << 2;
457 isup_cqr(linkset->
ss7, startcic, endcic, dpc, status);
463 static inline void ss7_hangup_cics(
struct sig_ss7_linkset *linkset,
int startcic,
int endcic,
unsigned int dpc)
467 for (i = 0; i < linkset->
numchans; i++) {
468 if (linkset->
pvts[i] && (linkset->
pvts[i]->
dpc == dpc && ((linkset->
pvts[i]->
cic >= startcic) && (linkset->
pvts[i]->
cic <= endcic)))) {
469 sig_ss7_lock_private(linkset->
pvts[i]);
470 sig_ss7_lock_owner(linkset, i);
475 sig_ss7_unlock_private(linkset->
pvts[i]);
480 static inline void ss7_block_cics(
struct sig_ss7_linkset *linkset,
int startcic,
int endcic,
unsigned int dpc,
unsigned char state[],
int block)
485 for (i = 0; i < linkset->
numchans; i++) {
486 if (linkset->
pvts[i] && (linkset->
pvts[i]->
dpc == dpc && ((linkset->
pvts[i]->
cic >= startcic) && (linkset->
pvts[i]->
cic <= endcic)))) {
489 sig_ss7_set_remotelyblocked(linkset->
pvts[i], block);
491 sig_ss7_set_remotelyblocked(linkset->
pvts[i], block);
496 static void ss7_inservice(
struct sig_ss7_linkset *linkset,
int startcic,
int endcic,
unsigned int dpc)
500 for (i = 0; i < linkset->
numchans; i++) {
501 if (linkset->
pvts[i] && (linkset->
pvts[i]->
dpc == dpc && ((linkset->
pvts[i]->
cic >= startcic) && (linkset->
pvts[i]->
cic <= endcic))))
502 sig_ss7_set_inservice(linkset->
pvts[i], 1);
508 int i, startcic = -1, endcic,
dpc;
513 startcic = linkset->
pvts[0]->
cic;
517 for (i = 0; i < linkset->
numchans; i++) {
518 if (linkset->
pvts[i+1] && linkset->
pvts[i+1]->
dpc == dpc && ((linkset->
pvts[i+1]->
cic - linkset->
pvts[i]->
cic) == 1) && (linkset->
pvts[i]->
cic - startcic < 31)) {
521 endcic = linkset->
pvts[i]->
cic;
522 ast_verbose(
"Resetting CICs %d to %d\n", startcic, endcic);
523 isup_grs(linkset->
ss7, startcic, endcic, dpc);
526 if (linkset->
pvts[i+1]) {
527 startcic = linkset->
pvts[i+1]->
cic;
537 struct ss7 *ss7 = linkset->
ss7;
550 if (linkset->
type == SS7_ITU) {
562 sig_ss7_unlock_private(p);
567 sig_ss7_lock_private(p);
576 sig_ss7_lock_private(p);
578 sig_ss7_set_echocanceller(p, 1);
659 sig_ss7_unlock_private(p);
671 sig_ss7_lock_private(p);
674 static void ss7_apply_plan_to_number(
char *buf,
size_t size,
const struct sig_ss7_linkset *ss7,
const char *
number,
const unsigned nai)
683 case SS7_NAI_INTERNATIONAL:
686 case SS7_NAI_NATIONAL:
689 case SS7_NAI_SUBSCRIBER:
692 case SS7_NAI_UNKNOWN:
696 snprintf(buf, size,
"%s", number);
701 static int ss7_pres_scr2cid_pres(
char presentation_ind,
char screening_ind)
703 return ((presentation_ind & 0x3) << 5) | (screening_ind & 0x3);
710 struct timeval *next = NULL,
tv;
712 struct ss7 *ss7 = linkset->
ss7;
719 #define SS7_MAX_POLL 60000
721 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
730 if ((next = ss7_schedule_next(ss7))) {
732 tv.tv_sec = next->tv_sec - tv.tv_sec;
733 tv.tv_usec = next->tv_usec - tv.tv_usec;
734 if (tv.tv_usec < 0) {
735 tv.tv_usec += 1000000;
742 nextms = tv.tv_sec * 1000;
743 nextms += tv.tv_usec / 1000;
744 if (SS7_MAX_POLL < nextms) {
745 nextms = SS7_MAX_POLL;
748 nextms = SS7_MAX_POLL;
752 pollers[i].fd = linkset->
fds[i];
753 pollers[i].events = ss7_pollflags(ss7, linkset->
fds[i]);
754 pollers[i].revents = 0;
758 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
759 pthread_testcancel();
761 pthread_testcancel();
762 pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
764 if ((res < 0) && (
errno != EINTR)) {
768 ss7_schedule_run(ss7);
775 if (pollers[i].revents & POLLPRI) {
776 sig_ss7_handle_link_exception(linkset, i);
778 if (pollers[i].revents & POLLIN) {
779 res = ss7_read(ss7, pollers[i].fd);
781 if (pollers[i].revents & POLLOUT) {
782 res = ss7_write(ss7, pollers[i].fd);
789 while ((e = ss7_check_event(ss7))) {
790 if (linkset->
debug) {
792 linkset->
span, ss7_event2str(e->e));
797 if (linkset->
state != LINKSET_STATE_UP) {
799 ss7_reset_linkset(linkset);
801 linkset->
state = LINKSET_STATE_UP;
805 linkset->
state = LINKSET_STATE_DOWN;
806 for (i = 0; i < linkset->
numchans; i++) {
807 p = linkset->
pvts[i];
814 ast_verbose(
"MTP2 link up (SLC %d)\n", e->gen.data);
820 chanpos = ss7_find_cic_gripe(linkset, e->cpg.cic, e->cpg.opc,
"CPG");
824 p = linkset->
pvts[chanpos];
825 sig_ss7_lock_private(p);
826 switch (e->cpg.event) {
827 case CPG_EVENT_ALERTING:
831 sig_ss7_lock_owner(linkset, chanpos);
838 case CPG_EVENT_PROGRESS:
839 case CPG_EVENT_INBANDINFO:
841 ast_debug(1,
"Queuing frame PROGRESS on CIC %d\n", p->
cic);
844 sig_ss7_set_dialing(p, 0);
845 sig_ss7_open_media(p);
849 ast_debug(1,
"Do not handle CPG with event type 0x%x\n", e->cpg.event);
853 sig_ss7_unlock_private(p);
857 chanpos = ss7_find_cic_gripe(linkset, e->rsc.cic, e->rsc.opc,
"RSC");
861 p = linkset->
pvts[chanpos];
862 sig_ss7_lock_private(p);
863 sig_ss7_set_inservice(p, 1);
864 sig_ss7_set_remotelyblocked(p, 0);
865 isup_set_call_dpc(e->rsc.call, p->
dpc);
866 sig_ss7_lock_owner(linkset, chanpos);
872 sig_ss7_unlock_private(p);
873 isup_rlc(ss7, e->rsc.call);
876 ast_debug(1,
"Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
877 chanpos = ss7_find_cic_gripe(linkset, e->grs.startcic, e->grs.opc,
"GRS");
881 p = linkset->
pvts[chanpos];
882 isup_gra(ss7, e->grs.startcic, e->grs.endcic, e->grs.opc);
883 ss7_block_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc, NULL, 0);
884 ss7_hangup_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc);
887 ast_debug(1,
"Got Circuit group query message from CICs %d to %d\n", e->cqm.startcic, e->cqm.endcic);
888 ss7_handle_cqm(linkset, e->cqm.startcic, e->cqm.endcic, e->cqm.opc);
891 ast_verbose(
"Got reset acknowledgement from CIC %d to %d.\n", e->gra.startcic, e->gra.endcic);
892 ss7_inservice(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc);
893 ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc, e->gra.status, 1);
896 ast_debug(1,
"Got IAM for CIC %d and called number %s, calling number %s\n", e->iam.cic, e->iam.called_party_num, e->iam.calling_party_num);
897 chanpos = ss7_find_cic_gripe(linkset, e->iam.cic, e->iam.opc,
"IAM");
899 isup_rel(ss7, e->iam.call, -1);
902 p = linkset->
pvts[chanpos];
903 sig_ss7_lock_private(p);
904 sig_ss7_lock_owner(linkset, chanpos);
915 "Linkset %d: SS7 IAM glare on CIC/DPC %d/%d. Dropping both calls.\n",
916 linkset->
span, e->iam.cic, e->iam.opc);
930 sig_ss7_unlock_private(p);
939 if (!sig_ss7_is_chan_available(p)) {
942 sig_ss7_unlock_private(p);
954 p->
callingpres = ss7_pres_scr2cid_pres(e->iam.presentation_ind, e->iam.screening_ind);
960 ss7_apply_plan_to_number(p->
exten,
sizeof(p->
exten), linkset,
965 sig_ss7_set_dnid(p, p->
exten);
972 ss7_apply_plan_to_number(p->
exten,
sizeof(p->
exten), linkset, e->iam.called_party_num, e->iam.
called_nai);
973 st = strchr(p->
exten,
'#');
1004 sig_ss7_set_caller_id(p);
1007 if (e->iam.cot_check_required) {
1009 sig_ss7_loopback(p, 1);
1011 ss7_start_call(p, linkset);
1014 ast_debug(1,
"Call on CIC for unconfigured extension %s\n", p->
exten);
1018 sig_ss7_unlock_private(p);
1020 case ISUP_EVENT_COT:
1021 chanpos = ss7_find_cic_gripe(linkset, e->cot.cic, e->cot.opc,
"COT");
1023 isup_rel(ss7, e->cot.call, -1);
1026 p = linkset->
pvts[chanpos];
1028 sig_ss7_lock_private(p);
1030 sig_ss7_loopback(p, 0);
1031 ss7_start_call(p, linkset);
1033 sig_ss7_unlock_private(p);
1035 case ISUP_EVENT_CCR:
1036 ast_debug(1,
"Got CCR request on CIC %d\n", e->ccr.cic);
1037 chanpos = ss7_find_cic_gripe(linkset, e->ccr.cic, e->ccr.opc,
"CCR");
1042 p = linkset->
pvts[chanpos];
1044 sig_ss7_lock_private(p);
1045 sig_ss7_loopback(p, 1);
1046 sig_ss7_unlock_private(p);
1048 isup_lpa(linkset->
ss7, e->ccr.cic, p->
dpc);
1050 case ISUP_EVENT_CVT:
1051 ast_debug(1,
"Got CVT request on CIC %d\n", e->cvt.cic);
1052 chanpos = ss7_find_cic_gripe(linkset, e->cvt.cic, e->cvt.opc,
"CVT");
1057 p = linkset->
pvts[chanpos];
1059 sig_ss7_lock_private(p);
1060 sig_ss7_loopback(p, 1);
1061 sig_ss7_unlock_private(p);
1063 isup_cvr(linkset->
ss7, e->cvt.cic, p->
dpc);
1065 case ISUP_EVENT_REL:
1066 chanpos = ss7_find_cic_gripe(linkset, e->rel.cic, e->rel.opc,
"REL");
1069 isup_rlc(ss7, e->rel.call);
1072 p = linkset->
pvts[chanpos];
1073 sig_ss7_lock_private(p);
1074 sig_ss7_lock_owner(linkset, chanpos);
1082 sig_ss7_loopback(p, 0);
1084 isup_rlc(ss7, e->rel.call);
1087 sig_ss7_unlock_private(p);
1089 case ISUP_EVENT_ACM:
1090 chanpos = ss7_find_cic_gripe(linkset, e->acm.cic, e->acm.opc,
"ACM");
1092 isup_rel(ss7, e->acm.call, -1);
1096 p = linkset->
pvts[chanpos];
1098 ast_debug(1,
"Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->
cic);
1100 if (e->acm.call_ref_ident > 0) {
1104 sig_ss7_lock_private(p);
1109 sig_ss7_set_dialing(p, 0);
1111 if (e->acm.called_party_status_ind == 1) {
1115 sig_ss7_lock_owner(linkset, chanpos);
1122 sig_ss7_unlock_private(p);
1125 case ISUP_EVENT_CGB:
1126 chanpos = ss7_find_cic_gripe(linkset, e->cgb.startcic, e->cgb.opc,
"CGB");
1130 p = linkset->
pvts[chanpos];
1131 ss7_block_cics(linkset, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, 1);
1132 isup_cgba(linkset->
ss7, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, e->cgb.type);
1134 case ISUP_EVENT_CGU:
1135 chanpos = ss7_find_cic_gripe(linkset, e->cgu.startcic, e->cgu.opc,
"CGU");
1139 p = linkset->
pvts[chanpos];
1140 ss7_block_cics(linkset, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, 0);
1141 isup_cgua(linkset->
ss7, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, e->cgu.type);
1143 case ISUP_EVENT_UCIC:
1144 chanpos = ss7_find_cic_gripe(linkset, e->ucic.cic, e->ucic.opc,
"UCIC");
1148 p = linkset->
pvts[chanpos];
1149 ast_debug(1,
"Unequiped Circuit Id Code on CIC %d\n", e->ucic.cic);
1150 sig_ss7_lock_private(p);
1151 sig_ss7_set_remotelyblocked(p, 1);
1152 sig_ss7_set_inservice(p, 0);
1153 sig_ss7_unlock_private(p);
1155 case ISUP_EVENT_BLO:
1156 chanpos = ss7_find_cic_gripe(linkset, e->blo.cic, e->blo.opc,
"BLO");
1160 p = linkset->
pvts[chanpos];
1161 ast_debug(1,
"Blocking CIC %d\n", e->blo.cic);
1162 sig_ss7_lock_private(p);
1163 sig_ss7_set_remotelyblocked(p, 1);
1164 sig_ss7_unlock_private(p);
1165 isup_bla(linkset->
ss7, e->blo.cic, p->
dpc);
1167 case ISUP_EVENT_BLA:
1168 chanpos = ss7_find_cic_gripe(linkset, e->bla.cic, e->bla.opc,
"BLA");
1172 ast_debug(1,
"Blocking CIC %d\n", e->bla.cic);
1173 p = linkset->
pvts[chanpos];
1174 sig_ss7_lock_private(p);
1175 sig_ss7_set_locallyblocked(p, 1);
1176 sig_ss7_unlock_private(p);
1178 case ISUP_EVENT_UBL:
1179 chanpos = ss7_find_cic_gripe(linkset, e->ubl.cic, e->ubl.opc,
"UBL");
1183 p = linkset->
pvts[chanpos];
1184 ast_debug(1,
"Unblocking CIC %d\n", e->ubl.cic);
1185 sig_ss7_lock_private(p);
1186 sig_ss7_set_remotelyblocked(p, 0);
1187 sig_ss7_unlock_private(p);
1188 isup_uba(linkset->
ss7, e->ubl.cic, p->
dpc);
1190 case ISUP_EVENT_UBA:
1191 chanpos = ss7_find_cic_gripe(linkset, e->uba.cic, e->uba.opc,
"UBA");
1195 p = linkset->
pvts[chanpos];
1196 ast_debug(1,
"Unblocking CIC %d\n", e->uba.cic);
1197 sig_ss7_lock_private(p);
1198 sig_ss7_set_locallyblocked(p, 0);
1199 sig_ss7_unlock_private(p);
1201 case ISUP_EVENT_CON:
1202 case ISUP_EVENT_ANM:
1203 if (e->e == ISUP_EVENT_CON) {
1204 chanpos = ss7_find_cic_gripe(linkset, e->con.cic, e->con.opc,
"CON");
1206 isup_rel(ss7, e->con.call, -1);
1210 chanpos = ss7_find_cic_gripe(linkset, e->anm.cic, e->anm.opc,
"ANM");
1212 isup_rel(ss7, e->anm.call, -1);
1218 p = linkset->
pvts[chanpos];
1219 sig_ss7_lock_private(p);
1224 sig_ss7_set_dialing(p, 0);
1225 sig_ss7_open_media(p);
1226 sig_ss7_set_echocanceller(p, 1);
1227 sig_ss7_unlock_private(p);
1230 case ISUP_EVENT_RLC:
1232 chanpos = ss7_find_cic_gripe(linkset, e->rlc.cic, e->rlc.opc,
"RLC");
1237 p = linkset->
pvts[chanpos];
1238 sig_ss7_lock_private(p);
1245 sig_ss7_unlock_private(p);
1248 case ISUP_EVENT_FAA:
1253 chanpos = ss7_find_cic_gripe(linkset, e->faa.cic, e->faa.opc,
"FAA");
1255 isup_rel(linkset->
ss7, e->faa.call, -1);
1260 p = linkset->
pvts[chanpos];
1261 ast_debug(1,
"FAA received on CIC %d\n", e->faa.cic);
1262 sig_ss7_lock_private(p);
1271 sig_ss7_unlock_private(p);
1275 ast_debug(1,
"Unknown event %s\n", ss7_event2str(e->e));
1295 sig_ss7_unlock_private(pvt);
1297 sig_ss7_lock_private(pvt);
1301 pthread_kill(ss7->
master, SIGURG);
1318 ss7_link_alarm(linkset->
ss7, linkset->
fds[which]);
1334 ss7_link_noalarm(linkset->
ss7, linkset->
fds[which]);
1355 if (!linkset->
ss7) {
1356 linkset->
type = ss7type;
1357 linkset->
ss7 = ss7_new(ss7type);
1358 if (!linkset->
ss7) {
1364 ss7_set_network_ind(linkset->
ss7, networkindicator);
1365 ss7_set_pc(linkset->
ss7, pointcode);
1367 if (ss7_add_link(linkset->
ss7, transport, linkset->
fds[which])) {
1373 ss7_link_alarm(linkset->
ss7, linkset->
fds[which]);
1376 ss7_link_noalarm(linkset->
ss7, linkset->
fds[which]);
1379 ss7_set_adjpc(linkset->
ss7, linkset->
fds[which], adjpointcode);
1403 available = sig_ss7_is_chan_available(p);
1412 static unsigned char cid_pres2ss7pres(
int cid_pres)
1414 return (cid_pres >> 5) & 0x03;
1417 static unsigned char cid_pres2ss7screen(
int cid_pres)
1419 return cid_pres & 0x03;
1435 char ss7_called_nai;
1436 int called_nai_strip;
1437 char ss7_calling_nai;
1438 int calling_nai_strip;
1439 const char *charge_str = NULL;
1440 const char *gen_address = NULL;
1441 const char *gen_digits = NULL;
1442 const char *gen_dig_type = NULL;
1443 const char *gen_dig_scheme = NULL;
1444 const char *gen_name = NULL;
1445 const char *jip_digits = NULL;
1446 const char *lspi_ident = NULL;
1447 const char *rlt_flag = NULL;
1448 const char *call_ref_id = NULL;
1449 const char *call_ref_pc = NULL;
1450 const char *send_far = NULL;
1457 c = strchr(dest,
'/');
1474 ss7_grab(p, p->
ss7);
1489 called_nai_strip = 0;
1494 ss7_called_nai = SS7_NAI_INTERNATIONAL;
1497 ss7_called_nai = SS7_NAI_NATIONAL;
1499 ss7_called_nai = SS7_NAI_SUBSCRIBER;
1504 calling_nai_strip = 0;
1509 ss7_calling_nai = SS7_NAI_INTERNATIONAL;
1512 ss7_calling_nai = SS7_NAI_NATIONAL;
1514 ss7_calling_nai = SS7_NAI_SUBSCRIBER;
1517 isup_set_calling(p->
ss7call, l ? (l + calling_nai_strip) : NULL, ss7_calling_nai,
1527 isup_set_charge(p->
ss7call, charge_str, SS7_ANI_CALLING_PARTY_SUB_NUMBER, 0x10);
1537 isup_set_gen_digits(p->
ss7call, gen_digits, atoi(gen_dig_type), atoi(gen_dig_scheme));
1541 isup_set_generic_name(p->
ss7call, gen_name, GEN_NAME_TYPE_CALLING_NAME, GEN_NAME_AVAIL_AVAILABLE, GEN_NAME_PRES_ALLOWED);
1545 isup_set_jip_digits(p->
ss7call, jip_digits);
1549 isup_set_lspi(p->
ss7call, lspi_ident, 0x18, 0x7, 0x00);
1552 if ((rlt_flag) && ((strncmp(
"NO", rlt_flag, strlen(rlt_flag))) != 0 )) {
1553 isup_set_lspi(p->
ss7call, rlt_flag, 0x18, 0x7, 0x00);
1558 if (call_ref_id && call_ref_pc) {
1559 isup_set_callref(p->
ss7call, atoi(call_ref_id),
1560 call_ref_pc ? atoi(call_ref_pc) : 0);
1564 if ((send_far) && ((strncmp(
"NO", send_far, strlen(send_far))) != 0 ))
1569 sig_ss7_set_dialing(p, 1);
1595 sig_ss7_set_dialing(p, 0);
1596 sig_ss7_set_outgoing(p, 0);
1601 ss7_grab(p, p->
ss7);
1610 icause = atoi(cause);
1636 ss7_grab(p, p->
ss7);
1640 sig_ss7_open_media(p);
1658 if (pchan->
owner == oldchan) {
1659 pchan->
owner = newchan;
1680 switch (condition) {
1691 ss7_grab(p, p->
ss7);
1712 ast_debug(1,
"Received AST_CONTROL_PROCEEDING on %s\n",chan->
name);
1713 ss7_grab(p, p->
ss7);
1730 ast_debug(1,
"Received AST_CONTROL_PROGRESS on %s\n",chan->
name);
1731 ss7_grab(p, p->
ss7);
1738 sig_ss7_set_echocanceller(p, 1);
1774 res = sig_ss7_play_tone(p, -1);
1797 if (p->
ss7->
type == SS7_ITU) {
1803 sig_ss7_set_outgoing(p, 1);
1806 sig_ss7_set_outgoing(p, 0);
1829 #define SIG_SS7_SC_HEADER "%-4s %4s %-4s %-3s %-3s %-10s %-4s %s\n"
1830 #define SIG_SS7_SC_LINE "%4d %4d %-4s %-3s %-3s %-10s %-4s %s"
1833 ast_cli(fd, SIG_SS7_SC_HEADER,
"link",
"",
"Chan",
"Lcl",
"Rem",
"Call",
"SS7",
"Channel");
1834 ast_cli(fd, SIG_SS7_SC_HEADER,
"set",
"Chan",
"Idle",
"Blk",
"Blk",
"Level",
"Call",
"Name");
1844 for (idx = 0; idx < linkset->
numchans; ++idx) {
1845 if (!linkset->
pvts[idx]) {
1848 pvt = linkset->
pvts[idx];
1849 sig_ss7_lock_private(pvt);
1850 sig_ss7_lock_owner(linkset, idx);
1852 snprintf(line,
sizeof(line), SIG_SS7_SC_LINE,
1855 sig_ss7_is_chan_available(pvt) ?
"Yes" :
"No",
1865 sig_ss7_unlock_private(pvt);
1894 pvt->
calls = callback;
1913 memset(ss7, 0,
sizeof(*ss7));
unsigned char gen_add_pres_ind
union ast_frame_subclass subclass
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
#define ast_channel_lock(chan)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
void(*const set_callerid)(void *pvt, const struct ast_party_caller *caller)
char * str
Subscriber phone number (Malloced)
struct sig_ss7_callback * calls
General Asterisk channel transcoding definitions.
struct ast_party_connected_line connected
Channel Connected Line ID information.
unsigned int alreadyhungup
TRUE if the call has already gone/hungup.
enum sig_ss7_call_level call_level
Asterisk main include file. File version handling, generic pbx functions.
int sig_ss7_available(struct sig_ss7_chan *p)
unsigned char gen_dig_type
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
struct ast_party_id id
Connected party ID.
unsigned char gen_add_num_plan
#define AST_CAUSE_SWITCH_CONGESTION
void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset)
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
#define AST_CAUSE_UNALLOCATED
void(*const unlock_private)(void *pvt)
#define DEADLOCK_AVOIDANCE(lock)
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
void ast_verbose(const char *fmt,...)
enum sig_ss7_linkset::@121 state
struct sig_ss7_linkset * ss7
Interface header for SS7 signaling module.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
int ani2
Automatic Number Identification 2 (Info Digits)
#define ast_mutex_lock(a)
unsigned short transfercapability
unsigned char gen_dig_scheme
char exten[AST_MAX_EXTENSION]
#define AST_CAUSE_NORMAL_CIRCUIT_CONGESTION
void ast_cli(int fd, const char *fmt,...)
int(*const set_echocanceller)(void *pvt, int enable)
#define AST_CAUSE_INVALID_NUMBER_FORMAT
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
void(*const open_media)(void *pvt)
int(*const play_tone)(void *pvt, enum sig_ss7_tone tone)
#define ast_verb(level,...)
struct sig_ss7_chan * sig_ss7_chan_new(void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7)
char cid_subaddr[AST_MAX_EXTENSION]
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
char cid_name[AST_MAX_EXTENSION]
struct sig_ss7_callback * calls
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
unsigned int remotelyblocked
TRUE if the channel is remotely blocked. Set by user and link.
#define LINKSTATE_INALARM
char context[AST_MAX_CONTEXT]
#define ast_debug(level,...)
Log a DEBUG message.
unsigned int use_callerid
TRUE if caller ID is used on this channel.
unsigned int progress
TRUE if the call has seen inband-information progress through the network.
void(*const set_dialing)(void *pvt, int is_dialing)
#define LINKSTATE_STARTING
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
#define ast_mutex_trylock(a)
#define AST_PTHREADT_NULL
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void(*const queue_control)(void *pvt, int subclass)
void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which)
#define LINKSET_FLAG_EXPLICITACM
void(*const set_alarm)(void *pvt, int in_alarm)
void sig_ss7_cli_show_channels_header(int fd)
Caller Party information.
void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm)
void(*const set_loopback)(void *pvt, int enable)
char mohinterpret[MAX_MUSICCLASS]
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
void(*const set_locallyblocked)(void *pvt, int is_blocked)
char subscriberprefix[20]
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
void(*const set_digital)(void *pvt, int is_digital)
struct sig_ss7_chan * pvts[SIG_SS7_MAX_CHANNELS]
int fds[SIG_SS7_NUM_DCHANS]
void(*const handle_link_exception)(struct sig_ss7_linkset *linkset, int which)
#define SIG_SS7_NUM_DCHANS
enum ast_channel_state _state
void(*const set_remotelyblocked)(void *pvt, int is_blocked)
const ast_string_field name
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
unsigned int rlt
XXX BOOLEAN Purpose???
unsigned char gen_add_type
int ast_softhangup_nolock(struct ast_channel *chan, int reason)
Softly hangup up a channel (no channel lock)
int linkstate[SIG_SS7_NUM_DCHANS]
void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7)
#define ast_channel_unlock(chan)
unsigned int call_ref_ident
void(*const set_dnid)(void *pvt, const char *dnid)
struct ast_channel * sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability)
#define SIG_SS7_DEBUG_DEFAULT
void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which)
char cid_num[AST_MAX_EXTENSION]
int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest)
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 available(struct dahdi_pvt **pvt, int is_specific_channel)
unsigned int locallyblocked
TRUE if the channel is locally blocked. Set by user and link.
void(*const set_inservice)(void *pvt, int is_inservice)
void sig_ss7_chan_delete(struct sig_ss7_chan *doomed)
int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast)
Standard Command Line Interface.
int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define AST_CAUSE_USER_BUSY
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
char * ast_transfercapability2str(int transfercapability) attribute_const
Gives the string form of a given transfer capability.
Data structure associated with a single frame of data.
Internal Asterisk hangup causes.
struct ast_channel * owner
char internationalprefix[10]
struct isup_call * ss7call
Opaque libss7 call control structure.
int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast)
char cid_ani[AST_MAX_EXTENSION]
struct ast_channel *(*const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor)
#define ast_mutex_init(pmutex)
#define ast_channel_trylock(chan)
void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan)
unsigned char gen_add_nai
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
void(*const lock_private)(void *pvt)
unsigned char valid
TRUE if the number information is valid/present.
void(*const set_outgoing)(void *pvt, int is_outgoing)
#define AST_CAUSE_CONGESTION
void * ss7_linkset(void *data)
#define AST_TRANS_CAP_DIGITAL
unsigned char calling_party_cat
#define ast_mutex_unlock(a)
struct ast_party_number number
Subscriber phone number.