00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _ASTERISK_SIG_SS7_H
00031 #define _ASTERISK_SIG_SS7_H
00032
00033 #include "asterisk/channel.h"
00034 #include <libss7.h>
00035
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039
00040
00041
00042
00043 #define SIG_SS7_DEBUG \
00044 (SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP)
00045
00046 #if 0
00047
00048 #define SIG_SS7_DEBUG_DEFAULT SIG_SS7_DEBUG
00049 #else
00050
00051 #define SIG_SS7_DEBUG_DEFAULT 0
00052 #endif
00053
00054
00055
00056 #define SIG_SS7_NUM_DCHANS 4
00057 #define SIG_SS7_MAX_CHANNELS 672
00058
00059 #define SIG_SS7 (0x1000000 | DAHDI_SIG_CLEAR)
00060
00061 #define LINKSTATE_INALARM (1 << 0)
00062 #define LINKSTATE_STARTING (1 << 1)
00063 #define LINKSTATE_UP (1 << 2)
00064 #define LINKSTATE_DOWN (1 << 3)
00065
00066 #define SS7_NAI_DYNAMIC -1
00067
00068 #define LINKSET_FLAG_EXPLICITACM (1 << 0)
00069
00070
00071 enum sig_ss7_tone {
00072 SIG_SS7_TONE_RINGTONE = 0,
00073 SIG_SS7_TONE_STUTTER,
00074 SIG_SS7_TONE_CONGESTION,
00075 SIG_SS7_TONE_DIALTONE,
00076 SIG_SS7_TONE_DIALRECALL,
00077 SIG_SS7_TONE_INFO,
00078 SIG_SS7_TONE_BUSY,
00079 };
00080
00081 enum sig_ss7_law {
00082 SIG_SS7_DEFLAW = 0,
00083 SIG_SS7_ULAW,
00084 SIG_SS7_ALAW
00085 };
00086
00087 struct sig_ss7_linkset;
00088
00089 struct sig_ss7_callback {
00090
00091 void (* const unlock_private)(void *pvt);
00092
00093 void (* const lock_private)(void *pvt);
00094
00095 int (* const set_echocanceller)(void *pvt, int enable);
00096 void (* const set_loopback)(void *pvt, int enable);
00097
00098 struct ast_channel * (* const new_ast_channel)(void *pvt, int state, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor);
00099 int (* const play_tone)(void *pvt, enum sig_ss7_tone tone);
00100
00101 void (* const handle_link_exception)(struct sig_ss7_linkset *linkset, int which);
00102 void (* const set_alarm)(void *pvt, int in_alarm);
00103 void (* const set_dialing)(void *pvt, int is_dialing);
00104 void (* const set_digital)(void *pvt, int is_digital);
00105 void (* const set_inservice)(void *pvt, int is_inservice);
00106 void (* const set_locallyblocked)(void *pvt, int is_blocked);
00107 void (* const set_remotelyblocked)(void *pvt, int is_blocked);
00108 void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
00109 void (* const set_dnid)(void *pvt, const char *dnid);
00110
00111 void (* const queue_control)(void *pvt, int subclass);
00112 };
00113
00114 struct sig_ss7_chan {
00115 struct sig_ss7_callback *calls;
00116 void *chan_pvt;
00117 struct sig_ss7_linkset *ss7;
00118 struct ast_channel *owner;
00119
00120
00121 struct isup_call *ss7call;
00122
00123 int channel;
00124 int cic;
00125 unsigned int dpc;
00126
00127
00128
00129
00130
00131
00132 int stripmsd;
00133
00134
00135
00136 unsigned int hidecallerid:1;
00137
00138 unsigned int use_callerid:1;
00139
00140
00141
00142
00143 unsigned int use_callingpres:1;
00144 unsigned int immediate:1;
00145
00146
00147 unsigned int locallyblocked:1;
00148
00149 unsigned int remotelyblocked:1;
00150
00151 char context[AST_MAX_CONTEXT];
00152 char mohinterpret[MAX_MUSICCLASS];
00153
00154
00155 int cid_ani2;
00156 int cid_ton;
00157 int callingpres;
00158 char cid_num[AST_MAX_EXTENSION];
00159 char cid_subaddr[AST_MAX_EXTENSION];
00160 char cid_name[AST_MAX_EXTENSION];
00161 char cid_ani[AST_MAX_EXTENSION];
00162 char exten[AST_MAX_EXTENSION];
00163
00164
00165 char charge_number[50];
00166 char gen_add_number[50];
00167 char gen_dig_number[50];
00168 char orig_called_num[50];
00169 char redirecting_num[50];
00170 char generic_name[50];
00171 unsigned char gen_add_num_plan;
00172 unsigned char gen_add_nai;
00173 unsigned char gen_add_pres_ind;
00174 unsigned char gen_add_type;
00175 unsigned char gen_dig_type;
00176 unsigned char gen_dig_scheme;
00177 char jip_number[50];
00178 #if 0
00179 unsigned char lspi_type;
00180 unsigned char lspi_scheme;
00181 unsigned char lspi_context;
00182 #endif
00183 char lspi_ident[50];
00184 unsigned int call_ref_ident;
00185 unsigned int call_ref_pc;
00186 unsigned char calling_party_cat;
00187
00188
00189
00190
00191
00192 unsigned int inalarm:1;
00193
00194 unsigned int outgoing:1;
00195
00196
00197
00198
00199 unsigned int proceeding:1;
00200
00201 unsigned int progress:1;
00202
00203 unsigned int alerting:1;
00204
00205 unsigned int alreadyhungup:1;
00206
00207 unsigned int rlt:1;
00208
00209 unsigned int loopedback:1;
00210 };
00211
00212 struct sig_ss7_linkset {
00213 pthread_t master;
00214 ast_mutex_t lock;
00215 struct sig_ss7_callback *calls;
00216 struct ss7 *ss7;
00217 struct sig_ss7_chan *pvts[SIG_SS7_MAX_CHANNELS];
00218 int fds[SIG_SS7_NUM_DCHANS];
00219 int numsigchans;
00220 int linkstate[SIG_SS7_NUM_DCHANS];
00221 int numchans;
00222 int span;
00223 enum {
00224 LINKSET_STATE_DOWN = 0,
00225 LINKSET_STATE_UP
00226 } state;
00227
00228
00229 int flags;
00230 int type;
00231 char called_nai;
00232 char calling_nai;
00233 char internationalprefix[10];
00234 char nationalprefix[10];
00235 char subscriberprefix[20];
00236 char unknownprefix[20];
00237 };
00238
00239 void sig_ss7_set_alarm(struct sig_ss7_chan *p, int in_alarm);
00240
00241 void *ss7_linkset(void *data);
00242
00243 void sig_ss7_link_alarm(struct sig_ss7_linkset *linkset, int which);
00244 void sig_ss7_link_noalarm(struct sig_ss7_linkset *linkset, int which);
00245 int sig_ss7_add_sigchan(struct sig_ss7_linkset *linkset, int which, int ss7type, int transport, int inalarm, int networkindicator, int pointcode, int adjpointcode);
00246
00247 int sig_ss7_available(struct sig_ss7_chan *p);
00248 int sig_ss7_call(struct sig_ss7_chan *p, struct ast_channel *ast, char *rdest);
00249 int sig_ss7_hangup(struct sig_ss7_chan *p, struct ast_channel *ast);
00250 int sig_ss7_answer(struct sig_ss7_chan *p, struct ast_channel *ast);
00251 void sig_ss7_fixup(struct ast_channel *oldchan, struct ast_channel *newchan, struct sig_ss7_chan *pchan);
00252 int sig_ss7_indicate(struct sig_ss7_chan *p, struct ast_channel *chan, int condition, const void *data, size_t datalen);
00253 struct ast_channel *sig_ss7_request(struct sig_ss7_chan *p, enum sig_ss7_law law, const struct ast_channel *requestor, int transfercapability);
00254 void sig_ss7_chan_delete(struct sig_ss7_chan *doomed);
00255 struct sig_ss7_chan *sig_ss7_chan_new(void *pvt_data, struct sig_ss7_callback *callback, struct sig_ss7_linkset *ss7);
00256 void sig_ss7_init_linkset(struct sig_ss7_linkset *ss7);
00257
00258
00259
00260
00261 #ifdef __cplusplus
00262 }
00263 #endif
00264
00265 #endif
00266
00267