dect
/
asterisk
Archived
13
0
Fork 0

Extract sig_ss7 out of chan_dahdi.

Extract the SS7 specific code out of chan_dahdi like what was done to
ISDN/PRI and analog signaling.  The new SS7 structures were modeled on
sig_pri.

The changes to sig_pri are an enhancement and a bug fix made possible
because SS7 was extracted.

1) The sig_pri TRANSFERCAPABILITY channel variable should have been set
unconditionally in sig_pri_new_ast_channel().

2) SS7/PRI transfer capability interaction in dahdi_new() fixed because of
SS7 extraction.

3) Module ref count error in dahdi_new() if startpbx failed to start the
PBX for some reason.

Review:	https://reviewboard.asterisk.org/r/661/


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@268774 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
rmudgett 2010-06-07 20:04:42 +00:00
parent 24c72d28ff
commit 2384f564ed
6 changed files with 2632 additions and 1590 deletions

View File

@ -73,8 +73,8 @@ $(if $(filter chan_iax2,$(EMBEDDED_MODS)),modules.link,chan_iax2.so): iax2-parse
iax2-parser.o iax2-provision.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_iax2)
$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c))
$(subst .c,.o,$(wildcard sip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_sip)
$(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o
sig_analog.o sig_pri.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)
$(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o sig_ss7.o
sig_analog.o sig_pri.o sig_ss7.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)
ifneq ($(filter chan_h323,$(EMBEDDED_MODS)),)
modules.link: h323/libchanh323.a

File diff suppressed because it is too large Load Diff

View File

@ -786,12 +786,12 @@ static int sig_pri_play_tone(struct sig_pri_chan *p, enum sig_pri_tone tone)
return -1;
}
static struct ast_channel *sig_pri_new_ast_channel(struct sig_pri_chan *p, int state, int startpbx, int ulaw, int transfercapability, char *exten, const struct ast_channel *requestor)
static struct ast_channel *sig_pri_new_ast_channel(struct sig_pri_chan *p, int state, int ulaw, int transfercapability, char *exten, const struct ast_channel *requestor)
{
struct ast_channel *c;
if (p->calls->new_ast_channel)
c = p->calls->new_ast_channel(p->chan_pvt, state, startpbx, ulaw, transfercapability, exten, requestor);
c = p->calls->new_ast_channel(p->chan_pvt, state, ulaw, exten, requestor);
else
return NULL;
@ -799,9 +799,10 @@ static struct ast_channel *sig_pri_new_ast_channel(struct sig_pri_chan *p, int s
p->owner = c;
p->isidlecall = 0;
p->alreadyhungup = 0;
c->transfercapability = transfercapability;
pbx_builtin_setvar_helper(c, "TRANSFERCAPABILITY",
ast_transfercapability2str(transfercapability));
if (transfercapability & AST_TRANS_CAP_DIGITAL) {
c->transfercapability = transfercapability;
pbx_builtin_setvar_helper(c, "TRANSFERCAPABILITY", ast_transfercapability2str(transfercapability));
sig_pri_set_digital(p, 1);
}
if (p->pri && !pri_grab(p, p->pri)) {
@ -841,7 +842,7 @@ struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law
ast_log(LOG_DEBUG, "%s %d\n", __FUNCTION__, p->channel);
p->outgoing = 1;
ast = sig_pri_new_ast_channel(p, AST_STATE_RESERVED, 0, law, transfercapability, p->exten, requestor);
ast = sig_pri_new_ast_channel(p, AST_STATE_RESERVED, law, transfercapability, p->exten, requestor);
if (!ast) {
p->outgoing = 0;
}
@ -4504,7 +4505,7 @@ static void *pri_dchannel(void *vpri)
*/
ast_mutex_unlock(&pri->lock);
c = sig_pri_new_ast_channel(pri->pvts[chanpos],
AST_STATE_RESERVED, 0,
AST_STATE_RESERVED,
(e->ring.layer1 == PRI_LAYER_1_ALAW)
? SIG_PRI_ALAW : SIG_PRI_ULAW,
e->ring.ctype, pri->pvts[chanpos]->exten, NULL);
@ -4597,7 +4598,7 @@ static void *pri_dchannel(void *vpri)
*/
ast_mutex_unlock(&pri->lock);
c = sig_pri_new_ast_channel(pri->pvts[chanpos],
AST_STATE_RING, 0,
AST_STATE_RING,
(e->ring.layer1 == PRI_LAYER_1_ALAW)
? SIG_PRI_ALAW : SIG_PRI_ULAW, e->ring.ctype,
pri->pvts[chanpos]->exten, NULL);

View File

@ -102,7 +102,7 @@ struct sig_pri_callback {
int (* const train_echocanceller)(void *pvt);
int (* const dsp_reset_and_flush_digits)(void *pvt);
struct ast_channel * (* const new_ast_channel)(void *pvt, int state, int startpbx, enum sig_pri_law law, int transfercapability, char *exten, const struct ast_channel *chan);
struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_channel *chan);
void (* const fixup_chans)(void *old_chan, void *new_chan);

1598
channels/sig_ss7.c Normal file

File diff suppressed because it is too large Load Diff

265
channels/sig_ss7.h Normal file
View File

@ -0,0 +1,265 @@
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2010 Digium, Inc.
*
* Richard Mudgett <rmudgett@digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
*/
/*!
* \file
* \brief Interface header for SS7 signaling module.
*
* \author Matthew Fredrickson <creslin@digium.com>
* \author Richard Mudgett <rmudgett@digium.com>
*
* See Also:
* \arg \ref AstCREDITS
*/
#ifndef _ASTERISK_SIG_SS7_H
#define _ASTERISK_SIG_SS7_H
#include "asterisk/channel.h"
#include <libss7.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------- */
/*! SS7 debug message flags when SS7 debugging is turned on at the command line. */
#define SIG_SS7_DEBUG \
(SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP)
#if 0
/*! SS7 debug message flags set on initial startup. */
#define SIG_SS7_DEBUG_DEFAULT SIG_SS7_DEBUG
#else
/*! SS7 debug message flags set on initial startup. */
#define SIG_SS7_DEBUG_DEFAULT 0
#endif
/* ------------------------------------------------------------------- */
#define SIG_SS7_NUM_DCHANS 4 /*!< No more than 4 d-channels */
#define SIG_SS7_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
#define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
#define LINKSTATE_INALARM (1 << 0)
#define LINKSTATE_STARTING (1 << 1)
#define LINKSTATE_UP (1 << 2)
#define LINKSTATE_DOWN (1 << 3)
#define SS7_NAI_DYNAMIC -1
#define LINKSET_FLAG_EXPLICITACM (1 << 0)
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,
};
enum sig_ss7_law {
SIG_SS7_DEFLAW = 0,
SIG_SS7_ULAW,
SIG_SS7_ALAW
};
struct sig_ss7_linkset;
struct sig_ss7_callback {
/* Unlock the private in the signaling private structure. */
void (* const unlock_private)(void *pvt);
/* Lock the private in the signaling private structure. */
void (* const lock_private)(void *pvt);
int (* const set_echocanceller)(void *pvt, int enable);
void (* const set_loopback)(void *pvt, int enable);
struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor);
int (* const play_tone)(void *pvt, enum sig_ss7_tone tone);
void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which);
void (* const set_alarm)(void *pvt, int in_alarm);
void (* const set_dialing)(void *pvt, int is_dialing);
void (* const set_digital)(void *pvt, int is_digital);
void (* const set_inservice)(void *pvt, int is_inservice);
void (* const set_locallyblocked)(void *pvt, int is_blocked);
void (* const set_remotelyblocked)(void *pvt, int is_blocked);
void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
void (* const set_dnid)(void *pvt, const char *dnid);
void (* const queue_control)(void *pvt, int subclass);
};
struct sig_ss7_chan {
struct sig_ss7_callback *calls;
void *chan_pvt; /*!< Private structure of the user of this module. */
struct sig_ss7_linkset *ss7;
struct ast_channel *owner;
/*! \brief Opaque libss7 call control structure */
struct isup_call *ss7call;
int channel; /*!< Channel Number */
int cic; /*!< CIC associated with channel */
unsigned int dpc; /*!< CIC's DPC */
/* Options to be set by user */
/*!
* \brief Number of most significant digits/characters to strip from the dialed number.
* \note Feature is deprecated. Use dialplan logic.
*/
int stripmsd;
/*!
* \brief TRUE if the outgoing caller ID is blocked/hidden.
*/
unsigned int hidecallerid:1;
/*! \brief TRUE if caller ID is used on this channel. */
unsigned int use_callerid:1;
/*!
* \brief TRUE if we will use the calling presentation setting
* from the Asterisk channel for outgoing calls.
*/
unsigned int use_callingpres:1;
unsigned int immediate:1; /*!< Answer before getting digits? */
/*! \brief TRUE if the channel is locally blocked. Set by user and link. */
unsigned int locallyblocked:1;
/*! \brief TRUE if the channel is remotely blocked. Set by user and link. */
unsigned int remotelyblocked:1;
char context[AST_MAX_CONTEXT];
char mohinterpret[MAX_MUSICCLASS];
/* Options to be checked by user */
int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
int cid_ton; /*!< Type Of Number (TON) */
int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
char cid_num[AST_MAX_EXTENSION];
char cid_subaddr[AST_MAX_EXTENSION];/*!< XXX SS7 may not support. */
char cid_name[AST_MAX_EXTENSION];
char cid_ani[AST_MAX_EXTENSION];
char exten[AST_MAX_EXTENSION];
/* Options to be checked by user that are stuffed into channel variables. */
char charge_number[50];
char gen_add_number[50];
char gen_dig_number[50];
char orig_called_num[50];
char redirecting_num[50];
char generic_name[50];
unsigned char gen_add_num_plan;
unsigned char gen_add_nai;
unsigned char gen_add_pres_ind;
unsigned char gen_add_type;
unsigned char gen_dig_type;
unsigned char gen_dig_scheme;
char jip_number[50];
#if 0
unsigned char lspi_type;
unsigned char lspi_scheme;
unsigned char lspi_context;
#endif
char lspi_ident[50];
unsigned int call_ref_ident;
unsigned int call_ref_pc;
unsigned char calling_party_cat;
/*
* Channel status bits.
*/
/*! TRUE if channel is associated with a link that is down. */
unsigned int inalarm:1;
/*! TRUE if this channel is being used for an outgoing call. */
unsigned int outgoing:1;
/*!
* \brief TRUE if call is in a proceeding state.
* The call has started working its way through the network.
*/
unsigned int proceeding:1;
/*! \brief TRUE if the call has seen progress through the network. */
unsigned int progress:1;
/*! \brief TRUE if channel is alerting/ringing */
unsigned int alerting:1;
/*! \brief TRUE if the call has already gone/hungup */
unsigned int alreadyhungup:1;
/*! \brief XXX BOOLEAN Purpose??? */
unsigned int rlt:1;
/*! TRUE if this channel is in loopback. */
unsigned int loopedback:1;
};
struct sig_ss7_linkset {
pthread_t master; /*!< Thread of master */
ast_mutex_t lock; /*!< libss7 access lock */
struct sig_ss7_callback *calls;
struct ss7 *ss7;
struct sig_ss7_chan *pvts[SIG_SS7_MAX_CHANNELS];/*!< Member channel pvt structs */
int fds[SIG_SS7_NUM_DCHANS];
int numsigchans;
int linkstate[SIG_SS7_NUM_DCHANS];
int numchans;
int span; /*!< span number put into user output messages */
enum {
LINKSET_STATE_DOWN = 0,
LINKSET_STATE_UP
} state;
/* Options to be set by user */
int flags; /*!< Linkset flags (LINKSET_FLAG_EXPLICITACM) */
int type; /*!< SS7 type ITU/ANSI. Used for companding selection. */
char called_nai; /*!< Called Nature of Address Indicator */
char calling_nai; /*!< Calling Nature of Address Indicator */
char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
char subscriberprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
char unknownprefix[20]; /*!< for unknown dialplans */
};
void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm);
void *ss7_linkset(void *data);
void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which);
void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which);
int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode);
int sig_ss7_available(struct sig_ss7_chan *p);
int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest);
int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast);
int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast);
int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
struct ast_channel *sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability);
void sig_ss7_chan_delete(struct sig_ss7_chan *doomed);
struct sig_ss7_chan *sig_ss7_chan_new(void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7);
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* _ASTERISK_SIG_SS7_H */
/* ------------------------------------------------------------------- */
/* end sig_ss7.h */