Wed Apr 6 11:30:11 2011

Asterisk developer's documentation


sig_ss7.h File Reference

Interface header for SS7 signaling module. More...

#include "asterisk/channel.h"
#include <libss7.h>

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_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.
sig_ss7_chansig_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_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.
ast_channelsig_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)


Detailed Description

Interface header for SS7 signaling module.

Author:
Matthew Fredrickson <creslin@digium.com>

Richard Mudgett <rmudgett@digium.com>

See Also:

Definition in file sig_ss7.h.


Define Documentation

#define LINKSET_FLAG_EXPLICITACM   (1 << 0)

Definition at line 68 of file sig_ss7.h.

Referenced by 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   (0x1000000 | DAHDI_SIG_CLEAR)

Definition at line 59 of file sig_ss7.h.

#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

No more than a DS3 per trunk group

Definition at line 57 of file sig_ss7.h.

#define SIG_SS7_NUM_DCHANS   4

No more than 4 d-channels

Definition at line 56 of file sig_ss7.h.

#define SS7_NAI_DYNAMIC   -1

Definition at line 66 of file sig_ss7.h.

Referenced by sig_ss7_call().


Enumeration Type Documentation

enum sig_ss7_law

Enumerator:
SIG_SS7_DEFLAW 
SIG_SS7_ULAW 
SIG_SS7_ALAW 

Definition at line 81 of file sig_ss7.h.

00081                  {
00082    SIG_SS7_DEFLAW = 0,
00083    SIG_SS7_ULAW,
00084    SIG_SS7_ALAW
00085 };

enum sig_ss7_tone

Enumerator:
SIG_SS7_TONE_RINGTONE 
SIG_SS7_TONE_STUTTER 
SIG_SS7_TONE_CONGESTION 
SIG_SS7_TONE_DIALTONE 
SIG_SS7_TONE_DIALRECALL 
SIG_SS7_TONE_INFO 
SIG_SS7_TONE_BUSY 

Definition at line 71 of file sig_ss7.h.


Function Documentation

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.

Since:
1.8
Parameters:
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.
Return values:
0 on success.
-1 on error.

Definition at line 1158 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().

01159 {
01160    if (!linkset->ss7) {
01161       linkset->type = ss7type;
01162       linkset->ss7 = ss7_new(ss7type);
01163       if (!linkset->ss7) {
01164          ast_log(LOG_ERROR, "Can't create new SS7!\n");
01165          return -1;
01166       }
01167    }
01168 
01169    ss7_set_network_ind(linkset->ss7, networkindicator);
01170    ss7_set_pc(linkset->ss7, pointcode);
01171 
01172    if (ss7_add_link(linkset->ss7, transport, linkset->fds[which])) {
01173       ast_log(LOG_WARNING, "Could not add SS7 link!\n");
01174    }
01175 
01176    if (inalarm) {
01177       linkset->linkstate[which] = LINKSTATE_DOWN | LINKSTATE_INALARM;
01178       ss7_link_alarm(linkset->ss7, linkset->fds[which]);
01179    } else {
01180       linkset->linkstate[which] = LINKSTATE_DOWN;
01181       ss7_link_noalarm(linkset->ss7, linkset->fds[which]);
01182    }
01183 
01184    ss7_set_adjpc(linkset->ss7, linkset->fds[which], adjpointcode);
01185 
01186    return 0;
01187 }

int sig_ss7_answer ( struct sig_ss7_chan p,
struct ast_channel ast 
)

SS7 answer channel.

Since:
1.8
Parameters:
p Signaling private structure pointer.
ast Asterisk channel structure pointer.
Return values:
0 on success.
-1 on error.

Definition at line 1433 of file sig_ss7.c.

References ast_log(), LOG_WARNING, sig_ss7_chan::proceeding, sig_ss7_linkset::span, sig_ss7_linkset::ss7, sig_ss7_chan::ss7, ss7_grab(), ss7_rel(), and sig_ss7_chan::ss7call.

Referenced by dahdi_answer().

01434 {
01435    int res;
01436 
01437    if (!ss7_grab(p, p->ss7)) {
01438       p->proceeding = 1;
01439       res = isup_anm(p->ss7->ss7, p->ss7call);
01440       ss7_rel(p->ss7);
01441    } else {
01442       ast_log(LOG_WARNING, "Unable to grab SS7 on span %d\n", p->ss7->span);
01443       res = -1;
01444    }
01445    return res;
01446 }

int sig_ss7_available ( struct sig_ss7_chan p  ) 

Determine if the specified channel is available for an outgoing call.

Since:
1.8
Parameters:
p Signaling private structure pointer.
Return values:
TRUE if the channel is available.

Definition at line 1197 of file sig_ss7.c.

References sig_ss7_chan::inalarm, sig_ss7_chan::locallyblocked, sig_ss7_chan::owner, sig_ss7_chan::remotelyblocked, sig_ss7_chan::ss7, and sig_ss7_chan::ss7call.

Referenced by available().

01198 {
01199    if (!p->ss7) {
01200       /* Something is wrong here.  A SS7 channel without the ss7 pointer? */
01201       return 0;
01202    }
01203 
01204    if (!p->inalarm && !p->owner && !p->ss7call
01205       && !p->locallyblocked && !p->remotelyblocked) {
01206       return 1;
01207    }
01208 
01209    return 0;
01210 }

int sig_ss7_call ( struct sig_ss7_chan p,
struct ast_channel ast,
char *  rdest 
)

Dial out using the specified SS7 channel.

Since:
1.8
Parameters:
p Signaling private structure pointer.
ast Asterisk channel structure pointer.
rdest Dialstring.
Return values:
0 on success.
-1 on error.

Definition at line 1233 of file sig_ss7.c.

References ast_party_connected_line::ani2, ast_copy_string(), ast_log(), ast_setstate(), AST_STATE_DIALING, 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_set_dialing(), sig_ss7_linkset::ss7, sig_ss7_chan::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().

