73 #include "chan_ooh323.h"
77 #define IPTOS_MINCOST 0x02
80 #define FORMAT_STRING_SIZE 512
83 #define DEFAULT_CONTEXT "default"
84 #define DEFAULT_H323ID "Asterisk PBX"
85 #define DEFAULT_LOGFILE "h323_log"
86 #define DEFAULT_H323ACCNT "ast_h323"
89 #define H323_SILENCESUPPRESSION (1<<0)
90 #define H323_GKROUTED (1<<1)
91 #define H323_TUNNELING (1<<2)
92 #define H323_FASTSTART (1<<3)
93 #define H323_OUTGOING (1<<4)
94 #define H323_ALREADYGONE (1<<5)
95 #define H323_NEEDDESTROY (1<<6)
96 #define H323_DISABLEGK (1<<7)
97 #define H323_NEEDSTART (1<<8)
100 #define T38TOAUDIOTIMEOUT 30
101 #define T38_DISABLED 0
102 #define T38_ENABLED 1
105 #define FAXDETECT_CNG 1
106 #define FAXDETECT_T38 2
109 static const char type[] =
"OOH323";
110 static const char tdesc[] =
"Objective Systems H323 Channel Driver";
111 static const char config[] =
"ooh323.conf";
119 .resync_threshold = -1,
127 static int ooh323_digit_begin(
struct ast_channel *ast,
char digit);
128 static int ooh323_digit_end(
struct ast_channel *ast,
char digit,
unsigned int duration);
129 static int ooh323_call(
struct ast_channel *ast,
const char *dest,
int timeout);
137 static int function_ooh323_read(
struct ast_channel *chan,
const char *cmd,
char *
data,
char *buf,
size_t len);
138 static int function_ooh323_write(
struct ast_channel *chan,
const char *cmd,
char *
data,
const char *value);
145 void setup_rtp_remote(ooCallData *call,
const char *remoteIp,
int remotePort);
147 struct ooh323_peer *find_friend(
const char *name,
int port);
152 .description = tdesc,
154 .requester = ooh323_request,
155 .send_digit_begin = ooh323_digit_begin,
156 .send_digit_end = ooh323_digit_end,
158 .hangup = ooh323_hangup,
159 .answer = ooh323_answer,
161 .write = ooh323_write,
162 .exception = ooh323_read,
163 .indicate = ooh323_indicate,
164 .fixup = ooh323_fixup,
166 .queryoption = ooh323_queryoption,
168 .func_channel_read = function_ooh323_read,
169 .func_channel_write = function_ooh323_write,
174 .get_rtp_info = ooh323_get_rtp_peer,
175 .get_vrtp_info = ooh323_get_vrtp_peer,
176 .update_peer = ooh323_set_rtp_peer,
177 .get_codec = ooh323_get_codec,
211 unsigned int call_reference;
220 char caller_url[256];
234 char accountcode[256];
243 struct OOH323Regex *rtpmask;
244 char rtpmaskstr[120];
245 int rtdrcount, rtdrinterval;
246 int faststart, h245tunneling;
252 AST_MUTEX_DEFINE_STATIC(
iflock);
261 char accountcode[20];
271 struct OOH323Regex *rtpmask;
272 char rtpmaskstr[120];
273 int rtdrcount, rtdrinterval;
275 int faststart, h245tunneling;
287 unsigned outgoinglimit;
290 char accountcode[20];
304 struct OOH323Regex *rtpmask;
305 char rtpmaskstr[120];
306 int rtdrcount,rtdrinterval;
308 int faststart, h245tunneling;
328 static int h323_reloading = 0;
329 AST_MUTEX_DEFINE_STATIC(h323_reload_lock);
332 static int usecnt = 0;
333 AST_MUTEX_DEFINE_STATIC(usecnt_lock);
335 static long callnumber = 0;
336 AST_MUTEX_DEFINE_STATIC(ooh323c_cn_lock);
339 int onAlerting(ooCallData *call);
340 int onProgress(ooCallData *call);
341 int onNewCallCreated(ooCallData *call);
342 int onOutgoingCall(ooCallData *call);
343 int onCallEstablished(ooCallData *call);
344 int onCallCleared(ooCallData *call);
345 void onModeChanged(ooCallData *call,
int t38mode);
347 extern OOH323EndPoint gH323ep;
349 static char gLogFile[PATH_MAX] = DEFAULT_LOGFILE;
350 static char gInitError[256] =
"";
351 static int gPort = 1720;
352 static char gIP[2+8*4+7];
356 static struct ooAliases *gAliasList;
358 static int gDTMFMode = H323_DTMF_RFC2833;
359 static int gDTMFCodec = 101;
360 static int gFAXdetect = FAXDETECT_CNG;
361 static int gT38Support = T38_FAXGW;
362 static char gGatekeeper[100];
363 static char gRASIP[2+8*4+7];
364 static enum RasGatekeeperMode gRasGkMode = RasNoGatekeeper;
366 static int gIsGateway = 0;
367 static int gFastStart = 1;
368 static int gTunneling = 1;
369 static int gBeMaster = 0;
370 static int gMediaWaitForConnect = 0;
371 static int gDirectRTP = 0;
372 static int gEarlyDirect = 0;
374 static int gRTPTimeout = 60;
375 static int g729onlyA = 0;
376 static char gAccountcode[80] = DEFAULT_H323ACCNT;
377 static int gAMAFLAGS;
379 static int gIncomingLimit = 1024;
380 static int gOutgoingLimit = 1024;
381 OOBOOL gH323Debug = FALSE;
382 static int gTRCLVL = OOTRCLVLERR;
383 static int gRTDRCount = 0, gRTDRInterval = 0;
384 static int gNat = FALSE;
385 static int gANIasDNI = 0;
387 static int t35countrycode = 0;
388 static int t35extensions = 0;
389 static int manufacturer = 0;
405 AST_MUTEX_DEFINE_STATIC(
monlock);
423 ast_verb(0,
"--- ooh323_new - %s\n", host);
429 ast_mutex_unlock(&i->lock);
430 ast_mutex_lock(&ooh323c_cn_lock);
432 i->accountcode, i->exten, i->context, assignedids, requestor, i->amaflags,
433 "OOH323/%s-%ld", host, callnumber);
435 ast_mutex_unlock(&ooh323c_cn_lock);
437 ast_mutex_lock(&i->lock);
440 ast_channel_tech_set(ch, &ooh323_tech);
450 ast_channel_nativeformats_set(ch, caps);
453 ast_channel_set_rawwriteformat(ch, tmpfmt);
454 ast_channel_set_rawreadformat(ch, tmpfmt);
462 ast_channel_rings_set(ch, 1);
464 ast_channel_adsicpe_set(ch, AST_ADSI_UNAVAILABLE);
465 ast_channel_tech_pvt_set(ch, i);
470 if ((i->dtmfmode & H323_DTMF_INBAND) || (i->faxdetect & FAXDETECT_CNG)) {
475 if (i->dtmfmode & H323_DTMF_INBAND) {
476 features |= DSP_FEATURE_DIGIT_DETECT;
477 if (i->dtmfmode & H323_DTMF_INBANDRELAX) {
483 if (i->faxdetect & FAXDETECT_CNG) {
484 features |= DSP_FEATURE_FAX_DETECT;
486 DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED);
493 ast_mutex_lock(&usecnt_lock);
495 ast_mutex_unlock(&usecnt_lock);
500 ast_channel_context_set(ch, i->context);
501 ast_channel_exten_set(ch, i->exten);
503 ast_channel_priority_set(ch, 1);
505 if(!ast_test_flag(i, H323_OUTGOING)) {
507 if (!ast_strlen_zero(i->caller_h323id)) {
511 if (!ast_strlen_zero(i->caller_dialedDigits)) {
513 i->caller_dialedDigits);
515 if (!ast_strlen_zero(i->caller_email)) {
519 if (!ast_strlen_zero(i->caller_url)) {
524 if (!ast_strlen_zero(i->accountcode))
525 ast_channel_accountcode_set(ch, i->accountcode);
533 ast_log(LOG_WARNING,
"Unable to start PBX on %s\n", ast_channel_name(ch));
534 ast_channel_unlock(ch);
541 ast_log(LOG_WARNING,
"Unable to allocate channel structure\n");
545 if(ch) ast_channel_unlock(ch);
548 ast_verb(0,
"+++ h323_new\n");
556 static struct ooh323_pvt *ooh323_alloc(
int callref,
char *callToken)
561 ast_verb(0,
"--- ooh323_alloc\n");
565 ast_log(LOG_ERROR,
"Couldn't allocate private ooh323 structure\n");
570 ast_log(LOG_ERROR,
"Couldn't allocate private ooh323 structure\n");
574 ast_mutex_init(&pvt->lock);
575 ast_mutex_lock(&pvt->lock);
579 pvt->faxdetected = 0;
580 pvt->faxdetect = gFAXdetect;
581 pvt->t38support = gT38Support;
582 pvt->rtptimeout = gRTPTimeout;
584 pvt->rtdrinterval = gRTDRInterval;
585 pvt->rtdrcount = gRTDRCount;
586 pvt->g729onlyA = g729onlyA;
588 pvt->call_reference = callref;
593 if (gRasGkMode == RasNoGatekeeper)
594 OO_SETFLAG(pvt->flags, H323_DISABLEGK);
596 pvt->dtmfmode = gDTMFMode;
597 pvt->dtmfcodec = gDTMFCodec;
599 ast_copy_string(pvt->accountcode, gAccountcode,
sizeof(pvt->accountcode));
601 pvt->amaflags = gAMAFLAGS;
604 pvt->aniasdni = gANIasDNI;
606 ast_mutex_unlock(&pvt->lock);
611 ast_mutex_unlock(&
iflock);
614 ast_verb(0,
"+++ ooh323_alloc\n");
642 ast_log(LOG_NOTICE,
"Asked to get a channel of unsupported format '%s'\n",
ast_format_cap_get_names(cap, &codec_buf));
646 p = ooh323_alloc(0,0);
649 ast_log(LOG_WARNING,
"Unable to build pvt data for '%s'\n", data);
652 ast_mutex_lock(&p->lock);
655 ast_set_flag(p, H323_OUTGOING);
660 dest = strchr(tmp,
'/');
667 }
else if ((dest = strchr(tmp,
'@'))) {
677 if ((sport = strchr(dest,
':'))) {
688 ast_mutex_unlock(&p->lock);
690 ast_mutex_unlock(&
iflock);
691 ast_log(LOG_ERROR,
"Destination format is not supported\n");
692 *cause = AST_CAUSE_INVALID_NUMBER_FORMAT;
699 p->port = peer->port;
707 p->g729onlyA = peer->g729onlyA;
708 p->dtmfmode |= peer->dtmfmode;
709 p->dtmfcodec = peer->dtmfcodec;
710 p->faxdetect = peer->faxdetect;
711 p->t38support = peer->t38support;
712 p->rtptimeout = peer->rtptimeout;
714 p->faststart = peer->faststart;
715 p->h245tunneling = peer->h245tunneling;
716 p->directrtp = peer->directrtp;
717 p->earlydirect = peer->earlydirect;
718 if (peer->rtpmask && peer->rtpmaskstr[0]) {
719 p->rtpmask = peer->rtpmask;
720 ast_copy_string(p->rtpmaskstr, peer->rtpmaskstr,
sizeof(p->rtpmaskstr));
723 if (peer->rtdrinterval) {
724 p->rtdrinterval = peer->rtdrinterval;
725 p->rtdrcount = peer->rtdrcount;
728 ast_copy_string(p->accountcode, peer->accountcode,
sizeof(p->accountcode));
729 p->amaflags = peer->amaflags;
731 if (gRasGkMode == RasNoGatekeeper) {
733 ast_log(LOG_ERROR,
"Call to undefined peer %s", dest);
735 ast_mutex_unlock(&p->lock);
737 ast_mutex_unlock(&
iflock);
739 }
else if (!gH323ep.gkClient || (gH323ep.gkClient && gH323ep.gkClient->state != GkClientRegistered)) {
740 ast_log(LOG_ERROR,
"Gatekeeper client is configured but not registered\n");
741 *cause = AST_CAUSE_NORMAL_TEMPORARY_FAILURE;
744 p->g729onlyA = g729onlyA;
745 p->dtmfmode = gDTMFMode;
746 p->dtmfcodec = gDTMFCodec;
747 p->faxdetect = gFAXdetect;
748 p->t38support = gT38Support;
749 p->rtptimeout = gRTPTimeout;
752 p->rtdrinterval = gRTDRInterval;
753 p->rtdrcount = gRTDRCount;
754 p->faststart = gFastStart;
755 p->h245tunneling = gTunneling;
756 p->directrtp = gDirectRTP;
757 p->earlydirect = gEarlyDirect;
772 assignedids, requestor);
774 ast_mutex_unlock(&p->lock);
779 ast_mutex_unlock(&
iflock);
781 ast_mutex_lock(&p->lock);
784 ast_mutex_unlock(&p->lock);
787 ast_mutex_unlock(&
iflock);
788 ast_log(LOG_ERROR,
"Failed to allocate memory for callToken\n");
792 ast_cond_init(&p->rtpcond, NULL);
795 ast_cond_wait(&p->rtpcond, &p->lock);
797 ast_mutex_unlock(&p->lock);
798 ast_cond_destroy(&p->rtpcond);
803 ast_verb(0,
"+++ ooh323_request\n");
810 static struct ooh323_pvt* find_call(ooCallData *call)
815 ast_verb(0,
"--- find_call\n");
819 for (p =
iflist; p; p = p->next) {
820 if (p->callToken && !strcmp(p->callToken, call->callToken)) {
824 ast_mutex_unlock(&
iflock);
827 ast_verb(0,
"+++ find_call\n");
832 struct ooh323_user *find_user(
const char * name,
const char* ip)
837 ast_verb(0,
"--- find_user: %s, %s\n",name,ip);
839 ast_mutex_lock(&userl.lock);
841 for (user = userl.users; user; user = user->next) {
842 if (ip && user->mUseIP && !strcmp(user->mIP, ip)) {
845 if (name && !strcmp(user->name, name)) {
850 ast_mutex_unlock(&userl.lock);
853 ast_verb(0,
"+++ find_user\n");
858 struct ooh323_peer *find_friend(
const char *name,
int port)
863 ast_verb(0,
"--- find_friend \"%s\"\n", name);
866 ast_mutex_lock(&peerl.lock);
867 for (peer = peerl.peers; peer; peer = peer->next) {
869 ast_verb(0,
" comparing with \"%s\"\n", peer->ip);
871 if (!strcmp(peer->ip, name)) {
872 if (port <= 0 || (port > 0 && peer->port == port)) {
877 ast_mutex_unlock(&peerl.lock);
881 ast_verb(0,
" found matching friend\n");
883 ast_verb(0,
"+++ find_friend \"%s\"\n", name);
895 ast_verb(0,
"--- find_peer \"%s\"\n", name);
898 ast_mutex_lock(&peerl.lock);
899 for (peer = peerl.peers; peer; peer = peer->next) {
901 ast_verb(0,
" comparing with \"%s\"\n", peer->ip);
903 if (!strcasecmp(peer->name, name))
905 if (peer->h323id && !strcasecmp(peer->h323id, name))
907 if (peer->e164 && !strcasecmp(peer->e164, name))
916 ast_mutex_unlock(&peerl.lock);
920 ast_verb(0,
" found matching peer\n");
922 ast_verb(0,
"+++ find_peer \"%s\"\n", name);
928 static int ooh323_digit_begin(
struct ast_channel *chan,
char digit)
935 ast_verb(0,
"--- ooh323_digit_begin\n");
938 ast_log(LOG_ERROR,
"No private structure for call\n");
941 ast_mutex_lock(&p->lock);
943 if (p->rtp && ((p->dtmfmode & H323_DTMF_RFC2833) || (p->dtmfmode & H323_DTMF_CISCO))) {
945 }
else if (((p->dtmfmode & H323_DTMF_Q931) ||
946 (p->dtmfmode & H323_DTMF_H245ALPHANUMERIC) ||
947 (p->dtmfmode & H323_DTMF_H245SIGNAL))) {
950 ooSendDTMFDigit(p->callToken, dtmf);
951 }
else if (p->dtmfmode & H323_DTMF_INBAND) {
954 ast_mutex_unlock(&p->lock);
957 ast_verb(0,
"+++ ooh323_digit_begin, res = %d\n", res);
962 static int ooh323_digit_end(
struct ast_channel *chan,
char digit,
unsigned int duration)
968 ast_verb(0,
"--- ooh323_digit_end\n");
971 ast_log(LOG_ERROR,
"No private structure for call\n");
974 ast_mutex_lock(&p->lock);
975 if (p->rtp && ((p->dtmfmode & H323_DTMF_RFC2833) || (p->dtmfmode & H323_DTMF_CISCO)) ) {
977 }
else if(p->dtmfmode & H323_DTMF_INBAND) {
981 ast_mutex_unlock(&p->lock);
984 ast_verb(0,
"+++ ooh323_digit_end, res = %d\n", res);
990 static int ooh323_call(
struct ast_channel *ast,
const char *dest,
int timeout)
992 struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
993 char destination[256];
995 const char *
val = NULL;
996 ooCallOptions opts = {
1000 .callMode = OO_CALLMODE_AUDIOCALL,
1005 ast_verb(0,
"--- ooh323_call- %s\n", dest);
1009 ast_log(LOG_WARNING,
"ooh323_call called on %s, neither down nor "
1010 "reserved\n", ast_channel_name(ast));
1013 ast_mutex_lock(&p->lock);
1014 ast_set_flag(p, H323_OUTGOING);
1015 if (ast_channel_connected(ast)->
id.
number.valid && ast_channel_connected(ast)->
id.
number.str) {
1016 ast_free(p->callerid_num);
1020 if (ast_channel_connected(ast)->
id.name.valid && ast_channel_connected(ast)->
id.name.str) {
1021 ast_free(p->callerid_name);
1022 p->callerid_name =
ast_strdup(ast_channel_connected(ast)->
id.name.str);
1023 }
else if (ast_channel_connected(ast)->
id.
number.valid && ast_channel_connected(ast)->
id.
number.str) {
1024 ast_free(p->callerid_name);
1028 ast_free(ast_channel_connected(ast)->
id.name.str);
1030 ast_free(p->callerid_name);
1031 p->callerid_name =
ast_strdup(ast_channel_connected(ast)->
id.name.str);
1042 ast_copy_string(p->caller_dialedDigits, val,
sizeof(p->caller_dialedDigits));
1043 if(!p->callerid_num)
1055 if (p->host && p->port != 0)
1056 snprintf(destination,
sizeof(destination),
"%s:%d", p->host, p->port);
1058 snprintf(destination,
sizeof(destination),
"%s", p->host);
1062 destination[
sizeof(destination)-1]=
'\0';
1064 opts.transfercap = ast_channel_transfercapability(ast);
1065 opts.fastStart = p->faststart;
1066 opts.tunneling = p->h245tunneling;
1068 for (i=0;i<480 && !isRunning(p->callToken);i++) usleep(12000);
1070 if(OO_TESTFLAG(p->flags, H323_DISABLEGK)) {
1076 ast_mutex_unlock(&p->lock);
1078 ast_log(LOG_ERROR,
"Failed to make call\n");
1082 ast_verb(0,
"+++ ooh323_call\n");
1089 struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
1090 int q931cause = AST_CAUSE_NORMAL_CLEARING;
1093 ast_verb(0,
"--- ooh323_hangup\n");
1096 ast_mutex_lock(&p->lock);
1098 if (ast_channel_hangupcause(ast)) {
1099 q931cause = ast_channel_hangupcause(ast);
1103 if (!strcmp(cause,
"CONGESTION")) {
1104 q931cause = AST_CAUSE_NORMAL_CIRCUIT_CONGESTION;
1105 }
else if (!strcmp(cause,
"BUSY")) {
1106 q931cause = AST_CAUSE_USER_BUSY;
1107 }
else if (!strcmp(cause,
"CHANISUNVAIL")) {
1108 q931cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
1109 }
else if (!strcmp(cause,
"NOANSWER")) {
1110 q931cause = AST_CAUSE_NO_ANSWER;
1111 }
else if (!strcmp(cause,
"CANCEL")) {
1112 q931cause = AST_CAUSE_CALL_REJECTED;
1120 ast_verb(0,
" hanging %s with cause: %d\n", p->username, q931cause);
1121 ast_channel_tech_pvt_set(ast, NULL);
1122 if (!ast_test_flag(p, H323_ALREADYGONE)) {
1123 ooHangCall(p->callToken,
1124 ooh323_convert_hangupcause_asteriskToH323(q931cause), q931cause);
1125 ast_set_flag(p, H323_ALREADYGONE);
1128 ast_set_flag(p, H323_NEEDDESTROY);
1131 ast_channel_tech_pvt_set(p->owner, NULL);
1136 ast_mutex_unlock(&p->lock);
1137 ast_mutex_lock(&usecnt_lock);
1139 ast_mutex_unlock(&usecnt_lock);
1149 ast_verb(0,
"+++ ooh323_hangup\n");
1156 struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
1157 char *callToken = (
char *)NULL;
1160 ast_verb(0,
"--- ooh323_answer\n");
1164 ast_mutex_lock(&p->lock);
1165 callToken = (p->callToken ?
ast_strdup(p->callToken) : NULL);
1167 ast_channel_lock(ast);
1168 if (!p->alertsent) {
1170 ast_debug(1,
"Sending forced ringback for %s, res = %u\n",
1171 callToken, ooManualRingback(callToken));
1173 ooManualRingback(callToken);
1178 ast_debug(1,
"ooh323_answer(%s)\n", ast_channel_name(ast));
1179 ast_channel_unlock(ast);
1180 ooAnswerCall(p->callToken);
1183 ast_free(callToken);
1185 ast_mutex_unlock(&p->lock);
1189 ast_verb(0,
"+++ ooh323_answer\n");
1198 struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
1200 if (!p)
return &null_frame;
1202 ast_mutex_lock(&p->lock);
1204 fr = ooh323_rtp_read(ast, p);
1208 ast_mutex_unlock(&p->lock);
1214 struct ooh323_pvt *p = ast_channel_tech_pvt(ast);
1218 ast_mutex_lock(&p->lock);
1220 p->lastrtptx = time(NULL);
1223 ast_debug(1,
"Send UDPTL %u/%d len %d for %s\n",
1226 res = ast_udptl_write(p->udptl, f);
1227 ast_mutex_unlock(&p->lock);
1234 if (!ast_test_flag(p, H323_OUTGOING) && !p->progsent &&
1236 ooManualProgress(p->callToken);
1244 ast_log(LOG_WARNING,
1245 "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
1256 ast_mutex_unlock(&p->lock);
1263 ast_mutex_unlock(&p->lock);
1266 ast_mutex_unlock(&p->lock);
1269 ast_log(LOG_WARNING,
"Can't send %u type frames with OOH323 write\n",
1271 ast_mutex_unlock(&p->lock);
1280 static int ooh323_indicate(
struct ast_channel *ast,
int condition,
const void *data,
size_t datalen)
1284 char *callToken = (
char *)NULL;
1289 ast_mutex_lock(&p->lock);
1290 callToken = (p->callToken ?
ast_strdup(p->callToken) : NULL);
1291 ast_mutex_unlock(&p->lock);
1295 ast_verb(0,
" ooh323_indicate - No callToken\n");
1304 ast_verb(0,
"----- ooh323_indicate %d on call %s\n", condition, callToken);
1307 ast_mutex_lock(&p->lock);
1308 switch (condition) {
1314 if (!ast_test_flag(p, H323_ALREADYGONE)) {
1315 ooHangCall(callToken, OO_REASON_LOCAL_CONGESTED, AST_CAUSE_SWITCH_CONGESTION);
1319 if (!ast_test_flag(p, H323_ALREADYGONE)) {
1320 ooHangCall(callToken, OO_REASON_LOCAL_BUSY, AST_CAUSE_USER_BUSY);
1332 rres = ooManualProgress(callToken);
1334 ast_debug(1,
"Sending manual progress for %s, res = %u\n", callToken, rres);
1342 if (!p->alertsent) {
1343 rres = ooManualRingback(callToken);
1345 ast_debug(1,
"Sending manual ringback for %s, res = %u\n", callToken, rres);
1363 if (!ast_channel_connected(ast)->
id.name.valid
1364 || ast_strlen_zero(ast_channel_connected(ast)->
id.name.str)) {
1368 ast_debug(1,
"Sending connected line info for %s (%s)\n",
1369 callToken, ast_channel_connected(ast)->
id.name.str);
1371 ooSetANI(callToken, ast_channel_connected(ast)->
id.name.str);
1375 if (p->t38support != T38_ENABLED) {
1379 ¶meters,
sizeof(parameters));
1383 ast_log(LOG_ERROR,
"Invalid datalen for AST_CONTROL_T38. "
1384 "Expected %d, got %d\n",
1403 our_parameters.rate = AST_T38_RATE_14400;
1405 }
else if (!p->chmodepend) {
1407 ooRequestChangeMode(p->callToken, 1);
1418 }
else if (!p->chmodepend) {
1420 ooRequestChangeMode(p->callToken, 0);
1428 our_parameters.rate = AST_T38_RATE_14400;
1446 ast_log(LOG_WARNING,
"Don't know how to indicate condition %d on %s\n",
1447 condition, callToken);
1450 ast_mutex_unlock(&p->lock);
1453 ast_verb(0,
"++++ ooh323_indicate %d on %s is %d\n", condition, callToken, res);
1456 ast_free(callToken);
1460 static int ooh323_queryoption(
struct ast_channel *ast,
int option,
void *data,
int *datalen)
1470 ast_mutex_lock(&p->lock);
1473 ast_verb(0,
"----- ooh323_queryoption %d on channel %s\n", option, ast_channel_name(ast));
1477 case AST_OPTION_T38_STATE:
1480 ast_log(LOG_ERROR,
"Invalid datalen for AST_OPTION_T38_STATE option."
1481 " Expected %d, got %d\n", (
int)
sizeof(
enum ast_t38_state), *datalen);
1485 if (p->t38support != T38_DISABLED) {
1501 *cp = p->vad ? 1 : 0;
1502 ast_debug(1,
"Reporting digit detection %sabled on %s\n",
1503 *cp ?
"en" :
"dis", ast_channel_name(ast));
1513 ast_verb(0,
"+++++ ooh323_queryoption %d on channel %s\n", option, ast_channel_name(ast));
1515 ast_mutex_unlock(&p->lock);
1524 struct ooh323_pvt *p = ast_channel_tech_pvt(newchan);
1529 ast_verb(0,
"--- ooh323c ooh323_fixup\n");
1531 ast_mutex_lock(&p->lock);
1532 if (p->owner != oldchan) {
1533 ast_log(LOG_WARNING,
"Old channel wasn't %p but was %p\n", oldchan, p->owner);
1534 ast_mutex_unlock(&p->lock);
1538 if (p->owner == oldchan) {
1544 ast_mutex_unlock(&p->lock);
1547 ast_verb(0,
"+++ ooh323c ooh323_fixup \n");
1553 void ooh323_set_write_format(ooCallData *call,
struct ast_format *fmt,
int txframes)
1558 ast_verb(0,
"--- ooh323_update_writeformat %s/%d\n",
1561 p = find_call(call);
1563 ast_log(LOG_ERROR,
"No matching call found for %s\n", call->callToken);
1567 ast_mutex_lock(&p->lock);
1576 ast_log(LOG_ERROR,
"Could not allocate capabilities structure\n");
1580 while (p->owner && ast_channel_trylock(p->owner)) {
1581 ast_debug(1,
"Failed to grab lock, trying again\n");
1582 DEADLOCK_AVOIDANCE(&p->lock);
1585 ast_mutex_unlock(&p->lock);
1586 ast_log(LOG_ERROR,
"Channel has no owner\n");
1592 ast_verb(0,
"Writeformat before update %s/%s\n",
1597 if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
1599 p->rtp, p->dtmfcodec,
"audio",
"telephone-event", 0);
1601 if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) {
1603 p->rtp, p->dtmfcodec,
"audio",
"cisco-telephone-event", 0);
1610 ast_channel_nativeformats_set(p->owner, caps);
1614 ast_channel_unlock(p->owner);
1616 ast_log(LOG_ERROR,
"No owner found\n");
1619 ast_mutex_unlock(&p->lock);
1622 ast_verb(0,
"+++ ooh323_update_writeformat\n");
1625 void ooh323_set_read_format(ooCallData *call,
struct ast_format *fmt)
1630 ast_verb(0,
"--- ooh323_update_readformat %s\n",
1633 p = find_call(call);
1635 ast_log(LOG_ERROR,
"No matching call found for %s\n", call->callToken);
1639 ast_mutex_lock(&p->lock);
1648 ast_log(LOG_ERROR,
"Could not allocate capabilities structure\n");
1652 while (p->owner && ast_channel_trylock(p->owner)) {
1653 ast_debug(1,
"Failed to grab lock, trying again\n");
1654 DEADLOCK_AVOIDANCE(&p->lock);
1657 ast_mutex_unlock(&p->lock);
1658 ast_log(LOG_ERROR,
"Channel has no owner\n");
1664 ast_verb(0,
"Readformat before update %s\n",
1668 ast_channel_nativeformats_set(p->owner, caps);
1671 ast_channel_unlock(p->owner);
1673 ast_log(LOG_ERROR,
"No owner found\n");
1675 ast_mutex_unlock(&p->lock);
1678 ast_verb(0,
"+++ ooh323_update_readformat\n");
1682 int onAlerting(ooCallData *call)
1688 ast_verb(0,
"--- onAlerting %s\n", call->callToken);
1690 p = find_call(call);
1693 ast_log(LOG_ERROR,
"No matching call found\n");
1696 ast_mutex_lock(&p->lock);
1698 ast_mutex_unlock(&p->lock);
1702 while (p->owner && ast_channel_trylock(p->owner)) {
1703 ast_debug(1,
"Failed to grab lock, trying again\n");
1704 DEADLOCK_AVOIDANCE(&p->lock);
1707 ast_mutex_unlock(&p->lock);
1708 ast_log(LOG_ERROR,
"Channel has no owner\n");
1713 if (call->remoteDisplayName) {
1717 memset(&update_connected, 0,
sizeof(update_connected));
1718 update_connected.id.name = 1;
1720 connected.id.name.valid = 1;
1721 connected.id.name.str = (
char *) call->remoteDisplayName;
1729 ast_channel_unlock(c);
1730 ast_mutex_unlock(&p->lock);
1733 ast_verb(0,
"+++ onAlerting %s\n", call->callToken);
1738 int onProgress(ooCallData *call)
1744 ast_verb(0,
"--- onProgress %s\n", call->callToken);
1746 p = find_call(call);
1749 ast_log(LOG_ERROR,
"No matching call found\n");
1752 ast_mutex_lock(&p->lock);
1754 ast_mutex_unlock(&p->lock);
1755 ast_log(LOG_ERROR,
"Channel has no owner\n");
1758 while (p->owner && ast_channel_trylock(p->owner)) {
1759 ast_debug(1,
"Failed to grab lock, trying again\n");
1760 DEADLOCK_AVOIDANCE(&p->lock);
1763 ast_mutex_unlock(&p->lock);
1764 ast_log(LOG_ERROR,
"Channel has no owner\n");
1769 if (call->remoteDisplayName) {
1773 memset(&update_connected, 0,
sizeof(update_connected));
1774 update_connected.id.name = 1;
1776 connected.id.name.valid = 1;
1777 connected.id.name.str = (
char *) call->remoteDisplayName;
1785 ast_channel_unlock(c);
1786 ast_mutex_unlock(&p->lock);
1789 ast_verb(0,
"+++ onProgress %s\n", call->callToken);
1798 int ooh323_onReceivedDigit(OOH323CallData *call,
const char *digit)
1804 ast_debug(1,
"Received Digit: %c\n", digit[0]);
1805 p = find_call(call);
1807 ast_log(LOG_ERROR,
"Failed to find a matching call.\n");
1811 ast_log(LOG_ERROR,
"Channel has no owner\n");
1814 ast_mutex_lock(&p->lock);
1815 memset(&f, 0,
sizeof(f));
1823 f.
src =
"SEND_DIGIT";
1825 while (p->owner && ast_channel_trylock(p->owner)) {
1826 ast_debug(1,
"Failed to grab lock, trying again\n");
1827 DEADLOCK_AVOIDANCE(&p->lock);
1830 ast_mutex_unlock(&p->lock);
1831 ast_log(LOG_ERROR,
"Channel has no owner\n");
1835 ast_channel_unlock(p->owner);
1836 ast_mutex_unlock(&p->lock);
1840 int ooh323_onReceivedSetup(ooCallData *call, Q931Message *pmsg)
1845 ooAliases *alias = NULL;
1847 char number [OO_MAX_NUMBER_LENGTH];
1850 ast_verb(0,
"--- ooh323_onReceivedSetup %s\n", call->callToken);
1853 if (!(p = ooh323_alloc(call->callReference, call->callToken))) {
1854 ast_log(LOG_ERROR,
"Failed to create a new call.\n");
1857 ast_mutex_lock(&p->lock);
1858 ast_clear_flag(p, H323_OUTGOING);
1861 if (call->remoteDisplayName) {
1862 p->callerid_name =
ast_strdup(call->remoteDisplayName);
1865 if (ooCallGetCallingPartyNumber(call, number, OO_MAX_NUMBER_LENGTH) == OO_OK) {
1869 if (call->remoteAliases) {
1870 for (alias = call->remoteAliases; alias; alias = alias->next) {
1871 if (alias->type == T_H225AliasAddress_h323_ID) {
1872 if (!p->callerid_name) {
1875 ast_copy_string(p->caller_h323id, alias->value,
sizeof(p->caller_h323id));
1877 else if(alias->type == T_H225AliasAddress_dialedDigits)
1879 if(!p->callerid_num)
1882 sizeof(p->caller_dialedDigits));
1884 else if(alias->type == T_H225AliasAddress_email_ID)
1886 ast_copy_string(p->caller_email, alias->value,
sizeof(p->caller_email));
1888 else if(alias->type == T_H225AliasAddress_url_ID)
1896 if(ooCallGetCalledPartyNumber(call, number, OO_MAX_NUMBER_LENGTH)== OO_OK) {
1899 update_our_aliases(call, p);
1900 if (!ast_strlen_zero(p->callee_dialedDigits)) {
1902 }
else if(!ast_strlen_zero(p->callee_h323id)) {
1904 }
else if(!ast_strlen_zero(p->callee_email)) {
1906 if ((at = strchr(p->exten,
'@'))) {
1913 if (ast_strlen_zero(p->exten)) {
1918 user = find_user(p->callerid_name, call->remoteIP);
1919 if(user && (user->incominglimit == 0 || user->inUse < user->incominglimit)) {
1920 ast_mutex_lock(&user->lock);
1922 p->neighbor.user = user->mUseIP ?
ast_strdup(user->mIP) :
1925 ast_copy_string(p->accountcode, user->accountcode,
sizeof(p->accountcode));
1926 p->amaflags = user->amaflags;
1928 p->g729onlyA = user->g729onlyA;
1929 p->dtmfmode |= user->dtmfmode;
1930 p->dtmfcodec = user->dtmfcodec;
1931 p->faxdetect = user->faxdetect;
1932 p->t38support = user->t38support;
1933 p->rtptimeout = user->rtptimeout;
1935 p->h245tunneling = user->h245tunneling;
1936 p->faststart = user->faststart;
1937 p->directrtp = user->directrtp;
1938 p->earlydirect = user->earlydirect;
1941 OO_SETFLAG(call->flags, OO_M_FASTSTART);
1943 OO_CLRFLAG(call->flags, OO_M_FASTSTART);
1948 if (!p->h245tunneling)
1949 OO_CLRFLAG(call->flags, OO_M_TUNNELING);
1951 if (user->rtpmask && user->rtpmaskstr[0]) {
1952 p->rtpmask = user->rtpmask;
1954 sizeof(p->rtpmaskstr));
1956 if (user->rtdrcount > 0 && user->rtdrinterval > 0) {
1957 p->rtdrcount = user->rtdrcount;
1958 p->rtdrinterval = user->rtdrinterval;
1961 p->aniasdni = user->aniasdni;
1963 if (user->incominglimit) user->inUse++;
1964 ast_mutex_unlock(&user->lock);
1966 if (!OO_TESTFLAG(p->flags,H323_DISABLEGK)) {
1968 p->directrtp = gDirectRTP;
1969 p->earlydirect = gEarlyDirect;
1971 ast_mutex_unlock(&p->lock);
1972 ast_log(LOG_ERROR,
"Unacceptable ip %s\n", call->remoteIP);
1974 ooHangCall(call->callToken, ooh323_convert_hangupcause_asteriskToH323(AST_CAUSE_CALL_REJECTED), AST_CAUSE_CALL_REJECTED);
1975 call->callEndReason = OO_REASON_REMOTE_REJECTED;
1978 ooHangCall(call->callToken, ooh323_convert_hangupcause_asteriskToH323(AST_CAUSE_NORMAL_CIRCUIT_CONGESTION), AST_CAUSE_NORMAL_CIRCUIT_CONGESTION);
1979 call->callEndReason = OO_REASON_REMOTE_REJECTED;
1981 ast_set_flag(p, H323_NEEDDESTROY);
1986 ooh323c_set_capability_for_call(call, p->cap, p->dtmfmode, p->dtmfcodec,
1987 p->t38support, p->g729onlyA);
1991 ast_mutex_unlock(&p->lock);
1992 ast_log(LOG_ERROR,
"Could not create ast_channel\n");
1997 ooCallSetCallerId(call, p->exten);
1999 if (!configure_local_rtp(p, call)) {
2000 ast_mutex_unlock(&p->lock);
2001 ast_log(LOG_ERROR,
"Couldn't create rtp structure\n");
2005 ast_mutex_unlock(&p->lock);
2008 ast_verb(0,
"+++ ooh323_onReceivedSetup - Determined context %s, "
2009 "extension %s\n", p->context, p->exten);
2016 int onOutgoingCall(ooCallData *call)
2022 ast_verb(0,
"--- onOutgoingCall %lx: %s\n", (
long unsigned int) call, call->callToken);
2024 if (!strcmp(call->callType,
"outgoing")) {
2025 p = find_call(call);
2027 ast_log(LOG_ERROR,
"Failed to find a matching call.\n");
2030 ast_mutex_lock(&p->lock);
2032 if (!ast_strlen_zero(p->callerid_name)) {
2033 ooCallSetCallerId(call, p->callerid_name);
2035 if (!ast_strlen_zero(p->callerid_num)) {
2037 while (*(p->callerid_num + i) !=
'\0') {
2038 if(!isdigit(*(p->callerid_num+i))) {
break; }
2041 if(*(p->callerid_num+i) ==
'\0')
2042 ooCallSetCallingPartyNumber(call, p->callerid_num);
2044 if(!p->callerid_name)
2045 ooCallSetCallerId(call, p->callerid_num);
2049 if (!ast_strlen_zero(p->caller_h323id))
2050 ooCallAddAliasH323ID(call, p->caller_h323id);
2052 if (!ast_strlen_zero(p->caller_dialedDigits)) {
2054 ast_verb(0,
"Setting dialed digits %s\n", p->caller_dialedDigits);
2056 ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
2057 }
else if (!ast_strlen_zero(p->callerid_num)) {
2058 if (ooIsDialedDigit(p->callerid_num)) {
2060 ast_verb(0,
"setting callid number %s\n", p->callerid_num);
2062 ooCallAddAliasDialedDigits(call, p->callerid_num);
2063 }
else if (ast_strlen_zero(p->caller_h323id)) {
2064 ooCallAddAliasH323ID(call, p->callerid_num);
2067 if (p->rtpmask && p->rtpmaskstr[0]) {
2068 call->rtpMask = p->rtpmask;
2069 ast_mutex_lock(&call->rtpMask->lock);
2070 call->rtpMask->inuse++;
2071 ast_mutex_unlock(&call->rtpMask->lock);
2072 ast_copy_string(call->rtpMaskStr, p->rtpmaskstr,
sizeof(call->rtpMaskStr));
2075 if (!p->rtp && !configure_local_rtp(p, call)) {
2076 ast_mutex_unlock(&p->lock);
2080 ast_mutex_unlock(&p->lock);
2084 ast_verb(0,
"+++ onOutgoingCall %s\n", call->callToken);
2089 int onNewCallCreated(ooCallData *call)
2095 ast_verb(0,
"--- onNewCallCreated %lx: %s\n", (
long unsigned int) call, call->callToken);
2097 ast_mutex_lock(&call->Lock);
2098 if (ooh323c_start_call_thread(call)) {
2099 ast_log(LOG_ERROR,
"Failed to create call thread.\n");
2100 ast_mutex_unlock(&call->Lock);
2104 if (!strcmp(call->callType,
"outgoing")) {
2105 p = find_call(call);
2107 ast_log(LOG_ERROR,
"Failed to find a matching call.\n");
2108 ast_mutex_unlock(&call->Lock);
2111 ast_mutex_lock(&p->lock);
2113 if (!ast_strlen_zero(p->callerid_name)) {
2114 ooCallSetCallerId(call, p->callerid_name);
2116 if (!ast_strlen_zero(p->callerid_num)) {
2118 while (*(p->callerid_num + i) !=
'\0') {
2119 if(!isdigit(*(p->callerid_num+i))) {
break; }
2122 if(*(p->callerid_num+i) ==
'\0')
2123 ooCallSetCallingPartyNumber(call, p->callerid_num);
2125 if(ast_strlen_zero(p->callerid_name))
2126 ooCallSetCallerId(call, p->callerid_num);
2130 if (!ast_strlen_zero(p->caller_h323id))
2131 ooCallAddAliasH323ID(call, p->caller_h323id);
2133 if (!ast_strlen_zero(p->caller_dialedDigits)) {
2135 ast_verb(0,
"Setting dialed digits %s\n", p->caller_dialedDigits);
2137 ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
2138 }
else if (!ast_strlen_zero(p->callerid_num)) {
2139 if (ooIsDialedDigit(p->callerid_num)) {
2141 ast_verb(0,
"setting callid number %s\n", p->callerid_num);
2143 ooCallAddAliasDialedDigits(call, p->callerid_num);
2144 }
else if (ast_strlen_zero(p->caller_h323id)) {
2145 ooCallAddAliasH323ID(call, p->callerid_num);
2150 if (!ast_strlen_zero(p->exten)) {
2151 if (ooIsDialedDigit(p->exten)) {
2152 ooCallSetCalledPartyNumber(call, p->exten);
2153 ooCallAddRemoteAliasDialedDigits(call, p->exten);
2155 ooCallAddRemoteAliasH323ID(call, p->exten);
2162 ast_verb(0,
" Outgoing call %s(%s) - Codec prefs - %s\n",
2163 p->username?p->username:
"NULL", call->callToken,
2167 ooh323c_set_capability_for_call(call, p->cap,
2168 p->dtmfmode, p->dtmfcodec, p->t38support, p->g729onlyA);
2170 configure_local_rtp(p, call);
2171 ast_cond_signal(&p->rtpcond);
2172 ast_mutex_unlock(&p->lock);
2175 ast_mutex_unlock(&call->Lock);
2177 ast_verb(0,
"+++ onNewCallCreated %s\n", call->callToken);
2181 int onCallEstablished(ooCallData *call)
2186 ast_verb(0,
"--- onCallEstablished %s\n", call->callToken);
2189 if (!(p = find_call(call))) {
2190 ast_log(LOG_ERROR,
"Failed to find a matching call.\n");
2194 if(ast_test_flag(p, H323_OUTGOING)) {
2195 ast_mutex_lock(&p->lock);
2197 ast_mutex_unlock(&p->lock);
2198 ast_log(LOG_ERROR,
"Channel has no owner\n");
2202 while (p->owner && ast_channel_trylock(p->owner)) {
2203 ast_debug(1,
"Failed to grab lock, trying again\n");
2204 DEADLOCK_AVOIDANCE(&p->lock);
2209 if (call->remoteDisplayName) {
2213 memset(&update_connected, 0,
sizeof(update_connected));
2214 update_connected.id.name = 1;
2216 connected.id.name.valid = 1;
2217 connected.id.name.str = (
char *) call->remoteDisplayName;
2224 ast_channel_unlock(p->owner);
2226 ast_mutex_unlock(&p->lock);
2231 ast_verb(0,
"+++ onCallEstablished %s\n", call->callToken);
2236 int onCallCleared(ooCallData *call)
2242 ast_verb(0,
"--- onCallCleared %s \n", call->callToken);
2245 if ((p = find_call(call))) {
2246 ast_mutex_lock(&p->lock);
2249 if (ast_channel_trylock(p->owner)) {
2250 ooTrace(OOTRCLVLINFO,
"Failed to grab lock, trying again\n");
2251 ast_debug(1,
"Failed to grab lock, trying again\n");
2252 DEADLOCK_AVOIDANCE(&p->lock);
2254 ownerLock = 1;
break;
2259 if (!ast_test_flag(p, H323_ALREADYGONE)) {
2261 ast_set_flag(p, H323_ALREADYGONE);
2262 ast_channel_hangupcause_set(p->owner, call->q931cause);
2269 ast_channel_tech_pvt_set(p->owner, NULL);
2270 ast_channel_unlock(p->owner);
2276 ast_cond_signal(&p->rtpcond);
2279 ast_set_flag(p, H323_NEEDDESTROY);
2281 ooh323c_stop_call_thread(call);
2283 ast_mutex_unlock(&p->lock);
2284 ast_mutex_lock(&usecnt_lock);
2286 ast_mutex_unlock(&usecnt_lock);
2291 ast_verb(0,
"+++ onCallCleared\n");
2333 ast_verb(0,
"--- ooh323_delete_peer\n");
2337 ast_mutex_lock(&peerl.lock);
2339 if(cur==peer)
break;
2346 prev->next = cur->next;
2348 peerl.peers = cur->next;
2350 ast_mutex_unlock(&peerl.lock);
2352 ast_free(peer->h323id);
2353 ast_free(peer->email);
2354 ast_free(peer->url);
2355 ast_free(peer->e164);
2357 ao2_cleanup(peer->cap);
2362 ast_verb(0,
"+++ ooh323_delete_peer\n");
2373 ast_verb(0,
"--- build_user\n");
2382 ast_mutex_init(&user->lock);
2385 user->rtptimeout = gRTPTimeout;
2387 user->dtmfmode = gDTMFMode;
2388 user->dtmfcodec = gDTMFCodec;
2389 user->faxdetect = gFAXdetect;
2390 user->t38support = gT38Support;
2391 user->faststart = gFastStart;
2392 user->h245tunneling = gTunneling;
2393 user->directrtp = gDirectRTP;
2394 user->earlydirect = gEarlyDirect;
2395 user->g729onlyA = g729onlyA;
2398 ast_copy_string(user->accountcode, gAccountcode,
sizeof(user->accountcode));
2399 user->amaflags = gAMAFLAGS;
2402 if (!strcasecmp(v->
name,
"context")) {
2404 }
else if (!strcasecmp(v->
name,
"incominglimit")) {
2405 user->incominglimit = atoi(v->
value);
2406 if (user->incominglimit < 0)
2407 user->incominglimit = 0;
2408 }
else if (!strcasecmp(v->
name,
"accountcode")) {
2410 }
else if (!strcasecmp(v->
name,
"roundtrip")) {
2411 sscanf(v->
value,
"%d,%d", &user->rtdrcount, &user->rtdrinterval);
2412 }
else if (!strcasecmp(v->
name,
"faststart")) {
2414 }
else if (!strcasecmp(v->
name,
"h245tunneling")) {
2416 }
else if (!strcasecmp(v->
name,
"directrtp") || !strcasecmp(v->
name,
"directmedia")) {
2419 }
else if (!strcasecmp(v->
name,
"earlydirect") || !strcasecmp(v->
name,
"directrtpsetup")) {
2421 }
else if (!strcasecmp(v->
name,
"g729onlyA")) {
2423 }
else if (!strcasecmp(v->
name,
"nat")) {
2425 }
else if (!strcasecmp(v->
name,
"rtptimeout")) {
2426 user->rtptimeout = atoi(v->
value);
2427 if (user->rtptimeout < 0)
2428 user->rtptimeout = gRTPTimeout;
2429 }
else if (!strcasecmp(v->
name,
"rtpmask")) {
2430 if ((user->rtpmask =
ast_calloc(1,
sizeof(
struct OOH323Regex))) &&
2431 (regcomp(&user->rtpmask->regex, v->
value, REG_EXTENDED)
2433 ast_mutex_init(&user->rtpmask->lock);
2434 user->rtpmask->inuse = 1;
2436 sizeof(user->rtpmaskstr));
2437 }
else user->rtpmask = NULL;
2438 }
else if (!strcasecmp(v->
name,
"disallow")) {
2440 }
else if (!strcasecmp(v->
name,
"allow")) {
2441 const char* tcodecs = v->
value;
2442 if (!strcasecmp(v->
value,
"all")) {
2443 tcodecs =
"ulaw,alaw,g729,g723,gsm";
2446 }
else if (!strcasecmp(v->
name,
"amaflags")) {
2448 }
else if (!strcasecmp(v->
name,
"ip") || !strcasecmp(v->
name,
"host")) {
2456 }
else if (!strcasecmp(v->
name,
"dtmfmode")) {
2457 if (!strcasecmp(v->
value,
"rfc2833"))
2458 user->dtmfmode = H323_DTMF_RFC2833;
2459 if (!strcasecmp(v->
value,
"cisco"))
2460 user->dtmfmode = H323_DTMF_CISCO;
2461 else if (!strcasecmp(v->
value,
"q931keypad"))
2462 user->dtmfmode = H323_DTMF_Q931;
2463 else if (!strcasecmp(v->
value,
"h245alphanumeric"))
2464 user->dtmfmode = H323_DTMF_H245ALPHANUMERIC;
2465 else if (!strcasecmp(v->
value,
"h245signal"))
2466 user->dtmfmode = H323_DTMF_H245SIGNAL;
2467 else if (!strcasecmp(v->
value,
"inband"))
2468 user->dtmfmode = H323_DTMF_INBAND;
2469 }
else if (!strcasecmp(v->
name,
"relaxdtmf")) {
2470 user->dtmfmode |=
ast_true(v->
value) ? H323_DTMF_INBANDRELAX : 0;
2471 }
else if (!strcasecmp(v->
name,
"dtmfcodec") && atoi(v->
value)) {
2472 user->dtmfcodec = atoi(v->
value);
2473 }
else if (!strcasecmp(v->
name,
"faxdetect")) {
2475 user->faxdetect = FAXDETECT_CNG | FAXDETECT_T38;
2477 user->faxdetect = 0;
2480 char *word, *next = buf;
2481 user->faxdetect = 0;
2482 while ((word = strsep(&next,
","))) {
2483 if (!strcasecmp(word,
"cng")) {
2484 user->faxdetect |= FAXDETECT_CNG;
2485 }
else if (!strcasecmp(word,
"t38")) {
2486 user->faxdetect |= FAXDETECT_T38;
2488 ast_log(LOG_WARNING,
"Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
2493 }
else if (!strcasecmp(v->
name,
"t38support")) {
2494 if (!strcasecmp(v->
value,
"disabled"))
2495 user->t38support = T38_DISABLED;
2496 if (!strcasecmp(v->
value,
"no"))
2497 user->t38support = T38_DISABLED;
2498 else if (!strcasecmp(v->
value,
"faxgw"))
2499 user->t38support = T38_FAXGW;
2500 else if (!strcasecmp(v->
value,
"yes"))
2501 user->t38support = T38_ENABLED;
2502 }
else if (!strcasecmp(v->
name,
"aniasdni")) {
2510 ast_verb(0,
"+++ build_user\n");
2520 ast_verb(0,
"--- build_peer\n");
2529 ast_mutex_init(&peer->lock);
2532 peer->rtptimeout = gRTPTimeout;
2534 ast_copy_string(peer->accountcode, gAccountcode,
sizeof(peer->accountcode));
2535 peer->amaflags = gAMAFLAGS;
2536 peer->dtmfmode = gDTMFMode;
2537 peer->dtmfcodec = gDTMFCodec;
2538 peer->faxdetect = gFAXdetect;
2539 peer->t38support = gT38Support;
2540 peer->faststart = gFastStart;
2541 peer->h245tunneling = gTunneling;
2542 peer->directrtp = gDirectRTP;
2543 peer->earlydirect = gEarlyDirect;
2544 peer->g729onlyA = g729onlyA;
2546 if (0 == friend_type) {
2551 if (!strcasecmp(v->
name,
"h323id")) {
2553 ast_log(LOG_ERROR,
"Could not allocate memory for h323id of "
2555 ooh323_delete_peer(peer);
2558 }
else if (!strcasecmp(v->
name,
"e164")) {
2561 for(tmp = v->
value; *tmp; tmp++) {
2562 if (!isdigit(*tmp)) {
2569 ast_log(LOG_ERROR,
"Could not allocate memory for e164 of "
2571 ooh323_delete_peer(peer);
2575 ast_log(LOG_ERROR,
"Invalid e164: %s for peer %s\n", v->
value, name);
2577 }
else if (!strcasecmp(v->
name,
"email")) {
2579 ast_log(LOG_ERROR,
"Could not allocate memory for email of "
2581 ooh323_delete_peer(peer);
2584 }
else if (!strcasecmp(v->
name,
"url")) {
2586 ast_log(LOG_ERROR,
"Could not allocate memory for h323id of "
2588 ooh323_delete_peer(peer);
2591 }
else if (!strcasecmp(v->
name,
"port")) {
2592 peer->port = atoi(v->
value);
2593 }
else if (!strcasecmp(v->
name,
"host") || !strcasecmp(v->
name,
"ip")) {
2601 }
else if (!strcasecmp(v->
name,
"outgoinglimit")) {
2602 int val = atoi(v->
value);
2604 peer->outgoinglimit = 0;
2606 peer->outgoinglimit = val;
2608 }
else if (!strcasecmp(v->
name,
"accountcode")) {
2610 }
else if (!strcasecmp(v->
name,
"faststart")) {
2612 }
else if (!strcasecmp(v->
name,
"h245tunneling")) {
2614 }
else if (!strcasecmp(v->
name,
"directrtp") || !strcasecmp(v->
name,
"directmedia")) {
2617 }
else if (!strcasecmp(v->
name,
"earlydirect") || !strcasecmp(v->
name,
"directrtpsetup")) {
2619 }
else if (!strcasecmp(v->
name,
"g729onlyA")) {
2621 }
else if (!strcasecmp(v->
name,
"nat")) {
2623 }
else if (!strcasecmp(v->
name,
"rtptimeout")) {
2624 peer->rtptimeout = atoi(v->
value);
2625 if(peer->rtptimeout < 0)
2626 peer->rtptimeout = gRTPTimeout;
2627 }
else if (!strcasecmp(v->
name,
"rtpmask")) {
2628 if ((peer->rtpmask =
ast_calloc(1,
sizeof(
struct OOH323Regex))) &&
2629 (regcomp(&peer->rtpmask->regex, v->
value, REG_EXTENDED)
2631 ast_mutex_init(&peer->rtpmask->lock);
2632 peer->rtpmask->inuse = 1;
2634 sizeof(peer->rtpmaskstr));
2635 }
else peer->rtpmask = NULL;
2636 }
else if (!strcasecmp(v->
name,
"disallow")) {
2638 }
else if (!strcasecmp(v->
name,
"allow")) {
2639 const char* tcodecs = v->
value;
2640 if (!strcasecmp(v->
value,
"all")) {
2641 tcodecs =
"ulaw,alaw,g729,g723,gsm";
2644 }
else if (!strcasecmp(v->
name,
"amaflags")) {
2646 }
else if (!strcasecmp(v->
name,
"roundtrip")) {
2647 sscanf(v->
value,
"%d,%d", &peer->rtdrcount, &peer->rtdrinterval);
2648 }
else if (!strcasecmp(v->
name,
"dtmfmode")) {
2649 if (!strcasecmp(v->
value,
"rfc2833"))
2650 peer->dtmfmode = H323_DTMF_RFC2833;
2651 if (!strcasecmp(v->
value,
"cisco"))
2652 peer->dtmfmode = H323_DTMF_CISCO;
2653 else if (!strcasecmp(v->
value,
"q931keypad"))
2654 peer->dtmfmode = H323_DTMF_Q931;
2655 else if (!strcasecmp(v->
value,
"h245alphanumeric"))
2656 peer->dtmfmode = H323_DTMF_H245ALPHANUMERIC;
2657 else if (!strcasecmp(v->
value,
"h245signal"))
2658 peer->dtmfmode = H323_DTMF_H245SIGNAL;
2659 else if (!strcasecmp(v->
value,
"inband"))
2660 peer->dtmfmode = H323_DTMF_INBAND;
2661 }
else if (!strcasecmp(v->
name,
"relaxdtmf")) {
2662 peer->dtmfmode |=
ast_true(v->
value) ? H323_DTMF_INBANDRELAX : 0;
2663 }
else if (!strcasecmp(v->
name,
"dtmfcodec") && atoi(v->
value)) {
2664 peer->dtmfcodec = atoi(v->
value);
2665 }
else if (!strcasecmp(v->
name,
"faxdetect")) {
2667 peer->faxdetect = FAXDETECT_CNG | FAXDETECT_T38;
2669 peer->faxdetect = 0;
2672 char *word, *next = buf;
2673 peer->faxdetect = 0;
2674 while ((word = strsep(&next,
","))) {
2675 if (!strcasecmp(word,
"cng")) {
2676 peer->faxdetect |= FAXDETECT_CNG;
2677 }
else if (!strcasecmp(word,
"t38")) {
2678 peer->faxdetect |= FAXDETECT_T38;
2680 ast_log(LOG_WARNING,
"Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
2685 }
else if (!strcasecmp(v->
name,
"t38support")) {
2686 if (!strcasecmp(v->
value,
"disabled"))
2687 peer->t38support = T38_DISABLED;
2688 if (!strcasecmp(v->
value,
"no"))
2689 peer->t38support = T38_DISABLED;
2690 else if (!strcasecmp(v->
value,
"faxgw"))
2691 peer->t38support = T38_FAXGW;
2692 else if (!strcasecmp(v->
value,
"yes"))
2693 peer->t38support = T38_ENABLED;
2700 ast_verb(0,
"+++ build_peer\n");
2705 static int ooh323_do_reload(
void)
2707 struct ooAliases * pNewAlias = NULL;
2711 ast_verb(0,
"--- ooh323_do_reload\n");
2715 if (gH323ep.gkClient) {
2716 ooGkClientDestroy();
2722 if (gRasGkMode == RasUseSpecificGatekeeper ||
2723 gRasGkMode == RasDiscoverGatekeeper) {
2724 ooGkClientInit(gRasGkMode, (gRasGkMode == RasUseSpecificGatekeeper) ?
2725 gGatekeeper : 0, gRASIP, 0);
2726 ooGkClientStart(gH323ep.gkClient);
2731 ast_verb(0,
"updating local aliases\n");
2734 for (pNewAlias = gAliasList; pNewAlias; pNewAlias = pNewAlias->next) {
2735 switch (pNewAlias->type) {
2736 case T_H225AliasAddress_h323_ID:
2737 ooH323EpAddAliasH323ID(pNewAlias->value);
2739 case T_H225AliasAddress_dialedDigits:
2740 ooH323EpAddAliasDialedDigits(pNewAlias->value);
2742 case T_H225AliasAddress_email_ID:
2743 ooH323EpAddAliasEmailID(pNewAlias->value);
2750 ast_mutex_lock(&peerl.lock);
2754 ooH323EpAddAliasH323ID(peer->h323id);
2757 ooH323EpAddAliasEmailID(peer->email);
2760 ooH323EpAddAliasDialedDigits(peer->e164);
2763 ooH323EpAddAliasURLID(peer->url);
2767 ast_mutex_unlock(&peerl.lock);
2770 ast_verb(0,
"+++ ooh323_do_reload\n");
2785 "Usage: ooh323 reload\n"
2786 " Reload OOH323 config.\n";
2793 return CLI_SHOWUSAGE;
2796 ast_verb(0,
"--- ooh323_reload\n");
2798 ast_mutex_lock(&h323_reload_lock);
2799 if (h323_reloading) {
2800 ast_verb(0,
"Previous OOH323 reload not yet done\n");
2804 ast_mutex_unlock(&h323_reload_lock);
2808 ast_verb(0,
"+++ ooh323_reload\n");
2813 int reload_config(
int reload)
2816 struct ooAliases *pNewAlias = NULL, *cur, *prev;
2826 ast_verb(0,
"--- reload_config\n");
2832 ast_log(LOG_NOTICE,
"Unable to load config %s, OOH323 disabled\n", config);
2834 }
else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
2835 return RESULT_SUCCESS;
2841 ast_verb(0,
" reload_config - Freeing up alias list\n");
2847 ast_free(prev->value);
2851 ooH323EpClearAllAliases();
2855 snprintf(gLogFile,
sizeof(gLogFile),
"%s/%s", ast_config_AST_LOG_DIR, DEFAULT_LOGFILE);
2858 strcpy(gCallerID, DEFAULT_H323ID);
2861 gDTMFMode = H323_DTMF_RFC2833;
2863 gFAXdetect = FAXDETECT_CNG;
2864 gT38Support = T38_FAXGW;
2865 gTRCLVL = OOTRCLVLERR;
2866 gRasGkMode = RasNoGatekeeper;
2867 gGatekeeper[0] =
'\0';
2873 strcpy(gAccountcode, DEFAULT_H323ACCNT);
2877 strcpy(gContext, DEFAULT_CONTEXT);
2879 gMediaWaitForConnect = 0;
2880 ooconfig.mTCPPortStart = 12030;
2881 ooconfig.mTCPPortEnd = 12230;
2882 memcpy(&global_jbconf, &default_jbconf,
sizeof(
struct ast_jb_conf));
2884 v = ast_variable_browse(cfg,
"general");
2892 if (!strcasecmp(v->
name,
"port")) {
2893 gPort = (int)strtol(v->
value, NULL, 10);
2894 }
else if (!strcasecmp(v->
name,
"bindaddr")) {
2897 ast_log(LOG_WARNING,
"Invalid address: %s\n", v->
value);
2904 }
else if (!strcasecmp(v->
name,
"h225portrange")) {
2908 endlimit = strchr(temp,
',');
2912 ooconfig.mTCPPortStart = atoi(temp);
2913 ooconfig.mTCPPortEnd = atoi(endlimit);
2916 ast_log(LOG_ERROR,
"h225portrange: Invalid format, separate port range with \",\"\n");
2918 }
else if (!strcasecmp(v->
name,
"gateway")) {
2920 }
else if (!strcasecmp(v->
name,
"faststart")) {
2923 ooH323EpEnableFastStart();
2925 ooH323EpDisableFastStart();
2926 }
else if (!strcasecmp(v->
name,
"mediawaitforconnect")) {
2928 if (gMediaWaitForConnect)
2929 ooH323EpEnableMediaWaitForConnect();
2931 ooH323EpDisableMediaWaitForConnect();
2932 }
else if (!strcasecmp(v->
name,
"h245tunneling")) {
2935 ooH323EpEnableH245Tunneling();
2937 ooH323EpDisableH245Tunneling();
2938 }
else if (!strcasecmp(v->
name,
"directrtp") || !strcasecmp(v->
name,
"directmedia")) {
2941 }
else if (!strcasecmp(v->
name,
"earlydirect") || !strcasecmp(v->
name,
"directrtpsetup")) {
2943 }
else if (!strcasecmp(v->
name,
"g729onlyA")) {
2945 }
else if (!strcasecmp(v->
name,
"roundtrip")) {
2946 sscanf(v->
value,
"%d,%d", &gRTDRCount, &gRTDRInterval);
2947 }
else if (!strcasecmp(v->
name,
"trybemaster")) {
2950 ooH323EpTryBeMaster(1);
2952 ooH323EpTryBeMaster(0);
2953 }
else if (!strcasecmp(v->
name,
"h323id")) {
2954 pNewAlias =
ast_calloc(1,
sizeof(
struct ooAliases));
2956 ast_log(LOG_ERROR,
"Failed to allocate memory for h323id alias\n");
2960 if (gAliasList == NULL) {
2963 pNewAlias->type = T_H225AliasAddress_h323_ID;
2965 pNewAlias->next = gAliasList;
2966 gAliasList = pNewAlias;
2968 }
else if (!strcasecmp(v->
name,
"e164")) {
2971 for(tmp = v->
value; *tmp; tmp++) {
2972 if (!isdigit(*tmp)) {
2978 pNewAlias =
ast_calloc(1,
sizeof(
struct ooAliases));
2980 ast_log(LOG_ERROR,
"Failed to allocate memory for e164 alias\n");
2984 pNewAlias->type = T_H225AliasAddress_dialedDigits;
2986 pNewAlias->next = gAliasList;
2987 gAliasList = pNewAlias;
2990 ast_log(LOG_ERROR,
"Invalid e164: %s\n", v->
value);
2992 }
else if (!strcasecmp(v->
name,
"email")) {
2993 pNewAlias =
ast_calloc(1,
sizeof(
struct ooAliases));
2995 ast_log(LOG_ERROR,
"Failed to allocate memory for email alias\n");
2999 pNewAlias->type = T_H225AliasAddress_email_ID;
3001 pNewAlias->next = gAliasList;
3002 gAliasList = pNewAlias;
3004 }
else if (!strcasecmp(v->
name,
"t35country")) {
3005 t35countrycode = atoi(v->
value);
3006 }
else if (!strcasecmp(v->
name,
"t35extensions")) {
3007 t35extensions = atoi(v->
value);
3008 }
else if (!strcasecmp(v->
name,
"manufacturer")) {
3009 manufacturer = atoi(v->
value);
3010 }
else if (!strcasecmp(v->
name,
"vendorid")) {
3012 }
else if (!strcasecmp(v->
name,
"versionid")) {
3014 }
else if (!strcasecmp(v->
name,
"callerid")) {
3016 }
else if (!strcasecmp(v->
name,
"incominglimit")) {
3017 gIncomingLimit = atoi(v->
value);
3018 }
else if (!strcasecmp(v->
name,
"outgoinglimit")) {
3019 gOutgoingLimit = atoi(v->
value);
3020 }
else if (!strcasecmp(v->
name,
"gatekeeper")) {
3021 if (!strcasecmp(v->
value,
"DISABLE")) {
3022 gRasGkMode = RasNoGatekeeper;
3023 }
else if (!strcasecmp(v->
value,
"DISCOVER")) {
3024 gRasGkMode = RasDiscoverGatekeeper;
3026 gRasGkMode = RasUseSpecificGatekeeper;
3029 }
else if (!strcasecmp(v->
name,
"localras")) {
3031 ast_verb(3,
" == Setting RAS IP to %s\n", gRASIP);
3032 }
else if (!strcasecmp(v->
name,
"logfile")) {
3033 if (v->
value[0] ==
'/') {
3036 snprintf(gLogFile,
sizeof(gLogFile),
"%s/%s", ast_config_AST_LOG_DIR, v->
value);
3038 }
else if (!strcasecmp(v->
name,
"context")) {
3040 ast_verb(3,
" == Setting default context to %s\n", gContext);
3041 }
else if (!strcasecmp(v->
name,
"nat")) {
3043 }
else if (!strcasecmp(v->
name,
"rtptimeout")) {
3044 gRTPTimeout = atoi(v->
value);
3045 if (gRTPTimeout < 0)
3047 }
else if (!strcasecmp(v->
name,
"tos")) {
3048 if (sscanf(v->
value,
"%30i", &format) == 1)
3049 gTOS = format & 0xff;
3050 else if (!strcasecmp(v->
value,
"lowdelay"))
3051 gTOS = IPTOS_LOWDELAY;
3052 else if (!strcasecmp(v->
value,
"throughput"))
3053 gTOS = IPTOS_THROUGHPUT;
3054 else if (!strcasecmp(v->
value,
"reliability"))
3055 gTOS = IPTOS_RELIABILITY;
3056 else if (!strcasecmp(v->
value,
"mincost"))
3057 gTOS = IPTOS_MINCOST;
3058 else if (!strcasecmp(v->
value,
"none"))
3061 ast_log(LOG_WARNING,
"Invalid tos value at line %d, should be "
3062 "'lowdelay', 'throughput', 'reliability', "
3063 "'mincost', or 'none'\n", v->lineno);
3064 }
else if (!strcasecmp(v->
name,
"amaflags")) {
3066 }
else if (!strcasecmp(v->
name,
"accountcode")) {
3068 }
else if (!strcasecmp(v->
name,
"disallow")) {
3070 }
else if (!strcasecmp(v->
name,
"allow")) {
3071 const char* tcodecs = v->
value;
3072 if (!strcasecmp(v->
value,
"all")) {
3073 tcodecs =
"ulaw,alaw,g729,g723,gsm";
3076 }
else if (!strcasecmp(v->
name,
"dtmfmode")) {
3077 if (!strcasecmp(v->
value,
"inband"))
3078 gDTMFMode = H323_DTMF_INBAND;
3079 else if (!strcasecmp(v->
value,
"rfc2833"))
3080 gDTMFMode = H323_DTMF_RFC2833;
3081 else if (!strcasecmp(v->
value,
"cisco"))
3082 gDTMFMode = H323_DTMF_CISCO;
3083 else if (!strcasecmp(v->
value,
"q931keypad"))
3084 gDTMFMode = H323_DTMF_Q931;
3085 else if (!strcasecmp(v->
value,
"h245alphanumeric"))
3086 gDTMFMode = H323_DTMF_H245ALPHANUMERIC;
3087 else if (!strcasecmp(v->
value,
"h245signal"))
3088 gDTMFMode = H323_DTMF_H245SIGNAL;
3090 ast_log(LOG_WARNING,
"Unknown dtmf mode '%s', using rfc2833\n",
3092 gDTMFMode = H323_DTMF_RFC2833;
3094 }
else if (!strcasecmp(v->
name,
"relaxdtmf")) {
3095 gDTMFMode |=
ast_true(v->
value) ? H323_DTMF_INBANDRELAX : 0;
3096 }
else if (!strcasecmp(v->
name,
"dtmfcodec") && atoi(v->
value)) {
3097 gDTMFCodec = atoi(v->
value);
3098 }
else if (!strcasecmp(v->
name,
"faxdetect")) {
3100 gFAXdetect = FAXDETECT_CNG | FAXDETECT_T38;
3105 char *word, *next = buf;
3107 while ((word = strsep(&next,
","))) {
3108 if (!strcasecmp(word,
"cng")) {
3109 gFAXdetect |= FAXDETECT_CNG;
3110 }
else if (!strcasecmp(word,
"t38")) {
3111 gFAXdetect |= FAXDETECT_T38;
3113 ast_log(LOG_WARNING,
"Unknown faxdetect mode '%s' on line %d.\n", word, v->lineno);
3118 }
else if (!strcasecmp(v->
name,
"t38support")) {
3119 if (!strcasecmp(v->
value,
"disabled"))
3120 gT38Support = T38_DISABLED;
3121 if (!strcasecmp(v->
value,
"no"))
3122 gT38Support = T38_DISABLED;
3123 else if (!strcasecmp(v->
value,
"faxgw"))
3124 gT38Support = T38_FAXGW;
3125 else if (!strcasecmp(v->
value,
"yes"))
3126 gT38Support = T38_ENABLED;
3127 }
else if (!strcasecmp(v->
name,
"tracelevel")) {
3128 gTRCLVL = atoi(v->
value);
3129 ooH323EpSetTraceLevel(gTRCLVL);
3130 }
else if (!strcasecmp(v->
name,
"aniasdni")) {
3137 if (strcasecmp(cat,
"general")) {
3138 int friend_type = 0;
3139 utype = ast_variable_retrieve(cfg, cat,
"type");
3141 friend_type = strcasecmp(utype,
"friend");
3142 if (!strcmp(utype,
"user") || 0 == friend_type) {
3143 user =
build_user(cat, ast_variable_browse(cfg, cat));
3145 ast_mutex_lock(&userl.lock);
3146 user->next = userl.users;
3148 ast_mutex_unlock(&userl.lock);
3150 ast_log(LOG_WARNING,
"Failed to build user %s\n", cat);
3153 if (!strcasecmp(utype,
"peer") || 0 == friend_type) {
3154 peer =
build_peer(cat, ast_variable_browse(cfg, cat), friend_type);
3156 ast_mutex_lock(&peerl.lock);
3157 peer->next = peerl.peers;
3159 ast_mutex_unlock(&peerl.lock);
3161 ast_log(LOG_WARNING,
"Failed to build peer %s\n", cat);
3171 if (ast_strlen_zero(gIP)) {
3172 ooGetLocalIPAddress(gIP);
3173 if (!strcmp(gIP,
"127.0.0.1") || !strcmp(gIP,
"::1")) {
3174 ast_log(LOG_NOTICE,
"Failed to determine local ip address. Please "
3175 "specify it in ooh323.conf. OOH323 Disabled\n");
3181 ast_verb(0,
"+++ reload_config\n");
3195 e->
command =
"ooh323 show peer";
3197 "Usage: ooh323 show peer <name>\n"
3198 " List details of specific OOH323 peer.\n";
3205 return CLI_SHOWUSAGE;
3207 ast_mutex_lock(&peerl.lock);
3210 ast_mutex_lock(&peer->lock);
3211 if (!strcmp(peer->name, a->argv[3])) {
3216 ast_mutex_unlock(&prev->lock);
3221 sprintf(ip_port,
"%s:%d", peer->ip, peer->port);
3222 ast_cli(a->fd,
"%-15.15s%s\n",
"Name: ", peer->name);
3223 ast_cli(a->fd,
"%s:%s,%s\n",
"FastStart/H.245 Tunneling", peer->faststart?
"yes":
"no",
3224 peer->h245tunneling?
"yes":
"no");
3225 ast_cli(a->fd,
"%-15s%s\n",
"DirectRTP", peer->directrtp ?
"yes" :
"no");
3226 ast_cli(a->fd,
"%-15s%s\n",
"EarlyDirectRTP", peer->earlydirect ?
"yes" :
"no");
3227 ast_cli(a->fd,
"%-15.15s",
"DTMF Mode: ");
3228 if (peer->dtmfmode & H323_DTMF_CISCO) {
3229 ast_cli(a->fd,
"%s\n",
"cisco");
3230 ast_cli(a->fd,
"%-15.15s%d\n",
"DTMF Codec: ", peer->dtmfcodec);
3231 }
else if (peer->dtmfmode & H323_DTMF_RFC2833) {
3232 ast_cli(a->fd,
"%s\n",
"rfc2833");
3233 ast_cli(a->fd,
"%-15.15s%d\n",
"DTMF Codec: ", peer->dtmfcodec);
3234 }
else if (peer->dtmfmode & H323_DTMF_Q931) {
3235 ast_cli(a->fd,
"%s\n",
"q931keypad");
3236 }
else if (peer->dtmfmode & H323_DTMF_H245ALPHANUMERIC) {
3237 ast_cli(a->fd,
"%s\n",
"h245alphanumeric");
3238 }
else if (peer->dtmfmode & H323_DTMF_H245SIGNAL) {
3239 ast_cli(a->fd,
"%s\n",
"h245signal");
3240 }
else if (peer->dtmfmode & H323_DTMF_INBAND && peer->dtmfmode & H323_DTMF_INBANDRELAX) {
3241 ast_cli(a->fd,
"%s\n",
"inband-relaxed");
3242 }
else if (peer->dtmfmode & H323_DTMF_INBAND) {
3243 ast_cli(a->fd,
"%s\n",
"inband");
3245 ast_cli(a->fd,
"%s\n",
"unknown");
3247 ast_cli(a->fd,
"%-15s",
"T.38 Mode: ");
3248 if (peer->t38support == T38_DISABLED) {
3249 ast_cli(a->fd,
"%s\n",
"disabled");
3250 }
else if (peer->t38support == T38_FAXGW) {
3251 ast_cli(a->fd,
"%s\n",
"faxgw compatible");
3253 if (peer->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
3254 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Yes");
3255 }
else if (peer->faxdetect & FAXDETECT_CNG) {
3256 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Cng");
3257 }
else if (peer->faxdetect & FAXDETECT_T38) {
3258 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"T.38");
3260 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"No");
3263 ast_cli(a->fd,
"%-15.15s%s\n",
"AccountCode: ", peer->accountcode);
3265 ast_cli(a->fd,
"%-15.15s%s\n",
"IP:Port: ", ip_port);
3266 ast_cli(a->fd,
"%-15.15s%u\n",
"OutgoingLimit: ", peer->outgoinglimit);
3267 ast_cli(a->fd,
"%-15.15s%d\n",
"rtptimeout: ", peer->rtptimeout);
3268 ast_cli(a->fd,
"%-15.15s%s\n",
"nat: ", peer->nat?
"yes":
"no");
3269 if (peer->rtpmaskstr[0]) {
3270 ast_cli(a->fd,
"%-15.15s%s\n",
"rtpmask: ", peer->rtpmaskstr);
3272 if (peer->rtdrcount && peer->rtdrinterval) {
3273 ast_cli(a->fd,
"%-15.15s%d,%d\n",
"RoundTrip: ", peer->rtdrcount, peer->rtdrinterval);
3275 ast_mutex_unlock(&peer->lock);
3277 ast_cli(a->fd,
"Peer %s not found\n", a->argv[3]);
3278 ast_cli(a->fd,
"\n");
3280 ast_mutex_unlock(&peerl.lock);
3290 #define FORMAT "%-15.15s %-15.15s %-23.23s %-s\n"
3294 e->
command =
"ooh323 show peers";
3296 "Usage: ooh323 show peers\n"
3297 " Lists all known OOH323 peers.\n";
3304 return CLI_SHOWUSAGE;
3306 ast_cli(a->fd, FORMAT,
"Name",
"Accountcode",
"ip:port",
"Formats");
3308 ast_mutex_lock(&peerl.lock);
3311 ast_mutex_lock(&peer->lock);
3312 snprintf(ip_port,
sizeof(ip_port),
"%s:%d", peer->ip, peer->port);
3313 ast_cli(a->fd, FORMAT, peer->name,
3319 ast_mutex_unlock(&prev->lock);
3322 ast_mutex_unlock(&peerl.lock);
3333 e->
command =
"ooh323 show user";
3335 "Usage: ooh323 show user <name>\n"
3336 " List details of specific OOH323 user.\n";
3343 return CLI_SHOWUSAGE;
3346 ast_mutex_lock(&userl.lock);
3349 ast_mutex_lock(&user->lock);
3350 if (!strcmp(user->name, a->argv[3])) {
3355 ast_mutex_unlock(&prev->lock);
3360 ast_cli(a->fd,
"%-15.15s%s\n",
"Name: ", user->name);
3361 ast_cli(a->fd,
"%s:%s,%s\n",
"FastStart/H.245 Tunneling", user->faststart?
"yes":
"no",
3362 user->h245tunneling?
"yes":
"no");
3363 ast_cli(a->fd,
"%-15s%s\n",
"DirectRTP", user->directrtp ?
"yes" :
"no");
3364 ast_cli(a->fd,
"%-15s%s\n",
"EarlyDirectRTP", user->earlydirect ?
"yes" :
"no");
3365 ast_cli(a->fd,
"%-15.15s",
"DTMF Mode: ");
3366 if (user->dtmfmode & H323_DTMF_CISCO) {
3367 ast_cli(a->fd,
"%s\n",
"cisco");
3368 ast_cli(a->fd,
"%-15.15s%d\n",
"DTMF Codec: ", user->dtmfcodec);
3369 }
else if (user->dtmfmode & H323_DTMF_RFC2833) {
3370 ast_cli(a->fd,
"%s\n",
"rfc2833");
3371 ast_cli(a->fd,
"%-15.15s%d\n",
"DTMF Codec: ", user->dtmfcodec);
3372 }
else if (user->dtmfmode & H323_DTMF_Q931) {
3373 ast_cli(a->fd,
"%s\n",
"q931keypad");
3374 }
else if (user->dtmfmode & H323_DTMF_H245ALPHANUMERIC) {
3375 ast_cli(a->fd,
"%s\n",
"h245alphanumeric");
3376 }
else if (user->dtmfmode & H323_DTMF_H245SIGNAL) {
3377 ast_cli(a->fd,
"%s\n",
"h245signal");
3378 }
else if (user->dtmfmode & H323_DTMF_INBAND && user->dtmfmode & H323_DTMF_INBANDRELAX) {
3379 ast_cli(a->fd,
"%s\n",
"inband-relaxed");
3380 }
else if (user->dtmfmode & H323_DTMF_INBAND) {
3381 ast_cli(a->fd,
"%s\n",
"inband");
3383 ast_cli(a->fd,
"%s\n",
"unknown");
3385 ast_cli(a->fd,
"%-15s",
"T.38 Mode: ");
3386 if (user->t38support == T38_DISABLED) {
3387 ast_cli(a->fd,
"%s\n",
"disabled");
3388 }
else if (user->t38support == T38_FAXGW) {
3389 ast_cli(a->fd,
"%s\n",
"faxgw compatible");
3391 if (user->faxdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
3392 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Yes");
3393 }
else if (user->faxdetect & FAXDETECT_CNG) {
3394 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Cng");
3395 }
else if (user->faxdetect & FAXDETECT_T38) {
3396 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"T.38");
3398 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"No");
3401 ast_cli(a->fd,
"%-15.15s%s\n",
"AccountCode: ", user->accountcode);
3403 ast_cli(a->fd,
"%-15.15s%s\n",
"Context: ", user->context);
3404 ast_cli(a->fd,
"%-15.15s%d\n",
"IncomingLimit: ", user->incominglimit);
3405 ast_cli(a->fd,
"%-15.15s%u\n",
"InUse: ", user->inUse);
3406 ast_cli(a->fd,
"%-15.15s%d\n",
"rtptimeout: ", user->rtptimeout);
3407 ast_cli(a->fd,
"%-15.15s%s\n",
"nat: ", user->nat?
"yes":
"no");
3408 if (user->rtpmaskstr[0]) {
3409 ast_cli(a->fd,
"%-15.15s%s\n",
"rtpmask: ", user->rtpmaskstr);
3411 ast_mutex_unlock(&user->lock);
3412 if (user->rtdrcount && user->rtdrinterval) {
3413 ast_cli(a->fd,
"%-15.15s%d,%d\n",
"RoundTrip: ", user->rtdrcount, user->rtdrinterval);
3416 ast_cli(a->fd,
"User %s not found\n", a->argv[3]);
3417 ast_cli(a->fd,
"\n");
3419 ast_mutex_unlock(&userl.lock);
3428 #define FORMAT1 "%-15.15s %-15.15s %-15.15s %-s\n"
3432 e->
command =
"ooh323 show users";
3434 "Usage: ooh323 show users \n"
3435 " Lists all known OOH323 users.\n";
3442 return CLI_SHOWUSAGE;
3445 ast_cli(a->fd, FORMAT1,
"Username",
"Accountcode",
"Context",
"Formats");
3447 ast_mutex_lock(&userl.lock);
3451 ast_mutex_lock(&user->lock);
3452 ast_cli(a->fd, FORMAT1, user->name,
3453 user->accountcode, user->context,
3457 ast_mutex_unlock(&prev->lock);
3460 ast_mutex_unlock(&userl.lock);
3462 return RESULT_SUCCESS;
3470 e->
command =
"ooh323 set debug [off]";
3472 "Usage: ooh323 set debug [off]\n"
3473 " Enables/Disables debugging of OOH323 channel driver\n";
3479 if (a->argc < 3 || a->argc > 4)
3480 return CLI_SHOWUSAGE;
3481 if (a->argc == 4 && strcasecmp(a->argv[3],
"off"))
3482 return CLI_SHOWUSAGE;
3484 gH323Debug = (a->argc == 4) ? FALSE : TRUE;
3485 ast_cli(a->fd,
"OOH323 Debugging %s\n", gH323Debug ?
"Enabled" :
"Disabled");
3491 static int ooh323_show_channels(
int fd,
int argc,
char *argv[])
3493 return RESULT_SUCCESS;
3499 char value[FORMAT_STRING_SIZE];
3503 e->
command =
"ooh323 show gk";
3505 "Usage: ooh323 show gk\n"
3506 " Shows Gatekeeper connection state\n";
3513 return CLI_SHOWUSAGE;
3515 ast_cli(a->fd,
"\nGateKeeper connection state:\n");
3516 if (!gH323ep.gkClient) {
3517 ast_cli(a->fd,
"No Gatekeeper is configured\n");
3521 if (gRasGkMode == RasNoGatekeeper) {
3522 snprintf(value,
sizeof(value),
"%s",
"No Gatekeeper");
3523 }
else if (gRasGkMode == RasDiscoverGatekeeper) {
3524 snprintf(value,
sizeof(value),
"%s",
"Discover");
3526 snprintf(value,
sizeof(value),
"%s", gGatekeeper);
3528 ast_cli(a->fd,
"%-20s%s\n",
"Gatekeeper:", value);
3529 switch(gH323ep.gkClient->state) {
3531 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Idle");
3533 case GkClientDiscovered:
3534 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Discovered");
3536 case GkClientRegistered:
3537 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Registered");
3539 case GkClientUnregistered:
3540 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Unregistered");
3543 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Error");
3545 case GkClientFailed:
3546 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Failed");
3548 case GkClientStopped:
3549 ast_cli(a->fd,
"%-20s%s\n",
"GK state:",
"Shutdown");
3560 char value[FORMAT_STRING_SIZE];
3562 ooAliases *pAlias = NULL, *pAliasNext = NULL;;
3566 e->
command =
"ooh323 show config";
3568 "Usage: ooh323 show config\n"
3569 " Shows global configuration of H.323 channel driver\n";
3576 return CLI_SHOWUSAGE;
3578 ast_cli(a->fd,
"\nObjective Open H.323 Channel Driver's Config:\n");
3579 snprintf(value,
sizeof(value),
"%s:%d", gIP, gPort);
3580 ast_cli(a->fd,
"%-20s%s\n",
"IP:Port: ", value);
3581 ast_cli(a->fd,
"%-20s%d-%d\n",
"H.225 port range: ", ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd);
3582 ast_cli(a->fd,
"%-20s%s\n",
"FastStart", gFastStart?
"yes":
"no");
3583 ast_cli(a->fd,
"%-20s%s\n",
"Tunneling", gTunneling?
"yes":
"no");
3584 ast_cli(a->fd,
"%-20s%s\n",
"CallerId", gCallerID);
3585 ast_cli(a->fd,
"%-20s%s\n",
"MediaWaitForConnect", gMediaWaitForConnect?
"yes":
"no");
3586 ast_cli(a->fd,
"%-20s%s\n",
"DirectRTP", gDirectRTP ?
"yes" :
"no");
3587 ast_cli(a->fd,
"%-20s%s\n",
"EarlyDirectRTP", gEarlyDirect ?
"yes" :
"no");
3590 extern OOH323EndPoint gH323ep;
3591 ast_cli(a->fd,
"%-20s%s\n",
"FASTSTART",
3592 (OO_TESTFLAG(gH323ep.flags, OO_M_FASTSTART) != 0) ?
"yes" :
"no");
3593 ast_cli(a->fd,
"%-20s%s\n",
"TUNNELING",
3594 (OO_TESTFLAG(gH323ep.flags, OO_M_TUNNELING) != 0) ?
"yes" :
"no");
3595 ast_cli(a->fd,
"%-20s%s\n",
"MEDIAWAITFORCONN",
3596 (OO_TESTFLAG(gH323ep.flags, OO_M_MEDIAWAITFORCONN) != 0) ?
"yes" :
"no");
3599 if (gRasGkMode == RasNoGatekeeper) {
3600 snprintf(value,
sizeof(value),
"%s",
"No Gatekeeper");
3601 }
else if (gRasGkMode == RasDiscoverGatekeeper) {
3602 snprintf(value,
sizeof(value),
"%s",
"Discover");
3604 snprintf(value,
sizeof(value),
"%s", gGatekeeper);
3606 ast_cli(a->fd,
"%-20s%s\n",
"Gatekeeper:", value);
3607 ast_cli(a->fd,
"%-20s%s\n",
"H.323 LogFile:", gLogFile);
3608 ast_cli(a->fd,
"%-20s%s\n",
"Context:", gContext);
3609 ast_cli(a->fd,
"%-20s%s\n",
"Capability:",
3611 ast_cli(a->fd,
"%-20s",
"DTMF Mode: ");
3612 if (gDTMFMode & H323_DTMF_CISCO) {
3613 ast_cli(a->fd,
"%s\n",
"cisco");
3614 ast_cli(a->fd,
"%-20.15s%d\n",
"DTMF Codec: ", gDTMFCodec);
3615 }
else if (gDTMFMode & H323_DTMF_RFC2833) {
3616 ast_cli(a->fd,
"%s\n",
"rfc2833");
3617 ast_cli(a->fd,
"%-20.15s%d\n",
"DTMF Codec: ", gDTMFCodec);
3618 }
else if (gDTMFMode & H323_DTMF_Q931) {
3619 ast_cli(a->fd,
"%s\n",
"q931keypad");
3620 }
else if (gDTMFMode & H323_DTMF_H245ALPHANUMERIC) {
3621 ast_cli(a->fd,
"%s\n",
"h245alphanumeric");
3622 }
else if (gDTMFMode & H323_DTMF_H245SIGNAL) {
3623 ast_cli(a->fd,
"%s\n",
"h245signal");
3624 }
else if (gDTMFMode & H323_DTMF_INBAND && gDTMFMode & H323_DTMF_INBANDRELAX) {
3625 ast_cli(a->fd,
"%s\n",
"inband-relaxed");
3626 }
else if (gDTMFMode & H323_DTMF_INBAND) {
3627 ast_cli(a->fd,
"%s\n",
"inband");
3629 ast_cli(a->fd,
"%s\n",
"unknown");
3632 ast_cli(a->fd,
"%-20s",
"T.38 Mode: ");
3633 if (gT38Support == T38_DISABLED) {
3634 ast_cli(a->fd,
"%s\n",
"disabled");
3635 }
else if (gT38Support == T38_FAXGW) {
3636 ast_cli(a->fd,
"%s\n",
"faxgw compatible");
3638 if (gFAXdetect == (FAXDETECT_CNG | FAXDETECT_T38)) {
3639 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Yes");
3640 }
else if (gFAXdetect & FAXDETECT_CNG) {
3641 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"Cng");
3642 }
else if (gFAXdetect & FAXDETECT_T38) {
3643 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"T.38");
3645 ast_cli(a->fd,
"%-20s%s\n",
"FAX Detect:",
"No");
3648 if (gRTDRCount && gRTDRInterval) {
3649 ast_cli(a->fd,
"%-20.15s%d,%d\n",
"RoundTrip: ", gRTDRCount, gRTDRInterval);
3652 ast_cli(a->fd,
"%-20s%ld\n",
"Call counter: ", callnumber);
3653 ast_cli(a->fd,
"%-20s%s\n",
"AccountCode: ", gAccountcode);
3656 pAlias = gAliasList;
3658 ast_cli(a->fd,
"%-20s\n",
"Aliases: ");
3661 pAliasNext = pAlias->next;
3663 ast_cli(a->fd,
"\t%-30s\t%-30s\n",pAlias->value, pAliasNext->value);
3664 pAlias = pAliasNext->next;
3666 ast_cli(a->fd,
"\t%-30s\n",pAlias->value);
3667 pAlias = pAlias->next;
3674 AST_CLI_DEFINE(handle_cli_ooh323_set_debug,
"Enable/Disable OOH323 debugging"),
3675 AST_CLI_DEFINE(handle_cli_ooh323_show_config,
"Show details on global configuration of H.323 channel driver"),
3676 AST_CLI_DEFINE(handle_cli_ooh323_show_gk,
"Show OOH323 Gatekeeper connection status"),
3677 AST_CLI_DEFINE(handle_cli_ooh323_show_peer,
"Show details on specific OOH323 peer"),
3678 AST_CLI_DEFINE(handle_cli_ooh323_show_peers,
"Show defined OOH323 peers"),
3679 AST_CLI_DEFINE(handle_cli_ooh323_show_user,
"Show details on specific OOH323 user"),
3680 AST_CLI_DEFINE(handle_cli_ooh323_show_users,
"Show defined OOH323 users"),
3681 AST_CLI_DEFINE(handle_cli_ooh323_reload,
"reload ooh323 config")
3685 static int function_ooh323_read(
struct ast_channel *chan,
const char *cmd,
char *data,
char *buf,
size_t len)
3687 struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
3689 ast_channel_lock(chan);
3691 ast_channel_unlock(chan);
3696 ast_log(LOG_ERROR,
"This function is only supported on OOH323 channels, Channel is %s\n",
ast_channel_tech(chan)->type);
3697 ast_channel_unlock(chan);
3701 ast_mutex_lock(&p->lock);
3702 if (!strcasecmp(data,
"faxdetect")) {
3704 }
else if (!strcasecmp(data,
"t38support")) {
3706 }
else if (!strcasecmp(data,
"caller_h323id")) {
3708 }
else if (!strcasecmp(data,
"caller_dialeddigits")) {
3710 }
else if (!strcasecmp(data,
"caller_email")) {
3712 }
else if (!strcasecmp(data,
"h323id_url")) {
3714 }
else if (!strcasecmp(data,
"callee_h323id")) {
3716 }
else if (!strcasecmp(data,
"callee_dialeddigits")) {
3718 }
else if (!strcasecmp(data,
"callee_email")) {
3720 }
else if (!strcasecmp(data,
"callee_url")) {
3723 ast_mutex_unlock(&p->lock);
3725 ast_channel_unlock(chan);
3730 static int function_ooh323_write(
struct ast_channel *chan,
const char *cmd,
char *data,
const char *value)
3732 struct ooh323_pvt *p = ast_channel_tech_pvt(chan);
3735 ast_channel_lock(chan);
3737 ast_channel_unlock(chan);
3742 ast_log(LOG_ERROR,
"This function is only supported on OOH323 channels, Channel is %s\n",
ast_channel_tech(chan)->type);
3743 ast_channel_unlock(chan);
3747 ast_mutex_lock(&p->lock);
3748 if (!strcasecmp(data,
"faxdetect")) {
3757 char *word, *next = buf;
3760 while ((word = strsep(&next,
","))) {
3761 if (!strcasecmp(word,
"cng")) {
3762 p->faxdetect |= FAXDETECT_CNG;
3763 }
else if (!strcasecmp(word,
"t38")) {
3764 p->faxdetect |= FAXDETECT_T38;
3766 ast_log(LOG_WARNING,
"Unknown faxdetect mode '%s'.\n", word);
3772 }
else if (!strcasecmp(data,
"t38support")) {
3781 ast_mutex_unlock(&p->lock);
3782 ast_channel_unlock(chan);
3787 static int load_module(
void)
3789 struct ooAliases * pNewAlias = NULL;
3791 OOH225MsgCallbacks h225Callbacks = {0, 0, 0, 0};
3793 OOH323CALLBACKS h323Callbacks = {
3794 .onNewCallCreated = onNewCallCreated,
3795 .onAlerting = onAlerting,
3796 .onProgress = onProgress,
3797 .onIncomingCall = NULL,
3798 .onOutgoingCall = onOutgoingCall,
3799 .onCallEstablished = onCallEstablished,
3800 .onCallCleared = onCallCleared,
3801 .openLogicalChannels = NULL,
3802 .onReceivedDTMF = ooh323_onReceivedDigit,
3803 .onModeChanged = onModeChanged,
3804 .onMediaChanged = (cb_OnMediaChanged) setup_rtp_remote,
3819 h225Callbacks.onReceivedSetup = &ooh323_onReceivedSetup;
3822 ast_mutex_init(&userl.lock);
3824 ast_mutex_init(&peerl.lock);
3831 ast_log(LOG_WARNING,
"Unable to create schedule context\n");
3834 ast_log(LOG_WARNING,
"Unable to create I/O context\n");
3838 if (!reload_config(0)) {
3841 if (OO_OK != ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, gLogFile, gInitError,
sizeof(gInitError))) {
3842 ast_log(LOG_ERROR,
"Failed to initialize OOH323 endpoint: %s"
3843 "OOH323 Disabled\n", gInitError);
3853 ast_log(LOG_ERROR,
"Unable to register channel class %s\n", type);
3860 ast_rtp_glue_register(&ooh323_rtp);
3864 ooH323EpSetAsGateway();
3866 ooH323EpSetVersionInfo(t35countrycode, t35extensions, manufacturer,
3868 ooH323EpDisableAutoAnswer();
3869 ooH323EpSetH225MsgCallbacks(h225Callbacks);
3870 ooH323EpSetTraceLevel(gTRCLVL);
3871 ooH323EpSetLocalAddress(gIP, gPort);
3873 ast_debug(1,
"OOH323 channel is in IP6 mode\n");
3875 ooH323EpSetCallerID(gCallerID);
3877 if(ooH323EpSetTCPPortRange(ooconfig.mTCPPortStart, ooconfig.mTCPPortEnd) == OO_FAILED) {
3878 ast_log(LOG_ERROR,
"h225portrange: Failed to set range\n");
3882 for (pNewAlias = gAliasList; pNewAlias; pNewAlias = pNewAlias->next) {
3883 switch (pNewAlias->type) {
3884 case T_H225AliasAddress_h323_ID:
3885 ooH323EpAddAliasH323ID(pNewAlias->value);
3887 case T_H225AliasAddress_dialedDigits:
3888 ooH323EpAddAliasDialedDigits(pNewAlias->value);
3890 case T_H225AliasAddress_email_ID:
3891 ooH323EpAddAliasEmailID(pNewAlias->value);
3898 ast_mutex_lock(&peerl.lock);
3901 if(peer->h323id) ooH323EpAddAliasH323ID(peer->h323id);
3902 if(peer->email) ooH323EpAddAliasEmailID(peer->email);
3903 if(peer->e164) ooH323EpAddAliasDialedDigits(peer->e164);
3904 if(peer->url) ooH323EpAddAliasURLID(peer->url);
3907 ast_mutex_unlock(&peerl.lock);
3910 if (gMediaWaitForConnect)
3911 ooH323EpEnableMediaWaitForConnect();
3913 ooH323EpDisableMediaWaitForConnect();
3917 ooH323EpEnableFastStart();
3919 ooH323EpDisableFastStart();
3922 ooH323EpDisableH245Tunneling();
3925 ooH323EpTryBeMaster(1);
3927 ooH323EpEnableManualRingback();
3930 if (gRasGkMode == RasUseSpecificGatekeeper)
3931 ooGkClientInit(gRasGkMode, gGatekeeper, gRASIP, 0);
3932 else if (gRasGkMode == RasDiscoverGatekeeper)
3933 ooGkClientInit(gRasGkMode, 0, gRASIP, 0);
3936 ooH323EpSetH323Callbacks(h323Callbacks);
3939 if (ooh323c_set_capability(gCap, gDTMFMode, gDTMFCodec) < 0) {
3940 ast_log(LOG_ERROR,
"Capabilities failure for OOH323. OOH323 Disabled.\n");
3949 if (ooCreateH323Listener() != OO_OK) {
3950 ast_log(LOG_ERROR,
"OOH323 Listener Creation failure. "
3951 "OOH323 DISABLED\n");
3961 if (ooh323c_start_stack_thread() < 0) {
3962 ast_log(LOG_ERROR,
"Failed to start OOH323 stack thread. "
3963 "OOH323 DISABLED\n");
3974 ast_log(LOG_ERROR,
"Can't load ooh323 config file, OOH323 Disabled\n");
3981 static int reload_module(
void)
3983 ast_mutex_lock(&h323_reload_lock);
3984 if (h323_reloading) {
3985 ast_verb(0,
"Previous OOH323 reload not yet done\n");
3989 ast_mutex_unlock(&h323_reload_lock);
3993 ast_verb(0,
"+++ ooh323_reload\n");
3998 static void *do_monitor(
void *data)
4008 ast_mutex_lock(&h323_reload_lock);
4009 reloading = h323_reloading;
4011 ast_mutex_unlock(&h323_reload_lock);
4013 ast_verb(1,
"Reloading H.323\n");
4016 if (gH323ep.gkClient && gH323ep.gkClient->state == GkClientStopped) {
4017 ooGkClientDestroy();
4018 ast_verb(0,
"Restart stopped gatekeeper client\n");
4019 ooGkClientInit(gRasGkMode, (gRasGkMode == RasUseSpecificGatekeeper) ?
4020 gGatekeeper : 0, gRASIP, 0);
4021 ooGkClientStart(gH323ep.gkClient);
4029 h323_next = h323->next;
4031 if (h323->rtp && h323->rtptimeout && h323->lastrtptx &&
4032 h323->lastrtptx + h323->rtptimeout < t) {
4034 h323->lastrtptx = time(NULL);
4037 if (h323->rtp && h323->owner && h323->rtptimeout &&
4039 h323->lastrtprx + h323->rtptimeout < t) {
4040 if (!ast_channel_trylock(h323->owner)) {
4042 ast_log(LOG_NOTICE,
"Disconnecting call '%s' for lack of RTP activity in %ld seconds\n", ast_channel_name(h323->owner), (
long) (t - h323->lastrtprx));
4043 ast_channel_unlock(h323->owner);
4048 if (ast_test_flag(h323, H323_NEEDDESTROY)) {
4049 ooh323_destroy (h323);
4062 ast_mutex_unlock(&
iflock);
4063 pthread_testcancel();
4067 if ((res < 0) || (res > 1000)) {
4071 pthread_testcancel();
4082 int restart_monitor(
void)
4084 pthread_attr_t attr;
4089 if (ast_mutex_lock(&
monlock)) {
4090 ast_log(LOG_WARNING,
"Unable to lock monitor\n");
4095 ast_log(LOG_WARNING,
"Cannot kill myself\n");
4102 pthread_attr_init(&attr);
4103 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
4105 if (ast_pthread_create(&
monitor_thread, &attr, do_monitor, NULL) < 0) {
4107 ast_log(LOG_ERROR,
"Unable to start monitor thread.\n");
4124 ast_verb(0,
"--- ooh323_destroy \n");
4127 ast_verb(0,
" Destroying %s\n", p->username);
4132 if (cur == p) {
break; }
4138 ast_mutex_lock(&cur->lock);
4140 prev->next = cur->next;
4144 if (cur->callToken) {
4146 ast_verb(0,
" Destroying %s\n", cur->callToken);
4147 ast_free(cur->callToken);
4151 if (cur->username) {
4152 ast_free(cur->username);
4157 ast_free(cur->host);
4161 if (cur->callerid_name) {
4162 ast_free(cur->callerid_name);
4163 cur->callerid_name = 0;
4166 if (cur->callerid_num) {
4167 ast_free(cur->callerid_num);
4168 cur->callerid_num = 0;
4178 ast_udptl_destroy(cur->udptl);
4184 while(ast_channel_trylock(cur->owner)) {
4185 ast_debug(1,
"Failed to grab lock, trying again\n");
4186 DEADLOCK_AVOIDANCE(&cur->lock);
4188 ast_debug(1,
"Detaching from %s\n", ast_channel_name(cur->owner));
4189 ast_channel_tech_pvt_set(cur->owner, NULL);
4190 ast_channel_unlock(cur->owner);
4196 ast_dsp_free(cur->vad);
4202 if(!ast_test_flag(cur, H323_OUTGOING)) {
4203 if (cur->neighbor.user) {
4204 user = find_user(p->callerid_name, cur->neighbor.user);
4205 if(user && user->inUse > 0) {
4206 ast_mutex_lock(&user->lock);
4208 ast_mutex_unlock(&user->lock);
4210 ast_free(cur->neighbor.user);
4216 ast_mutex_unlock(&cur->lock);
4217 ast_mutex_destroy(&cur->lock);
4218 ao2_cleanup(cur->writeformat);
4219 ao2_cleanup(cur->readformat);
4220 ao2_cleanup(cur->cap);
4225 ast_verb(0,
"+++ ooh323_destroy\n");
4233 ast_mutex_lock(&peerl.lock);
4239 ast_mutex_destroy(&prev->lock);
4240 ast_free(prev->h323id);
4241 ast_free(prev->email);
4242 ast_free(prev->url);
4243 ast_free(prev->e164);
4245 ast_mutex_lock(&prev->rtpmask->lock);
4246 prev->rtpmask->inuse--;
4247 ast_mutex_unlock(&prev->rtpmask->lock);
4248 if (prev->rtpmask->inuse == 0) {
4249 regfree(&prev->rtpmask->regex);
4250 ast_mutex_destroy(&prev->rtpmask->lock);
4251 ast_free(prev->rtpmask);
4256 if (cur == peerl.peers) {
4261 ast_mutex_unlock(&peerl.lock);
4268 ast_mutex_lock(&userl.lock);
4273 ast_mutex_destroy(&prev->lock);
4276 ast_mutex_lock(&prev->rtpmask->lock);
4277 prev->rtpmask->inuse--;
4278 ast_mutex_unlock(&prev->rtpmask->lock);
4279 if (prev->rtpmask->inuse == 0) {
4280 regfree(&prev->rtpmask->regex);
4281 ast_mutex_destroy(&prev->rtpmask->lock);
4282 ast_free(prev->rtpmask);
4285 ao2_cleanup(prev->cap);
4287 if (cur == userl.users) {
4292 ast_mutex_unlock(&userl.lock);
4296 static int unload_module(
void)
4299 struct ooAliases *cur = NULL, *prev = NULL;
4302 ast_verb(0,
"--- ooh323 unload_module \n");
4313 ast_verb(0,
" unload_module - hanging up all interfaces\n");
4315 if (!ast_mutex_lock(&
iflock)) {
4325 ast_mutex_unlock(&
iflock);
4327 ast_log(LOG_WARNING,
"Unable to lock the interface list\n");
4333 ast_verb(0,
" unload_module - stopping monitor thread\n");
4336 if (!ast_mutex_lock(&
monlock)) {
4345 ast_log(LOG_WARNING,
"Unable to lock the monitor\n");
4352 ast_verb(0,
" unload_module - stopping stack thread\n");
4354 ooh323c_stop_stack_thread();
4358 ast_verb(0,
" unload_module - freeing up memory used by interfaces\n");
4360 if (!ast_mutex_lock(&
iflock)) {
4372 ast_mutex_unlock(&
iflock);
4374 ast_log(LOG_WARNING,
"Unable to lock the interface list\n");
4380 ast_verb(0,
" unload_module - deleting users\n");
4386 ast_verb(0,
" unload_module - deleting peers\n");
4392 ast_verb(0,
" unload_module - Freeing up alias list\n");
4398 ast_free(prev->value);
4405 ast_verb(0,
" unload_module- destroying OOH323 endpoint \n");
4410 ast_verb(0,
"+++ ooh323 unload_module \n");
4424 ast_verb(0,
"+++ ooh323 get_codec, %s\n", ast_channel_name(chan));
4436 ast_verb(0,
"--- ooh323 get_codec, %s\n", ast_channel_name(chan));
4449 ast_verb(0,
"+++ ooh323 get_rtp_peer \n");
4452 if (!(p = (
struct ooh323_pvt *) ast_channel_tech_pvt(chan)))
4459 *rtp = p->rtp ?
ao2_ref(p->rtp, +1), p->rtp : NULL;
4469 if (ast_test_flag(&global_jbconf, AST_JB_FORCED)) {
4479 ast_verb(0,
"--- ooh323 get_rtp_peer, res = %d\n", (
int) res);
4490 if (!(p = (
struct ooh323_pvt *) ast_channel_tech_pvt(chan)))
4497 *rtp = p->vrtp ?
ao2_ref(p->vrtp, +1), p->vrtp : NULL;
4506 int ooh323_convertAsteriskCapToH323Cap(
struct ast_format *format)
4509 return OO_G711ULAW64K;
4511 return OO_G711ALAW64K;
4513 return OO_GSMFULLRATE;
4525 return OO_H263VIDEO;
4527 ast_log(LOG_NOTICE,
"Don't know how to deal with mode %s\n",
ast_format_get_name(format));
4538 char *callToken = NULL;
4541 ast_verb(0,
"--- ooh323_set_peer - %s\n", ast_channel_name(chan));
4544 if (ooh323_convertAsteriskCapToH323Cap(ast_channel_writeformat(chan)) < 0) {
4545 ast_log(LOG_WARNING,
"Unknown format.\n");
4548 p = (
struct ooh323_pvt *) ast_channel_tech_pvt(chan);
4550 ast_log(LOG_ERROR,
"No Private Structure, this is bad\n");
4554 ast_mutex_lock(&p->lock);
4560 memset(&p->redirip, 0,
sizeof(p->redirip));
4563 callToken = (p->callToken ?
ast_strdup(p->callToken) : NULL);
4567 ast_verb(0,
" set_rtp_peer - No callToken\n");
4569 ast_mutex_unlock(&p->lock);
4584 ast_verb(0,
"ooh323_set_rtp_peer return back to local\n");
4586 ooUpdateLogChannels(callToken,
"0.0.0.0" , 0);
4590 ast_mutex_unlock(&p->lock);
4591 ast_free(callToken);
4599 int configure_local_rtp(
struct ooh323_pvt *p, ooCallData *call)
4601 char lhost[INET6_ADDRSTRLEN];
4604 ooMediaInfo mediaInfo;
4608 ast_verb(0,
"--- configure_local_rtp\n");
4610 memset(&mediaInfo, 0,
sizeof(mediaInfo));
4615 ast_log(LOG_WARNING,
"Unable to create RTP session: %s\n",
4622 if (!(p->udptl = ast_udptl_new_with_bindaddr(sched, io, 0, &tmp))) {
4623 ast_log(LOG_WARNING,
"Unable to create UDPTL session: %s\n",
4630 while (p->owner && ast_channel_trylock(p->owner)) {
4631 ast_debug(1,
"Failed to grab lock, trying again\n");
4632 DEADLOCK_AVOIDANCE(&p->lock);
4635 ast_mutex_unlock(&p->lock);
4636 ast_log(LOG_ERROR,
"Channel has no owner\n");
4640 ast_log(LOG_ERROR,
"Channel has no owner\n");
4648 ast_channel_unlock(p->owner);
4658 if (p->dtmfmode & H323_DTMF_RFC2833 && p->dtmfcodec) {
4661 p->rtp, p->dtmfcodec,
"audio",
"telephone-event", 0);
4663 if (p->dtmfmode & H323_DTMF_CISCO && p->dtmfcodec) {
4666 p->rtp, p->dtmfcodec,
"audio",
"cisco-telephone-event", 0);
4673 if (p->rtptimeout) {
4682 ast_verb(0,
"Setup RTDR info: %d, %d\n", p->rtdrinterval, p->rtdrcount);
4683 call->rtdrInterval = p->rtdrinterval;
4684 call->rtdrCount = p->rtdrcount;
4688 ast_copy_string(mediaInfo.lMediaIP, lhost,
sizeof(mediaInfo.lMediaIP));
4689 mediaInfo.lMediaPort = lport;
4690 mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort + 1;
4694 strcpy(mediaInfo.dir,
"transmit");
4695 mediaInfo.cap = ooh323_convertAsteriskCapToH323Cap(format);
4696 ooAddMediaInfo(call, mediaInfo);
4697 strcpy(mediaInfo.dir,
"receive");
4698 ooAddMediaInfo(call, mediaInfo);
4699 if (mediaInfo.cap == OO_G729A) {
4700 strcpy(mediaInfo.dir,
"transmit");
4701 mediaInfo.cap = OO_G729;
4702 ooAddMediaInfo(call, mediaInfo);
4703 strcpy(mediaInfo.dir,
"receive");
4704 ooAddMediaInfo(call, mediaInfo);
4706 strcpy(mediaInfo.dir,
"transmit");
4707 mediaInfo.cap = OO_G729B;
4708 ooAddMediaInfo(call, mediaInfo);
4709 strcpy(mediaInfo.dir,
"receive");
4710 ooAddMediaInfo(call, mediaInfo);
4717 ast_udptl_get_us(p->udptl, &tmp);
4720 ast_copy_string(mediaInfo.lMediaIP, lhost,
sizeof(mediaInfo.lMediaIP));
4721 mediaInfo.lMediaPort = lport;
4722 mediaInfo.lMediaCntrlPort = mediaInfo.lMediaPort +1;
4723 mediaInfo.cap = OO_T38;
4724 strcpy(mediaInfo.dir,
"transmit");
4725 ooAddMediaInfo(call, mediaInfo);
4726 strcpy(mediaInfo.dir,
"receive");
4727 ooAddMediaInfo(call, mediaInfo);
4731 ast_verb(0,
"+++ configure_local_rtp\n");
4736 void setup_rtp_remote(ooCallData *call,
const char *remoteIp,
int remotePort)
4742 ast_verb(0,
"--- setup_rtp_remote %s:%d\n", remoteIp, remotePort);
4744 if (!remoteIp || !remoteIp[0] || !remotePort) {
4746 ast_verb(0,
"+++ setup_rtp_remote no data\n");
4752 p = find_call(call);
4754 if (!p || !p->rtp) {
4755 ast_log(LOG_ERROR,
"Something is wrong: rtp\n");
4759 ast_mutex_lock(&p->lock);
4765 ast_mutex_unlock(&p->lock);
4768 ast_verb(0,
"+++ setup_rtp_remote\n");
4775 void setup_rtp_connection(ooCallData *call,
const char *remoteIp,
int remotePort)
4781 ast_verb(0,
"--- setup_rtp_connection %s:%d\n", remoteIp, remotePort);
4784 p = find_call(call);
4786 if (!p || !p->rtp) {
4787 ast_log(LOG_ERROR,
"Something is wrong: rtp\n");
4791 ast_mutex_lock(&p->lock);
4802 ast_mutex_unlock(&p->lock);
4805 ast_verb(0,
"+++ setup_rtp_connection\n");
4810 void close_rtp_connection(ooCallData *call)
4815 ast_verb(0,
"--- close_rtp_connection\n");
4817 p = find_call(call);
4819 ast_log(LOG_ERROR,
"Couldn't find matching call to close rtp "
4823 ast_mutex_lock(&p->lock);
4827 ast_mutex_unlock(&p->lock);
4830 ast_verb(0,
"+++ close_rtp_connection\n");
4839 void setup_udptl_connection(ooCallData *call,
const char *remoteIp,
4846 ast_verb(0,
"--- setup_udptl_connection\n");
4849 p = find_call(call);
4852 ast_log(LOG_ERROR,
"Something is wrong: rtp\n");
4856 ast_mutex_lock(&p->lock);
4858 while (p->owner && ast_channel_trylock(p->owner)) {
4859 ast_debug(1,
"Failed to grab lock, trying again\n");
4860 DEADLOCK_AVOIDANCE(&p->lock);
4863 ast_mutex_unlock(&p->lock);
4864 ast_log(LOG_ERROR,
"Channel has no owner\n");
4868 ast_mutex_unlock(&p->lock);
4869 ast_log(LOG_ERROR,
"Channel has no owner\n");
4876 ast_udptl_set_peer(p->udptl, &them);
4878 p->t38_tx_enable = 1;
4879 p->lastTxT38 = time(NULL);
4880 if (p->t38support == T38_ENABLED) {
4884 parameters.
rate = AST_T38_RATE_14400;
4892 ast_channel_unlock(p->owner);
4893 ast_mutex_unlock(&p->lock);
4896 ast_verb(0,
"+++ setup_udptl_connection\n");
4901 void close_udptl_connection(ooCallData *call)
4906 ast_verb(0,
"--- close_udptl_connection\n");
4908 p = find_call(call);
4910 ast_log(LOG_ERROR,
"Couldn't find matching call to close udptl "
4914 ast_mutex_lock(&p->lock);
4916 while (p->owner && ast_channel_trylock(p->owner)) {
4917 ast_debug(1,
"Failed to grab lock, trying again\n");
4918 DEADLOCK_AVOIDANCE(&p->lock);
4921 ast_mutex_unlock(&p->lock);
4922 ast_log(LOG_ERROR,
"Channel has no owner\n");
4926 ast_mutex_unlock(&p->lock);
4927 ast_log(LOG_ERROR,
"Channel has no owner\n");
4931 p->t38_tx_enable = 0;
4932 if (p->t38support == T38_ENABLED) {
4938 ast_channel_unlock(p->owner);
4939 ast_mutex_unlock(&p->lock);
4942 ast_verb(0,
"+++ close_udptl_connection\n");
4949 int update_our_aliases(ooCallData *call,
struct ooh323_pvt *p)
4952 ooAliases *psAlias = NULL;
4954 if (!call->ourAliases)
4956 for (psAlias = call->ourAliases; psAlias; psAlias = psAlias->next) {
4957 if (psAlias->type == T_H225AliasAddress_h323_ID) {
4958 ast_copy_string(p->callee_h323id, psAlias->value,
sizeof(p->callee_h323id));
4961 if (psAlias->type == T_H225AliasAddress_dialedDigits) {
4963 sizeof(p->callee_dialedDigits));
4966 if (psAlias->type == T_H225AliasAddress_url_ID) {
4967 ast_copy_string(p->callee_url, psAlias->value,
sizeof(p->callee_url));
4970 if (psAlias->type == T_H225AliasAddress_email_ID) {
4971 ast_copy_string(p->callee_email, psAlias->value,
sizeof(p->callee_email));
4984 switch (ast_channel_fdno(ast)) {
4987 p->lastrtprx = time(NULL);
4994 p->lastrtprx = time(NULL);
5000 f = ast_udptl_read(p->udptl);
5002 ast_debug(1,
"Got UDPTL %u/%d len %d for %s\n",
5005 p->lastrtprx = time(NULL);
5022 ast_channel_nativeformats_set(p->owner, caps);
5028 if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
5043 if (!p->faxmode && !p->chmodepend && (dfr->
subclass.
integer ==
'e') && (p->t38support != T38_DISABLED)) {
5045 ast_verb(0,
"request to change %s to t.38 because fax ced\n", p->callToken);
5048 ooRequestChangeMode(p->callToken, 1);
5050 const char *target_context = ast_channel_context(p->owner);
5051 if ((strcmp(ast_channel_exten(p->owner),
"fax")) &&
5054 ast_verb(2,
"Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
5057 ast_log(LOG_NOTICE,
"Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
5064 }
else if (dfr && dfr->
frametype == AST_FRAME_DTMF) {
5076 void onModeChanged(ooCallData *call,
int t38mode) {
5079 p = find_call(call);
5081 ast_log(LOG_ERROR,
"No matching call found for %s\n", call->callToken);
5085 ast_mutex_lock(&p->lock);
5088 ast_debug(1,
"change mode to %d for %s\n", t38mode, call->callToken);
5090 if (t38mode == p->faxmode) {
5092 ast_debug(1,
"mode for %s is already %d\n", call->callToken,
5095 ast_mutex_unlock(&p->lock);
5100 while (p->owner && ast_channel_trylock(p->owner)) {
5101 ast_debug(1,
"Failed to grab lock, trying again\n");
5102 DEADLOCK_AVOIDANCE(&p->lock);
5106 ast_mutex_unlock(&p->lock);
5107 ast_log(LOG_ERROR,
"Channel has no owner\n");
5112 ast_mutex_unlock(&p->lock);
5113 ast_log(LOG_ERROR,
"Channel has no owner\n");
5120 if (p->t38support == T38_ENABLED) {
5123 if ((p->faxdetect & FAXDETECT_T38) && !p->faxdetected) {
5124 const char *target_context;
5125 ast_debug(1,
"* Detected T.38 Request\n");
5126 target_context = ast_channel_context(p->owner);
5127 if ((strcmp(ast_channel_exten(p->owner),
"fax")) &&
5130 ast_verb(2,
"Redirecting '%s' to fax extension due to CNG detection\n", ast_channel_name(p->owner));
5133 ast_log(LOG_NOTICE,
"Failed to async goto '%s' into fax of '%s'\n", ast_channel_name(p->owner),target_context);
5142 if (call->T38FarMaxDatagram) {
5147 if (call->T38Version) {
5148 parameters.
version = call->T38Version;
5151 parameters.
rate = AST_T38_RATE_14400;
5153 ¶meters,
sizeof(parameters));
5159 if (p->t38support == T38_ENABLED) {
5163 parameters.
rate = AST_T38_RATE_14400;
5165 ¶meters,
sizeof(parameters));
5173 ast_channel_unlock(p->owner);
5174 ast_mutex_unlock(&p->lock);
5179 int ooh323_convert_hangupcause_asteriskToH323(
int cause)
5182 case AST_CAUSE_CALL_REJECTED:
5183 return OO_REASON_REMOTE_REJECTED;
5184 case AST_CAUSE_UNALLOCATED:
5185 return OO_REASON_NOUSER;
5186 case AST_CAUSE_BUSY:
5187 return OO_REASON_REMOTE_BUSY;
5188 case AST_CAUSE_BEARERCAPABILITY_NOTAVAIL:
5189 return OO_REASON_NOCOMMON_CAPABILITIES;
5190 case AST_CAUSE_CONGESTION:
5191 return OO_REASON_REMOTE_BUSY;
5192 case AST_CAUSE_NO_ANSWER:
5193 return OO_REASON_REMOTE_NOANSWER;
5194 case AST_CAUSE_NORMAL:
5195 return OO_REASON_REMOTE_CLEARED;
5196 case AST_CAUSE_FAILURE:
5198 return OO_REASON_UNKNOWN;
5206 int ooh323_convert_hangupcause_h323ToAsterisk(
int cause)
5209 case OO_REASON_REMOTE_REJECTED:
5210 return AST_CAUSE_CALL_REJECTED;
5211 case OO_REASON_NOUSER:
5212 return AST_CAUSE_UNALLOCATED;
5213 case OO_REASON_REMOTE_BUSY:
5214 case OO_REASON_LOCAL_BUSY:
5215 return AST_CAUSE_BUSY;
5216 case OO_REASON_NOCOMMON_CAPABILITIES:
5217 return AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
5218 case OO_REASON_REMOTE_CONGESTED:
5219 case OO_REASON_LOCAL_CONGESTED:
5220 return AST_CAUSE_CONGESTION;
5221 case OO_REASON_REMOTE_NOANSWER:
5222 return AST_CAUSE_NO_ANSWER;
5223 case OO_REASON_UNKNOWN:
5224 case OO_REASON_INVALIDMESSAGE:
5225 case OO_REASON_TRANSPORTFAILURE:
5226 return AST_CAUSE_FAILURE;
5227 case OO_REASON_REMOTE_CLEARED:
5228 return AST_CAUSE_NORMAL;
5230 return AST_CAUSE_NORMAL;
5237 void ast_ooh323c_exit()
5239 ooGkClientDestroy();
5243 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"Objective Systems H323 Channel",
5244 .support_level = AST_MODULE_SUPPORT_EXTENDED,
5245 .load = load_module,
5246 .unload = unload_module,
5247 .reload = reload_module,
5249 .requires =
"udptl",
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
int ast_io_wait(struct io_context *ioc, int howlong)
Waits for IO.
struct ast_variable * next
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress...
Main Channel structure associated with a channel.
#define ast_frdup(fr)
Copies a frame.
char * str
Subscriber phone number (Malloced)
static struct iax2_peer * find_peer(const char *name, int realtime)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
int ast_parse_arg(const char *arg, enum ast_parse_flags flags, void *p_result,...)
The argument parsing routine.
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
struct ast_party_id id
Connected party ID.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
struct ast_party_name name
Subscriber name.
#define DSP_DIGITMODE_DTMF
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
descriptor for a cli entry.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
int ast_rtp_instance_early_bridge(struct ast_channel *c0, struct ast_channel *c1)
Early bridge two channels that use RTP instances.
Structure for variables, used for configurations and for channel variables.
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
enum ast_control_t38 request_response
Structure to pass both assignedid values to channel drivers.
Structure for an UDPTL session.
ast_channel_state
ast_channel states
char * str
Subscriber name (Malloced)
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
ast_t38_state
Possible T38 states on channels.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
void ast_udptl_set_far_max_datagram(struct ast_udptl *udptl, unsigned int max_datagram)
sets far max datagram size. If max_datagram is = 0, the far max datagram size is set to a default val...
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
#define ast_strdup(str)
A wrapper for strdup()
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
char * ast_category_browse(struct ast_config *config, const char *prev_name)
Browse categories.
void ast_update_use_count(void)
Notify when usecount has been changed.
static struct iax2_user * build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create in-memory user structure from configuration.
list of users found in the config file
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Socket address structure.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_frame_subclass subclass
int ast_queue_hangup_with_cause(struct ast_channel *chan, int cause)
Queue a hangup frame with hangupcause set.
static struct ast_jb_conf default_jbconf
Global jitterbuffer configuration.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
struct ast_party_id id
Caller party ID.
#define DSP_DIGITMODE_RELAXDTMF
static struct iax2_peer * build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
Create peer structure based on configuration.
static ast_mutex_t monlock
Protect the monitoring thread, so only one process can kill or start it, and not when it's doing some...
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
#define ast_config_load(filename, flags)
Load a config file.
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
static pthread_t monitor_thread
This is the thread for the monitor which checks for input on the channels which are not currently in ...
void ast_unregister_atexit(void(*func)(void))
Unregister a function registered with ast_register_atexit().
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define ast_strdupa(s)
duplicate a string in memory from the stack
static struct ao2_container * codecs
Registered codecs.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Global IO variables are now in a struct in order to be made threadsafe.
#define AST_MAX_EXTENSION
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
enum ast_control_t38_rate rate
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
static ast_mutex_t iflock
Protect the interface list (of dahdi_pvt's)
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
#define ast_debug(level,...)
Log a DEBUG message.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record tx payload type information that was seen in an a=rtpmap: SDP line.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
#define AST_OPTION_DIGIT_DETECT
unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl)
retrieves far max ifp
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
Support for dynamic strings.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
Connected Line/Party information.
int ast_rtp_instance_dtmf_begin(struct ast_rtp_instance *instance, char digit)
Begin sending a DTMF digit.
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
#define ast_module_ref(mod)
Hold a reference to the module.
struct ast_format_cap * capabilities
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
union ast_frame::@224 data
#define ast_calloc(num, len)
A wrapper for calloc()
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
Module has failed to load, may be in an inconsistent state.
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
structure to hold users read from users.conf
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Structure used to handle boolean flags.
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Indicate what information in ast_party_connected_line should be set.
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
#define ast_module_unref(mod)
Release a reference to the module.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
struct ast_frame ast_null_frame
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static struct dahdi_pvt * iflist
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
void ast_udptl_set_tag(struct ast_udptl *udptl, const char *format,...)
Associates a character string 'tag' with a UDPTL session.
Data structure associated with a single frame of data.
static void delete_users(void)
Delete all users.
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
enum ast_frame_type frametype
Channels have this property if they can create jitter; i.e. most VoIP channels.
unsigned char valid
TRUE if the name information is valid/present.
struct ast_format * format
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
Softly hangup up a channel (no channel lock)
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
void ast_rtp_instance_update_source(struct ast_rtp_instance *instance)
Indicate that the RTP marker bit should be set on an RTP stream.
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
unsigned char valid
TRUE if the number information is valid/present.
#define ast_rtp_instance_get_and_cmp_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to, comparing its address to another...
General jitterbuffer configuration.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
Structure for mutex and tracking information.
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
static char * ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brack...
struct ast_party_number number
Subscriber phone number.
int ast_rtp_instance_dtmf_end(struct ast_rtp_instance *instance, char digit)
Stop sending a DTMF digit.
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...