| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 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 |
|
| 43 |
#define SIG_SS7_DEBUG \ |
| 44 |
(SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP) |
| 45 |
|
| 46 |
#if 0 |
| 47 |
|
| 48 |
#define SIG_SS7_DEBUG_DEFAULT SIG_SS7_DEBUG |
| 49 |
#else |
| 50 |
|
| 51 |
#define SIG_SS7_DEBUG_DEFAULT 0 |
| 52 |
#endif |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#define SIG_SS7_NUM_DCHANS 4 |
| 57 |
#define SIG_SS7_MAX_CHANNELS 672 |
| 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 |
#define LINKSET_FLAG_INITIALHWBLO (1 << 1) |
| 70 |
#define LINKSET_FLAG_USEECHOCONTROL (1 << 2) |
| 71 |
#define LINKSET_FLAG_DEFAULTECHOCONTROL (1 << 3) |
| 72 |
#define LINKSET_FLAG_AUTOACM (1 << 4) |
| 73 |
|
| 74 |
#define SS7_BLOCKED_MAINTENANCE (1 << 0) |
| 75 |
#define SS7_BLOCKED_HARDWARE (1 << 1) |
| 76 |
|
| 77 |
|
| 78 |
enum sig_ss7_tone { |
| 79 |
SIG_SS7_TONE_RINGTONE = 0, |
| 80 |
SIG_SS7_TONE_STUTTER, |
| 81 |
SIG_SS7_TONE_CONGESTION, |
| 82 |
SIG_SS7_TONE_DIALTONE, |
| 83 |
SIG_SS7_TONE_DIALRECALL, |
| 84 |
SIG_SS7_TONE_INFO, |
| 85 |
SIG_SS7_TONE_BUSY, |
| 86 |
}; |
| 87 |
|
| 88 |
enum sig_ss7_law { |
| 89 |
SIG_SS7_DEFLAW = 0, |
| 90 |
SIG_SS7_ULAW, |
| 91 |
SIG_SS7_ALAW |
| 92 |
}; |
| 93 |
|
| 94 |
enum sig_ss7_redirect_indication { |
| 95 |
SS7_INDICATION_NO_REDIRECTION = 0, |
| 96 |
SS7_INDICATION_REROUTED_PRES_ALLOWED, |
| 97 |
SS7_INDICATION_REROUTED_INFO_RESTRICTED, |
| 98 |
SS7_INDICATION_DIVERTED_PRES_ALLOWED, |
| 99 |
SS7_INDICATION_DIVERTED_INFO_RESTRICTED, |
| 100 |
SS7_INDICATION_REROUTED_PRES_RESTRICTED, |
| 101 |
SS7_INDICATION_DIVERTED_PRES_RESTRICTED, |
| 102 |
SS7_INDICATION_SPARE |
| 103 |
}; |
| 104 |
|
| 105 |
enum sig_ss7_redirect_reason { |
| 106 |
SS7_REDIRECTING_REASON_UNKNOWN = 0, |
| 107 |
SS7_REDIRECTING_REASON_USER_BUSY, |
| 108 |
SS7_REDIRECTING_REASON_NO_ANSWER, |
| 109 |
SS7_REDIRECTING_REASON_UNCONDITIONAL, |
| 110 |
SS7_REDIRECTING_REASON_DEFLECTION_DURING_ALERTING, |
| 111 |
SS7_REDIRECTING_REASON_DEFLECTION_IMMEDIATE_RESPONSE, |
| 112 |
SS7_REDIRECTING_REASON_UNAVAILABLE |
| 113 |
}; |
| 114 |
|
| 115 |
|
| 116 |
enum sig_ss7_call_level { |
| 117 |
|
| 118 |
SIG_SS7_CALL_LEVEL_IDLE, |
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
SIG_SS7_CALL_LEVEL_ALLOCATED, |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
SIG_SS7_CALL_LEVEL_CONTINUITY, |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
SIG_SS7_CALL_LEVEL_SETUP, |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
SIG_SS7_CALL_LEVEL_PROCEEDING, |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
SIG_SS7_CALL_LEVEL_ALERTING, |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
SIG_SS7_CALL_LEVEL_CONNECT, |
| 149 |
}; |
| 150 |
|
| 151 |
struct sig_ss7_linkset; |
| 152 |
|
| 153 |
struct sig_ss7_callback { |
| 154 |
|
| 155 |
void (* const unlock_private)(void *pvt); |
| 156 |
|
| 157 |
void (* const lock_private)(void *pvt); |
| 158 |
|
| 159 |
void (* const deadlock_avoidance_private)(void *pvt); |
| 160 |
|
| 161 |
int (* const set_echocanceller)(void *pvt, int enable); |
| 162 |
void (* const set_loopback)(void *pvt, int enable); |
| 163 |
|
| 164 |
struct ast_channel * (* const new_ast_channel)(void *pvt, int state, |
| 165 |
enum sig_ss7_law law, char *exten, const struct ast_assigned_ids *assignedids, |
| 166 |
const struct ast_channel *requestor); |
| 167 |
int (* const play_tone)(void *pvt, enum sig_ss7_tone tone); |
| 168 |
|
| 169 |
void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which); |
| 170 |
void (* const set_alarm)(void *pvt, int in_alarm); |
| 171 |
void (* const set_dialing)(void *pvt, int is_dialing); |
| 172 |
void (* const set_digital)(void *pvt, int is_digital); |
| 173 |
void (* const set_outgoing)(void *pvt, int is_outgoing); |
| 174 |
void (* const set_inservice)(void *pvt, int is_inservice); |
| 175 |
void (* const set_locallyblocked)(void *pvt, int is_blocked); |
| 176 |
void (* const set_remotelyblocked)(void *pvt, int is_blocked); |
| 177 |
void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller); |
| 178 |
void (* const set_dnid)(void *pvt, const char *dnid); |
| 179 |
|
| 180 |
void (* const queue_control)(void *pvt, int subclass); |
| 181 |
void (* const open_media)(void *pvt); |
| 182 |
|
| 183 |
struct sig_ss7_linkset *(* const find_linkset)(struct ss7 *ss7); |
| 184 |
}; |
| 185 |
|
| 186 |
|
| 187 |
extern struct sig_ss7_callback sig_ss7_callbacks; |
| 188 |
|
| 189 |
struct sig_ss7_chan { |
| 190 |
void *chan_pvt; |
| 191 |
struct sig_ss7_linkset *ss7; |
| 192 |
struct ast_channel *owner; |
| 193 |
|
| 194 |
|
| 195 |
struct isup_call *ss7call; |
| 196 |
|
| 197 |
|
| 198 |
enum sig_ss7_call_level call_level; |
| 199 |
|
| 200 |
int channel; |
| 201 |
int cic; |
| 202 |
unsigned int dpc; |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
int stripmsd; |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
unsigned int hidecallerid:1; |
| 214 |
|
| 215 |
unsigned int use_callerid:1; |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
unsigned int use_callingpres:1; |
| 221 |
unsigned int immediate:1; |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
unsigned int locallyblocked:2; |
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
unsigned int remotelyblocked:2; |
| 236 |
|
| 237 |
char context[AST_MAX_CONTEXT]; |
| 238 |
char mohinterpret[MAX_MUSICCLASS]; |
| 239 |
|
| 240 |
|
| 241 |
int cid_ani2; |
| 242 |
int cid_ton; |
| 243 |
int callingpres; |
| 244 |
char cid_num[AST_MAX_EXTENSION]; |
| 245 |
char cid_subaddr[AST_MAX_EXTENSION]; |
| 246 |
char cid_name[AST_MAX_EXTENSION]; |
| 247 |
char cid_ani[AST_MAX_EXTENSION]; |
| 248 |
char exten[AST_MAX_EXTENSION]; |
| 249 |
|
| 250 |
|
| 251 |
char charge_number[50]; |
| 252 |
char gen_add_number[50]; |
| 253 |
char gen_dig_number[50]; |
| 254 |
char orig_called_num[50]; |
| 255 |
int orig_called_presentation; |
| 256 |
char redirecting_num[50]; |
| 257 |
int redirecting_presentation; |
| 258 |
unsigned char redirect_counter; |
| 259 |
unsigned char redirect_info; |
| 260 |
unsigned char redirect_info_ind; |
| 261 |
unsigned char redirect_info_orig_reas; |
| 262 |
unsigned char redirect_info_counter; |
| 263 |
unsigned char redirect_info_reas; |
| 264 |
char generic_name[50]; |
| 265 |
unsigned char gen_add_num_plan; |
| 266 |
unsigned char gen_add_nai; |
| 267 |
unsigned char gen_add_pres_ind; |
| 268 |
unsigned char gen_add_type; |
| 269 |
unsigned char gen_dig_type; |
| 270 |
unsigned char gen_dig_scheme; |
| 271 |
char jip_number[50]; |
| 272 |
#if 0 |
| 273 |
unsigned char lspi_type; |
| 274 |
unsigned char lspi_scheme; |
| 275 |
unsigned char lspi_context; |
| 276 |
#endif |
| 277 |
char lspi_ident[50]; |
| 278 |
unsigned int call_ref_ident; |
| 279 |
unsigned int call_ref_pc; |
| 280 |
unsigned char calling_party_cat; |
| 281 |
unsigned int do_hangup; |
| 282 |
unsigned int echocontrol_ind; |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
unsigned int inalarm:1; |
| 289 |
|
| 290 |
unsigned int inservice:1; |
| 291 |
|
| 292 |
unsigned int outgoing:1; |
| 293 |
|
| 294 |
unsigned int called_complete:1; |
| 295 |
|
| 296 |
unsigned int progress:1; |
| 297 |
|
| 298 |
unsigned int rlt:1; |
| 299 |
|
| 300 |
unsigned int loopedback:1; |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
char cug_interlock_ni[5]; |
| 307 |
|
| 308 |
unsigned short cug_interlock_code; |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
unsigned char cug_indicator; |
| 316 |
}; |
| 317 |
|
| 318 |
struct sig_ss7_linkset { |
| 319 |
pthread_t master; |
| 320 |
ast_mutex_t lock; |
| 321 |
struct ss7 *ss7; |
| 322 |
struct sig_ss7_chan *pvts[SIG_SS7_MAX_CHANNELS]; |
| 323 |
int fds[SIG_SS7_NUM_DCHANS]; |
| 324 |
int numsigchans; |
| 325 |
int linkstate[SIG_SS7_NUM_DCHANS]; |
| 326 |
int numchans; |
| 327 |
int span; |
| 328 |
int debug; |
| 329 |
enum { |
| 330 |
LINKSET_STATE_DOWN = 0, |
| 331 |
LINKSET_STATE_UP |
| 332 |
} state; |
| 333 |
|
| 334 |
|
| 335 |
int flags; |
| 336 |
int type; |
| 337 |
char called_nai; |
| 338 |
char calling_nai; |
| 339 |
char internationalprefix[10]; |
| 340 |
char nationalprefix[10]; |
| 341 |
char subscriberprefix[20]; |
| 342 |
char unknownprefix[20]; |
| 343 |
char networkroutedprefix[20]; |
| 344 |
}; |
| 345 |
|
| 346 |
void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm); |
| 347 |
|
| 348 |
void *ss7_linkset(void *data); |
| 349 |
|
| 350 |
void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which); |
| 351 |
void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which); |
| 352 |
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 cur_slc); |
| 353 |
|
| 354 |
int sig_ss7_reset_cic(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc); |
| 355 |
int sig_ss7_reset_group(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc, int range); |
| 356 |
int sig_ss7_cic_blocking(struct sig_ss7_linkset *linkset, int do_block, int cic); |
| 357 |
int sig_ss7_group_blocking(struct sig_ss7_linkset *linkset, int do_block, int startcic, int endcic, unsigned char state[], int type); |
| 358 |
|
| 359 |
int sig_ss7_available(struct sig_ss7_chan *p); |
| 360 |
int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, const char *rdest); |
| 361 |
int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast); |
| 362 |
int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast); |
| 363 |
int sig_ss7_find_cic(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc); |
| 364 |
int sig_ss7_find_cic_range(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc); |
| 365 |
void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan); |
| 366 |
int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen); |
| 367 |
struct ast_channel *sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, |
| 368 |
const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, |
| 369 |
int transfercapability); |
| 370 |
void sig_ss7_chan_delete(struct sig_ss7_chan *doomed); |
| 371 |
struct sig_ss7_chan *sig_ss7_chan_new(void *pvt_data, struct sig_ss7_linkset *ss7); |
| 372 |
void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7); |
| 373 |
void sig_ss7_free_isup_call(struct sig_ss7_linkset *linkset, int channel); |
| 374 |
|
| 375 |
void sig_ss7_cli_show_channels_header(int fd); |
| 376 |
void sig_ss7_cli_show_channels(int fd, struct sig_ss7_linkset *linkset); |
| 377 |
|
| 378 |
int sig_ss7_cb_hangup(struct ss7 *ss7, int cic, unsigned int dpc, int cause, int do_hangup); |
| 379 |
void sig_ss7_cb_call_null(struct ss7 *ss7, struct isup_call *c, int lock); |
| 380 |
void sig_ss7_cb_notinservice(struct ss7 *ss7, int cic, unsigned int dpc); |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
#ifdef __cplusplus |
| 385 |
} |
| 386 |
#endif |
| 387 |
|
| 388 |
#endif |
| 389 |
|
| 390 |
|