01234 {
01235    char ss7_called_nai;
01236    int called_nai_strip;
01237    char ss7_calling_nai;
01238    int calling_nai_strip;
01239    const char *charge_str = NULL;
01240    const char *gen_address = NULL;
01241    const char *gen_digits = NULL;
01242    const char *gen_dig_type = NULL;
01243    const char *gen_dig_scheme = NULL;
01244    const char *gen_name = NULL;
01245    const char *jip_digits = NULL;
01246    const char *lspi_ident = NULL;
01247    const char *rlt_flag = NULL;
01248    const char *call_ref_id = NULL;
01249    const char *call_ref_pc = NULL;
01250    const char *send_far = NULL;
01251    char *c;
01252    char *l;
01253    char dest[256];
01254 
01255    ast_copy_string(dest, rdest, sizeof(dest));
01256 
01257    c = strchr(dest, '/');
01258    if (c) {
01259       c++;
01260    } else {
01261       c = "";
01262    }
01263    if (strlen(c) < p->stripmsd) {
01264       ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
01265       return -1;
01266    }
01267 
01268    if (!p->hidecallerid) {
01269       l = ast->connected.id.number.valid ? ast->connected.id.number.str : NULL;
01270    } else {
01271       l = NULL;
01272    }
01273 
01274    if (ss7_grab(p, p->ss7)) {
01275       ast_log(LOG_WARNING, "Failed to grab SS7!\n");
01276       return -1;
01277    }
01278 
01279    p->ss7call = isup_new_call(p->ss7->ss7);
01280    if (!p->ss7call) {
01281       ss7_rel(p->ss7);
01282       ast_log(LOG_ERROR, "Unable to allocate new SS7 call!\n");
01283       return -1;
01284    }
01285 
01286    called_nai_strip = 0;
01287    ss7_called_nai = p->ss7->called_nai;
01288    if (ss7_called_nai == SS7_NAI_DYNAMIC) { /* compute dynamically */
01289       if (strncmp(c + p->stripmsd, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
01290          called_nai_strip = strlen(p->ss7->internationalprefix);
01291          ss7_called_nai = SS7_NAI_INTERNATIONAL;
01292       } else if (strncmp(c + p->stripmsd, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
01293          called_nai_strip = strlen(p->ss7->nationalprefix);
01294          ss7_called_nai = SS7_NAI_NATIONAL;
01295       } else {
01296          ss7_called_nai = SS7_NAI_SUBSCRIBER;
01297       }
01298    }
01299    isup_set_called(p->ss7call, c + p->stripmsd + called_nai_strip, ss7_called_nai, p->ss7->ss7);
01300 
01301    calling_nai_strip = 0;
01302    ss7_calling_nai = p->ss7->calling_nai;
01303    if ((l != NULL) && (ss7_calling_nai == SS7_NAI_DYNAMIC)) { /* compute dynamically */
01304       if (strncmp(l, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
01305          calling_nai_strip = strlen(p->ss7->internationalprefix);
01306          ss7_calling_nai = SS7_NAI_INTERNATIONAL;
01307       } else if (strncmp(l, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
01308          calling_nai_strip = strlen(p->ss7->nationalprefix);
01309          ss7_calling_nai = SS7_NAI_NATIONAL;
01310       } else {
01311          ss7_calling_nai = SS7_NAI_SUBSCRIBER;
01312       }
01313    }
01314    isup_set_calling(p->ss7call, l ? (l + calling_nai_strip) : NULL, ss7_calling_nai,
01315       p->use_callingpres ? cid_pres2ss7pres(ast->connected.id.number.presentation) : (l ? SS7_PRESENTATION_ALLOWED : SS7_PRESENTATION_RESTRICTED),
01316       p->use_callingpres ? cid_pres2ss7screen(ast->connected.id.number.presentation) : SS7_SCREENING_USER_PROVIDED);
01317 
01318    isup_set_oli(p->ss7call, ast->connected.ani2);
01319    isup_init_call(p->ss7->ss7, p->ss7call, p->cic, p->dpc);
01320 
01321    /* Set the charge number if it is set */
01322    charge_str = pbx_builtin_getvar_helper(ast, "SS7_CHARGE_NUMBER");
01323    if (charge_str)
01324       isup_set_charge(p->ss7call, charge_str, SS7_ANI_CALLING_PARTY_SUB_NUMBER, 0x10);
01325 
01326    gen_address = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_ADDRESS");
01327    if (gen_address)
01328       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 */
01329 
01330    gen_digits = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGITS");
01331    gen_dig_type = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGTYPE");
01332    gen_dig_scheme = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGSCHEME");
01333    if (gen_digits)
01334       isup_set_gen_digits(p->ss7call, gen_digits, atoi(gen_dig_type), atoi(gen_dig_scheme));
01335 
01336    gen_name = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_NAME");
01337    if (gen_name)
01338       isup_set_generic_name(p->ss7call, gen_name, GEN_NAME_TYPE_CALLING_NAME, GEN_NAME_AVAIL_AVAILABLE, GEN_NAME_PRES_ALLOWED);
01339 
01340    jip_digits = pbx_builtin_getvar_helper(ast, "SS7_JIP");
01341    if (jip_digits)
01342       isup_set_jip_digits(p->ss7call, jip_digits);
01343 
01344    lspi_ident = pbx_builtin_getvar_helper(ast, "SS7_LSPI_IDENT");
01345    if (lspi_ident)
01346       isup_set_lspi(p->ss7call, lspi_ident, 0x18, 0x7, 0x00);
01347 
01348    rlt_flag = pbx_builtin_getvar_helper(ast, "SS7_RLT_ON");
01349    if ((rlt_flag) && ((strncmp("NO", rlt_flag, strlen(rlt_flag))) != 0 )) {
01350       isup_set_lspi(p->ss7call, rlt_flag, 0x18, 0x7, 0x00); /* Setting for Nortel DMS-250/500 */
01351    }
01352 
01353    call_ref_id = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_IDENT");
01354    call_ref_pc = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_PC");
01355    if (call_ref_id && call_ref_pc) {
01356       isup_set_callref(p->ss7call, atoi(call_ref_id),
01357              call_ref_pc ? atoi(call_ref_pc) : 0);
01358    }
01359 
01360    send_far = pbx_builtin_getvar_helper(ast, "SS7_SEND_FAR");
01361    if ((send_far) && ((strncmp("NO", send_far, strlen(send_far))) != 0 ))
01362       (isup_far(p->ss7->ss7, p->ss7call));
01363 
01364    isup_iam(p->ss7->ss7, p->ss7call);
01365    sig_ss7_set_dialing(p, 1);
01366    ast_setstate(ast, AST_STATE_DIALING);
01367    ss7_rel(p->ss7);
01368    return 0;
01369 }

void sig_ss7_chan_delete ( struct sig_ss7_chan doomed  ) 

Delete the sig_ss7 private channel structure.

Since:
1.8
Parameters:
doomed sig_ss7 private channel structure to delete.
Returns:
Nothing

Definition at line 1591 of file sig_ss7.c.

References ast_free.

Referenced by destroy_dahdi_pvt().

01592 {
01593    ast_free(doomed);
01594 }

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.

Since:
1.8
Parameters:
pvt_data Upper layer private data structure.
callback Callbacks to the upper layer.
ss7 Controlling linkset for the channel.
Return values:
sig_ss7_chan on success.
NULL on error.

Definition at line 1607 of file sig_ss7.c.

References ast_calloc, and sig_ss7_chan::ss7.

01608 {
01609    struct sig_ss7_chan *pvt;
01610 
01611    pvt = ast_calloc(1, sizeof(*pvt));
01612    if (!pvt) {
01613       return pvt;
01614    }
01615 
01616    pvt->calls = callback;
01617    pvt->chan_pvt = pvt_data;
01618    pvt->ss7 = ss7;
01619 
01620    return pvt;
01621 }

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.

Since:
1.8
Parameters:
oldchan Old channel pointer to replace.
newchan New channel pointer to set.
pchan Signaling private structure pointer.
Returns:
Nothing

Definition at line 1458 of file sig_ss7.c.

References sig_ss7_chan::owner.

01459 {
01460    if (pchan->owner == oldchan) {
01461       pchan->owner = newchan;
01462    }
01463 }

int sig_ss7_hangup ( struct sig_ss7_chan p,
struct ast_channel ast 
)

SS7 hangup channel.

Since:
1.8
Parameters:
p Signaling private structure pointer.
ast Asterisk channel structure pointer.
Return values:
0 on success.
-1 on error.

Definition at line 1381 of file sig_ss7.c.

References sig_ss7_chan::alerting, sig_ss7_chan::alreadyhungup, ast_log(), cause, sig_ss7_chan::cic, sig_ss7_chan::exten, ast_channel::hangupcause, LOG_WARNING, sig_ss7_chan::outgoing, sig_ss7_chan::owner, pbx_builtin_getvar_helper(), sig_ss7_chan::proceeding, sig_ss7_chan::progress, sig_ss7_chan::rlt, sig_ss7_set_dialing(), sig_ss7_linkset::ss7, sig_ss7_chan::ss7, ss7_grab(), ss7_rel(), sig_ss7_chan::ss7call, and ast_channel::tech_pvt.

Referenced by dahdi_hangup().

01382 {
01383    int res = 0;
01384 
01385    if (!ast->tech_pvt) {
01386       ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
01387       return 0;
01388    }
01389 
01390    p->owner = NULL;
01391    sig_ss7_set_dialing(p, 0);
01392    p->outgoing = 0;
01393    p->proceeding = 0;
01394    p->progress = 0;
01395    p->alerting = 0;
01396    p->rlt = 0;
01397    p->exten[0] = '\0';
01398    /* Perform low level hangup if no owner left */
01399    if (p->ss7call) {
01400       if (!ss7_grab(p, p->ss7)) {
01401          if (!p->alreadyhungup) {
01402             const char *cause = pbx_builtin_getvar_helper(ast,"SS7_CAUSE");
01403             int icause = ast->hangupcause ? ast->hangupcause : -1;
01404 
01405             if (cause) {
01406                if (atoi(cause))
01407                   icause = atoi(cause);
01408             }
01409             isup_rel(p->ss7->ss7, p->ss7call, icause);
01410             ss7_rel(p->ss7);
01411             p->alreadyhungup = 1;
01412          } else
01413             ast_log(LOG_WARNING, "Trying to hangup twice!\n");
01414       } else {
01415          ast_log(LOG_WARNING, "Unable to grab SS7 on CIC %d\n", p->cic);
01416          res = -1;
01417       }
01418    }
01419 
01420    return res;
01421 }

int sig_ss7_indicate ( struct sig_ss7_chan p,
struct ast_channel chan,
int  condition,
const void *  data,
size_t  datalen 
)

SS7 answer channel.

Since:
1.8
Parameters:
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.
Return values:
0 on success.
-1 on error or indication condition not handled.

Definition at line 1478 of file sig_ss7.c.

References ast_channel::_state, sig_ss7_chan::alerting, AST_CAUSE_CONGESTION, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HOLD, 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, ast_channel::hangupcause, sig_ss7_chan::mohinterpret, ast_channel::name, sig_ss7_chan::outgoing, sig_ss7_chan::proceeding, sig_ss7_chan::progress, sig_ss7_chan::rlt, sig_ss7_play_tone(), sig_ss7_set_echocanceller(), SIG_SS7_TONE_BUSY, SIG_SS7_TONE_RINGTONE, sig_ss7_linkset::ss7, sig_ss7_chan::ss7, ss7_grab(), ss7_rel(), and sig_ss7_chan::ss7call.

Referenced by dahdi_indicate().

01479 {
01480    int res = -1;
01481 
01482    switch (condition) {
01483    case AST_CONTROL_BUSY:
01484       res = sig_ss7_play_tone(p, SIG_SS7_TONE_BUSY);
01485       break;
01486    case AST_CONTROL_RINGING:
01487       if ((!p->alerting) && p->ss7 && !p->outgoing && (chan->_state != AST_STATE_UP)) {
01488          if (p->ss7->ss7) {
01489             ss7_grab(p, p->ss7);
01490 
01491             if ((isup_far(p->ss7->ss7, p->ss7call)) != -1)
01492                p->rlt = 1;
01493             if (p->rlt != 1) /* No need to send CPG if call will be RELEASE */
01494                isup_cpg(p->ss7->ss7, p->ss7call, CPG_EVENT_ALERTING);
01495             p->alerting = 1;
01496             ss7_rel(p->ss7);
01497          }
01498       }
01499 
01500       res = sig_ss7_play_tone(p, SIG_SS7_TONE_RINGTONE);
01501 
01502       if (chan->_state != AST_STATE_UP && chan->_state != AST_STATE_RING) {
01503          ast_setstate(chan, AST_STATE_RINGING);
01504       }
01505       break;
01506    case AST_CONTROL_PROCEEDING:
01507       ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
01508       /* This IF sends the FAR for an answered ALEG call */
01509       if (chan->_state == AST_STATE_UP && (p->rlt != 1)){
01510          if ((isup_far(p->ss7->ss7, p->ss7call)) != -1)
01511             p->rlt = 1;
01512       }
01513 
01514       if (!p->proceeding && p->ss7 && !p->outgoing) {
01515          if (p->ss7->ss7) {
01516             ss7_grab(p, p->ss7);
01517             isup_acm(p->ss7->ss7, p->ss7call);
01518             p->proceeding = 1;
01519             ss7_rel(p->ss7);
01520          }
01521       }
01522       /* don't continue in ast_indicate */
01523       res = 0;
01524       break;
01525    case AST_CONTROL_PROGRESS:
01526       ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
01527       if (!p->progress && p->ss7 && !p->outgoing) {
01528          if (p->ss7->ss7) {
01529             ss7_grab(p, p->ss7);
01530             isup_cpg(p->ss7->ss7, p->ss7call, CPG_EVENT_INBANDINFO);
01531             p->progress = 1;
01532             ss7_rel(p->ss7);
01533             /* enable echo canceler here on SS7 calls */
01534             sig_ss7_set_echocanceller(p, 1);
01535          }
01536       }
01537       /* don't continue in ast_indicate */
01538       res = 0;
01539       break;
01540    case AST_CONTROL_CONGESTION:
01541       chan->hangupcause = AST_CAUSE_CONGESTION;
01542       break;
01543    case AST_CONTROL_HOLD:
01544       ast_moh_start(chan, data, p->mohinterpret);
01545       break;
01546    case AST_CONTROL_UNHOLD:
01547       ast_moh_stop(chan);
01548       break;
01549    case AST_CONTROL_SRCUPDATE:
01550       res = 0;
01551       break;
01552    case -1:
01553       res = sig_ss7_play_tone(p, -1);
01554       break;
01555    }
01556    return res;
01557 }

void sig_ss7_init_linkset ( struct sig_ss7_linkset ss7  ) 

Initialize the SS7 linkset control.

Since:
1.8
Parameters:
ss7 sig_ss7 SS7 control structure.
Returns:
Nothing

Definition at line 1631 of file sig_ss7.c.

References ARRAY_LEN, ast_mutex_init, AST_PTHREADT_NULL, and sig_ss7_chan::ss7.

Referenced by load_module().

01632 {
01633    int idx;
01634 
01635    memset(ss7, 0, sizeof(*ss7));
01636 
01637    ast_mutex_init(&ss7->lock);
01638 
01639    ss7->master = AST_PTHREADT_NULL;
01640    for (idx = 0; idx < ARRAY_LEN(ss7->fds); ++idx) {
01641       ss7->fds[idx] = -1;
01642    }
01643 }

void sig_ss7_link_alarm ( struct sig_ss7_linkset linkset,
int  which 
)

Notify the SS7 layer that the link is in alarm.

Since:
1.8
Parameters:
linkset Controlling linkset for the channel.
which Link index of the signaling channel.
Returns:
Nothing

Definition at line 1119 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().

01120 {
01121    linkset->linkstate[which] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
01122    linkset->linkstate[which] &= ~LINKSTATE_UP;
01123    ss7_link_alarm(linkset->ss7, linkset->fds[which]);
01124 }

void sig_ss7_link_noalarm ( struct sig_ss7_linkset linkset,
int  which 
)

Notify the SS7 layer that the link is no longer in alarm.

Since:
1.8
Parameters:
linkset Controlling linkset for the channel.
which Link index of the signaling channel.
Returns:
Nothing

Definition at line 1135 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().

01136 {
01137    linkset->linkstate[which] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
01138    linkset->linkstate[which] |= LINKSTATE_STARTING;
01139    ss7_link_noalarm(linkset->ss7, linkset->fds[which]);
01140 }

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.

Since:
1.8
Parameters:
p Signaling private structure pointer.
law Companding law preferred
requestor Asterisk channel requesting a channel to dial (Can be NULL)
transfercapability 
Return values:
ast_channel on success.
NULL on error.

Definition at line 1571 of file sig_ss7.c.

References AST_STATE_RESERVED, sig_ss7_chan::exten, sig_ss7_chan::outgoing, and sig_ss7_new_ast_channel().

Referenced by dahdi_request().

01572 {
01573    struct ast_channel *ast;
01574 
01575    p->outgoing = 1;
01576    ast = sig_ss7_new_ast_channel(p, AST_STATE_RESERVED, law, transfercapability, p->exten, requestor);
01577    if (!ast) {
01578       p->outgoing = 0;
01579    }
01580    return ast;
01581 }

void sig_ss7_set_alarm ( struct sig_ss7_chan p,
int  in_alarm 
)

Definition at line 67 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(), and handle_init_event().

00068 {
00069    p->inalarm = in_alarm;
00070    if (p->calls->set_alarm) {
00071       p->calls->set_alarm(p->chan_pvt, in_alarm);
00072    }
00073 }

void* ss7_linkset ( void *  data  ) 

Definition at line 582 of file sig_ss7.c.

References ast_mutex_lock, ast_tvnow(), sig_ss7_linkset::lock, SIG_SS7_DEBUG_DEFAULT, sig_ss7_linkset::ss7, and tv.

00583 {
00584    int res, i;
00585    struct timeval *next = NULL, tv;
00586    struct sig_ss7_linkset *linkset = (struct sig_ss7_linkset *) data;
00587    struct ss7 *ss7 = linkset->ss7;
00588    ss7_event *e = NULL;
00589    struct sig_ss7_chan *p;
00590    int chanpos;
00591    struct pollfd pollers[SIG_SS7_NUM_DCHANS];
00592    int cic;
00593    unsigned int dpc;
00594    int nextms = 0;
00595 
00596    ss7_set_debug(ss7, SIG_SS7_DEBUG_DEFAULT);
00597    ss7_start(ss7);
00598 
00599    for (;;) {
00600       ast_mutex_lock(&linkset->lock);
00601       if ((next = ss7_schedule_next(ss7))) {
00602          tv = ast_tvnow();
00603          tv.tv_sec = next->tv_sec - tv.tv_sec;
00604          tv.tv_usec = next->tv_usec - tv.tv_usec;
00605          if (tv.tv_usec < 0) {
00606             tv.tv_usec += 1000000;
00607             tv.tv_sec -= 1;
00608          }
00609          if (tv.tv_sec < 0) {
00610             tv.tv_sec = 0;
00611             tv.tv_usec = 0;
00612          }
00613          nextms = tv.tv_sec * 1000;
00614          nextms += tv.tv_usec / 1000;
00615       }
00616       ast_mutex_unlock(&linkset->lock);
00617 
00618       for (i = 0; i < linkset->numsigchans; i++) {
00619          pollers[i].fd = linkset->fds[i];
00620          pollers[i].events = ss7_pollflags(ss7, linkset->fds[i]);
00621          pollers[i].revents = 0;
00622       }
00623 
00624       res = poll(pollers, linkset->numsigchans, nextms);
00625       if ((res < 0) && (errno != EINTR)) {
00626          ast_log(LOG_ERROR, "poll(%s)\n", strerror(errno));
00627       } else if (!res) {
00628          ast_mutex_lock(&linkset->lock);
00629          ss7_schedule_run(ss7);
00630          ast_mutex_unlock(&linkset->lock);
00631          continue;
00632       }
00633 
00634       ast_mutex_lock(&linkset->lock);
00635       for (i = 0; i < linkset->numsigchans; i++) {
00636          if (pollers[i].revents & POLLPRI) {
00637             sig_ss7_handle_link_exception(linkset, i);
00638          }
00639          if (pollers[i].revents & POLLIN) {
00640             res = ss7_read(ss7, pollers[i].fd);
00641          }
00642          if (pollers[i].revents & POLLOUT) {
00643             res = ss7_write(ss7, pollers[i].fd);
00644             if (res < 0) {
00645                ast_debug(1, "Error in write %s\n", strerror(errno));
00646             }
00647          }
00648       }
00649 
00650       while ((e = ss7_check_event(ss7))) {
00651          switch (e->e) {
00652          case SS7_EVENT_UP:
00653             if (linkset->state != LINKSET_STATE_UP) {
00654                ast_verbose("--- SS7 Up ---\n");
00655                ss7_reset_linkset(linkset);
00656             }
00657             linkset->state = LINKSET_STATE_UP;
00658             break;
00659          case SS7_EVENT_DOWN:
00660             ast_verbose("--- SS7 Down ---\n");
00661             linkset->state = LINKSET_STATE_DOWN;
00662             for (i = 0; i < linkset->numchans; i++) {
00663                p = linkset->pvts[i];
00664                if (p) {
00665                   sig_ss7_set_alarm(p, 1);
00666                }
00667             }
00668             break;
00669          case MTP2_LINK_UP:
00670             ast_verbose("MTP2 link up (SLC %d)\n", e->gen.data);
00671             break;
00672          case MTP2_LINK_DOWN:
00673             ast_log(LOG_WARNING, "MTP2 link down (SLC %d)\n", e->gen.data);
00674             break;
00675          case ISUP_EVENT_CPG:
00676             chanpos = ss7_find_cic(linkset, e->cpg.cic, e->cpg.opc);
00677             if (chanpos < 0) {
00678                ast_log(LOG_WARNING, "CPG on unconfigured CIC %d\n", e->cpg.cic);
00679                break;
00680             }
00681             p = linkset->pvts[chanpos];
00682             sig_ss7_lock_private(p);
00683             switch (e->cpg.event) {
00684             case CPG_EVENT_ALERTING:
00685                p->alerting = 1;
00686                sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
00687                break;
00688             case CPG_EVENT_PROGRESS:
00689             case CPG_EVENT_INBANDINFO:
00690                {
00691                   ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
00692                   sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROGRESS);
00693                   p->progress = 1;
00694                   sig_ss7_set_dialing(p, 0);
00695 #if 0 /* This code no longer seems to be necessary so I did not convert it. */
00696                   if (p->dsp && p->dsp_features) {
00697                      ast_dsp_set_features(p->dsp, p->dsp_features);
00698                      p->dsp_features = 0;
00699                   }
00700 #endif
00701                }
00702                break;
00703             default:
00704                ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
00705                break;
00706             }
00707 
00708             sig_ss7_unlock_private(p);
00709             break;
00710          case ISUP_EVENT_RSC:
00711             ast_verbose("Resetting CIC %d\n", e->rsc.cic);
00712             chanpos = ss7_find_cic(linkset, e->rsc.cic, e->rsc.opc);
00713             if (chanpos < 0) {
00714                ast_log(LOG_WARNING, "RSC on unconfigured CIC %d\n", e->rsc.cic);
00715                break;
00716             }
00717             p = linkset->pvts[chanpos];
00718             sig_ss7_lock_private(p);
00719             sig_ss7_set_inservice(p, 1);
00720             sig_ss7_set_remotelyblocked(p, 0);
00721             dpc = p->dpc;
00722             isup_set_call_dpc(e->rsc.call, dpc);
00723             p->ss7call = NULL;
00724             if (p->owner)
00725                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
00726             sig_ss7_unlock_private(p);
00727             isup_rlc(ss7, e->rsc.call);
00728             break;
00729          case ISUP_EVENT_GRS:
00730             ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
00731             chanpos = ss7_find_cic(linkset, e->grs.startcic, e->grs.opc);
00732             if (chanpos < 0) {
00733                ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic);
00734                break;
00735             }
00736             p = linkset->pvts[chanpos];
00737             isup_gra(ss7, e->grs.startcic, e->grs.endcic, e->grs.opc);
00738             ss7_block_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc, NULL, 0);
00739             ss7_hangup_cics(linkset, e->grs.startcic, e->grs.endcic, e->grs.opc);
00740             break;
00741          case ISUP_EVENT_CQM:
00742             ast_debug(1, "Got Circuit group query message from CICs %d to %d\n", e->cqm.startcic, e->cqm.endcic);
00743             ss7_handle_cqm(linkset, e->cqm.startcic, e->cqm.endcic, e->cqm.opc);
00744             break;
00745          case ISUP_EVENT_GRA:
00746             ast_verbose("Got reset acknowledgement from CIC %d to %d.\n", e->gra.startcic, e->gra.endcic);
00747             ss7_inservice(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc);
00748             ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.opc, e->gra.status, 1);
00749             break;
00750          case ISUP_EVENT_IAM:
00751             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);
00752             chanpos = ss7_find_cic(linkset, e->iam.cic, e->iam.opc);
00753             if (chanpos < 0) {
00754                ast_log(LOG_WARNING, "IAM on unconfigured CIC %d\n", e->iam.cic);
00755                isup_rel(ss7, e->iam.call, -1);
00756                break;
00757             }
00758             p = linkset->pvts[chanpos];
00759             sig_ss7_lock_private(p);
00760             if (p->owner) {
00761                if (p->ss7call == e->iam.call) {
00762                   sig_ss7_unlock_private(p);
00763                   ast_log(LOG_WARNING, "Duplicate IAM requested on CIC %d\n", e->iam.cic);
00764                   break;
00765                } else {
00766                   sig_ss7_unlock_private(p);
00767                   ast_log(LOG_WARNING, "Ring requested on CIC %d already in use!\n", e->iam.cic);
00768                   break;
00769                }
00770             }
00771 
00772             dpc = p->dpc;
00773             p->ss7call = e->iam.call;
00774             isup_set_call_dpc(p->ss7call, dpc);
00775 
00776             if ((p->use_callerid) && (!ast_strlen_zero(e->iam.calling_party_num))) {
00777                ss7_apply_plan_to_number(p->cid_num, sizeof(p->cid_num), linkset, e->iam.calling_party_num, e->iam.calling_nai);
00778                p->callingpres = ss7_pres_scr2cid_pres(e->iam.presentation_ind, e->iam.screening_ind);
00779             } else
00780                p->cid_num[0] = 0;
00781 
00782             /* Set DNID */
00783             if (!ast_strlen_zero(e->iam.called_party_num)) {
00784                ss7_apply_plan_to_number(p->exten, sizeof(p->exten), linkset,
00785                   e->iam.called_party_num, e->iam.called_nai);
00786                sig_ss7_set_dnid(p, p->exten);
00787             }
00788 
00789             if (p->immediate) {
00790                p->exten[0] = 's';
00791                p->exten[1] = '\0';
00792             } else if (!ast_strlen_zero(e->iam.called_party_num)) {
00793                char *st;
00794                ss7_apply_plan_to_number(p->exten, sizeof(p->exten), linkset, e->iam.called_party_num, e->iam.called_nai);
00795                st = strchr(p->exten, '#');
00796                if (st) {
00797                   *st = '\0';
00798                }
00799             } else {
00800                p->exten[0] = '\0';
00801             }
00802 
00803             p->cid_ani[0] = '\0';
00804             if ((p->use_callerid) && (!ast_strlen_zero(e->iam.generic_name)))
00805                ast_copy_string(p->cid_name, e->iam.generic_name, sizeof(p->cid_name));
00806             else
00807                p->cid_name[0] = '\0';
00808 
00809             p->cid_ani2 = e->iam.oli_ani2;
00810             p->cid_ton = 0;
00811             ast_copy_string(p->charge_number, e->iam.charge_number, sizeof(p->charge_number));
00812             ast_copy_string(p->gen_add_number, e->iam.gen_add_number, sizeof(p->gen_add_number));
00813             p->gen_add_type = e->iam.gen_add_type;
00814             p->gen_add_nai = e->iam.gen_add_nai;
00815             p->gen_add_pres_ind = e->iam.gen_add_pres_ind;
00816             p->gen_add_num_plan = e->iam.gen_add_num_plan;
00817             ast_copy_string(p->gen_dig_number, e->iam.gen_dig_number, sizeof(p->gen_dig_number));
00818             p->gen_dig_type = e->iam.gen_dig_type;
00819             p->gen_dig_scheme = e->iam.gen_dig_scheme;
00820             ast_copy_string(p->jip_number, e->iam.jip_number, sizeof(p->jip_number));
00821             ast_copy_string(p->orig_called_num, e->iam.orig_called_num, sizeof(p->orig_called_num));
00822             ast_copy_string(p->redirecting_num, e->iam.redirecting_num, sizeof(p->redirecting_num));
00823             ast_copy_string(p->generic_name, e->iam.generic_name, sizeof(p->generic_name));
00824             p->calling_party_cat = e->iam.calling_party_cat;
00825 
00826             sig_ss7_set_caller_id(p);
00827 
00828             if (ast_exists_extension(NULL, p->context, p->exten, 1, p->cid_num)) {
00829                if (e->iam.cot_check_required) {
00830                   sig_ss7_loopback(p, 1);
00831                } else
00832                   ss7_start_call(p, linkset);
00833             } else {
00834                ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
00835                p->alreadyhungup = 1;
00836                isup_rel(ss7, e->iam.call, AST_CAUSE_UNALLOCATED);
00837             }
00838             sig_ss7_unlock_private(p);
00839             break;
00840          case ISUP_EVENT_COT:
00841             chanpos = ss7_find_cic(linkset, e->cot.cic, e->cot.opc);
00842             if (chanpos < 0) {
00843                ast_log(LOG_WARNING, "COT on unconfigured CIC %d\n", e->cot.cic);
00844                isup_rel(ss7, e->cot.call, -1);
00845                break;
00846             }
00847             p = linkset->pvts[chanpos];
00848 
00849             sig_ss7_lock_private(p);
00850             if (p->loopedback) {
00851                sig_ss7_loopback(p, 0);
00852                ss7_start_call(p, linkset);
00853             }
00854             sig_ss7_unlock_private(p);
00855             break;
00856          case ISUP_EVENT_CCR:
00857             ast_debug(1, "Got CCR request on CIC %d\n", e->ccr.cic);
00858             chanpos = ss7_find_cic(linkset, e->ccr.cic, e->ccr.opc);
00859             if (chanpos < 0) {
00860                ast_log(LOG_WARNING, "CCR on unconfigured CIC %d\n", e->ccr.cic);
00861                break;
00862             }
00863 
00864             p = linkset->pvts[chanpos];
00865 
00866             sig_ss7_lock_private(p);
00867             sig_ss7_loopback(p, 1);
00868             sig_ss7_unlock_private(p);
00869 
00870             isup_lpa(linkset->ss7, e->ccr.cic, p->dpc);
00871             break;
00872          case ISUP_EVENT_CVT:
00873             ast_debug(1, "Got CVT request on CIC %d\n", e->cvt.cic);
00874             chanpos = ss7_find_cic(linkset, e->cvt.cic, e->cvt.opc);
00875             if (chanpos < 0) {
00876                ast_log(LOG_WARNING, "CVT on unconfigured CIC %d\n", e->cvt.cic);
00877                break;
00878             }
00879 
00880             p = linkset->pvts[chanpos];
00881 
00882             sig_ss7_lock_private(p);
00883             sig_ss7_loopback(p, 1);
00884             sig_ss7_unlock_private(p);
00885 
00886             isup_cvr(linkset->ss7, e->cvt.cic, p->dpc);
00887             break;
00888          case ISUP_EVENT_REL:
00889             chanpos = ss7_find_cic(linkset, e->rel.cic, e->rel.opc);
00890             if (chanpos < 0) {
00891                ast_log(LOG_WARNING, "REL on unconfigured CIC %d\n", e->rel.cic);
00892                break;
00893             }
00894             p = linkset->pvts[chanpos];
00895             sig_ss7_lock_private(p);
00896             if (p->owner) {
00897                p->owner->hangupcause = e->rel.cause;
00898                p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
00899             } else {
00900                ast_log(LOG_WARNING, "REL on channel (CIC %d) without owner!\n", p->cic);
00901             }
00902 
00903             /* End the loopback if we have one */
00904             sig_ss7_loopback(p, 0);
00905 
00906             isup_rlc(ss7, e->rel.call);
00907             p->ss7call = NULL;
00908 
00909             sig_ss7_unlock_private(p);
00910             break;
00911          case ISUP_EVENT_ACM:
00912             chanpos = ss7_find_cic(linkset, e->acm.cic, e->acm.opc);
00913             if (chanpos < 0) {
00914                ast_log(LOG_WARNING, "ACM on unconfigured CIC %d\n", e->acm.cic);
00915                isup_rel(ss7, e->acm.call, -1);
00916                break;
00917             } else {
00918                p = linkset->pvts[chanpos];
00919 
00920                ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
00921 
00922                if (e->acm.call_ref_ident > 0) {
00923                   p->rlt = 1; /* Setting it but not using it here*/
00924                }
00925 
00926                sig_ss7_lock_private(p);
00927                sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROCEEDING);
00928                p->proceeding = 1;
00929                sig_ss7_set_dialing(p, 0);
00930                /* Send alerting if subscriber is free */
00931                if (e->acm.called_party_status_ind == 1) {
00932                   p->alerting = 1;
00933                   sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
00934                }
00935                sig_ss7_unlock_private(p);
00936             }
00937             break;
00938          case ISUP_EVENT_CGB:
00939             chanpos = ss7_find_cic(linkset, e->cgb.startcic, e->cgb.opc);
00940             if (chanpos < 0) {
00941                ast_log(LOG_WARNING, "CGB on unconfigured CIC %d\n", e->cgb.startcic);
00942                break;
00943             }
00944             p = linkset->pvts[chanpos];
00945             ss7_block_cics(linkset, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, 1);
00946             isup_cgba(linkset->ss7, e->cgb.startcic, e->cgb.endcic, e->cgb.opc, e->cgb.status, e->cgb.type);
00947             break;
00948          case ISUP_EVENT_CGU:
00949             chanpos = ss7_find_cic(linkset, e->cgu.startcic, e->cgu.opc);
00950             if (chanpos < 0) {
00951                ast_log(LOG_WARNING, "CGU on unconfigured CIC %d\n", e->cgu.startcic);
00952                break;
00953             }
00954             p = linkset->pvts[chanpos];
00955             ss7_block_cics(linkset, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, 0);
00956             isup_cgua(linkset->ss7, e->cgu.startcic, e->cgu.endcic, e->cgu.opc, e->cgu.status, e->cgu.type);
00957             break;
00958          case ISUP_EVENT_UCIC:
00959             chanpos = ss7_find_cic(linkset, e->ucic.cic, e->ucic.opc);
00960             if (chanpos < 0) {
00961                ast_log(LOG_WARNING, "UCIC on unconfigured CIC %d\n", e->ucic.cic);
00962                break;
00963             }
00964             p = linkset->pvts[chanpos];
00965             ast_debug(1, "Unequiped Circuit Id Code on CIC %d\n", e->ucic.cic);
00966             sig_ss7_lock_private(p);
00967             sig_ss7_set_remotelyblocked(p, 1);
00968             sig_ss7_set_inservice(p, 0);
00969             sig_ss7_unlock_private(p);/* doesn't require a SS7 acknowledgement */
00970             break;
00971          case ISUP_EVENT_BLO:
00972             chanpos = ss7_find_cic(linkset, e->blo.cic, e->blo.opc);
00973             if (chanpos < 0) {
00974                ast_log(LOG_WARNING, "BLO on unconfigured CIC %d\n", e->blo.cic);
00975                break;
00976             }
00977             p = linkset->pvts[chanpos];
00978             ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
00979             sig_ss7_lock_private(p);
00980             sig_ss7_set_remotelyblocked(p, 1);
00981             sig_ss7_unlock_private(p);
00982             isup_bla(linkset->ss7, e->blo.cic, p->dpc);
00983             break;
00984          case ISUP_EVENT_BLA:
00985             chanpos = ss7_find_cic(linkset, e->bla.cic, e->bla.opc);
00986             if (chanpos < 0) {
00987                ast_log(LOG_WARNING, "BLA on unconfigured CIC %d\n", e->bla.cic);
00988                break;
00989             }
00990             ast_debug(1, "Blocking CIC %d\n", e->bla.cic);
00991             p = linkset->pvts[chanpos];
00992             sig_ss7_lock_private(p);
00993             sig_ss7_set_locallyblocked(p, 1);
00994             sig_ss7_unlock_private(p);
00995             break;
00996          case ISUP_EVENT_UBL:
00997             chanpos = ss7_find_cic(linkset, e->ubl.cic, e->ubl.opc);
00998             if (chanpos < 0) {
00999                ast_log(LOG_WARNING, "UBL on unconfigured CIC %d\n", e->ubl.cic);
01000                break;
01001             }
01002             p = linkset->pvts[chanpos];
01003             ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
01004             sig_ss7_lock_private(p);
01005             sig_ss7_set_remotelyblocked(p, 0);
01006             sig_ss7_unlock_private(p);
01007             isup_uba(linkset->ss7, e->ubl.cic, p->dpc);
01008             break;
01009          case ISUP_EVENT_UBA:
01010             chanpos = ss7_find_cic(linkset, e->uba.cic, e->uba.opc);
01011             if (chanpos < 0) {
01012                ast_log(LOG_WARNING, "UBA on unconfigured CIC %d\n", e->uba.cic);
01013                break;
01014             }
01015             p = linkset->pvts[chanpos];
01016             ast_debug(1, "Unblocking CIC %d\n", e->uba.cic);
01017             sig_ss7_lock_private(p);
01018             sig_ss7_set_locallyblocked(p, 0);
01019             sig_ss7_unlock_private(p);
01020             break;
01021          case ISUP_EVENT_CON:
01022          case ISUP_EVENT_ANM:
01023             if (e->e == ISUP_EVENT_CON)
01024                cic = e->con.cic;
01025             else
01026                cic = e->anm.cic;
01027 
01028             chanpos = ss7_find_cic(linkset, cic, (e->e == ISUP_EVENT_ANM) ? e->anm.opc : e->con.opc);
01029             if (chanpos < 0) {
01030                ast_log(LOG_WARNING, "ANM/CON on unconfigured CIC %d\n", cic);
01031                isup_rel(ss7, (e->e == ISUP_EVENT_ANM) ? e->anm.call : e->con.call, -1);
01032                break;
01033             } else {
01034                p = linkset->pvts[chanpos];
01035                sig_ss7_lock_private(p);
01036                sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_ANSWER);
01037 #if 0 /* This code no longer seems to be necessary so I did not convert it. */
01038                if (p->dsp && p->dsp_features) {
01039                   ast_dsp_set_features(p->dsp, p->dsp_features);
01040                   p->dsp_features = 0;
01041                }
01042 #endif
01043                sig_ss7_set_echocanceller(p, 1);
01044                sig_ss7_unlock_private(p);
01045             }
01046             break;
01047          case ISUP_EVENT_RLC:
01048             chanpos = ss7_find_cic(linkset, e->rlc.cic, e->rlc.opc);
01049             if (chanpos < 0) {
01050                ast_log(LOG_WARNING, "RLC on unconfigured CIC %d\n", e->rlc.cic);
01051                break;
01052             } else {
01053                p = linkset->pvts[chanpos];
01054                sig_ss7_lock_private(p);
01055                if (p->alreadyhungup)
01056                   p->ss7call = NULL;
01057                else
01058                   ast_log(LOG_NOTICE, "Received RLC out and we haven't sent REL.  Ignoring.\n");
01059                sig_ss7_unlock_private(p);
01060                }
01061                break;
01062          case ISUP_EVENT_FAA:
01063             chanpos = ss7_find_cic(linkset, e->faa.cic, e->faa.opc);
01064             if (chanpos < 0) {
01065                ast_log(LOG_WARNING, "FAA on unconfigured CIC %d\n", e->faa.cic);
01066                break;
01067             } else {
01068                p = linkset->pvts[chanpos];
01069                ast_debug(1, "FAA received on CIC %d\n", e->faa.cic);
01070                sig_ss7_lock_private(p);
01071                if (p->alreadyhungup){
01072                   p->ss7call = NULL;
01073                   ast_log(LOG_NOTICE, "Received FAA and we haven't sent FAR.  Ignoring.\n");
01074                }
01075                sig_ss7_unlock_private(p);
01076             }
01077             break;
01078          default:
01079             ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e));
01080             break;
01081          }
01082       }
01083       ast_mutex_unlock(&linkset->lock);
01084    }
01085 
01086    return 0;
01087 }


Generated on Wed Apr 6 11:30:11 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7