2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2010 Digium, Inc.
6 * Richard Mudgett <rmudgett@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief Interface header for SS7 signaling module.
23 * \author Matthew Fredrickson <creslin@digium.com>
24 * \author Richard Mudgett <rmudgett@digium.com>
27 * \arg \ref AstCREDITS
30 #ifndef _ASTERISK_SIG_SS7_H
31 #define _ASTERISK_SIG_SS7_H
33 #include "asterisk/channel.h"
40 /* ------------------------------------------------------------------- */
42 /*! SS7 debug message flags when SS7 debugging is turned on at the command line. */
43 #define SIG_SS7_DEBUG \
44 (SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP)
47 /*! SS7 debug message flags set on initial startup. */
48 #define SIG_SS7_DEBUG_DEFAULT SIG_SS7_DEBUG
50 /*! SS7 debug message flags set on initial startup. */
51 #define SIG_SS7_DEBUG_DEFAULT 0
54 /* ------------------------------------------------------------------- */
56 #define SIG_SS7_NUM_DCHANS 4 /*!< No more than 4 d-channels */
57 #define SIG_SS7_MAX_CHANNELS 672 /*!< No more than a DS3 per trunk group */
59 #define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
61 #define LINKSTATE_INALARM (1 << 0)
62 #define LINKSTATE_STARTING (1 << 1)
63 #define LINKSTATE_UP (1 << 2)
64 #define LINKSTATE_DOWN (1 << 3)
66 #define SS7_NAI_DYNAMIC -1
68 #define LINKSET_FLAG_EXPLICITACM (1 << 0)
72 SIG_SS7_TONE_RINGTONE = 0,
74 SIG_SS7_TONE_CONGESTION,
75 SIG_SS7_TONE_DIALTONE,
76 SIG_SS7_TONE_DIALRECALL,
87 /*! Call establishment life cycle level for simple comparisons. */
88 enum sig_ss7_call_level {
89 /*! Call does not exist. */
90 SIG_SS7_CALL_LEVEL_IDLE,
92 * Call is allocated to the channel.
93 * We have not sent or responded to IAM yet.
95 SIG_SS7_CALL_LEVEL_ALLOCATED,
97 * Call is performing continuity check after receiving IAM.
98 * We are waiting for COT to proceed further.
100 SIG_SS7_CALL_LEVEL_CONTINUITY,
103 * We have not seen a response or sent further call progress to an IAM yet.
105 SIG_SS7_CALL_LEVEL_SETUP,
107 * Call routing is happening.
108 * We have sent or received ACM.
110 SIG_SS7_CALL_LEVEL_PROCEEDING,
112 * Called party is being alerted of the call.
113 * We have sent or received CPG(ALERTING)/ACM(ALERTING).
115 SIG_SS7_CALL_LEVEL_ALERTING,
117 * Call is connected/answered.
118 * We have sent or received CON/ANM.
120 SIG_SS7_CALL_LEVEL_CONNECT,
121 /*! Call has collided with incoming call. */
122 SIG_SS7_CALL_LEVEL_GLARE,
125 struct sig_ss7_linkset;
127 struct sig_ss7_callback {
128 /* Unlock the private in the signaling private structure. */
129 void (* const unlock_private)(void *pvt);
130 /* Lock the private in the signaling private structure. */
131 void (* const lock_private)(void *pvt);
132 /* Do deadlock avoidance for the private signaling structure lock. */
133 void (* const deadlock_avoidance_private)(void *pvt);
135 int (* const set_echocanceller)(void *pvt, int enable);
136 void (* const set_loopback)(void *pvt, int enable);
138 struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor);
139 int (* const play_tone)(void *pvt, enum sig_ss7_tone tone);
141 void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which);
142 void (* const set_alarm)(void *pvt, int in_alarm);
143 void (* const set_dialing)(void *pvt, int is_dialing);
144 void (* const set_digital)(void *pvt, int is_digital);
145 void (* const set_inservice)(void *pvt, int is_inservice);
146 void (* const set_locallyblocked)(void *pvt, int is_blocked);
147 void (* const set_remotelyblocked)(void *pvt, int is_blocked);
148 void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
149 void (* const set_dnid)(void *pvt, const char *dnid);
151 void (* const queue_control)(void *pvt, int subclass);
154 struct sig_ss7_chan {
155 struct sig_ss7_callback *calls;
156 void *chan_pvt; /*!< Private structure of the user of this module. */
157 struct sig_ss7_linkset *ss7;
158 struct ast_channel *owner;
160 /*! \brief Opaque libss7 call control structure */
161 struct isup_call *ss7call;
163 /*! Call establishment life cycle level for simple comparisons. */
164 enum sig_ss7_call_level call_level;
166 int channel; /*!< Channel Number */
167 int cic; /*!< CIC associated with channel */
168 unsigned int dpc; /*!< CIC's DPC */
170 /* Options to be set by user */
172 * \brief Number of most significant digits/characters to strip from the dialed number.
173 * \note Feature is deprecated. Use dialplan logic.
177 * \brief TRUE if the outgoing caller ID is blocked/hidden.
179 unsigned int hidecallerid:1;
180 /*! \brief TRUE if caller ID is used on this channel. */
181 unsigned int use_callerid:1;
183 * \brief TRUE if we will use the calling presentation setting
184 * from the Asterisk channel for outgoing calls.
186 unsigned int use_callingpres:1;
187 unsigned int immediate:1; /*!< Answer before getting digits? */
189 /*! \brief TRUE if the channel is locally blocked. Set by user and link. */
190 unsigned int locallyblocked:1;
191 /*! \brief TRUE if the channel is remotely blocked. Set by user and link. */
192 unsigned int remotelyblocked:1;
194 char context[AST_MAX_CONTEXT];
195 char mohinterpret[MAX_MUSICCLASS];
197 /* Options to be checked by user */
198 int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
199 int cid_ton; /*!< Type Of Number (TON) */
200 int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
201 char cid_num[AST_MAX_EXTENSION];
202 char cid_subaddr[AST_MAX_EXTENSION];/*!< XXX SS7 may not support. */
203 char cid_name[AST_MAX_EXTENSION];
204 char cid_ani[AST_MAX_EXTENSION];
205 char exten[AST_MAX_EXTENSION];
207 /* Options to be checked by user that are stuffed into channel variables. */
208 char charge_number[50];
209 char gen_add_number[50];
210 char gen_dig_number[50];
211 char orig_called_num[50];
212 char redirecting_num[50];
213 char generic_name[50];
214 unsigned char gen_add_num_plan;
215 unsigned char gen_add_nai;
216 unsigned char gen_add_pres_ind;
217 unsigned char gen_add_type;
218 unsigned char gen_dig_type;
219 unsigned char gen_dig_scheme;
222 unsigned char lspi_type;
223 unsigned char lspi_scheme;
224 unsigned char lspi_context;
227 unsigned int call_ref_ident;
228 unsigned int call_ref_pc;
229 unsigned char calling_party_cat;
232 * Channel status bits.
234 /*! TRUE if channel is associated with a link that is down. */
235 unsigned int inalarm:1;
236 /*! TRUE if this channel is being used for an outgoing call. */
237 unsigned int outgoing:1;
238 /*! \brief TRUE if the call has seen inband-information progress through the network. */
239 unsigned int progress:1;
240 /*! \brief TRUE if the call has already gone/hungup */
241 unsigned int alreadyhungup:1;
242 /*! \brief XXX BOOLEAN Purpose??? */
244 /*! TRUE if this channel is in loopback. */
245 unsigned int loopedback:1;
248 struct sig_ss7_linkset {
249 pthread_t master; /*!< Thread of master */
250 ast_mutex_t lock; /*!< libss7 access lock */
251 struct sig_ss7_callback *calls;
253 struct sig_ss7_chan *pvts[SIG_SS7_MAX_CHANNELS];/*!< Member channel pvt structs */
254 int fds[SIG_SS7_NUM_DCHANS];
256 int linkstate[SIG_SS7_NUM_DCHANS];
258 int span; /*!< span number put into user output messages */
259 int debug; /*!< set to true if to dump SS7 event info */
261 LINKSET_STATE_DOWN = 0,
265 /* Options to be set by user */
266 int flags; /*!< Linkset flags (LINKSET_FLAG_EXPLICITACM) */
267 int type; /*!< SS7 type ITU/ANSI. Used for companding selection. */
268 char called_nai; /*!< Called Nature of Address Indicator */
269 char calling_nai; /*!< Calling Nature of Address Indicator */
270 char internationalprefix[10]; /*!< country access code ('00' for european dialplans) */
271 char nationalprefix[10]; /*!< area access code ('0' for european dialplans) */
272 char subscriberprefix[20]; /*!< area access code + area code ('0'+area code for european dialplans) */
273 char unknownprefix[20]; /*!< for unknown dialplans */
276 void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm);
278 void *ss7_linkset(void *data);
280 void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which);
281 void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which);
282 int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode);
284 int sig_ss7_available(struct sig_ss7_chan *p);
285 int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest);
286 int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast);
287 int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast);
288 void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan);
289 int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
290 struct ast_channel *sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability);
291 void sig_ss7_chan_delete(struct sig_ss7_chan *doomed);
292 struct sig_ss7_chan *sig_ss7_chan_new(void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7);
293 void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7);
295 void sig_ss7_cli_show_channels_header(int fd);
296 void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset);
299 /* ------------------------------------------------------------------- */
305 #endif /* _ASTERISK_SIG_SS7_H */
306 /* ------------------------------------------------------------------- */