Interface header for SS7 signaling module. More...


Go to the source code of this file.
Data Structures | |
| struct | sig_ss7_callback |
| struct | sig_ss7_chan |
| struct | sig_ss7_linkset |
Defines | |
| #define | LINKSET_FLAG_EXPLICITACM (1 << 0) |
| #define | LINKSTATE_DOWN (1 << 3) |
| #define | LINKSTATE_INALARM (1 << 0) |
| #define | LINKSTATE_STARTING (1 << 1) |
| #define | LINKSTATE_UP (1 << 2) |
| #define | SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR) |
| #define | SIG_SS7_DEBUG (SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP) |
| #define | SIG_SS7_DEBUG_DEFAULT 0 |
| #define | SIG_SS7_MAX_CHANNELS 672 |
| #define | SIG_SS7_NUM_DCHANS 4 |
| #define | SS7_NAI_DYNAMIC -1 |
Enumerations | |
| enum | sig_ss7_call_level { SIG_SS7_CALL_LEVEL_IDLE, SIG_SS7_CALL_LEVEL_ALLOCATED, SIG_SS7_CALL_LEVEL_CONTINUITY, SIG_SS7_CALL_LEVEL_SETUP, SIG_SS7_CALL_LEVEL_PROCEEDING, SIG_SS7_CALL_LEVEL_ALERTING, SIG_SS7_CALL_LEVEL_CONNECT, SIG_SS7_CALL_LEVEL_GLARE } |
| enum | sig_ss7_law { SIG_SS7_DEFLAW = 0, SIG_SS7_ULAW, SIG_SS7_ALAW } |
| enum | sig_ss7_tone { SIG_SS7_TONE_RINGTONE = 0, SIG_SS7_TONE_STUTTER, SIG_SS7_TONE_CONGESTION, SIG_SS7_TONE_DIALTONE, SIG_SS7_TONE_DIALRECALL, SIG_SS7_TONE_INFO, SIG_SS7_TONE_BUSY } |
Functions | |
| int | sig_ss7_add_sigchan (struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode) |
| Setup and add a SS7 link channel. | |
| int | sig_ss7_answer (struct sig_ss7_chan *p, struct ast_channel *ast) |
| SS7 answer channel. | |
| int | sig_ss7_available (struct sig_ss7_chan *p) |
| Determine if the specified channel is available for an outgoing call. | |
| int | sig_ss7_call (struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest) |
| Dial out using the specified SS7 channel. | |
| void | sig_ss7_chan_delete (struct sig_ss7_chan *doomed) |
| Delete the sig_ss7 private channel structure. | |
| struct sig_ss7_chan * | sig_ss7_chan_new (void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7) |
| Create a new sig_ss7 private channel structure. | |
| void | sig_ss7_cli_show_channels (int fd, struct sig_ss7_linkset *linkset) |
| void | sig_ss7_cli_show_channels_header (int fd) |
| void | sig_ss7_fixup (struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan) |
| Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links. | |
| int | sig_ss7_hangup (struct sig_ss7_chan *p, struct ast_channel *ast) |
| SS7 hangup channel. | |
| int | sig_ss7_indicate (struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen) |
| SS7 answer channel. | |
| void | sig_ss7_init_linkset (struct sig_ss7_linkset *ss7) |
| Initialize the SS7 linkset control. | |
| void | sig_ss7_link_alarm (struct sig_ss7_linkset *linkset, int which) |
| Notify the SS7 layer that the link is in alarm. | |
| void | sig_ss7_link_noalarm (struct sig_ss7_linkset *linkset, int which) |
| Notify the SS7 layer that the link is no longer in alarm. | |
| struct ast_channel * | sig_ss7_request (struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability) |
| SS7 channel request. | |
| void | sig_ss7_set_alarm (struct sig_ss7_chan *p, int in_alarm) |
| void * | ss7_linkset (void *data) |
| #define LINKSET_FLAG_EXPLICITACM (1 << 0) |
Definition at line 68 of file sig_ss7.h.
Referenced by process_dahdi(), and ss7_start_call().
| #define LINKSTATE_DOWN (1 << 3) |
Definition at line 64 of file sig_ss7.h.
Referenced by sig_ss7_add_sigchan(), sig_ss7_link_alarm(), and sig_ss7_link_noalarm().
| #define LINKSTATE_INALARM (1 << 0) |
Definition at line 61 of file sig_ss7.h.
Referenced by sig_ss7_add_sigchan(), sig_ss7_link_alarm(), and sig_ss7_link_noalarm().
| #define LINKSTATE_STARTING (1 << 1) |
Definition at line 62 of file sig_ss7.h.
Referenced by sig_ss7_link_noalarm().
| #define LINKSTATE_UP (1 << 2) |
Definition at line 63 of file sig_ss7.h.
Referenced by sig_ss7_link_alarm().
| #define SIG_SS7_DEBUG (SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP) |
SS7 debug message flags when SS7 debugging is turned on at the command line.
Definition at line 43 of file sig_ss7.h.
Referenced by handle_ss7_debug().
| #define SIG_SS7_DEBUG_DEFAULT 0 |
SS7 debug message flags set on initial startup.
Definition at line 51 of file sig_ss7.h.
Referenced by ss7_linkset().
| #define SIG_SS7_MAX_CHANNELS 672 |
| #define SIG_SS7_NUM_DCHANS 4 |
No more than 4 d-channels
Definition at line 56 of file sig_ss7.h.
Referenced by __unload_module(), dahdi_restart(), and linkset_addsigchan().
| #define SS7_NAI_DYNAMIC -1 |
Definition at line 66 of file sig_ss7.h.
Referenced by process_dahdi(), and sig_ss7_call().
| enum sig_ss7_call_level |
Call establishment life cycle level for simple comparisons.
Definition at line 88 of file sig_ss7.h.
{
/*! Call does not exist. */
SIG_SS7_CALL_LEVEL_IDLE,
/*!
* Call is allocated to the channel.
* We have not sent or responded to IAM yet.
*/
SIG_SS7_CALL_LEVEL_ALLOCATED,
/*!
* Call is performing continuity check after receiving IAM.
* We are waiting for COT to proceed further.
*/
SIG_SS7_CALL_LEVEL_CONTINUITY,
/*!
* Call is present.
* We have not seen a response or sent further call progress to an IAM yet.
*/
SIG_SS7_CALL_LEVEL_SETUP,
/*!
* Call routing is happening.
* We have sent or received ACM.
*/
SIG_SS7_CALL_LEVEL_PROCEEDING,
/*!
* Called party is being alerted of the call.
* We have sent or received CPG(ALERTING)/ACM(ALERTING).
*/
SIG_SS7_CALL_LEVEL_ALERTING,
/*!
* Call is connected/answered.
* We have sent or received CON/ANM.
*/
SIG_SS7_CALL_LEVEL_CONNECT,
/*! Call has collided with incoming call. */
SIG_SS7_CALL_LEVEL_GLARE,
};
| enum sig_ss7_law |
Definition at line 81 of file sig_ss7.h.
{
SIG_SS7_DEFLAW = 0,
SIG_SS7_ULAW,
SIG_SS7_ALAW
};
| enum sig_ss7_tone |
| int sig_ss7_add_sigchan | ( | struct sig_ss7_linkset * | linkset, |
| int | which, | ||
| int | ss7type, | ||
| int | transport, | ||
| int | inalarm, | ||
| int | networkindicator, | ||
| int | pointcode, | ||
| int | adjpointcode | ||
| ) |
Setup and add a SS7 link channel.
| linkset | Controlling linkset for the channel. |
| which | Link index of the signaling channel. |
| ss7type | Switch type of the linkset |
| transport | Signaling transport of channel. |
| inalarm | Non-zero if the channel is in alarm. |
| networkindicator | User configuration parameter. |
| pointcode | User configuration parameter. |
| adjpointcode | User configuration parameter. |
| 0 | on success. |
| -1 | on error. |
Definition at line 1302 of file sig_ss7.c.
References ast_log(), sig_ss7_linkset::fds, sig_ss7_linkset::linkstate, LINKSTATE_DOWN, LINKSTATE_INALARM, LOG_ERROR, LOG_WARNING, sig_ss7_linkset::ss7, and sig_ss7_linkset::type.
Referenced by linkset_addsigchan().
{
if (!linkset->ss7) {
linkset->type = ss7type;
linkset->ss7 = ss7_new(ss7type);
if (!linkset->ss7) {
ast_log(LOG_ERROR, "Can't create new SS7!\n");
return -1;
}
}
ss7_set_network_ind(linkset->ss7, networkindicator);
ss7_set_pc(linkset->ss7, pointcode);
if (ss7_add_link(linkset->ss7, transport, linkset->fds[which])) {
ast_log(LOG_WARNING, "Could not add SS7 link!\n");
}
if (inalarm) {
linkset->linkstate[which] = LINKSTATE_DOWN | LINKSTATE_INALARM;
ss7_link_alarm(linkset->ss7, linkset->fds[which]);
} else {
linkset->linkstate[which] = LINKSTATE_DOWN;
ss7_link_noalarm(linkset->ss7, linkset->fds[which]);
}
ss7_set_adjpc(linkset->ss7, linkset->fds[which], adjpointcode);
return 0;
}
| int sig_ss7_answer | ( | struct sig_ss7_chan * | p, |
| struct ast_channel * | ast | ||
| ) |
SS7 answer channel.
| p | Signaling private structure pointer. |
| ast | Asterisk channel structure pointer. |
| 0 | on success. |
| -1 | on error. |
Definition at line 1599 of file sig_ss7.c.
References sig_ss7_chan::call_level, SIG_SS7_CALL_LEVEL_CONNECT, sig_ss7_chan::ss7, sig_ss7_linkset::ss7, ss7_grab(), ss7_rel(), and sig_ss7_chan::ss7call.
Referenced by dahdi_answer().
{
int res;
ss7_grab(p, p->ss7);
if (p->call_level < SIG_SS7_CALL_LEVEL_CONNECT) {
p->call_level = SIG_SS7_CALL_LEVEL_CONNECT;
}
res = isup_anm(p->ss7->ss7, p->ss7call);
ss7_rel(p->ss7);
return res;
}
| int sig_ss7_available | ( | struct sig_ss7_chan * | p | ) |
Determine if the specified channel is available for an outgoing call.
| p | Signaling private structure pointer. |
| TRUE | if the channel is available. |
Definition at line 1359 of file sig_ss7.c.
References ast_mutex_lock, ast_mutex_unlock, available(), sig_ss7_chan::call_level, sig_ss7_linkset::lock, SIG_SS7_CALL_LEVEL_ALLOCATED, sig_ss7_is_chan_available(), and sig_ss7_chan::ss7.
Referenced by available().
{
int available;
if (!p->ss7) {
/* Something is wrong here. A SS7 channel without the ss7 pointer? */
return 0;
}
/* Only have to deal with the linkset lock. */
ast_mutex_lock(&p->ss7->lock);
available = sig_ss7_is_chan_available(p);
if (available) {
p->call_level = SIG_SS7_CALL_LEVEL_ALLOCATED;
}
ast_mutex_unlock(&p->ss7->lock);
return available;
}
| int sig_ss7_call | ( | struct sig_ss7_chan * | p, |
| struct ast_channel * | ast, | ||
| char * | rdest | ||
| ) |
Dial out using the specified SS7 channel.
| p | Signaling private structure pointer. |
| ast | Asterisk channel structure pointer. |
| rdest | Dialstring. |
| 0 | on success. |
| -1 | on error. |
Definition at line 1400 of file sig_ss7.c.
References ast_party_connected_line::ani2, ast_copy_string(), ast_log(), ast_setstate(), AST_STATE_DIALING, sig_ss7_chan::call_level, sig_ss7_linkset::called_nai, sig_ss7_linkset::calling_nai, sig_ss7_chan::cic, cid_pres2ss7pres(), cid_pres2ss7screen(), ast_channel::connected, sig_ss7_chan::dpc, sig_ss7_chan::gen_add_nai, sig_ss7_chan::gen_add_num_plan, sig_ss7_chan::gen_add_pres_ind, sig_ss7_chan::gen_add_type, sig_ss7_chan::hidecallerid, ast_party_connected_line::id, sig_ss7_linkset::internationalprefix, LOG_ERROR, LOG_WARNING, sig_ss7_linkset::nationalprefix, ast_party_id::number, pbx_builtin_getvar_helper(), ast_party_number::presentation, SIG_SS7_CALL_LEVEL_ALLOCATED, SIG_SS7_CALL_LEVEL_SETUP, sig_ss7_set_dialing(), sig_ss7_chan::ss7, sig_ss7_linkset::ss7, ss7_grab(), SS7_NAI_DYNAMIC, ss7_rel(), sig_ss7_chan::ss7call, ast_party_number::str, sig_ss7_chan::stripmsd, sig_ss7_chan::use_callingpres, and ast_party_number::valid.
Referenced by dahdi_call().
{
char ss7_called_nai;
int called_nai_strip;
char ss7_calling_nai;
int calling_nai_strip;
const char *charge_str = NULL;
const char *gen_address = NULL;
const char *gen_digits = NULL;
const char *gen_dig_type = NULL;
const char *gen_dig_scheme = NULL;
const char *gen_name = NULL;
const char *jip_digits = NULL;
const char *lspi_ident = NULL;
const char *rlt_flag = NULL;
const char *call_ref_id = NULL;
const char *call_ref_pc = NULL;
const char *send_far = NULL;
char *c;
char *l;
char dest[256];
ast_copy_string(dest, rdest, sizeof(dest));
c = strchr(dest, '/');
if (c) {
c++;
} else {
c = "";
}
if (strlen(c) < p->stripmsd) {
ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
return -1;
}
if (!p->hidecallerid) {
l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
} else {
l = NULL;
}
ss7_grab(p, p->ss7);
if (p->call_level != SIG_SS7_CALL_LEVEL_ALLOCATED) {
/* Call collision before sending IAM. Abort call. */
ss7_rel(p->ss7);
return -1;
}
p->ss7call = isup_new_call(p->ss7->ss7);
if (!p->ss7call) {
ss7_rel(p->ss7);
ast_log(LOG_ERROR, "Unable to allocate new SS7 call!\n");
return -1;
}
called_nai_strip = 0;
ss7_called_nai = p->ss7->called_nai;
if (ss7_called_nai == SS7_NAI_DYNAMIC) { /* compute dynamically */
if (strncmp(c + p->stripmsd, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
called_nai_strip = strlen(p->ss7->internationalprefix);
ss7_called_nai = SS7_NAI_INTERNATIONAL;
} else if (strncmp(c + p->stripmsd, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
called_nai_strip = strlen(p->ss7->nationalprefix);
ss7_called_nai = SS7_NAI_NATIONAL;
} else {
ss7_called_nai = SS7_NAI_SUBSCRIBER;
}
}
isup_set_called(p->ss7call, c + p->stripmsd + called_nai_strip, ss7_called_nai, p->ss7->ss7);
calling_nai_strip = 0;
ss7_calling_nai = p->ss7->calling_nai;
if ((l != NULL) && (ss7_calling_nai == SS7_NAI_DYNAMIC)) { /* compute dynamically */
if (strncmp(l, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
calling_nai_strip = strlen(p->ss7->internationalprefix);
ss7_calling_nai = SS7_NAI_INTERNATIONAL;
} else if (strncmp(l, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
calling_nai_strip = strlen(p->ss7->nationalprefix);
ss7_calling_nai = SS7_NAI_NATIONAL;
} else {
ss7_calling_nai = SS7_NAI_SUBSCRIBER;
}
}
isup_set_calling(p->ss7call, l ? (l + calling_nai_strip) : NULL, ss7_calling_nai,
p->use_callingpres ? cid_pres2ss7pres(ast->connected.id.number.presentation) : (l ? SS7_PRESENTATION_ALLOWED : SS7_PRESENTATION_RESTRICTED),
p->use_callingpres ? cid_pres2ss7screen(ast->connected.id.number.presentation) : SS7_SCREENING_USER_PROVIDED);
isup_set_oli(p->ss7call, ast->connected.ani2);
isup_init_call(p->ss7->ss7, p->ss7call, p->cic, p->dpc);
/* Set the charge number if it is set */
charge_str = pbx_builtin_getvar_helper(ast, "SS7_CHARGE_NUMBER");
if (charge_str)
isup_set_charge(p->ss7call, charge_str, SS7_ANI_CALLING_PARTY_SUB_NUMBER, 0x10);
gen_address = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_ADDRESS");
if (gen_address)
isup_set_gen_address(p->ss7call, gen_address, p->gen_add_nai,p->gen_add_pres_ind, p->gen_add_num_plan,p->gen_add_type); /* need to add some types here for NAI,PRES,TYPE */
gen_digits = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGITS");
gen_dig_type = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGTYPE");
gen_dig_scheme = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGSCHEME");
if (gen_digits)
isup_set_gen_digits(p->ss7call, gen_digits, atoi(gen_dig_type), atoi(gen_dig_scheme));
gen_name = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_NAME");
if (gen_name)
isup_set_generic_name(p->ss7call, gen_name, GEN_NAME_TYPE_CALLING_NAME, GEN_NAME_AVAIL_AVAILABLE, GEN_NAME_PRES_ALLOWED);
jip_digits = pbx_builtin_getvar_helper(ast, "SS7_JIP");
if (jip_digits)
isup_set_jip_digits(p->ss7call, jip_digits);
lspi_ident = pbx_builtin_getvar_helper(ast, "SS7_LSPI_IDENT");
if (lspi_ident)
isup_set_lspi(p->ss7call, lspi_ident, 0x18, 0x7, 0x00);
rlt_flag = pbx_builtin_getvar_helper(ast, "SS7_RLT_ON");
if ((rlt_flag) && ((strncmp("NO", rlt_flag, strlen(rlt_flag))) != 0 )) {
isup_set_lspi(p->ss7call, rlt_flag, 0x18, 0x7, 0x00); /* Setting for Nortel DMS-250/500 */
}
call_ref_id = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_IDENT");
call_ref_pc = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_PC");
if (call_ref_id && call_ref_pc) {
isup_set_callref(p->ss7call, atoi(call_ref_id),
call_ref_pc ? atoi(call_ref_pc) : 0);
}
send_far = pbx_builtin_getvar_helper(ast, "SS7_SEND_FAR");
if ((send_far) && ((strncmp("NO", send_far, strlen(send_far))) != 0 ))
(isup_far(p->ss7->ss7, p->ss7call));
p->call_level = SIG_SS7_CALL_LEVEL_SETUP;
isup_iam(p->ss7->ss7, p->ss7call);
sig_ss7_set_dialing(p, 1);
ast_setstate(ast, AST_STATE_DIALING);
ss7_rel(p->ss7);
return 0;
}
| void sig_ss7_chan_delete | ( | struct sig_ss7_chan * | doomed | ) |
Delete the sig_ss7 private channel structure.
| doomed | sig_ss7 private channel structure to delete. |
Definition at line 1769 of file sig_ss7.c.
References ast_free.
Referenced by destroy_dahdi_pvt().
{
ast_free(doomed);
}
| struct sig_ss7_chan* sig_ss7_chan_new | ( | void * | pvt_data, |
| struct sig_ss7_callback * | callback, | ||
| struct sig_ss7_linkset * | ss7 | ||
| ) | [read] |
Create a new sig_ss7 private channel structure.
| pvt_data | Upper layer private data structure. |
| callback | Callbacks to the upper layer. |
| ss7 | Controlling linkset for the channel. |
| sig_ss7_chan | on success. |
| NULL | on error. |
Definition at line 1830 of file sig_ss7.c.
References ast_calloc, sig_ss7_chan::calls, sig_ss7_chan::chan_pvt, and sig_ss7_chan::ss7.
Referenced by mkintf().
{
struct sig_ss7_chan *pvt;
pvt = ast_calloc(1, sizeof(*pvt));
if (!pvt) {
return pvt;
}
pvt->calls = callback;
pvt->chan_pvt = pvt_data;
pvt->ss7 = ss7;
return pvt;
}
| void sig_ss7_cli_show_channels | ( | int | fd, |
| struct sig_ss7_linkset * | linkset | ||
| ) |
Definition at line 1782 of file sig_ss7.c.
References ast_channel_unlock, ast_cli(), ast_mutex_lock, ast_mutex_unlock, sig_ss7_chan::call_level, sig_ss7_chan::channel, sig_ss7_chan::locallyblocked, sig_ss7_linkset::lock, ast_channel::name, sig_ss7_linkset::numchans, sig_ss7_chan::owner, sig_ss7_linkset::pvts, sig_ss7_chan::remotelyblocked, sig_ss7_call_level2str(), sig_ss7_is_chan_available(), sig_ss7_lock_owner(), sig_ss7_lock_private(), SIG_SS7_SC_LINE, sig_ss7_unlock_private(), sig_ss7_linkset::span, and sig_ss7_chan::ss7call.
Referenced by handle_ss7_show_channels().
{
char line[256];
int idx;
struct sig_ss7_chan *pvt;
ast_mutex_lock(&linkset->lock);
for (idx = 0; idx < linkset->numchans; ++idx) {
if (!linkset->pvts[idx]) {
continue;
}
pvt = linkset->pvts[idx];
sig_ss7_lock_private(pvt);
sig_ss7_lock_owner(linkset, idx);
snprintf(line, sizeof(line), SIG_SS7_SC_LINE,
linkset->span,
pvt->channel,
sig_ss7_is_chan_available(pvt) ? "Yes" : "No",
pvt->locallyblocked ? "Yes" : "No",
pvt->remotelyblocked ? "Yes" : "No",
sig_ss7_call_level2str(pvt->call_level),
pvt->ss7call ? "Yes" : "No",
pvt->owner ? pvt->owner->name : "");
if (pvt->owner) {
ast_channel_unlock(pvt->owner);
}
sig_ss7_unlock_private(pvt);
ast_mutex_unlock(&linkset->lock);
ast_cli(fd, "%s\n", line);
ast_mutex_lock(&linkset->lock);
}
ast_mutex_unlock(&linkset->lock);
}
| void sig_ss7_cli_show_channels_header | ( | int | fd | ) |
Definition at line 1776 of file sig_ss7.c.
References ast_cli(), and SIG_SS7_SC_HEADER.
Referenced by handle_ss7_show_channels().
{
ast_cli(fd, SIG_SS7_SC_HEADER, "link", "", "Chan", "Lcl", "Rem", "Call", "SS7", "Channel");
ast_cli(fd, SIG_SS7_SC_HEADER, "set", "Chan", "Idle", "Blk", "Blk", "Level", "Call", "Name");
}
| void sig_ss7_fixup | ( | struct ast_channel * | oldchan, |
| struct ast_channel * | newchan, | ||
| struct sig_ss7_chan * | pchan | ||
| ) |
Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links.
| oldchan | Old channel pointer to replace. |
| newchan | New channel pointer to set. |
| pchan | Signaling private structure pointer. |
Definition at line 1622 of file sig_ss7.c.
References sig_ss7_chan::owner.
Referenced by dahdi_fixup().
| int sig_ss7_hangup | ( | struct sig_ss7_chan * | p, |
| struct ast_channel * | ast | ||
| ) |
SS7 hangup channel.
| p | Signaling private structure pointer. |
| ast | Asterisk channel structure pointer. |
| 0 | on success. |
| -1 | on error. |
Definition at line 1552 of file sig_ss7.c.
References sig_ss7_chan::alreadyhungup, ast_log(), sig_ss7_chan::call_level, cause, sig_ss7_chan::exten, ast_channel::hangupcause, LOG_WARNING, sig_ss7_chan::outgoing, sig_ss7_chan::owner, pbx_builtin_getvar_helper(), sig_ss7_chan::progress, sig_ss7_chan::rlt, SIG_SS7_CALL_LEVEL_IDLE, sig_ss7_set_dialing(), sig_ss7_chan::ss7, sig_ss7_linkset::ss7, ss7_grab(), ss7_rel(), sig_ss7_chan::ss7call, and ast_channel::tech_pvt.
Referenced by dahdi_hangup().
{
int res = 0;
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
}
p->owner = NULL;
sig_ss7_set_dialing(p, 0);
p->outgoing = 0;
p->progress = 0;
p->rlt = 0;
p->exten[0] = '\0';
/* Perform low level hangup if no owner left */
ss7_grab(p, p->ss7);
p->call_level = SIG_SS7_CALL_LEVEL_IDLE;
if (p->ss7call) {
if (!p->alreadyhungup) {
const char *cause = pbx_builtin_getvar_helper(ast,"SS7_CAUSE");
int icause = ast->hangupcause ? ast->hangupcause : -1;
if (cause) {
if (atoi(cause)) {
icause = atoi(cause);
}
}
isup_rel(p->ss7->ss7, p->ss7call, icause);
p->alreadyhungup = 1;
}
}
ss7_rel(p->ss7);
return res;
}
| int sig_ss7_indicate | ( | struct sig_ss7_chan * | p, |
| struct ast_channel * | chan, | ||
| int | condition, | ||
| const void * | data, | ||
| size_t | datalen | ||
| ) |
SS7 answer channel.
| p | Signaling private structure pointer. |
| chan | Asterisk channel structure pointer. |
| condition | AST control frame subtype. |
| data | AST control frame payload contents. |
| datalen | Length of payload contents. |
| 0 | on success. |
| -1 | on error or indication condition not handled. |
Definition at line 1642 of file sig_ss7.c.
References ast_channel::_state, AST_CAUSE_CONGESTION, AST_CAUSE_INVALID_NUMBER_FORMAT, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, ast_debug, ast_moh_start(), ast_moh_stop(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, sig_ss7_chan::call_level, ast_channel::hangupcause, sig_ss7_chan::mohinterpret, ast_channel::name, sig_ss7_chan::outgoing, sig_ss7_chan::progress, sig_ss7_chan::rlt, SIG_SS7_CALL_LEVEL_ALERTING, SIG_SS7_CALL_LEVEL_CONNECT, SIG_SS7_CALL_LEVEL_PROCEEDING, sig_ss7_play_tone(), sig_ss7_set_echocanceller(), SIG_SS7_TONE_BUSY, SIG_SS7_TONE_RINGTONE, sig_ss7_chan::ss7, sig_ss7_linkset::ss7, ss7_grab(), ss7_rel(), and sig_ss7_chan::ss7call.
Referenced by dahdi_indicate().
{
int res = -1;
switch (condition) {
case AST_CONTROL_BUSY:
res = sig_ss7_play_tone(p, SIG_SS7_TONE_BUSY);
break;
case AST_CONTROL_RINGING:
ss7_grab(p, p->ss7);
if (p->call_level < SIG_SS7_CALL_LEVEL_ALERTING && !p->outgoing) {
p->call_level = SIG_SS7_CALL_LEVEL_ALERTING;
if ((isup_far(p->ss7->ss7, p->ss7call)) != -1) {
p->rlt = 1;
}
/* No need to send CPG if call will be RELEASE */
if (p->rlt != 1) {
isup_cpg(p->ss7->ss7, p->ss7call, CPG_EVENT_ALERTING);
}
}
ss7_rel(p->ss7);
res = sig_ss7_play_tone(p, SIG_SS7_TONE_RINGTONE);
if (chan->_state != AST_STATE_UP && chan->_state != AST_STATE_RING) {
ast_setstate(chan, AST_STATE_RINGING);
}
break;
case AST_CONTROL_PROCEEDING:
ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
ss7_grab(p, p->ss7);
/* This IF sends the FAR for an answered ALEG call */
if (chan->_state == AST_STATE_UP && (p->rlt != 1)){
if ((isup_far(p->ss7->ss7, p->ss7call)) != -1) {
p->rlt = 1;
}
}
if (p->call_level < SIG_SS7_CALL_LEVEL_PROCEEDING && !p->outgoing) {
p->call_level = SIG_SS7_CALL_LEVEL_PROCEEDING;
isup_acm(p->ss7->ss7, p->ss7call);
}
ss7_rel(p->ss7);
/* don't continue in ast_indicate */
res = 0;
break;
case AST_CONTROL_PROGRESS:
ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
ss7_grab(p, p->ss7);
if (!p->progress && p->call_level < SIG_SS7_CALL_LEVEL_ALERTING && !p->outgoing) {
p->progress = 1;/* No need to send inband-information progress again. */
isup_cpg(p->ss7->ss7, p->ss7call, CPG_EVENT_INBANDINFO);
ss7_rel(p->ss7);
/* enable echo canceler here on SS7 calls */
sig_ss7_set_echocanceller(p, 1);
} else {
ss7_rel(p->ss7);
}
/* don't continue in ast_indicate */
res = 0;
break;
case AST_CONTROL_INCOMPLETE:
/* If the channel is connected, wait for additional input */
if (p->call_level == SIG_SS7_CALL_LEVEL_CONNECT) {
res = 0;
break;
}
chan->hangupcause = AST_CAUSE_INVALID_NUMBER_FORMAT;
break;
case AST_CONTROL_CONGESTION:
chan->hangupcause = AST_CAUSE_CONGESTION;
break;
case AST_CONTROL_HOLD:
ast_moh_start(chan, data, p->mohinterpret);
break;
case AST_CONTROL_UNHOLD:
ast_moh_stop(chan);
break;
case AST_CONTROL_SRCUPDATE:
res = 0;
break;
case -1:
res = sig_ss7_play_tone(p, -1);
break;
}
return res;
}
| void sig_ss7_init_linkset | ( | struct sig_ss7_linkset * | ss7 | ) |
Initialize the SS7 linkset control.
| ss7 | SS7 linkset control structure. |
Definition at line 1854 of file sig_ss7.c.
References ARRAY_LEN, ast_mutex_init, AST_PTHREADT_NULL, sig_ss7_linkset::fds, sig_ss7_linkset::lock, and sig_ss7_linkset::master.
Referenced by dahdi_restart(), and load_module().
{
int idx;
memset(ss7, 0, sizeof(*ss7));
ast_mutex_init(&ss7->lock);
ss7->master = AST_PTHREADT_NULL;
for (idx = 0; idx < ARRAY_LEN(ss7->fds); ++idx) {
ss7->fds[idx] = -1;
}
}
| void sig_ss7_link_alarm | ( | struct sig_ss7_linkset * | linkset, |
| int | which | ||
| ) |
Notify the SS7 layer that the link is in alarm.
| linkset | Controlling linkset for the channel. |
| which | Link index of the signaling channel. |
Definition at line 1263 of file sig_ss7.c.
References sig_ss7_linkset::fds, sig_ss7_linkset::linkstate, LINKSTATE_DOWN, LINKSTATE_INALARM, LINKSTATE_UP, and sig_ss7_linkset::ss7.
Referenced by my_handle_link_exception().
{
linkset->linkstate[which] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
linkset->linkstate[which] &= ~LINKSTATE_UP;
ss7_link_alarm(linkset->ss7, linkset->fds[which]);
}
| void sig_ss7_link_noalarm | ( | struct sig_ss7_linkset * | linkset, |
| int | which | ||
| ) |
Notify the SS7 layer that the link is no longer in alarm.
| linkset | Controlling linkset for the channel. |
| which | Link index of the signaling channel. |
Definition at line 1279 of file sig_ss7.c.
References sig_ss7_linkset::fds, sig_ss7_linkset::linkstate, LINKSTATE_DOWN, LINKSTATE_INALARM, LINKSTATE_STARTING, and sig_ss7_linkset::ss7.
Referenced by my_handle_link_exception().
{
linkset->linkstate[which] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
linkset->linkstate[which] |= LINKSTATE_STARTING;
ss7_link_noalarm(linkset->ss7, linkset->fds[which]);
}
| struct ast_channel* sig_ss7_request | ( | struct sig_ss7_chan * | p, |
| enum sig_ss7_law | law, | ||
| const struct ast_channel * | requestor, | ||
| int | transfercapability | ||
| ) | [read] |
SS7 channel request.
| p | Signaling private structure pointer. |
| law | Companding law preferred |
| requestor | Asterisk channel requesting a channel to dial (Can be NULL) |
| transfercapability |
| ast_channel | on success. |
| NULL | on error. |
Definition at line 1744 of file sig_ss7.c.
References ast_mutex_lock, ast_mutex_unlock, AST_STATE_RESERVED, sig_ss7_chan::call_level, sig_ss7_chan::exten, sig_ss7_linkset::lock, sig_ss7_chan::outgoing, SIG_SS7_CALL_LEVEL_IDLE, sig_ss7_new_ast_channel(), and sig_ss7_chan::ss7.
Referenced by dahdi_request().
{
struct ast_channel *ast;
p->outgoing = 1;
ast = sig_ss7_new_ast_channel(p, AST_STATE_RESERVED, law, transfercapability, p->exten, requestor);
if (!ast) {
p->outgoing = 0;
/* Release the allocated channel. Only have to deal with the linkset lock. */
ast_mutex_lock(&p->ss7->lock);
p->call_level = SIG_SS7_CALL_LEVEL_IDLE;
ast_mutex_unlock(&p->ss7->lock);
}
return ast;
}
| void sig_ss7_set_alarm | ( | struct sig_ss7_chan * | p, |
| int | in_alarm | ||
| ) |
Definition at line 91 of file sig_ss7.c.
References sig_ss7_chan::calls, sig_ss7_chan::chan_pvt, sig_ss7_chan::inalarm, and sig_ss7_callback::set_alarm.
Referenced by dahdi_handle_event(), handle_init_event(), mkintf(), and ss7_linkset().
| void* ss7_linkset | ( | void * | data | ) |
Definition at line 661 of file sig_ss7.c.
References sig_ss7_chan::alreadyhungup, ast_assert, AST_CAUSE_NORMAL_CLEARING, AST_CAUSE_UNALLOCATED, ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, ast_copy_string(), ast_debug, ast_dsp_set_features(), ast_exists_extension(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_setstate(), AST_SOFTHANGUP_DEV, ast_softhangup_nolock(), AST_STATE_RINGING, ast_strlen_zero(), ast_tvnow(), ast_verbose(), sig_ss7_chan::call_level, sig_ss7_linkset::called_nai, sig_ss7_linkset::calling_nai, sig_ss7_chan::calling_party_cat, sig_ss7_chan::callingpres, sig_ss7_chan::charge_number, sig_ss7_chan::cic, sig_ss7_chan::cid_ani, sig_ss7_chan::cid_ani2, sig_ss7_chan::cid_name, sig_ss7_chan::cid_num, sig_ss7_chan::cid_ton, sig_ss7_chan::context, sig_ss7_linkset::debug, sig_ss7_chan::dpc, errno, sig_ss7_chan::exten, sig_ss7_linkset::fds, sig_ss7_chan::gen_add_nai, sig_ss7_chan::gen_add_num_plan, sig_ss7_chan::gen_add_number, sig_ss7_chan::gen_add_pres_ind, sig_ss7_chan::gen_add_type, sig_ss7_chan::gen_dig_number, sig_ss7_chan::gen_dig_scheme, sig_ss7_chan::gen_dig_type, sig_ss7_chan::generic_name, ast_channel::hangupcause, sig_ss7_chan::immediate, sig_ss7_chan::jip_number, sig_ss7_linkset::lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, sig_ss7_chan::loopedback, sig_ss7_linkset::numchans, sig_ss7_linkset::numsigchans, sig_ss7_chan::orig_called_num, sig_ss7_chan::owner, sig_ss7_chan::progress, sig_ss7_linkset::pvts, sig_ss7_chan::redirecting_num, sig_ss7_chan::rlt, SIG_SS7_CALL_LEVEL_ALERTING, SIG_SS7_CALL_LEVEL_ALLOCATED, SIG_SS7_CALL_LEVEL_CONNECT, SIG_SS7_CALL_LEVEL_CONTINUITY, SIG_SS7_CALL_LEVEL_GLARE, SIG_SS7_CALL_LEVEL_IDLE, SIG_SS7_CALL_LEVEL_PROCEEDING, SIG_SS7_DEBUG_DEFAULT, sig_ss7_handle_link_exception(), sig_ss7_lock_owner(), sig_ss7_lock_private(), sig_ss7_loopback(), sig_ss7_queue_control(), sig_ss7_set_alarm(), sig_ss7_set_caller_id(), sig_ss7_set_dialing(), sig_ss7_set_dnid(), sig_ss7_set_echocanceller(), sig_ss7_set_inservice(), sig_ss7_set_locallyblocked(), sig_ss7_set_remotelyblocked(), sig_ss7_unlock_private(), sig_ss7_linkset::span, sig_ss7_linkset::ss7, ss7_apply_plan_to_number(), ss7_block_cics(), ss7_find_cic_gripe(), ss7_handle_cqm(), ss7_hangup_cics(), ss7_inservice(), ss7_pres_scr2cid_pres(), ss7_reset_linkset(), ss7_start_call(), sig_ss7_chan::ss7call, sig_ss7_linkset::state, tv, and sig_ss7_chan::use_callerid.
Referenced by setup_dahdi_int().
{
int res, i;
struct timeval *next = NULL, tv;
struct sig_ss7_linkset *linkset = (struct sig_ss7_linkset *) data;
struct ss7 *ss7 = linkset->ss7;
ss7_event *e = NULL;
struct sig_ss7_chan *p;
int chanpos;
struct pollfd pollers[SIG_SS7_NUM_DCHANS];
int nextms = 0;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
ss7_set_debug(ss7, SIG_SS7_DEBUG_DEFAULT);
ast_mutex_lock(&linkset->lock);
ss7_start(ss7);
ast_mutex_unlock(&linkset->lock);
for (;;) {
ast_mutex_lock(&linkset->lock);
if ((next = ss7_schedule_next(ss7))) {
tv = ast_tvnow();
tv.tv_sec = next->tv_sec - tv.tv_sec;
tv.tv_usec = next->tv_usec - tv.tv_usec;
if (tv.tv_usec < 0) {
tv.tv_usec += 1000000;
tv.tv_sec -= 1;
}
if (tv.tv_sec < 0) {
tv.tv_sec = 0;
tv.tv_usec = 0;
}
nextms = tv.tv_sec * 1000;
nextms += tv.tv_usec / 1000;
}
for (i = 0; i < linkset->numsigchans; i++) {
pollers[i].fd = linkset->fds[i];
pollers[i].events = ss7_pollflags(ss7, linkset->fds[i]);
pollers[i].revents = 0;
}
ast_mutex_unlock(&linkset->lock);
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
pthread_testcancel();
res = poll(pollers, linkset->numsigchans, nextms);
pthread_testcancel();
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
if ((res < 0) && (errno != EINTR)) {
ast_log(LOG_ERROR, "poll(%s)\n", strerror(errno));
} else if (!res) {
ast_mutex_lock(&linkset->lock);
ss7_schedule_run(ss7);
ast_mutex_unlock(&linkset->lock);
continue;
}
ast_mutex_lock(&linkset->lock);
for (i = 0; i < linkset->numsigchans; i++) {
if (pollers[i].revents & POLLPRI) {
sig_ss7_handle_link_exception(linkset, i);
}
if (pollers[i].revents & POLLIN) {
res = ss7_read(ss7, pollers[i].fd);
}
if (pollers[i].revents & POLLOUT) {
res = ss7_write(ss7, pollers[i].fd);
if (res < 0) {
ast_debug(1, "Error in write %s\n", strerror(errno));
}
}
}
while ((e = ss7_check_event(ss7))) {
if (linkset->debug) {
ast_verbose("Linkset %d: Processing event: %s\n",
linkset->span, ss7_event2str(e->e));
}
switch (e->e) {
case SS7_EVENT_UP:
if (linkset->state != LINKSET_STATE_UP) {
ast_verbose("--- SS7 Up ---\n");
ss7_reset_linkset(linkset);
}
linkset->state = LINKSET_STATE_UP;
break;
case SS7_EVENT_DOWN:
ast_verbose("--- SS7 Down ---\n");
linkset->state = LINKSET_STATE_DOWN;
for (i = 0; i < linkset->numchans; i++) {
p = linkset->pvts[i];
if (p) {
sig_ss7_set_alarm(p, 1);
}
}
break;
case MTP2_LINK_UP:
ast_verbose("MTP2 link up (SLC %d)\n", e->gen.data);
break;
case MTP2_LINK_DOWN:
ast_log(LOG_WARNING, "MTP2 link down (SLC %d)\n", e->gen.data);
break;
case ISUP_EVENT_CPG:
chanpos = ss7_find_cic_gripe(linkset, e->cpg.cic, e->cpg.opc, "CPG");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
switch (e->cpg.event) {
case CPG_EVENT_ALERTING:
if (p->call_level < SIG_SS7_CALL_LEVEL_ALERTING) {
p->call_level = SIG_SS7_CALL_LEVEL_ALERTING;
}
sig_ss7_lock_owner(linkset, chanpos);
if (p->owner) {
ast_setstate(p->owner, AST_STATE_RINGING);
ast_channel_unlock(p->owner);
}
sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
break;
case CPG_EVENT_PROGRESS:
case CPG_EVENT_INBANDINFO:
{
ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROGRESS);
p->progress = 1;
sig_ss7_set_dialing(p, 0);
#if 0 /* This code no longer seems to be necessary so I did not convert it. */
if (p->dsp && p->dsp_features) {
ast_dsp_set_features(p->dsp, p->dsp_features);
p->dsp_features = 0;
}
#endif
}
break;
default:
ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
break;
}
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_RSC:
ast_verbose("Resetting CIC %d\n", e->rsc.cic);
chanpos = ss7_find_cic_gripe(linkset, e->rsc.cic, e->rsc.opc, "RSC");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_set_inservice(p, 1);
sig_ss7_set_remotelyblocked(p, 0);
isup_set_call_dpc(e->rsc.call, p->dpc);
sig_ss7_lock_owner(linkset, chanpos);
p->ss7call = NULL;
if (p->owner) {
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
}
sig_ss7_unlock_private(p);
isup_rlc(ss7, e->rsc.call);
break;
case ISUP_EVENT_GRS:
ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
chanpos = ss7_find_cic_gripe(linkset, e->grs.startcic, e->grs.opc, "GRS");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
isup_gra(ss7, e->grs.startcic, e->grs.endcic, e->grs.opc);
ss7_block_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc, NULL, 0);
ss7_hangup_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc);
break;
case ISUP_EVENT_CQM:
ast_debug(1, "Got Circuit group query message from CICs %d to %d\n", e->cqm.startcic, e->cqm.endcic);
ss7_handle_cqm(linkset, e->cqm.startcic, e->cqm.endcic, e->cqm.opc);
break;
case ISUP_EVENT_GRA:
ast_verbose("Got reset acknowledgement from CIC %d to %d.\n", e->gra.startcic, e->gra.endcic);
ss7_inservice(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc);
ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc, e->gra.status, 1);
break;
case ISUP_EVENT_IAM:
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);
chanpos = ss7_find_cic_gripe(linkset, e->iam.cic, e->iam.opc, "IAM");
if (chanpos < 0) {
isup_rel(ss7, e->iam.call, -1);
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_lock_owner(linkset, chanpos);
if (p->call_level != SIG_SS7_CALL_LEVEL_IDLE) {
/*
* Detected glare/dual-seizure
*
* Always abort both calls since we can't implement the dual
* seizure procedures due to our channel assignment architecture
* and the fact that we cannot tell libss7 to discard its call
* structure to ignore the incoming IAM.
*/
ast_debug(1,
"Linkset %d: SS7 IAM glare on CIC/DPC %d/%d. Dropping both calls.\n",
linkset->span, e->iam.cic, e->iam.opc);
if (p->call_level == SIG_SS7_CALL_LEVEL_ALLOCATED) {
/*
* We have not sent our IAM yet and we never will at this point.
*/
p->alreadyhungup = 1;
isup_rel(ss7, e->iam.call, -1);
}
p->call_level = SIG_SS7_CALL_LEVEL_GLARE;
if (p->owner) {
p->owner->hangupcause = AST_CAUSE_NORMAL_CLEARING;
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
}
sig_ss7_unlock_private(p);
break;
}
/*
* The channel should not have an owner at this point since we
* are in the process of creating an owner for it.
*/
ast_assert(!p->owner);
/* Mark channel as in use so no outgoing call will steal it. */
p->call_level = SIG_SS7_CALL_LEVEL_ALLOCATED;
p->ss7call = e->iam.call;
isup_set_call_dpc(p->ss7call, p->dpc);
if ((p->use_callerid) && (!ast_strlen_zero(e->iam.calling_party_num))) {
ss7_apply_plan_to_number(p->cid_num, sizeof(p->cid_num), linkset, e->iam.calling_party_num, e->iam.calling_nai);
p->callingpres = ss7_pres_scr2cid_pres(e->iam.presentation_ind, e->iam.screening_ind);
} else
p->cid_num[0] = 0;
/* Set DNID */
if (!ast_strlen_zero(e->iam.called_party_num)) {
ss7_apply_plan_to_number(p->exten, sizeof(p->exten), linkset,
e->iam.called_party_num, e->iam.called_nai);
} else {
p->exten[0] = '\0';
}
sig_ss7_set_dnid(p, p->exten);
if (p->immediate) {
p->exten[0] = 's';
p->exten[1] = '\0';
} else if (!ast_strlen_zero(e->iam.called_party_num)) {
char *st;
ss7_apply_plan_to_number(p->exten, sizeof(p->exten), linkset, e->iam.called_party_num, e->iam.called_nai);
st = strchr(p->exten, '#');
if (st) {
*st = '\0';
}
} else {
p->exten[0] = '\0';
}
p->cid_ani[0] = '\0';
if ((p->use_callerid) && (!ast_strlen_zero(e->iam.generic_name)))
ast_copy_string(p->cid_name, e->iam.generic_name, sizeof(p->cid_name));
else
p->cid_name[0] = '\0';
p->cid_ani2 = e->iam.oli_ani2;
p->cid_ton = 0;
ast_copy_string(p->charge_number, e->iam.charge_number, sizeof(p->charge_number));
ast_copy_string(p->gen_add_number, e->iam.gen_add_number, sizeof(p->gen_add_number));
p->gen_add_type = e->iam.gen_add_type;
p->gen_add_nai = e->iam.gen_add_nai;
p->gen_add_pres_ind = e->iam.gen_add_pres_ind;
p->gen_add_num_plan = e->iam.gen_add_num_plan;
ast_copy_string(p->gen_dig_number, e->iam.gen_dig_number, sizeof(p->gen_dig_number));
p->gen_dig_type = e->iam.gen_dig_type;
p->gen_dig_scheme = e->iam.gen_dig_scheme;
ast_copy_string(p->jip_number, e->iam.jip_number, sizeof(p->jip_number));
ast_copy_string(p->orig_called_num, e->iam.orig_called_num, sizeof(p->orig_called_num));
ast_copy_string(p->redirecting_num, e->iam.redirecting_num, sizeof(p->redirecting_num));
ast_copy_string(p->generic_name, e->iam.generic_name, sizeof(p->generic_name));
p->calling_party_cat = e->iam.calling_party_cat;
sig_ss7_set_caller_id(p);
if (ast_exists_extension(NULL, p->context, p->exten, 1, p->cid_num)) {
if (e->iam.cot_check_required) {
p->call_level = SIG_SS7_CALL_LEVEL_CONTINUITY;
sig_ss7_loopback(p, 1);
} else {
ss7_start_call(p, linkset);
}
} else {
ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
p->alreadyhungup = 1;
isup_rel(ss7, e->iam.call, AST_CAUSE_UNALLOCATED);
}
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_COT:
chanpos = ss7_find_cic_gripe(linkset, e->cot.cic, e->cot.opc, "COT");
if (chanpos < 0) {
isup_rel(ss7, e->cot.call, -1);
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
if (p->loopedback) {
sig_ss7_loopback(p, 0);
ss7_start_call(p, linkset);
}
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_CCR:
ast_debug(1, "Got CCR request on CIC %d\n", e->ccr.cic);
chanpos = ss7_find_cic_gripe(linkset, e->ccr.cic, e->ccr.opc, "CCR");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_loopback(p, 1);
sig_ss7_unlock_private(p);
isup_lpa(linkset->ss7, e->ccr.cic, p->dpc);
break;
case ISUP_EVENT_CVT:
ast_debug(1, "Got CVT request on CIC %d\n", e->cvt.cic);
chanpos = ss7_find_cic_gripe(linkset, e->cvt.cic, e->cvt.opc, "CVT");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_loopback(p, 1);
sig_ss7_unlock_private(p);
isup_cvr(linkset->ss7, e->cvt.cic, p->dpc);
break;
case ISUP_EVENT_REL:
chanpos = ss7_find_cic_gripe(linkset, e->rel.cic, e->rel.opc, "REL");
if (chanpos < 0) {
/* Continue hanging up the call anyway. */
isup_rlc(ss7, e->rel.call);
break;
}
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_lock_owner(linkset, chanpos);
if (p->owner) {
p->owner->hangupcause = e->rel.cause;
ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
ast_channel_unlock(p->owner);
}
/* End the loopback if we have one */
sig_ss7_loopback(p, 0);
isup_rlc(ss7, e->rel.call);
p->ss7call = NULL;
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_ACM:
chanpos = ss7_find_cic_gripe(linkset, e->acm.cic, e->acm.opc, "ACM");
if (chanpos < 0) {
isup_rel(ss7, e->acm.call, -1);
break;
}
{
p = linkset->pvts[chanpos];
ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
if (e->acm.call_ref_ident > 0) {
p->rlt = 1; /* Setting it but not using it here*/
}
sig_ss7_lock_private(p);
sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROCEEDING);
if (p->call_level < SIG_SS7_CALL_LEVEL_PROCEEDING) {
p->call_level = SIG_SS7_CALL_LEVEL_PROCEEDING;
}
sig_ss7_set_dialing(p, 0);
/* Send alerting if subscriber is free */
if (e->acm.called_party_status_ind == 1) {
if (p->call_level < SIG_SS7_CALL_LEVEL_ALERTING) {
p->call_level = SIG_SS7_CALL_LEVEL_ALERTING;
}
sig_ss7_lock_owner(linkset, chanpos);
if (p->owner) {
ast_setstate(p->owner, AST_STATE_RINGING);
ast_channel_unlock(p->owner);
}
sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
}
sig_ss7_unlock_private(p);
}
break;
case ISUP_EVENT_CGB:
chanpos = ss7_find_cic_gripe(linkset, e->cgb.startcic, e->cgb.opc, "CGB");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ss7_block_cics(linkset, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, 1);
isup_cgba(linkset->ss7, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, e->cgb.type);
break;
case ISUP_EVENT_CGU:
chanpos = ss7_find_cic_gripe(linkset, e->cgu.startcic, e->cgu.opc, "CGU");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ss7_block_cics(linkset, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, 0);
isup_cgua(linkset->ss7, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, e->cgu.type);
break;
case ISUP_EVENT_UCIC:
chanpos = ss7_find_cic_gripe(linkset, e->ucic.cic, e->ucic.opc, "UCIC");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ast_debug(1, "Unequiped Circuit Id Code on CIC %d\n", e->ucic.cic);
sig_ss7_lock_private(p);
sig_ss7_set_remotelyblocked(p, 1);
sig_ss7_set_inservice(p, 0);
sig_ss7_unlock_private(p);/* doesn't require a SS7 acknowledgement */
break;
case ISUP_EVENT_BLO:
chanpos = ss7_find_cic_gripe(linkset, e->blo.cic, e->blo.opc, "BLO");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
sig_ss7_lock_private(p);
sig_ss7_set_remotelyblocked(p, 1);
sig_ss7_unlock_private(p);
isup_bla(linkset->ss7, e->blo.cic, p->dpc);
break;
case ISUP_EVENT_BLA:
chanpos = ss7_find_cic_gripe(linkset, e->bla.cic, e->bla.opc, "BLA");
if (chanpos < 0) {
break;
}
ast_debug(1, "Blocking CIC %d\n", e->bla.cic);
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
sig_ss7_set_locallyblocked(p, 1);
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_UBL:
chanpos = ss7_find_cic_gripe(linkset, e->ubl.cic, e->ubl.opc, "UBL");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
sig_ss7_lock_private(p);
sig_ss7_set_remotelyblocked(p, 0);
sig_ss7_unlock_private(p);
isup_uba(linkset->ss7, e->ubl.cic, p->dpc);
break;
case ISUP_EVENT_UBA:
chanpos = ss7_find_cic_gripe(linkset, e->uba.cic, e->uba.opc, "UBA");
if (chanpos < 0) {
break;
}
p = linkset->pvts[chanpos];
ast_debug(1, "Unblocking CIC %d\n", e->uba.cic);
sig_ss7_lock_private(p);
sig_ss7_set_locallyblocked(p, 0);
sig_ss7_unlock_private(p);
break;
case ISUP_EVENT_CON:
case ISUP_EVENT_ANM:
if (e->e == ISUP_EVENT_CON) {
chanpos = ss7_find_cic_gripe(linkset, e->con.cic, e->con.opc, "CON");
if (chanpos < 0) {
isup_rel(ss7, e->con.call, -1);
break;
}
} else {
chanpos = ss7_find_cic_gripe(linkset, e->anm.cic, e->anm.opc, "ANM");
if (chanpos < 0) {
isup_rel(ss7, e->anm.call, -1);
break;
}
}
{
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
if (p->call_level < SIG_SS7_CALL_LEVEL_CONNECT) {
p->call_level = SIG_SS7_CALL_LEVEL_CONNECT;
}
sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_ANSWER);
#if 0 /* This code no longer seems to be necessary so I did not convert it. */
if (p->dsp && p->dsp_features) {
ast_dsp_set_features(p->dsp, p->dsp_features);
p->dsp_features = 0;
}
#endif
sig_ss7_set_echocanceller(p, 1);
sig_ss7_unlock_private(p);
}
break;
case ISUP_EVENT_RLC:
/* XXX Call ptr should be passed up from libss7! */
chanpos = ss7_find_cic_gripe(linkset, e->rlc.cic, e->rlc.opc, "RLC");
if (chanpos < 0) {
break;
}
{
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
if (p->alreadyhungup) {
if (!p->owner) {
p->call_level = SIG_SS7_CALL_LEVEL_IDLE;
}
p->ss7call = NULL;
}
sig_ss7_unlock_private(p);
}
break;
case ISUP_EVENT_FAA:
/*!
* \todo The handling of the SS7 FAA message is not good and I
* don't know enough to handle it correctly.
*/
chanpos = ss7_find_cic_gripe(linkset, e->faa.cic, e->faa.opc, "FAA");
if (chanpos < 0) {
isup_rel(linkset->ss7, e->faa.call, -1);
break;
}
{
/* XXX FAR and FAA used for something dealing with transfers? */
p = linkset->pvts[chanpos];
ast_debug(1, "FAA received on CIC %d\n", e->faa.cic);
sig_ss7_lock_private(p);
if (p->alreadyhungup){
if (!p->owner) {
p->call_level = SIG_SS7_CALL_LEVEL_IDLE;
}
/* XXX We seem to be leaking the isup call structure here. */
p->ss7call = NULL;
ast_log(LOG_NOTICE, "Received FAA and we haven't sent FAR. Ignoring.\n");
}
sig_ss7_unlock_private(p);
}
break;
default:
ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e));
break;
}
}
ast_mutex_unlock(&linkset->lock);
}
return 0;
}