Wed Jan 8 2020 09:49:51

Asterisk developer's documentation


sig_ss7.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2010 Digium, Inc.
5  *
6  * Richard Mudgett <rmudgett@digium.com>
7  *
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.
13  *
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.
17  */
18 
19 /*!
20  * \file
21  * \brief Interface header for SS7 signaling module.
22  *
23  * \author Matthew Fredrickson <creslin@digium.com>
24  * \author Richard Mudgett <rmudgett@digium.com>
25  *
26  * See Also:
27  * \arg \ref AstCREDITS
28  */
29 
30 #ifndef _ASTERISK_SIG_SS7_H
31 #define _ASTERISK_SIG_SS7_H
32 
33 #include "asterisk/channel.h"
34 #include <libss7.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* ------------------------------------------------------------------- */
41 
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)
45 
46 #if 0
47 /*! SS7 debug message flags set on initial startup. */
48 #define SIG_SS7_DEBUG_DEFAULT SIG_SS7_DEBUG
49 #else
50 /*! SS7 debug message flags set on initial startup. */
51 #define SIG_SS7_DEBUG_DEFAULT 0
52 #endif
53 
54 /* ------------------------------------------------------------------- */
55 
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 */
58 
59 #define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
60 
61 #define LINKSTATE_INALARM (1 << 0)
62 #define LINKSTATE_STARTING (1 << 1)
63 #define LINKSTATE_UP (1 << 2)
64 #define LINKSTATE_DOWN (1 << 3)
65 
66 #define SS7_NAI_DYNAMIC -1
67 
68 #define LINKSET_FLAG_EXPLICITACM (1 << 0)
69 
70 
79 };
80 
85 };
86 
87 /*! Call establishment life cycle level for simple comparisons. */
89  /*! Call does not exist. */
91  /*!
92  * Call is allocated to the channel.
93  * We have not sent or responded to IAM yet.
94  */
96  /*!
97  * Call is performing continuity check after receiving IAM.
98  * We are waiting for COT to proceed further.
99  */
101  /*!
102  * Call is present.
103  * We have not seen a response or sent further call progress to an IAM yet.
104  */
106  /*!
107  * Call routing is happening.
108  * We have sent or received ACM.
109  */
111  /*!
112  * Called party is being alerted of the call.
113  * We have sent or received CPG(ALERTING)/ACM(ALERTING).
114  */
116  /*!
117  * Call is connected/answered.
118  * We have sent or received CON/ANM.
119  */
121  /*! Call has collided with incoming call. */
123 };
124 
125 struct sig_ss7_linkset;
126 
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 
133  int (* const set_echocanceller)(void *pvt, int enable);
134  void (* const set_loopback)(void *pvt, int enable);
135 
136  struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor);
137  int (* const play_tone)(void *pvt, enum sig_ss7_tone tone);
138 
139  void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which);
140  void (* const set_alarm)(void *pvt, int in_alarm);
141  void (* const set_dialing)(void *pvt, int is_dialing);
142  void (* const set_digital)(void *pvt, int is_digital);
143  void (* const set_outgoing)(void *pvt, int is_outgoing);
144  void (* const set_inservice)(void *pvt, int is_inservice);
145  void (* const set_locallyblocked)(void *pvt, int is_blocked);
146  void (* const set_remotelyblocked)(void *pvt, int is_blocked);
147  void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
148  void (* const set_dnid)(void *pvt, const char *dnid);
149 
150  void (* const queue_control)(void *pvt, int subclass);
151  void (* const open_media)(void *pvt);
152 };
153 
154 struct sig_ss7_chan {
156  void *chan_pvt; /*!< Private structure of the user of this module. */
159 
160  /*! \brief Opaque libss7 call control structure */
161  struct isup_call *ss7call;
162 
163  /*! Call establishment life cycle level for simple comparisons. */
165 
166  int channel; /*!< Channel Number */
167  int cic; /*!< CIC associated with channel */
168  unsigned int dpc; /*!< CIC's DPC */
169 
170  /* Options to be set by user */
171  /*!
172  * \brief Number of most significant digits/characters to strip from the dialed number.
173  * \note Feature is deprecated. Use dialplan logic.
174  */
175  int stripmsd;
176  /*!
177  * \brief TRUE if the outgoing caller ID is blocked/hidden.
178  */
179  unsigned int hidecallerid:1;
180  /*! \brief TRUE if caller ID is used on this channel. */
181  unsigned int use_callerid:1;
182  /*!
183  * \brief TRUE if we will use the calling presentation setting
184  * from the Asterisk channel for outgoing calls.
185  */
186  unsigned int use_callingpres:1;
187  unsigned int immediate:1; /*!< Answer before getting digits? */
188 
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;
193 
196 
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 */
202  char cid_subaddr[AST_MAX_EXTENSION];/*!< XXX SS7 may not support. */
206 
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;
220  char jip_number[50];
221 #if 0
222  unsigned char lspi_type;
223  unsigned char lspi_scheme;
224  unsigned char lspi_context;
225 #endif
226  char lspi_ident[50];
227  unsigned int call_ref_ident;
228  unsigned int call_ref_pc;
229  unsigned char calling_party_cat;
230 
231  /*
232  * Channel status bits.
233  */
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??? */
243  unsigned int rlt:1;
244  /*! TRUE if this channel is in loopback. */
245  unsigned int loopedback:1;
246 };
247 
249  pthread_t master; /*!< Thread of master */
250  ast_mutex_t lock; /*!< libss7 access lock */
252  struct ss7 *ss7;
253  struct sig_ss7_chan *pvts[SIG_SS7_MAX_CHANNELS];/*!< Member channel pvt structs */
257  int numchans;
258  int span; /*!< span number put into user output messages */
259  int debug; /*!< set to true if to dump SS7 event info */
260  enum {
263  } state;
264 
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 */
274 };
275 
276 void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm);
277 
278 void *ss7_linkset(void *data);
279 
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);
283 
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);
294 
296 void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset);
297 
298 
299 /* ------------------------------------------------------------------- */
300 
301 #ifdef __cplusplus
302 }
303 #endif
304 
305 #endif /* _ASTERISK_SIG_SS7_H */
306 /* ------------------------------------------------------------------- */
307 /* end sig_ss7.h */
unsigned char gen_add_pres_ind
Definition: sig_ss7.h:216
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:109
void(*const set_callerid)(void *pvt, const struct ast_party_caller *caller)
Definition: sig_ss7.h:147
Main Channel structure associated with a channel.
Definition: channel.h:742
char calling_nai
Definition: sig_ss7.h:269
struct sig_ss7_callback * calls
Definition: sig_ss7.h:251
int cid_ton
Definition: sig_ss7.h:199
unsigned int alreadyhungup
TRUE if the call has already gone/hungup.
Definition: sig_ss7.h:241
unsigned int call_ref_pc
Definition: sig_ss7.h:228
enum sig_ss7_call_level call_level
Definition: sig_ss7.h:164
int sig_ss7_available(struct sig_ss7_chan *p)
unsigned char gen_dig_type
Definition: sig_ss7.h:218
unsigned int dpc
Definition: sig_ss7.h:168
int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen)
unsigned char gen_add_num_plan
Definition: sig_ss7.h:214
void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset)
unsigned int hidecallerid
TRUE if the outgoing caller ID is blocked/hidden.
Definition: sig_ss7.h:179
#define MAX_MUSICCLASS
Definition: channel.h:139
sig_ss7_call_level
Definition: sig_ss7.h:88
char unknownprefix[20]
Definition: sig_ss7.h:273
void(*const unlock_private)(void *pvt)
Definition: sig_ss7.h:129
enum sig_ss7_linkset::@121 state
int callingpres
Definition: sig_ss7.h:200
int channel
Definition: sig_ss7.h:166
unsigned int loopedback
Definition: sig_ss7.h:245
struct sig_ss7_linkset * ss7
Definition: sig_ss7.h:157
char gen_add_number[50]
Definition: sig_ss7.h:209
unsigned int inalarm
Definition: sig_ss7.h:235
pthread_t master
Definition: sig_ss7.h:249
unsigned short transfercapability
Definition: channel.h:863
char redirecting_num[50]
Definition: sig_ss7.h:212
unsigned char gen_dig_scheme
Definition: sig_ss7.h:219
Definition: dsp.c:105
char exten[AST_MAX_EXTENSION]
Definition: sig_ss7.h:205
int(*const set_echocanceller)(void *pvt, int enable)
Definition: sig_ss7.h:133
char lspi_ident[50]
Definition: sig_ss7.h:226
void(*const open_media)(void *pvt)
Definition: sig_ss7.h:151
int(*const play_tone)(void *pvt, enum sig_ss7_tone tone)
Definition: sig_ss7.h:137
struct sig_ss7_chan * sig_ss7_chan_new(void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7)
char cid_subaddr[AST_MAX_EXTENSION]
Definition: sig_ss7.h:202
char cid_name[AST_MAX_EXTENSION]
Definition: sig_ss7.h:203
struct sig_ss7_callback * calls
Definition: sig_ss7.h:155
unsigned int use_callingpres
TRUE if we will use the calling presentation setting from the Asterisk channel for outgoing calls...
Definition: sig_ss7.h:186
struct ss7 * ss7
Definition: sig_ss7.h:252
#define SIG_SS7_MAX_CHANNELS
Definition: sig_ss7.h:57
unsigned int remotelyblocked
TRUE if the channel is remotely blocked. Set by user and link.
Definition: sig_ss7.h:192
ast_mutex_t lock
Definition: sig_ss7.h:250
char context[AST_MAX_CONTEXT]
Definition: sig_ss7.h:194
unsigned int use_callerid
TRUE if caller ID is used on this channel.
Definition: sig_ss7.h:181
void(*const set_dialing)(void *pvt, int is_dialing)
Definition: sig_ss7.h:141
General Asterisk PBX channel definitions.
int stripmsd
Number of most significant digits/characters to strip from the dialed number.
Definition: sig_ss7.h:175
void(*const queue_control)(void *pvt, int subclass)
Definition: sig_ss7.h:150
void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which)
#define AST_MAX_EXTENSION
Definition: channel.h:135
void(*const set_alarm)(void *pvt, int in_alarm)
Definition: sig_ss7.h:140
void sig_ss7_cli_show_channels_header(int fd)
Caller Party information.
Definition: channel.h:368
char generic_name[50]
Definition: sig_ss7.h:213
void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm)
void(*const set_loopback)(void *pvt, int enable)
Definition: sig_ss7.h:134
void * chan_pvt
Definition: sig_ss7.h:156
char mohinterpret[MAX_MUSICCLASS]
Definition: sig_ss7.h:195
void(*const set_locallyblocked)(void *pvt, int is_blocked)
Definition: sig_ss7.h:145
char subscriberprefix[20]
Definition: sig_ss7.h:272
int cid_ani2
Definition: sig_ss7.h:198
char charge_number[50]
Definition: sig_ss7.h:208
void(*const set_digital)(void *pvt, int is_digital)
Definition: sig_ss7.h:142
struct sig_ss7_chan * pvts[SIG_SS7_MAX_CHANNELS]
Definition: sig_ss7.h:253
int fds[SIG_SS7_NUM_DCHANS]
Definition: sig_ss7.h:254
char orig_called_num[50]
Definition: sig_ss7.h:211
void(*const handle_link_exception)(struct sig_ss7_linkset *linkset, int which)
Definition: sig_ss7.h:139
#define SIG_SS7_NUM_DCHANS
Definition: sig_ss7.h:56
void(*const set_remotelyblocked)(void *pvt, int is_blocked)
Definition: sig_ss7.h:146
unsigned int rlt
XXX BOOLEAN Purpose???
Definition: sig_ss7.h:243
sig_ss7_tone
Definition: sig_ss7.h:71
unsigned char gen_add_type
Definition: sig_ss7.h:217
int linkstate[SIG_SS7_NUM_DCHANS]
Definition: sig_ss7.h:256
void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7)
unsigned int call_ref_ident
Definition: sig_ss7.h:227
#define AST_MAX_CONTEXT
Definition: channel.h:136
char called_nai
Definition: sig_ss7.h:268
void(*const set_dnid)(void *pvt, const char *dnid)
Definition: sig_ss7.h:148
struct ast_channel * sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability)
char jip_number[50]
Definition: sig_ss7.h:220
void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which)
char cid_num[AST_MAX_EXTENSION]
Definition: sig_ss7.h:201
char nationalprefix[10]
Definition: sig_ss7.h:271
int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest)
unsigned int locallyblocked
TRUE if the channel is locally blocked. Set by user and link.
Definition: sig_ss7.h:190
unsigned int immediate
Definition: sig_ss7.h:187
void(*const set_inservice)(void *pvt, int is_inservice)
Definition: sig_ss7.h:144
void sig_ss7_chan_delete(struct sig_ss7_chan *doomed)
int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast)
int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode)
char gen_dig_number[50]
Definition: sig_ss7.h:210
struct ast_channel * owner
Definition: sig_ss7.h:158
char internationalprefix[10]
Definition: sig_ss7.h:270
struct isup_call * ss7call
Opaque libss7 call control structure.
Definition: sig_ss7.h:161
int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast)
char cid_ani[AST_MAX_EXTENSION]
Definition: sig_ss7.h:204
struct ast_channel *(*const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor)
Definition: sig_ss7.h:136
void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan)
unsigned char gen_add_nai
Definition: sig_ss7.h:215
void(*const lock_private)(void *pvt)
Definition: sig_ss7.h:131
sig_ss7_law
Definition: sig_ss7.h:81
void(*const set_outgoing)(void *pvt, int is_outgoing)
Definition: sig_ss7.h:143
void * ss7_linkset(void *data)
Structure for mutex and tracking information.
Definition: lock.h:121
unsigned char calling_party_cat
Definition: sig_ss7.h:229